From efeae73139ddf064fafce565cc39640af10d900f Mon Sep 17 00:00:00 2001 From: Ben Ashbaugh Date: Tue, 10 Oct 2023 22:13:58 -0700 Subject: [PATCH] add support for semaphore-specific device handle list enums (#94) --- layers/10_cmdbufemu/README.md | 2 +- layers/11_semaemu/README.md | 2 +- layers/11_semaemu/emulate.cpp | 16 ++++++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/layers/10_cmdbufemu/README.md b/layers/10_cmdbufemu/README.md index e93660a..169b47e 100644 --- a/layers/10_cmdbufemu/README.md +++ b/layers/10_cmdbufemu/README.md @@ -7,7 +7,7 @@ It works by intercepting calls to `clGetExtensionFunctionAddressForPlatform` to If a query succeeds by default then the layer does nothing and simply returns the queried function pointer as-is. If the query is unsuccessful however, then the layer returns its own function pointer, which will record the contents of the command buffer for later playback. -This command buffer emulation layer currently implements v0.9.0 of the `cl_khr_command_buffer` extension and v0.9.0 of the `cl_khr_command_buffer_mutable_dispatch` extension. +This command buffer emulation layer currently implements v0.9.4 of the `cl_khr_command_buffer` extension and v0.9.0 of the `cl_khr_command_buffer_mutable_dispatch` extension. The functionality in this emulation layer is sufficient to run the command buffer samples in this repository. Please note that the emulated command buffers are intended to be functional, but unlike a native implementation, they may not provide any performance benefit over similar code without using command buffers. diff --git a/layers/11_semaemu/README.md b/layers/11_semaemu/README.md index ef99b09..84418df 100644 --- a/layers/11_semaemu/README.md +++ b/layers/11_semaemu/README.md @@ -7,7 +7,7 @@ It works by intercepting calls to `clGetExtensionFunctionAddressForPlatform` to If a query succeeds by default then the layer does nothing and simply returns the queried function pointer as-is. If the query is unsuccessful however, then the layer returns its own function pointer, which will emulate semaphores using events. -This semaphore emulation layer currently implements v0.9.0 of the `cl_khr_semaphore` extension. +This semaphore emulation layer currently implements v0.9.1 of the `cl_khr_semaphore` extension. The functionality in this emulation layer is sufficient to run the semaphore samples in this repository. Please note that the emulated semaphores are intended to be functional, but unlike a native implementation, they may not provide any performance benefit over similar code without using semaphores. diff --git a/layers/11_semaemu/emulate.cpp b/layers/11_semaemu/emulate.cpp index f651347..4202063 100644 --- a/layers/11_semaemu/emulate.cpp +++ b/layers/11_semaemu/emulate.cpp @@ -21,9 +21,13 @@ #ifndef CL_KHR_SEMAPHORE_EXTENSION_NAME #define CL_KHR_SEMAPHORE_EXTENSION_NAME "cl_khr_semaphore" #endif +#ifndef CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR +#define CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR 0x2053 +#define CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR 0 +#endif static constexpr cl_version version_cl_khr_semaphore = - CL_MAKE_VERSION(0, 9, 0); + CL_MAKE_VERSION(0, 9, 1); SLayerContext& getLayerContext(void) { @@ -48,7 +52,7 @@ typedef struct _cl_semaphore_khr { const cl_semaphore_properties_khr* check = properties; bool found_CL_SEMAPHORE_TYPE_KHR = false; - bool found_CL_DEVICE_HANDLE_LIST_KHR = false; + bool found_CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR = false; while( errorCode == CL_SUCCESS && check[0] != 0 ) { cl_int property = (cl_int)check[0]; @@ -66,16 +70,16 @@ typedef struct _cl_semaphore_khr check += 2; } break; - case CL_DEVICE_HANDLE_LIST_KHR: - if( found_CL_DEVICE_HANDLE_LIST_KHR ) + case CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR: + if( found_CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR ) { errorCode = CL_INVALID_VALUE; } else { - found_CL_DEVICE_HANDLE_LIST_KHR = true; + found_CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR = true; ++check; - while(*check++ != CL_DEVICE_HANDLE_LIST_END_KHR) + while(*check++ != CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR) { // TODO: validate device handles. }