From 4f81a5ef7dbd2ecaa5f1a73795b969673ae36ccb Mon Sep 17 00:00:00 2001
From: foreman
Date: Fri, 8 Apr 2016 15:51:49 -0400
Subject: [PATCH] P4 to Git Change 1256021 by cpaquot@hog-ocl on 2016/04/08
15:41:06
SWDEV-90482 - [Afterswitch] Interop from OpenGL to OpenCL is broken in one driver and crashes in another
Fixed the crash by restoring the order where we bind the external device.
ReviewBoardURL = http://ocltc.amd.com/reviews/r/10195/diff/
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#544 edit
---
rocclr/runtime/device/gpu/gpudevice.cpp | 33 ++++++++++++-------------
1 file changed, 16 insertions(+), 17 deletions(-)
diff --git a/rocclr/runtime/device/gpu/gpudevice.cpp b/rocclr/runtime/device/gpu/gpudevice.cpp
index d15cea66be..c3d4616900 100644
--- a/rocclr/runtime/device/gpu/gpudevice.cpp
+++ b/rocclr/runtime/device/gpu/gpudevice.cpp
@@ -1759,8 +1759,23 @@ Device::bindExternalDevice(
{
assert(pDevice);
+ if (flags & amd::Context::Flags::GLDeviceKhr) {
+ // There is no need to perform full initialization here
+ // if the GSLDevice is still uninitialized.
+ // Only adapter initialization is required to validate
+ // GL interoperability.
+ PerformAdapterInitialization();
+
+ // Attempt to associate GSL-OGL
+ if (!glAssociate((CALvoid*)pContext, pDevice)) {
+ if (!validateOnly) {
+ LogError("Failed gslGLAssociate()");
+ }
+ return false;
+ }
+ }
#ifdef _WIN32
- if (flags & amd::Context::Flags::D3D10DeviceKhr) {
+ else 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
@@ -1811,22 +1826,6 @@ Device::bindExternalDevice(
else if (flags & amd::Context::Flags::D3D9DeviceVAKhr) {
}
#endif //_WIN32
- if (flags & amd::Context::Flags::GLDeviceKhr) {
- // There is no need to perform full initialization here
- // if the GSLDevice is still uninitialized.
- // Only adapter initialization is required to validate
- // GL interoperability.
- PerformAdapterInitialization();
-
- // Attempt to associate GSL-OGL
- if (!glAssociate((CALvoid*)pContext, pDevice)) {
- if (!validateOnly) {
- LogError("Failed gslGLAssociate()");
- }
- return false;
- }
- }
-
return true;
}