summaryrefslogtreecommitdiffstats
path: root/RenderScript/src
diff options
context:
space:
mode:
Diffstat (limited to 'RenderScript/src')
-rw-r--r--RenderScript/src/BlendStateDescParser.cpp (renamed from RenderScript/src/BlendStateParser.cpp)82
-rw-r--r--RenderScript/src/BufferParser.cpp2
-rw-r--r--RenderScript/src/BufferViewParser.cpp2
-rw-r--r--RenderScript/src/DepthStencilStateDescParser.cpp (renamed from RenderScript/src/DepthStencilStateParser.cpp)62
-rw-r--r--RenderScript/src/DeviceContextFuncBindings.cpp115
-rw-r--r--RenderScript/src/DrawAttribsParser.cpp2
-rw-r--r--RenderScript/src/EngineObjectParserBase.cpp2
-rw-r--r--RenderScript/src/EnumMappings.cpp45
-rw-r--r--RenderScript/src/InputLayoutDescParser.cpp87
-rw-r--r--RenderScript/src/LayoutDescParser.cpp151
-rw-r--r--RenderScript/src/LuaBindings.cpp2
-rw-r--r--RenderScript/src/LuaFunctionBinding.cpp2
-rw-r--r--RenderScript/src/LuaWrappers.cpp2
-rw-r--r--RenderScript/src/PSODescParser.cpp257
-rw-r--r--RenderScript/src/ParsingErrors.cpp2
-rw-r--r--RenderScript/src/RasterizerStateDescParser.cpp70
-rw-r--r--RenderScript/src/RasterizerStateParser.cpp89
-rw-r--r--RenderScript/src/ResourceMappingParser.cpp22
-rw-r--r--RenderScript/src/SamplerParser.cpp40
-rw-r--r--RenderScript/src/ScissorRectParser.cpp2
-rw-r--r--RenderScript/src/ScriptParser.cpp49
-rw-r--r--RenderScript/src/ShaderParser.cpp308
-rw-r--r--RenderScript/src/ShaderResourceBindingParser.cpp192
-rw-r--r--RenderScript/src/ShaderVariableParser.cpp2
-rw-r--r--RenderScript/src/TextureParser.cpp63
-rw-r--r--RenderScript/src/TextureViewParser.cpp4
-rw-r--r--RenderScript/src/ViewportParser.cpp2
-rw-r--r--RenderScript/src/pch.cpp2
28 files changed, 1155 insertions, 505 deletions
diff --git a/RenderScript/src/BlendStateParser.cpp b/RenderScript/src/BlendStateDescParser.cpp
index adf26ae..13458e3 100644
--- a/RenderScript/src/BlendStateParser.cpp
+++ b/RenderScript/src/BlendStateDescParser.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2015 Egor Yusov
+/* Copyright 2015-2016 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,10 @@
*/
#include "pch.h"
-#include "BlendStateParser.h"
+#include "BlendStateDescParser.h"
+#include "LuaWrappers.h"
+#include "ClassMethodBinding.h"
+
namespace std
{
@@ -33,10 +36,10 @@ namespace std
namespace Diligent
{
- class RenderTargetBlendStateParser;
+ class RenderTargetBlendDescArrayParser;
template<>
- class MemberBinder<RenderTargetBlendStateParser> : public MemberBinderBase
+ class MemberBinder<RenderTargetBlendDescArrayParser> : public MemberBinderBase
{
public:
MemberBinder( size_t MemberOffset, size_t Dummy ) :
@@ -126,71 +129,26 @@ namespace Diligent
EnumMapping < BLEND_OPERATION > m_BlendOpEnumMapping;
EnumMapping < COLOR_MASK > m_ColorMaskEnumMapping;
};
+
-
- const Char* BlendStateParser::BlendStateLibName = "BlendState";
-
- BlendStateParser::BlendStateParser( IRenderDevice *pRenderDevice, lua_State *L ) :
- EngineObjectParserCommon<IBlendState>( pRenderDevice, L, BlendStateLibName ),
- m_SetBlendBinding( this, L, "Context", "SetBlendState", &BlendStateParser::SetBlendState )
+ MemberBinder<BlendStateDesc> :: MemberBinder( size_t MemberOffset, size_t Dummy ) :
+ MemberBinderBase( MemberOffset )
{
- DEFINE_BUFFERED_STRING_BINDER( m_Bindings, SBSDescWrapper, Name, NameBuffer )
+ DEFINE_BINDER( m_Bindings, BlendStateDesc, AlphaToCoverageEnable, Bool, Validator<Bool>() )
+ DEFINE_BINDER( m_Bindings, BlendStateDesc, IndependentBlendEnable, Bool, Validator<Bool>() )
- DEFINE_BINDER( m_Bindings, SBSDescWrapper, AlphaToCoverageEnable, Bool, Validator<Bool>() )
- DEFINE_BINDER( m_Bindings, SBSDescWrapper, IndependentBlendEnable, Bool, Validator<Bool>() )
-
- DEFINE_BINDER( m_Bindings, SBSDescWrapper, RenderTargets, RenderTargetBlendStateParser, 0 )
- };
+ DEFINE_BINDER( m_Bindings, BlendStateDesc, RenderTargets, RenderTargetBlendDescArrayParser, 0 )
+ }
- void BlendStateParser::CreateObj( lua_State *L )
+ void MemberBinder<BlendStateDesc> ::GetValue(lua_State *L, const void* pBasePointer)
{
- INIT_LUA_STACK_TRACKING( L );
-
- SBSDescWrapper BlendDesc;
- ParseLuaTable( L, 1, &BlendDesc, m_Bindings );
-
- CHECK_LUA_STACK_HEIGHT();
-
- auto ppBlendState = reinterpret_cast<IBlendState**>(lua_newuserdata( L, sizeof( IBlendState* ) ));
- *ppBlendState = nullptr;
- m_pRenderDevice->CreateBlendState( BlendDesc, ppBlendState );
- if( *ppBlendState == nullptr )
- SCRIPT_PARSING_ERROR( L, "Failed to create blend state object" )
-
- CHECK_LUA_STACK_HEIGHT( +1 );
+ const auto &BlendDesc = GetMemberByOffest< BlendStateDesc >(pBasePointer, m_MemberOffset);
+ PushLuaTable(L, &BlendDesc, m_Bindings);
}
- int BlendStateParser::SetBlendState( lua_State *L )
+ void MemberBinder<BlendStateDesc> ::SetValue(lua_State *L, int Index, void* pBasePointer)
{
- auto *pBS = *GetUserData<IBlendState**>( L, 1, m_MetatableRegistryName.c_str() );
-
- auto NumArgs = lua_gettop( L );
- float BlendFactors[4] = { 1, 1, 1, 1 };
- if( NumArgs >= 2 )
- {
- INIT_LUA_STACK_TRACKING( L );
-
- ParseLuaArray( L, 2, BlendFactors, [&]( void* _pBasePointer, int StackIndex, int NewArrayIndex )
- {
- VERIFY( BlendFactors == _pBasePointer, "Sanity check" );
- if( !(NewArrayIndex >= 1 && NewArrayIndex <= 4) )
- SCRIPT_PARSING_ERROR( L, "Incorrect blend factor index ", NewArrayIndex, ". Only 1..4 are allowed." );
-
- BlendFactors[NewArrayIndex - 1] = ReadValueFromLua<Float32>( L, StackIndex );
- }
- );
-
- CHECK_LUA_STACK_HEIGHT();
- }
-
- Uint32 SampleMask = 0xFFFFFFFF;
- if( NumArgs >= 3 )
- {
- SampleMask = ReadValueFromLua<Uint32>( L, 3 );
- }
-
- auto *pContext = LoadDeviceContextFromRegistry( L );
- pContext->SetBlendState( pBS, BlendFactors, SampleMask );
- return 0;
+ auto &BlendDesc = GetMemberByOffest< BlendStateDesc>( pBasePointer, m_MemberOffset );
+ ParseLuaTable( L, Index, &BlendDesc, m_Bindings );
}
}
diff --git a/RenderScript/src/BufferParser.cpp b/RenderScript/src/BufferParser.cpp
index efa2d2a..0dffd13 100644
--- a/RenderScript/src/BufferParser.cpp
+++ b/RenderScript/src/BufferParser.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2015 Egor Yusov
+/* Copyright 2015-2016 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/RenderScript/src/BufferViewParser.cpp b/RenderScript/src/BufferViewParser.cpp
index c86bace..a1bff10 100644
--- a/RenderScript/src/BufferViewParser.cpp
+++ b/RenderScript/src/BufferViewParser.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2015 Egor Yusov
+/* Copyright 2015-2016 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/RenderScript/src/DepthStencilStateParser.cpp b/RenderScript/src/DepthStencilStateDescParser.cpp
index 4f95623..aed7235 100644
--- a/RenderScript/src/DepthStencilStateParser.cpp
+++ b/RenderScript/src/DepthStencilStateDescParser.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2015 Egor Yusov
+/* Copyright 2015-2016 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@
*/
#include "pch.h"
-#include "DepthStencilStateParser.h"
+#include "DepthStencilStateDescParser.h"
namespace std
{
@@ -31,8 +31,6 @@ namespace std
namespace Diligent
{
- const Char* DepthStencilStateParser::DepthStencilStateLibName = "DepthStencilState";
-
template<>
class MemberBinder<StencilOpDesc> : public MemberBinderBase
{
@@ -77,51 +75,29 @@ namespace Diligent
EnumMapping < STENCIL_OP > m_StencilOpEnumMapping;
};
- DepthStencilStateParser::DepthStencilStateParser( IRenderDevice *pRenderDevice, lua_State *L ) :
- EngineObjectParserCommon<IDepthStencilState>( pRenderDevice, L, DepthStencilStateLibName ),
- m_SetDepthStencilBinding( this, L, "Context", "SetDepthStencilState", &DepthStencilStateParser::SetDepthStencilState )
+ MemberBinder<DepthStencilStateDesc>::MemberBinder( size_t MemberOffset, size_t Dummy ) :
+ MemberBinderBase( MemberOffset )
{
- DEFINE_BUFFERED_STRING_BINDER( m_Bindings, SDSSDescWrapper, Name, NameBuffer )
-
- DEFINE_BINDER( m_Bindings, SDSSDescWrapper, DepthEnable, Bool, Validator<Bool>() )
- DEFINE_BINDER( m_Bindings, SDSSDescWrapper, DepthWriteEnable, Bool, Validator<Bool>() )
- DEFINE_ENUM_BINDER( m_Bindings, SDSSDescWrapper, DepthFunc, COMPARISON_FUNCTION, m_CmpFuncEnumMapping )
-
- DEFINE_BINDER( m_Bindings, SDSSDescWrapper, StencilEnable, Bool, Validator<Bool>() )
- DEFINE_BINDER( m_Bindings, SDSSDescWrapper, StencilReadMask, Uint8, Validator<Uint8>() )
- DEFINE_BINDER( m_Bindings, SDSSDescWrapper, StencilWriteMask, Uint8, Validator<Uint8>() )
- DEFINE_BINDER( m_Bindings, SDSSDescWrapper, FrontFace, StencilOpDesc, 0 )
- DEFINE_BINDER( m_Bindings, SDSSDescWrapper, BackFace, StencilOpDesc, 0 )
+ DEFINE_BINDER( m_Bindings, DepthStencilStateDesc, DepthEnable, Bool, Validator<Bool>() )
+ DEFINE_BINDER( m_Bindings, DepthStencilStateDesc, DepthWriteEnable, Bool, Validator<Bool>() )
+ DEFINE_ENUM_BINDER( m_Bindings, DepthStencilStateDesc, DepthFunc, COMPARISON_FUNCTION, m_CmpFuncEnumMapping )
+
+ DEFINE_BINDER( m_Bindings, DepthStencilStateDesc, StencilEnable, Bool, Validator<Bool>() )
+ DEFINE_BINDER( m_Bindings, DepthStencilStateDesc, StencilReadMask, Uint8, Validator<Uint8>() )
+ DEFINE_BINDER( m_Bindings, DepthStencilStateDesc, StencilWriteMask, Uint8, Validator<Uint8>() )
+ DEFINE_BINDER( m_Bindings, DepthStencilStateDesc, FrontFace, StencilOpDesc, 0 )
+ DEFINE_BINDER( m_Bindings, DepthStencilStateDesc, BackFace, StencilOpDesc, 0 )
};
- void DepthStencilStateParser::CreateObj( lua_State *L )
+ void MemberBinder<DepthStencilStateDesc> ::GetValue(lua_State *L, const void* pBasePointer)
{
- INIT_LUA_STACK_TRACKING( L );
-
- SDSSDescWrapper DepthStencilDesc;
- ParseLuaTable( L, 1, &DepthStencilDesc, m_Bindings );
-
- CHECK_LUA_STACK_HEIGHT();
-
- auto ppDepthStencilState = reinterpret_cast<IDepthStencilState**>(lua_newuserdata( L, sizeof( IDepthStencilState* ) ));
- *ppDepthStencilState = nullptr;
- m_pRenderDevice->CreateDepthStencilState( DepthStencilDesc, ppDepthStencilState );
- if( *ppDepthStencilState == nullptr )
- SCRIPT_PARSING_ERROR(L, "Failed to create depth stencil state")
-
- CHECK_LUA_STACK_HEIGHT( +1 );
+ const auto &DSSDesc = GetMemberByOffest< DepthStencilStateDesc >(pBasePointer, m_MemberOffset);
+ PushLuaTable(L, &DSSDesc, m_Bindings);
}
- int DepthStencilStateParser::SetDepthStencilState( lua_State *L )
+ void MemberBinder<DepthStencilStateDesc> ::SetValue(lua_State *L, int Index, void* pBasePointer)
{
- auto pVertDesc = *GetUserData<IDepthStencilState**>( L, 1, m_MetatableRegistryName.c_str() );
- Uint8 StencilRef = 0;
- if( lua_gettop( L ) > 1 )
- {
- StencilRef = ReadValueFromLua<Uint8>( L, 2 );
- }
- auto *pContext = LoadDeviceContextFromRegistry( L );
- pContext->SetDepthStencilState( pVertDesc, StencilRef );
- return 0;
+ auto &DSSDesc = GetMemberByOffest< DepthStencilStateDesc>( pBasePointer, m_MemberOffset );
+ ParseLuaTable( L, Index, &DSSDesc, m_Bindings );
}
}
diff --git a/RenderScript/src/DeviceContextFuncBindings.cpp b/RenderScript/src/DeviceContextFuncBindings.cpp
index 9525cf2..bf7e402 100644
--- a/RenderScript/src/DeviceContextFuncBindings.cpp
+++ b/RenderScript/src/DeviceContextFuncBindings.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2015 Egor Yusov
+/* Copyright 2015-2016 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,15 +26,27 @@
#include "GraphicsUtilities.h"
#include "TextureViewParser.h"
#include "EngineObjectParserBase.h"
+#include "ShaderResourceBindingParser.h"
+#include "PSODescParser.h"
namespace Diligent
{
- DeviceContextFuncBindings::DeviceContextFuncBindings( IRenderDevice *pRenderDevice, lua_State *L, TextureViewParser *pTexViewPasrser ) :
+ DeviceContextFuncBindings::DeviceContextFuncBindings( IRenderDevice *pRenderDevice, lua_State *L,
+ TextureViewParser *pTexViewPasrser,
+ ShaderResourceBindingParser *pSRBParser,
+ PSODescParser *pPSOParser) :
m_SetRenderTargetsBinding(this, L, "Context", "SetRenderTargets", &DeviceContextFuncBindings::SetRenderTargets),
m_ClearRenderTargetBinding(this, L, "Context", "ClearRenderTarget", &DeviceContextFuncBindings::ClearRenderTarget),
m_ClearDepthStencilBinding(this, L, "Context", "ClearDepthStencil", &DeviceContextFuncBindings::ClearDepthStencil),
- m_TexViewMetatableName( pTexViewPasrser->GetMetatableName() )
+ m_SetStencilRefBinding(this, L, "Context", "SetStencilRef", &DeviceContextFuncBindings::SetStencilRef),
+ m_SetBlendFactorsBinding(this, L, "Context", "SetBlendFactors", &DeviceContextFuncBindings::SetBlendFactors),
+ m_CommitShaderResourcesBinding(this, L, "Context", "CommitShaderResources", &DeviceContextFuncBindings::CommitShaderResources),
+ m_TransitionShaderResourcesBinding(this, L, "Context", "TransitionShaderResources", &DeviceContextFuncBindings::TransitionShaderResources),
+ m_TexViewMetatableName( pTexViewPasrser->GetMetatableName() ),
+ m_ShaderResBindingMetatableName( pSRBParser->GetMetatableName() ),
+ m_PSOMetatableName(pPSOParser->GetMetatableName())
{
+ DEFINE_ENUM_ELEMENT_MAPPING( m_CommitShaderResFlagsEnumMapping, COMMIT_SHADER_RESOURCES_FLAG_TRANSITION_RESOURCES );
};
int DeviceContextFuncBindings::SetRenderTargets( lua_State *L )
@@ -142,4 +154,101 @@ namespace Diligent
return 0;
}
+
+ int DeviceContextFuncBindings::SetStencilRef( lua_State *L )
+ {
+ auto NumArgs = lua_gettop( L );
+
+ Uint32 StencilRef = 0;
+ if(NumArgs >= 1 )
+ StencilRef = ReadValueFromLua<Uint32>( L, 1 );
+
+ auto *pContext = EngineObjectParserBase::LoadDeviceContextFromRegistry( L );
+ pContext->SetStencilRef( StencilRef );
+
+ // Return no values to Lua
+ return 0;
+ }
+
+ int DeviceContextFuncBindings::SetBlendFactors( lua_State *L )
+ {
+ float BlendFactors[4] = {};
+ auto NumArgs = lua_gettop( L );
+
+ for(int bf=0; bf < std::min(NumArgs, 4); ++bf)
+ BlendFactors[bf] = ReadValueFromLua<Float32>( L, bf+1 );
+
+ auto *pContext = EngineObjectParserBase::LoadDeviceContextFromRegistry( L );
+ pContext->SetBlendFactors( BlendFactors );
+
+ // Return no values to Lua
+ return 0;
+ }
+
+ int DeviceContextFuncBindings::CommitShaderResources( lua_State *L )
+ {
+ auto NumArgs = lua_gettop( L );
+ IShaderResourceBinding *pShaderResBinding = nullptr;
+ int CurrArg = 1;
+ if(NumArgs >= CurrArg )
+ {
+ if( lua_type( L, CurrArg ) == LUA_TUSERDATA )
+ {
+ pShaderResBinding = *GetUserData<IShaderResourceBinding**>( L, CurrArg, m_ShaderResBindingMetatableName.c_str() );
+ ++CurrArg;
+ }
+ }
+
+ Uint32 Flags = 0;
+ if(NumArgs >= CurrArg &&
+ (lua_type( L, CurrArg ) == LUA_TSTRING ||
+ lua_type( L, CurrArg ) == LUA_TTABLE ) )
+ {
+ FlagsLoader<COMMIT_SHADER_RESOURCES_FLAG> CommitShaderResFlagsLoader(0, "CommitShaderResourcesFlag", m_CommitShaderResFlagsEnumMapping);
+ CommitShaderResFlagsLoader.SetValue( L, CurrArg, &Flags );
+ ++CurrArg;
+ }
+
+ auto *pContext = EngineObjectParserBase::LoadDeviceContextFromRegistry( L );
+ pContext->CommitShaderResources( pShaderResBinding, Flags );
+
+ return 0;
+ }
+
+ int DeviceContextFuncBindings::TransitionShaderResources( lua_State *L )
+ {
+ auto NumArgs = lua_gettop( L );
+ IPipelineState *pPSO = nullptr;
+ int CurrArg = 1;
+
+ if(NumArgs >= CurrArg )
+ {
+ if( lua_type( L, CurrArg ) == LUA_TUSERDATA )
+ {
+ pPSO = *GetUserData<IPipelineState**>( L, CurrArg, m_PSOMetatableName.c_str() );
+ ++CurrArg;
+ }
+ }
+
+ if( !pPSO )
+ {
+ SCRIPT_PARSING_ERROR( L, "PSO is expected as the first argument" );
+ }
+
+ IShaderResourceBinding *pShaderResBinding = nullptr;
+ if(NumArgs >= CurrArg )
+ {
+ if( lua_type( L, CurrArg ) == LUA_TUSERDATA )
+ {
+ pShaderResBinding = *GetUserData<IShaderResourceBinding**>( L, CurrArg, m_ShaderResBindingMetatableName.c_str() );
+ ++CurrArg;
+ }
+ }
+
+ auto *pContext = EngineObjectParserBase::LoadDeviceContextFromRegistry( L );
+ pContext->TransitionShaderResources( pPSO, pShaderResBinding );
+
+ return 0;
+ }
+
}
diff --git a/RenderScript/src/DrawAttribsParser.cpp b/RenderScript/src/DrawAttribsParser.cpp
index a1d9d3e..1c8a8c2 100644
--- a/RenderScript/src/DrawAttribsParser.cpp
+++ b/RenderScript/src/DrawAttribsParser.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2015 Egor Yusov
+/* Copyright 2015-2016 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/RenderScript/src/EngineObjectParserBase.cpp b/RenderScript/src/EngineObjectParserBase.cpp
index 5790e60..a1ac853 100644
--- a/RenderScript/src/EngineObjectParserBase.cpp
+++ b/RenderScript/src/EngineObjectParserBase.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2015 Egor Yusov
+/* Copyright 2015-2016 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/RenderScript/src/EnumMappings.cpp b/RenderScript/src/EnumMappings.cpp
index 3bc9349..33c87c1 100644
--- a/RenderScript/src/EnumMappings.cpp
+++ b/RenderScript/src/EnumMappings.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2015 Egor Yusov
+/* Copyright 2015-2016 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,6 +44,7 @@ namespace Diligent
TextureFormatEnumMapping::TextureFormatEnumMapping()
{
+ DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_UNKNOWN );
DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGBA32_TYPELESS );
DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGBA32_FLOAT );
DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGBA32_UINT );
@@ -144,26 +145,27 @@ namespace Diligent
DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BC7_UNORM );
DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BC7_UNORM_SRGB );
static_assert(TEX_FORMAT_NUM_FORMATS == TEX_FORMAT_BC7_UNORM_SRGB + 1, "Not all texture formats initialized.");
- VERIFY( m_Str2ValMap.size() == TEX_FORMAT_NUM_FORMATS - 1,
+ VERIFY( m_Str2ValMap.size() == TEX_FORMAT_NUM_FORMATS,
"Unexpected map size. Did you update TEXTURE_FORMAT enum?" );
- VERIFY( m_Val2StrMap.size() == TEX_FORMAT_NUM_FORMATS - 1,
+ VERIFY( m_Val2StrMap.size() == TEX_FORMAT_NUM_FORMATS,
"Unexpected map size. Did you update TEXTURE_FORMAT enum?" );
}
- TextureTypeEnumMapping::TextureTypeEnumMapping()
+ ResourceDimEnumMapping::ResourceDimEnumMapping()
{
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEXTURE_TYPE_1D );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEXTURE_TYPE_1D_ARRAY );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEXTURE_TYPE_2D );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEXTURE_TYPE_2D_ARRAY );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEXTURE_TYPE_3D );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEXTURE_TYPE_CUBE );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEXTURE_TYPE_CUBE_ARRAY );
- static_assert(TEXTURE_TYPE_NUM_TYPES == TEXTURE_TYPE_CUBE_ARRAY + 1, "Not all texture types initialized.");
- VERIFY( m_Str2ValMap.size() == TEXTURE_TYPE_NUM_TYPES - 1,
- "Unexpected map size. Did you update TEXTURE_TYPE enum?" );
- VERIFY( m_Val2StrMap.size() == TEXTURE_TYPE_NUM_TYPES - 1,
- "Unexpected map size. Did you update TEXTURE_TYPE enum?" );
+ DEFINE_ENUM_ELEMENT_MAPPING( (*this), RESOURCE_DIM_BUFFER );
+ DEFINE_ENUM_ELEMENT_MAPPING( (*this), RESOURCE_DIM_TEX_1D );
+ DEFINE_ENUM_ELEMENT_MAPPING( (*this), RESOURCE_DIM_TEX_1D_ARRAY );
+ DEFINE_ENUM_ELEMENT_MAPPING( (*this), RESOURCE_DIM_TEX_2D );
+ DEFINE_ENUM_ELEMENT_MAPPING( (*this), RESOURCE_DIM_TEX_2D_ARRAY );
+ DEFINE_ENUM_ELEMENT_MAPPING( (*this), RESOURCE_DIM_TEX_3D );
+ DEFINE_ENUM_ELEMENT_MAPPING( (*this), RESOURCE_DIM_TEX_CUBE );
+ DEFINE_ENUM_ELEMENT_MAPPING( (*this), RESOURCE_DIM_TEX_CUBE_ARRAY );
+ static_assert(RESOURCE_DIM_NUM_DIMENSIONS == RESOURCE_DIM_TEX_CUBE_ARRAY + 1, "Not all texture types initialized.");
+ VERIFY( m_Str2ValMap.size() == RESOURCE_DIM_NUM_DIMENSIONS - 1,
+ "Unexpected map size. Did you update RESOURCE_DIMENSION enum?" );
+ VERIFY( m_Val2StrMap.size() == RESOURCE_DIM_NUM_DIMENSIONS - 1,
+ "Unexpected map size. Did you update RESOURCE_DIMENSION enum?" );
}
ValueTypeEnumMapping::ValueTypeEnumMapping()
@@ -207,4 +209,15 @@ namespace Diligent
DEFINE_ENUM_ELEMENT_MAPPING( (*this), BIND_SHADER_RESOURCES_UPDATE_UNRESOLVED );
DEFINE_ENUM_ELEMENT_MAPPING( (*this), BIND_SHADER_RESOURCES_ALL_RESOLVED );
}
+
+ ShaderTypeEnumMapping::ShaderTypeEnumMapping()
+ {
+ DEFINE_ENUM_ELEMENT_MAPPING( (*this), SHADER_TYPE_UNKNOWN );
+ DEFINE_ENUM_ELEMENT_MAPPING( (*this), SHADER_TYPE_VERTEX );
+ DEFINE_ENUM_ELEMENT_MAPPING( (*this), SHADER_TYPE_PIXEL );
+ DEFINE_ENUM_ELEMENT_MAPPING( (*this), SHADER_TYPE_GEOMETRY );
+ DEFINE_ENUM_ELEMENT_MAPPING( (*this), SHADER_TYPE_HULL );
+ DEFINE_ENUM_ELEMENT_MAPPING( (*this), SHADER_TYPE_DOMAIN );
+ DEFINE_ENUM_ELEMENT_MAPPING( (*this), SHADER_TYPE_COMPUTE );
+ }
}
diff --git a/RenderScript/src/InputLayoutDescParser.cpp b/RenderScript/src/InputLayoutDescParser.cpp
new file mode 100644
index 0000000..b063c55
--- /dev/null
+++ b/RenderScript/src/InputLayoutDescParser.cpp
@@ -0,0 +1,87 @@
+/* Copyright 2015-2016 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+#include "pch.h"
+#include "InputLayoutDescParser.h"
+
+namespace Diligent
+{
+ MemberBinder<InputLayoutDesc> :: MemberBinder( size_t InputLayoutOffset, size_t ElementsBufferOffset ) :
+ MemberBinderBase( InputLayoutOffset ),
+ m_LayoutElementsBufferOffset(ElementsBufferOffset)
+ {
+ DEFINE_BINDER( m_Bindings, LayoutElement, InputIndex, Uint32, Validator<Uint32>( "Input Index", 0, 32 ) )
+ DEFINE_BINDER( m_Bindings, LayoutElement, BufferSlot, Uint32, Validator<Uint32>( "Buffer Slot", 0, MaxBufferSlots ) )
+ DEFINE_BINDER( m_Bindings, LayoutElement, NumComponents, Uint32, Validator<Uint32>( "Num Components", 1, 4 ) )
+
+ DEFINE_ENUM_BINDER( m_Bindings, LayoutElement, ValueType, VALUE_TYPE, m_ValueTypeEnumMapping )
+
+ DEFINE_BINDER( m_Bindings, LayoutElement, IsNormalized, Bool, Validator<Bool>() )
+ DEFINE_BINDER( m_Bindings, LayoutElement, RelativeOffset, Uint32, Validator<Uint32>() )
+
+
+ m_FrequencyEnumMapping.AddMapping( "FREQUENCY_PER_VERTEX", LayoutElement::FREQUENCY_PER_VERTEX );
+ m_FrequencyEnumMapping.AddMapping( "FREQUENCY_PER_INSTANCE", LayoutElement::FREQUENCY_PER_INSTANCE );
+ VERIFY( m_FrequencyEnumMapping.m_Str2ValMap.size() == LayoutElement::FREQUENCY_NUM_FREQUENCIES - 1,
+ "Unexpected map size. Did you update LayoutElement::FREQUENCY_PER_VERTEX enum?" );
+ VERIFY( m_FrequencyEnumMapping.m_Val2StrMap.size() == LayoutElement::FREQUENCY_NUM_FREQUENCIES - 1,
+ "Unexpected map size. Did you update LayoutElement::FREQUENCY_PER_VERTEX enum?" );
+ DEFINE_ENUM_BINDER( m_Bindings, LayoutElement, Frequency, LayoutElement::FREQUENCY, m_FrequencyEnumMapping )
+
+ DEFINE_BINDER( m_Bindings, LayoutElement, InstanceDataStepRate, Uint32, Validator<Uint32>() )
+ }
+
+ void MemberBinder<InputLayoutDesc> :: GetValue( lua_State *L, const void* pBasePointer )
+ {
+ // Use raw pointer to push the value to Lua because the buffer
+ // most likely does not exist
+ const auto &InputLayout = GetMemberByOffest<const InputLayoutDesc>(pBasePointer, m_MemberOffset);
+ PushLuaArray( L, InputLayout.LayoutElements, InputLayout.LayoutElements + InputLayout.NumElements, [&]( const LayoutElement &Elem )
+ {
+ PushLuaTable( L, &Elem, m_Bindings );
+ }
+ );
+ }
+
+ void MemberBinder<InputLayoutDesc> :: SetValue( lua_State *L, int Index, void* pBasePointer )
+ {
+ ParseLuaArray( L, Index, pBasePointer, [&]( void* _pBasePointer, int StackIndex, int NewArrayIndex )
+ {
+ VERIFY( pBasePointer == _pBasePointer, "Sanity check failed" );
+ auto &Elements = GetMemberByOffest<std::vector<LayoutElement> >( pBasePointer, m_LayoutElementsBufferOffset);
+ auto CurrIndex = Elements.size();
+ if( CurrIndex != NewArrayIndex - 1 )
+ SCRIPT_PARSING_ERROR( L, "Explicit array indices are not allowed in layout description. Provided index ", NewArrayIndex - 1, " conflicts with actual index ", CurrIndex, "." );
+ Elements.resize( CurrIndex + 1 );
+ ParseLuaTable( L, StackIndex, &(Elements)[CurrIndex], m_Bindings );
+ if( Elements[CurrIndex].ValueType == VT_UNDEFINED )
+ SCRIPT_PARSING_ERROR( L, "Valid value type must be specified for layout element #", CurrIndex );
+ }
+ );
+
+ auto &ElementsBuffer = GetMemberByOffest<std::vector<LayoutElement> >( pBasePointer, m_LayoutElementsBufferOffset );
+ auto &InputLayout = GetMemberByOffest< InputLayoutDesc >( pBasePointer, m_MemberOffset );
+ InputLayout.LayoutElements = ElementsBuffer.data();
+ InputLayout.NumElements = static_cast<Uint32>( ElementsBuffer.size() );
+ }
+}
diff --git a/RenderScript/src/LayoutDescParser.cpp b/RenderScript/src/LayoutDescParser.cpp
deleted file mode 100644
index a5bbda1..0000000
--- a/RenderScript/src/LayoutDescParser.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/* Copyright 2015 Egor Yusov
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
- *
- * In no event and under no legal theory, whether in tort (including negligence),
- * contract, or otherwise, unless required by applicable law (such as deliberate
- * and grossly negligent acts) or agreed to in writing, shall any Contributor be
- * liable for any damages, including any direct, indirect, special, incidental,
- * or consequential damages of any character arising as a result of this License or
- * out of the use or inability to use the software (including but not limited to damages
- * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
- * all other commercial damages or losses), even if such Contributor has been advised
- * of the possibility of such damages.
- */
-
-#include "pch.h"
-#include "LayoutDescParser.h"
-
-namespace std
-{
- DEFINE_ENUM_HASH( Diligent::LayoutElement::FREQUENCY )
-}
-
-namespace Diligent
-{
- const Char* LayoutDescParser::LayoutDescLibName = "LayoutDesc";
-
- class LayoutElementLoader; // Used only as a template switch
-
- template<>
- class MemberBinder<LayoutElementLoader> : public MemberBinderBase
- {
- public:
- MemberBinder( size_t LayoutElementsOffset, size_t ElementsBufferOffset, size_t NumElementsOffset ) :
- MemberBinderBase( ElementsBufferOffset ),
- m_LayoutElementsOffset(LayoutElementsOffset),
- m_NumElementsOffset(NumElementsOffset)
- {
- DEFINE_BINDER( m_Bindings, LayoutElement, InputIndex, Uint32, Validator<Uint32>( "Input Index", 0, 32 ) )
- DEFINE_BINDER( m_Bindings, LayoutElement, BufferSlot, Uint32, Validator<Uint32>( "Buffer Slot", 0, MaxBufferSlots ) )
- DEFINE_BINDER( m_Bindings, LayoutElement, NumComponents, Uint32, Validator<Uint32>( "Num Components", 1, 4 ) )
-
- DEFINE_ENUM_BINDER( m_Bindings, LayoutElement, ValueType, VALUE_TYPE, m_ValueTypeEnumMapping )
-
- DEFINE_BINDER( m_Bindings, LayoutElement, IsNormalized, Bool, Validator<Bool>() )
- DEFINE_BINDER( m_Bindings, LayoutElement, RelativeOffset, Uint32, Validator<Uint32>() )
-
-
- m_FrequencyEnumMapping.AddMapping( "FREQUENCY_PER_VERTEX", LayoutElement::FREQUENCY_PER_VERTEX );
- m_FrequencyEnumMapping.AddMapping( "FREQUENCY_PER_INSTANCE", LayoutElement::FREQUENCY_PER_INSTANCE );
- VERIFY( m_FrequencyEnumMapping.m_Str2ValMap.size() == LayoutElement::FREQUENCY_NUM_FREQUENCIES - 1,
- "Unexpected map size. Did you update LayoutElement::FREQUENCY_PER_VERTEX enum?" );
- VERIFY( m_FrequencyEnumMapping.m_Val2StrMap.size() == LayoutElement::FREQUENCY_NUM_FREQUENCIES - 1,
- "Unexpected map size. Did you update LayoutElement::FREQUENCY_PER_VERTEX enum?" );
- DEFINE_ENUM_BINDER( m_Bindings, LayoutElement, Frequency, LayoutElement::FREQUENCY, m_FrequencyEnumMapping )
-
- DEFINE_BINDER( m_Bindings, LayoutElement, InstanceDataStepRate, Uint32, Validator<Uint32>() )
- }
-
- virtual void GetValue( lua_State *L, const void* pBasePointer )
- {
- // Use raw pointer to push the value to Lua because the buffer
- // most likely does not exist
- const auto *Elements = GetMemberByOffest<const LayoutElement*>(pBasePointer, m_LayoutElementsOffset);
- const auto &NumElements = GetMemberByOffest< Uint32 >( pBasePointer, m_NumElementsOffset );
- PushLuaArray( L, Elements, Elements + NumElements, [&]( const LayoutElement &Elem )
- {
- PushLuaTable( L, &Elem, m_Bindings );
- }
- );
- }
-
- virtual void SetValue( lua_State *L, int Index, void* pBasePointer )
- {
- ParseLuaArray( L, Index, pBasePointer, [&]( void* _pBasePointer, int StackIndex, int NewArrayIndex )
- {
- VERIFY( pBasePointer == _pBasePointer, "Sanity check failed" );
- auto &Elements = GetMemberByOffest<std::vector<LayoutElement> >( pBasePointer, m_MemberOffset );
- auto CurrIndex = Elements.size();
- if( CurrIndex != NewArrayIndex - 1 )
- SCRIPT_PARSING_ERROR( L, "Explicit array indices are not allowed in layout description. Provided index ", NewArrayIndex - 1, " conflicts with actual index ", CurrIndex, "." );
- Elements.resize( CurrIndex + 1 );
- ParseLuaTable( L, StackIndex, &(Elements)[CurrIndex], m_Bindings );
- if( Elements[CurrIndex].ValueType == VT_UNDEFINED )
- SCRIPT_PARSING_ERROR( L, "Valid value type must be specified for layout element #", CurrIndex );
- }
- );
-
- auto &ElementsBuffer = GetMemberByOffest<std::vector<LayoutElement> >( pBasePointer, m_MemberOffset );
- auto &LayoutElements = GetMemberByOffest< LayoutElement* >( pBasePointer, m_LayoutElementsOffset );
- auto &NumElements = GetMemberByOffest< Uint32 >( pBasePointer, m_NumElementsOffset );
- LayoutElements = ElementsBuffer.data();
- NumElements = static_cast<Uint32>( ElementsBuffer.size() );
- }
- private:
- BindingsMapType m_Bindings;
- ValueTypeEnumMapping m_ValueTypeEnumMapping;
- EnumMapping < LayoutElement::FREQUENCY > m_FrequencyEnumMapping;
- size_t m_LayoutElementsOffset;
- size_t m_NumElementsOffset;
- };
-
- LayoutDescParser::LayoutDescParser( IRenderDevice *pRenderDevice, lua_State *L ) :
- EngineObjectParserCommon<IVertexDescription>( pRenderDevice, L, LayoutDescLibName ),
- m_SetInputLayoutBinding( this, L, "Context", "SetInputLayout", &LayoutDescParser::SetInputLayout )
- {
- DEFINE_BUFFERED_STRING_BINDER( m_Bindings, LayoutDescWrapper, Name, NameBuffer )
-
- auto *pLayoutElemBinder =
- new MemberBinder<LayoutElementLoader>(
- offsetof(LayoutDescWrapper, LayoutElements),
- offsetof(LayoutDescWrapper, ElementsBuffer),
- offsetof(LayoutDescWrapper, NumElements)
- );
- m_Bindings.insert( std::make_pair( "LayoutElements", std::unique_ptr<MemberBinderBase>(pLayoutElemBinder) ) );
- };
-
- void LayoutDescParser::CreateObj( lua_State *L )
- {
- INIT_LUA_STACK_TRACKING( L );
-
- LayoutDescWrapper LayoutDesc;
- ParseLuaTable( L, -2, &LayoutDesc, m_Bindings );
- CHECK_LUA_STACK_HEIGHT();
-
- auto ppVertexShader = GetUserData<IShader**>( L, -1, "Metatables.Shader" );
- auto ppVertDesc = reinterpret_cast<IVertexDescription**>(lua_newuserdata( L, sizeof( IVertexDescription* ) ));
- *ppVertDesc = nullptr;
- m_pRenderDevice->CreateVertexDescription( LayoutDesc, *ppVertexShader, ppVertDesc );
- if( *ppVertDesc == nullptr )
- SCRIPT_PARSING_ERROR(L, "Failed to create vertex description")
-
- CHECK_LUA_STACK_HEIGHT( +1 );
- }
-
- int LayoutDescParser::SetInputLayout( lua_State *L )
- {
- auto pVertDesc = *GetUserData<IVertexDescription**>( L, 1, m_MetatableRegistryName.c_str() );
- auto *pContext = LoadDeviceContextFromRegistry( L );
- pContext->SetVertexDescription( pVertDesc );
- return 0;
- }
-}
diff --git a/RenderScript/src/LuaBindings.cpp b/RenderScript/src/LuaBindings.cpp
index 707a33c..9217b67 100644
--- a/RenderScript/src/LuaBindings.cpp
+++ b/RenderScript/src/LuaBindings.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2015 Egor Yusov
+/* Copyright 2015-2016 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/RenderScript/src/LuaFunctionBinding.cpp b/RenderScript/src/LuaFunctionBinding.cpp
index d81634e..a3a3dd1 100644
--- a/RenderScript/src/LuaFunctionBinding.cpp
+++ b/RenderScript/src/LuaFunctionBinding.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2015 Egor Yusov
+/* Copyright 2015-2016 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/RenderScript/src/LuaWrappers.cpp b/RenderScript/src/LuaWrappers.cpp
index 939fdac..1a0e119 100644
--- a/RenderScript/src/LuaWrappers.cpp
+++ b/RenderScript/src/LuaWrappers.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2015 Egor Yusov
+/* Copyright 2015-2016 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/RenderScript/src/PSODescParser.cpp b/RenderScript/src/PSODescParser.cpp
new file mode 100644
index 0000000..9f00f95
--- /dev/null
+++ b/RenderScript/src/PSODescParser.cpp
@@ -0,0 +1,257 @@
+/* Copyright 2015-2016 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+#include "pch.h"
+#include "PSODescParser.h"
+#include "BlendStateDescParser.h"
+#include "RasterizerStateDescParser.h"
+#include "DepthStencilStateDescParser.h"
+#include "InputLayoutDescParser.h"
+
+namespace std
+{
+ DEFINE_ENUM_HASH( Diligent::PRIMITIVE_TOPOLOGY_TYPE )
+}
+
+namespace Diligent
+{
+ class RTVFormatsParser;
+
+ template<>
+ class MemberBinder<RTVFormatsParser> : public MemberBinderBase
+ {
+ public:
+ MemberBinder( size_t /*MemberOffset*/, size_t /*Dummy*/ ) :
+ // We will use a pointer to the GraphicsPipelineDesc structure itself
+ MemberBinderBase( 0 ),
+ m_TexFmtLoader(0, "RTVFormats", m_TexFmtEnumMapping)
+ {
+ }
+
+ virtual void GetValue( lua_State *L, const void* pBasePointer )override
+ {
+ const auto &GraphicsPipeline = GetMemberByOffest< GraphicsPipelineDesc >(pBasePointer, m_MemberOffset);
+ PushLuaArray( L, GraphicsPipeline.RTVFormats, GraphicsPipeline.RTVFormats + GraphicsPipeline.NumRenderTargets, [&]( const TEXTURE_FORMAT &Fmt )
+ {
+ m_TexFmtLoader.GetValue(L, &Fmt);
+ });
+ }
+
+ virtual void SetValue( lua_State *L, int Index, void* pBasePointer )override
+ {
+ auto &GraphicsPipeline = GetMemberByOffest< GraphicsPipelineDesc >( pBasePointer, m_MemberOffset );
+ if(lua_type(L,Index) == LUA_TTABLE)
+ {
+ ParseLuaArray( L, Index, pBasePointer, [&]( void* _pBasePointer, int StackIndex, int NewArrayIndex )
+ {
+ // Lua array indices are 1-based
+ NewArrayIndex -= 1;
+ VERIFY( pBasePointer == _pBasePointer, "Sanity check failed" );
+ if( NewArrayIndex < 0 || NewArrayIndex >= MaxRenderTargets )
+ SCRIPT_PARSING_ERROR( L, "Render target array index ", NewArrayIndex," is out of allowed range [", 0, ' ', MaxRenderTargets-1, ']' );
+
+ m_TexFmtLoader.SetValue(L, StackIndex, &GraphicsPipeline.RTVFormats[NewArrayIndex]);
+ GraphicsPipeline.NumRenderTargets = std::max(GraphicsPipeline.NumRenderTargets, static_cast<Uint32>(NewArrayIndex+1));
+ }
+ );
+ }
+ else if(lua_type(L,Index) == LUA_TSTRING)
+ {
+ m_TexFmtLoader.SetValue(L, Index, &GraphicsPipeline.RTVFormats[0]);
+ GraphicsPipeline.NumRenderTargets = 1;
+ }
+ else
+ {
+ SCRIPT_PARSING_ERROR( L, "Unexpected type ", lua_typename(L, Index), ". Table of strings or a string are expected" );
+ }
+ }
+ private:
+ TextureFormatEnumMapping m_TexFmtEnumMapping;
+ EnumMemberBinder<TEXTURE_FORMAT> m_TexFmtLoader;
+ };
+
+
+ template<>
+ class MemberBinder<SampleDesc> : public MemberBinderBase
+ {
+ public:
+ MemberBinder( size_t MemberOffset, size_t Dummy ) :
+ MemberBinderBase( MemberOffset )
+ {
+ DEFINE_BINDER( m_Bindings, SampleDesc, Count, Uint32, Validator<Uint32>("Count", 1,32) );
+ DEFINE_BINDER( m_Bindings, SampleDesc, Quality, Uint32, Validator<Uint32>("Quality", 0,std::numeric_limits<Uint32>::max()) );
+ }
+
+ virtual void GetValue( lua_State *L, const void* pBasePointer )override
+ {
+ const auto &SmplDesc = GetMemberByOffest< SampleDesc >(pBasePointer, m_MemberOffset);
+ PushLuaTable(L, &SmplDesc, m_Bindings);
+ }
+
+ virtual void SetValue( lua_State *L, int Index, void* pBasePointer )override
+ {
+ auto &SmplDesc = GetMemberByOffest< SampleDesc >( pBasePointer, m_MemberOffset );
+ ParseLuaTable( L, Index, &SmplDesc, m_Bindings );
+ }
+
+ private:
+ BindingsMapType m_Bindings;
+ };
+
+ template<>
+ class MemberBinder<GraphicsPipelineDesc> : public MemberBinderBase
+ {
+ public:
+ MemberBinder( size_t MemberOffset, size_t Dummy ) :
+ MemberBinderBase( MemberOffset )
+ {
+ std::vector<String> AllowedMetatable = { "Metatables.Shader" };
+
+ DEFINE_BINDER( m_Bindings, GraphicsPipelineDesc, pVS, EngineObjectPtrLoader<IShader>, AllowedMetatable );
+ DEFINE_BINDER( m_Bindings, GraphicsPipelineDesc, pPS, EngineObjectPtrLoader<IShader>, AllowedMetatable );
+ DEFINE_BINDER( m_Bindings, GraphicsPipelineDesc, pDS, EngineObjectPtrLoader<IShader>, AllowedMetatable );
+ DEFINE_BINDER( m_Bindings, GraphicsPipelineDesc, pHS, EngineObjectPtrLoader<IShader>, AllowedMetatable );
+ DEFINE_BINDER( m_Bindings, GraphicsPipelineDesc, pGS, EngineObjectPtrLoader<IShader>, AllowedMetatable );
+
+ //D3D12_STREAM_OUTPUT_DESC StreamOutput;
+
+ DEFINE_BINDER( m_Bindings, GraphicsPipelineDesc, BlendDesc, BlendStateDesc, 0 )
+ DEFINE_BINDER( m_Bindings, GraphicsPipelineDesc, SampleMask, Uint32, Validator<Uint32>() )
+ DEFINE_BINDER( m_Bindings, GraphicsPipelineDesc, RasterizerDesc, RasterizerStateDesc, 0 )
+ DEFINE_BINDER( m_Bindings, GraphicsPipelineDesc, DepthStencilDesc, DepthStencilStateDesc, 0 )
+
+ auto *pLayoutElemBinder =
+ new MemberBinder<InputLayoutDesc>(
+ offsetof(GraphicsPipelineDesc, InputLayout),
+ offsetof(PSODescParser::PSODescWrapper, LayoutElementsBuffer) - offsetof(PSODescParser::PSODescWrapper, GraphicsPipeline)
+ );
+ m_Bindings.insert( std::make_pair( "InputLayout", std::unique_ptr<MemberBinderBase>(pLayoutElemBinder) ) );
+
+ //D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue;
+
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyTypeEnumMapping, PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyTypeEnumMapping, PRIMITIVE_TOPOLOGY_TYPE_POINT );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyTypeEnumMapping, PRIMITIVE_TOPOLOGY_TYPE_LINE );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyTypeEnumMapping, PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyTypeEnumMapping, PRIMITIVE_TOPOLOGY_TYPE_PATCH );
+ VERIFY( m_PrimTopologyTypeEnumMapping.m_Str2ValMap.size() == PRIMITIVE_TOPOLOGY_TYPE_NUM_TYPES,
+ "Unexpected map size. Did you update PRIMITIVE_TOPOLOGY_TYPE enum?" );
+ VERIFY( m_PrimTopologyTypeEnumMapping.m_Val2StrMap.size() == PRIMITIVE_TOPOLOGY_TYPE_NUM_TYPES,
+ "Unexpected map size. Did you update PRIMITIVE_TOPOLOGY_TYPE enum?" );
+ DEFINE_ENUM_BINDER( m_Bindings, GraphicsPipelineDesc, PrimitiveTopologyType, PRIMITIVE_TOPOLOGY_TYPE, m_PrimTopologyTypeEnumMapping );
+
+ DEFINE_BINDER( m_Bindings, GraphicsPipelineDesc, RTVFormats, RTVFormatsParser, 0 );
+ DEFINE_ENUM_BINDER( m_Bindings, GraphicsPipelineDesc, DSVFormat, TEXTURE_FORMAT, m_TexFmtEnumMapping );
+
+ DEFINE_BINDER( m_Bindings, GraphicsPipelineDesc, SmplDesc, SampleDesc, 0 );
+
+ //Uint32 NodeMask;
+ }
+
+ virtual void GetValue( lua_State *L, const void* pBasePointer )override
+ {
+ const auto &GraphicsPipeline = GetMemberByOffest< GraphicsPipelineDesc >(pBasePointer, m_MemberOffset);
+ PushLuaTable(L, &GraphicsPipeline, m_Bindings);
+ }
+
+ virtual void SetValue( lua_State *L, int Index, void* pBasePointer )override
+ {
+ auto &GraphicsPipeline = GetMemberByOffest< GraphicsPipelineDesc >( pBasePointer, m_MemberOffset );
+ ParseLuaTable( L, Index, &GraphicsPipeline, m_Bindings );
+ }
+ private:
+ TextureFormatEnumMapping m_TexFmtEnumMapping;
+ EnumMapping < PRIMITIVE_TOPOLOGY_TYPE > m_PrimTopologyTypeEnumMapping;
+ BindingsMapType m_Bindings;
+ };
+
+
+ template<>
+ class MemberBinder<ComputePipelineDesc> : public MemberBinderBase
+ {
+ public:
+ MemberBinder( size_t MemberOffset, size_t Dummy ) :
+ MemberBinderBase( MemberOffset )
+ {
+ std::vector<String> AllowedMetatable = { "Metatables.Shader" };
+ DEFINE_BINDER( m_Bindings, ComputePipelineDesc, pCS, EngineObjectPtrLoader<IShader>, AllowedMetatable );
+ }
+
+ virtual void GetValue( lua_State *L, const void* pBasePointer )override
+ {
+ const auto &ComputePipeline = GetMemberByOffest< ComputePipelineDesc >(pBasePointer, m_MemberOffset);
+ PushLuaTable(L, &ComputePipeline, m_Bindings);
+ }
+
+ virtual void SetValue( lua_State *L, int Index, void* pBasePointer )override
+ {
+ auto &ComputePipeline = GetMemberByOffest< ComputePipelineDesc >( pBasePointer, m_MemberOffset );
+ ParseLuaTable( L, Index, &ComputePipeline, m_Bindings );
+ }
+ private:
+ BindingsMapType m_Bindings;
+ };
+
+
+ const Char* PSODescParser::PSODescLibName = "PipelineState";
+ PSODescParser::PSODescParser( IRenderDevice *pRenderDevice, lua_State *L ) :
+ EngineObjectParserCommon<IPipelineState>( pRenderDevice, L, PSODescLibName ),
+ m_SetPSOBinding( this, L, "Context", "SetPipelineState", &PSODescParser::SetPSO )
+ {
+ DEFINE_BUFFERED_STRING_BINDER( m_Bindings, PSODescWrapper, Name, NameBuffer )
+
+ DEFINE_BINDER( m_Bindings, PSODescWrapper, IsComputePipeline, Bool, Validator<Bool>() )
+ DEFINE_BINDER( m_Bindings, PSODescWrapper, SRBAllocationGranularity, Uint32, Validator<Uint32>("SRBAllocationGranularity", 1, 65536) )
+
+ DEFINE_BINDER( m_Bindings, PSODescWrapper, GraphicsPipeline, GraphicsPipelineDesc, 0 )
+ DEFINE_BINDER( m_Bindings, PSODescWrapper, ComputePipeline, ComputePipelineDesc, 0 )
+ };
+
+ void PSODescParser::CreateObj( lua_State *L )
+ {
+ INIT_LUA_STACK_TRACKING( L );
+
+ PSODescWrapper PSODesc;
+ ParseLuaTable( L, 1, &PSODesc, m_Bindings );
+
+ CHECK_LUA_STACK_HEIGHT();
+
+ auto ppPSO = reinterpret_cast<IPipelineState**>(lua_newuserdata( L, sizeof( IPipelineState* ) ));
+ *ppPSO = nullptr;
+ m_pRenderDevice->CreatePipelineState( PSODesc, ppPSO );
+ if( *ppPSO == nullptr )
+ SCRIPT_PARSING_ERROR( L, "Failed to create Pipeline State Object state object" )
+
+ CHECK_LUA_STACK_HEIGHT( +1 );
+ }
+
+ int PSODescParser::SetPSO( lua_State *L )
+ {
+ auto *pPSO = *GetUserData<IPipelineState**>( L, 1, m_MetatableRegistryName.c_str() );
+
+ auto *pContext = LoadDeviceContextFromRegistry( L );
+ pContext->SetPipelineState( pPSO );
+
+ return 0;
+ }
+}
diff --git a/RenderScript/src/ParsingErrors.cpp b/RenderScript/src/ParsingErrors.cpp
index bb78387..e3db2b0 100644
--- a/RenderScript/src/ParsingErrors.cpp
+++ b/RenderScript/src/ParsingErrors.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2015 Egor Yusov
+/* Copyright 2015-2016 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/RenderScript/src/RasterizerStateDescParser.cpp b/RenderScript/src/RasterizerStateDescParser.cpp
new file mode 100644
index 0000000..3032874
--- /dev/null
+++ b/RenderScript/src/RasterizerStateDescParser.cpp
@@ -0,0 +1,70 @@
+/* Copyright 2015-2016 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+#include "pch.h"
+#include "RasterizerStateDescParser.h"
+
+namespace Diligent
+{
+
+ MemberBinder<RasterizerStateDesc>::MemberBinder( size_t MemberOffset, size_t Dummy ) :
+ MemberBinderBase(MemberOffset)
+ {
+ DEFINE_ENUM_ELEMENT_MAPPING( m_FillModeEnumMapping, FILL_MODE_WIREFRAME );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_FillModeEnumMapping, FILL_MODE_SOLID );
+ VERIFY( m_FillModeEnumMapping.m_Str2ValMap.size() == FILL_MODE_NUM_MODES-1,
+ "Unexpected map size. Did you update FILL_MODE enum?" );
+ VERIFY( m_FillModeEnumMapping.m_Val2StrMap.size() == FILL_MODE_NUM_MODES-1,
+ "Unexpected map size. Did you update FILL_MODE enum?" );
+ DEFINE_ENUM_BINDER( m_Bindings, RasterizerStateDesc, FillMode, FILL_MODE, m_FillModeEnumMapping );
+
+ DEFINE_ENUM_ELEMENT_MAPPING( m_CullModeEnumMapping, CULL_MODE_NONE );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_CullModeEnumMapping, CULL_MODE_FRONT );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_CullModeEnumMapping, CULL_MODE_BACK );
+ VERIFY( m_CullModeEnumMapping.m_Str2ValMap.size() == CULL_MODE_NUM_MODES-1,
+ "Unexpected map size. Did you update CULL_MODE enum?" );
+ VERIFY( m_CullModeEnumMapping.m_Val2StrMap.size() == CULL_MODE_NUM_MODES-1,
+ "Unexpected map size. Did you update CULL_MODE enum?" );
+ DEFINE_ENUM_BINDER( m_Bindings, RasterizerStateDesc, CullMode, CULL_MODE, m_CullModeEnumMapping );
+
+ DEFINE_BINDER( m_Bindings, RasterizerStateDesc, FrontCounterClockwise, Bool, Validator<Bool>() );
+ DEFINE_BINDER( m_Bindings, RasterizerStateDesc, DepthBias, Int32, Validator<Int32>() );
+ DEFINE_BINDER( m_Bindings, RasterizerStateDesc, DepthBiasClamp, Float32, Validator<Float32>() );
+ DEFINE_BINDER( m_Bindings, RasterizerStateDesc, SlopeScaledDepthBias, Float32, Validator<Float32>() );
+ DEFINE_BINDER( m_Bindings, RasterizerStateDesc, DepthClipEnable, Bool, Validator<Bool>() );
+ DEFINE_BINDER( m_Bindings, RasterizerStateDesc, ScissorEnable, Bool, Validator<Bool>() );
+ DEFINE_BINDER( m_Bindings, RasterizerStateDesc, AntialiasedLineEnable, Bool, Validator<Bool>() );
+ };
+
+ void MemberBinder<RasterizerStateDesc> ::GetValue(lua_State *L, const void* pBasePointer)
+ {
+ const auto &RasterizerDesc = GetMemberByOffest< RasterizerStateDesc >(pBasePointer, m_MemberOffset);
+ PushLuaTable(L, &RasterizerDesc, m_Bindings);
+ }
+
+ void MemberBinder<RasterizerStateDesc> ::SetValue(lua_State *L, int Index, void* pBasePointer)
+ {
+ auto &RasterizerDesc = GetMemberByOffest< RasterizerStateDesc>( pBasePointer, m_MemberOffset );
+ ParseLuaTable( L, Index, &RasterizerDesc, m_Bindings );
+ }
+}
diff --git a/RenderScript/src/RasterizerStateParser.cpp b/RenderScript/src/RasterizerStateParser.cpp
deleted file mode 100644
index 1cac9ed..0000000
--- a/RenderScript/src/RasterizerStateParser.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/* Copyright 2015 Egor Yusov
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
- *
- * In no event and under no legal theory, whether in tort (including negligence),
- * contract, or otherwise, unless required by applicable law (such as deliberate
- * and grossly negligent acts) or agreed to in writing, shall any Contributor be
- * liable for any damages, including any direct, indirect, special, incidental,
- * or consequential damages of any character arising as a result of this License or
- * out of the use or inability to use the software (including but not limited to damages
- * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
- * all other commercial damages or losses), even if such Contributor has been advised
- * of the possibility of such damages.
- */
-
-#include "pch.h"
-#include "RasterizerStateParser.h"
-
-
-namespace Diligent
-{
- const Char* RasterizerStateParser::RasterizerStateLibName = "RasterizerState";
-
- RasterizerStateParser::RasterizerStateParser( IRenderDevice *pRenderDevice, lua_State *L ) :
- EngineObjectParserCommon<IRasterizerState>( pRenderDevice, L, RasterizerStateLibName ),
- m_SetRasterizerBinding( this, L, "Context", "SetRasterizerState", &RasterizerStateParser::SetRasterizerState )
- {
- DEFINE_BUFFERED_STRING_BINDER( m_Bindings, SRSDescWrapper, Name, NameBuffer )
-
- DEFINE_ENUM_ELEMENT_MAPPING( m_FillModeEnumMapping, FILL_MODE_WIREFRAME );
- DEFINE_ENUM_ELEMENT_MAPPING( m_FillModeEnumMapping, FILL_MODE_SOLID );
- VERIFY( m_FillModeEnumMapping.m_Str2ValMap.size() == FILL_MODE_NUM_MODES-1,
- "Unexpected map size. Did you update FILL_MODE enum?" );
- VERIFY( m_FillModeEnumMapping.m_Val2StrMap.size() == FILL_MODE_NUM_MODES-1,
- "Unexpected map size. Did you update FILL_MODE enum?" );
- DEFINE_ENUM_BINDER( m_Bindings, SRSDescWrapper, FillMode, FILL_MODE, m_FillModeEnumMapping );
-
- DEFINE_ENUM_ELEMENT_MAPPING( m_CullModeEnumMapping, CULL_MODE_NONE );
- DEFINE_ENUM_ELEMENT_MAPPING( m_CullModeEnumMapping, CULL_MODE_FRONT );
- DEFINE_ENUM_ELEMENT_MAPPING( m_CullModeEnumMapping, CULL_MODE_BACK );
- VERIFY( m_CullModeEnumMapping.m_Str2ValMap.size() == CULL_MODE_NUM_MODES-1,
- "Unexpected map size. Did you update CULL_MODE enum?" );
- VERIFY( m_CullModeEnumMapping.m_Val2StrMap.size() == CULL_MODE_NUM_MODES-1,
- "Unexpected map size. Did you update CULL_MODE enum?" );
- DEFINE_ENUM_BINDER( m_Bindings, SRSDescWrapper, CullMode, CULL_MODE, m_CullModeEnumMapping );
-
- DEFINE_BINDER( m_Bindings, SRSDescWrapper, FrontCounterClockwise, Bool, Validator<Bool>() );
- DEFINE_BINDER( m_Bindings, SRSDescWrapper, DepthBias, Int32, Validator<Int32>() );
- DEFINE_BINDER( m_Bindings, SRSDescWrapper, DepthBiasClamp, Float32, Validator<Float32>() );
- DEFINE_BINDER( m_Bindings, SRSDescWrapper, SlopeScaledDepthBias, Float32, Validator<Float32>() );
- DEFINE_BINDER( m_Bindings, SRSDescWrapper, DepthClipEnable, Bool, Validator<Bool>() );
- DEFINE_BINDER( m_Bindings, SRSDescWrapper, ScissorEnable, Bool, Validator<Bool>() );
- DEFINE_BINDER( m_Bindings, SRSDescWrapper, AntialiasedLineEnable, Bool, Validator<Bool>() );
- };
-
- void RasterizerStateParser::CreateObj( lua_State *L )
- {
- INIT_LUA_STACK_TRACKING( L );
-
- SRSDescWrapper RasterizerDesc;
- ParseLuaTable( L, 1, &RasterizerDesc, m_Bindings );
-
- CHECK_LUA_STACK_HEIGHT();
-
- auto ppRasterizerState = reinterpret_cast<IRasterizerState**>(lua_newuserdata( L, sizeof( IRasterizerState* ) ));
- *ppRasterizerState = nullptr;
- m_pRenderDevice->CreateRasterizerState( RasterizerDesc, ppRasterizerState );
- if( *ppRasterizerState == nullptr )
- SCRIPT_PARSING_ERROR(L, "Failed to create rasterizer state")
-
- CHECK_LUA_STACK_HEIGHT( +1 );
- }
-
- int RasterizerStateParser::SetRasterizerState( lua_State *L )
- {
- auto *pRS = *GetUserData<IRasterizerState**>( L, 1, m_MetatableRegistryName.c_str() );
- auto *pContext = LoadDeviceContextFromRegistry( L );
- pContext->SetRasterizerState( pRS );
- return 0;
- }
-}
diff --git a/RenderScript/src/ResourceMappingParser.cpp b/RenderScript/src/ResourceMappingParser.cpp
index e3f4918..558685e 100644
--- a/RenderScript/src/ResourceMappingParser.cpp
+++ b/RenderScript/src/ResourceMappingParser.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2015 Egor Yusov
+/* Copyright 2015-2016 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +36,6 @@ namespace Diligent
BufferParser *pBuffParser,
BufferViewParser *pBuffViewParser ) :
EngineObjectParserBase( pRenderDevice, L, ResourceMappingLibName),
- m_BindShaderResourcesBinding( this, L, "Context", "BindShaderResources", &ResourceMappingParser::BindShaderResources ),
m_pTexViewParser( pTexViewParser ),
m_pBuffParser( pBuffParser ),
m_pBuffViewParser( pBuffViewParser ),
@@ -131,25 +130,6 @@ namespace Diligent
}
}
- int ResourceMappingParser::BindShaderResources( lua_State *L )
- {
- auto *pContext = LoadDeviceContextFromRegistry( L );
- auto pResMapping = *GetUserData<IResourceMapping**>( L, 1, m_MetatableRegistryName.c_str() );
- Uint32 Flags = 0;
- auto NumArgs = lua_gettop( L );
- // The last argument may be flags
- const int FlagsArgInd = 2;
- if( NumArgs >= FlagsArgInd &&
- (lua_type( L, FlagsArgInd ) == LUA_TSTRING || lua_type( L, FlagsArgInd ) == LUA_TTABLE ) )
- {
- FlagsLoader<BIND_SHADER_RESOURCES_FLAGS> FlagsLoader(0, "BindShaderResourceFlags", m_BindShaderResFlagEnumMapping);
- FlagsLoader.SetValue( L, FlagsArgInd, &Flags );
- }
-
- pContext->BindShaderResources( pResMapping, Flags );
- return 0;
- }
-
void ResourceMappingParser::GetObjectByName( lua_State *L, const Char *ShaderName, IResourceMapping** ppObject )
{
auto pObject = *GetGlobalObject<IResourceMapping**>( L, ShaderName, m_MetatableRegistryName.c_str() );
diff --git a/RenderScript/src/SamplerParser.cpp b/RenderScript/src/SamplerParser.cpp
index 74aa71f..864a5df 100644
--- a/RenderScript/src/SamplerParser.cpp
+++ b/RenderScript/src/SamplerParser.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2015 Egor Yusov
+/* Copyright 2015-2016 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,43 +33,7 @@ namespace Diligent
{
DEFINE_BUFFERED_STRING_BINDER( m_Bindings, SSamDescWrapper, Name, NameBuffer )
- DEFINE_ENUM_ELEMENT_MAPPING( m_FilterTypeEnumMapping, FILTER_TYPE_POINT );
- DEFINE_ENUM_ELEMENT_MAPPING( m_FilterTypeEnumMapping, FILTER_TYPE_LINEAR );
- DEFINE_ENUM_ELEMENT_MAPPING( m_FilterTypeEnumMapping, FILTER_TYPE_ANISOTROPIC );
- DEFINE_ENUM_ELEMENT_MAPPING( m_FilterTypeEnumMapping, FILTER_TYPE_COMPARISON_POINT );
- DEFINE_ENUM_ELEMENT_MAPPING( m_FilterTypeEnumMapping, FILTER_TYPE_COMPARISON_LINEAR );
- DEFINE_ENUM_ELEMENT_MAPPING( m_FilterTypeEnumMapping, FILTER_TYPE_COMPARISON_ANISOTROPIC );
- VERIFY( m_FilterTypeEnumMapping.m_Str2ValMap.size() == FILTER_TYPE_NUM_FILTERS - 1, "Unexpected map size. Did you update FILTER_TYPE enum?" );
- VERIFY( m_FilterTypeEnumMapping.m_Val2StrMap.size() == FILTER_TYPE_NUM_FILTERS - 1, "Unexpected map size. Did you update FILTER_TYPE enum?" );
- DEFINE_ENUM_BINDER( m_Bindings, SSamDescWrapper, MinFilter, FILTER_TYPE, m_FilterTypeEnumMapping )
- DEFINE_ENUM_BINDER( m_Bindings, SSamDescWrapper, MagFilter, FILTER_TYPE, m_FilterTypeEnumMapping )
- DEFINE_ENUM_BINDER( m_Bindings, SSamDescWrapper, MipFilter, FILTER_TYPE, m_FilterTypeEnumMapping )
-
-
- DEFINE_ENUM_ELEMENT_MAPPING( m_TexAddrModeEnumMapping, TEXTURE_ADDRESS_WRAP );
- DEFINE_ENUM_ELEMENT_MAPPING( m_TexAddrModeEnumMapping, TEXTURE_ADDRESS_MIRROR );
- DEFINE_ENUM_ELEMENT_MAPPING( m_TexAddrModeEnumMapping, TEXTURE_ADDRESS_CLAMP );
- DEFINE_ENUM_ELEMENT_MAPPING( m_TexAddrModeEnumMapping, TEXTURE_ADDRESS_BORDER );
- DEFINE_ENUM_ELEMENT_MAPPING( m_TexAddrModeEnumMapping, TEXTURE_ADDRESS_MIRROR_ONCE );
- VERIFY( m_TexAddrModeEnumMapping.m_Str2ValMap.size() == TEXTURE_ADDRESS_NUM_MODES - 1, "Unexpected map size. Did you update TEXTURE_ADDRESS_MODE enum?" );
- VERIFY( m_TexAddrModeEnumMapping.m_Val2StrMap.size() == TEXTURE_ADDRESS_NUM_MODES - 1, "Unexpected map size. Did you update TEXTURE_ADDRESS_MODE enum?" );
- DEFINE_ENUM_BINDER( m_Bindings, SSamDescWrapper, AddressU, TEXTURE_ADDRESS_MODE, m_TexAddrModeEnumMapping )
- DEFINE_ENUM_BINDER( m_Bindings, SSamDescWrapper, AddressV, TEXTURE_ADDRESS_MODE, m_TexAddrModeEnumMapping )
- DEFINE_ENUM_BINDER( m_Bindings, SSamDescWrapper, AddressW, TEXTURE_ADDRESS_MODE, m_TexAddrModeEnumMapping )
-
-
- Validator<Float32> DummyValidatorF( SkipValidationFunc<float> );
- DEFINE_BINDER( m_Bindings, SSamDescWrapper, MipLODBias, Float32, DummyValidatorF )
-
- Validator<Uint32> MaxAnisotropyValidator( "Max Anisotropy", 0, 32 );
- DEFINE_BINDER( m_Bindings, SSamDescWrapper, MaxAnisotropy, Uint32, MaxAnisotropyValidator )
-
- DEFINE_ENUM_BINDER( m_Bindings, SSamDescWrapper, ComparisonFunc, COMPARISON_FUNCTION, m_CmpFuncEnumMapping )
-
- DEFINE_BINDER( m_Bindings, SSamDescWrapper, BorderColor, RGBALoader, 0 )
-
- DEFINE_BINDER( m_Bindings, SSamDescWrapper, MinLOD, Float32, DummyValidatorF )
- DEFINE_BINDER( m_Bindings, SSamDescWrapper, MaxLOD, Float32, DummyValidatorF )
+ InitSamplerParserBindings<SSamDescWrapper>(m_Bindings, m_FilterTypeEnumMapping, m_TexAddrModeEnumMapping, m_CmpFuncEnumMapping);
};
void SamplerParser::CreateObj( lua_State *L )
diff --git a/RenderScript/src/ScissorRectParser.cpp b/RenderScript/src/ScissorRectParser.cpp
index 3f81087..dc573e4 100644
--- a/RenderScript/src/ScissorRectParser.cpp
+++ b/RenderScript/src/ScissorRectParser.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2015 Egor Yusov
+/* Copyright 2015-2016 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/RenderScript/src/ScriptParser.cpp b/RenderScript/src/ScriptParser.cpp
index 3331eac..6147f1b 100644
--- a/RenderScript/src/ScriptParser.cpp
+++ b/RenderScript/src/ScriptParser.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2015 Egor Yusov
+/* Copyright 2015-2016 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +25,6 @@
#include "ScriptParser.h"
#include "LuaBindings.h"
#include "SamplerParser.h"
-#include "LayoutDescParser.h"
#include "ShaderParser.h"
#include "BufferParser.h"
#include "TextureParser.h"
@@ -34,13 +33,12 @@
#include "ResourceMappingParser.h"
#include "TextureViewParser.h"
#include "BufferViewParser.h"
-#include "DepthStencilStateParser.h"
-#include "RasterizerStateParser.h"
-#include "BlendStateParser.h"
+#include "PSODescParser.h"
#include "DeviceContextFuncBindings.h"
#include "ViewportParser.h"
#include "ScissorRectParser.h"
#include "ShaderVariableParser.h"
+#include "ShaderResourceBindingParser.h"
using namespace Diligent;
using namespace Diligent;
@@ -61,17 +59,15 @@ namespace Diligent
}
IMPLEMENT_PUSH_FUNC_STUBS( ISampler, m_pSamplerParser)
- IMPLEMENT_PUSH_FUNC_STUBS( IVertexDescription, m_pLayoutDescParser )
IMPLEMENT_PUSH_FUNC_STUBS( IShader, m_pShaderParser )
IMPLEMENT_PUSH_FUNC_STUBS( IBuffer, m_pBufferParser )
IMPLEMENT_PUSH_FUNC_STUBS( ITexture, m_pTextureParser )
IMPLEMENT_PUSH_FUNC_STUBS( IResourceMapping, m_pResourceMappingParser )
IMPLEMENT_PUSH_FUNC_STUBS( ITextureView, m_pTextureViewParser )
IMPLEMENT_PUSH_FUNC_STUBS( IBufferView, m_pBufferViewParser )
- IMPLEMENT_PUSH_FUNC_STUBS( IDepthStencilState, m_pDSStateParser )
- IMPLEMENT_PUSH_FUNC_STUBS( IRasterizerState, m_pRSParser )
- IMPLEMENT_PUSH_FUNC_STUBS( IBlendState, m_pBSParser )
+ IMPLEMENT_PUSH_FUNC_STUBS( IPipelineState, m_pPSOParser )
IMPLEMENT_PUSH_FUNC_STUBS( IShaderVariable, m_pShaderVariableParser )
+ IMPLEMENT_PUSH_FUNC_STUBS( IShaderResourceBinding, m_pShaderResBindingParser )
void ScriptParser::SpecialPushFuncs::PushFuncStub( lua_State *L, const DrawAttribs &DrawAttribs )
@@ -103,7 +99,6 @@ namespace Diligent
DefineGlobalConstants(m_LuaState);
m_pSamplerParser.reset( new SamplerParser( pRenderDevice, m_LuaState ) );
- m_pLayoutDescParser.reset( new LayoutDescParser( pRenderDevice, m_LuaState ) );
m_pBufferParser.reset( new BufferParser( pRenderDevice, m_LuaState ) );
m_pTextureParser.reset( new TextureParser( pRenderDevice, m_LuaState ) );
m_pDrawAttribsParser.reset( new DrawAttribsParser( m_pBufferParser.get(), pRenderDevice, m_LuaState ) );
@@ -113,13 +108,12 @@ namespace Diligent
m_pBufferViewParser.reset( new BufferViewParser( m_pBufferParser.get(), pRenderDevice, m_LuaState ) );
m_pResourceMappingParser.reset( new ResourceMappingParser( pRenderDevice, m_LuaState, m_pTextureViewParser.get(), m_pBufferParser.get(), m_pBufferViewParser.get() ) );
m_pShaderParser.reset( new ShaderParser( pRenderDevice, m_LuaState, m_pResourceMappingParser->GetMetatableName() ) );
- m_pDSStateParser.reset( new DepthStencilStateParser( pRenderDevice, m_LuaState ) );
- m_pRSParser.reset( new RasterizerStateParser( pRenderDevice, m_LuaState ) );
- m_pBSParser.reset( new BlendStateParser( pRenderDevice, m_LuaState ) );
- m_pDeviceCtxFuncBindings.reset( new DeviceContextFuncBindings( pRenderDevice, m_LuaState, m_pTextureViewParser.get() ) );
+ m_pPSOParser.reset( new PSODescParser( pRenderDevice, m_LuaState ) );
m_pViewportParser.reset( new ViewportParser( pRenderDevice, m_LuaState ) );
m_pScissorRectParser.reset( new ScissorRectParser( pRenderDevice, m_LuaState ) );
m_pShaderVariableParser.reset( new ShaderVariableParser( pRenderDevice, m_LuaState, m_pShaderParser->GetMetatableName(), m_pBufferParser->GetMetatableName(), m_pBufferViewParser->GetMetatableName(), m_pTextureViewParser->GetMetatableName() ) );
+ m_pShaderResBindingParser.reset( new ShaderResourceBindingParser( pRenderDevice, m_LuaState, m_pPSOParser->GetMetatableName(), m_pResourceMappingParser->GetMetatableName(), m_pShaderVariableParser->GetMetatableName() ) );
+ m_pDeviceCtxFuncBindings.reset( new DeviceContextFuncBindings( pRenderDevice, m_LuaState, m_pTextureViewParser.get(), m_pShaderResBindingParser.get(), m_pPSOParser.get() ) );
}
ScriptParser::~ScriptParser()
@@ -148,8 +142,12 @@ namespace Diligent
pDeviceStr = "OpenGLES";
break;
- case DeviceType::DirectX:
- pDeviceStr = "DirectX";
+ case DeviceType::D3D11:
+ pDeviceStr = "D3D11";
+ break;
+
+ case DeviceType::D3D12:
+ pDeviceStr = "D3D12";
break;
default:
@@ -201,11 +199,6 @@ namespace Diligent
m_pSamplerParser->GetObjectByName( m_LuaState, SamplerName, ppSampler );
}
- void ScriptParser::GetVertexDescriptionByName( const Char *VertDescName, IVertexDescription** ppVertDesc )
- {
- m_pLayoutDescParser->GetObjectByName( m_LuaState, VertDescName, ppVertDesc );
- }
-
void ScriptParser::GetShaderByName( const Char *ShaderName, IShader** ppShader )
{
m_pShaderParser->GetObjectByName( m_LuaState, ShaderName, ppShader );
@@ -236,19 +229,9 @@ namespace Diligent
m_pBufferViewParser->GetObjectByName( m_LuaState, BufferViewName, ppBufferView );
}
- void ScriptParser::GetDepthStencilStateByName( const Char *DepthStencilStateName, IDepthStencilState** ppDepthStencilState )
- {
- m_pDSStateParser->GetObjectByName( m_LuaState, DepthStencilStateName, ppDepthStencilState );
- }
-
- void ScriptParser::GetRasterizerStateByName( const Char *RasterizerStateName, IRasterizerState** ppRasterizerState )
- {
- m_pRSParser->GetObjectByName( m_LuaState, RasterizerStateName, ppRasterizerState );
- }
-
- void ScriptParser::GetBlendStateByName( const Char *BlendStateName, IBlendState** ppBlendState )
+ void ScriptParser::GetPipelineStateByName( const Char *PSOName, IPipelineState** ppPSO )
{
- m_pBSParser->GetObjectByName( m_LuaState, BlendStateName, ppBlendState );
+ m_pPSOParser->GetObjectByName( m_LuaState, PSOName, ppPSO );
}
void ScriptParser::GetShaderVariableByName( const Char *ShaderVarName, IShaderVariable** ppShaderVar )
diff --git a/RenderScript/src/ShaderParser.cpp b/RenderScript/src/ShaderParser.cpp
index 38bdee3..de85150 100644
--- a/RenderScript/src/ShaderParser.cpp
+++ b/RenderScript/src/ShaderParser.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2015 Egor Yusov
+/* Copyright 2015-2016 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,23 +24,261 @@
#include "pch.h"
#include "ShaderParser.h"
#include "BasicShaderSourceStreamFactory.h"
+#include "SamplerParser.h"
+
namespace std
{
- DEFINE_ENUM_HASH( Diligent::SHADER_TYPE )
+ DEFINE_ENUM_HASH( Diligent::SHADER_VARIABLE_TYPE )
}
namespace Diligent
{
const Char* ShaderParser::ShaderLibName = "Shader";
+
+ class ShaderVariableTypeEnumMapping : public EnumMapping < Diligent::SHADER_VARIABLE_TYPE >
+ {
+ public:
+ ShaderVariableTypeEnumMapping()
+ {
+ DEFINE_ENUM_ELEMENT_MAPPING( (*this), SHADER_VARIABLE_TYPE_STATIC );
+ DEFINE_ENUM_ELEMENT_MAPPING( (*this), SHADER_VARIABLE_TYPE_MUTABLE );
+ DEFINE_ENUM_ELEMENT_MAPPING( (*this), SHADER_VARIABLE_TYPE_DYNAMIC );
+ }
+ };
+
+ class ShaderVariableDescArrayParser;
+ template<>
+ class MemberBinder<ShaderVariableDescArrayParser> : public MemberBinderBase
+ {
+ public:
+ MemberBinder( size_t VariableDescOffset,
+ size_t NumVariablesOffset,
+ size_t VarDescBufferOffset,
+ size_t VarNamesBufferOffset ) :
+ MemberBinderBase( VariableDescOffset ),
+ m_NumVariablesOffset(NumVariablesOffset),
+ m_VarDescBufferOffset(VarDescBufferOffset),
+ m_VarNamesBufferOffset(VarNamesBufferOffset)
+ {
+ DEFINE_ENUM_BINDER( m_Bindings, ShaderVariableDesc, Type, SHADER_VARIABLE_TYPE, m_ShaderVarTypeEnumMapping )
+ }
+
+ virtual void GetValue( lua_State *L, const void* pBasePointer )override
+ {
+ // Use raw pointer to push the value to Lua because the buffer
+ // most likely does not exist
+ const auto &VarDesc = GetMemberByOffest<ShaderVariableDesc*>( pBasePointer, m_MemberOffset);
+ const auto &NumVars = GetMemberByOffest<Uint32>( pBasePointer, m_NumVariablesOffset);
+
+ PushLuaArray( L, VarDesc, VarDesc + NumVars, [&]( const ShaderVariableDesc &VarDesc )
+ {
+ // Push variable type. The function will leave the new table on top
+ // of the stack
+ PushLuaTable( L, &VarDesc, m_Bindings ); // Stack: +1
+
+ // Push name into the same table
+ lua_pushstring( L, "Name" ); // Stack: +2
+ lua_pushstring( L, VarDesc.Name); // Stack: +3
+ lua_settable( L, -3 ); // Stack: +1
+ }
+ );
+ }
+
+ virtual void SetValue( lua_State *L, int Index, void* pBasePointer )
+ {
+ auto &ShaderVarDescBuffer = GetMemberByOffest<std::vector<ShaderVariableDesc>>( pBasePointer, m_VarDescBufferOffset);
+ auto &ShaderNamesBuffer = GetMemberByOffest<std::vector<String>>( pBasePointer, m_VarNamesBufferOffset);
+
+ ParseLuaArray( L, Index, pBasePointer,
+ [&]( void* _pBasePointer, int StackIndex, int NewArrayIndex )
+ {
+ VERIFY_EXPR( pBasePointer == _pBasePointer );
+
+ auto CurrIndex = ShaderVarDescBuffer.size();
+ if( CurrIndex != NewArrayIndex - 1 )
+ SCRIPT_PARSING_ERROR( L, "Explicit array indices are not allowed in shader name description. Provided index ", NewArrayIndex - 1, " conflicts with actual index ", CurrIndex, "." );
+ ShaderVarDescBuffer.resize( CurrIndex + 1 );
+ ShaderNamesBuffer.resize( CurrIndex + 1 );
+ ParseLuaTable( L, StackIndex, &(ShaderVarDescBuffer)[CurrIndex],
+ [&](int TblStackInd, void* __pBasePointer, const char *Key)
+ {
+ auto Binding = m_Bindings.find( Key );
+ if( Binding != m_Bindings.end() )
+ {
+ Binding->second->SetValue( L, TblStackInd, __pBasePointer );
+ }
+ else if (strcmp(Key, "Name") == 0)
+ {
+ auto Name = ReadValueFromLua<const Char*>(L, TblStackInd);
+ ShaderNamesBuffer[CurrIndex] = Name;
+ }
+ else
+ {
+ SCRIPT_PARSING_ERROR( L, "Unknown Member \"", Key, '\"' );
+ }
+ }
+ );
+
+ if( ShaderNamesBuffer[CurrIndex].length() == 0 )
+ SCRIPT_PARSING_ERROR(L, "Missing shader variable name")
+ }
+ );
+
+ for(size_t v=0; v < ShaderVarDescBuffer.size(); ++v)
+ {
+ ShaderVarDescBuffer[v].Name = ShaderNamesBuffer[v].c_str();
+ }
+
+ auto &VarDesc = GetMemberByOffest<ShaderVariableDesc*>( pBasePointer, m_MemberOffset);
+ auto &NumVars = GetMemberByOffest<Uint32>( pBasePointer, m_NumVariablesOffset);
+ NumVars = static_cast<Uint32>(ShaderVarDescBuffer.size());
+ VarDesc = NumVars ? ShaderVarDescBuffer.data() : nullptr;
+ }
+ private:
+ BindingsMapType m_Bindings;
+ ShaderVariableTypeEnumMapping m_ShaderVarTypeEnumMapping;
+ ShaderTypeEnumMapping m_ShaderTypeEnumMapping;
+ size_t m_NumVariablesOffset;
+ size_t m_VarDescBufferOffset;
+ size_t m_VarNamesBufferOffset;
+ };
+
+
+ class StaticSamplerDescArrayParser;
+ template<>
+ class MemberBinder<StaticSamplerDescArrayParser> : public MemberBinderBase
+ {
+ public:
+ MemberBinder( size_t StaticSamplerDescOffset,
+ size_t NumStaticSamplersOffset,
+ size_t StaticSamplersBufferOffset,
+ size_t StaticSamplerTexNamesBufferOffset ) :
+ MemberBinderBase( StaticSamplerDescOffset ),
+ m_NumStaticSamplersOffset(NumStaticSamplersOffset),
+ m_StaticSamplersBufferOffset(StaticSamplersBufferOffset),
+ m_StaticSamplerTexNamesBufferOffset(StaticSamplerTexNamesBufferOffset)
+ {
+ InitSamplerParserBindings<SamplerDesc>(m_Bindings, m_FilterTypeEnumMapping, m_TexAddrModeEnumMapping, m_CmpFuncEnumMapping);
+ }
+
+ virtual void GetValue( lua_State *L, const void* pBasePointer )override
+ {
+ // Use raw pointer to push the value to Lua because the buffer
+ // most likely does not exist
+ const auto &StaticSamplers = GetMemberByOffest<StaticSamplerDesc*>( pBasePointer, m_MemberOffset);
+ const auto &NumStaticSamplers = GetMemberByOffest<Uint32>( pBasePointer, m_NumStaticSamplersOffset);
+
+ PushLuaArray( L, StaticSamplers, StaticSamplers + NumStaticSamplers, [&]( const StaticSamplerDesc &SamDesc )
+ {
+ // Push new table to hold variables of StaticSamplerDesc struct
+ lua_newtable(L); // Stack: +1
+
+ // Push "Desc" field
+ lua_pushstring( L, "Desc" ); // Stack: +2
+ // Push members of StaticSamplerDesc::Desc. The function will leave new table on top
+ // of the stack
+ PushLuaTable( L, &SamDesc.Desc, m_Bindings ); // Stack: +3
+ // Push the table from the top into the parent table
+ lua_settable( L, -3 ); // Stack: +1
+
+ // Push "TextureName" field
+ lua_pushstring( L, "TextureName" ); // Stack: +2
+ lua_pushstring( L, SamDesc.TextureName); // Stack: +3
+ lua_settable( L, -3 ); // Stack: +1
+ }
+ );
+ }
+
+ virtual void SetValue( lua_State *L, int Index, void* pBasePointer )
+ {
+ auto &StaticSamplersBuffer = GetMemberByOffest<std::vector<StaticSamplerDesc>>( pBasePointer, m_StaticSamplersBufferOffset);
+ auto &StaticSamplerTexNamesBuffer = GetMemberByOffest<std::vector<String>>( pBasePointer, m_StaticSamplerTexNamesBufferOffset);
+
+ ParseLuaArray( L, Index, pBasePointer,
+ [&]( void* _pBasePointer, int StackIndex, int NewArrayIndex )
+ {
+ VERIFY_EXPR( pBasePointer == _pBasePointer );
+
+ auto CurrIndex = StaticSamplersBuffer.size();
+ if( CurrIndex != NewArrayIndex - 1 )
+ SCRIPT_PARSING_ERROR( L, "Explicit array indices are not allowed in static sampler description. Provided index ", NewArrayIndex - 1, " conflicts with actual index ", CurrIndex, "." );
+ StaticSamplersBuffer.resize( CurrIndex + 1 );
+ StaticSamplerTexNamesBuffer.resize( CurrIndex + 1 );
+ ParseLuaTable( L, StackIndex, &(StaticSamplersBuffer)[CurrIndex],
+ [&](int TblStackInd, void* __pBasePointer, const char *Key)
+ {
+ if (strcmp(Key, "Desc") == 0)
+ {
+ ParseLuaTable( L, StackIndex, &(StaticSamplersBuffer)[CurrIndex].Desc,
+ [&](int TblStackInd, void* __pBasePointer, const char *Key)
+ {
+ if (strcmp(Key, "Name") == 0)
+ {
+ UNSUPPORTED("Parsing of the static sampler name is not implemented")
+ }
+ else
+ {
+ auto Binding = m_Bindings.find( Key );
+ if (Binding != m_Bindings.end())
+ {
+ Binding->second->SetValue( L, TblStackInd, __pBasePointer );
+ }
+ else
+ {
+ SCRIPT_PARSING_ERROR( L, "Unknown Member \"", Key, '\"' );
+ }
+ }
+ }
+ );
+ }
+ else if (strcmp(Key, "TextureName") == 0)
+ {
+ auto Name = ReadValueFromLua<const Char*>(L, TblStackInd);
+ StaticSamplerTexNamesBuffer[CurrIndex] = Name;
+ }
+ else
+ {
+ SCRIPT_PARSING_ERROR( L, "Unknown Member \"", Key, '\"' );
+ }
+ }
+ );
+
+ if( StaticSamplerTexNamesBuffer[CurrIndex].length() == 0 )
+ SCRIPT_PARSING_ERROR(L, "Missing static sampler texture name")
+ }
+ );
+
+ for(size_t v=0; v < StaticSamplersBuffer.size(); ++v)
+ {
+ StaticSamplersBuffer[v].TextureName = StaticSamplerTexNamesBuffer[v].c_str();
+ }
+
+ auto &StaticSamplers = GetMemberByOffest<StaticSamplerDesc*>( pBasePointer, m_MemberOffset);
+ auto &NumStaticSamplers = GetMemberByOffest<Uint32>( pBasePointer, m_NumStaticSamplersOffset);
+ NumStaticSamplers = static_cast<Uint32>(StaticSamplersBuffer.size());
+ StaticSamplers = NumStaticSamplers ? StaticSamplersBuffer.data() : nullptr;
+ }
+ private:
+ BindingsMapType m_Bindings;
+ EnumMapping<FILTER_TYPE> m_FilterTypeEnumMapping;
+ EnumMapping<TEXTURE_ADDRESS_MODE> m_TexAddrModeEnumMapping;
+ ComparisonFuncEnumMapping m_CmpFuncEnumMapping;
+
+ size_t m_NumStaticSamplersOffset;
+ size_t m_StaticSamplersBufferOffset;
+ size_t m_StaticSamplerTexNamesBufferOffset;
+ };
+
+
class ShaderDescLoader;
template<>
class MemberBinder<ShaderDescLoader> : public MemberBinderBase
{
public:
- MemberBinder( size_t MemberOffset, size_t Dummy ) :
+ MemberBinder( size_t MemberOffset, size_t VarDescBufferOffset, size_t VarNamesBufferOffset, size_t StaticSamplersBufferOffset, size_t StaticSamplerTexNamesBufferOffset ) :
MemberBinderBase( MemberOffset )
{
auto *pNameBinder = new BufferedStringBinder( offsetof( ShaderDesc, Name ),
@@ -51,14 +289,27 @@ namespace Diligent
// keep pointer to it
m_Bindings.insert( std::make_pair( "Name", std::unique_ptr<MemberBinderBase>(pNameBinder) ) );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ShaderTypeEnumMapping, SHADER_TYPE_UNKNOWN );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ShaderTypeEnumMapping, SHADER_TYPE_VERTEX );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ShaderTypeEnumMapping, SHADER_TYPE_PIXEL );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ShaderTypeEnumMapping, SHADER_TYPE_GEOMETRY );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ShaderTypeEnumMapping, SHADER_TYPE_HULL );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ShaderTypeEnumMapping, SHADER_TYPE_DOMAIN );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ShaderTypeEnumMapping, SHADER_TYPE_COMPUTE );
DEFINE_ENUM_BINDER( m_Bindings, ShaderDesc, ShaderType, SHADER_TYPE, m_ShaderTypeEnumMapping )
+
+ DEFINE_ENUM_BINDER( m_Bindings, ShaderDesc, DefaultVariableType, SHADER_VARIABLE_TYPE, m_ShaderVarTypeEnumMapping )
+
+ auto *pShaderDescBinder =
+ new MemberBinder<ShaderVariableDescArrayParser>(
+ offsetof(ShaderDesc, VariableDesc),
+ offsetof(ShaderDesc, NumVariables),
+ VarDescBufferOffset,
+ VarNamesBufferOffset
+ );
+ m_Bindings.insert( std::make_pair( "VariableDesc", std::unique_ptr<MemberBinderBase>(pShaderDescBinder) ) );
+
+ auto *pStaticSamplerDescBinder =
+ new MemberBinder<StaticSamplerDescArrayParser>(
+ offsetof(ShaderDesc, StaticSamplers),
+ offsetof(ShaderDesc, NumStaticSamplers),
+ StaticSamplersBufferOffset,
+ StaticSamplerTexNamesBufferOffset
+ );
+ m_Bindings.insert( std::make_pair( "StaticSamplers", std::unique_ptr<MemberBinderBase>(pStaticSamplerDescBinder) ) );
}
virtual void GetValue( lua_State *L, const void* pBasePointer )
@@ -75,16 +326,17 @@ namespace Diligent
private:
BindingsMapType m_Bindings;
- EnumMapping<SHADER_TYPE> m_ShaderTypeEnumMapping;
+ ShaderTypeEnumMapping m_ShaderTypeEnumMapping;
+ ShaderVariableTypeEnumMapping m_ShaderVarTypeEnumMapping;
};
ShaderParser::ShaderParser( IRenderDevice *pRenderDevice, lua_State *L, const String& ResMappingMetatableName ) :
EngineObjectParserCommon<IShader>( pRenderDevice, L, ShaderLibName ),
- m_SetShadersBinding( this, L, "Context", "SetShaders", &ShaderParser::SetShaders ),
m_BindResourcesBinding( this, L, m_MetatableRegistryName.c_str(), "BindResources", &ShaderParser::BindResources ),
m_ResMappingMetatableName(ResMappingMetatableName)
{
DEFINE_BUFFERED_STRING_BINDER( m_Bindings, ShaderCreationAttribsWrapper, FilePath, FilePathBuffer )
+ DEFINE_BUFFERED_STRING_BINDER( m_Bindings, ShaderCreationAttribsWrapper, Source, SourceBuffer )
DEFINE_BUFFERED_STRING_BINDER( m_Bindings, ShaderCreationAttribsWrapper, EntryPoint, EntryPointBuffer )
DEFINE_BUFFERED_STRING_BINDER( m_Bindings, ShaderCreationAttribsWrapper, SearchDirectories, SearchDirectoriesBuffer )
@@ -93,7 +345,15 @@ namespace Diligent
DEFINE_ENUM_ELEMENT_MAPPING( m_ShaderSourceLangEnumMapping, SHADER_SOURCE_LANGUAGE_GLSL );
DEFINE_ENUM_BINDER( m_Bindings, ShaderCreationAttribsWrapper, SourceLanguage, SHADER_SOURCE_LANGUAGE, m_ShaderSourceLangEnumMapping );
- DEFINE_BINDER( m_Bindings, ShaderCreationAttribsWrapper, Desc, ShaderDescLoader, 0 )
+ auto *pShaderDescBinder =
+ new MemberBinder<ShaderDescLoader>(
+ offsetof(ShaderCreationAttribsWrapper, Desc),
+ offsetof(ShaderCreationAttribsWrapper, m_VarDescBuffer) - offsetof(ShaderCreationAttribsWrapper, Desc),
+ offsetof(ShaderCreationAttribsWrapper, m_VarNamesBuffer) - offsetof(ShaderCreationAttribsWrapper, Desc),
+ offsetof(ShaderCreationAttribsWrapper, m_StaticSamplersBuffer) - offsetof(ShaderCreationAttribsWrapper, Desc),
+ offsetof(ShaderCreationAttribsWrapper, m_StaticSamplerTexNamesBuffer) - offsetof(ShaderCreationAttribsWrapper, Desc)
+ );
+ m_Bindings.insert( std::make_pair( "Desc", std::unique_ptr<MemberBinderBase>(pShaderDescBinder) ) );
};
void ShaderParser::CreateObj( lua_State *L )
@@ -124,8 +384,8 @@ namespace Diligent
ShaderCreationAttrs.Desc = (*ppShader)->GetDesc();
PushField( L, &ShaderCreationAttrs, Field, m_Bindings );
}
-
- int ShaderParser::SetShaders( lua_State *L )
+
+ int ShaderParser::BindResources( lua_State *L )
{
// In order to communicate properly with Lua, a C function must use the following protocol,
// which defines the way parameters and results are passed : a C function receives its arguments
@@ -137,24 +397,6 @@ namespace Diligent
// Any other value in the stack below the results will be properly discarded by Lua.
// Like a Lua function, a C function called by Lua can also return many results.
- auto NumArgs = lua_gettop( L );
- const int MaxShaders = 6;
- IShader* pShaders[MaxShaders] = {};
- VERIFY( NumArgs <= MaxShaders, "Too many shaders are being set" );
- NumArgs = std::min<int>( NumArgs, MaxShaders );
- for( int i = 0; i < NumArgs; ++i )
- {
- pShaders[i] = *GetUserData<IShader**>(L, i+1, m_MetatableRegistryName.c_str() );
- }
- auto *pContext = LoadDeviceContextFromRegistry( L );
- pContext->SetShaders( pShaders, NumArgs );
-
- // Returning no arguments
- return 0;
- }
-
- int ShaderParser::BindResources( lua_State *L )
- {
try
{
auto NumArgs = lua_gettop( L );
diff --git a/RenderScript/src/ShaderResourceBindingParser.cpp b/RenderScript/src/ShaderResourceBindingParser.cpp
new file mode 100644
index 0000000..4daf2aa
--- /dev/null
+++ b/RenderScript/src/ShaderResourceBindingParser.cpp
@@ -0,0 +1,192 @@
+/* Copyright 2015-2016 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+#include "pch.h"
+#include "ShaderResourceBindingParser.h"
+
+namespace Diligent
+{
+ const Char* ShaderResourceBindingParser::ShaderResourceBindingLibName = "ShaderResourceBinding";
+
+ ShaderResourceBindingParser::ShaderResourceBindingParser( IRenderDevice *pRenderDevice, lua_State *L,
+ const String &PSOLibMetatableName,
+ const String &ResMappingMetatableName,
+ const String &ShaderVarMetatableRegistryName ) :
+ m_PSOLibMetatableName(PSOLibMetatableName),
+ m_ResMappingMetatableName(ResMappingMetatableName),
+ m_ShaderVarMetatableRegistryName(ShaderVarMetatableRegistryName),
+ EngineObjectParserBase( pRenderDevice, L, ShaderResourceBindingLibName ),
+ m_BindResourcesBinding( this, L, m_MetatableRegistryName.c_str(), "BindResources", &ShaderResourceBindingParser::BindResources ),
+ m_GetVariableBinding( this, L, m_MetatableRegistryName.c_str(), "GetVariable", &ShaderResourceBindingParser::GetVariable ),
+ m_CreateShaderResourceBinding( this, L, PSOLibMetatableName.c_str(), "CreateShaderResourceBinding", &ShaderResourceBindingParser::CreateShaderResourceBinding )
+ {
+
+ }
+
+
+ void ShaderResourceBindingParser::CreateObj( lua_State *L )
+ {
+ INIT_LUA_STACK_TRACKING(L);
+
+ // Shader should be the first argument
+ auto *pPSO = *GetUserData<IPipelineState**>( L, 1, m_PSOLibMetatableName.c_str() );
+
+ auto pNewShaderResBndngLuaObj = reinterpret_cast<IShaderResourceBinding**>(lua_newuserdata( L, sizeof( IShaderResourceBinding* ) ));
+ pPSO->CreateShaderResourceBinding(pNewShaderResBndngLuaObj);
+
+ CHECK_LUA_STACK_HEIGHT( +1 );
+ }
+
+ void ShaderResourceBindingParser::DestroyObj( void *pData )
+ {
+ if( pData != nullptr )
+ {
+ auto ppShaderResBinding = reinterpret_cast<IShaderResourceBinding**>(pData);
+ if( *ppShaderResBinding != nullptr )
+ (*ppShaderResBinding)->Release();
+ }
+ }
+
+ void ShaderResourceBindingParser::ReadField( lua_State *L, void *pData, const Char *Field )
+ {
+ SCRIPT_PARSING_ERROR(L, "Shader resource binding have no fields that can be read")
+ }
+
+ void ShaderResourceBindingParser::UpdateField( lua_State *L, void *pData, const Char *Field )
+ {
+ SCRIPT_PARSING_ERROR(L, "Shader resource binding have no fields that can be updated")
+ }
+
+
+ void ShaderResourceBindingParser::PushExistingObject( lua_State *L, const void *pObject )
+ {
+ auto pShaderResourceBinding = reinterpret_cast<IShaderResourceBinding**>(lua_newuserdata( L, sizeof( IShaderResourceBinding* ) ));
+ *pShaderResourceBinding = reinterpret_cast<IShaderResourceBinding*>( const_cast<void*>(pObject) );
+ (*pShaderResourceBinding)->AddRef();
+ }
+
+
+ int ShaderResourceBindingParser::CreateShaderResourceBinding( lua_State *L )
+ {
+ return LuaCreate(L);
+ }
+
+ int ShaderResourceBindingParser::BindResources( lua_State *L )
+ {
+ try
+ {
+ auto NumArgs = lua_gettop( L );
+ if( NumArgs < 3 )
+ {
+ SCRIPT_PARSING_ERROR( L, "At least 2 arguments (shader flags and resource mapping) are expected" );
+ }
+
+
+ int ArgStackInd = 1;
+
+ auto *pResBinding = *GetUserData<IShaderResourceBinding**>( L, ArgStackInd, m_MetatableRegistryName.c_str() );
+ VERIFY( pResBinding, "Resource mapping pointer is null" );
+ if( !pResBinding )return 0;
+
+ ++ArgStackInd;
+ Uint32 ShaderFlags = 0;
+ {
+ FlagsLoader<SHADER_TYPE> FlagsLoader(0, "BindShaderResourceFlags", m_ShaderTypeEnumMapping);
+ FlagsLoader.SetValue( L, ArgStackInd, &ShaderFlags );
+ }
+
+ ++ArgStackInd;
+ auto *pResourceMapping = *GetUserData<IResourceMapping**>( L, ArgStackInd, m_ResMappingMetatableName.c_str() );
+ if( !pResourceMapping )
+ {
+ SCRIPT_PARSING_ERROR( L, "Incorrect 2nd argument type: resource mapping is expected" );
+ }
+
+ ++ArgStackInd;
+ Uint32 Flags = 0;
+ // The last argument may be flags
+ if( NumArgs >= ArgStackInd &&
+ (lua_type( L, ArgStackInd ) == LUA_TSTRING || lua_type( L, ArgStackInd ) == LUA_TTABLE ) )
+ {
+ FlagsLoader<BIND_SHADER_RESOURCES_FLAGS> FlagsLoader(0, "BindShaderResourceFlags", m_BindShaderResFlagEnumMapping);
+ FlagsLoader.SetValue( L, ArgStackInd, &Flags );
+ }
+
+ pResBinding->BindResources( ShaderFlags, pResourceMapping, Flags );
+ }
+ catch( const std::runtime_error& )
+ {
+
+ }
+ return 0;
+ }
+
+ int ShaderResourceBindingParser::GetVariable( lua_State *L )
+ {
+ auto NumArgs = lua_gettop( L );
+ if( NumArgs < 3 )
+ {
+ SCRIPT_PARSING_ERROR( L, "2 arguments (shader type and variable name) are expected" );
+ }
+
+ INIT_LUA_STACK_TRACKING(L);
+
+ int ArgStackInd = 1;
+
+ // The object itself goes first
+ auto *pShaderResBinding = *GetUserData<IShaderResourceBinding**>( L, ArgStackInd, m_MetatableRegistryName.c_str() );
+
+ // Shader type should be the first argument
+ ++ArgStackInd;
+ SHADER_TYPE ShaderType = SHADER_TYPE_UNKNOWN;
+ EnumMemberBinder<SHADER_TYPE> ShaderTypeParser(0, "ShaderType", m_ShaderTypeEnumMapping);
+ 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());
+
+ auto pNewShaderVarLuaObj = reinterpret_cast<IShaderVariable**>(lua_newuserdata( L, sizeof( IShaderVariable* ) ));
+ *pNewShaderVarLuaObj = pVar;
+ pVar->AddRef();
+
+ // Push onto the stack the metatable associated with name given in the registry
+ luaL_getmetatable( L, m_ShaderVarMetatableRegistryName.c_str() ); // -0 | +1 -> +1
+ // Pop a table from the top of the stack and set it as the new metatable
+ // for the value at the given index (which is where the new user datum is)
+ lua_setmetatable( L, -2 ); // -1 | +0 -> -1
+
+ CHECK_LUA_STACK_HEIGHT( +1 );
+
+ return 1;
+ }
+
+ void ShaderResourceBindingParser::GetObjectByName( lua_State *L, const Char *ShaderName, IShaderResourceBinding** ppObject )
+ {
+ auto pObject = *GetGlobalObject<IShaderResourceBinding**>( L, ShaderName, m_MetatableRegistryName.c_str() );
+ *ppObject = pObject;
+ pObject->AddRef();
+ }
+}
diff --git a/RenderScript/src/ShaderVariableParser.cpp b/RenderScript/src/ShaderVariableParser.cpp
index 35b5361..62dc8ba 100644
--- a/RenderScript/src/ShaderVariableParser.cpp
+++ b/RenderScript/src/ShaderVariableParser.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2015 Egor Yusov
+/* Copyright 2015-2016 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/RenderScript/src/TextureParser.cpp b/RenderScript/src/TextureParser.cpp
index 628c9a1..a7ac219 100644
--- a/RenderScript/src/TextureParser.cpp
+++ b/RenderScript/src/TextureParser.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2015 Egor Yusov
+/* Copyright 2015-2016 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,12 +29,69 @@ namespace Diligent
{
const Char* TextureParser::TextureLibName = "Texture";
+ template<>
+ class MemberBinder<DepthStencilClearValue> : public MemberBinderBase
+ {
+ public:
+ MemberBinder(size_t MemberOffset, int /*Dummy*/) :
+ MemberBinderBase(MemberOffset)
+ {
+ DEFINE_BINDER( m_Bindings, DepthStencilClearValue, Depth, Float32, Validator<Float32>("Depth clear value", 0.f, 1.f) )
+ DEFINE_BINDER( m_Bindings, DepthStencilClearValue, Stencil, Uint8, Validator<Uint8>() )
+ }
+
+ virtual void GetValue(lua_State *L, const void* pBasePointer)override
+ {
+ const auto *pDSClearValue = &GetMemberByOffest<DepthStencilClearValue>( pBasePointer, m_MemberOffset );
+ PushLuaTable( L, pDSClearValue, m_Bindings );
+ }
+
+ virtual void SetValue(lua_State *L, int Index, void* pBasePointer)override
+ {
+ auto *pDSClearValue = &GetMemberByOffest<DepthStencilClearValue>(pBasePointer, m_MemberOffset);
+ ParseLuaTable( L, Index, pDSClearValue, m_Bindings );
+ }
+
+ private:
+ BindingsMapType m_Bindings;
+ };
+
+ template<>
+ class MemberBinder<OptimizedClearValue> : public MemberBinderBase
+ {
+ public:
+ MemberBinder(size_t MemberOffset, int /*Dummy*/) :
+ MemberBinderBase(MemberOffset)
+ {
+ DEFINE_ENUM_BINDER( m_Bindings, OptimizedClearValue, Format, TEXTURE_FORMAT, m_TexFmtEnumMapping );
+ DEFINE_BINDER( m_Bindings, OptimizedClearValue, Color, RGBALoader, 0 )
+ DEFINE_BINDER( m_Bindings, OptimizedClearValue, DepthStencil, DepthStencilClearValue, 0 )
+ }
+
+ virtual void GetValue(lua_State *L, const void* pBasePointer)override
+ {
+ const auto *pClearValue = &GetMemberByOffest<OptimizedClearValue>( pBasePointer, m_MemberOffset );
+ PushLuaTable( L, pClearValue, m_Bindings );
+ }
+
+ virtual void SetValue(lua_State *L, int Index, void* pBasePointer)override
+ {
+ auto *pClearValue = &GetMemberByOffest<OptimizedClearValue>(pBasePointer, m_MemberOffset);
+ ParseLuaTable( L, Index, pClearValue, m_Bindings );
+ }
+
+ private:
+ BindingsMapType m_Bindings;
+ TextureFormatEnumMapping m_TexFmtEnumMapping;
+ };
+
+
TextureParser::TextureParser( IRenderDevice *pRenderDevice, lua_State *L ) :
EngineObjectParserCommon<ITexture>( pRenderDevice, L, TextureLibName )
{
DEFINE_BUFFERED_STRING_BINDER( m_Bindings, STexDescWrapper, Name, NameBuffer )
- DEFINE_ENUM_BINDER( m_Bindings, STexDescWrapper, Type, TEXTURE_TYPE, m_TexTypeEnumMapping );
+ DEFINE_ENUM_BINDER( m_Bindings, STexDescWrapper, Type, RESOURCE_DIMENSION, m_TexTypeEnumMapping );
DEFINE_BINDER( m_Bindings, STexDescWrapper, Width, Uint32, Validator<Uint32>( "Width", 1, 16384 ) );
DEFINE_BINDER( m_Bindings, STexDescWrapper, Height, Uint32, Validator<Uint32>( "Heihght", 1, 16384 ) );
@@ -64,6 +121,8 @@ namespace Diligent
DEFINE_ENUM_ELEMENT_MAPPING( m_MiscFlagEnumMapping, MISC_TEXTURE_FLAG_GENERATE_MIPS );
DEFINE_FLAGS_BINDER( m_Bindings, STexDescWrapper, MiscFlags, Diligent::MISC_TEXTURE_FLAG, m_MiscFlagEnumMapping );
+
+ DEFINE_BINDER( m_Bindings, STexDescWrapper, ClearValue, OptimizedClearValue, 0 );
};
void TextureParser::CreateObj( lua_State *L )
diff --git a/RenderScript/src/TextureViewParser.cpp b/RenderScript/src/TextureViewParser.cpp
index 20ddabb..c4b82d5 100644
--- a/RenderScript/src/TextureViewParser.cpp
+++ b/RenderScript/src/TextureViewParser.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2015 Egor Yusov
+/* Copyright 2015-2016 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,7 +54,7 @@ namespace Diligent
"Unexpected map size. Did you update TEXTURE_VIEW_TYPE enum?" );
DEFINE_ENUM_BINDER( m_Bindings, STexViewDescWrapper, ViewType, TEXTURE_VIEW_TYPE, m_ViewTypeEnumMapping );
- DEFINE_ENUM_BINDER( m_Bindings, STexViewDescWrapper, TextureType, TEXTURE_TYPE, m_TexTypeEnumMapping );
+ DEFINE_ENUM_BINDER( m_Bindings, STexViewDescWrapper, TextureDim, RESOURCE_DIMENSION, m_TexTypeEnumMapping );
DEFINE_ENUM_BINDER( m_Bindings, STexViewDescWrapper, Format, TEXTURE_FORMAT, m_TexFormatEnumMapping );
DEFINE_BINDER( m_Bindings, STexViewDescWrapper, MostDetailedMip, Uint32, Validator<Uint32>( "MostDetailedMip", 0, 16384 ) );
diff --git a/RenderScript/src/ViewportParser.cpp b/RenderScript/src/ViewportParser.cpp
index 7afbfe6..91e4c31 100644
--- a/RenderScript/src/ViewportParser.cpp
+++ b/RenderScript/src/ViewportParser.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2015 Egor Yusov
+/* Copyright 2015-2016 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/RenderScript/src/pch.cpp b/RenderScript/src/pch.cpp
index 4a893f2..964b3f1 100644
--- a/RenderScript/src/pch.cpp
+++ b/RenderScript/src/pch.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2015 Egor Yusov
+/* Copyright 2015-2016 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.