Skip to content

Commit

Permalink
properly handle the case when multiple layers are enabled (#85)
Browse files Browse the repository at this point in the history
also fix a minor typo
  • Loading branch information
bashbaug authored May 10, 2023
1 parent 7208cb2 commit a434b4e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
14 changes: 5 additions & 9 deletions layers/10_cmdbufemu/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,8 @@ clGetExtensionFunctionAddressForPlatform_layer(
cl_platform_id platform,
const char * func_name)
{
void* ret = g_pNextDispatch->clGetExtensionFunctionAddressForPlatform(
platform,
func_name);

if (ret) {
return ret;
}

// For now, prefer the emulated functions, even if the extension is
// supported natively. Eventually this should become smarter.
CHECK_RETURN_EXTENSION_FUNCTION( clCreateCommandBufferKHR );
CHECK_RETURN_EXTENSION_FUNCTION( clFinalizeCommandBufferKHR );
CHECK_RETURN_EXTENSION_FUNCTION( clRetainCommandBufferKHR );
Expand All @@ -157,7 +151,9 @@ clGetExtensionFunctionAddressForPlatform_layer(
CHECK_RETURN_EXTENSION_FUNCTION( clGetMutableCommandInfoKHR );
#endif // defined(cl_khr_command_buffer_mutable_dispatch)

return nullptr;
return g_pNextDispatch->clGetExtensionFunctionAddressForPlatform(
platform,
func_name);
}

static cl_int CL_API_CALL
Expand Down
14 changes: 5 additions & 9 deletions layers/11_semaemu/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,18 @@ clGetExtensionFunctionAddressForPlatform_layer(
cl_platform_id platform,
const char * func_name)
{
void* ret = g_pNextDispatch->clGetExtensionFunctionAddressForPlatform(
platform,
func_name);

//if (ret) {
// return ret;
//}

// For now, prefer the emulated functions, even if the extension is
// supported natively. Eventually this should become smarter.
CHECK_RETURN_EXTENSION_FUNCTION( clCreateSemaphoreWithPropertiesKHR );
CHECK_RETURN_EXTENSION_FUNCTION( clEnqueueWaitSemaphoresKHR );
CHECK_RETURN_EXTENSION_FUNCTION( clEnqueueSignalSemaphoresKHR );
CHECK_RETURN_EXTENSION_FUNCTION( clGetSemaphoreInfoKHR );
CHECK_RETURN_EXTENSION_FUNCTION( clRetainSemaphoreKHR );
CHECK_RETURN_EXTENSION_FUNCTION( clReleaseSemaphoreKHR );

return nullptr;
return g_pNextDispatch->clGetExtensionFunctionAddressForPlatform(
platform,
func_name);
}

static cl_int CL_API_CALL
Expand Down
2 changes: 1 addition & 1 deletion samples/12_commandbuffers/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ int main(
sizeof(testContext),
&testContext,
NULL );
printf("\t\tCL_COMMAND_BUFFER_CONEXT: %p (%s)\n",
printf("\t\tCL_COMMAND_BUFFER_CONTEXT: %p (%s)\n",
testContext,
testContext == context() ? "matches" : "MISMATCH!");

Expand Down

0 comments on commit a434b4e

Please sign in to comment.