mirror of
https://github.com/intel/compute-runtime.git
synced 2025-11-10 05:49:51 +08:00
Verify GL sharing based on primary display's luid
Resolves: NEO-5016 Change-Id: I244536fdd8acacfeb423ae09e13191df66c4f74a Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
48e7ca6102
commit
442b6cfc47
@@ -358,7 +358,7 @@ cl_int CL_API_CALL clGetGLContextInfoKHR(const cl_context_properties *properties
|
||||
ClDevice *deviceToReturn = nullptr;
|
||||
for (auto i = 0u; i < platform->getNumDevices(); i++) {
|
||||
auto device = platform->getClDevice(i);
|
||||
if (device->getRootDeviceEnvironment().osInterface->get()->getWddm()->verifyHdcHandle(GLHDCHandle)) {
|
||||
if (device->getRootDeviceEnvironment().osInterface->get()->getWddm()->verifyAdapterLuid(glSharing->getAdapterLuid())) {
|
||||
deviceToReturn = device;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
#include "opencl/source/sharings/gl/windows/gl_sharing_windows.h"
|
||||
|
||||
#include "shared/source/os_interface/windows/sys_calls.h"
|
||||
#include "shared/source/os_interface/windows/wddm/wddm.h"
|
||||
|
||||
#include "opencl/source/context/context.inl"
|
||||
#include "opencl/source/helpers/windows/gl_helper.h"
|
||||
#include "opencl/source/sharings/gl/gl_arb_sync_event.h"
|
||||
@@ -154,9 +157,65 @@ GLboolean GLSharingFunctionsWindows::initGLFunctions() {
|
||||
this->pfnGlArbSyncObjectSignal = signalArbSyncObject;
|
||||
this->pfnGlArbSyncObjectWaitServer = serverWaitForArbSyncObject;
|
||||
|
||||
initAdapterLuid();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
LUID GLSharingFunctionsWindows::getAdapterLuid() const {
|
||||
return adapterLuid;
|
||||
}
|
||||
void GLSharingFunctionsWindows::initAdapterLuid() {
|
||||
if (adapterLuid.HighPart != 0 || adapterLuid.LowPart != 0) {
|
||||
return;
|
||||
}
|
||||
WCHAR displayName[ARRAYSIZE(DISPLAY_DEVICEW::DeviceName)];
|
||||
UINT iDevNum = 0u;
|
||||
DISPLAY_DEVICEW dispDevice = {0};
|
||||
dispDevice.cb = sizeof(dispDevice);
|
||||
while (SysCalls::enumDisplayDevices(NULL, iDevNum++, &dispDevice, EDD_GET_DEVICE_INTERFACE_NAME)) {
|
||||
if (dispDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) {
|
||||
wcscpy_s(displayName, ARRAYSIZE(DISPLAY_DEVICEW::DeviceName), dispDevice.DeviceName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DXGI_ADAPTER_DESC1 OpenAdapterDesc = {{0}};
|
||||
DXGI_OUTPUT_DESC outputDesc = {0};
|
||||
IDXGIFactory1 *pFactory = nullptr;
|
||||
IDXGIAdapter1 *pAdapter = nullptr;
|
||||
bool found = false;
|
||||
|
||||
HRESULT hr = Wddm::createDxgiFactory(__uuidof(IDXGIFactory), (void **)(&pFactory));
|
||||
iDevNum = 0u;
|
||||
while (pFactory->EnumAdapters1(iDevNum++, &pAdapter) != DXGI_ERROR_NOT_FOUND) {
|
||||
IDXGIOutput *pOutput = nullptr;
|
||||
UINT outputNum = 0;
|
||||
while (pAdapter->EnumOutputs(outputNum++, &pOutput) != DXGI_ERROR_NOT_FOUND && pOutput) {
|
||||
pOutput->GetDesc(&outputDesc);
|
||||
if (wcscmp(outputDesc.DeviceName, displayName) == 0) {
|
||||
|
||||
hr = pAdapter->GetDesc1(&OpenAdapterDesc);
|
||||
if (hr == S_OK) {
|
||||
adapterLuid = OpenAdapterDesc.AdapterLuid;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
pAdapter->Release();
|
||||
pAdapter = nullptr;
|
||||
if (found) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pFactory != nullptr) {
|
||||
pFactory->Release();
|
||||
pFactory = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
template GLSharingFunctionsWindows *Context::getSharing<GLSharingFunctionsWindows>();
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -122,6 +122,8 @@ class GLSharingFunctionsWindows : public GLSharingFunctions {
|
||||
pfnGlArbSyncObjectWaitServer(osInterface, glSyncInfo);
|
||||
}
|
||||
|
||||
LUID getAdapterLuid() const;
|
||||
|
||||
// Buffer reuse
|
||||
std::mutex mutex;
|
||||
std::vector<std::pair<unsigned int, GraphicsAllocation *>> graphicsAllocationsForGlBufferReuse;
|
||||
@@ -136,6 +138,8 @@ class GLSharingFunctionsWindows : public GLSharingFunctions {
|
||||
void createBackupContext();
|
||||
bool isOpenGlExtensionSupported(const unsigned char *pExtentionString);
|
||||
|
||||
void initAdapterLuid();
|
||||
|
||||
// Handles
|
||||
GLType GLHDCType = 0;
|
||||
GLContext GLHGLRCHandle = 0;
|
||||
@@ -143,6 +147,7 @@ class GLSharingFunctionsWindows : public GLSharingFunctions {
|
||||
GLDisplay GLHDCHandle = 0;
|
||||
OS_HANDLE GLDeviceHandle = 0;
|
||||
OS_HANDLE GLContextHandle = 0;
|
||||
LUID adapterLuid{};
|
||||
|
||||
// GL functions
|
||||
std::unique_ptr<OsLibrary> glLibrary;
|
||||
|
||||
Reference in New Issue
Block a user