c99d679c9e
SWDEV-86035 - Add OCL backend for PAL - PAL backend build is disabled by default. "BUILD_PAL_DEVICE = yes" enables the build. You also have to update the client workspace with PAL mapping: //depot/stg/pal/... //<your_opencl_location>/runtime/device/pal/palbe/... Affected files ... ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/build/Makefile.api#130 edit ... //depot/stg/opencl/drivers/opencl/compiler/sclibdefs.opencl#8 edit ... //depot/stg/opencl/drivers/opencl/opencldefs#166 edit ... //depot/stg/opencl/drivers/opencl/openclrules#91 edit ... //depot/stg/opencl/drivers/opencl/runtime/Makefile#21 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#192 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/Makefile#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/build/Makefile#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/build/Makefile.pal#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palappprofile.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palappprofile.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palbinary.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palbinary.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palblit.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palblit.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palcompiler.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palconstbuf.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palconstbuf.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palcounters.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palcounters.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldebugger.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldebugmanager.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldebugmanager.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldefs.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldeviced3d10.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldeviced3d11.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldeviced3d9.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevicegl.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palkernel.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palkernel.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palmemory.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palmemory.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprintf.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprintf.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprogram.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprogram.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palsched.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palschedcl.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palsettings.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palsettings.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palthreadtrace.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palthreadtrace.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paltimestamp.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paltimestamp.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paltrap.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palwavelimiter.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palwavelimiter.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/runtimedefs#36 edit ... //depot/stg/opencl/drivers/opencl/runtime/top.hpp#23 edit
143 行
4.0 KiB
C++
143 行
4.0 KiB
C++
#include "paldevice.hpp"
|
|
|
|
#if defined(ATI_OS_LINUX)
|
|
namespace pal {
|
|
bool
|
|
Device::associateD3D11Device(void* d3d11Device)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
#else // !ATI_OS_LINUX
|
|
|
|
#include <D3D11.h>
|
|
|
|
/**************************************************************************************************************
|
|
* Note: ideally the DXX extension interfaces should be mapped from the DXX perforce branch.
|
|
* This means OCL client spec will need to change to include headers directly from the DXX perforce tree.
|
|
* However, OCL only cares about the DXX OpenCL extension interface class. The spec cannot change
|
|
* without notification. So it is safe to use a local copy of the relevant DXX extension interface classes.
|
|
**************************************************************************************************************/
|
|
#include "DxxOpenCLInteropExt.h"
|
|
|
|
namespace pal {
|
|
|
|
static bool
|
|
queryD3D11DeviceGPUMask(ID3D11Device* pd3d11Device, UINT* pd3d11DeviceGPUMask)
|
|
{
|
|
HMODULE hDLL = nullptr;
|
|
IAmdDxExt* pExt = nullptr;
|
|
IAmdDxExtCLInterop* pCLExt = nullptr;
|
|
PFNAmdDxExtCreate11 AmdDxExtCreate11;
|
|
HRESULT hr = S_OK;
|
|
|
|
// Get a handle to the DXX DLL with extension API support
|
|
#if defined _WIN64
|
|
static const CHAR dxxModuleName[13] = "atidxx64.dll";
|
|
#else
|
|
static const CHAR dxxModuleName[13] = "atidxx32.dll";
|
|
#endif
|
|
|
|
hDLL = GetModuleHandle(dxxModuleName);
|
|
|
|
if (hDLL == nullptr) {
|
|
hr = E_FAIL;
|
|
}
|
|
|
|
// Get the exported AmdDxExtCreate() function pointer
|
|
if (SUCCEEDED(hr)) {
|
|
AmdDxExtCreate11 = reinterpret_cast<PFNAmdDxExtCreate11>(
|
|
GetProcAddress(hDLL, "AmdDxExtCreate11"));
|
|
if (AmdDxExtCreate11 == nullptr) {
|
|
hr = E_FAIL;
|
|
}
|
|
}
|
|
|
|
// Create the extension object
|
|
if (SUCCEEDED(hr)) {
|
|
hr = AmdDxExtCreate11(pd3d11Device, &pExt);
|
|
}
|
|
|
|
// Get the extension version information
|
|
if (SUCCEEDED(hr)) {
|
|
AmdDxExtVersion extVersion;
|
|
hr = pExt->GetVersion(&extVersion);
|
|
|
|
if (extVersion.majorVersion == 0) {
|
|
hr = E_FAIL;
|
|
}
|
|
}
|
|
|
|
// Get the OpenCL Interop interface
|
|
if (SUCCEEDED(hr)) {
|
|
pCLExt = static_cast<IAmdDxExtCLInterop*>(
|
|
pExt->GetExtInterface(AmdDxExtCLInteropID));
|
|
if (pCLExt != nullptr) {
|
|
// Get the GPU mask using the CL Interop extension.
|
|
pCLExt->QueryInteropGpuMask(pd3d11DeviceGPUMask);
|
|
}
|
|
else {
|
|
hr = E_FAIL;
|
|
}
|
|
}
|
|
|
|
if (pCLExt != nullptr) {
|
|
pCLExt->Release();
|
|
}
|
|
|
|
if (pExt != nullptr) {
|
|
pExt->Release();
|
|
}
|
|
|
|
return (SUCCEEDED(hr));
|
|
}
|
|
|
|
bool
|
|
Device::associateD3D11Device(void* d3d11Device)
|
|
{
|
|
ID3D11Device* pd3d11Device = static_cast<ID3D11Device*>(d3d11Device);
|
|
|
|
IDXGIDevice* pDXGIDevice;
|
|
pd3d11Device->QueryInterface(__uuidof(IDXGIDevice), (void **)&pDXGIDevice);
|
|
|
|
IDXGIAdapter* pDXGIAdapter;
|
|
pDXGIDevice->GetAdapter(&pDXGIAdapter);
|
|
|
|
DXGI_ADAPTER_DESC adapterDesc;
|
|
pDXGIAdapter->GetDesc(&adapterDesc);
|
|
|
|
// match the adapter
|
|
bool canInteroperate =
|
|
(properties().osProperties.luidHighPart == adapterDesc.AdapterLuid.HighPart) &&
|
|
(properties().osProperties.luidLowPart == adapterDesc.AdapterLuid.LowPart);
|
|
|
|
UINT chainBitMask = 1 << properties().gpuIndex;
|
|
|
|
// match the chain ID
|
|
if (canInteroperate) {
|
|
UINT d3d11DeviceGPUMask = 0;
|
|
|
|
if (queryD3D11DeviceGPUMask(pd3d11Device, &d3d11DeviceGPUMask)) {
|
|
canInteroperate = (chainBitMask & d3d11DeviceGPUMask) != 0;
|
|
}
|
|
else {
|
|
// special handling for Intel iGPU + AMD dGPU in LDA mode
|
|
// (only occurs on a PX platform) where
|
|
// the D3D11Device object is created on the Intel iGPU and
|
|
// passed to AMD dGPU (secondary) to interoperate.
|
|
if (chainBitMask > 1) {
|
|
canInteroperate = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
pDXGIDevice->Release();
|
|
pDXGIAdapter->Release();
|
|
|
|
return canInteroperate;
|
|
}
|
|
|
|
} // pal
|
|
|
|
#endif // !ATI_OS_LINUX
|