Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhiljnv authored Sep 28, 2020
2 parents 98ca71f + 8f7f56d commit 97f0eb5
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 20 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ if (WIN32)
# only required in rare cases.
if (DEFINED ENV{DXSDK_DIR} AND NOT (MINGW OR MSYS OR CYGWIN))
include_directories ($ENV{DXSDK_DIR}/Include)
include_directories ($ENV{WDK}/km)
endif ()
else ()
# By default don't include OpenCL 3.0 symbol definitions (i.e. comment them
Expand Down Expand Up @@ -112,6 +113,7 @@ set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
target_include_directories(OpenCL SYSTEM PUBLIC ${OPENCL_ICD_LOADER_HEADERS_DIR})

if (WIN32)

target_link_libraries (OpenCL cfgmgr32.lib runtimeobject.lib)

option (OPENCL_ICD_LOADER_DISABLE_OPENCLON12 "Disable support for OpenCLOn12. Support for OpenCLOn12 should only be disabled when building an import lib to link with, and must be enabled when building an ICD loader for distribution!" OFF)
Expand Down
5 changes: 5 additions & 0 deletions loader/icd.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ void khrIcdContextPropertiesGetPlatform(
const cl_context_properties *properties,
cl_platform_id *outPlatform);

// translate device type to platform
void khrIcdDeviceTypeGetPlatform(
cl_device_type device_type,
cl_platform_id *outPlatform);

// internal tracing macros
#if 0
#include <stdio.h>
Expand Down
5 changes: 5 additions & 0 deletions loader/windows/OpenCL.rc
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@
OPENCL_ICD_LOADER_TOSTRING(OPENCL_ICD_LOADER_VERSION_REV)

VS_VERSION_INFO VERSIONINFO
<<<<<<< HEAD

This comment has been minimized.

Copy link
@ben-clayton

ben-clayton Sep 28, 2020

Looks like you have a merge conflict submitted here.

FILEVERSION 2,2,2,0
PRODUCTVERSION 2,2,2,0
=======
FILEVERSION OPENCL_ICD_LOADER_VERSION_MAJOR,OPENCL_ICD_LOADER_VERSION_MINOR,OPENCL_ICD_LOADER_VERSION_REV,0
PRODUCTVERSION OPENCL_ICD_LOADER_VERSION_MAJOR,OPENCL_ICD_LOADER_VERSION_MINOR,OPENCL_ICD_LOADER_VERSION_REV,0
>>>>>>> KhronosGroup-master
FILETYPE VFT_DLL

BEGIN
Expand Down
26 changes: 11 additions & 15 deletions loader/windows/icd_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "icd_windows_dxgk.h"
#include "icd_windows_apppackage.h"
#include <stdio.h>
#include <windows.h>
#include <winreg.h>

#include <initguid.h>
Expand All @@ -45,7 +44,7 @@ static WinAdapter* pWinAdapterCapacity = NULL;

