diff --git a/source/cl/source/extension/include/extension/khr_command_buffer.h b/source/cl/source/extension/include/extension/khr_command_buffer.h index 42d66801c..eae62e7cc 100644 --- a/source/cl/source/extension/include/extension/khr_command_buffer.h +++ b/source/cl/source/extension/include/extension/khr_command_buffer.h @@ -460,12 +460,13 @@ struct _cl_command_buffer_khr final : public cl::base<_cl_command_buffer_khr> { /// @brief Modify commands in command-buffer /// - /// @param[in] mutable_config New configuration for one or more commands + /// @param[in] mutable_configs List of new configuration for one or more + /// commands. It is only valid to pass pointers to + /// cl_mutable_dispatch_config_khr structs in this list. /// /// @return CL_SUCCESS or appropriate OpenCL error code. cl_int updateCommandBuffer( - cargo::array_view - &mutable_configs); + const cargo::array_view &mutable_configs); /// @brief Verifies whether a queue is compatible with the command-buffer. /// diff --git a/source/cl/source/extension/source/khr_command_buffer.cpp b/source/cl/source/extension/source/khr_command_buffer.cpp index 8fdb63ead..109c3360f 100644 --- a/source/cl/source/extension/source/khr_command_buffer.cpp +++ b/source/cl/source/extension/source/khr_command_buffer.cpp @@ -1072,13 +1072,15 @@ cargo::expected createArgumentDescriptor( } // anonymous namespace [[nodiscard]] cl_int _cl_command_buffer_khr::updateCommandBuffer( - cargo::array_view - &mutable_dispatch_configs) { + const cargo::array_view &mutable_configs) { const std::lock_guard guard(mutex); const cl_device_id device = command_queue->device; // Verify struct configures kernel arguments and return error if malformed - for (const auto &config_ptr : mutable_dispatch_configs) { + for (const auto &mutable_config : mutable_configs) { + auto config_ptr = + static_cast(mutable_config); + OCL_CHECK(config_ptr == nullptr, return CL_INVALID_VALUE); const cl_mutable_dispatch_config_khr &config = *config_ptr; OCL_CHECK(!config.command, return CL_INVALID_MUTABLE_COMMAND_KHR); @@ -1094,7 +1096,10 @@ cargo::expected createArgumentDescriptor( return CL_INVALID_OPERATION); } - for (auto config : mutable_dispatch_configs) { + for (const auto &mutable_config : mutable_configs) { + auto config = + static_cast(mutable_config); + unsigned update_index = 0; const unsigned num_args = config->num_args + config->num_svm_args; UpdateInfo update_info; diff --git a/source/cl/source/extension/source/khr_command_buffer_mutable_dispatch.cpp b/source/cl/source/extension/source/khr_command_buffer_mutable_dispatch.cpp index 28537b755..97cc0c6fd 100644 --- a/source/cl/source/extension/source/khr_command_buffer_mutable_dispatch.cpp +++ b/source/cl/source/extension/source/khr_command_buffer_mutable_dispatch.cpp @@ -115,12 +115,8 @@ CL_API_ENTRY cl_int CL_API_CALL clUpdateMutableCommandsKHR( } } - const cl_mutable_dispatch_config_khr **casted_configs = - reinterpret_cast(configs); - cargo::array_view - mutable_dispatch_configs(casted_configs, num_configs); - - return command_buffer->updateCommandBuffer(mutable_dispatch_configs); + cargo::array_view config_array(configs, num_configs); + return command_buffer->updateCommandBuffer(config_array); } CL_API_ENTRY cl_int CL_API_CALL clGetMutableCommandInfoKHR(