diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp b/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp index 1c0fd10c3b..4b5cc14665 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp @@ -1446,17 +1446,8 @@ bool Resource::gslGLAcquire() { bool retVal = true; - if (cal()->type_ == OGLInterop) { - //release is required only for depth resources - switch ((int)cal()->format_) { - case CM_SURF_FMT_DEPTH24_STEN8: - case CM_SURF_FMT_DEPTH32F_X24_STEN8: - case CM_SURF_FMT_DEPTH32F: - case CM_SURF_FMT_DEPTH16: - retVal = dev().resGLAcquire(glPlatformContext_,glInteropMbRes_, glType_); - break; - } + retVal = dev().resGLAcquire(glPlatformContext_,glInteropMbRes_, glType_); } return retVal; } @@ -1465,17 +1456,8 @@ bool Resource::gslGLRelease() { bool retVal = true; - if (cal()->type_ == OGLInterop) { - //release is required only for depth resources - switch ((int)cal()->format_) { - case CM_SURF_FMT_DEPTH24_STEN8: - case CM_SURF_FMT_DEPTH32F_X24_STEN8: - case CM_SURF_FMT_DEPTH32F: - case CM_SURF_FMT_DEPTH16: - retVal = dev().resGLRelease(glPlatformContext_,glInteropMbRes_); - break; - } + retVal = dev().resGLRelease(glPlatformContext_,glInteropMbRes_, glType_); } return retVal; } diff --git a/projects/clr/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.h b/projects/clr/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.h index 121f6c26cb..f9f911c94c 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.h +++ b/projects/clr/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.h @@ -86,9 +86,9 @@ public: CALvoid* GLdeviceContext, gslMemObject mem, gslMemObject mem_base, CALvoid* mbResHandle, CALuint type) const; //! @brief Decompresses depth/MSAA surfaces.This function is called on every 'clEnqeueuAcquireGLObject'. - bool resGLAcquire( CALvoid* GLplatformContext,CALvoid* mbResHandle, CALuint type) const; + bool resGLAcquire( CALvoid* GLplatformContext, CALvoid* mbResHandle, CALuint type) const; //! @brief This function is called on every 'clEnqeueuReleaseGLObject'. - bool resGLRelease(CALvoid* GLplatformContext,CALvoid* mbResHandle) const; + bool resGLRelease(CALvoid* GLplatformContext, CALvoid* mbResHandle, CALuint type) const; gsl::gsAdaptor* getNative() const; CALuint getElfMachine() const { return m_elfmachine; }; diff --git a/projects/clr/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDeviceGL.cpp b/projects/clr/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDeviceGL.cpp index 0dd86aa9b7..7f9d87eea7 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDeviceGL.cpp +++ b/projects/clr/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDeviceGL.cpp @@ -761,20 +761,23 @@ CALGSLDevice::resGLAcquire(CALvoid* GLplatformContext, //! @note: GSL device isn't thread safe amd::ScopedLock k(gslDeviceOps()); - GLResource hRes; + GLResource hRes = {0}; osAssert(mbResHandle); hRes.mbResHandle = (GLuintp)mbResHandle; - switch(type) + switch(type) { case CAL_RES_GL_BUFFER_TYPE_TEXTURE: hRes.type = GL_RESOURCE_ATTACH_TEXTURE_AMD; - break; + break; case CAL_RES_GL_BUFFER_TYPE_RENDERBUFFER: hRes.type = GL_RESOURCE_ATTACH_RENDERBUFFER_AMD; break; - break; + case CAL_RES_GL_BUFFER_TYPE_VERTEXBUFFER: + hRes.type = GL_RESOURCE_ATTACH_VERTEXBUFFER_AMD; + break; default: - return false; + // @note: No acquire for GL_RESOURCE_ATTACH_FRAMEBUFFER_AMD + return true; } bool status = false; #ifdef ATI_OS_LINUX @@ -796,15 +799,31 @@ CALGSLDevice::resGLAcquire(CALvoid* GLplatformContext, bool CALGSLDevice::resGLRelease(CALvoid* GLplatformContext, - CALvoid* mbResHandle) const + CALvoid* mbResHandle, + CALuint type) const { //! @note: GSL device isn't thread safe amd::ScopedLock k(gslDeviceOps()); - GLResource hRes; + GLResource hRes = {0}; osAssert(mbResHandle); bool status = false; hRes.mbResHandle = (GLuintp)mbResHandle; + switch(type) + { + case CAL_RES_GL_BUFFER_TYPE_TEXTURE: + hRes.type = GL_RESOURCE_ATTACH_TEXTURE_AMD; + break; + case CAL_RES_GL_BUFFER_TYPE_RENDERBUFFER: + hRes.type = GL_RESOURCE_ATTACH_RENDERBUFFER_AMD; + break; + case CAL_RES_GL_BUFFER_TYPE_VERTEXBUFFER: + hRes.type = GL_RESOURCE_ATTACH_VERTEXBUFFER_AMD; + break; + default: + // @note: No release for GL_RESOURCE_ATTACH_FRAMEBUFFER_AMD + return true; + } #ifdef ATI_OS_LINUX //TODO : make sure the application GL context is current. if not no @@ -836,7 +855,7 @@ CALGSLDevice::resGLFree ( //! @note: GSL device isn't thread safe amd::ScopedLock k(gslDeviceOps()); - GLResource hRes; + GLResource hRes = {0}; osAssert(mbResHandle); hRes.mbResHandle = (GLuintp)mbResHandle;