Skip to content

Commit

Permalink
Vulkan interop coverage (#1887)
Browse files Browse the repository at this point in the history
Added Code changes for 1D, 1DList, 3D, 3DList and test cases.
  • Loading branch information
pkaur19 authored May 28, 2024
1 parent d53d7bc commit 1433ffe
Show file tree
Hide file tree
Showing 10 changed files with 695 additions and 0 deletions.
102 changes: 102 additions & 0 deletions test_conformance/common/vulkan_wrapper/vulkan_list_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,57 @@ VulkanBufferList::~VulkanBufferList()
}
}

//////////////////////////////////////
// VulkanImage1DList implementation //
//////////////////////////////////////

VulkanImage1DList::VulkanImage1DList(const VulkanImage1DList &image1DList) {}

VulkanImage1DList::VulkanImage1DList(
size_t numImages, std::vector<VulkanDeviceMemory *> &deviceMemory,
uint64_t baseOffset, uint64_t interImageOffset, const VulkanDevice &device,
VulkanFormat format, uint32_t width, uint32_t mipLevels,
VulkanImageTiling vulkanImageTiling,
VulkanExternalMemoryHandleType externalMemoryHandleType,
VulkanImageCreateFlag imageCreateFlag, VulkanImageUsage imageUsage,
VulkanSharingMode sharingMode)
{
for (size_t i2DIdx = 0; i2DIdx < numImages; i2DIdx++)
{
VulkanImage1D *image2D = new VulkanImage1D(
device, format, width, vulkanImageTiling, mipLevels,
externalMemoryHandleType, imageCreateFlag, imageUsage, sharingMode);
add(*image2D);
deviceMemory[i2DIdx]->bindImage(
*image2D, baseOffset + (i2DIdx * interImageOffset));
}
}

VulkanImage1DList::VulkanImage1DList(
size_t numImages, const VulkanDevice &device, VulkanFormat format,
uint32_t width, VulkanImageTiling vulkanImageTiling, uint32_t mipLevels,
VulkanExternalMemoryHandleType externalMemoryHandleType,
VulkanImageCreateFlag imageCreateFlag, VulkanImageUsage imageUsage,
VulkanSharingMode sharingMode)
{
for (size_t bIdx = 0; bIdx < numImages; bIdx++)
{
VulkanImage1D *image2D = new VulkanImage1D(
device, format, width, vulkanImageTiling, mipLevels,
externalMemoryHandleType, imageCreateFlag, imageUsage, sharingMode);
add(*image2D);
}
}

VulkanImage1DList::~VulkanImage1DList()
{
for (size_t i2DIdx = 0; i2DIdx < m_wrapperList.size(); i2DIdx++)
{
VulkanImage1D &image2D = m_wrapperList[i2DIdx];
delete &image2D;
}
}

//////////////////////////////////////
// VulkanImage2DList implementation //
//////////////////////////////////////
Expand Down Expand Up @@ -319,6 +370,57 @@ VulkanImage2DList::~VulkanImage2DList()
}
}

//////////////////////////////////////
// VulkanImage3DList implementation //
//////////////////////////////////////

VulkanImage3DList::VulkanImage3DList(const VulkanImage3DList &image3DList) {}

VulkanImage3DList::VulkanImage3DList(
size_t numImages, std::vector<VulkanDeviceMemory *> &deviceMemory,
uint64_t baseOffset, uint64_t interImageOffset, const VulkanDevice &device,
VulkanFormat format, uint32_t width, uint32_t height, uint32_t depth,
uint32_t mipLevels, VulkanImageTiling vulkanImageTiling,
VulkanExternalMemoryHandleType externalMemoryHandleType,
VulkanImageCreateFlag imageCreateFlag, VulkanImageUsage imageUsage,
VulkanSharingMode sharingMode)
{
for (size_t i2DIdx = 0; i2DIdx < numImages; i2DIdx++)
{
VulkanImage3D *image3D = new VulkanImage3D(
device, format, width, height, depth, vulkanImageTiling, mipLevels,
externalMemoryHandleType, imageCreateFlag, imageUsage, sharingMode);
add(*image3D);
deviceMemory[i2DIdx]->bindImage(
*image3D, baseOffset + (i2DIdx * interImageOffset));
}
}