BOOL adapterAdd(const char* szName, LUID luid)
{
BOOL result = TRUE;
BOOL result = TRUE;
if (pWinAdapterEnd == pWinAdapterCapacity)
{
size_t oldCapacity = pWinAdapterCapacity - pWinAdapterBegin;
Expand All @@ -55,20 +54,15 @@ BOOL adapterAdd(const char* szName, LUID luid)
newCapacity = 1;
}
else if(newCapacity < UINT_MAX/2)
{
{
newCapacity *= 2;
}

WinAdapter* pNewBegin = malloc(newCapacity * sizeof(*pWinAdapterBegin));
WinAdapter* pNewBegin = realloc(pWinAdapterBegin, newCapacity * sizeof(*pWinAdapterBegin));
if (!pNewBegin)
result = FALSE;
else
{
if (pWinAdapterBegin)
{
memcpy(pNewBegin, pWinAdapterBegin, oldCapacity * sizeof(*pWinAdapterBegin));
free(pWinAdapterBegin);
}
pWinAdapterCapacity = pNewBegin + newCapacity;
pWinAdapterEnd = pNewBegin + oldCapacity;
pWinAdapterBegin = pNewBegin;
Expand All @@ -80,8 +74,8 @@ BOOL adapterAdd(const char* szName, LUID luid)
pWinAdapterEnd->szName = malloc(nameLen);
if (!pWinAdapterEnd->szName)
result = FALSE;
else
{
else
{
memcpy(pWinAdapterEnd->szName, szName, nameLen);
pWinAdapterEnd->luid = luid;
++pWinAdapterEnd;
Expand All @@ -94,6 +88,7 @@ void adapterFree(WinAdapter *pWinAdapter)
{
free(pWinAdapter->szName);
pWinAdapter->szName = NULL;
pWinAdapter->luid = ZeroLuid;
}

/*
Expand All @@ -119,7 +114,7 @@ BOOL CALLBACK khrIcdOsVendorsEnumerate(PINIT_ONCE InitOnce, PVOID Parameter, PVO
{
KHR_ICD_TRACE("Failed to load via DXGK interface on RS4, continuing\n");
status |= khrIcdOsVendorsEnumerateHKR();
if (!status)
if (!status)
{
KHR_ICD_TRACE("Failed to enumerate HKR entries, continuing\n");
}
Expand Down Expand Up @@ -190,8 +185,8 @@ BOOL CALLBACK khrIcdOsVendorsEnumerate(PINIT_ONCE InitOnce, PVOID Parameter, PVO
{
IDXGIFactory* pFactory = NULL;
PFN_CREATE_DXGI_FACTORY pCreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY)GetProcAddress(hDXGI, "CreateDXGIFactory");
if (pCreateDXGIFactory)
{
if (pCreateDXGIFactory)
{
HRESULT hr = pCreateDXGIFactory(&IID_IDXGIFactory, &pFactory);
if (SUCCEEDED(hr))
{
Expand All @@ -210,10 +205,11 @@ BOOL CALLBACK khrIcdOsVendorsEnumerate(PINIT_ONCE InitOnce, PVOID Parameter, PVO
khrIcdVendorAdd(iterAdapter->szName);
break;
}
}
}
}

pAdapter->lpVtbl->Release(pAdapter);
pAdapter->lpVtbl->Release(pAdapter);
}
pFactory->lpVtbl->Release(pFactory);
}
Expand Down
7 changes: 6 additions & 1 deletion loader/windows/icd_windows_dxgk.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ bool khrIcdOsVendorsEnumerateDXGK(void)
{
bool ret = false;
int result = 0;

// Get handle to GDI Runtime
HMODULE h = LoadLibrary("gdi32.dll");
if (h == NULL)
Expand All @@ -42,6 +41,7 @@ bool khrIcdOsVendorsEnumerateDXGK(void)
if(GetProcAddress(h, "D3DKMTSubmitPresentBltToHwQueue")) // OS Version check
{
LoaderEnumAdapters2 EnumAdapters;

NTSTATUS status = STATUS_SUCCESS;

char cszLibraryName[MAX_PATH] = { 0 };
Expand All @@ -63,6 +63,7 @@ bool khrIcdOsVendorsEnumerateDXGK(void)
{
EnumAdapters.adapter_count = 0;
EnumAdapters.adapters = NULL;

status = pEnumAdapters2(&EnumAdapters);
if (status == STATUS_BUFFER_TOO_SMALL)
{
Expand All @@ -82,6 +83,7 @@ bool khrIcdOsVendorsEnumerateDXGK(void)
KHR_ICD_TRACE("Allocation failure for adapters buffer\n");
goto out;
}

status = pEnumAdapters2(&EnumAdapters);
if (!NT_SUCCESS(status))
{
Expand All @@ -90,7 +92,9 @@ bool khrIcdOsVendorsEnumerateDXGK(void)
}
const char* cszOpenCLRegKeyName = getOpenCLRegKeyName();
const int szOpenCLRegKeyName = (int)(strlen(cszOpenCLRegKeyName) + 1)*sizeof(cszOpenCLRegKeyName[0]);

for (UINT AdapterIndex = 0; AdapterIndex < EnumAdapters.adapter_count; AdapterIndex++)

{
LoaderQueryRegistryInfo queryArgs = {0};
LoaderQueryRegistryInfo* pQueryArgs = &queryArgs;
Expand Down Expand Up @@ -132,6 +136,7 @@ bool khrIcdOsVendorsEnumerateDXGK(void)
continue;
}
}

if (NT_SUCCESS(status) && pQueryArgs->status == LOADER_QUERY_REGISTRY_STATUS_BUFFER_OVERFLOW)
{
ULONG queryBufferSize = sizeof(LoaderQueryRegistryInfo) + queryArgs.output_value_size;
Expand Down
6 changes: 4 additions & 2 deletions loader/windows/icd_windows_hkr.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/

#include "icd.h"
#include "icd_windows_hkr.h"
#include <windows.h>
#include "icd_windows_dxgk.h"
#include <cfgmgr32.h>
Expand Down Expand Up @@ -129,7 +128,7 @@ static bool ReadOpenCLKey(DEVINST dnDevNode)
goto out;
}

if (REG_SZ != dwLibraryNameType)
if (REG_MULTI_SZ != dwLibraryNameType)
{
if (REG_MULTI_SZ == dwLibraryNameType)
{
Expand Down Expand Up @@ -174,6 +173,7 @@ static DeviceProbeResult ProbeDevice(DEVINST devnode)
devnode,
0);

// TODO: consider extracting warning messages out of this function
if (CR_SUCCESS != ret)
{
KHR_ICD_TRACE(" WARNING: failed to probe the status of the device 0x%x\n", ret);
Expand Down Expand Up @@ -346,6 +346,8 @@ bool khrIcdOsVendorsEnumerateHKR(void)
&szGuid,
0);

KHR_ICD_ASSERT(devpropType == DEVPROP_TYPE_GUID);

if (CR_SUCCESS != ret ||
!IsEqualGUID(&OCL_GUID_DEVCLASS_SOFTWARECOMPONENT, &guid))
{
Expand Down
1 change: 0 additions & 1 deletion test/loader_test/test_buffer_object.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <stdlib.h>

#include <CL/cl.h>
#include "param_struct.h"
#include <platform/icd_test_log.h>
Expand Down
2 changes: 1 addition & 1 deletion test/loader_test/test_kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ int test_clEnqueueMigrateMemObjects(const struct clEnqueueMigrateMemObjects_st*
&event);

ret_val=clEnqueueMigrateMemObjects(command_queue,
data->num_mem_objects,
(cl_uint)data->num_mem_objects,
data->mem_objects,
data->flags,
data->num_events_in_wait_list,
Expand Down

0 comments on commit 97f0eb5

Please sign in to comment.