P4 to Git Change 1456230 by asalmanp@asalmanp-ocl-stg on 2017/09/07 12:00:21
SWDEV-130722 - Channel order in an interop buffer from OpenCL to OpenGL is flipped on Vega
OCL calls glGetTexLevelParameteriv_ function to get the internal GL format but this format is the one chosen by app in OGL API such as glTexImage2D.
The issue is that OGL sometimes selects a different format than defined in the glTexImage2D and this causes some issues in cl_gl interop. One example is shown below
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA/**internal format**/, width, height, 0, GL_BGRA/**external format**/, GL_UNSIGNED_BYTES, NULL);
in this case GL_RGBA is selected by app as the internal format but OGL switches to BGRA8 internally and causes an issue later in cl_gl interop (i.e., R and B channels are swapped) because OCL gets GL_RGBA as the internal format in the glGetTexLevelParameteriv_ call.
To avoid this issue, OCL needs to query the real internal gl format in wglResourceAttachAMD and adjusts the CL format accordingly.
ReviewBoardURL = http://ocltc.amd.com/reviews/r/13408/
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.hpp#19 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevicegl.cpp#5 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.cpp#35 edit
[ROCm/clr commit: e8395888c5]
This commit is contained in:
@@ -482,7 +482,7 @@ class Device : public NullDevice {
|
||||
bool initGLInteropPrivateExt(void* GLplatformContext, void* GLdeviceContext) const;
|
||||
bool glCanInterop(void* GLplatformContext, void* GLdeviceContext) const;
|
||||
bool resGLAssociate(void* GLContext, uint name, uint type, void** handle, void** mbResHandle,
|
||||
size_t* offset
|
||||
size_t* offset, uint& glFormat
|
||||
#ifdef ATI_OS_WIN
|
||||
,
|
||||
Pal::DoppDesktopInfo& doppDesktopInfo
|
||||
|
||||
@@ -178,7 +178,7 @@ bool Device::glDissociate(void* GLplatformContext, void* GLdeviceContext) const
|
||||
}
|
||||
|
||||
bool Device::resGLAssociate(void* GLContext, uint name, uint type, void** handle,
|
||||
void** mbResHandle, size_t* offset
|
||||
void** mbResHandle, size_t* offset, uint& glFormat
|
||||
#ifdef ATI_OS_WIN
|
||||
,
|
||||
Pal::DoppDesktopInfo& doppDesktopInfo
|
||||
@@ -225,6 +225,8 @@ bool Device::resGLAssociate(void* GLContext, uint name, uint type, void** handle
|
||||
}
|
||||
#endif
|
||||
|
||||
glFormat = static_cast<uint>(hData.format);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@@ -483,13 +483,20 @@ bool Resource::create(MemoryType memType, CreateParams* params) {
|
||||
layer = oglRes->layer_;
|
||||
type = oglRes->type_;
|
||||
mipLevel = oglRes->mipLevel_;
|
||||
uint glFormat = 0;
|
||||
|
||||
if (!dev().resGLAssociate(oglRes->glPlatformContext_, oglRes->handle_, glType_,
|
||||
&openInfo.hExternalResource, &glInteropMbRes_, &offset_,
|
||||
&openInfo.hExternalResource, &glInteropMbRes_, &offset_, glFormat,
|
||||
openInfo.doppDesktopInfo)) {
|
||||
return false;
|
||||
}
|
||||
desc_.isDoppTexture_ = (openInfo.doppDesktopInfo.gpuVirtAddr != 0);
|
||||
// This is a temporary workaround for SWDEV-130722
|
||||
// 0x22 = CM_SURF_FMT_BGRA8 defined in cm_enum.h in gsl
|
||||
if (glFormat == 0x22) {
|
||||
desc_.format_.image_channel_order = CL_BGRA;
|
||||
format = dev().getPalFormat(desc().format_, &channels);
|
||||
}
|
||||
} else {
|
||||
D3DInteropParams* d3dRes = reinterpret_cast<D3DInteropParams*>(params);
|
||||
openInfo.hExternalResource = d3dRes->handle_;
|
||||
|
||||
Reference in New Issue
Block a user