diff --git a/layers/10_cmdbufemu/README.md b/layers/10_cmdbufemu/README.md index ee32b8e..2000279 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.4 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.8 of the `cl_khr_command_buffer` extension and v0.9.5 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. @@ -40,4 +40,5 @@ The following environment variables can modify the behavior of the command buffe This section describes some of the limitations of the emulated `cl_khr_command_buffer` functionality: * Some error conditions are not properly checked for and returned. +* Deferred kernel arguments are supported, but `CL_COMMAND_BUFFER_STATE_FINALIZED_KHR` is not properly handled. * Many functions are not thread safe. diff --git a/layers/10_cmdbufemu/emulate.cpp b/layers/10_cmdbufemu/emulate.cpp index cf58d37..b6ac52e 100644 --- a/layers/10_cmdbufemu/emulate.cpp +++ b/layers/10_cmdbufemu/emulate.cpp @@ -20,9 +20,9 @@ #include "emulate.h" static constexpr cl_version version_cl_khr_command_buffer = - CL_MAKE_VERSION(0, 9, 7); + CL_MAKE_VERSION(0, 9, 8); static constexpr cl_version version_cl_khr_command_buffer_mutable_dispatch = - CL_MAKE_VERSION(0, 9, 3); + CL_MAKE_VERSION(0, 9, 5); SLayerContext& getLayerContext(void) { @@ -2113,6 +2113,13 @@ cl_int CL_API_CALL clEnqueueCommandBufferKHR_EMU( } } + // If the error code is CL_INVALID_KERNEL_ARGS, then there are probably + // deferred kernel arguments and the command buffer is not yet in the + // executable state, therefore we should return CL_INVALID_OPERATION. + if( errorCode == CL_INVALID_KERNEL_ARGS ) + { + errorCode = CL_INVALID_OPERATION; + } return errorCode; } @@ -2821,7 +2828,12 @@ cl_int CL_API_CALL clCommandNDRangeKernelKHR_EMU( nullptr, nullptr ) ) { - return errorCode; + // Ignore CL_INVALID_KERNEL_ARGS errors if this is a mutable + // command in order to handle deferred kernel arguments. + if( !( errorCode == CL_INVALID_KERNEL_ARGS && mutable_handle ) ) + { + return errorCode; + } } }