From 4afe48a0fb2975dfc2bae58b115725bf94aa6d20 Mon Sep 17 00:00:00 2001 From: Soren Jorvang Date: Tue, 29 Jun 2010 10:23:40 +0000 Subject: [PATCH] Check for weakly linked OpenCL. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5811 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/OpenCL.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Source/Core/Common/Src/OpenCL.cpp b/Source/Core/Common/Src/OpenCL.cpp index 05cb6112ec..3291820780 100644 --- a/Source/Core/Common/Src/OpenCL.cpp +++ b/Source/Core/Common/Src/OpenCL.cpp @@ -44,13 +44,16 @@ bool Initialize() #if defined(HAVE_OPENCL) && HAVE_OPENCL if(g_context) return false; - int err; // error code returned from api calls + int err; // error code returned from api calls #ifdef _WIN32 - clrInit(); - if(!clrHasOpenCL()) - return false; + clrInit(); + if(!clrHasOpenCL()) + return false; #endif + // If OpenCL is weakly linked and not found, its symbols will be NULL + if (clGetPlatformIDs == NULL) + return false; // Connect to a compute device cl_uint numPlatforms; @@ -173,8 +176,8 @@ cl_kernel CompileKernel(cl_program program, const char *Function) cl_kernel kernel = clCreateKernel(program, Function, &err); if (!kernel || err != CL_SUCCESS) { - char buffer[1024]; - sprintf(buffer, "Failed to create compute kernel '%s' !", Function); + char buffer[1024]; + sprintf(buffer, "Failed to create compute kernel '%s' !", Function); HandleCLError(err, buffer); return NULL; }