From 5ca6f4cee300ea12fe3616a6499c40043aeff59b Mon Sep 17 00:00:00 2001 From: Ben Ashbaugh Date: Wed, 6 Nov 2024 21:08:46 -0800 Subject: [PATCH] fixes for Windows --- samples/extensions/khr/externalmemory/main.c | 6 ++++-- samples/extensions/khr/externalmemory/main.cpp | 6 ++++-- samples/extensions/khr/externalmemory/vulkan_utils.h | 10 ++++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/samples/extensions/khr/externalmemory/main.c b/samples/extensions/khr/externalmemory/main.c index 330576b4..59ea67c9 100644 --- a/samples/extensions/khr/externalmemory/main.c +++ b/samples/extensions/khr/externalmemory/main.c @@ -575,10 +575,11 @@ int main(int argc, char* argv[]) // Create OpenCL buffers from Vulkan external memory file descriptors. cl_mem_properties ext_mem_props_x[] = { - (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR, #ifdef _WIN32 + (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR, (cl_mem_properties)handle_x, #else + (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR, (cl_mem_properties)fd_x, #endif (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_KHR, @@ -587,10 +588,11 @@ int main(int argc, char* argv[]) 0 }; cl_mem_properties ext_mem_props_y[] = { - (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR, #ifdef _WIN32 + (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR, (cl_mem_properties)handle_y, #else + (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR, (cl_mem_properties)fd_y, #endif (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_KHR, diff --git a/samples/extensions/khr/externalmemory/main.cpp b/samples/extensions/khr/externalmemory/main.cpp index 2f6c7e8b..ef929819 100644 --- a/samples/extensions/khr/externalmemory/main.cpp +++ b/samples/extensions/khr/externalmemory/main.cpp @@ -483,10 +483,11 @@ int main(int argc, char* argv[]) // Create OpenCL buffers from Vulkan external memory file descriptors. std::vector ext_mem_props_x = { - (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR, #ifdef _WIN32 + (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR, (cl_mem_properties)handle_x, #else + (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR, (cl_mem_properties)fd_x, #endif (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_KHR, @@ -495,10 +496,11 @@ int main(int argc, char* argv[]) 0 }; std::vector ext_mem_props_y = { - (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR, #ifdef _WIN32 + (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR, (cl_mem_properties)handle_y, #else + (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR, (cl_mem_properties)fd_y, #endif (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_KHR, diff --git a/samples/extensions/khr/externalmemory/vulkan_utils.h b/samples/extensions/khr/externalmemory/vulkan_utils.h index ff6730e0..74b2c561 100644 --- a/samples/extensions/khr/externalmemory/vulkan_utils.h +++ b/samples/extensions/khr/externalmemory/vulkan_utils.h @@ -278,10 +278,12 @@ find_suitable_device(VkInstance instance, ++platform_id) { cl_uint cl_platform_devices_count = 0; - OCLERROR_RET(clGetDeviceIDs(platforms[platform_id], - CL_DEVICE_TYPE_ALL, 0, NULL, - &cl_platform_devices_count), - error, candidates); + error = clGetDeviceIDs(platforms[platform_id], CL_DEVICE_TYPE_ALL, 0, + NULL, &cl_platform_devices_count); + if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND) + { + goto candidates; + } for (cl_uint cl_candidate_id = 0; cl_candidate_id < cl_platform_devices_count;