VulkanImage3DList::VulkanImage3DList(
size_t numImages, const VulkanDevice &device, VulkanFormat format,
uint32_t width, uint32_t height, uint32_t depth,
VulkanImageTiling vulkanImageTiling, uint32_t mipLevels,
VulkanExternalMemoryHandleType externalMemoryHandleType,
VulkanImageCreateFlag imageCreateFlag, VulkanImageUsage imageUsage,
VulkanSharingMode sharingMode)
{
for (size_t bIdx = 0; bIdx < numImages; bIdx++)
{
VulkanImage3D *image3D = new VulkanImage3D(
device, format, width, height, depth, vulkanImageTiling, mipLevels,
externalMemoryHandleType, imageCreateFlag, imageUsage, sharingMode);
add(*image3D);
}
}

VulkanImage3DList::~VulkanImage3DList()
{
for (size_t i2DIdx = 0; i2DIdx < m_wrapperList.size(); i2DIdx++)
{
VulkanImage3D &image3D = m_wrapperList[i2DIdx];
delete &image3D;
}
}
////////////////////////////////////////
// VulkanImageViewList implementation //
////////////////////////////////////////
Expand Down
59 changes: 59 additions & 0 deletions test_conformance/common/vulkan_wrapper/vulkan_list_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,35 @@ class VulkanBufferList : public VulkanList<VulkanBuffer, VkBuffer> {
virtual ~VulkanBufferList();
};

class VulkanImage1DList : public VulkanList<VulkanImage1D, VkImage> {
protected:
VulkanImage1DList(const VulkanImage1DList &image1DList);

public:
VulkanImage1DList(
size_t numImages, std::vector<VulkanDeviceMemory *> &deviceMemory,
uint64_t baseOffset, uint64_t interImageOffset,
const VulkanDevice &device, VulkanFormat format, uint32_t width,
uint32_t mipLevels, VulkanImageTiling vulkanImageTiling,
VulkanExternalMemoryHandleType externalMemoryHandleType =
VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_NONE,
VulkanImageCreateFlag imageCreateFlag = VULKAN_IMAGE_CREATE_FLAG_NONE,
VulkanImageUsage imageUsage =
VULKAN_IMAGE_USAGE_SAMPLED_STORAGE_TRANSFER_SRC_DST,
VulkanSharingMode sharingMode = VULKAN_SHARING_MODE_EXCLUSIVE);
VulkanImage1DList(
size_t numImages, const VulkanDevice &device, VulkanFormat format,
uint32_t width, VulkanImageTiling vulkanImageTiling,
uint32_t mipLevels = 1,
VulkanExternalMemoryHandleType externalMemoryHandleType =
VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_NONE,
VulkanImageCreateFlag imageCreateFlag = VULKAN_IMAGE_CREATE_FLAG_NONE,
VulkanImageUsage imageUsage =
VULKAN_IMAGE_USAGE_SAMPLED_STORAGE_TRANSFER_SRC_DST,
VulkanSharingMode sharingMode = VULKAN_SHARING_MODE_EXCLUSIVE);
virtual ~VulkanImage1DList();
};

