summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineOpenGL
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-10-08 14:54:32 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-10-08 14:54:32 +0000
commit32f57de71b70a5d1d7f72c6e270789f809b16d9a (patch)
tree74e9be6e146ab85995d7366cc6ffdeae54abc64d /Graphics/GraphicsEngineOpenGL
parentFixed build issue (diff)
downloadDiligentCore-32f57de71b70a5d1d7f72c6e270789f809b16d9a.tar.gz
DiligentCore-32f57de71b70a5d1d7f72c6e270789f809b16d9a.zip
OpenGL backend: improved resource binding issues reporting
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/GLPipelineResourceLayout.h2
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/PipelineStateGLImpl.h2
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp62
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/GLPipelineResourceLayout.cpp12
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/ShaderResourceBindingGLImpl.cpp2
5 files changed, 46 insertions, 34 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/include/GLPipelineResourceLayout.h b/Graphics/GraphicsEngineOpenGL/include/GLPipelineResourceLayout.h
index 96c73fa6..31d3d9b5 100644
--- a/Graphics/GraphicsEngineOpenGL/include/GLPipelineResourceLayout.h
+++ b/Graphics/GraphicsEngineOpenGL/include/GLPipelineResourceLayout.h
@@ -222,7 +222,7 @@ public:
void BindResources(SHADER_TYPE ShaderStage, IResourceMapping* pResourceMapping, Uint32 Flags, const GLProgramResourceCache& dbgResourceCache);
#ifdef DEVELOPMENT
- bool dvpVerifyBindings()const;
+ bool dvpVerifyBindings(const GLProgramResourceCache& ResourceCache)const;
#endif
IShaderResourceVariable* GetShaderVariable( SHADER_TYPE ShaderStage, const Char* Name );
diff --git a/Graphics/GraphicsEngineOpenGL/include/PipelineStateGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/PipelineStateGLImpl.h
index baa96a90..d7dd7a96 100644
--- a/Graphics/GraphicsEngineOpenGL/include/PipelineStateGLImpl.h
+++ b/Graphics/GraphicsEngineOpenGL/include/PipelineStateGLImpl.h
@@ -70,7 +70,9 @@ public:
void InitializeSRBResourceCache(GLProgramResourceCache& ResourceCache)const;
+ const GLPipelineResourceLayout& GetResourceLayout()const {return m_ResourceLayout;}
const GLPipelineResourceLayout& GetStaticResourceLayout()const {return m_StaticResourceLayout;}
+ const GLProgramResourceCache& GetStaticResourceCache()const {return m_StaticResourceCache;}
private:
GLObjectWrappers::GLPipelineObj& GetGLProgramPipeline(GLContext::NativeGLContextType Context);
diff --git a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
index e1d2640a..fc3a2df2 100644
--- a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
@@ -369,6 +369,9 @@ namespace Diligent
auto* pShaderResBindingGL = ValidatedCast<ShaderResourceBindingGLImpl>(pResBinding);
const auto& ResourceCache = pShaderResBindingGL->GetResourceCache(m_pPipelineState);
+#ifdef DEVELOPMENT
+ m_pPipelineState->GetResourceLayout().dvpVerifyBindings(ResourceCache);
+#endif
VERIFY_EXPR(m_BoundWritableTextures.empty());
VERIFY_EXPR(m_BoundWritableBuffers.empty());
@@ -376,22 +379,26 @@ namespace Diligent
for (Uint32 ub = 0; ub < ResourceCache.GetUBCount(); ++ub)
{
const auto& UB = ResourceCache.GetUB(ub);
- if (auto* pBufferGL = UB.pBuffer.RawPtr<BufferGLImpl>())
- {
- pBufferGL->BufferMemoryBarrier(
- GL_UNIFORM_BARRIER_BIT,// Shader uniforms sourced from buffer objects after the barrier
- // will reflect data written by shaders prior to the barrier
- m_ContextState);
+ if (!UB.pBuffer)
+ continue;
- glBindBufferBase(GL_UNIFORM_BUFFER, ub, pBufferGL->m_GlBuffer);
- DEV_CHECK_GL_ERROR("Failed to bind uniform buffer to slot ", ub);
- //glBindBufferRange(GL_UNIFORM_BUFFER, it->Index, pBufferGL->m_GlBuffer, 0, pBufferGL->GetDesc().uiSizeInBytes);
- }
+ auto* pBufferGL = UB.pBuffer.RawPtr<BufferGLImpl>();
+ pBufferGL->BufferMemoryBarrier(
+ GL_UNIFORM_BARRIER_BIT,// Shader uniforms sourced from buffer objects after the barrier
+ // will reflect data written by shaders prior to the barrier
+ m_ContextState);
+
+ glBindBufferBase(GL_UNIFORM_BUFFER, ub, pBufferGL->m_GlBuffer);
+ DEV_CHECK_GL_ERROR("Failed to bind uniform buffer to slot ", ub);
+ //glBindBufferRange(GL_UNIFORM_BUFFER, it->Index, pBufferGL->m_GlBuffer, 0, pBufferGL->GetDesc().uiSizeInBytes);
}
for (Uint32 s = 0; s < ResourceCache.GetSamplerCount(); ++s)
{
const auto& Sam = ResourceCache.GetSampler(s);
+ if (!Sam.pView)
+ continue;
+
// We must check 'pTexture' first as 'pBuffer' is in union with 'pSampler'
if (Sam.pTexture != nullptr)
{
@@ -436,6 +443,9 @@ namespace Diligent
for (Uint32 img = 0; img < ResourceCache.GetImageCount(); ++img)
{
const auto& Img = ResourceCache.GetImage(img);
+ if (!Img.pView)
+ continue;
+
// We must check 'pTexture' first as 'pBuffer' is in union with 'pSampler'
if (Img.pTexture != nullptr)
{
@@ -521,24 +531,24 @@ namespace Diligent
for (Uint32 ssbo = 0; ssbo < ResourceCache.GetSSBOCount(); ++ssbo)
{
const auto& SSBO = ResourceCache.GetSSBO(ssbo);
- if (SSBO.pBufferView)
- {
- auto* pBufferViewGL = SSBO.pBufferView.RawPtr<BufferViewGLImpl>();
- const auto& ViewDesc = pBufferViewGL->GetDesc();
- VERIFY( ViewDesc.ViewType == BUFFER_VIEW_UNORDERED_ACCESS || ViewDesc.ViewType == BUFFER_VIEW_SHADER_RESOURCE, "Unexpected buffer view type" );
-
- auto* pBufferGL = pBufferViewGL->GetBuffer<BufferGLImpl>();
- pBufferGL->BufferMemoryBarrier(
- GL_SHADER_STORAGE_BARRIER_BIT,// Accesses to shader storage blocks after the barrier
- // will reflect writes prior to the barrier
- m_ContextState);
+ if (!SSBO.pBufferView)
+ return;
+
+ auto* pBufferViewGL = SSBO.pBufferView.RawPtr<BufferViewGLImpl>();
+ const auto& ViewDesc = pBufferViewGL->GetDesc();
+ VERIFY( ViewDesc.ViewType == BUFFER_VIEW_UNORDERED_ACCESS || ViewDesc.ViewType == BUFFER_VIEW_SHADER_RESOURCE, "Unexpected buffer view type" );
+
+ auto* pBufferGL = pBufferViewGL->GetBuffer<BufferGLImpl>();
+ pBufferGL->BufferMemoryBarrier(
+ GL_SHADER_STORAGE_BARRIER_BIT,// Accesses to shader storage blocks after the barrier
+ // will reflect writes prior to the barrier
+ m_ContextState);
- glBindBufferRange(GL_SHADER_STORAGE_BUFFER, ssbo, pBufferGL->m_GlBuffer, ViewDesc.ByteOffset, ViewDesc.ByteWidth);
- DEV_CHECK_GL_ERROR("Failed to bind shader storage buffer");
+ glBindBufferRange(GL_SHADER_STORAGE_BUFFER, ssbo, pBufferGL->m_GlBuffer, ViewDesc.ByteOffset, ViewDesc.ByteWidth);
+ DEV_CHECK_GL_ERROR("Failed to bind shader storage buffer");
- if (ViewDesc.ViewType == BUFFER_VIEW_UNORDERED_ACCESS)
- m_BoundWritableBuffers.push_back(pBufferGL);
- }
+ if (ViewDesc.ViewType == BUFFER_VIEW_UNORDERED_ACCESS)
+ m_BoundWritableBuffers.push_back(pBufferGL);
}
#endif
diff --git a/Graphics/GraphicsEngineOpenGL/src/GLPipelineResourceLayout.cpp b/Graphics/GraphicsEngineOpenGL/src/GLPipelineResourceLayout.cpp
index 4454fda5..12beba0f 100644
--- a/Graphics/GraphicsEngineOpenGL/src/GLPipelineResourceLayout.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/GLPipelineResourceLayout.cpp
@@ -798,7 +798,7 @@ void GLPipelineResourceLayout::CopyResources(GLProgramResourceCache& DstCache)co
}
#ifdef DEVELOPMENT
-bool GLPipelineResourceLayout::dvpVerifyBindings()const
+bool GLPipelineResourceLayout::dvpVerifyBindings(const GLProgramResourceCache& ResourceCache)const
{
#define LOG_MISSING_BINDING(VarType, BindInfo, BindPt)\
do{ \
@@ -814,7 +814,7 @@ do{ \
{
for (Uint32 BindPoint = ub.m_Attribs.Binding; BindPoint < Uint32{ub.m_Attribs.Binding} + ub.m_Attribs.ArraySize; ++BindPoint)
{
- if (!m_pResourceCache->IsUBBound(BindPoint))
+ if (!ResourceCache.IsUBBound(BindPoint))
{
LOG_MISSING_BINDING("constant buffer", ub, BindPoint);
BindingsOK = false;
@@ -828,14 +828,14 @@ do{ \
{
VERIFY_EXPR(sam.m_Attribs.ResourceType == SHADER_RESOURCE_TYPE_TEXTURE_SRV ||
sam.m_Attribs.ResourceType == SHADER_RESOURCE_TYPE_BUFFER_SRV);
- if (!m_pResourceCache->IsSamplerBound(BindPoint, sam.m_Attribs.ResourceType == SHADER_RESOURCE_TYPE_TEXTURE_SRV))
+ if (!ResourceCache.IsSamplerBound(BindPoint, sam.m_Attribs.ResourceType == SHADER_RESOURCE_TYPE_TEXTURE_SRV))
{
LOG_MISSING_BINDING("texture", sam, BindPoint);
BindingsOK = false;
}
else
{
- const auto& CachedSampler = const_cast<const GLProgramResourceCache*>(m_pResourceCache)->GetSampler(BindPoint);
+ const auto& CachedSampler = ResourceCache.GetSampler(BindPoint);
if (sam.m_StaticSamplerIdx >= 0 && CachedSampler.pSampler == nullptr)
{
LOG_ERROR_MESSAGE("Static sampler is not initialized for texture '", sam.m_Attribs.Name, "'");
@@ -851,7 +851,7 @@ do{ \
{
VERIFY_EXPR(img.m_Attribs.ResourceType == SHADER_RESOURCE_TYPE_TEXTURE_UAV ||
img.m_Attribs.ResourceType == SHADER_RESOURCE_TYPE_BUFFER_UAV);
- if (!m_pResourceCache->IsImageBound(BindPoint, img.m_Attribs.ResourceType == SHADER_RESOURCE_TYPE_TEXTURE_UAV))
+ if (!ResourceCache.IsImageBound(BindPoint, img.m_Attribs.ResourceType == SHADER_RESOURCE_TYPE_TEXTURE_UAV))
{
LOG_MISSING_BINDING("texture UAV", img, BindPoint);
BindingsOK = false;
@@ -863,7 +863,7 @@ do{ \
{
for (Uint32 BindPoint = ssbo.m_Attribs.Binding; BindPoint < Uint32{ssbo.m_Attribs.Binding} + ssbo.m_Attribs.ArraySize; ++BindPoint)
{
- if (!m_pResourceCache->IsSSBOBound(BindPoint))
+ if (!ResourceCache.IsSSBOBound(BindPoint))
{
LOG_MISSING_BINDING("buffer", ssbo, BindPoint);
BindingsOK = false;
diff --git a/Graphics/GraphicsEngineOpenGL/src/ShaderResourceBindingGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/ShaderResourceBindingGLImpl.cpp
index fb023a90..0236e282 100644
--- a/Graphics/GraphicsEngineOpenGL/src/ShaderResourceBindingGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/ShaderResourceBindingGLImpl.cpp
@@ -107,7 +107,7 @@ void ShaderResourceBindingGLImpl::InitializeStaticResources(const IPipelineState
const auto& StaticResLayout = pPSOGL->GetStaticResourceLayout();
#ifdef DEVELOPMENT
- if (!StaticResLayout.dvpVerifyBindings())
+ if (!StaticResLayout.dvpVerifyBindings(pPSOGL->GetStaticResourceCache()))
{
LOG_ERROR_MESSAGE("Static resources in SRB of PSO '", pPSOGL->GetDesc().Name, "' will not be successfully initialized "
"because not all static resource bindings in shader '", pPSOGL->GetDesc().Name, "' are valid. "