summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineOpenGL
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-10-14 08:04:05 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-10-14 08:04:05 +0000
commitb3fec8bd40e80115086281bce74774617aa95e23 (patch)
tree99c9b3250484d6a5f3283320aea8b7b90f3f30c1 /Graphics/GraphicsEngineOpenGL
parentShader variable access test: fixed issue with raw buffers in GL/VK/Metal (diff)
downloadDiligentCore-b3fec8bd40e80115086281bce74774617aa95e23.tar.gz
DiligentCore-b3fec8bd40e80115086281bce74774617aa95e23.zip
Added buffer mode validation when binding buffer views
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/GLPipelineResourceLayout.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/src/GLPipelineResourceLayout.cpp b/Graphics/GraphicsEngineOpenGL/src/GLPipelineResourceLayout.cpp
index 0955a54f..914a09bb 100644
--- a/Graphics/GraphicsEngineOpenGL/src/GLPipelineResourceLayout.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/GLPipelineResourceLayout.cpp
@@ -307,6 +307,16 @@ void GLPipelineResourceLayout::SamplerBindInfo::BindResource(IDeviceObject* pVie
{
auto& CachedBuffSampler = ResourceCache.GetConstSampler(m_Attribs.Binding + ArrayIndex);
VerifyResourceViewBinding(m_Attribs, GetType(), ArrayIndex, pView, pViewGL.RawPtr(), {BUFFER_VIEW_SHADER_RESOURCE}, CachedBuffSampler.pView.RawPtr());
+ if (pViewGL != nullptr)
+ {
+ const auto& ViewDesc = pViewGL->GetDesc();
+ const auto& BuffDesc = pViewGL->GetBuffer()->GetDesc();
+ if (!(BuffDesc.Mode == BUFFER_MODE_FORMATTED && ViewDesc.Format.ValueType != VT_UNDEFINED || BuffDesc.Mode == BUFFER_MODE_RAW))
+ {
+ LOG_ERROR_MESSAGE("Error binding buffer view '", ViewDesc.Name, "' of buffer '", BuffDesc.Name, "' to shader variable '",
+ m_Attribs.Name, ": formatted buffer view is expected.");
+ }
+ }
}
#endif
ResourceCache.SetBufSampler(m_Attribs.Binding + ArrayIndex, std::move(pViewGL));
@@ -347,6 +357,16 @@ void GLPipelineResourceLayout::ImageBindInfo::BindResource(IDeviceObject* pView,
{
auto& CachedUAV = ResourceCache.GetConstImage(m_Attribs.Binding + ArrayIndex);
VerifyResourceViewBinding(m_Attribs, GetType(), ArrayIndex, pView, pViewGL.RawPtr(), {BUFFER_VIEW_UNORDERED_ACCESS}, CachedUAV.pView.RawPtr());
+ if (pViewGL != nullptr)
+ {
+ const auto& ViewDesc = pViewGL->GetDesc();
+ const auto& BuffDesc = pViewGL->GetBuffer()->GetDesc();
+ if (!(BuffDesc.Mode == BUFFER_MODE_FORMATTED && ViewDesc.Format.ValueType != VT_UNDEFINED || BuffDesc.Mode == BUFFER_MODE_RAW))
+ {
+ LOG_ERROR_MESSAGE("Error binding buffer view '", ViewDesc.Name, "' of buffer '", BuffDesc.Name, "' to shader variable '",
+ m_Attribs.Name, ": formatted buffer view is expected.");
+ }
+ }
}
#endif
ResourceCache.SetBufImage(m_Attribs.Binding + ArrayIndex, std::move(pViewGL));
@@ -375,6 +395,16 @@ void GLPipelineResourceLayout::StorageBufferBindInfo::BindResource(IDeviceObject
auto& CachedSSBO = ResourceCache.GetConstSSBO(m_Attribs.Binding + ArrayIndex);
// HLSL structured buffers are mapped to SSBOs in GLSL
VerifyResourceViewBinding(m_Attribs, GetType(), ArrayIndex, pView, pViewGL.RawPtr(), {BUFFER_VIEW_SHADER_RESOURCE, BUFFER_VIEW_UNORDERED_ACCESS}, CachedSSBO.pBufferView.RawPtr());
+ if (pViewGL != nullptr)
+ {
+ const auto& ViewDesc = pViewGL->GetDesc();
+ const auto& BuffDesc = pViewGL->GetBuffer()->GetDesc();
+ if (BuffDesc.Mode != BUFFER_MODE_STRUCTURED && BuffDesc.Mode != BUFFER_MODE_RAW)
+ {
+ LOG_ERROR_MESSAGE("Error binding buffer view '", ViewDesc.Name, "' of buffer '", BuffDesc.Name, "' to shader variable '",
+ m_Attribs.Name, ": structured buffer view is expected.");
+ }
+ }
}
#endif
ResourceCache.SetSSBO(m_Attribs.Binding + ArrayIndex, std::move(pViewGL));