From f93288162c398987d238e4ead5186d8b2000fc5a Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Thu, 18 Oct 2018 20:28:09 -0700 Subject: Updated BIND_SHADER_RESOURCES_* flags --- .../src/GLProgramResources.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/src/GLProgramResources.cpp b/Graphics/GraphicsEngineOpenGL/src/GLProgramResources.cpp index a845c613..cb2cbe36 100644 --- a/Graphics/GraphicsEngineOpenGL/src/GLProgramResources.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/GLProgramResources.cpp @@ -428,16 +428,17 @@ namespace Diligent template void BindResourcesHelper(TResArrayType &ResArr, IResourceMapping *pResourceMapping, Uint32 Flags) { - for( auto res = ResArr.begin(); res != ResArr.end(); ++res ) + for (auto& res : ResArr) { - auto &Name = res->Name; - for(Uint32 ArrInd = 0; ArrInd < res->pResources.size(); ++ArrInd) + if ( (Flags & (1 << res.VarType)) == 0 ) + continue; + + auto &Name = res.Name; + for(Uint32 ArrInd = 0; ArrInd < res.pResources.size(); ++ArrInd) { - auto &CurrResource = res->pResources[ArrInd]; - if( Flags & BIND_SHADER_RESOURCES_RESET_BINDINGS ) - CurrResource.Release(); + auto &CurrResource = res.pResources[ArrInd]; - if( (Flags & BIND_SHADER_RESOURCES_UPDATE_UNRESOLVED) && CurrResource ) + if( (Flags & BIND_SHADER_RESOURCES_KEEP_EXISTING) && CurrResource ) continue; // Skip already resolved resources RefCntAutoPtr pNewRes; @@ -445,13 +446,13 @@ namespace Diligent if (pNewRes != nullptr) { - if(res->VarType == SHADER_VARIABLE_TYPE_STATIC && CurrResource != nullptr && CurrResource != pNewRes ) + if(res.VarType == SHADER_VARIABLE_TYPE_STATIC && CurrResource != nullptr && CurrResource != pNewRes ) LOG_ERROR_MESSAGE( "Updating binding for static variable \"", Name, "\" is invalid and may result in an undefined behavior" ); CurrResource = pNewRes; } else { - if ( CurrResource == nullptr && (Flags & BIND_SHADER_RESOURCES_ALL_RESOLVED) ) + if ( CurrResource == nullptr && (Flags & BIND_SHADER_RESOURCES_VERIFY_ALL_RESOLVED) ) LOG_ERROR_MESSAGE("Resource \"", Name, "\" is not found in the resource mapping"); } } @@ -463,6 +464,9 @@ namespace Diligent if( !pResourceMapping ) return; + if ( (Flags & BIND_SHADER_RESOURCES_UPDATE_ALL) == 0 ) + Flags |= BIND_SHADER_RESOURCES_UPDATE_ALL; + BindResourcesHelper( m_UniformBlocks, pResourceMapping, Flags ); BindResourcesHelper( m_Samplers, pResourceMapping, Flags ); BindResourcesHelper( m_Images, pResourceMapping, Flags ); -- cgit v1.2.3