Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added OpenCL Universal Driver Support for Win10 RS3 #21

Merged
merged 1 commit into from
Oct 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set (OPENCL_ICD_LOADER_SOURCES icd.c icd_dispatch.c)
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
list (APPEND OPENCL_ICD_LOADER_SOURCES icd_linux.c icd_exports.map)
else ()
list (APPEND OPENCL_ICD_LOADER_SOURCES icd_windows.c OpenCL.def)
list (APPEND OPENCL_ICD_LOADER_SOURCES icd_windows.c icd_windows_hkr.c OpenCL.def OpenCL.rc)
include_directories ($ENV{DXSDK_DIR}/Include)
endif ()

Expand All @@ -27,6 +27,8 @@ set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")

if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-pthread -Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/icd_exports.map")
else()
target_link_libraries (OpenCL cfgmgr32.lib)
endif ()

target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
Expand Down
7 changes: 3 additions & 4 deletions OpenCL.rc
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
#ifdef RC_INVOKED

VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,2,0,0
PRODUCTVERSION 2,2,0,0
FILEVERSION 2,2,1,0
PRODUCTVERSION 2,2,1,0
FILETYPE VFT_DLL

BEGIN
Expand All @@ -52,8 +52,7 @@ BEGIN
VALUE "FileDescription" ,"OpenCL Client DLL"
VALUE "ProductName" ,"Khronos OpenCL ICD"
VALUE "LegalCopyright" ,"Copyright \251 The Khronos Group Inc 2016"
VALUE "FileVersion" ,"2.2.0.0"

VALUE "FileVersion" ,"2.2.1.0"
VALUE "CompanyName" ,"Khronos Group"
VALUE "InternalName" ,"OpenCL"
VALUE "OriginalFilename","OpenCL.dll"
Expand Down
11 changes: 11 additions & 0 deletions icd.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void khrIcdVendorAdd(const char *libraryName)
cl_uint i = 0;
cl_uint platformCount = 0;
cl_platform_id *platforms = NULL;
KHRicdVendor *vendorIterator = NULL;

// require that the library name be valid
if (!libraryName)
Expand All @@ -74,6 +75,16 @@ void khrIcdVendorAdd(const char *libraryName)
goto Done;
}

// ensure that we haven't already loaded this vendor
for (vendorIterator = khrIcdVendors; vendorIterator; vendorIterator = vendorIterator->next)
{
if (vendorIterator->library == library)
{
KHR_ICD_TRACE("already loaded vendor %s, nothing to do here\n", libraryName);
goto Done;
}
}

// get the library's clGetExtensionFunctionAddress pointer
p_clGetExtensionFunctionAddress = (pfn_clGetExtensionFunctionAddress)(size_t)khrIcdOsLibraryGetFunctionAddress(library, "clGetExtensionFunctionAddress");
if (!p_clGetExtensionFunctionAddress)
Expand Down
16 changes: 15 additions & 1 deletion icd.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
#include <CL/cl.h>
#include <CL/cl_ext.h>

#ifdef _WIN32
#include <tchar.h>
#endif

/*
* type definitions
*/
Expand Down Expand Up @@ -145,7 +149,16 @@ void khrIcdContextPropertiesGetPlatform(
fprintf(stderr, "KHR ICD trace at %s:%d: ", __FILE__, __LINE__); \
fprintf(stderr, __VA_ARGS__); \
} while (0)

#ifdef _WIN32
#define KHR_ICD_WIDE_TRACE(...) \
do \
{ \
fwprintf(stderr, L"KHR ICD trace at %hs:%d: ", __FILE__, __LINE__); \
fwprintf(stderr, __VA_ARGS__); \
} while (0)
#else
#define KHR_ICD_WIDE_TRACE(...)
#endif
#define KHR_ICD_ASSERT(x) \
do \
{ \
Expand All @@ -156,6 +169,7 @@ void khrIcdContextPropertiesGetPlatform(
} while (0)
#else
#define KHR_ICD_TRACE(...)
#define KHR_ICD_WIDE_TRACE(...)
#define KHR_ICD_ASSERT(x)
#endif

Expand Down
6 changes: 6 additions & 0 deletions icd_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
*/

#include "icd.h"
#include "icd_windows_hkr.h"
#include <stdio.h>
#include <windows.h>
#include <winreg.h>
Expand All @@ -57,6 +58,11 @@ BOOL CALLBACK khrIcdOsVendorsEnumerate(PINIT_ONCE InitOnce, PVOID Parameter, PVO
HKEY platformsKey = NULL;
DWORD dwIndex;

if (!khrIcdOsVendorsEnumerateHKR())
{
KHR_ICD_TRACE("Failed to enumerate HKR entries, continuing\n");
}

KHR_ICD_TRACE("Opening key HKLM\\%s...\n", platformsName);
result = RegOpenKeyExA(
HKEY_LOCAL_MACHINE,
Expand Down
Loading