summaryrefslogtreecommitdiffstats
path: root/RenderScript/src/ShaderResourceBindingParser.cpp
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-04-05 15:52:31 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-04-05 15:52:31 +0000
commitd6d73dd8e7f98f6591f93b7ecda08b34cce518ec (patch)
tree59ae736203e824b6bbc9fcfa93d720e93037a5f8 /RenderScript/src/ShaderResourceBindingParser.cpp
parentAdded options to capture RGB vs RGBA when encoding image as png plus some for... (diff)
downloadDiligentTools-d6d73dd8e7f98f6591f93b7ecda08b34cce518ec.tar.gz
DiligentTools-d6d73dd8e7f98f6591f93b7ecda08b34cce518ec.zip
Changes to comply with the updated API
Diffstat (limited to 'RenderScript/src/ShaderResourceBindingParser.cpp')
-rw-r--r--RenderScript/src/ShaderResourceBindingParser.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/RenderScript/src/ShaderResourceBindingParser.cpp b/RenderScript/src/ShaderResourceBindingParser.cpp
index 32c8176..ed24c0d 100644
--- a/RenderScript/src/ShaderResourceBindingParser.cpp
+++ b/RenderScript/src/ShaderResourceBindingParser.cpp
@@ -37,7 +37,8 @@ namespace Diligent
m_ResMappingMetatableName(ResMappingMetatableName),
m_ShaderVarMetatableRegistryName(ShaderVarMetatableRegistryName),
m_BindResourcesBinding( this, L, m_MetatableRegistryName.c_str(), "BindResources", &ShaderResourceBindingParser::BindResources ),
- m_GetVariableBinding( this, L, m_MetatableRegistryName.c_str(), "GetVariable", &ShaderResourceBindingParser::GetVariable ),
+ m_GetVariableByNameBinding( this, L, m_MetatableRegistryName.c_str(), "GetVariableByName", &ShaderResourceBindingParser::GetVariable ),
+ m_GetVariableByIndexBinding( this, L, m_MetatableRegistryName.c_str(), "GetVariableByIndex", &ShaderResourceBindingParser::GetVariable ),
m_CreateShaderResourceBinding( this, L, PSOLibMetatableName.c_str(), "CreateShaderResourceBinding", &ShaderResourceBindingParser::CreateShaderResourceBinding ),
m_InitializeStaticResourcesBinding( this, L, m_MetatableRegistryName.c_str(), "InitializeStaticResources", &ShaderResourceBindingParser::InitializeStaticResources )
{
@@ -171,10 +172,19 @@ namespace Diligent
ShaderTypeParser.SetValue(L, ArgStackInd, &ShaderType);
++ArgStackInd;
- // Variable name should be the second argument
- auto VarName = ReadValueFromLua<String>( L, ArgStackInd );
-
- auto pVar = pShaderResBinding->GetVariable(ShaderType, VarName.c_str());
+ IShaderResourceVariable* pVar = nullptr;
+ if (lua_type(L,ArgStackInd) == LUA_TSTRING)
+ {
+ // Variable name should be the second argument
+ auto VarName = ReadValueFromLua<String>( L, ArgStackInd );
+ pVar = pShaderResBinding->GetVariableByName(ShaderType, VarName.c_str());
+ }
+ else
+ {
+ // Variable name should be the second argument
+ auto VarIndex = ReadValueFromLua<int>( L, ArgStackInd );
+ pVar = pShaderResBinding->GetVariableByIndex(ShaderType, VarIndex);
+ }
auto pNewShaderVarLuaObj = reinterpret_cast<IShaderResourceVariable**>(lua_newuserdata( L, sizeof( IShaderResourceVariable* ) ));
*pNewShaderVarLuaObj = pVar;