P4 to Git Change 1264764 by wchau@wchau_WIN_OCL_HSA on 2016/05/03 16:46:02

SWDEV-93075 - [OCL] Access violation in clCreateContext() in amdocl.dll when DX9 and DX11 devices are used.  Add support for multiple external devices for context creation to make sure the devices are initialized with proper type.

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_context.cpp#50 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_d3d10.cpp#12 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_d3d11.cpp#19 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_d3d9.cpp#29 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/cpu/cpudevice.hpp#95 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#274 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#547 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.hpp#160 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpumemory.cpp#128 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsadevice.cpp#62 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsadevice.hpp#30 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#4 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.hpp#5 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palmemory.cpp#3 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/context.cpp#41 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/context.hpp#25 edit


[ROCm/clr commit: 6a5cdbf60c]
이 커밋은 다음에 포함됨:
foreman
2016-05-03 17:00:14 -04:00
부모 21610ac41b
커밋 be4288bc18
10개의 변경된 파일과 90개의 추가작업 그리고 66개의 파일을 삭제
+20 -14
파일 보기
@@ -1769,7 +1769,7 @@ Device::createView(amd::Memory& owner, const device::Memory& parent) const
//! Attempt to bind with external graphics API's device/context
bool
Device::bindExternalDevice(
uint flags, void* pDevice, void* pContext, bool validateOnly)
uint flags, void* const pDevice[], void* pContext, bool validateOnly)
{
assert(pDevice);
@@ -1781,15 +1781,16 @@ Device::bindExternalDevice(
PerformAdapterInitialization();
// Attempt to associate GSL-OGL
if (!glAssociate((CALvoid*)pContext, pDevice)) {
if (!glAssociate((CALvoid*)pContext, pDevice[amd::Context::DeviceFlagIdx::GLDeviceKhrIdx])) {
if (!validateOnly) {
LogError("Failed gslGLAssociate()");
}
return false;
}
}
#ifdef _WIN32
else if (flags & amd::Context::Flags::D3D10DeviceKhr) {
if (flags & amd::Context::Flags::D3D10DeviceKhr) {
// There is no need to perform full initialization here
// if the GSLDevice is still uninitialized.
// Only adapter initialization is required
@@ -1798,12 +1799,13 @@ Device::bindExternalDevice(
// Associate GSL-D3D
if (!associateD3D10Device(
reinterpret_cast<ID3D10Device*>(pDevice))) {
reinterpret_cast<ID3D10Device*>(pDevice[amd::Context::DeviceFlagIdx::D3D10DeviceKhrIdx]))) {
LogError("Failed gslD3D10Associate()");
return false;
}
}
else if (flags & amd::Context::Flags::D3D11DeviceKhr) {
if (flags & amd::Context::Flags::D3D11DeviceKhr) {
// There is no need to perform full initialization here
// if the GSLDevice is still uninitialized.
// Only adapter initialization is required to validate
@@ -1812,47 +1814,51 @@ Device::bindExternalDevice(
// Associate GSL-D3D
if (!associateD3D11Device(
reinterpret_cast<ID3D11Device*>(pDevice))) {
reinterpret_cast<ID3D11Device*>(pDevice[amd::Context::DeviceFlagIdx::D3D11DeviceKhrIdx]))) {
LogError("Failed gslD3D11Associate()");
return false;
}
}
else if (flags & amd::Context::Flags::D3D9DeviceKhr) {
if (flags & amd::Context::Flags::D3D9DeviceKhr) {
PerformAdapterInitialization();
// Associate GSL-D3D
if (!associateD3D9Device(
reinterpret_cast<IDirect3DDevice9*>(pDevice))) {
reinterpret_cast<IDirect3DDevice9*>(pDevice[amd::Context::DeviceFlagIdx::D3D9DeviceKhrIdx]))) {
LogWarning("D3D9<->OpenCL adapter mismatch or D3D9Associate() failure");
return false;
}
}
else if (flags & amd::Context::Flags::D3D9DeviceEXKhr) {
if (flags & amd::Context::Flags::D3D9DeviceEXKhr) {
PerformAdapterInitialization();
// Associate GSL-D3D
if (!associateD3D9Device(
reinterpret_cast<IDirect3DDevice9Ex*>(pDevice))) {
reinterpret_cast<IDirect3DDevice9Ex*>(pDevice[amd::Context::DeviceFlagIdx::D3D9DeviceEXKhrIdx]))) {
LogWarning("D3D9<->OpenCL adapter mismatch or D3D9Associate() failure");
return false;
}
}
else if (flags & amd::Context::Flags::D3D9DeviceVAKhr) {
if (flags & amd::Context::Flags::D3D9DeviceVAKhr) {
}
#endif //_WIN32
return true;
}
bool
Device::unbindExternalDevice(uint flags, void* pDevice, void* pContext, bool validateOnly)
Device::unbindExternalDevice(uint flags, void* const pDevice[], void* pContext, bool validateOnly)
{
if ((flags & amd::Context::Flags::GLDeviceKhr) == 0) {
return true;
}
if (pDevice != NULL) {
void * glDevice = pDevice[amd::Context::DeviceFlagIdx::GLDeviceKhrIdx];
if (glDevice != NULL) {
// Dissociate GSL-OGL
if (true != glDissociate(pContext, pDevice)) {
if (true != glDissociate(pContext, glDevice)) {
if (validateOnly) {
LogWarning("Failed gslGLDiassociate()");
}