class VulkanImage2DList : public VulkanList<VulkanImage2D, VkImage> {
protected:
VulkanImage2DList(const VulkanImage2DList &image2DList);
Expand Down Expand Up @@ -232,6 +261,36 @@ class VulkanImage2DList : public VulkanList<VulkanImage2D, VkImage> {
virtual ~VulkanImage2DList();
};

class VulkanImage3DList : public VulkanList<VulkanImage3D, VkImage> {
protected:
VulkanImage3DList(const VulkanImage3DList &image3DList);

public:
VulkanImage3DList(
size_t numImages, std::vector<VulkanDeviceMemory *> &deviceMemory,
uint64_t baseOffset, uint64_t interImageOffset,
const VulkanDevice &device, VulkanFormat format, uint32_t width,
uint32_t height, uint32_t depth, uint32_t mipLevels,
VulkanImageTiling vulkanImageTiling,
VulkanExternalMemoryHandleType externalMemoryHandleType =
VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_NONE,
VulkanImageCreateFlag imageCreateFlag = VULKAN_IMAGE_CREATE_FLAG_NONE,
VulkanImageUsage imageUsage =
VULKAN_IMAGE_USAGE_SAMPLED_STORAGE_TRANSFER_SRC_DST,
VulkanSharingMode sharingMode = VULKAN_SHARING_MODE_EXCLUSIVE);
VulkanImage3DList(
size_t numImages, const VulkanDevice &device, VulkanFormat format,
uint32_t width, uint32_t height, uint32_t depth,
VulkanImageTiling vulkanImageTiling, uint32_t mipLevels = 1,
VulkanExternalMemoryHandleType externalMemoryHandleType =
VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_NONE,
VulkanImageCreateFlag imageCreateFlag = VULKAN_IMAGE_CREATE_FLAG_NONE,
VulkanImageUsage imageUsage =
VULKAN_IMAGE_USAGE_SAMPLED_STORAGE_TRANSFER_SRC_DST,
VulkanSharingMode sharingMode = VULKAN_SHARING_MODE_EXCLUSIVE);
virtual ~VulkanImage3DList();
};

class VulkanImageViewList : public VulkanList<VulkanImageView, VkImageView> {
protected:
VulkanImageViewList(const VulkanImageViewList &imageViewList);
Expand Down
61 changes: 61 additions & 0 deletions test_conformance/common/vulkan_wrapper/vulkan_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1810,6 +1810,36 @@ const VulkanMemoryTypeList &VulkanImage::getMemoryTypeList() const

VulkanImage::operator VkImage() const { return m_vkImage; }

//////////////////////////////////
// VulkanImage1D implementation //
//////////////////////////////////

VulkanImage1D::VulkanImage1D(const VulkanImage1D &image1D): VulkanImage(image1D)
{}

VulkanImage1D::VulkanImage1D(
const VulkanDevice &device, VulkanFormat format, uint32_t width,
VulkanImageTiling imageTiling, uint32_t numMipLevels,
VulkanExternalMemoryHandleType externalMemoryHandleType,
VulkanImageCreateFlag imageCreateFlag, VulkanImageUsage imageUsage,
VulkanSharingMode sharingMode)
: VulkanImage(device, VULKAN_IMAGE_TYPE_1D, format,
VulkanExtent3D(width, 1, 1), numMipLevels, 1,
externalMemoryHandleType, imageCreateFlag, imageTiling,
imageUsage, sharingMode)
{}

VulkanImage1D::~VulkanImage1D() {}

VulkanExtent3D VulkanImage1D::getExtent3D(uint32_t mipLevel) const
{
uint32_t width = std::max(m_extent3D.getWidth() >> mipLevel, uint32_t(1));
uint32_t height = 1;
uint32_t depth = 1;

return VulkanExtent3D(width, height, depth);
}

//////////////////////////////////
// VulkanImage2D implementation //
//////////////////////////////////
Expand Down Expand Up @@ -1840,6 +1870,37 @@ VulkanExtent3D VulkanImage2D::getExtent3D(uint32_t mipLevel) const
return VulkanExtent3D(width, height, depth);
}

//////////////////////////////////
// VulkanImage3D implementation //
//////////////////////////////////

VulkanImage3D::VulkanImage3D(const VulkanImage3D &image3D): VulkanImage(image3D)
{}

VulkanImage3D::VulkanImage3D(
const VulkanDevice &device, VulkanFormat format, uint32_t width,
uint32_t height, uint32_t depth, VulkanImageTiling imageTiling,
uint32_t numMipLevels,
VulkanExternalMemoryHandleType externalMemoryHandleType,
VulkanImageCreateFlag imageCreateFlag, VulkanImageUsage imageUsage,
VulkanSharingMode sharingMode)
: VulkanImage(device, VULKAN_IMAGE_TYPE_3D, format,
VulkanExtent3D(width, height, depth), numMipLevels, 1,
externalMemoryHandleType, imageCreateFlag, imageTiling,
imageUsage, sharingMode)
{}

VulkanImage3D::~VulkanImage3D() {}

VulkanExtent3D VulkanImage3D::getExtent3D(uint32_t mipLevel) const
{
uint32_t width = std::max(m_extent3D.getWidth() >> mipLevel, uint32_t(1));
uint32_t height = std::max(m_extent3D.getHeight() >> mipLevel, uint32_t(1));
uint32_t depth = std::max(m_extent3D.getDepth() >> mipLevel, uint32_t(1));

return VulkanExtent3D(width, height, depth);
}

////////////////////////////////////
// VulkanImageView implementation //
////////////////////////////////////
Expand Down
41 changes: 41 additions & 0 deletions test_conformance/common/vulkan_wrapper/vulkan_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,47 @@ class VulkanImage {
operator VkImage() const;
};

class VulkanImage1D : public VulkanImage {
protected:
VkImageView m_vkImageView;

public:
VulkanImage1D(
const VulkanDevice &device, VulkanFormat format, uint32_t width,
VulkanImageTiling imageTiling, uint32_t numMipLevels = 1,
VulkanExternalMemoryHandleType externalMemoryHandleType =
VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_NONE,
VulkanImageCreateFlag imageCreateFlag = VULKAN_IMAGE_CREATE_FLAG_NONE,
VulkanImageUsage imageUsage =
VULKAN_IMAGE_USAGE_SAMPLED_STORAGE_TRANSFER_SRC_DST,
VulkanSharingMode sharingMode = VULKAN_SHARING_MODE_EXCLUSIVE);
virtual ~VulkanImage1D();
virtual VulkanExtent3D getExtent3D(uint32_t mipLevel = 0) const;

VulkanImage1D(const VulkanImage1D &image1D);
};

class VulkanImage3D : public VulkanImage {
protected:
VkImageView m_vkImageView;

public:
VulkanImage3D(
const VulkanDevice &device, VulkanFormat format, uint32_t width,
uint32_t height, uint32_t depth, VulkanImageTiling imageTiling,
uint32_t numMipLevels = 1,
VulkanExternalMemoryHandleType externalMemoryHandleType =
VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_NONE,
VulkanImageCreateFlag imageCreateFlag = VULKAN_IMAGE_CREATE_FLAG_NONE,
VulkanImageUsage imageUsage =
VULKAN_IMAGE_USAGE_SAMPLED_STORAGE_TRANSFER_SRC_DST,
VulkanSharingMode sharingMode = VULKAN_SHARING_MODE_EXCLUSIVE);
virtual ~VulkanImage3D();
virtual VulkanExtent3D getExtent3D(uint32_t mipLevel = 0) const;

VulkanImage3D(const VulkanImage3D &image3D);
};

class VulkanImage2D : public VulkanImage {
protected:
VkImageView m_vkImageView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ class VulkanBuffer;
class VulkanOffset3D;
class VulkanExtent3D;
class VulkanImage;
class VulkanImage1D;
class VulkanImage2D;
class VulkanImage3D;
class VulkanImageView;
class VulkanDeviceMemory;
class VulkanSemaphore;
Expand All @@ -59,7 +61,9 @@ class VulkanQueueList;
class VulkanCommandBufferList;
class VulkanDescriptorSetLayoutList;
class VulkanBufferList;
class VulkanImage1DList;
class VulkanImage2DList;
class VulkanImage3DList;
class VulkanImageViewList;
class VulkanDeviceMemoryList;
class VulkanSemaphoreList;
Expand Down
2 changes: 2 additions & 0 deletions test_conformance/vulkan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ set (${MODULE_NAME}_SOURCES
test_vulkan_interop_buffer.cpp
test_vulkan_interop_image.cpp
test_vulkan_api_consistency.cpp
test_vulkan_api_consistency_for_3dimages.cpp
test_vulkan_api_consistency_for_1dimages.cpp
test_vulkan_platform_device_info.cpp
vulkan_interop_common.cpp
../../test_common/harness/genericThread.cpp
Expand Down
2 changes: 2 additions & 0 deletions test_conformance/vulkan/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ test_definition test_list[] = { ADD_TEST(buffer_single_queue),
ADD_TEST(image_multiple_queue),
ADD_TEST(consistency_external_buffer),
ADD_TEST(consistency_external_image),
ADD_TEST(consistency_external_for_3dimage),
ADD_TEST(consistency_external_for_1dimage),
ADD_TEST(consistency_external_semaphore),
ADD_TEST(platform_info),
ADD_TEST(device_info) };
Expand Down
8 changes: 8 additions & 0 deletions test_conformance/vulkan/procs.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ extern int test_consistency_external_image(cl_device_id device,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_external_for_3dimage(cl_device_id device,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_external_for_1dimage(cl_device_id device,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_external_semaphore(cl_device_id device,
cl_context context,
cl_command_queue queue,
Expand Down
Loading

0 comments on commit 1433ffe

Please sign in to comment.