From e3eeee486636c0717e66c9a0ae216339abb14ddd Mon Sep 17 00:00:00 2001 From: Ben Ashbaugh Date: Tue, 4 Aug 2026 11:34:39 -0700 Subject: [PATCH] check that devices match in the command buffer emulation layer This error condition specifically: CL_INVALID_DEVICE if any element of queues does not have the same device as the command-queue set on command_buffer creation at the same list index. --- layers/10_cmdbufemu/emulate.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/layers/10_cmdbufemu/emulate.cpp b/layers/10_cmdbufemu/emulate.cpp index 4b475fe..526d83a 100644 --- a/layers/10_cmdbufemu/emulate.cpp +++ b/layers/10_cmdbufemu/emulate.cpp @@ -1503,6 +1503,14 @@ typedef struct _cl_command_buffer_khr &cmdbuf_context, nullptr); + cl_device_id cmdbuf_device = nullptr; + g_pNextDispatch->clGetCommandQueueInfo( + getQueue(), + CL_QUEUE_DEVICE, + sizeof(cmdbuf_device), + &cmdbuf_device, + nullptr); + for( cl_uint q = 0; q < num_queues && queues; q++ ) { if( queues[q] == nullptr ) @@ -1521,6 +1529,18 @@ typedef struct _cl_command_buffer_khr { return CL_INVALID_CONTEXT; } + + cl_device_id queue_device = nullptr; + g_pNextDispatch->clGetCommandQueueInfo( + queues[q], + CL_QUEUE_DEVICE, + sizeof(queue_device), + &queue_device, + nullptr); + if( queue_device != cmdbuf_device ) + { + return CL_INVALID_DEVICE; + } } // CL_INCOMPATIBLE_COMMAND_QUEUE_KHR if any element of queues is not compatible with the command-queue set on command_buffer creation at the same list index.