From 7b0f1810b6bb4b279e8336dc1080de35a628e963 Mon Sep 17 00:00:00 2001 From: Ben Ashbaugh Date: Tue, 12 Mar 2024 12:51:11 -0700 Subject: [PATCH] validate command buffer creation flags (#110) This is needed to pass the new command buffer negative tests. --- layers/10_cmdbufemu/emulate.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/layers/10_cmdbufemu/emulate.cpp b/layers/10_cmdbufemu/emulate.cpp index 2fae532..e465ab7 100644 --- a/layers/10_cmdbufemu/emulate.cpp +++ b/layers/10_cmdbufemu/emulate.cpp @@ -1197,6 +1197,7 @@ typedef struct _cl_command_buffer_khr { found_CL_COMMAND_BUFFER_FLAGS_KHR = true; flags = ((const cl_command_buffer_flags_khr*)(check + 1))[0]; + errorCode = validateCreateCommandBufferFlags( flags ); check += 2; } break; @@ -1246,6 +1247,19 @@ typedef struct _cl_command_buffer_khr return cmdbuf && cmdbuf->Magic == cMagic; } + static cl_int validateCreateCommandBufferFlags( + cl_command_buffer_flags_khr flags ) + { + const cl_command_buffer_flags_khr allFlags = + CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR; + if( flags & ~allFlags ) + { + return CL_INVALID_VALUE; + } + + return CL_SUCCESS; + } + cl_int retain() { RefCount.fetch_add(1, std::memory_order_relaxed);