From f920b651a8c4cd4a61155eef0f6a48b45024578a Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Mon, 27 Aug 2018 18:18:53 -0700 Subject: Fixed a problem with accessing variables in inactive shader stages in D3D11 backend; improved error messages --- .../src/ShaderResourceBindingD3D11Impl.cpp | 36 +++++++++------------- .../GraphicsEngineD3D11/src/TextureBaseD3D11.cpp | 2 -- 2 files changed, 15 insertions(+), 23 deletions(-) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderResourceBindingD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderResourceBindingD3D11Impl.cpp index 433ea149..7255f215 100644 --- a/Graphics/GraphicsEngineD3D11/src/ShaderResourceBindingD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/ShaderResourceBindingD3D11Impl.cpp @@ -146,48 +146,42 @@ IShaderVariable* ShaderResourceBindingD3D11Impl::GetVariable(SHADER_TYPE ShaderT { auto Ind = GetShaderTypeIndex(ShaderType); VERIFY_EXPR(Ind >= 0 && Ind < _countof(m_ResourceLayoutIndex)); - if( Ind >= 0 ) + auto ResLayoutIndex = m_ResourceLayoutIndex[Ind]; + if( ResLayoutIndex < 0 ) { - auto ResLayoutIndex = m_ResourceLayoutIndex[Ind]; - return m_pResourceLayouts[ResLayoutIndex].GetShaderVariable(Name); - } - else - { - LOG_ERROR("Shader type ", GetShaderTypeLiteralName(ShaderType)," is not active in the resource binding"); + LOG_ERROR("Unable to find mutable/dynamic variable '", Name, "': shader stage ", GetShaderTypeLiteralName(ShaderType), " is inactive"); return nullptr; } + + return m_pResourceLayouts[ResLayoutIndex].GetShaderVariable(Name); } Uint32 ShaderResourceBindingD3D11Impl::GetVariableCount(SHADER_TYPE ShaderType) const { auto Ind = GetShaderTypeIndex(ShaderType); VERIFY_EXPR(Ind >= 0 && Ind < _countof(m_ResourceLayoutIndex)); - if( Ind >= 0 ) - { - auto ResLayoutIndex = m_ResourceLayoutIndex[Ind]; - return m_pResourceLayouts[ResLayoutIndex].GetTotalResourceCount(); - } - else + auto ResLayoutIndex = m_ResourceLayoutIndex[Ind]; + if( ResLayoutIndex < 0 ) { - LOG_ERROR("Shader type ", GetShaderTypeLiteralName(ShaderType)," is not active in the resource binding"); + LOG_ERROR("Unable to get the number of mutable/dynamic variables: shader stage ", GetShaderTypeLiteralName(ShaderType), " is inactive"); return 0; } + + return m_pResourceLayouts[ResLayoutIndex].GetTotalResourceCount(); } IShaderVariable* ShaderResourceBindingD3D11Impl::GetVariable(SHADER_TYPE ShaderType, Uint32 Index) { auto Ind = GetShaderTypeIndex(ShaderType); VERIFY_EXPR(Ind >= 0 && Ind < _countof(m_ResourceLayoutIndex)); - if( Ind >= 0 ) - { - auto ResLayoutIndex = m_ResourceLayoutIndex[Ind]; - return m_pResourceLayouts[ResLayoutIndex].GetShaderVariable(Index); - } - else + auto ResLayoutIndex = m_ResourceLayoutIndex[Ind]; + if( ResLayoutIndex < 0 ) { - LOG_ERROR("Shader type ", GetShaderTypeLiteralName(ShaderType)," is not active in the resource binding"); + LOG_ERROR("Unable to get mutable/dynamic variable at index ", Index, ": shader stage ", GetShaderTypeLiteralName(ShaderType), " is inactive"); return nullptr; } + + return m_pResourceLayouts[ResLayoutIndex].GetShaderVariable(Index); } } diff --git a/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp index 0fe0ace0..44fc2dc6 100644 --- a/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp @@ -155,8 +155,6 @@ void TextureBaseD3D11::UpdateData( IDeviceContext* pContext, Uint32 MipLevel, Ui return; } - VERIFY( m_Desc.Usage == USAGE_DEFAULT, "Only default usage resiurces can be updated with UpdateData()" ); - auto* pd3d11DeviceContext = static_cast(pContext)->GetD3D11DeviceContext(); D3D11_BOX D3D11Box; -- cgit v1.2.3