From b7ee1dd66b02000b0fcb517378bdcf15ed4e7cd7 Mon Sep 17 00:00:00 2001
From: foreman
Date: Wed, 5 Nov 2014 18:30:40 -0500
Subject: [PATCH] P4 to Git Change 1094113 by gandryey@gera-dev-w7 on
2014/11/05 18:22:34
ECR #304775 - CL-GL depth buffer interop
- Make the changes necessary for the depth buffer interop support. Currently the extension is disabled, because the conformance tests have multiple bugs.
Affected files ...
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_gl.cpp#45 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_memobj.cpp#71 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#231 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuresource.cpp#197 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpusettings.cpp#292 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gslbe/src/rt/GSLContext.cpp#66 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp#101 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gslbe/src/rt/GSLDeviceGL.cpp#20 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/memory.cpp#113 edit
... //depot/stg/opencl/drivers/opencl/runtime/utils/flags.hpp#217 edit
---
rocclr/runtime/device/device.hpp | 3 +--
rocclr/runtime/device/gpu/gpuresource.cpp | 16 +++++++++++++---
rocclr/runtime/device/gpu/gpusettings.cpp | 7 +++----
.../device/gpu/gslbe/src/rt/GSLContext.cpp | 1 +
.../device/gpu/gslbe/src/rt/GSLDevice.cpp | 1 +
.../device/gpu/gslbe/src/rt/GSLDeviceGL.cpp | 4 ++--
rocclr/runtime/platform/memory.cpp | 8 ++++----
rocclr/runtime/utils/flags.hpp | 2 --
8 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/rocclr/runtime/device/device.hpp b/rocclr/runtime/device/device.hpp
index 56a3c3606d..1b3f6e0a71 100644
--- a/rocclr/runtime/device/device.hpp
+++ b/rocclr/runtime/device/device.hpp
@@ -584,13 +584,12 @@ public:
uint supportRA_: 1; //!< Support RA channel order format
uint largeHostMemAlloc_: 1; //!< Allow large host mem allocations (> maxSingleAlloc)
uint waitCommand_: 1; //!< Enables a wait for every submitted command
- uint depthMSAAInterop_: 1; //!< Enable depth-stencil and MSAA interop CL-GL inteorp
uint customHostAllocator_: 1;//!< True if device has custom host allocator
// that replaces generic OS allocation routines
uint customSvmAllocator_: 1; //!< True if device has custom SVM allocator
uint supportDepthsRGB_: 1; //!< Support DEPTH and sRGB channel order format
uint assumeAliases_: 1; //!< Assume aliases in the compilation process
- uint reserved_: 23;
+ uint reserved_: 24;
};
uint value_;
};
diff --git a/rocclr/runtime/device/gpu/gpuresource.cpp b/rocclr/runtime/device/gpu/gpuresource.cpp
index 2e1dcfa70e..f826cc0a8e 100644
--- a/rocclr/runtime/device/gpu/gpuresource.cpp
+++ b/rocclr/runtime/device/gpu/gpuresource.cpp
@@ -243,8 +243,12 @@ static uint32_t GetHSAILImageFormatType(cmSurfFmt format)
case CM_SURF_FMT_RG32F:
case CM_SURF_FMT_RGBA32F:
case CM_SURF_FMT_DEPTH32F:
+ case CM_SURF_FMT_DEPTH32F_X24_STEN8:
formatType = HSA_EXT_IMAGE_CHANNEL_TYPE_FLOAT;
break;
+ case CM_SURF_FMT_DEPTH24_STEN8:
+ formatType = HSA_EXT_IMAGE_CHANNEL_TYPE_UNORM_INT24;
+ break;
default:
assert(false);
}
@@ -252,7 +256,7 @@ static uint32_t GetHSAILImageFormatType(cmSurfFmt format)
return formatType;
}
-static uint32_t GetHSAILImageOrderType(gslChannelOrder chOrder)
+static uint32_t GetHSAILImageOrderType(gslChannelOrder chOrder, cmSurfFmt format)
{
uint32_t orderType = HSA_EXT_IMAGE_CHANNEL_ORDER_A;
@@ -301,7 +305,13 @@ static uint32_t GetHSAILImageOrderType(gslChannelOrder chOrder)
orderType = HSA_EXT_IMAGE_CHANNEL_ORDER_LUMINANCE;
break;
case GSL_CHANNEL_ORDER_REPLICATE_R:
- orderType = HSA_EXT_IMAGE_CHANNEL_ORDER_DEPTH;
+ if ((format == CM_SURF_FMT_DEPTH32F_X24_STEN8) ||
+ (format == CM_SURF_FMT_DEPTH24_STEN8)) {
+ orderType = HSA_EXT_IMAGE_CHANNEL_ORDER_DEPTH_STENCIL;
+ }
+ else {
+ orderType = HSA_EXT_IMAGE_CHANNEL_ORDER_DEPTH;
+ }
break;
default:
assert(false);
@@ -976,7 +986,7 @@ Resource::create(MemoryType memType, CreateParams* params, bool heap)
}
dev().fillImageHwState(gslResource, hwState_, 8 * sizeof(uint32_t));
hwState_[8] = GetHSAILImageFormatType(cal()->format_);
- hwState_[9] = GetHSAILImageOrderType(cal()->channelOrder_);
+ hwState_[9] = GetHSAILImageOrderType(cal()->channelOrder_, cal()->format_);
hwState_[10] = static_cast(cal()->width_);
// Workaround for depth view, change tileIndex to 0 for depth view
if ((memoryType() == ImageView) &&
diff --git a/rocclr/runtime/device/gpu/gpusettings.cpp b/rocclr/runtime/device/gpu/gpusettings.cpp
index b64fcacf3b..629edcf773 100644
--- a/rocclr/runtime/device/gpu/gpusettings.cpp
+++ b/rocclr/runtime/device/gpu/gpusettings.cpp
@@ -345,9 +345,8 @@ Settings::create(
rectLinearDMA_ = true;
- if (AMD_DEPTH_MSAA_INTEROP) {
- enableExtension(ClKhrGLDepthImages);
- depthMSAAInterop_ = true;
+ if (oclVersion_ >= OpenCL20) {
+ //enableExtension(ClKhrGLDepthImages);
}
if (AMD_THREAD_TRACE_ENABLE) {
threadTraceEnable_ = true;
@@ -445,7 +444,7 @@ Settings::create(
if (apuSystem_ &&
((calAttr.totalVisibleHeap + calAttr.totalInvisibleHeap) < 150)) {
- remoteAlloc_ = true;
+ remoteAlloc_ = true;
}
// Override current device settings
diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLContext.cpp b/rocclr/runtime/device/gpu/gslbe/src/rt/GSLContext.cpp
index 59a5c2da2e..7889b46b1b 100644
--- a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLContext.cpp
+++ b/rocclr/runtime/device/gpu/gslbe/src/rt/GSLContext.cpp
@@ -300,6 +300,7 @@ CALGSLContext::setInput(uint32 physUnit, gslMemObject mem)
m_textureResources[physUnit], physUnit);
}
+ m_textureResources[physUnit]->updateDepthTextureParam(mem);
m_textureResources[physUnit]->setMemObject(m_cs, GSL_COMPUTE_PROGRAM, mem);
if (mem != NULL)
diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp b/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp
index 3af8cb0ea0..e9eab09072 100644
--- a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp
+++ b/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp
@@ -1701,6 +1701,7 @@ CALGSLDevice::fillImageHwState(gslMemObject mem, void* hwState, uint32 hwStateSi
amd::ScopedLock k(gslDeviceOps());
intp channelOrder = mem->getAttribs().channelOrder;
convertInputChannelOrder(&channelOrder);
+ m_textureResource->updateDepthTextureParam(mem);
m_textureResource->getTextureSrd(m_cs, mem, reinterpret_cast(&channelOrder),
hwState, hwStateSize);
}
diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDeviceGL.cpp b/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDeviceGL.cpp
index 201db415e3..9499c907d7 100644
--- a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDeviceGL.cpp
+++ b/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDeviceGL.cpp
@@ -82,8 +82,8 @@ static const cmFormatXlateParams cmFormatXlateTable [] = {
{CM_SURF_FMT_DEPTH24F_X8, (cmSurfFmt)500, GSL_CHANNEL_ORDER_R},
{CM_SURF_FMT_DEPTH24_STEN8, CM_SURF_FMT_DEPTH24_STEN8, GSL_CHANNEL_ORDER_REPLICATE_R},
{CM_SURF_FMT_DEPTH24F_STEN8, (cmSurfFmt)500, GSL_CHANNEL_ORDER_R},
- {CM_SURF_FMT_DEPTH32F_X24_STEN8, CM_SURF_FMT_RG32I, GSL_CHANNEL_ORDER_REPLICATE_R},
- {CM_SURF_FMT_DEPTH32F, CM_SURF_FMT_R32F, GSL_CHANNEL_ORDER_REPLICATE_R},
+ {CM_SURF_FMT_DEPTH32F_X24_STEN8, CM_SURF_FMT_DEPTH32F_X24_STEN8, GSL_CHANNEL_ORDER_REPLICATE_R},
+ {CM_SURF_FMT_DEPTH32F, CM_SURF_FMT_DEPTH32F, GSL_CHANNEL_ORDER_REPLICATE_R},
{CM_SURF_FMT_sR11_sG11_sB10, (cmSurfFmt)500, GSL_CHANNEL_ORDER_R},
{CM_SURF_FMT_sU16, CM_SURF_FMT_sU16, GSL_CHANNEL_ORDER_R},
{CM_SURF_FMT_sUV16, CM_SURF_FMT_sUV16, GSL_CHANNEL_ORDER_RG},
diff --git a/rocclr/runtime/platform/memory.cpp b/rocclr/runtime/platform/memory.cpp
index 61a13602a5..412f291a0f 100644
--- a/rocclr/runtime/platform/memory.cpp
+++ b/rocclr/runtime/platform/memory.cpp
@@ -1102,11 +1102,11 @@ Image::getSupportedFormats(
bool
Image::Format::isSupported(const Context& context, cl_mem_object_type image_type) const
{
- bool supportDepthMSAA = true;
+ bool supportDepth = true;
const std::vector& devices = context.devices();
for (size_t i = 0; i < devices.size(); i++) {
- if (!devices[i]->settings().depthMSAAInterop_) {
- supportDepthMSAA = false;
+ if (!devices[i]->settings().checkExtension(ClKhrGLDepthImages)) {
+ supportDepth = false;
}
}
@@ -1129,7 +1129,7 @@ Image::Format::isSupported(const Context& context, cl_mem_object_type image_type
delete image_formats;
- if (supportDepthMSAA) {
+ if (supportDepth) {
for (cl_uint i = 0; i < sizeof(depthFormats) / sizeof(cl_image_format); i++) {
if (*this == depthFormats[i]) {
return true;
diff --git a/rocclr/runtime/utils/flags.hpp b/rocclr/runtime/utils/flags.hpp
index d75b189e21..05a4710960 100644
--- a/rocclr/runtime/utils/flags.hpp
+++ b/rocclr/runtime/utils/flags.hpp
@@ -152,8 +152,6 @@ release(bool, GPU_USE_DEVICE_QUEUE, false, \
"Use a dedicated device queue for the actual submissions") \
release(bool, GPU_ENABLE_LARGE_ALLOCATION, false, \
"Enable >4GB single allocations") \
-release(bool, AMD_DEPTH_MSAA_INTEROP, false, \
- "Enable depth stencil and MSAA buffer interop") \
release(bool, AMD_THREAD_TRACE_ENABLE, false, \
"Enable thread trace extension") \
release(uint, OPENCL_VERSION, 200, \