Skip to content

Commit

Permalink
Support import via NT handle for named resource
Browse files Browse the repository at this point in the history
Minor change to support importing a named resource either
directly using the associated name or via NT handle.
  • Loading branch information
saurabhnv committed Feb 17, 2024
1 parent 7f02192 commit 47d3da4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
13 changes: 7 additions & 6 deletions test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ clExternalMemory::clExternalMemory(const clExternalMemory &externalMemory)
clExternalMemory::clExternalMemory(
const VulkanDeviceMemory *deviceMemory,
VulkanExternalMemoryHandleType externalMemoryHandleType, uint64_t size,
cl_context context, cl_device_id deviceId)
cl_context context, cl_device_id deviceId, cl_bool useNameForImport)
{
int err = 0;
m_externalMemory = NULL;
Expand Down Expand Up @@ -592,7 +592,7 @@ clExternalMemory::clExternalMemory(
ASSERT(0);
#else
const std::wstring &name = deviceMemory->getName();
if (name.size())
if (name.size() && useNameForImport)
{
err = check_external_memory_handle_type(
devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_NAME_KHR);
Expand Down Expand Up @@ -655,7 +655,8 @@ clExternalMemoryImage::clExternalMemoryImage(
const VulkanDeviceMemory &deviceMemory,
VulkanExternalMemoryHandleType externalMemoryHandleType, cl_context context,
size_t totalImageMemSize, size_t imageWidth, size_t imageHeight,
size_t totalSize, const VulkanImage2D &image2D, cl_device_id deviceId)
size_t totalSize, const VulkanImage2D &image2D, cl_device_id deviceId,
cl_bool useNameForImport)
{
cl_int errcode_ret = 0;
std::vector<cl_mem_properties> extMemProperties1;
Expand Down Expand Up @@ -683,7 +684,7 @@ clExternalMemoryImage::clExternalMemoryImage(
{
log_info("Opaque NT handles are only supported on Windows\n");
const std::wstring &name = deviceMemory.getName();
if (name.size())
if (name.size() && useNameForImport)
{
errcode_ret = check_external_memory_handle_type(
devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_NAME_KHR);
Expand Down Expand Up @@ -787,7 +788,7 @@ clExternalSemaphore::~clExternalSemaphore() = default;
clExternalImportableSemaphore::clExternalImportableSemaphore(
const VulkanSemaphore &semaphore, cl_context context,
VulkanExternalSemaphoreHandleType externalSemaphoreHandleType,
cl_device_id deviceId)
cl_device_id deviceId, cl_bool useNameForImport)
: m_deviceSemaphore(semaphore)
{

Expand Down Expand Up @@ -823,7 +824,7 @@ clExternalImportableSemaphore::clExternalImportableSemaphore(
ASSERT(0);
#else
const std::wstring &name = semaphore.getName();
if (name.size())
if (name.size() && useNameForImport)
{
err = check_external_semaphore_handle_type(
devList[0], CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_NAME_KHR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ class clExternalMemory {
clExternalMemory();
clExternalMemory(const VulkanDeviceMemory *deviceMemory,
VulkanExternalMemoryHandleType externalMemoryHandleType,
uint64_t size, cl_context context, cl_device_id deviceId);
uint64_t size, cl_context context, cl_device_id deviceId,
cl_bool useNameForImport = CL_FALSE);

virtual ~clExternalMemory();
cl_mem getExternalMemoryBuffer();
Expand All @@ -109,7 +110,7 @@ class clExternalMemoryImage {
VulkanExternalMemoryHandleType externalMemoryHandleType,
cl_context context, size_t totalImageMemSize, size_t imageWidth,
size_t imageHeight, size_t totalSize, const VulkanImage2D &image2D,
cl_device_id deviceId);
cl_device_id deviceId, cl_bool useNameForImport = CL_FALSE);
virtual ~clExternalMemoryImage();
cl_mem getExternalMemoryImage();
};
Expand Down Expand Up @@ -137,7 +138,7 @@ class clExternalImportableSemaphore : public virtual clExternalSemaphore {
clExternalImportableSemaphore(
const VulkanSemaphore &deviceSemaphore, cl_context context,
VulkanExternalSemaphoreHandleType externalSemaphoreHandleType,
cl_device_id deviceId);
cl_device_id deviceId, cl_bool useNameForImport = CL_FALSE);
~clExternalImportableSemaphore() override;
int wait(cl_command_queue command_queue) override;
int signal(cl_command_queue command_queue) override;
Expand Down

0 comments on commit 47d3da4

Please sign in to comment.