P4 to Git Change 1246105 by cpaquot@hog-ocl on 2016/03/10 15:13:37

SWDEV-89711 - Adding EGL interop capability:
	- Remove Context::Info::type_ and only use flags_, it's more accurate and type_ was just redundant
	- Plumbing work for EGL at the top of the API layer.

	ReviewBoardURL = http://ocltc.amd.com/reviews/r/9965/diff/

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_d3d10.cpp#11 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_d3d11.cpp#18 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_d3d9.cpp#28 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_gl.cpp#48 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_gl_amd.hpp#18 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/cpu/cpudevice.hpp#94 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#269 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#542 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.hpp#157 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsadevice.cpp#56 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsadevice.hpp#25 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/context.cpp#40 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/context.hpp#24 edit
This commit is contained in:
foreman
2016-03-10 15:21:20 -05:00
parent 3fe9bcaaff
commit 269f599f85
6 changed files with 33 additions and 41 deletions
+2 -2
View File
@@ -122,12 +122,12 @@ public:
//! Needed for OpenGL objects on CPU device
//! Return true if initialized interoperability, otherwise false
virtual bool bindExternalDevice(intptr_t type, void* pDevice, void* pContext, bool validateOnly)
virtual bool bindExternalDevice(uint flags, void* pDevice, void* pContext, bool validateOnly)
{
return true; // On CPU always avail if pD3DDevice is not NULL
}
virtual bool unbindExternalDevice(intptr_t type, void* pDevice, void* pContext, bool validateOnly)
virtual bool unbindExternalDevice(uint flags, void* pDevice, void* pContext, bool validateOnly)
{
return true;
}
+2 -2
View File
@@ -1614,14 +1614,14 @@ public:
//! Return true if initialized external API interop, otherwise false
virtual bool bindExternalDevice(
intptr_t type, //!< Enum val. for ext.API type: GL, D3D10, etc.
uint flags, //!< Enum val. for ext.API type: GL, D3D10, etc.
void* pDevice, //!< D3D device do D3D, HDC/Display handle of X Window for GL
void* pContext, //!< HGLRC/GLXContext handle
bool validateOnly //! Only validate if the device can inter-operate with pDevice/pContext, do not bind.
) = 0;
virtual bool unbindExternalDevice(
intptr_t type, //!< Enum val. for ext.API type: GL, D3D10, etc.
uint flags, //!< Enum val. for ext.API type: GL, D3D10, etc.
void* pDevice, //!< D3D device do D3D, HDC/Display handle of X Window for GL
void* pContext, //!< HGLRC/GLXContext handle
bool validateOnly //! Only validate if the device can inter-operate with pDevice/pContext, do not bind.
+14 -23
View File
@@ -1767,13 +1767,12 @@ Device::createView(amd::Memory& owner, const device::Memory& parent) const
//! Attempt to bind with external graphics API's device/context
bool
Device::bindExternalDevice(
intptr_t type, void* pDevice, void* pContext, bool validateOnly)
uint flags, void* pDevice, void* pContext, bool validateOnly)
{
assert(pDevice);
switch (type) {
#ifdef _WIN32
case CL_CONTEXT_D3D10_DEVICE_KHR:
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
@@ -1786,8 +1785,8 @@ Device::bindExternalDevice(
LogError("Failed gslD3D10Associate()");
return false;
}
break;
case CL_CONTEXT_D3D11_DEVICE_KHR:
}
else 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
@@ -1800,8 +1799,8 @@ Device::bindExternalDevice(
LogError("Failed gslD3D11Associate()");
return false;
}
break;
case CL_CONTEXT_ADAPTER_D3D9_KHR:
}
else if (flags & amd::Context::Flags::D3D9DeviceKhr) {
PerformAdapterInitialization();
// Associate GSL-D3D
@@ -1810,8 +1809,8 @@ Device::bindExternalDevice(
LogWarning("D3D9<->OpenCL adapter mismatch or D3D9Associate() failure");
return false;
}
break;
case CL_CONTEXT_ADAPTER_D3D9EX_KHR:
}
else if (flags & amd::Context::Flags::D3D9DeviceEXKhr) {
PerformAdapterInitialization();
// Associate GSL-D3D
@@ -1820,13 +1819,11 @@ Device::bindExternalDevice(
LogWarning("D3D9<->OpenCL adapter mismatch or D3D9Associate() failure");
return false;
}
break;
case CL_CONTEXT_ADAPTER_DXVA_KHR:
break;
}
else if (flags & amd::Context::Flags::D3D9DeviceVAKhr) {
}
#endif //_WIN32
case CL_GL_CONTEXT_KHR:
{
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
@@ -1841,20 +1838,14 @@ Device::bindExternalDevice(
return false;
}
}
break;
default:
LogError("Unknown external device!");
return false;
break;
}
return true;
}
bool
Device::unbindExternalDevice(intptr_t type, void* pDevice, void* pContext, bool validateOnly)
Device::unbindExternalDevice(uint flags, void* pDevice, void* pContext, bool validateOnly)
{
if (type != CL_GL_CONTEXT_KHR) {
if ((flags & amd::Context::Flags::GLDeviceKhr) == 0) {
return true;
}
+4 -4
View File
@@ -95,10 +95,10 @@ public:
//! Needed for OpenGL objects on CPU device
virtual bool bindExternalDevice(
intptr_t type, void* pDevice, void* pContext, bool validateOnly) { return true; }
uint flags, void* pDevice, void* pContext, bool validateOnly) { return true; }
virtual bool unbindExternalDevice(
intptr_t type, void* pDevice, void* pContext, bool validateOnly) { return true; }
uint flags, void* pDevice, void* pContext, bool validateOnly) { return true; }
//! Releases non-blocking map target memory
virtual void freeMapTarget(amd::Memory& mem, void* target) {}
@@ -438,14 +438,14 @@ public:
//! Attempt to bind with external graphics API's device/context
virtual bool bindExternalDevice(
intptr_t type,
uint flags,
void* pDevice,
void* pContext,
bool validateOnly);
//! Attempt to unbind with external graphics API's device/context
virtual bool unbindExternalDevice(
intptr_t type,
uint flags,
void* pDevice,
void* pContext,
bool validateOnly);
+10 -9
View File
@@ -67,7 +67,7 @@ Context::~Context()
std::vector<Device *>::const_iterator it;
// Loop through all devices
for (it = devices_.begin(); it != devices_.end(); it++) {
(*it)->unbindExternalDevice(info_.type_, info_.hDev_, info_.hCtx_, VALIDATE_ONLY);
(*it)->unbindExternalDevice(info_.flags_, info_.hDev_, info_.hCtx_, VALIDATE_ONLY);
}
}
@@ -119,7 +119,6 @@ Context::checkProperties(
return CL_INVALID_VALUE;
}
info->hDev_ = p->ptr;
info->type_ = CL_CONTEXT_D3D10_DEVICE_KHR;
info->flags_ |= D3D10DeviceKhr;
break;
case CL_CONTEXT_D3D11_DEVICE_KHR:
@@ -127,7 +126,6 @@ Context::checkProperties(
return CL_INVALID_VALUE;
}
info->hDev_ = p->ptr;
info->type_ = CL_CONTEXT_D3D11_DEVICE_KHR;
info->flags_ |= D3D11DeviceKhr;
break;
case CL_CONTEXT_ADAPTER_D3D9_KHR:
@@ -135,7 +133,6 @@ Context::checkProperties(
return CL_INVALID_VALUE;
}
info->hDev_ = p->ptr;
info->type_ = CL_CONTEXT_ADAPTER_D3D9_KHR;
info->flags_ |= D3D9DeviceKhr;
break;
case CL_CONTEXT_ADAPTER_D3D9EX_KHR:
@@ -143,7 +140,6 @@ Context::checkProperties(
return CL_INVALID_VALUE;
}
info->hDev_ = p->ptr;
info->type_ = CL_CONTEXT_ADAPTER_D3D9EX_KHR;
info->flags_ |= D3D9DeviceEXKhr;
break;
case CL_CONTEXT_ADAPTER_DXVA_KHR:
@@ -151,9 +147,15 @@ Context::checkProperties(
return CL_INVALID_VALUE;
}
info->hDev_ = p->ptr;
info->type_ = CL_CONTEXT_ADAPTER_DXVA_KHR;
info->flags_ |= D3D9DeviceVAKhr;
break;
#endif //_WIN32
case CL_EGL_DISPLAY_KHR:
info->hDev_ = p->ptr;
info->flags_ |= EGLDeviceKhr;
#ifdef _WIN32
case CL_WGL_HDC_KHR:
info->hDev_ = p->ptr;
#endif //_WIN32
@@ -174,7 +176,6 @@ Context::checkProperties(
return CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR;
}
if (p->name == CL_GL_CONTEXT_KHR) {
info->type_ = p->name;
info->hCtx_ = p->ptr;
}
info->flags_ |= GLDeviceKhr;
@@ -232,7 +233,7 @@ Context::create(const intptr_t* properties)
// Loop through all devices
for (it = devices_.begin(); it != devices_.end(); it++) {
if (!(*it)->bindExternalDevice(
info_.type_, info_.hDev_, info_.hCtx_, VALIDATE_ONLY)) {
info_.flags_, info_.hDev_, info_.hCtx_, VALIDATE_ONLY)) {
result = CL_INVALID_VALUE;
}
}
@@ -265,7 +266,7 @@ Context::create(const intptr_t* properties)
#endif //!_WIN32
);
if (h && (glenv_ = new GLFunctions(h))) {
if (h && (glenv_ = new GLFunctions(h, (info_.flags_ & Flags::EGLDeviceKhr) != 0))) {
if (!glenv_->init(reinterpret_cast<intptr_t>(info_.hDev_),
reinterpret_cast<intptr_t>(info_.hCtx_))) {
delete glenv_;
+1 -1
View File
@@ -41,13 +41,13 @@ public:
D3D9DeviceKhr = 1<<6, //!< d3d9 device
D3D9DeviceEXKhr = 1<<7, //!< d3d9EX device
D3D9DeviceVAKhr = 1<<8, //!< d3d9VA device
EGLDeviceKhr = 1<<9, //!< EGL device
};
//! Context info structure
struct Info
{
uint flags_; //!< Context info flags
intptr_t type_; //!< Context type
void* hDev_; //!< Device object reference
void* hCtx_; //!< Context object reference
size_t propertiesSize_;//!< Size of the original properties in bytes