summaryrefslogtreecommitdiffstats
path: root/RenderScript/src
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2019-12-12 23:16:42 +0000
committerassiduous <assiduous@diligentgraphics.com>2019-12-12 23:16:42 +0000
commitd9ff664e3d796f9526ed29b7a1066b3d3fb443b1 (patch)
treebc94032e85347cdd26cc4c3c67d288bcfa9ef540 /RenderScript/src
parentappveyor: swithced to VS2019 and enabled tests (diff)
downloadDiligentTools-d9ff664e3d796f9526ed29b7a1066b3d3fb443b1.tar.gz
DiligentTools-d9ff664e3d796f9526ed29b7a1066b3d3fb443b1.zip
Removed RenderScript and lua
Diffstat (limited to 'RenderScript/src')
-rw-r--r--RenderScript/src/BlendStateDescParser.cpp146
-rw-r--r--RenderScript/src/BufferParser.cpp226
-rw-r--r--RenderScript/src/BufferViewParser.cpp153
-rw-r--r--RenderScript/src/DepthStencilStateDescParser.cpp98
-rw-r--r--RenderScript/src/DeviceContextFuncBindings.cpp290
-rw-r--r--RenderScript/src/DrawAttribsParser.cpp201
-rw-r--r--RenderScript/src/EngineObjectParserBase.cpp271
-rw-r--r--RenderScript/src/EnumMappings.cpp234
-rw-r--r--RenderScript/src/InputLayoutDescParser.cpp91
-rw-r--r--RenderScript/src/LuaBindings.cpp279
-rw-r--r--RenderScript/src/LuaFunctionBinding.cpp110
-rw-r--r--RenderScript/src/LuaWrappers.cpp83
-rw-r--r--RenderScript/src/PSODescParser.cpp671
-rw-r--r--RenderScript/src/ParsingErrors.cpp87
-rw-r--r--RenderScript/src/RasterizerStateDescParser.cpp70
-rw-r--r--RenderScript/src/ResourceMappingParser.cpp146
-rw-r--r--RenderScript/src/SamplerParser.cpp56
-rw-r--r--RenderScript/src/ScissorRectParser.cpp124
-rw-r--r--RenderScript/src/ScriptParser.cpp277
-rw-r--r--RenderScript/src/ShaderParser.cpp120
-rw-r--r--RenderScript/src/ShaderResourceBindingParser.cpp226
-rw-r--r--RenderScript/src/ShaderVariableParser.cpp165
-rw-r--r--RenderScript/src/TextureParser.cpp174
-rw-r--r--RenderScript/src/TextureViewParser.cpp165
-rw-r--r--RenderScript/src/ViewportParser.cpp133
-rw-r--r--RenderScript/src/pch.cpp25
26 files changed, 0 insertions, 4621 deletions
diff --git a/RenderScript/src/BlendStateDescParser.cpp b/RenderScript/src/BlendStateDescParser.cpp
deleted file mode 100644
index bc43944..0000000
--- a/RenderScript/src/BlendStateDescParser.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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 "BlendStateDescParser.h"
-#include "LuaWrappers.h"
-#include "ClassMethodBinding.h"
-
-namespace Diligent
-{
- class RenderTargetBlendDescArrayParser;
-
- template<>
- class MemberBinder<RenderTargetBlendDescArrayParser> : public MemberBinderBase
- {
- public:
- MemberBinder( size_t MemberOffset, size_t Dummy ) :
- MemberBinderBase( MemberOffset )
- {
- DEFINE_BINDER( m_Bindings, RenderTargetBlendDesc, BlendEnable );
-
- DEFINE_ENUM_ELEMENT_MAPPING( m_BlendFactorEnumMapping, BLEND_FACTOR_ZERO);
- DEFINE_ENUM_ELEMENT_MAPPING( m_BlendFactorEnumMapping, BLEND_FACTOR_ONE);
- DEFINE_ENUM_ELEMENT_MAPPING( m_BlendFactorEnumMapping, BLEND_FACTOR_SRC_COLOR);
- DEFINE_ENUM_ELEMENT_MAPPING( m_BlendFactorEnumMapping, BLEND_FACTOR_INV_SRC_COLOR);
- DEFINE_ENUM_ELEMENT_MAPPING( m_BlendFactorEnumMapping, BLEND_FACTOR_SRC_ALPHA);
- DEFINE_ENUM_ELEMENT_MAPPING( m_BlendFactorEnumMapping, BLEND_FACTOR_INV_SRC_ALPHA);
- DEFINE_ENUM_ELEMENT_MAPPING( m_BlendFactorEnumMapping, BLEND_FACTOR_DEST_ALPHA);
- DEFINE_ENUM_ELEMENT_MAPPING( m_BlendFactorEnumMapping, BLEND_FACTOR_INV_DEST_ALPHA);
- DEFINE_ENUM_ELEMENT_MAPPING( m_BlendFactorEnumMapping, BLEND_FACTOR_DEST_COLOR);
- DEFINE_ENUM_ELEMENT_MAPPING( m_BlendFactorEnumMapping, BLEND_FACTOR_INV_DEST_COLOR);
- DEFINE_ENUM_ELEMENT_MAPPING( m_BlendFactorEnumMapping, BLEND_FACTOR_SRC_ALPHA_SAT);
- DEFINE_ENUM_ELEMENT_MAPPING( m_BlendFactorEnumMapping, BLEND_FACTOR_BLEND_FACTOR);
- DEFINE_ENUM_ELEMENT_MAPPING( m_BlendFactorEnumMapping, BLEND_FACTOR_INV_BLEND_FACTOR);
- DEFINE_ENUM_ELEMENT_MAPPING( m_BlendFactorEnumMapping, BLEND_FACTOR_SRC1_COLOR);
- DEFINE_ENUM_ELEMENT_MAPPING( m_BlendFactorEnumMapping, BLEND_FACTOR_INV_SRC1_COLOR);
- DEFINE_ENUM_ELEMENT_MAPPING( m_BlendFactorEnumMapping, BLEND_FACTOR_SRC1_ALPHA);
- DEFINE_ENUM_ELEMENT_MAPPING( m_BlendFactorEnumMapping, BLEND_FACTOR_INV_SRC1_ALPHA);
- VERIFY( m_BlendFactorEnumMapping.m_Str2ValMap.size() == BLEND_FACTOR_NUM_FACTORS - 1,
- "Unexpected map size. Did you update BLEND_FACTOR enum?" );
- VERIFY( m_BlendFactorEnumMapping.m_Val2StrMap.size() == BLEND_FACTOR_NUM_FACTORS - 1,
- "Unexpected map size. Did you update BLEND_FACTOR enum?" );
-
- DEFINE_ENUM_BINDER( m_Bindings, RenderTargetBlendDesc, SrcBlend, m_BlendFactorEnumMapping );
- DEFINE_ENUM_BINDER( m_Bindings, RenderTargetBlendDesc, DestBlend, m_BlendFactorEnumMapping );
- DEFINE_ENUM_BINDER( m_Bindings, RenderTargetBlendDesc, SrcBlendAlpha, m_BlendFactorEnumMapping );
- DEFINE_ENUM_BINDER( m_Bindings, RenderTargetBlendDesc, DestBlendAlpha, m_BlendFactorEnumMapping );
-
-
- DEFINE_ENUM_ELEMENT_MAPPING( m_BlendOpEnumMapping, BLEND_OPERATION_ADD );
- DEFINE_ENUM_ELEMENT_MAPPING( m_BlendOpEnumMapping, BLEND_OPERATION_SUBTRACT );
- DEFINE_ENUM_ELEMENT_MAPPING( m_BlendOpEnumMapping, BLEND_OPERATION_REV_SUBTRACT );
- DEFINE_ENUM_ELEMENT_MAPPING( m_BlendOpEnumMapping, BLEND_OPERATION_MIN );
- DEFINE_ENUM_ELEMENT_MAPPING( m_BlendOpEnumMapping, BLEND_OPERATION_MAX );
- VERIFY( m_BlendOpEnumMapping.m_Str2ValMap.size() == BLEND_OPERATION_NUM_OPERATIONS - 1,
- "Unexpected map size. Did you update BLEND_OPERATION enum?" );
- VERIFY( m_BlendOpEnumMapping.m_Val2StrMap.size() == BLEND_OPERATION_NUM_OPERATIONS - 1,
- "Unexpected map size. Did you update BLEND_OPERATION enum?" );
-
- DEFINE_ENUM_BINDER( m_Bindings, RenderTargetBlendDesc, BlendOp, m_BlendOpEnumMapping );
- DEFINE_ENUM_BINDER( m_Bindings, RenderTargetBlendDesc, BlendOpAlpha, m_BlendOpEnumMapping );
-
-
- DEFINE_ENUM_ELEMENT_MAPPING( m_ColorMaskEnumMapping, COLOR_MASK_RED );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ColorMaskEnumMapping, COLOR_MASK_GREEN );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ColorMaskEnumMapping, COLOR_MASK_BLUE );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ColorMaskEnumMapping, COLOR_MASK_ALPHA );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ColorMaskEnumMapping, COLOR_MASK_ALL );
- DEFINE_FLAGS_BINDER( m_Bindings, RenderTargetBlendDesc, RenderTargetWriteMask, COLOR_MASK, m_ColorMaskEnumMapping );
- }
-
- virtual void GetValue( lua_State *L, const void* pBasePointer )
- {
- const auto &RTs = GetMemberByOffest< const RenderTargetBlendDesc >(pBasePointer, m_MemberOffset);
- PushLuaArray( L, &RTs, &RTs+BlendStateDesc::MaxRenderTargets, [&](const RenderTargetBlendDesc &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" );
- auto &RenderTargets = GetMemberByOffest<RenderTargetBlendDesc>( pBasePointer, m_MemberOffset );
-
- auto MaxRTs = BlendStateDesc::MaxRenderTargets;
- if( !(NewArrayIndex >= 1 && NewArrayIndex <= MaxRTs) )
- SCRIPT_PARSING_ERROR( L, "Incorrect render target index ", NewArrayIndex, ". Only 1..", MaxRTs, " are allowed" );
-
- ParseLuaTable( L, StackIndex, &RenderTargets + (NewArrayIndex-1), m_Bindings );
- }
- );
- }
- private:
- BindingsMapType m_Bindings;
-
- EnumMapping < BLEND_FACTOR > m_BlendFactorEnumMapping;
- EnumMapping < BLEND_OPERATION > m_BlendOpEnumMapping;
- EnumMapping < COLOR_MASK > m_ColorMaskEnumMapping;
- };
-
-
- MemberBinder<BlendStateDesc> :: MemberBinder( size_t MemberOffset, size_t Dummy ) :
- MemberBinderBase( MemberOffset )
- {
- DEFINE_BINDER( m_Bindings, BlendStateDesc, AlphaToCoverageEnable );
- DEFINE_BINDER( m_Bindings, BlendStateDesc, IndependentBlendEnable );
-
- DEFINE_BINDER_EX( m_Bindings, BlendStateDesc, RenderTargets, RenderTargetBlendDescArrayParser, 0 );
- }
-
- void MemberBinder<BlendStateDesc> ::GetValue(lua_State *L, const void* pBasePointer)
- {
- const auto &BlendDesc = GetMemberByOffest< BlendStateDesc >(pBasePointer, m_MemberOffset);
- PushLuaTable(L, &BlendDesc, m_Bindings);
- }
-
- void MemberBinder<BlendStateDesc> ::SetValue(lua_State *L, int Index, void* pBasePointer)
- {
- 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
deleted file mode 100644
index a275e7a..0000000
--- a/RenderScript/src/BufferParser.cpp
+++ /dev/null
@@ -1,226 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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 "BufferParser.h"
-
-namespace Diligent
-{
- const Char* BufferParser::BufferLibName = "Buffer";
-
- BufferParser::BufferParser( IRenderDevice *pRenderDevice, lua_State *L ) :
- EngineObjectParserCommon<IBuffer>( pRenderDevice, L, BufferLibName ),
- m_SetVertexBuffersBinding(this, L, "Context", "SetVertexBuffers", &BufferParser::SetVertexBuffers),
- m_SetIndexBufferBinding( this, L, "Context", "SetIndexBuffer", &BufferParser::SetIndexBuffer )
- {
- DEFINE_BUFFERED_STRING_BINDER( m_Bindings, SBuffDescWrapper, Name, NameBuffer );
-
- DEFINE_BINDER( m_Bindings, SBuffDescWrapper, uiSizeInBytes );
-
- DEFINE_ENUM_ELEMENT_MAPPING( m_BindFlagEnumMapping, BIND_VERTEX_BUFFER );
- DEFINE_ENUM_ELEMENT_MAPPING( m_BindFlagEnumMapping, BIND_INDEX_BUFFER );
- DEFINE_ENUM_ELEMENT_MAPPING( m_BindFlagEnumMapping, BIND_UNIFORM_BUFFER );
- DEFINE_ENUM_ELEMENT_MAPPING( m_BindFlagEnumMapping, BIND_SHADER_RESOURCE );
- DEFINE_ENUM_ELEMENT_MAPPING( m_BindFlagEnumMapping, BIND_STREAM_OUTPUT );
- //DEFINE_ENUM_ELEMENT_MAPPING( m_BindFlagEnumMapping, BIND_RENDER_TARGET );
- //DEFINE_ENUM_ELEMENT_MAPPING( m_BindFlagEnumMapping, BIND_DEPTH_STENCIL );
- DEFINE_ENUM_ELEMENT_MAPPING( m_BindFlagEnumMapping, BIND_UNORDERED_ACCESS );
- DEFINE_ENUM_ELEMENT_MAPPING( m_BindFlagEnumMapping, BIND_INDIRECT_DRAW_ARGS );
- // Explicit namespace declaraion is necesseary to avoid
- // name conflicts when building for windows store
- DEFINE_FLAGS_BINDER( m_Bindings, SBuffDescWrapper, BindFlags, Diligent::BIND_FLAGS, m_BindFlagEnumMapping );
-
- DEFINE_ENUM_BINDER( m_Bindings, SBuffDescWrapper, Usage, m_UsageEnumMapping );
- DEFINE_FLAGS_BINDER( m_Bindings, SBuffDescWrapper, CPUAccessFlags, CPU_ACCESS_FLAGS, m_CpuAccessFlagEnumMapping );
-
- DEFINE_ENUM_ELEMENT_MAPPING( m_BuffModeEnumMapping, BUFFER_MODE_UNDEFINED );
- DEFINE_ENUM_ELEMENT_MAPPING( m_BuffModeEnumMapping, BUFFER_MODE_FORMATTED );
- DEFINE_ENUM_ELEMENT_MAPPING( m_BuffModeEnumMapping, BUFFER_MODE_STRUCTURED );
- DEFINE_ENUM_ELEMENT_MAPPING( m_BuffModeEnumMapping, BUFFER_MODE_RAW );
- static_assert(BUFFER_MODE_NUM_MODES == BUFFER_MODE_RAW + 1, "Not all buffer modes initialized.");
- VERIFY( m_BuffModeEnumMapping.m_Str2ValMap.size() == BUFFER_MODE_NUM_MODES,
- "Unexpected map size. Did you update BUFFER_MODE enum?" );
- VERIFY( m_BuffModeEnumMapping.m_Val2StrMap.size() == BUFFER_MODE_NUM_MODES,
- "Unexpected map size. Did you update BUFFER_MODE enum?" );
- DEFINE_ENUM_BINDER( m_Bindings, SBuffDescWrapper, Mode, m_BuffModeEnumMapping );
-
- DEFINE_BINDER( m_Bindings, SBuffDescWrapper, ElementByteStride );
-
- DEFINE_ENUM_ELEMENT_MAPPING( m_SetVBFlagEnumMapping, SET_VERTEX_BUFFERS_FLAG_NONE );
- DEFINE_ENUM_ELEMENT_MAPPING( m_SetVBFlagEnumMapping, SET_VERTEX_BUFFERS_FLAG_RESET );
- };
-
- void BufferParser::CreateObj( lua_State *L )
- {
- auto NumArgs = lua_gettop( L );
- INIT_LUA_STACK_TRACKING(L);
- SBuffDescWrapper BufferDesc;
- ParseLuaTable( L, 1, &BufferDesc, m_Bindings );
- CHECK_LUA_STACK_HEIGHT();
-
- if( (BufferDesc.Mode == BUFFER_MODE_STRUCTURED || BufferDesc.Mode == BUFFER_MODE_FORMATTED) && BufferDesc.ElementByteStride == 0 )
- SCRIPT_PARSING_ERROR( L, "Element byte stride of a structured or formatted buffer cannot be zero" );
-
- if( (BufferDesc.Mode == BUFFER_MODE_FORMATTED || BufferDesc.Mode == BUFFER_MODE_STRUCTURED) &&
- (BufferDesc.uiSizeInBytes % BufferDesc.ElementByteStride) != 0 )
- SCRIPT_PARSING_ERROR( L, "Buffer size (", BufferDesc.uiSizeInBytes, ") is not multiple of element byte stride (", BufferDesc.ElementByteStride, ")." );
-
- std::vector<Uint8> RawData;
- if( NumArgs > 1 )
- {
- if( NumArgs != 3 )
- {
- SCRIPT_PARSING_ERROR( L, "To initialize buffer with initial data, provide value type and array of values as the 2nd and 3rd parameters. ", NumArgs, " arguments is provided." );
- }
-
- m_ArrayLoader.LoadArray( L, 3, RawData );
- }
- BufferData BuffData;
- auto DataSize = static_cast<Uint32>(RawData.size());
- if( DataSize )
- {
- if( BufferDesc.uiSizeInBytes == 0 )
- BufferDesc.uiSizeInBytes = DataSize;
- if( DataSize != BufferDesc.uiSizeInBytes )
- {
- SCRIPT_PARSING_ERROR( L, "Initial buffer data size (", DataSize, ") does not match the requested buffer size (", BufferDesc.uiSizeInBytes, "). "
- "Do not specify uiSizeInBytes to have the buffer size calculated automatically." );
- }
- BuffData.pData = RawData.data();
- BuffData.DataSize = DataSize;
- }
-
- if( (BufferDesc.BindFlags & BIND_UNIFORM_BUFFER) && (BufferDesc.uiSizeInBytes % 16) )
- {
- SCRIPT_PARSING_ERROR( L, "Uniform buffer size (", DataSize, ") is not multiple of 16." );
- }
-
- auto ppBuffer = reinterpret_cast<IBuffer**>(lua_newuserdata( L, sizeof( IBuffer* ) ));
- *ppBuffer = nullptr;
- m_pRenderDevice->CreateBuffer( BufferDesc, &BuffData, ppBuffer );
- if( *ppBuffer == nullptr )
- SCRIPT_PARSING_ERROR( L, "Failed to create buffer" )
-
- CHECK_LUA_STACK_HEIGHT( +1 );
- }
-
- int BufferParser::SetVertexBuffers( lua_State *L )
- {
- auto NumArgs = lua_gettop( L );
-
- int CurrArgInd = 1;
-
- Int32 StartSlot = 0;
- if( lua_type( L, CurrArgInd ) == LUA_TNUMBER )
- {
- StartSlot = ReadValueFromLua<Int32>( L, CurrArgInd++ );
- if( StartSlot < 0 )
- {
- SCRIPT_PARSING_ERROR( L, "Start slot (", StartSlot, " provided) must be in range 0..", MaxBufferSlots - 1 );
- }
- }
-
- SET_VERTEX_BUFFERS_FLAGS Flags = SET_VERTEX_BUFFERS_FLAG_NONE;
- RESOURCE_STATE_TRANSITION_MODE StateTransitionMode = RESOURCE_STATE_TRANSITION_MODE_NONE;
- Uint32 NumBuffers = 0;
- IBuffer *pBuffs[MaxBufferSlots] = {};
- Uint32 Offsets[MaxBufferSlots] = {};
- while( CurrArgInd <= NumArgs )
- {
- if( StartSlot + (NumBuffers + 1) > MaxBufferSlots )
- {
- SCRIPT_PARSING_ERROR( L, "Too many buffer slots (", StartSlot, "..", StartSlot + NumBuffers - 1, ") are being set. Allowed slots are 0..", MaxBufferSlots - 1 );
- break;
- }
-
- if( lua_type( L, CurrArgInd ) != LUA_TNIL )
- pBuffs[NumBuffers] = *GetUserData<IBuffer**>( L, CurrArgInd++, m_MetatableRegistryName.c_str() );
- else
- {
- ++CurrArgInd;
- pBuffs[NumBuffers] = nullptr;
- }
-
- if( lua_type( L, CurrArgInd ) == LUA_TNUMBER )
- Offsets[NumBuffers] = ReadValueFromLua<Uint32>( L, CurrArgInd++ );
- else
- Offsets[NumBuffers] = 0;
-
- if( CurrArgInd >= NumArgs-1 && lua_type( L, CurrArgInd ) == LUA_TSTRING)
- {
- EnumMemberBinder<RESOURCE_STATE_TRANSITION_MODE> StateTransitionModeLoader(0, "StateTransitionMode", m_StateTransitionModeMapping);
- StateTransitionModeLoader.SetValue( L, CurrArgInd, &StateTransitionMode );
- ++CurrArgInd;
- }
-
- // The last argument may be flags
- if( CurrArgInd == NumArgs &&
- (lua_type( L, CurrArgInd ) == LUA_TSTRING ||
- lua_type( L, CurrArgInd ) == LUA_TTABLE ) )
- {
- VERIFY( Flags == 0, "Flags have already been set!" );
- FlagsLoader<SET_VERTEX_BUFFERS_FLAGS> SetVBFlagsLoader(0, "SetVBFlags", m_SetVBFlagEnumMapping);
- SetVBFlagsLoader.SetValue( L, CurrArgInd, &Flags );
- ++CurrArgInd;
- }
-
- ++NumBuffers;
- }
-
- auto *pContext = LoadDeviceContextFromRegistry( L );
- pContext->SetVertexBuffers( StartSlot, NumBuffers, pBuffs, Offsets, StateTransitionMode, Flags );
-
- // Return no values to Lua
- return 0;
- }
-
- int BufferParser::SetIndexBuffer( lua_State *L )
- {
- auto *pIndexBuff = *GetUserData<IBuffer**>( L, 1, m_MetatableRegistryName.c_str() );
- Uint32 Offset = 0;
- auto NumArgs = lua_gettop( L );
- if( NumArgs > 3 )
- {
- SCRIPT_PARSING_ERROR( L, "SetIndexBuffer() expects offset and state transition mode as optional 2nd and 3rd parameters. ", NumArgs, " arguments are provided." );
- }
- int CurrArg = 2;
- if( CurrArg <= NumArgs && lua_isnumber( L, CurrArg ) )
- {
- Offset = ReadValueFromLua<Uint32>( L, CurrArg );
- ++CurrArg;
- }
-
- RESOURCE_STATE_TRANSITION_MODE StateTransitionMode = RESOURCE_STATE_TRANSITION_MODE_NONE;
- if( CurrArg <= NumArgs && lua_type( L, CurrArg ) == LUA_TSTRING)
- {
- EnumMemberBinder<RESOURCE_STATE_TRANSITION_MODE> StateTransitionModeLoader(0, "StateTransitionMode", m_StateTransitionModeMapping);
- StateTransitionModeLoader.SetValue( L, CurrArg, &StateTransitionMode );
- }
-
- auto *pContext = LoadDeviceContextFromRegistry( L );
- pContext->SetIndexBuffer( pIndexBuff, Offset, StateTransitionMode );
-
- // Return no values to Lua
- return 0;
- }
-}
diff --git a/RenderScript/src/BufferViewParser.cpp b/RenderScript/src/BufferViewParser.cpp
deleted file mode 100644
index b71a95b..0000000
--- a/RenderScript/src/BufferViewParser.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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 "BufferViewParser.h"
-#include "BufferParser.h"
-#include "SamplerParser.h"
-#include "GraphicsAccessories.h"
-
-namespace Diligent
-{
- const Char* BufferViewParser::BufferViewLibName = "BufferView";
-
- template<>
- class MemberBinder<BufferFormat> : public MemberBinderBase
- {
- public:
- MemberBinder( size_t MemberOffset, size_t Dummy ) :
- MemberBinderBase( MemberOffset )
- {
- DEFINE_ENUM_BINDER( m_Bindings, BufferFormat, ValueType, m_ValueTypeEnumMapping );
- using NumComponentsType = decltype(BufferFormat::NumComponents);
- DEFINE_BINDER_EX( m_Bindings, BufferFormat, NumComponents, NumComponentsType, Validator<NumComponentsType>( "Num Components", 1, 4 ) );
- DEFINE_BINDER( m_Bindings, BufferFormat, IsNormalized );
- }
-
- virtual void GetValue( lua_State *L, const void* pBasePointer )
- {
- const auto &BuffFmt = GetMemberByOffest<BufferFormat>( pBasePointer, m_MemberOffset );
- PushLuaTable( L, &BuffFmt, m_Bindings );
- }
-
- virtual void SetValue( lua_State *L, int Index, void* pBasePointer )
- {
- auto &BuffFmt = GetMemberByOffest<BufferFormat>( pBasePointer, m_MemberOffset );
- ParseLuaTable( L, Index, &BuffFmt, m_Bindings );
- }
- private:
- BindingsMapType m_Bindings;
- ValueTypeEnumMapping m_ValueTypeEnumMapping;
- };
-
- BufferViewParser::BufferViewParser( BufferParser *pBufParser,
- IRenderDevice *pRenderDevice,
- lua_State *L ) :
- EngineObjectParserCommon<IBufferView>( pRenderDevice, L, BufferViewLibName ),
- m_BufferLibMetatableName(pBufParser->GetMetatableName()),
- m_CreateViewBinding( this, L, m_BufferLibMetatableName.c_str(), "CreateView", &BufferViewParser::CreateView ),
- m_GetDefaultViewBinding( this, L, m_BufferLibMetatableName.c_str(), "GetDefaultView", &BufferViewParser::GetDefaultView ),
- m_ViewTypeParser( 0, "ViewType", m_ViewTypeEnumMapping )
- {
- DEFINE_BUFFERED_STRING_BINDER( m_Bindings, SBuffViewDescWrapper, Name, NameBuffer );
-
- DEFINE_ENUM_ELEMENT_MAPPING( m_ViewTypeEnumMapping, BUFFER_VIEW_SHADER_RESOURCE );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ViewTypeEnumMapping, BUFFER_VIEW_UNORDERED_ACCESS );
- VERIFY( m_ViewTypeEnumMapping.m_Str2ValMap.size() == BUFFER_VIEW_NUM_VIEWS - 1,
- "Unexpected map size. Did you update BUFFER_VIEW_TYPE enum?" );
- VERIFY( m_ViewTypeEnumMapping.m_Val2StrMap.size() == BUFFER_VIEW_NUM_VIEWS - 1,
- "Unexpected map size. Did you update BUFFER_VIEW_TYPE enum?" );
- DEFINE_ENUM_BINDER( m_Bindings, SBuffViewDescWrapper, ViewType, m_ViewTypeEnumMapping );
-
- DEFINE_BINDER_EX( m_Bindings, SBuffViewDescWrapper, Format, BufferFormat, 0 );
-
- DEFINE_BINDER( m_Bindings, SBuffViewDescWrapper, ByteOffset);
- DEFINE_BINDER( m_Bindings, SBuffViewDescWrapper, ByteWidth);
- };
-
- void BufferViewParser::CreateObj( lua_State *L )
- {
- INIT_LUA_STACK_TRACKING(L);
-
- auto *pBuffer = *GetUserData<IBuffer**>( L, 1, m_BufferLibMetatableName.c_str() );
-
- SBuffViewDescWrapper BufferViewDesc;
- ParseLuaTable( L, 2, &BufferViewDesc, m_Bindings );
- CHECK_LUA_STACK_HEIGHT();
-
- auto ppBufferView = reinterpret_cast<IBufferView**>(lua_newuserdata( L, sizeof( IBufferView* ) ));
- *ppBufferView = nullptr;
-
- auto& BuffFmt = BufferViewDesc.Format;
- const auto& BuffDesc = pBuffer->GetDesc();
- if (BuffFmt.ValueType != VT_UNDEFINED)
- {
- if (BuffFmt.NumComponents == 0)
- SCRIPT_PARSING_ERROR( L, "Number components cannot be 0" );
- auto FmtSize = GetValueSize( BuffFmt.ValueType ) * Uint32{BuffFmt.NumComponents};
- if (BuffDesc.ElementByteStride != FmtSize )
- {
- SCRIPT_PARSING_ERROR( L, "Format size (", FmtSize, ") specified by view '", BufferViewDesc.Name,"' does not match the element byte stride (", BuffDesc.ElementByteStride, ") of the buffer '", BuffDesc.Name, "'." );
- }
- if (BuffFmt.ValueType == VT_FLOAT32 || BuffFmt.ValueType == VT_FLOAT16)
- BuffFmt.IsNormalized = false;
- }
-
- pBuffer->CreateView( BufferViewDesc, ppBufferView );
- if( *ppBufferView == nullptr )
- SCRIPT_PARSING_ERROR(L, "Failed to create buffer view")
-
- CHECK_LUA_STACK_HEIGHT( +1 );
- }
-
- int BufferViewParser::CreateView( lua_State *L )
- {
- // Note that LuaCreate is a static function.
- // However, this pointer to the BufferViewParser object
- // is stored in the upvalue. So LuaCreate will call
- // BufferViewParser::CreateObj()
- return LuaCreate(L);
- }
-
- int BufferViewParser::GetDefaultView( lua_State *L )
- {
- INIT_LUA_STACK_TRACKING( L );
-
- // Buffer should be the first argument
- auto *pBuffer = *GetUserData<IBuffer**>( L, 1, m_BufferLibMetatableName.c_str() );
-
- // View type should be the second argument
- BUFFER_VIEW_TYPE ViewType;
- m_ViewTypeParser.SetValue( L, 2, &ViewType );
-
- auto pView = pBuffer->GetDefaultView( ViewType );
-
- // Push existing object
- PushObject(L, pView);
-
- CHECK_LUA_STACK_HEIGHT( +1 );
-
- // Returning one value to Lua
- return 1;
- }
-}
diff --git a/RenderScript/src/DepthStencilStateDescParser.cpp b/RenderScript/src/DepthStencilStateDescParser.cpp
deleted file mode 100644
index e896be8..0000000
--- a/RenderScript/src/DepthStencilStateDescParser.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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 "DepthStencilStateDescParser.h"
-
-namespace Diligent
-{
- template<>
- class MemberBinder<StencilOpDesc> : public MemberBinderBase
- {
- public:
- MemberBinder( size_t MemberOffset, size_t Dummy ) :
- MemberBinderBase( MemberOffset )
- {
- DEFINE_ENUM_ELEMENT_MAPPING( m_StencilOpEnumMapping, STENCIL_OP_KEEP );
- DEFINE_ENUM_ELEMENT_MAPPING( m_StencilOpEnumMapping, STENCIL_OP_ZERO );
- DEFINE_ENUM_ELEMENT_MAPPING( m_StencilOpEnumMapping, STENCIL_OP_REPLACE );
- DEFINE_ENUM_ELEMENT_MAPPING( m_StencilOpEnumMapping, STENCIL_OP_INCR_SAT );
- DEFINE_ENUM_ELEMENT_MAPPING( m_StencilOpEnumMapping, STENCIL_OP_DECR_SAT );
- DEFINE_ENUM_ELEMENT_MAPPING( m_StencilOpEnumMapping, STENCIL_OP_INVERT );
- DEFINE_ENUM_ELEMENT_MAPPING( m_StencilOpEnumMapping, STENCIL_OP_INCR_WRAP );
- DEFINE_ENUM_ELEMENT_MAPPING( m_StencilOpEnumMapping, STENCIL_OP_DECR_WRAP );
- VERIFY( m_StencilOpEnumMapping.m_Str2ValMap.size() == STENCIL_OP_NUM_OPS - 1,
- "Unexpected map size. Did you update STENCIL_OP enum?" );
- VERIFY( m_StencilOpEnumMapping.m_Val2StrMap.size() == STENCIL_OP_NUM_OPS - 1,
- "Unexpected map size. Did you update STENCIL_OP enum?" );
-
- DEFINE_ENUM_BINDER( m_Bindings, StencilOpDesc, StencilFailOp, m_StencilOpEnumMapping );
- DEFINE_ENUM_BINDER( m_Bindings, StencilOpDesc, StencilDepthFailOp, m_StencilOpEnumMapping );
- DEFINE_ENUM_BINDER( m_Bindings, StencilOpDesc, StencilPassOp, m_StencilOpEnumMapping );
- DEFINE_ENUM_BINDER( m_Bindings, StencilOpDesc, StencilFunc, m_CmpFuncEnumMapping );
- }
-
- virtual void GetValue( lua_State *L, const void* pBasePointer )
- {
- const auto &StOpDesc = GetMemberByOffest< StencilOpDesc >(pBasePointer, m_MemberOffset);
- PushLuaTable( L, &StOpDesc, m_Bindings );
- }
-
- virtual void SetValue( lua_State *L, int Index, void* pBasePointer )
- {
- auto &StOpDesc = GetMemberByOffest< StencilOpDesc >( pBasePointer, m_MemberOffset );
- ParseLuaTable( L, Index, &StOpDesc, m_Bindings );
- }
-
- private:
- BindingsMapType m_Bindings;
- ComparisonFuncEnumMapping m_CmpFuncEnumMapping;
- EnumMapping < STENCIL_OP > m_StencilOpEnumMapping;
- };
-
- MemberBinder<DepthStencilStateDesc>::MemberBinder( size_t MemberOffset, size_t Dummy ) :
- MemberBinderBase( MemberOffset )
- {
- DEFINE_BINDER( m_Bindings, DepthStencilStateDesc, DepthEnable );
- DEFINE_BINDER( m_Bindings, DepthStencilStateDesc, DepthWriteEnable );
- DEFINE_ENUM_BINDER( m_Bindings, DepthStencilStateDesc, DepthFunc, m_CmpFuncEnumMapping );
-
- DEFINE_BINDER( m_Bindings, DepthStencilStateDesc, StencilEnable );
- DEFINE_BINDER( m_Bindings, DepthStencilStateDesc, StencilReadMask );
- DEFINE_BINDER( m_Bindings, DepthStencilStateDesc, StencilWriteMask );
- DEFINE_BINDER_EX( m_Bindings, DepthStencilStateDesc, FrontFace, StencilOpDesc, 0 );
- DEFINE_BINDER_EX( m_Bindings, DepthStencilStateDesc, BackFace, StencilOpDesc, 0 );
- };
-
- void MemberBinder<DepthStencilStateDesc> ::GetValue(lua_State *L, const void* pBasePointer)
- {
- const auto &DSSDesc = GetMemberByOffest< DepthStencilStateDesc >(pBasePointer, m_MemberOffset);
- PushLuaTable(L, &DSSDesc, m_Bindings);
- }
-
- void MemberBinder<DepthStencilStateDesc> ::SetValue(lua_State *L, int Index, void* pBasePointer)
- {
- 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
deleted file mode 100644
index 4c2754a..0000000
--- a/RenderScript/src/DeviceContextFuncBindings.cpp
+++ /dev/null
@@ -1,290 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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 "DeviceContextFuncBindings.h"
-#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,
- 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_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_ClearDepthStencilFlagsEnumMapping, CLEAR_DEPTH_FLAG_NONE );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ClearDepthStencilFlagsEnumMapping, CLEAR_DEPTH_FLAG );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ClearDepthStencilFlagsEnumMapping, CLEAR_STENCIL_FLAG );
- };
-
- int DeviceContextFuncBindings::SetRenderTargets( lua_State *L )
- {
- auto NumArgs = lua_gettop( L );
- ITextureView *pRTVs[MaxRenderTargets] = {};
- ITextureView *pDSV = nullptr;
- Uint32 NumRTs = 0;
- RESOURCE_STATE_TRANSITION_MODE TransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION;
- for( int CurrArg = 1; CurrArg <= NumArgs; ++CurrArg )
- {
- if( lua_type( L, CurrArg ) == LUA_TUSERDATA )
- {
- auto *pView = *GetUserData<ITextureView**>( L, CurrArg, m_TexViewMetatableName.c_str() );
- auto ViewType = pView->GetDesc().ViewType;
- if( ViewType == TEXTURE_VIEW_RENDER_TARGET )
- {
- if( NumRTs < MaxRenderTargets )
- {
- pRTVs[NumRTs] = pView;
- ++NumRTs;
- }
- else
- {
- SCRIPT_PARSING_ERROR( L, "Too many render targets are being set. ", MaxRenderTargets, " at most are allowed." );
- }
- }
- else if( ViewType == TEXTURE_VIEW_DEPTH_STENCIL )
- {
- if( pDSV != nullptr )
- SCRIPT_PARSING_ERROR( L, "Respecifying depth stencil view. Only one is allowed" );
- pDSV = pView;
- }
- else
- {
- SCRIPT_PARSING_ERROR( L, "Unexpected view type. Only render target and depth stencil are allowed" );
- }
- }
- else
- {
- EnumMemberBinder<RESOURCE_STATE_TRANSITION_MODE> StateTransitionModeLoader(0, "StateTransitionMode", m_StateTransitionModeMapping);
- StateTransitionModeLoader.SetValue( L, CurrArg, &TransitionMode );
- }
- }
-
- auto *pContext = EngineObjectParserBase::LoadDeviceContextFromRegistry( L );
- pContext->SetRenderTargets( NumRTs, pRTVs, pDSV, TransitionMode );
-
- // Return no values to Lua
- return 0;
- }
-
- int DeviceContextFuncBindings::ClearRenderTarget( lua_State *L )
- {
- auto NumArgs = lua_gettop( L );
-
- ITextureView *pView = nullptr;
- Float32 RGBA[4] = {};
-
- int CurrArg = 1;
- if( CurrArg <= NumArgs )
- {
- if( lua_type( L, CurrArg ) == LUA_TUSERDATA )
- {
- pView = *GetUserData<ITextureView**>( L, CurrArg, m_TexViewMetatableName.c_str() );
- ++CurrArg;
- }
- }
- for( int c = 0; c < 4 && CurrArg <= NumArgs; ++c, ++CurrArg )
- {
- if( lua_type( L, CurrArg ) != LUA_TNUMBER )
- break;
- RGBA[c] = ReadValueFromLua<Float32>( L, CurrArg );
- }
-
- RESOURCE_STATE_TRANSITION_MODE StateTransitionMode = RESOURCE_STATE_TRANSITION_MODE_NONE;
- if( CurrArg <= NumArgs && lua_type( L, CurrArg ) == LUA_TSTRING )
- {
- EnumMemberBinder<RESOURCE_STATE_TRANSITION_MODE> StateTransitionModeLoader(0, "StateTransitionMode", m_StateTransitionModeMapping);
- StateTransitionModeLoader.SetValue( L, CurrArg, &StateTransitionMode );
- ++CurrArg;
- }
- auto *pContext = EngineObjectParserBase::LoadDeviceContextFromRegistry( L );
- pContext->ClearRenderTarget( pView, RGBA, StateTransitionMode );
-
- return 0;
- }
-
- int DeviceContextFuncBindings::ClearDepthStencil( lua_State *L )
- {
- auto NumArgs = lua_gettop( L );
-
- ITextureView *pView = nullptr;
- Float32 fDepth = 1.f;
- Uint8 Stencil = 0;
-
- int CurrArg = 1;
- if( CurrArg <= NumArgs )
- {
- if( lua_type( L, CurrArg ) == LUA_TUSERDATA )
- {
- pView = *GetUserData<ITextureView**>( L, CurrArg, m_TexViewMetatableName.c_str() );
- ++CurrArg;
- }
- }
-
- CLEAR_DEPTH_STENCIL_FLAGS ClearFlags = CLEAR_DEPTH_FLAG_NONE;
- if( CurrArg <= NumArgs &&
- (lua_type( L, CurrArg ) == LUA_TSTRING ||
- lua_type( L, CurrArg ) == LUA_TTABLE ) )
- {
- FlagsLoader<CLEAR_DEPTH_STENCIL_FLAGS> FlagsLoader(0, "ClearDepthStencilFlags", m_ClearDepthStencilFlagsEnumMapping);
- FlagsLoader.SetValue( L, CurrArg, &ClearFlags );
- ++CurrArg;
- }
-
- if( CurrArg <= NumArgs && (ClearFlags == CLEAR_DEPTH_FLAG_NONE || (ClearFlags & CLEAR_DEPTH_FLAG)!=0) )
- {
- fDepth = ReadValueFromLua<Float32>( L, CurrArg );
- ClearFlags |= CLEAR_DEPTH_FLAG;
- ++CurrArg;
- }
-
- if( CurrArg <= NumArgs && lua_isnumber( L, CurrArg ) )
- {
- Stencil = ReadValueFromLua<Uint8>( L, CurrArg );
- ClearFlags |= CLEAR_STENCIL_FLAG;
- ++CurrArg;
- }
-
- RESOURCE_STATE_TRANSITION_MODE StateTransitionMode = RESOURCE_STATE_TRANSITION_MODE_NONE;
- if( CurrArg <= NumArgs && lua_type( L, CurrArg ) == LUA_TSTRING )
- {
- EnumMemberBinder<RESOURCE_STATE_TRANSITION_MODE> StateTransitionModeLoader(0, "StateTransitionMode", m_StateTransitionModeMapping);
- StateTransitionModeLoader.SetValue( L, CurrArg, &StateTransitionMode );
- ++CurrArg;
- }
-
- auto *pContext = EngineObjectParserBase::LoadDeviceContextFromRegistry( L );
- pContext->ClearDepthStencil( pView, ClearFlags, fDepth, Stencil, StateTransitionMode );
-
- 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;
- }
- }
-
- RESOURCE_STATE_TRANSITION_MODE StateTransitionMode = RESOURCE_STATE_TRANSITION_MODE_NONE;
- if( CurrArg <= NumArgs && lua_type( L, CurrArg ) == LUA_TSTRING )
- {
- EnumMemberBinder<RESOURCE_STATE_TRANSITION_MODE> StateTransitionModeLoader(0, "StateTransitionMode", m_StateTransitionModeMapping);
- StateTransitionModeLoader.SetValue( L, CurrArg, &StateTransitionMode );
- ++CurrArg;
- }
-
- auto *pContext = EngineObjectParserBase::LoadDeviceContextFromRegistry( L );
- pContext->CommitShaderResources( pShaderResBinding, StateTransitionMode );
-
- 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
deleted file mode 100644
index ee395a9..0000000
--- a/RenderScript/src/DrawAttribsParser.cpp
+++ /dev/null
@@ -1,201 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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 "DrawAttribsParser.h"
-#include "BufferParser.h"
-#include "ScriptParser.h"
-
-namespace Diligent
-{
- using CombinedDrawAttribs = ScriptParser::CombinedDrawAttribs;
-
- const Char* DrawAttribsParser::DrawAttribsLibName = "DrawAttribs";
-
- DrawAttribsParser::DrawAttribsParser( BufferParser *pBuffParser, IRenderDevice *pRenderDevice, lua_State *L ) :
- EngineObjectParserBase( pRenderDevice, L, DrawAttribsLibName ),
- m_DrawBinding( this, L, "Context", "Draw", &DrawAttribsParser::Draw ),
- m_DispatchComputeBinding( this, L, "Context", "DispatchCompute", &DrawAttribsParser::DispatchCompute ),
- m_BufferMetatableName(pBuffParser->GetMetatableName())
- {
- // NumVertices and NumIndices are in Union
- DEFINE_BINDER( m_Bindings, CombinedDrawAttribs, NumVertices );
- DEFINE_BINDER( m_Bindings, CombinedDrawAttribs, NumIndices );
-
- DEFINE_ENUM_ELEMENT_MAPPING( m_DrawFlagsEnumMapping, DRAW_FLAG_NONE );
- DEFINE_ENUM_ELEMENT_MAPPING( m_DrawFlagsEnumMapping, DRAW_FLAG_VERIFY_STATES );
- DEFINE_ENUM_ELEMENT_MAPPING( m_DrawFlagsEnumMapping, DRAW_FLAG_VERIFY_DRAW_ATTRIBS );
- DEFINE_ENUM_ELEMENT_MAPPING( m_DrawFlagsEnumMapping, DRAW_FLAG_VERIFY_RENDER_TARGETS );
- DEFINE_ENUM_ELEMENT_MAPPING( m_DrawFlagsEnumMapping, DRAW_FLAG_VERIFY_ALL );
-
- DEFINE_FLAGS_BINDER( m_Bindings, CombinedDrawAttribs, Flags, DRAW_FLAGS, m_DrawFlagsEnumMapping );
- DEFINE_ENUM_BINDER( m_Bindings, CombinedDrawAttribs, IndirectAttribsBufferStateTransitionMode, m_StateTransitionModeEnumMapping);
-
- DEFINE_ENUM_ELEMENT_MAPPING( m_ValueTypeEnumMapping, VT_UINT16 );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ValueTypeEnumMapping, VT_UINT32 );
- DEFINE_ENUM_BINDER( m_Bindings, CombinedDrawAttribs, IndexType, m_ValueTypeEnumMapping );
-
- DEFINE_BINDER( m_Bindings, CombinedDrawAttribs, NumInstances );
-
- DEFINE_BINDER( m_Bindings, CombinedDrawAttribs, BaseVertex );
- DEFINE_BINDER( m_Bindings, CombinedDrawAttribs, IndirectDrawArgsOffset );
-
- // StartVertexLocation and FirstIndexLocation are in union
- DEFINE_BINDER( m_Bindings, CombinedDrawAttribs, StartVertexLocation );
- DEFINE_BINDER( m_Bindings, CombinedDrawAttribs, FirstIndexLocation );
-
- DEFINE_BINDER( m_Bindings, CombinedDrawAttribs, FirstInstanceLocation );
-
- std::vector<String> AllowedMetatable = { "Metatables.Buffer" };
- DEFINE_BINDER_EX( m_Bindings, CombinedDrawAttribs, pIndirectDrawAttribs, EngineObjectPtrLoader<IBuffer>, AllowedMetatable );
- };
-
- void DrawAttribsParser::CreateObj( lua_State *L )
- {
- INIT_LUA_STACK_TRACKING(L);
-
- CombinedDrawAttribs DrawAttrs;
- ParseLuaTable( L, 1, &DrawAttrs, m_Bindings );
-
- CHECK_LUA_STACK_HEIGHT();
-
- auto pDrawAttribs = reinterpret_cast<CombinedDrawAttribs*>(lua_newuserdata( L, sizeof( CombinedDrawAttribs ) ));
- memcpy(pDrawAttribs, &DrawAttrs, sizeof(CombinedDrawAttribs));
-
- CHECK_LUA_STACK_HEIGHT( +1 );
- }
-
- void DrawAttribsParser::DestroyObj( void *pData )
- {
- // We do not need to do anything, because the whole object is
- // created as full user data and thus managed by Lua
- }
-
- void DrawAttribsParser::ReadField( lua_State *L, void *pData, const Char *Field )
- {
- auto pDrawAttribs = reinterpret_cast<CombinedDrawAttribs*>(pData);
- PushField( L, pDrawAttribs, Field, m_Bindings );
- }
-
- void DrawAttribsParser::UpdateField( lua_State *L, void *pData, const Char *Field )
- {
- auto pDrawAttribs = reinterpret_cast<CombinedDrawAttribs*>(pData);
- Diligent::UpdateField( L, -1, pDrawAttribs, Field, m_Bindings );
- }
-
- void DrawAttribsParser::PushExistingObject( lua_State *L, const void *pObject )
- {
- auto pDrawAttribs = reinterpret_cast<CombinedDrawAttribs*>(lua_newuserdata( L, sizeof( CombinedDrawAttribs ) ));
- memcpy( pDrawAttribs, pObject, sizeof( CombinedDrawAttribs ) );
- }
-
- int DrawAttribsParser::Draw( lua_State *L )
- {
- auto pDrawAttribs = GetUserData<CombinedDrawAttribs*>( L, 1, m_MetatableRegistryName.c_str() );
- auto *pContext = LoadDeviceContextFromRegistry( L );
- if (pDrawAttribs->pIndirectDrawAttribs != nullptr)
- {
- if (pDrawAttribs->IndexType != VT_UNDEFINED)
- {
- DrawIndexedIndirectAttribs Attribs;
- Attribs.Flags = pDrawAttribs->Flags;
- Attribs.IndexType = pDrawAttribs->IndexType;
- Attribs.IndirectAttribsBufferStateTransitionMode = pDrawAttribs->IndirectAttribsBufferStateTransitionMode;
- Attribs.IndirectDrawArgsOffset = pDrawAttribs->IndirectDrawArgsOffset;
- pContext->DrawIndexedIndirect(Attribs, pDrawAttribs->pIndirectDrawAttribs);
- }
- else
- {
- DrawIndirectAttribs Attribs;
- Attribs.Flags = pDrawAttribs->Flags;
- Attribs.IndirectAttribsBufferStateTransitionMode = pDrawAttribs->IndirectAttribsBufferStateTransitionMode;
- Attribs.IndirectDrawArgsOffset = pDrawAttribs->IndirectDrawArgsOffset;
- pContext->DrawIndirect(Attribs, pDrawAttribs->pIndirectDrawAttribs);
- }
- }
- else
- {
- if (pDrawAttribs->IndexType != VT_UNDEFINED)
- {
- DrawIndexedAttribs Attribs;
- Attribs.BaseVertex = pDrawAttribs->BaseVertex;
- Attribs.FirstIndexLocation = pDrawAttribs->FirstIndexLocation;
- Attribs.FirstInstanceLocation = pDrawAttribs->FirstInstanceLocation;
- Attribs.Flags = pDrawAttribs->Flags;
- Attribs.IndexType = pDrawAttribs->IndexType;
- Attribs.NumIndices = pDrawAttribs->NumIndices;
- Attribs.NumInstances = pDrawAttribs->NumInstances;
- pContext->DrawIndexed(Attribs);
- }
- else
- {
- DrawAttribs Attribs;
- Attribs.FirstInstanceLocation = pDrawAttribs->FirstInstanceLocation;
- Attribs.Flags = pDrawAttribs->Flags;
- Attribs.NumInstances = pDrawAttribs->NumInstances;
- Attribs.NumVertices = pDrawAttribs->NumVertices;
- Attribs.StartVertexLocation = pDrawAttribs->StartVertexLocation;
- pContext->Draw(Attribs);
- }
- }
-
- return 0;
- }
-
- int DrawAttribsParser::DispatchCompute( lua_State *L )
- {
- if( lua_type( L, 1 ) == LUA_TUSERDATA )
- {
- DispatchComputeIndirectAttribs DispatchAttrs;
- auto* pIndirectDispatchAttribs = *GetUserData<IBuffer**>( L, 1, m_BufferMetatableName.c_str() );
- int CurrArgInd = 2;
- if( CurrArgInd <= lua_gettop( L ) && lua_isnumber( L, CurrArgInd ) )
- {
- DispatchAttrs.DispatchArgsByteOffset = ReadValueFromLua<Uint32>( L, CurrArgInd );
- ++CurrArgInd;
- }
- if( CurrArgInd <= lua_gettop( L ) && lua_type( L, CurrArgInd ) == LUA_TSTRING )
- {
- EnumMemberBinder<RESOURCE_STATE_TRANSITION_MODE> StateTransitionModeLoader(0, "StateTransitionMode", m_StateTransitionModeEnumMapping);
- StateTransitionModeLoader.SetValue( L, CurrArgInd, &DispatchAttrs.IndirectAttribsBufferStateTransitionMode );
- }
- auto *pContext = LoadDeviceContextFromRegistry( L );
- pContext->DispatchComputeIndirect( DispatchAttrs, pIndirectDispatchAttribs );
- }
- else
- {
- DispatchComputeAttribs DispatchAttrs;
- if( lua_gettop( L ) >= 1 )
- DispatchAttrs.ThreadGroupCountX = ReadValueFromLua<Uint32>( L, 1 );
- if( lua_gettop( L ) >= 2 )
- DispatchAttrs.ThreadGroupCountY = ReadValueFromLua<Uint32>( L, 2 );
- if( lua_gettop( L ) >= 3 )
- DispatchAttrs.ThreadGroupCountY = ReadValueFromLua<Uint32>( L, 3 );
- auto *pContext = LoadDeviceContextFromRegistry( L );
- pContext->DispatchCompute( DispatchAttrs );
- }
-
-
- return 0;
- }
-}
diff --git a/RenderScript/src/EngineObjectParserBase.cpp b/RenderScript/src/EngineObjectParserBase.cpp
deleted file mode 100644
index 96a1b53..0000000
--- a/RenderScript/src/EngineObjectParserBase.cpp
+++ /dev/null
@@ -1,271 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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 "EngineObjectParserBase.h"
-#include "ScriptParser.h"
-
-using namespace Diligent;
-
-namespace Diligent
-{
- EngineObjectParserBase::EngineObjectParserBase( IRenderDevice *pRenderDevice, lua_State *L, const Char *LibName ) :
- m_pRenderDevice( pRenderDevice ),
- m_LibName( LibName ),
- m_MetatableRegistryName( String( "Metatables." ) + m_LibName )
- {
- // TODO: remove this function, move everything to ctor
- RegisterTable( L );
- }
-
- int EngineObjectParserBase::LuaCreate( lua_State *L )
- {
- INIT_LUA_STACK_TRACKING( L );
-
- EngineObjectParserBase *This = static_cast<EngineObjectParserBase *>(lua_touserdata( L, lua_upvalueindex( 1 ) ));
- // This pointer cannot be null because we stored it in an up value when created the library
- VERIFY( This, "This pointer is null" );
- if( !This )return 0;
-
- try
- {
- This->CreateObj( L );
- }
- catch( const std::runtime_error &err )
- {
- SCRIPT_PARSING_ERROR( L, "Failed to create ", This->m_LibName, " object: \n", err.what() );
- }
-
- // Push onto the stack the metatable associated with name given in the registry
- luaL_getmetatable( L, This->m_MetatableRegistryName.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 number of return arguments
- // New userdatum is on the top of the stack
- return 1;
- }
-
- int EngineObjectParserBase::LuaGC( lua_State *L )
- {
- INIT_LUA_STACK_TRACKING( L );
-
- EngineObjectParserBase *This = static_cast<EngineObjectParserBase *>(lua_touserdata( L, lua_upvalueindex( 1 ) ));
- // This pointer cannot be null because we stored it in an up value when created the library
- VERIFY( This, "This pointer is null" );
- if( !This )return 0;
-
- // Do not throw exception as this function can be called from dtor!
- //auto pData = GetUserData<void*>( L, 1, This->m_MetatableRegistryName.c_str() );
- auto pData = reinterpret_cast<void*>(luaL_testudata( L, 1, This->m_MetatableRegistryName.c_str() ));
- if( pData )
- {
- This->DestroyObj( pData );
- }
-
- CHECK_LUA_STACK_HEIGHT();
-
- return 0;
- }
-
- int EngineObjectParserBase::LuaIndex( lua_State *L )
- {
- INIT_LUA_STACK_TRACKING( L );
-
- // Whenever Lua calls C, the called function gets a new stack, which is independent
- // of previous stacks and of stacks of C functions that are still active. This stack
- // initially contains any arguments to the C function and it is where the C function
- // pushes its results to be returned to the calle
-
-
- // Note that the syntax var.Name is just syntactic sugar for var["Name"]
- // The first parameter to the __index() function is the object and the second is
- // the index
-
- EngineObjectParserBase *This = static_cast<EngineObjectParserBase *>(lua_touserdata( L, lua_upvalueindex( 1 ) ));
- // This pointer cannot be null because we stored it in an up value when created the library
- VERIFY( This, "This pointer is null" );
- if( !This )return 0;
-
- auto pData = GetUserData<void*>( L, 1, This->m_MetatableRegistryName.c_str() );
- auto Field = ReadValueFromLua<const Char*>( L, 2 );
-
- // First try to find the field in the metatable
- // Push metatable onto the stack
- luaL_getmetatable( L, This->m_MetatableRegistryName.c_str() ); // -0 | +1 -> +1
- // Duplicate key on the top of the stack
- lua_pushvalue( L, -2 ); // -0 | +1 -> +1
- // Use rawget to avoid calling __index
- lua_rawget( L, -2 ); // -1 | +1 -> +0
- // Remove metatable from the stack
- lua_remove( L, -2 ); // -1 | +0 -> -1
- if( lua_type( L, -1 ) == LUA_TNIL )
- {
- // Pop nil from the stack
- lua_pop( L, 1 ); // -1 | +0 -> -1
- This->ReadField( L, pData, Field );
- }
- else
- {
- // Value is on top of the stack
- }
-
- CHECK_LUA_STACK_HEIGHT( +1 );
-
- return 1;
- }
-
- void EngineObjectParserBase::UpdateField( lua_State *L, void *pData, const Char *Field )
- {
- SCRIPT_PARSING_ERROR( L, "Attempting to update \"", Field, "\" field of a read-only object \"", m_LibName.c_str(), '\"' );
- }
-
- int EngineObjectParserBase::LuaNewIndex( lua_State *L )
- {
- INIT_LUA_STACK_TRACKING( L );
-
- EngineObjectParserBase *This = static_cast<EngineObjectParserBase *>(lua_touserdata( L, lua_upvalueindex( 1 ) ));
- // This pointer cannot be null because we stored it in an up value when created the library
- VERIFY( This, "This pointer is null" );
- if( !This )return 0;
-
- auto pData = GetUserData<void*>( L, 1, This->m_MetatableRegistryName.c_str() );
- auto Field = ReadValueFromLua<const Char*>( L, 2 );
- This->UpdateField( L, pData, Field );
-
- CHECK_LUA_STACK_HEIGHT();
-
- return 0;
- }
-
- void EngineObjectParserBase::RegisterTable( lua_State *L )
- {
- INIT_LUA_STACK_TRACKING( L );
-
- // If the registry already has the key with the same name, luaL_newmetatable() returns 0.
- // Otherwise, it creates a new table to be used as a metatable for userdata, adds it to the
- // registry with key tname, and returns 1. In both cases it pushes onto the stack the final
- // value associated with tname in the registry.
- auto Created = luaL_newmetatable( L, m_MetatableRegistryName.c_str() ); // -0 | +1 -> +1
- VERIFY( Created, "Metatble with the same name already registered!" ); (void)Created;
-
- // http://lua-users.org/wiki/MetatableEvents
- luaL_Reg MetaMethods[] = {
- // An object is marked for finalization when its metatable is set and the metatable
- // has a field indexed by the string "__gc". NOTE: if a metatable without a __gc field
- // is set and that field is only later added to the metatable, the object will NOT be marked
- // for finalization.
- { "__gc", LuaGC },
- { "__index", LuaIndex },
- { "__newindex", LuaNewIndex },
- { NULL, NULL }
- };
-
- lua_pushlightuserdata( L, this ); // -0 | +1 -> +1
-
- // Register all functions in the array into the table on the top of the stack
- // When nup (last parameter) is not zero, all functions are created sharing nup upvalues,
- // which must be previously pushed on the stack on top of the library table.
- // These values are popped from the stack after the registration.
- luaL_setfuncs( L, MetaMethods, 1 ); // -1 | +0 -> -1
-
- // luaL_setfuncs() does the following for every function in the list:
- //lua_pushstring( L, FuncName );
- //lua_pushlightuserdata( L, this );
- //lua_pushcclosure( L, Function, 1 );
- //lua_settable( L, -3 );
-
- // Protect metatable from tampering in the script
- // If __metatable field is set, then getmetatable() function returns
- // what is stored in this field instead of the actual metatable
- // and setmetatable() is not allowed to access it
- lua_pushliteral( L, "__metatable" ); // -0 | +1 -> +1
- lua_pushliteral( L, "Metatable is not accessible!" ); // -0 | +1 -> +1
- // Note that lua_settable() may trigger a metamethod
- // for the "newindex" event
- lua_settable( L, -3 ); // -2 | +0 -> -2
-
- // Pop metatable
- lua_pop( L, 1 ); // -1 | +0 -> -1
-
- CHECK_LUA_STACK_HEIGHT();
-
- luaL_Reg Methods[] = {
- { "Create", LuaCreate },
- { NULL, NULL }
- };
-
- // Create a new table with a size optimized to store all entries in the array Methods
- // (but does not actually store them).
- luaL_newlibtable( L, Methods ); // -0 | +1 -> +1
-
- // Push pointer onto the stack
- lua_pushlightuserdata( L, this ); // -0 | +1 -> +1
-
- // Register all functions in the array into the table on the top of the stack
- // When nup (last parameter) is not zero, all functions are created sharing nup upvalues,
- // which must be previously pushed on the stack on top of the library table.
- // These values are popped from the stack after the registration.
- luaL_setfuncs( L, Methods, 1 ); // -1 | +0 -> -1
-
- // Pop a value from the stack and set it as the new value of global name.
- lua_setglobal( L, m_LibName.c_str() ); // -1 | +0 -> -1
-
- CHECK_LUA_STACK_HEIGHT();
- }
-
- void EngineObjectParserBase::PushObject( lua_State *L, const void *pData )
- {
- INIT_LUA_STACK_TRACKING( L );
-
- if( pData )
- PushExistingObject( L, pData );
- else
- lua_pushnil( L );
-
- luaL_getmetatable( L, m_MetatableRegistryName.c_str() ); // -0 | +1 -> +1
- lua_setmetatable( L, -2 ); // -1 | +0 -> -1
-
- CHECK_LUA_STACK_HEIGHT( +1 );
- }
-
- IDeviceContext* EngineObjectParserBase::LoadDeviceContextFromRegistry( lua_State *L )
- {
- INIT_LUA_STACK_TRACKING( L );
-
- lua_pushstring( L, ScriptParser::DeviceContextRegistryKey ); // -0 | +1 -> +1
- lua_gettable(L, LUA_REGISTRYINDEX ); // -1 | +1 -> +0
- CheckType( L, -1, LUA_TLIGHTUSERDATA );
- IDeviceContext* pContext = reinterpret_cast<IDeviceContext*>( lua_touserdata(L, -1) );
- lua_pop( L, 1 ); // -1 | +0 -> -1
-
- VERIFY( pContext != nullptr, "Device context is null" );
-
- CHECK_LUA_STACK_HEIGHT();
-
- return pContext;
- }
-}
diff --git a/RenderScript/src/EnumMappings.cpp b/RenderScript/src/EnumMappings.cpp
deleted file mode 100644
index e6728ff..0000000
--- a/RenderScript/src/EnumMappings.cpp
+++ /dev/null
@@ -1,234 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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 "EnumMappings.h"
-
-using namespace std;
-
-namespace Diligent
-{
- CpuAccessFlagEnumMapping::CpuAccessFlagEnumMapping()
- {
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), CPU_ACCESS_NONE );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), CPU_ACCESS_READ );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), CPU_ACCESS_WRITE );
- }
-
- UsageEnumMapping::UsageEnumMapping()
- {
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), USAGE_STATIC );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), USAGE_DEFAULT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), USAGE_DYNAMIC );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), USAGE_STAGING );
- }
-
- 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 );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGBA32_SINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGB32_TYPELESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGB32_FLOAT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGB32_UINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGB32_SINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGBA16_TYPELESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGBA16_FLOAT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGBA16_UNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGBA16_UINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGBA16_SNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGBA16_SINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RG32_TYPELESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RG32_FLOAT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RG32_UINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RG32_SINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_R32G8X24_TYPELESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_D32_FLOAT_S8X24_UINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_X32_TYPELESS_G8X24_UINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGB10A2_TYPELESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGB10A2_UNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGB10A2_UINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_R11G11B10_FLOAT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGBA8_TYPELESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGBA8_UNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGBA8_UNORM_SRGB );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGBA8_UINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGBA8_SNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGBA8_SINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RG16_TYPELESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RG16_FLOAT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RG16_UNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RG16_UINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RG16_SNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RG16_SINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_R32_TYPELESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_D32_FLOAT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_R32_FLOAT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_R32_UINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_R32_SINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_R24G8_TYPELESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_D24_UNORM_S8_UINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_R24_UNORM_X8_TYPELESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_X24_TYPELESS_G8_UINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RG8_TYPELESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RG8_UNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RG8_UINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RG8_SNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RG8_SINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_R16_TYPELESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_R16_FLOAT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_D16_UNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_R16_UNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_R16_UINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_R16_SNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_R16_SINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_R8_TYPELESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_R8_UNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_R8_UINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_R8_SNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_R8_SINT );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_A8_UNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_R1_UNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RGB9E5_SHAREDEXP );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_RG8_B8G8_UNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_G8R8_G8B8_UNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BC1_TYPELESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BC1_UNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BC1_UNORM_SRGB );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BC2_TYPELESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BC2_UNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BC2_UNORM_SRGB );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BC3_TYPELESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BC3_UNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BC3_UNORM_SRGB );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BC4_TYPELESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BC4_UNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BC4_SNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BC5_TYPELESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BC5_UNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BC5_SNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_B5G6R5_UNORM ); // Deprecated format, unavailable in D3D11+
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_B5G5R5A1_UNORM ); // Deprecated format, unavailable in D3D11+
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BGRA8_UNORM ); // Deprecated format, unavailable in D3D11+
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BGRX8_UNORM ); // Deprecated format, unavailable in D3D11+
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_R10G10B10_XR_BIAS_A2_UNORM );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BGRA8_TYPELESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BGRA8_UNORM_SRGB );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BGRX8_TYPELESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BGRX8_UNORM_SRGB );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BC6H_TYPELESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BC6H_UF16 );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BC6H_SF16 );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), TEX_FORMAT_BC7_TYPELESS );
- 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,
- "Unexpected map size. Did you update TEXTURE_FORMAT enum?" );
- VERIFY( m_Val2StrMap.size() == TEX_FORMAT_NUM_FORMATS,
- "Unexpected map size. Did you update TEXTURE_FORMAT enum?" );
- }
-
- ResourceDimEnumMapping::ResourceDimEnumMapping()
- {
- 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()
- {
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), VT_UNDEFINED );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), VT_INT8 );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), VT_INT16 );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), VT_INT32 );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), VT_UINT8 );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), VT_UINT16 );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), VT_UINT32 );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), VT_FLOAT16 );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), VT_FLOAT32 );
- static_assert(VT_NUM_TYPES == VT_FLOAT32 + 1, "Not all value types initialized.");
- VERIFY( m_Str2ValMap.size() == VT_NUM_TYPES,
- "Unexpected map size. Did you update VALUE_TYPE enum?" );
- VERIFY( m_Val2StrMap.size() == VT_NUM_TYPES,
- "Unexpected map size. Did you update VALUE_TYPE enum?" );
- }
-
- ComparisonFuncEnumMapping::ComparisonFuncEnumMapping()
- {
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), COMPARISON_FUNC_NEVER );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), COMPARISON_FUNC_LESS );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), COMPARISON_FUNC_EQUAL );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), COMPARISON_FUNC_LESS_EQUAL );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), COMPARISON_FUNC_GREATER );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), COMPARISON_FUNC_NOT_EQUAL );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), COMPARISON_FUNC_GREATER_EQUAL );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), COMPARISON_FUNC_ALWAYS );
- static_assert(COMPARISON_FUNC_NUM_FUNCTIONS == COMPARISON_FUNC_ALWAYS + 1, "Not all comparison functions initialized.");
- VERIFY( m_Str2ValMap.size() == COMPARISON_FUNC_NUM_FUNCTIONS - 1,
- "Unexpected map size. Did you update COMPARISON_FUNCTION enum?" );
- VERIFY( m_Val2StrMap.size() == COMPARISON_FUNC_NUM_FUNCTIONS - 1,
- "Unexpected map size. Did you update COMPARISON_FUNCTION enum?" );
- }
-
- BindShaderResourcesFlagEnumMapping::BindShaderResourcesFlagEnumMapping()
- {
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), BIND_SHADER_RESOURCES_UPDATE_STATIC );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), BIND_SHADER_RESOURCES_UPDATE_MUTABLE );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), BIND_SHADER_RESOURCES_UPDATE_DYNAMIC );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), BIND_SHADER_RESOURCES_UPDATE_ALL );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), BIND_SHADER_RESOURCES_KEEP_EXISTING );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), BIND_SHADER_RESOURCES_VERIFY_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 );
- }
-
- StateTransitionModeEnumMapping::StateTransitionModeEnumMapping()
- {
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), RESOURCE_STATE_TRANSITION_MODE_NONE );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), RESOURCE_STATE_TRANSITION_MODE_TRANSITION );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), RESOURCE_STATE_TRANSITION_MODE_VERIFY );
- }
-}
diff --git a/RenderScript/src/InputLayoutDescParser.cpp b/RenderScript/src/InputLayoutDescParser.cpp
deleted file mode 100644
index 7c2da78..0000000
--- a/RenderScript/src/InputLayoutDescParser.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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)
- {
- using InputIndexType = decltype(LayoutElement::InputIndex);
- DEFINE_BINDER_EX( m_Bindings, LayoutElement, InputIndex, InputIndexType, Validator<InputIndexType>( "Input Index", 0, 32 ) );
- using BufferSlotType = decltype(LayoutElement::BufferSlot);
- DEFINE_BINDER_EX( m_Bindings, LayoutElement, BufferSlot, BufferSlotType, Validator<BufferSlotType>( "Buffer Slot", 0, MaxBufferSlots ) );
- using NumComponentsType = decltype(LayoutElement::NumComponents);
- DEFINE_BINDER_EX( m_Bindings, LayoutElement, NumComponents, NumComponentsType, Validator<NumComponentsType>( "Num Components", 1, 4 ) );
-
- DEFINE_ENUM_BINDER( m_Bindings, LayoutElement, ValueType, m_ValueTypeEnumMapping );
-
- DEFINE_BINDER( m_Bindings, LayoutElement, IsNormalized );
- DEFINE_BINDER( m_Bindings, LayoutElement, RelativeOffset );
- DEFINE_BINDER( m_Bindings, LayoutElement, Stride );
-
-
- 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, m_FrequencyEnumMapping );
-
- DEFINE_BINDER( m_Bindings, LayoutElement, InstanceDataStepRate );
- }
-
- 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( static_cast<int>(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/LuaBindings.cpp b/RenderScript/src/LuaBindings.cpp
deleted file mode 100644
index d3cc15e..0000000
--- a/RenderScript/src/LuaBindings.cpp
+++ /dev/null
@@ -1,279 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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 "LuaBindings.h"
-#include "GraphicsAccessories.h"
-
-using namespace std;
-
-namespace Diligent
-{
- template<typename Type>
- Type ReadIntValueFromLua( lua_State *L, int Index )
- {
- CheckType( L, Index, LUA_TNUMBER );
-
- int isnum;
- auto Val = lua_tonumberx( L, Index, &isnum );
- if( !isnum )
- {
- auto Str = lua_tostring( L, Index );
- SCRIPT_PARSING_ERROR( L, "Failed to convert parameter ", Str, " to int" );
- }
- if( static_cast<Type>(Val) != Val )
- {
- SCRIPT_PARSING_ERROR( L, "Parameter value (", Val, ") is not integer. Truncating to int" );
- }
- return static_cast<Type>(Val);
- }
-
- template<typename Type>
- Type ReadFPValueFromLua( lua_State *L, int Index )
- {
- CheckType( L, Index, LUA_TNUMBER );
-
- int isnum;
- auto Val = lua_tonumberx( L, Index, &isnum );
- if( !isnum )
- {
- auto Str = lua_tostring( L, Index );
- SCRIPT_PARSING_ERROR( L, "Failed to convert parameter ", Str, " to floating point" );
- }
- return static_cast<Type>(Val);
- }
-
- template<>
- int ReadValueFromLua<int>( lua_State *L, int Index )
- {
- return ReadIntValueFromLua<int>( L, Index );
- }
-
- template<>
- double ReadValueFromLua<double>( lua_State *L, int Index )
- {
- return ReadFPValueFromLua<double>( L, Index );
- }
-
- template<>
- float ReadValueFromLua<float>( lua_State *L, int Index )
- {
- return ReadFPValueFromLua<float>( L, Index );
- }
-
-
- template<>
- String ReadValueFromLua<String>( lua_State *L, int Index )
- {
- CheckType( L, Index, LUA_TSTRING );
-
- auto Str = lua_tostring( L, Index );
- return String( Str );
- }
-
- template<>
- const Char* ReadValueFromLua<const Char*>( lua_State *L, int Index )
- {
- CheckType( L, Index, LUA_TSTRING );
-
- auto Str = lua_tostring( L, Index );
- return Str;
- }
-
- template<>
- Bool ReadValueFromLua<Bool>( lua_State *L, int Index )
- {
- CheckType( L, Index, LUA_TBOOLEAN );
- auto Val = lua_toboolean( L, Index );
- return Val ? True : False;
- }
-
- template<>
- Uint32 ReadValueFromLua<Uint32>( lua_State *L, int Index )
- {
- return ReadIntValueFromLua<Uint32>( L, Index );
- }
-
- template<>
- Uint8 ReadValueFromLua<Uint8>( lua_State *L, int Index )
- {
- return ReadIntValueFromLua<Uint8>( L, Index );
- }
-
-
-
- template<>
- void PushValue<double>( lua_State *L, double Val )
- {
- lua_pushnumber( L, Val );
- }
-
- template<>
- void PushValue<const float&>( lua_State *L, const float& Val )
- {
- lua_pushnumber( L, Val );
- }
-
- template<>
- void PushValue<const Int32&>( lua_State *L, const Int32& Val )
- {
- lua_pushnumber( L, Val );
- }
-
- template<>
- void PushValue<const Uint8&>( lua_State *L, const Uint8& Val )
- {
- lua_pushnumber( L, Val );
- }
-
- template<>
- void PushValue<const Uint32&>( lua_State *L, const Uint32& Val )
- {
- lua_pushnumber( L, Val );
- }
-
- template<>
- void PushValue<const Char*>( lua_State *L, const Char* Val )
- {
- lua_pushstring( L, Val );
- }
-
- template<> void PushValue<const Char* const&>( lua_State *L, const Char* const& Val )
- {
- lua_pushstring( L, Val );
- }
-
- template<>
- void PushValue<const String&>( lua_State *L, const String& Val )
- {
- lua_pushstring( L, Val.c_str() );
- }
-
- template<>
- void PushValue<bool>( lua_State *L, bool Val )
- {
- lua_pushboolean( L, Val );
- }
-
- template<>
- void PushValue<const bool &>( lua_State *L, const bool &Val )
- {
- lua_pushboolean( L, Val );
- }
-
-
-
- template<VALUE_TYPE VTType>
- void ParseNumericArray( lua_State *L, int StackIndex, std::vector< Uint8 >& RawData )
- {
- typedef typename VALUE_TYPE2CType<VTType>::CType ElemType;
- CheckType( L, StackIndex, LUA_TTABLE );
- auto ArraySize = lua_rawlen( L, StackIndex );
-
- auto ElemSize = sizeof( ElemType );
- RawData.reserve( ArraySize * ElemSize );
-
- ParseLuaArray( L, StackIndex, &RawData, [ &]( void* pBasePointer, int StackIndex, int NewArrayIndex )
- {
- VERIFY( pBasePointer == &RawData, "Sanity check failed" );
- auto CurrIndex = RawData.size() / ElemSize;
- if(static_cast<int>(CurrIndex) != NewArrayIndex - 1 )
- SCRIPT_PARSING_ERROR( L, "Explicit array indices are not allowed in array initialization. Provided index ", NewArrayIndex - 1, " conflicts with actual index ", CurrIndex, "." );
- RawData.resize( (CurrIndex + 1) * ElemSize );
- auto CurrValue = ReadValueFromLua<double>( L, StackIndex );
- reinterpret_cast<ElemType&>(RawData[CurrIndex * ElemSize]) = static_cast<ElemType>(CurrValue);
- } );
- }
-
- NumericArrayLoader::NumericArrayLoader() :
- m_ValueTypeBinder( 0, "VALUE_TYPE", m_ValueTypeEnumMapping )
- {
- DEFINE_ENUM_ELEMENT_MAPPING( m_ValueTypeEnumMapping, VT_INT8 );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ValueTypeEnumMapping, VT_INT16 );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ValueTypeEnumMapping, VT_INT32 );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ValueTypeEnumMapping, VT_UINT8 );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ValueTypeEnumMapping, VT_UINT16 );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ValueTypeEnumMapping, VT_UINT32 );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ValueTypeEnumMapping, VT_FLOAT16 );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ValueTypeEnumMapping, VT_FLOAT32 );
- VERIFY( m_ValueTypeEnumMapping.m_Str2ValMap.size() == VT_NUM_TYPES - 1,
- "Unexpected map size. Did you update VALUE_TYPE enum?" );
- VERIFY( m_ValueTypeEnumMapping.m_Val2StrMap.size() == VT_NUM_TYPES - 1,
- "Unexpected map size. Did you update VALUE_TYPE enum?" );
-
- m_ParseFuncJumpTbl.insert( make_pair( VT_INT8, ParseNumericArray<VT_INT8> ) );
- m_ParseFuncJumpTbl.insert( make_pair( VT_INT16, ParseNumericArray<VT_INT16> ) );
- m_ParseFuncJumpTbl.insert( make_pair( VT_INT32, ParseNumericArray<VT_INT32> ) );
- m_ParseFuncJumpTbl.insert( make_pair( VT_UINT8, ParseNumericArray<VT_UINT8> ) );
- m_ParseFuncJumpTbl.insert( make_pair( VT_UINT16, ParseNumericArray<VT_UINT16> ) );
- m_ParseFuncJumpTbl.insert( make_pair( VT_UINT32, ParseNumericArray<VT_UINT32> ) );
- //m_ParseFuncJumpTbl.insert( make_pair( VT_FLOAT16, ParseNumericArray<VT_FLOAT16> ) );
- m_ParseFuncJumpTbl.insert( make_pair( VT_FLOAT32, ParseNumericArray<VT_FLOAT32> ) );
- };
-
-
- void NumericArrayLoader::LoadArray( lua_State *L, int StackIndex, std::vector< Uint8 >& RawData )
- {
- VALUE_TYPE ValueType;
- m_ValueTypeBinder.SetValue( L, StackIndex-1, &ValueType );
-
- auto it = m_ParseFuncJumpTbl.find( ValueType );
- if( it != m_ParseFuncJumpTbl.end() )
- {
- it->second( L, StackIndex, RawData );
- }
- else
- {
- SCRIPT_PARSING_ERROR( L, "No method to parse array of value VALUE_TYPE==", ValueType);
- }
- }
-
- // Special version of luaL_testudata() which takes an array of allowed metatables
- void *luaL_testudata( lua_State *L, int ud, const std::vector<String> &MetatableNames )
- {
- void *p = lua_touserdata( L, ud );
- if( p != nullptr )
- {
- // value is a userdata?
- if( lua_getmetatable( L, ud ) ) // -0 | +(0|1) -> +(0|1)
- {
- // does it have a metatable?
- bool bMatchingMTFound = false;
- for( auto mtname = MetatableNames.begin(); mtname != MetatableNames.end() && !bMatchingMTFound; ++mtname )
- {
- // get correct metatable
- luaL_getmetatable( L, mtname->c_str() ); // -0 | +1 -> +1
- if( lua_rawequal( L, -1, -2 ) ) // are the same?
- bMatchingMTFound = true;
-
- // pop correct metatable
- lua_pop( L, 1 ); // -1 | +0 -> -1
- }
- // pop user metatable
- lua_pop( L, 1 ); // -1 | +0 -> -1
- return bMatchingMTFound ? p : nullptr;
- }
- }
- return nullptr; // value is not a userdata with a metatable
- }
-}
diff --git a/RenderScript/src/LuaFunctionBinding.cpp b/RenderScript/src/LuaFunctionBinding.cpp
deleted file mode 100644
index b9a93be..0000000
--- a/RenderScript/src/LuaFunctionBinding.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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 "LuaFunctionBinding.h"
-#include "LuaBindings.h"
-
-namespace Diligent
-{
- void LuaFunctionCallerBase::PushFuncStub( lua_State *L, Bool Arg )
- {
- PushValue( L, Arg );
- }
-
- void LuaFunctionCallerBase::PushFuncStub( lua_State *L, Int32 Arg )
- {
- PushValue<double>( L, Arg );
- }
-
- void LuaFunctionCallerBase::PushFuncStub( lua_State *L, Uint32 Arg )
- {
- PushValue<double>( L, Arg );
- }
-
- void LuaFunctionCallerBase::PushFuncStub( lua_State *L, Int16 Arg )
- {
- PushValue<double>( L, Arg );
- }
-
- void LuaFunctionCallerBase::PushFuncStub( lua_State *L, Uint16 Arg )
- {
- PushValue<double>( L, Arg );
- }
-
- void LuaFunctionCallerBase::PushFuncStub( lua_State *L, Int8 Arg )
- {
- PushValue<double>( L, Arg );
- }
-
- void LuaFunctionCallerBase::PushFuncStub( lua_State *L, Uint8 Arg )
- {
- PushValue<double>( L, Arg );
- }
-
- void LuaFunctionCallerBase::PushFuncStub( lua_State *L, float Arg )
- {
- PushValue<double>( L, Arg );
- }
-
- void LuaFunctionCallerBase::PushFuncStub( lua_State *L, const Char *Arg )
- {
- PushValue( L, Arg );
- }
-
- void LuaFunctionCallerBase::PushFuncStub( lua_State *L, const String &Arg )
- {
- PushValue( L, Arg.c_str() );
- }
-
- void LuaFunctionCallerBase::Run_internal( int NumArgs, const Char *FuncName )
- {
- // http://www.lua.org/pil/25.2.html
-
- if( FuncName )
- {
- // Push onto the stack the value of the global name.
- lua_getglobal( m_LuaState, FuncName );
- // All arguments are now below the function, while we need to have
- // the function below all the arguments:
- lua_insert( m_LuaState, -NumArgs - 1 );
- }
- else
- {
- // If FuncName == 0, it is assumed that the chunk was previously loaded into the stack
- auto StackTop = lua_gettop( m_LuaState );
- if( StackTop < 1 )
- LOG_ERROR( "Lua stack is empty. Load Lua chunk before calling Run()" );
- }
- // do the call (NumArgs arguments, 0 results)
- // lua_pcall() pops the function and all its arguments from the stack and
- // pushes all the results (if any)
- // In case of errors, the error message is pushed onto the top of the stack
- if( lua_pcall( m_LuaState, NumArgs, 0, 0 ) != 0 )
- {
- auto ErrorMsg = lua_tostring( m_LuaState, -1 );
- LOG_ERROR_AND_THROW( "Failed to call function \"", FuncName ? FuncName : "<main chunk>", "\"\n"
- "The following error occured:\n", ErrorMsg );
- }
- }
-}
diff --git a/RenderScript/src/LuaWrappers.cpp b/RenderScript/src/LuaWrappers.cpp
deleted file mode 100644
index 504e2f7..0000000
--- a/RenderScript/src/LuaWrappers.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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 "LuaWrappers.h"
-
-namespace Diligent
-{
- LuaState::LuaState( Uint32 OpenLibFlags )
- {
- m_pLuaState = luaL_newstate();
- //luaL_openlibs( m_pLuaState );
-
- INIT_LUA_STACK_TRACKING( m_pLuaState );
- struct LuaStdLibInfo
- {
- const char *name;
- lua_CFunction func;
- Uint32 Flag;
- }LuaStdLibs[] =
- {
- { "_G", luaopen_base, LUA_LIB_BASE },
- { LUA_LOADLIBNAME, luaopen_package, LUA_LIB_PACKAGE },
- { LUA_COLIBNAME, luaopen_coroutine, LUA_LIB_COROUTINE },
- { LUA_TABLIBNAME, luaopen_table, LUA_LIB_TABLE },
- { LUA_IOLIBNAME, luaopen_io, LUA_LIB_IO },
- { LUA_OSLIBNAME, luaopen_os, LUA_LIB_OS },
- { LUA_STRLIBNAME, luaopen_string, LUA_LIB_STRING },
- { LUA_BITLIBNAME, luaopen_bit32, LUA_LIB_BIT32 },
- { LUA_MATHLIBNAME, luaopen_math, LUA_LIB_MATH },
- { LUA_DBLIBNAME, luaopen_debug, LUA_LIB_DEBUG },
- { nullptr, nullptr, 0 }
- };
-
- for( auto lib = LuaStdLibs; lib->func; lib++ )
- {
- if( OpenLibFlags & lib->Flag )
- {
- luaL_requiref( m_pLuaState, lib->name, lib->func, 1 ); // -0 | +1 -> +1
- lua_pop( m_pLuaState, 1 ); // -1 | +0 -> -1
- }
- }
-
- CHECK_LUA_STACK_HEIGHT();
- }
-
- LuaState::~LuaState()
- {
- Close();
- }
-
- void LuaState::Close()
- {
- if( m_pLuaState )
- lua_close( m_pLuaState );
- m_pLuaState = nullptr;
- }
-
- LuaState::operator lua_State *()
- {
- return m_pLuaState;
- }
-}
diff --git a/RenderScript/src/PSODescParser.cpp b/RenderScript/src/PSODescParser.cpp
deleted file mode 100644
index baa9c6c..0000000
--- a/RenderScript/src/PSODescParser.cpp
+++ /dev/null
@@ -1,671 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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"
-#include "SamplerParser.h"
-
-namespace Diligent
-{
- class ShaderVariableTypeEnumMapping : public EnumMapping < Diligent::SHADER_RESOURCE_VARIABLE_TYPE >
- {
- public:
- ShaderVariableTypeEnumMapping()
- {
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), SHADER_RESOURCE_VARIABLE_TYPE_STATIC );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE );
- DEFINE_ENUM_ELEMENT_MAPPING( (*this), SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC );
- }
- };
-
- class ShaderResourceVariableDescArrayParser;
- template<>
- class MemberBinder<ShaderResourceVariableDescArrayParser> : 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, ShaderResourceVariableDesc, Type, m_ShaderVarTypeEnumMapping );
- DEFINE_FLAGS_BINDER( m_Bindings, ShaderResourceVariableDesc, ShaderStages, SHADER_TYPE, m_ShaderTypeEnumMapping );
- }
-
- 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<ShaderResourceVariableDesc*>( pBasePointer, m_MemberOffset);
- const auto &NumVars = GetMemberByOffest<Uint32>( pBasePointer, m_NumVariablesOffset);
-
- PushLuaArray( L, VarDesc, VarDesc + NumVars, [&]( const ShaderResourceVariableDesc &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 )override
- {
- auto &ShaderVarDescBuffer = GetMemberByOffest<std::vector<ShaderResourceVariableDesc>>( 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( static_cast<int>(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<ShaderResourceVariableDesc*>( 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)
- {
- DEFINE_FLAGS_BINDER( m_Bindings, StaticSamplerDesc, ShaderStages, SHADER_TYPE, m_ShaderTypeEnumMapping );
- InitSamplerParserBindings<SamplerDesc>(m_SamDescBindings, 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 variable type. The function will leave the new table on top
- // of the stack
- PushLuaTable( L, &SamDesc, m_Bindings ); // 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_SamDescBindings ); // Stack: +3
- // Push the table from the top into the parent table
- lua_settable( L, -3 ); // Stack: +1
-
- // Push "SamplerOrTextureName" field
- lua_pushstring( L, "SamplerOrTextureName" ); // Stack: +2
- lua_pushstring( L, SamDesc.SamplerOrTextureName); // Stack: +3
- lua_settable( L, -3 ); // Stack: +1
- }
- );
- }
-
- virtual void SetValue( lua_State *L, int Index, void* pBasePointer )override
- {
- 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(static_cast<int>(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)
- {
- auto Binding = m_Bindings.find( Key );
- if( Binding != m_Bindings.end() )
- {
- Binding->second->SetValue( L, TblStackInd, __pBasePointer );
- }
- else 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_SamDescBindings.find( Key );
- if (Binding != m_SamDescBindings.end())
- {
- Binding->second->SetValue( L, TblStackInd, __pBasePointer );
- }
- else
- {
- SCRIPT_PARSING_ERROR( L, "Unknown Member \"", Key, '\"' );
- }
- }
- }
- );
- }
- else if (strcmp(Key, "SamplerOrTextureName") == 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].SamplerOrTextureName = 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;
- BindingsMapType m_SamDescBindings;
- EnumMapping<FILTER_TYPE> m_FilterTypeEnumMapping;
- EnumMapping<TEXTURE_ADDRESS_MODE> m_TexAddrModeEnumMapping;
- ComparisonFuncEnumMapping m_CmpFuncEnumMapping;
- ShaderTypeEnumMapping m_ShaderTypeEnumMapping;
-
- size_t m_NumStaticSamplersOffset;
- size_t m_StaticSamplersBufferOffset;
- size_t m_StaticSamplerTexNamesBufferOffset;
- };
-
-
- 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<Uint8>(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 )
- {
- using CountType = decltype(SampleDesc::Count);
- DEFINE_BINDER_EX( m_Bindings, SampleDesc, Count, CountType, Validator<CountType>("Count", 1,32) );
- using QualityType = decltype(SampleDesc::Quality);
- DEFINE_BINDER_EX( m_Bindings, SampleDesc, Quality, QualityType, Validator<QualityType>("Quality", 0,std::numeric_limits<QualityType>::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<PipelineResourceLayoutDesc> : public MemberBinderBase
- {
- public:
- MemberBinder( size_t MemberOffset, size_t VarDescBufferOffset, size_t VarNamesBufferOffset, size_t StaticSamplersBufferOffset, size_t StaticSamplerTexNamesBufferOffset ) :
- MemberBinderBase( MemberOffset )
- {
- DEFINE_ENUM_BINDER( m_Bindings, PipelineResourceLayoutDesc, DefaultVariableType, m_ShaderVarTypeEnumMapping );
-
- auto *pShaderDescBinder =
- new MemberBinder<ShaderResourceVariableDescArrayParser>(
- offsetof(PipelineResourceLayoutDesc, Variables),
- offsetof(PipelineResourceLayoutDesc, NumVariables),
- VarDescBufferOffset,
- VarNamesBufferOffset
- );
- m_Bindings.insert( std::make_pair( "Variables", std::unique_ptr<MemberBinderBase>(pShaderDescBinder) ) );
-
- auto *pStaticSamplerDescBinder =
- new MemberBinder<StaticSamplerDescArrayParser>(
- offsetof(PipelineResourceLayoutDesc, StaticSamplers),
- offsetof(PipelineResourceLayoutDesc, NumStaticSamplers),
- StaticSamplersBufferOffset,
- StaticSamplerTexNamesBufferOffset
- );
- m_Bindings.insert( std::make_pair( "StaticSamplers", std::unique_ptr<MemberBinderBase>(pStaticSamplerDescBinder) ) );
- }
-
- virtual void GetValue( lua_State *L, const void* pBasePointer )
- {
- const auto *pShaderDesc = &GetMemberByOffest<ShaderDesc>( pBasePointer, m_MemberOffset );
- PushLuaTable( L, pShaderDesc, m_Bindings );
- }
-
- virtual void SetValue( lua_State *L, int Index, void* pBasePointer )
- {
- auto *pShaderDesc = &GetMemberByOffest<ShaderDesc>(pBasePointer, m_MemberOffset);
- ParseLuaTable( L, Index, pShaderDesc, m_Bindings );
- }
-
- private:
- BindingsMapType m_Bindings;
- ShaderVariableTypeEnumMapping m_ShaderVarTypeEnumMapping;
- };
-
- template<>
- class MemberBinder<GraphicsPipelineDesc> : public MemberBinderBase
- {
- public:
- MemberBinder( size_t MemberOffset, size_t Dummy ) :
- MemberBinderBase( MemberOffset )
- {
- std::vector<String> AllowedMetatable = { "Metatables.Shader" };
-
- DEFINE_BINDER_EX( m_Bindings, GraphicsPipelineDesc, pVS, EngineObjectPtrLoader<IShader>, AllowedMetatable );
- DEFINE_BINDER_EX( m_Bindings, GraphicsPipelineDesc, pPS, EngineObjectPtrLoader<IShader>, AllowedMetatable );
- DEFINE_BINDER_EX( m_Bindings, GraphicsPipelineDesc, pDS, EngineObjectPtrLoader<IShader>, AllowedMetatable );
- DEFINE_BINDER_EX( m_Bindings, GraphicsPipelineDesc, pHS, EngineObjectPtrLoader<IShader>, AllowedMetatable );
- DEFINE_BINDER_EX( m_Bindings, GraphicsPipelineDesc, pGS, EngineObjectPtrLoader<IShader>, AllowedMetatable );
-
- //D3D12_STREAM_OUTPUT_DESC StreamOutput;
-
- DEFINE_BINDER_EX( m_Bindings, GraphicsPipelineDesc, BlendDesc, BlendStateDesc, 0 );
- DEFINE_BINDER( m_Bindings, GraphicsPipelineDesc, SampleMask );
- DEFINE_BINDER_EX( m_Bindings, GraphicsPipelineDesc, RasterizerDesc, RasterizerStateDesc, 0 );
- DEFINE_BINDER_EX( 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_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_TRIANGLE_LIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_POINT_LIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_LINE_LIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST );
- DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST );
- VERIFY( m_PrimTopologyEnumMapping.m_Str2ValMap.size() == PRIMITIVE_TOPOLOGY_NUM_TOPOLOGIES - 1,
- "Unexpected map size. Did you update PRIMITIVE_TOPOLOGY enum?" );
- VERIFY( m_PrimTopologyEnumMapping.m_Val2StrMap.size() == PRIMITIVE_TOPOLOGY_NUM_TOPOLOGIES - 1,
- "Unexpected map size. Did you update PRIMITIVE_TOPOLOGY enum?" );
- DEFINE_ENUM_BINDER( m_Bindings, GraphicsPipelineDesc, PrimitiveTopology, m_PrimTopologyEnumMapping);
-
- DEFINE_BINDER_EX( m_Bindings, GraphicsPipelineDesc, RTVFormats, RTVFormatsParser, 0 );
- DEFINE_ENUM_BINDER( m_Bindings, GraphicsPipelineDesc, DSVFormat, m_TexFmtEnumMapping );
-
- DEFINE_BINDER_EX( 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 > m_PrimTopologyEnumMapping;
- 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_EX( 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, const String& ResMappingMetatableName ) :
- EngineObjectParserCommon<IPipelineState>( pRenderDevice, L, PSODescLibName ),
- m_SetPSOBinding( this, L, "Context", "SetPipelineState", &PSODescParser::SetPSO ),
- m_IsCompatibleWithBinding(this, L, m_MetatableRegistryName.c_str(), "IsCompatibleWith", &PSODescParser::IsCompatibleWith),
- m_ResMappingMetatableName(ResMappingMetatableName),
- m_BindStaticResourcesBinding( this, L, m_MetatableRegistryName.c_str(), "BindStaticResources", &PSODescParser::BindStaticResources )
- {
- DEFINE_BUFFERED_STRING_BINDER( m_Bindings, PSODescWrapper, Name, NameBuffer )
-
- DEFINE_BINDER( m_Bindings, PSODescWrapper, IsComputePipeline );
- using SRBAllocationGranularityType = decltype(PSODescWrapper::SRBAllocationGranularity);
- Validator<SRBAllocationGranularityType> SRBValidator("SRBAllocationGranularity", 1, 65536);
- DEFINE_BINDER_EX( m_Bindings, PSODescWrapper, SRBAllocationGranularity, SRBAllocationGranularityType, SRBValidator);
-
- auto *pShaderDescBinder =
- new MemberBinder<PipelineResourceLayoutDesc>(
- offsetof(PSODescWrapper, ResourceLayout),
- offsetof(PSODescWrapper, m_VarDescBuffer) - offsetof(PSODescWrapper, ResourceLayout),
- offsetof(PSODescWrapper, m_VarNamesBuffer) - offsetof(PSODescWrapper, ResourceLayout),
- offsetof(PSODescWrapper, m_StaticSamplersBuffer) - offsetof(PSODescWrapper, ResourceLayout),
- offsetof(PSODescWrapper, m_StaticSamplerTexNamesBuffer) - offsetof(PSODescWrapper, ResourceLayout)
- );
- m_Bindings.insert( std::make_pair( "ResourceLayout", std::unique_ptr<MemberBinderBase>(pShaderDescBinder) ) );
-
- DEFINE_BINDER_EX( m_Bindings, PSODescWrapper, GraphicsPipeline, GraphicsPipelineDesc, 0 );
- DEFINE_BINDER_EX( 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;
- }
-
- int PSODescParser::IsCompatibleWith(lua_State *L)
- {
- INIT_LUA_STACK_TRACKING(L);
-
- auto *pThisPSO = *GetUserData<IPipelineState**>(L, 1, m_MetatableRegistryName.c_str());
-
- // Buffer should be the first argument
- auto *pPSO = *GetUserData<IPipelineState**>(L, 2, m_MetatableRegistryName.c_str());
-
- auto IsCompatible = pThisPSO->IsCompatibleWith(pPSO);
-
- // Push existing object
- PushValue(L, IsCompatible);
-
- // Returning one value to Lua
- return 1;
- }
-
- int PSODescParser::BindStaticResources( 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
- // from Lua in its PRIVATE stack in direct order( the first argument is pushed first ).So, when the
- // function starts, lua_gettop( L ) returns the number of arguments received by the function.The first
- // argument( if any ) is at index 1 and its last argument is at index lua_gettop( L ).
- // To return values to Lua, a C function just pushes them onto the stack, in direct order
- // ( the first result is pushed first ), and returns the number of results.
- // 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.
-
- 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 *pPSO = *GetUserData<IPipelineState**>( L, ArgStackInd, m_MetatableRegistryName.c_str() );
- VERIFY( pPSO, "PSO pointer is null" );
- if( !pPSO )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 );
- }
-
-
- pPSO->BindStaticResources( ShaderFlags, pResourceMapping, Flags );
- }
- catch( const std::runtime_error& )
- {
-
- }
-
- return 0;
- }
-}
diff --git a/RenderScript/src/ParsingErrors.cpp b/RenderScript/src/ParsingErrors.cpp
deleted file mode 100644
index bf34b9a..0000000
--- a/RenderScript/src/ParsingErrors.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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 "ParsingErrors.h"
-
-static Diligent::String FindSourceLine( const char *pSource, int LineNumber )
-{
- const char *pLineStart = pSource;
- for( int CurrLine = 1; CurrLine < LineNumber; ++CurrLine )
- {
- pLineStart = strchr( pLineStart, '\n' );
- if( !pLineStart )
- break;
- ++pLineStart;
- }
-
- Diligent::String Line;
- if( pLineStart )
- {
- for( ; *pLineStart != '\n' && *pLineStart != 0; ++pLineStart )
- Line += *pLineStart;
- }
- return Line;
-}
-
-void LuaDebugInformation( lua_State *L, std::stringstream &ss )
-{
- // Trace the Lua stack
- ss << "Lua stack:\n";
-
- Diligent::String FailureLine;
- //String ShortSource;
-
- lua_Debug info;
- int level = 0;
- //int FailureLineNum = -1;
- // lua_getstack() retrieves information about the interpreter runtime stack.
- // This function fills parts of a lua_Debug structure that is required to call lua_getinfo()
- // Level 0 is the current running function, whereas level n+1 is the function that has called
- // level n (except for tail calls, which do not count on the stack). When there are no errors,
- // lua_getstack returns 1; when called with a level greater than the stack depth, it returns 0.
- while( lua_getstack( L, level, &info ) )
- {
- // Get current stack level info
-
- // 'n': fills in the field name and namewhat;
- // 'S': fills in the fields source, short_src, linedefined, lastlinedefined, and what;
- // 'l': fills in the field currentline;
- // 't': fills in the field istailcall;
- // 'u': fills in the fields nups, nparams, and isvararg;
- // 'f': pushes onto the stack the function that is running at the given level;
- // 'L': pushes onto the stack a table whose indices are the numbers of the lines that are valid
- // on the function. (A valid line is a line with some associated code, that is, a line where
- // you can put a break point.Non - valid lines include empty lines and comments.)
- lua_getinfo( L, "nSl", &info );
- ss << (info.name ? info.name : "") << '<' << (info.what ? info.what : "") << "> Line " << info.currentline << '\n';
- if( info.currentline >= 0 && FailureLine.length() == 0 )
- {
- //ShortSource = info.short_src;
- FailureLine = FindSourceLine( info.source, info.currentline );
- //FailureLineNum = info.currentline;
- }
- ++level;
- }
- ss << "Failure line:\n" << FailureLine;// << "\nLocation:\n" << ShortSource << ':' << FailureLineNum;
-}
diff --git a/RenderScript/src/RasterizerStateDescParser.cpp b/RenderScript/src/RasterizerStateDescParser.cpp
deleted file mode 100644
index 233f853..0000000
--- a/RenderScript/src/RasterizerStateDescParser.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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, 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, m_CullModeEnumMapping );
-
- DEFINE_BINDER( m_Bindings, RasterizerStateDesc, FrontCounterClockwise );
- DEFINE_BINDER( m_Bindings, RasterizerStateDesc, DepthBias );
- DEFINE_BINDER( m_Bindings, RasterizerStateDesc, DepthBiasClamp );
- DEFINE_BINDER( m_Bindings, RasterizerStateDesc, SlopeScaledDepthBias );
- DEFINE_BINDER( m_Bindings, RasterizerStateDesc, DepthClipEnable );
- DEFINE_BINDER( m_Bindings, RasterizerStateDesc, ScissorEnable );
- DEFINE_BINDER( m_Bindings, RasterizerStateDesc, AntialiasedLineEnable );
- };
-
- 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/ResourceMappingParser.cpp b/RenderScript/src/ResourceMappingParser.cpp
deleted file mode 100644
index f5e833b..0000000
--- a/RenderScript/src/ResourceMappingParser.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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 "ResourceMappingParser.h"
-#include "TextureViewParser.h"
-#include "BufferParser.h"
-#include "BufferViewParser.h"
-
-namespace Diligent
-{
- const Char* ResourceMappingParser::ResourceMappingLibName = "ResourceMapping";
-
- ResourceMappingParser::ResourceMappingParser( IRenderDevice *pRenderDevice, lua_State *L,
- TextureViewParser *pTexViewParser,
- BufferParser *pBuffParser,
- BufferViewParser *pBuffViewParser ) :
- EngineObjectParserBase( pRenderDevice, L, ResourceMappingLibName),
- m_pTexViewParser( pTexViewParser ),
- m_pBuffParser( pBuffParser ),
- m_pBuffViewParser( pBuffViewParser ),
- m_MappedResourceMetatables( { pTexViewParser->GetMetatableName(), pBuffParser->GetMetatableName(), pBuffViewParser->GetMetatableName() } )
- {
- DEFINE_BINDER_EX( m_Bindings, ResourceMappingEntry, Name, const Char*, SkipValidationFunc<const Char*> );
- DEFINE_BINDER_EX( m_Bindings, ResourceMappingEntry, pObject, EngineObjectPtrLoader<IDeviceObject>, m_MappedResourceMetatables );
- };
-
- void ResourceMappingParser::CreateObj( lua_State *L )
- {
- std::vector<ResourceMappingEntry> Entries;
-
- ParseLuaArray( L, 1, &Entries, [ &]( void* pBasePointer, int StackIndex, int NewArrayIndex )
- {
- VERIFY( pBasePointer == &Entries, "Sanity check failed" );
- auto CurrIndex = Entries.size();
- if( static_cast<int>(CurrIndex) != NewArrayIndex - 1 )
- SCRIPT_PARSING_ERROR( L, "Explicit array indices are not allowed in resource mapping description. Provided index ", NewArrayIndex - 1, " conflicts with actual index ", CurrIndex, "." );
- Entries.resize( CurrIndex + 1 );
- ParseLuaTable( L, StackIndex, &(Entries)[CurrIndex], m_Bindings );
- }
- );
-
- Entries.push_back( ResourceMappingEntry() );
-
- // Note that ResourceMappingEntry.Name is declared as const Char*, not as String.
- // This is not a problem as Lua guarantees that all pointers to string values
- // remain valid as long as these strings are not popped from the stack
- ResourceMappingDesc ResourceMappingDesc;
- ResourceMappingDesc.pEntries = Entries.data();
-
- IResourceMapping **ppResourceMapping = reinterpret_cast<IResourceMapping**>( lua_newuserdata( L, sizeof( IResourceMapping* ) ) );
- *ppResourceMapping = nullptr;
- m_pRenderDevice->CreateResourceMapping( ResourceMappingDesc, ppResourceMapping );
- if( *ppResourceMapping == nullptr )
- SCRIPT_PARSING_ERROR(L, "Failed to create resource mapping")
- }
-
- void ResourceMappingParser::DestroyObj( void *pData )
- {
- if( pData != nullptr )
- {
- auto ppObject = reinterpret_cast<IResourceMapping**>(pData);
- if( *ppObject != nullptr )
- (*ppObject)->Release();
- }
- }
-
- void ResourceMappingParser::ReadField( lua_State *L, void *pData, const Char *Field )
- {
- auto *pResourceMapping = *reinterpret_cast<IResourceMapping**>(pData);
- Diligent::RefCntAutoPtr<IDeviceObject> pResource;
- pResourceMapping->GetResource( Field, &pResource );
- Diligent::RefCntAutoPtr<IObject> pTextureView;
- Diligent::RefCntAutoPtr<IObject> pBuffer;
- if( pResource )
- {
- pResource->QueryInterface( IID_TextureView, &pTextureView );
- if( pTextureView )
- {
- m_pTexViewParser->PushObject(L, pTextureView);
- }
-
- if( !pTextureView )
- {
- pResource->QueryInterface( IID_Buffer, &pBuffer );
- if( pBuffer )
- {
- m_pBuffParser->PushObject( L, pBuffer );
- }
- }
- }
-
- if( !(pTextureView || pBuffer) )
- {
- lua_pushnil( L ); // -0 | +1 -> +1
- }
- }
-
- void ResourceMappingParser::UpdateField( lua_State *L, void *pData, const Char *Field )
- {
- auto *pResourceMapping = *reinterpret_cast<IResourceMapping**>(pData);
- if( lua_type( L, 3 ) == LUA_TNIL )
- {
- pResourceMapping->RemoveResourceByName( Field );
- }
- else
- {
- auto pResource = *GetUserData<IDeviceObject**>( L, 3, m_MappedResourceMetatables );
- pResourceMapping->AddResource( Field, pResource, false );
- }
- }
-
- void ResourceMappingParser::GetObjectByName( lua_State *L, const Char *ShaderName, IResourceMapping** ppObject )
- {
- auto pObject = *GetGlobalObject<IResourceMapping**>( L, ShaderName, m_MetatableRegistryName.c_str() );
- *ppObject = pObject;
- pObject->AddRef();
- }
-
- void ResourceMappingParser::PushExistingObject( lua_State *L, const void *pObject )
- {
- auto ppObject = reinterpret_cast<IResourceMapping**>(lua_newuserdata( L, sizeof( IResourceMapping* ) ));
- *ppObject = reinterpret_cast<IResourceMapping*>(const_cast<void*>(pObject));
- (*ppObject)->AddRef();
- }
-}
diff --git a/RenderScript/src/SamplerParser.cpp b/RenderScript/src/SamplerParser.cpp
deleted file mode 100644
index 0e6be91..0000000
--- a/RenderScript/src/SamplerParser.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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 "SamplerParser.h"
-
-namespace Diligent
-{
- const Char* SamplerParser::SamplerLibName = "Sampler";
-
- SamplerParser::SamplerParser( IRenderDevice *pRenderDevice, lua_State *L ) :
- EngineObjectParserCommon<ISampler>( pRenderDevice, L, SamplerLibName )
- {
- DEFINE_BUFFERED_STRING_BINDER( m_Bindings, SSamDescWrapper, Name, NameBuffer )
-
- InitSamplerParserBindings<SSamDescWrapper>(m_Bindings, m_FilterTypeEnumMapping, m_TexAddrModeEnumMapping, m_CmpFuncEnumMapping);
- };
-
- void SamplerParser::CreateObj( lua_State *L )
- {
- INIT_LUA_STACK_TRACKING( L );
-
- SSamDescWrapper SamplerDesc;
- ParseLuaTable( L, -1, &SamplerDesc, m_Bindings );
-
- CHECK_LUA_STACK_HEIGHT();
-
- auto ppSampler = reinterpret_cast<ISampler**>(lua_newuserdata( L, sizeof( ISampler* ) ));
- *ppSampler = nullptr;
- m_pRenderDevice->CreateSampler( SamplerDesc, ppSampler );
- if( *ppSampler == nullptr )
- SCRIPT_PARSING_ERROR(L, "Failed to create a sampler")
-
- CHECK_LUA_STACK_HEIGHT( +1 );
- }
-}
diff --git a/RenderScript/src/ScissorRectParser.cpp b/RenderScript/src/ScissorRectParser.cpp
deleted file mode 100644
index 37db1ee..0000000
--- a/RenderScript/src/ScissorRectParser.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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 "ScissorRectParser.h"
-
-namespace Diligent
-{
- const Char* ScissorRectParser::ScissorRectLibName = "ScissorRect";
-
- ScissorRectParser::ScissorRectParser( IRenderDevice *pRenderDevice, lua_State *L ) :
- EngineObjectParserBase( pRenderDevice, L, ScissorRectLibName ),
- m_SetScissorRectsBinding( this, L, "Context", "SetScissorRects", &ScissorRectParser::SetScissorRects )
- {
- m_ScissorRects.reserve( 8 );
-
- // NumVertices and NumIndices are in Union
- DEFINE_BINDER( m_Bindings, Rect, left );
- DEFINE_BINDER( m_Bindings, Rect, top );
- DEFINE_BINDER( m_Bindings, Rect, right );
- DEFINE_BINDER( m_Bindings, Rect, bottom );
- };
-
- void ScissorRectParser::CreateObj( lua_State *L )
- {
- INIT_LUA_STACK_TRACKING(L);
-
- Rect ScissorRect;
- ParseLuaTable( L, 1, &ScissorRect, m_Bindings );
- if( ScissorRect.left > ScissorRect.right )
- SCRIPT_PARSING_ERROR(L, "Scissor rect left and right boundaries (", ScissorRect.left, ", ", ScissorRect.right, ") are incorrect")
- if( ScissorRect.top > ScissorRect.bottom )
- SCRIPT_PARSING_ERROR(L, "Scissor rect top and bottom boundaries (", ScissorRect.top, ", ", ScissorRect.bottom, ") are incorrect")
-
- CHECK_LUA_STACK_HEIGHT();
-
- auto pScissorRect = reinterpret_cast<Rect*>(lua_newuserdata( L, sizeof( Rect ) ));
- memcpy(pScissorRect, &ScissorRect, sizeof(ScissorRect));
-
- CHECK_LUA_STACK_HEIGHT( +1 );
- }
-
- void ScissorRectParser::DestroyObj( void *pData )
- {
- // We do not need to do anything, because the whole object is
- // created as full user data and thus managed by Lua
- }
-
- void ScissorRectParser::ReadField( lua_State *L, void *pData, const Char *Field )
- {
- auto pScissorRect = reinterpret_cast<Rect*>(pData);
- PushField( L, pScissorRect, Field, m_Bindings );
- }
-
- void ScissorRectParser::UpdateField( lua_State *L, void *pData, const Char *Field )
- {
- auto pScissorRect = reinterpret_cast<Rect*>(pData);
- Diligent::UpdateField( L, -1, pScissorRect, Field, m_Bindings );
- }
-
- void ScissorRectParser::PushExistingObject( lua_State *L, const void *pObject )
- {
- auto pScissorRect = reinterpret_cast<Rect*>(lua_newuserdata( L, sizeof( Rect ) ));
- memcpy( pScissorRect, pObject, sizeof( Rect ) );
- }
-
- int ScissorRectParser::SetScissorRects( lua_State *L )
- {
- auto NumArgs = lua_gettop( L );
- Uint32 RTWidth = 0;
- Uint32 RTHeight = 0;
- m_ScissorRects.clear();
- for( int Arg = 1; Arg <= NumArgs; ++Arg )
- {
- if( lua_type( L, Arg ) == LUA_TUSERDATA )
- {
- auto pScissorRect = GetUserData<Rect*>( L, Arg, m_MetatableRegistryName.c_str() );
- m_ScissorRects.emplace_back( *pScissorRect );
- }
- else
- {
- if( RTWidth == 0 )
- RTWidth = ReadValueFromLua<Uint32>( L, Arg );
- else if( RTHeight == 0 )
- RTHeight = ReadValueFromLua<Uint32>( L, Arg );
- else
- SCRIPT_PARSING_ERROR( L, "Render target size already specified (", RTWidth, "x", RTHeight, ")." );
- }
- }
-
- if( (RTWidth == 0 && RTHeight != 0) || (RTWidth != 0 && RTHeight == 0) )
- SCRIPT_PARSING_ERROR( L, "Render target size is incomplete (", RTWidth, "x", RTHeight, "). Use either 0x0 or fully specified size" );
-
- Uint32 NumScissorRects = static_cast<Uint32>( m_ScissorRects.size() );
-
- if( NumScissorRects == 0 )
- SCRIPT_PARSING_ERROR( L, "At least one viewport must be specified" );
-
- auto *pContext = LoadDeviceContextFromRegistry( L );
- pContext->SetScissorRects( NumScissorRects, m_ScissorRects.data(), RTWidth, RTHeight );
-
- return 0;
- }
-}
diff --git a/RenderScript/src/ScriptParser.cpp b/RenderScript/src/ScriptParser.cpp
deleted file mode 100644
index 7862303..0000000
--- a/RenderScript/src/ScriptParser.cpp
+++ /dev/null
@@ -1,277 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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 "ScriptParser.h"
-#include "LuaBindings.h"
-#include "SamplerParser.h"
-#include "ShaderParser.h"
-#include "BufferParser.h"
-#include "TextureParser.h"
-#include "DrawAttribsParser.h"
-#include "FileSystem.h"
-#include "ResourceMappingParser.h"
-#include "TextureViewParser.h"
-#include "BufferViewParser.h"
-#include "PSODescParser.h"
-#include "DeviceContextFuncBindings.h"
-#include "ViewportParser.h"
-#include "ScissorRectParser.h"
-#include "ShaderVariableParser.h"
-#include "ShaderResourceBindingParser.h"
-
-namespace Diligent
-{
- const Char* ScriptParser::DeviceContextRegistryKey = "DeviceContext";
-
-#define IMPLEMENT_PUSH_FUNC_STUBS(ObjectType, ParserName) \
- void ScriptParser::SpecialPushFuncs::PushFuncStub( lua_State *L, const ObjectType* pObject) \
- { \
- m_pScriptParser->ParserName->PushObject( L, pObject ); \
- } \
- \
- void ScriptParser::SpecialPushFuncs::PushFuncStub( lua_State *L, const RefCntAutoPtr<ObjectType> &pObject ) \
- { \
- PushFuncStub( L, pObject.RawPtr() ); \
- }
-
- IMPLEMENT_PUSH_FUNC_STUBS( ISampler, m_pSamplerParser)
- 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( IPipelineState, m_pPSOParser )
- IMPLEMENT_PUSH_FUNC_STUBS( IShaderResourceVariable, m_pShaderVariableParser )
- IMPLEMENT_PUSH_FUNC_STUBS( IShaderResourceBinding, m_pShaderResBindingParser )
-
-
- void ScriptParser::SpecialPushFuncs::PushFuncStub( lua_State *L, const CombinedDrawAttribs &CombinedAttribs )
- {
- m_pScriptParser->m_pDrawAttribsParser->PushObject( L, &CombinedAttribs );
- }
-
- void ScriptParser::SpecialPushFuncs::PushFuncStub( lua_State *L, const DrawAttribs &Attribs )
- {
- CombinedDrawAttribs CombinedAttribs;
- CombinedAttribs.FirstInstanceLocation = Attribs.FirstInstanceLocation;
- CombinedAttribs.Flags = Attribs.Flags;
- CombinedAttribs.NumInstances = Attribs.NumInstances;
- CombinedAttribs.NumVertices = Attribs.NumVertices;
- CombinedAttribs.StartVertexLocation = Attribs.StartVertexLocation;
- PushFuncStub( L, CombinedAttribs );
- }
-
- void ScriptParser::SpecialPushFuncs::PushFuncStub( lua_State *L, const DrawIndexedAttribs &Attribs )
- {
- CombinedDrawAttribs CombinedAttribs;
- CombinedAttribs.BaseVertex = Attribs.BaseVertex;
- CombinedAttribs.FirstIndexLocation = Attribs.FirstIndexLocation;
- CombinedAttribs.FirstInstanceLocation = Attribs.FirstInstanceLocation;
- CombinedAttribs.Flags = Attribs.Flags;
- CombinedAttribs.IndexType = Attribs.IndexType;
- CombinedAttribs.NumIndices = Attribs.NumIndices;
- CombinedAttribs.NumInstances = Attribs.NumInstances;
- PushFuncStub( L, CombinedAttribs );
- }
-
- void ScriptParser::SpecialPushFuncs::PushFuncStub( lua_State *L, const Viewport &Viewport )
- {
- m_pScriptParser->m_pViewportParser->PushObject( L, &Viewport );
- }
-
- void ScriptParser::SpecialPushFuncs::PushFuncStub( lua_State *L, const Rect &Rect )
- {
- m_pScriptParser->m_pScissorRectParser->PushObject( L, &Rect );
- }
-
- ScriptParser::ScriptParser( IReferenceCounters *pRefCounters, IRenderDevice *pRenderDevice ) :
- TBase(pRefCounters),
- m_pRenderDevice( pRenderDevice ),
- m_LuaState( LuaState::LUA_LIB_BASE | LuaState::LUA_LIB_COROUTINE | LuaState::LUA_LIB_TABLE |
- LuaState::LUA_LIB_STRING | LuaState::LUA_LIB_BIT32 | LuaState::LUA_LIB_MATH )
- {
- // Run's ctor is called BEFORE the m_LuaState's ctor
- // We need to explicitly init the object:
- m_RunFunctionCaller.SetLuaState( m_LuaState );
- m_RunFunctionCaller.SetScriptParser( this );
-
- // We need to define global constants before initializing parsers
- DefineGlobalConstants(m_LuaState);
-
- m_pSamplerParser.reset( new SamplerParser( 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 ) );
- // Texture view parser must be create AFTER texture parser, because it
- // registers CreateView function in Metatables.Texture table
- m_pTextureViewParser.reset( new TextureViewParser( m_pTextureParser.get(), m_pSamplerParser.get(), pRenderDevice, m_LuaState ) );
- 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_pPSOParser.reset( new PSODescParser( pRenderDevice, m_LuaState, m_pResourceMappingParser->GetMetatableName() ) );
- 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_pPSOParser->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()
- {
- // It is essentially important to close Lua first, because we need to release
- // all user data
- m_LuaState.Close();
- }
-
- void ScriptParser::DefineGlobalConstants( lua_State *L )
- {
- INIT_LUA_STACK_TRACKING( L );
-
- // Create a new empty table and push it onto the stack
- lua_newtable( L ); // -0 | +1 -> +1
-
- const auto &DeviceCaps = m_pRenderDevice->GetDeviceCaps();
- const Char *pDeviceStr = nullptr;
- switch(DeviceCaps.DevType)
- {
- case DeviceType::OpenGL:
- pDeviceStr = "OpenGL";
- break;
-
- case DeviceType::OpenGLES:
- pDeviceStr = "OpenGLES";
- break;
-
- case DeviceType::D3D11:
- pDeviceStr = "D3D11";
- break;
-
- case DeviceType::D3D12:
- pDeviceStr = "D3D12";
- break;
-
- case DeviceType::Vulkan:
- pDeviceStr = "Vulkan";
- break;
-
- default:
- UNEXPECTED( "Unknown device type" );
- }
- SetTableField( L, "DeviceType", -1, pDeviceStr ); // -0 | +0 -> 0
-
- // lua_setglobal() pops a value from the stack and sets it as the new value of global name.
- lua_setglobal( L, "Constants" ); // -1 | +0 -> -1
-
- CHECK_LUA_STACK_HEIGHT();
-
- lua_newtable( L ); // -0 | +1 -> +1
- lua_setglobal( L, "Context" ); // -1 | +0 -> -1
-
- CHECK_LUA_STACK_HEIGHT();
- }
-
- // Every C-function called by Lua sees only its own private stack, with its first argument at index 1
- // Return the number of results pushed onto the stack
-
- void ScriptParser::Parse( const Char *pScript )
- {
- // Load the chunck and push it onto the top of the stack.
- // In case of errors, the error message is pushed onto the top of the stack
- if( luaL_loadstring( m_LuaState, pScript ) )
- {
- // Get the error message from the top of the stack
-
- // NOTE: the lua_tostring function returns a pointer to an internal copy of the string.
- // The string is always zero-terminated and Lua ensures that this pointer is valid as long
- // as the corresponding value is in the stack.
- auto ErrorMsg = lua_tostring( m_LuaState, -1 );
- lua_pop(m_LuaState, 1); // pop error message from the stack
-
- if( ErrorMsg )
- {
- LOG_ERROR_AND_THROW( "Failed to parse the script file:\n", ErrorMsg );
- }
- else
- {
- LOG_ERROR_AND_THROW( "Failed to parse the script file." );
- }
- }
- }
-
- void ScriptParser::GetSamplerByName( const Char *SamplerName, ISampler** ppSampler )
- {
- m_pSamplerParser->GetObjectByName( m_LuaState, SamplerName, ppSampler );
- }
-
- void ScriptParser::GetShaderByName( const Char *ShaderName, IShader** ppShader )
- {
- m_pShaderParser->GetObjectByName( m_LuaState, ShaderName, ppShader );
- }
-
- void ScriptParser::GetBufferByName( const Char *BufferName, IBuffer** ppBuffer )
- {
- m_pBufferParser->GetObjectByName( m_LuaState, BufferName, ppBuffer );
- }
-
- void ScriptParser::GetTextureByName( const Char *TextureName, ITexture** ppTexture )
- {
- m_pTextureParser->GetObjectByName( m_LuaState, TextureName, ppTexture );
- }
-
- void ScriptParser::GetResourceMappingByName( const Char *ResourceMappingName, IResourceMapping** ppResourceMapping )
- {
- m_pResourceMappingParser->GetObjectByName( m_LuaState, ResourceMappingName, ppResourceMapping );
- }
-
- void ScriptParser::GetTextureViewByName( const Char *TextureViewName, ITextureView** ppTextureView )
- {
- m_pTextureViewParser->GetObjectByName( m_LuaState, TextureViewName, ppTextureView );
- }
-
- void ScriptParser::GetBufferViewByName( const Char *BufferViewName, IBufferView** ppBufferView )
- {
- m_pBufferViewParser->GetObjectByName( m_LuaState, BufferViewName, ppBufferView );
- }
-
- void ScriptParser::GetPipelineStateByName( const Char *PSOName, IPipelineState** ppPSO )
- {
- m_pPSOParser->GetObjectByName( m_LuaState, PSOName, ppPSO );
- }
-
- void ScriptParser::GetShaderVariableByName( const Char *ShaderVarName, IShaderResourceVariable** ppShaderVar )
- {
- m_pShaderVariableParser->GetObjectByName( m_LuaState, ShaderVarName, ppShaderVar );
- }
-
- void ScriptParser::GetShaderResourceBindingByName( const Char *SRBName, IShaderResourceBinding** ppSRB )
- {
- m_pShaderResBindingParser->GetObjectByName( m_LuaState, SRBName, ppSRB );
- }
-
- void ScriptParser::QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface )
- {
- UNSUPPORTED( "Not implemented" );
- }
-}
diff --git a/RenderScript/src/ShaderParser.cpp b/RenderScript/src/ShaderParser.cpp
deleted file mode 100644
index 153fb1e..0000000
--- a/RenderScript/src/ShaderParser.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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 "ShaderParser.h"
-
-namespace Diligent
-{
- const Char* ShaderParser::ShaderLibName = "Shader";
-
- class ShaderDescLoader;
-
- template<>
- class MemberBinder<ShaderDescLoader> : public MemberBinderBase
- {
- public:
- MemberBinder( size_t MemberOffset ) :
- MemberBinderBase( MemberOffset )
- {
- auto *pNameBinder = new BufferedStringBinder( offsetof( ShaderDesc, Name ),
- // This is a small hack: we need to compute an offset from the beginning of ShaderDesc structure to
- // the NameBuffer member of ShaderCreateInfoWrapper:
- offsetof( ShaderParser::ShaderCreateInfoWrapper, NameBuffer ) - offsetof( ShaderParser::ShaderCreateInfoWrapper, Desc.Name ) );
- // No need to make a copy of Name since it is constant and HashMapStringKey will simply
- // keep pointer to it
- m_Bindings.insert( std::make_pair( "Name", std::unique_ptr<MemberBinderBase>(pNameBinder) ) );
-
- DEFINE_ENUM_BINDER( m_Bindings, ShaderDesc, ShaderType, m_ShaderTypeEnumMapping );
- }
-
- virtual void GetValue( lua_State *L, const void* pBasePointer )
- {
- const auto *pShaderDesc = &GetMemberByOffest<ShaderDesc>( pBasePointer, m_MemberOffset );
- PushLuaTable( L, pShaderDesc, m_Bindings );
- }
-
- virtual void SetValue( lua_State *L, int Index, void* pBasePointer )
- {
- auto *pShaderDesc = &GetMemberByOffest<ShaderDesc>(pBasePointer, m_MemberOffset);
- ParseLuaTable( L, Index, pShaderDesc, m_Bindings );
- }
-
- private:
- BindingsMapType m_Bindings;
- ShaderTypeEnumMapping m_ShaderTypeEnumMapping;
- };
-
- ShaderParser::ShaderParser( IRenderDevice *pRenderDevice, lua_State *L) :
- EngineObjectParserCommon<IShader>( pRenderDevice, L, ShaderLibName )
- {
- DEFINE_BUFFERED_STRING_BINDER( m_Bindings, ShaderCreateInfoWrapper, FilePath, FilePathBuffer )
- DEFINE_BUFFERED_STRING_BINDER( m_Bindings, ShaderCreateInfoWrapper, Source, SourceBuffer )
- DEFINE_BUFFERED_STRING_BINDER( m_Bindings, ShaderCreateInfoWrapper, EntryPoint, EntryPointBuffer )
- DEFINE_BUFFERED_STRING_BINDER( m_Bindings, ShaderCreateInfoWrapper, SearchDirectories, SearchDirectoriesBuffer )
- DEFINE_BUFFERED_STRING_BINDER( m_Bindings, ShaderCreateInfoWrapper, CombinedSamplerSuffix, CombinedSamplerSuffixBuffer )
-
- DEFINE_BINDER(m_Bindings, ShaderCreateInfoWrapper, UseCombinedTextureSamplers);
-
- DEFINE_ENUM_ELEMENT_MAPPING( m_ShaderSourceLangEnumMapping, SHADER_SOURCE_LANGUAGE_DEFAULT );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ShaderSourceLangEnumMapping, SHADER_SOURCE_LANGUAGE_HLSL );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ShaderSourceLangEnumMapping, SHADER_SOURCE_LANGUAGE_GLSL );
- DEFINE_ENUM_BINDER( m_Bindings, ShaderCreateInfoWrapper, SourceLanguage, m_ShaderSourceLangEnumMapping );
-
- auto *pShaderDescBinder =
- new MemberBinder<ShaderDescLoader>(
- offsetof(ShaderCreateInfoWrapper, Desc)
- );
- m_Bindings.insert( std::make_pair( "Desc", std::unique_ptr<MemberBinderBase>(pShaderDescBinder) ) );
- };
-
- void ShaderParser::CreateObj( lua_State *L )
- {
- INIT_LUA_STACK_TRACKING( L );
-
- ShaderCreateInfoWrapper ShaderCreationAttrs;
- ParseLuaTable( L, -1, &ShaderCreationAttrs, m_Bindings );
-
- RefCntAutoPtr<IShaderSourceInputStreamFactory> pShaderSourceFactory;
- m_pRenderDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory(ShaderCreationAttrs.SearchDirectories, &pShaderSourceFactory);
- ShaderCreationAttrs.pShaderSourceStreamFactory = pShaderSourceFactory;
-
- CHECK_LUA_STACK_HEIGHT();
-
- IShader **ppShader = reinterpret_cast<IShader**>( lua_newuserdata( L, sizeof( IShader* ) ) );
- *ppShader = nullptr;
- m_pRenderDevice->CreateShader( ShaderCreationAttrs, ppShader );
- if( *ppShader == nullptr )
- SCRIPT_PARSING_ERROR(L, "Failed to create a shader")
-
- CHECK_LUA_STACK_HEIGHT( +1 );
- }
-
- void ShaderParser::ReadField( lua_State *L, void *pData, const Char *Field )
- {
- ShaderCreateInfoWrapper ShaderCreationAttrs;
- auto *ppShader = reinterpret_cast<IShader**>(pData);
- ShaderCreationAttrs.Desc = (*ppShader)->GetDesc();
- PushField( L, &ShaderCreationAttrs, Field, m_Bindings );
- }
-}
diff --git a/RenderScript/src/ShaderResourceBindingParser.cpp b/RenderScript/src/ShaderResourceBindingParser.cpp
deleted file mode 100644
index d4b5323..0000000
--- a/RenderScript/src/ShaderResourceBindingParser.cpp
+++ /dev/null
@@ -1,226 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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 ) :
- EngineObjectParserBase( pRenderDevice, L, ShaderResourceBindingLibName ),
- m_PSOLibMetatableName(PSOLibMetatableName),
- m_ResMappingMetatableName(ResMappingMetatableName),
- m_ShaderVarMetatableRegistryName(ShaderVarMetatableRegistryName),
- m_BindResourcesBinding( this, L, m_MetatableRegistryName.c_str(), "BindResources", &ShaderResourceBindingParser::BindResources ),
- m_GetVariableByNameBinding( this, L, m_MetatableRegistryName.c_str(), "GetVariableByName", &ShaderResourceBindingParser::GetVariable ),
- m_GetVariableByIndexBinding( this, L, m_MetatableRegistryName.c_str(), "GetVariableByIndex", &ShaderResourceBindingParser::GetVariable ),
- m_CreateShaderResourceBinding( this, L, PSOLibMetatableName.c_str(), "CreateShaderResourceBinding", &ShaderResourceBindingParser::CreateShaderResourceBinding ),
- m_InitializeStaticResourcesBinding( this, L, m_MetatableRegistryName.c_str(), "InitializeStaticResources", &ShaderResourceBindingParser::InitializeStaticResources )
- {
-
- }
-
-
- void ShaderResourceBindingParser::CreateObj( lua_State *L )
- {
- INIT_LUA_STACK_TRACKING(L);
-
- // PSO should be the first argument
- auto *pPSO = *GetUserData<IPipelineState**>( L, 1, m_PSOLibMetatableName.c_str() );
-
- bool InitStaticResources = false;
- auto NumArgs = lua_gettop( L );
- if( NumArgs >= 2 )
- {
- InitStaticResources = ReadValueFromLua<Bool>( L, 2 );
- }
-
- auto pNewShaderResBndngLuaObj = reinterpret_cast<IShaderResourceBinding**>(lua_newuserdata( L, sizeof( IShaderResourceBinding* ) ));
- pPSO->CreateShaderResourceBinding(pNewShaderResBndngLuaObj, InitStaticResources);
-
- 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;
- IShaderResourceVariable* pVar = nullptr;
- if (lua_type(L,ArgStackInd) == LUA_TSTRING)
- {
- // Variable name should be the second argument
- auto VarName = ReadValueFromLua<String>( L, ArgStackInd );
- pVar = pShaderResBinding->GetVariableByName(ShaderType, VarName.c_str());
- }
- else
- {
- // Variable name should be the second argument
- auto VarIndex = ReadValueFromLua<int>( L, ArgStackInd );
- pVar = pShaderResBinding->GetVariableByIndex(ShaderType, VarIndex);
- }
-
- auto pNewShaderVarLuaObj = reinterpret_cast<IShaderResourceVariable**>(lua_newuserdata( L, sizeof( IShaderResourceVariable* ) ));
- *pNewShaderVarLuaObj = pVar;
- 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;
- }
-
- int ShaderResourceBindingParser::InitializeStaticResources( lua_State *L )
- {
- auto NumArgs = lua_gettop( L );
- // The object itself goes first
- auto *pShaderResBinding = *GetUserData<IShaderResourceBinding**>( L, 1, m_MetatableRegistryName.c_str() );
- IPipelineState* pPSO = nullptr;
-
- if (NumArgs >= 2)
- {
- pPSO = *GetUserData<IPipelineState**>( L, 2, m_PSOLibMetatableName.c_str() );
- }
-
- pShaderResBinding->InitializeStaticResources(pPSO);
- return 0;
- }
-
- 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
deleted file mode 100644
index 8be96eb..0000000
--- a/RenderScript/src/ShaderVariableParser.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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 "ShaderVariableParser.h"
-
-namespace Diligent
-{
- const Char* ShaderVariableParser::ShaderVariableLibName = "ShaderVariable";
-
- ShaderVariableParser::ShaderVariableParser( IRenderDevice *pRenderDevice, lua_State *L,
- const String &PSOLibMetatableName,
- const String &BufferLibMetatableName,
- const String &BufferViewLibMetatableName,
- const String &TexViewMetatableName ) :
- EngineObjectParserBase( pRenderDevice, L, ShaderVariableLibName ),
- m_PSOLibMetatableName(PSOLibMetatableName),
- m_BufferLibMetatableName(BufferLibMetatableName),
- m_BufferViewLibMetatableName(BufferViewLibMetatableName),
- m_TexViewMetatableName(TexViewMetatableName),
- m_SetBinding( this, L, m_MetatableRegistryName.c_str(), "Set", &ShaderVariableParser::Set ),
- m_GetStaticVariableByNameBinding( this, L, m_PSOLibMetatableName.c_str(), "GetStaticVariableByName", &ShaderVariableParser::GetStaticVariableByName ),
- m_GetStaticVariableByIndexBinding( this, L, m_PSOLibMetatableName.c_str(), "GetStaticVariableByIndex", &ShaderVariableParser::GetStaticVariableByIndex )
- {
- };
-
- void ShaderVariableParser::CreateObj( 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);
-
- // Shader should be the first argument
- auto *pPSO = *GetUserData<IPipelineState**>( L, 1, m_PSOLibMetatableName.c_str() );
-
- SHADER_TYPE ShaderType = SHADER_TYPE_UNKNOWN;
- EnumMemberBinder<SHADER_TYPE> ShaderTypeParser(0, "ShaderType", m_ShaderTypeEnumMapping);
- ShaderTypeParser.SetValue(L, 2, &ShaderType);
-
- IShaderResourceVariable *pVar = nullptr;
- if (lua_type(L,3) == LUA_TSTRING)
- {
- // Variable name should be the second argument
- auto VarName = ReadValueFromLua<String>( L, 3 );
- pVar = pPSO->GetStaticVariableByName(ShaderType, VarName.c_str() );
- }
- else
- {
- // Variable name should be the second argument
- auto VarIndex = ReadValueFromLua<int>( L, 3 );
- pVar = pPSO->GetStaticVariableByIndex(ShaderType, VarIndex );
- }
-
- auto pNewShaderVarLuaObj = reinterpret_cast<IShaderResourceVariable**>(lua_newuserdata( L, sizeof( IShaderResourceVariable* ) ));
- *pNewShaderVarLuaObj = pVar;
- pVar->AddRef();
-
- CHECK_LUA_STACK_HEIGHT( +1 );
- }
-
- void ShaderVariableParser::DestroyObj( void *pData )
- {
- if( pData != nullptr )
- {
- auto ppShaderVar = reinterpret_cast<IShaderResourceVariable**>(pData);
- if( *ppShaderVar != nullptr )
- (*ppShaderVar)->Release();
- }
- }
-
- void ShaderVariableParser::ReadField( lua_State *L, void *pData, const Char *Field )
- {
- SCRIPT_PARSING_ERROR(L, "Shader variables have no fields that can be read")
- }
-
- void ShaderVariableParser::UpdateField( lua_State *L, void *pData, const Char *Field )
- {
- SCRIPT_PARSING_ERROR(L, "Shader variables have no fields that can be updated")
- }
-
- void ShaderVariableParser::PushExistingObject( lua_State *L, const void *pObject )
- {
- auto pShaderVariable = reinterpret_cast<IShaderResourceVariable**>(lua_newuserdata( L, sizeof( IShaderResourceVariable* ) ));
- *pShaderVariable = reinterpret_cast<IShaderResourceVariable*>( const_cast<void*>(pObject) );
- (*pShaderVariable)->AddRef();
- }
-
- int ShaderVariableParser::Set( lua_State *L )
- {
- // Shader variable is the first argument
- auto *pShaderVar = *GetUserData<IShaderResourceVariable**>( L, 1, m_MetatableRegistryName.c_str() );
-
- IDeviceObject *pObject = nullptr;
- auto ArgType = lua_type( L, 2 );
- if( ArgType == LUA_TUSERDATA )
- {
- auto ppObject = reinterpret_cast<IDeviceObject**>( luaL_testudata( L, 2, m_BufferLibMetatableName.c_str() ) );
- if( !ppObject )
- ppObject = reinterpret_cast<IDeviceObject**>( luaL_testudata( L, 2, m_BufferViewLibMetatableName.c_str() ) );
- if( !ppObject )
- ppObject = reinterpret_cast<IDeviceObject**>( luaL_testudata( L, 2, m_TexViewMetatableName.c_str() ) );
- if( ppObject )
- {
- pObject = *ppObject;
- }
- else
- {
- SCRIPT_PARSING_ERROR(L, "Set() function expects buffer, buffer view or texture view as an argument")
- }
- }
- else if( ArgType == LUA_TNIL )
- {
- pObject = nullptr;
- }
- else
- {
- SCRIPT_PARSING_ERROR(L, "Set() function expects user data or nil")
- }
-
- pShaderVar->Set( pObject );
-
- return 0;
- }
-
- int ShaderVariableParser::GetStaticVariableByName( lua_State *L )
- {
- return LuaCreate(L);
- }
-
- int ShaderVariableParser::GetStaticVariableByIndex( lua_State *L )
- {
- return LuaCreate(L);
- }
-
- void ShaderVariableParser::GetObjectByName( lua_State *L, const Char *ShaderName, IShaderResourceVariable** ppObject )
- {
- auto pObject = *GetGlobalObject<IShaderResourceVariable**>( L, ShaderName, m_MetatableRegistryName.c_str() );
- *ppObject = pObject;
- pObject->AddRef();
- }
-}
diff --git a/RenderScript/src/TextureParser.cpp b/RenderScript/src/TextureParser.cpp
deleted file mode 100644
index ce78b1b..0000000
--- a/RenderScript/src/TextureParser.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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 "TextureParser.h"
-#include "TextureViewParser.h"
-
-namespace Diligent
-{
- const Char* TextureParser::TextureLibName = "Texture";
-
- template<>
- class MemberBinder<DepthStencilClearValue> : public MemberBinderBase
- {
- public:
- MemberBinder(size_t MemberOffset, int /*Dummy*/) :
- MemberBinderBase(MemberOffset)
- {
- DEFINE_BINDER_EX( m_Bindings, DepthStencilClearValue, Depth, Float32, Validator<Float32>("Depth clear value", 0.f, 1.f) );
- DEFINE_BINDER( m_Bindings, DepthStencilClearValue, Stencil );
- }
-
- 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, m_TexFmtEnumMapping );
- DEFINE_BINDER_EX( m_Bindings, OptimizedClearValue, Color, RGBALoader, 0 );
- DEFINE_BINDER_EX( 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, m_TexTypeEnumMapping );
-
- {
- using WidthType = decltype(STexDescWrapper::Width);
- Validator<WidthType> WidthValidator("Width", 1, 16384);
- DEFINE_BINDER_EX( m_Bindings, STexDescWrapper, Width, WidthType, WidthValidator);
- }
-
- {
- using HeightType = decltype(STexDescWrapper::Height);
- Validator<HeightType> HeightValidator("Heihght", 1, 16384);
- DEFINE_BINDER_EX( m_Bindings, STexDescWrapper, Height, HeightType, HeightValidator);
- }
-
- {
- using ArraySizeType = decltype(STexDescWrapper::ArraySize);
- Validator<ArraySizeType> ArraySizeValidator("ArraySize", 1, 16384);
- DEFINE_BINDER_EX( m_Bindings, STexDescWrapper, ArraySize, ArraySizeType, ArraySizeValidator);
- }
-
- {
- using DepthType = decltype(STexDescWrapper::Depth);
- Validator<DepthType> DepthValidator("Depth", 1, 16384);
- DEFINE_BINDER_EX( m_Bindings, STexDescWrapper, Depth, DepthType, DepthValidator);
- }
-
- DEFINE_ENUM_BINDER( m_Bindings, STexDescWrapper, Format, m_TexFormatEnumMapping );
-
- {
- using MipLevelsType = decltype(STexDescWrapper::MipLevels);
- Validator<MipLevelsType> MipLevelsValidator("MipLevels", 1, 20);
- DEFINE_BINDER_EX( m_Bindings, STexDescWrapper, MipLevels, MipLevelsType, MipLevelsValidator);
- }
-
- {
- using SampleCountType = decltype(STexDescWrapper::SampleCount);
- Validator<SampleCountType> SampleCountValidator("SampleCount", 1, 32);
- DEFINE_BINDER_EX( m_Bindings, STexDescWrapper, SampleCount, SampleCountType, SampleCountValidator);
- }
-
- //DEFINE_ENUM_ELEMENT_MAPPING( m_BindFlagEnumMapping, BIND_VERTEX_BUFFER );
- //DEFINE_ENUM_ELEMENT_MAPPING( m_BindFlagEnumMapping, BIND_INDEX_BUFFER );
- //DEFINE_ENUM_ELEMENT_MAPPING( m_BindFlagEnumMapping, BIND_UNIFORM_BUFFER );
- DEFINE_ENUM_ELEMENT_MAPPING( m_BindFlagEnumMapping, BIND_SHADER_RESOURCE );
- DEFINE_ENUM_ELEMENT_MAPPING( m_BindFlagEnumMapping, BIND_STREAM_OUTPUT );
- DEFINE_ENUM_ELEMENT_MAPPING( m_BindFlagEnumMapping, BIND_RENDER_TARGET );
- DEFINE_ENUM_ELEMENT_MAPPING( m_BindFlagEnumMapping, BIND_DEPTH_STENCIL );
- DEFINE_ENUM_ELEMENT_MAPPING( m_BindFlagEnumMapping, BIND_UNORDERED_ACCESS );
- //DEFINE_ENUM_ELEMENT_MAPPING( m_BindFlagEnumMapping, BIND_INDIRECT_DRAW_ARGS );
- // Explicit namespace declaraion is necesseary to avoid
- // name conflicts when building for windows store
- DEFINE_FLAGS_BINDER( m_Bindings, STexDescWrapper, BindFlags, Diligent::BIND_FLAGS, m_BindFlagEnumMapping );
-
- DEFINE_ENUM_BINDER( m_Bindings, STexDescWrapper, Usage, m_UsageEnumMapping );
- DEFINE_FLAGS_BINDER( m_Bindings, STexDescWrapper, CPUAccessFlags, CPU_ACCESS_FLAGS, m_CpuAccessFlagEnumMapping );
-
- DEFINE_ENUM_ELEMENT_MAPPING( m_MiscFlagEnumMapping, MISC_TEXTURE_FLAG_NONE );
- DEFINE_ENUM_ELEMENT_MAPPING( m_MiscFlagEnumMapping, MISC_TEXTURE_FLAG_GENERATE_MIPS );
- DEFINE_FLAGS_BINDER( m_Bindings, STexDescWrapper, MiscFlags, Diligent::MISC_TEXTURE_FLAGS, m_MiscFlagEnumMapping );
-
- DEFINE_BINDER_EX( m_Bindings, STexDescWrapper, ClearValue, OptimizedClearValue, 0 );
- };
-
- void TextureParser::CreateObj( lua_State *L )
- {
- INIT_LUA_STACK_TRACKING(L);
-
- STexDescWrapper TextureDesc;
- ParseLuaTable( L, 1, &TextureDesc, m_Bindings );
-
- CHECK_LUA_STACK_HEIGHT();
-
- auto ppTexture = reinterpret_cast<ITexture**>(lua_newuserdata( L, sizeof( ITexture* ) ));
- *ppTexture = nullptr;
- m_pRenderDevice->CreateTexture( TextureDesc, nullptr, ppTexture );
- if( *ppTexture == nullptr )
- SCRIPT_PARSING_ERROR(L, "Failed to create a texture")
-
- CHECK_LUA_STACK_HEIGHT(+1);
- }
-}
diff --git a/RenderScript/src/TextureViewParser.cpp b/RenderScript/src/TextureViewParser.cpp
deleted file mode 100644
index 5b5bbac..0000000
--- a/RenderScript/src/TextureViewParser.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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 "TextureViewParser.h"
-#include "TextureParser.h"
-#include "SamplerParser.h"
-#include "GraphicsAccessories.h"
-
-namespace Diligent
-{
- const Char* TextureViewParser::TextureViewLibName = "TextureView";
-
- TextureViewParser::TextureViewParser( TextureParser *pTexParser,
- SamplerParser *pSamplerParser,
- IRenderDevice *pRenderDevice, lua_State *L ) :
- EngineObjectParserCommon<ITextureView>( pRenderDevice, L, TextureViewLibName ),
- m_TextureLibMetatableName(pTexParser->GetMetatableName()),
- m_SamplerLibMetatableName( pSamplerParser->GetMetatableName() ),
- m_CreateViewBinding( this, L, m_TextureLibMetatableName.c_str(), "CreateView", &TextureViewParser::CreateView ),
- m_GetDefaultViewBinding( this, L, m_TextureLibMetatableName.c_str(), "GetDefaultView", &TextureViewParser::GetDefaultView ),
- m_SetSamplerBinding( this, L, m_MetatableRegistryName.c_str(), "SetSampler", &TextureViewParser::SetSampler ),
- m_ViewTypeParser( 0, "ViewType", m_ViewTypeEnumMapping )
- {
- DEFINE_BUFFERED_STRING_BINDER( m_Bindings, STexViewDescWrapper, Name, NameBuffer )
-
- DEFINE_ENUM_ELEMENT_MAPPING( m_ViewTypeEnumMapping, TEXTURE_VIEW_SHADER_RESOURCE );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ViewTypeEnumMapping, TEXTURE_VIEW_RENDER_TARGET );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ViewTypeEnumMapping, TEXTURE_VIEW_DEPTH_STENCIL );
- DEFINE_ENUM_ELEMENT_MAPPING( m_ViewTypeEnumMapping, TEXTURE_VIEW_UNORDERED_ACCESS );
- VERIFY( m_ViewTypeEnumMapping.m_Str2ValMap.size() == TEXTURE_VIEW_NUM_VIEWS - 1,
- "Unexpected map size. Did you update TEXTURE_VIEW_TYPE enum?" );
- VERIFY( m_ViewTypeEnumMapping.m_Val2StrMap.size() == TEXTURE_VIEW_NUM_VIEWS - 1,
- "Unexpected map size. Did you update TEXTURE_VIEW_TYPE enum?" );
- DEFINE_ENUM_BINDER( m_Bindings, STexViewDescWrapper, ViewType, m_ViewTypeEnumMapping );
-
- DEFINE_ENUM_BINDER( m_Bindings, STexViewDescWrapper, TextureDim, m_TexTypeEnumMapping );
- DEFINE_ENUM_BINDER( m_Bindings, STexViewDescWrapper, Format, m_TexFormatEnumMapping );
-
- {
- using MostDetailedMipType = decltype(STexViewDescWrapper::MostDetailedMip);
- Validator<MostDetailedMipType> MostDetailedMipValidator("MostDetailedMip", 0, 16384);
- DEFINE_BINDER_EX( m_Bindings, STexViewDescWrapper, MostDetailedMip, MostDetailedMipType, MostDetailedMipValidator);
- }
-
- {
- using NumMipLevelsType = decltype(STexViewDescWrapper::NumMipLevels);
- Validator<NumMipLevelsType> NumMipLevelsValidator("NumMipLevels", 1, 16384);
- DEFINE_BINDER_EX( m_Bindings, STexViewDescWrapper, NumMipLevels, NumMipLevelsType, NumMipLevelsValidator);
- }
-
- // The following two members are in union
- {
- using FirstArraySliceType = decltype(STexViewDescWrapper::FirstArraySlice);
- Validator<FirstArraySliceType> FirstArraySliceValidator("FirstArraySlice", 0, 16384);
- DEFINE_BINDER_EX( m_Bindings, STexViewDescWrapper, FirstArraySlice, FirstArraySliceType, FirstArraySliceValidator);
- }
-
- {
- using FirstDepthSliceType = decltype(STexViewDescWrapper::FirstDepthSlice);
- Validator<FirstDepthSliceType> FirstDepthSliceValidator("FirstDepthSlice", 0, 16384);
- DEFINE_BINDER_EX( m_Bindings, STexViewDescWrapper, FirstDepthSlice, FirstDepthSliceType, FirstDepthSliceValidator);
- }
-
- // The following two members are in union
- {
- using NumArraySlicesType = decltype(STexViewDescWrapper::NumArraySlices);
- Validator<NumArraySlicesType> NumArraySlicesValidator("NumArraySlices", 0, 16384);
- DEFINE_BINDER_EX( m_Bindings, STexViewDescWrapper, NumArraySlices, NumArraySlicesType, NumArraySlicesValidator);
- }
-
- {
- using NumDepthSlicesType = decltype(STexViewDescWrapper::NumDepthSlices);
- Validator<NumDepthSlicesType> NumDepthSlicesValidator("NumDepthSlices", 0, 16384);
- DEFINE_BINDER_EX( m_Bindings, STexViewDescWrapper, NumDepthSlices, NumDepthSlicesType, NumDepthSlicesValidator);
- }
-
- DEFINE_ENUM_ELEMENT_MAPPING( m_UAVAccessFlagEnumMapping, UAV_ACCESS_FLAG_READ );
- DEFINE_ENUM_ELEMENT_MAPPING( m_UAVAccessFlagEnumMapping, UAV_ACCESS_FLAG_WRITE );
- DEFINE_ENUM_ELEMENT_MAPPING( m_UAVAccessFlagEnumMapping, UAV_ACCESS_FLAG_READ_WRITE );
- DEFINE_FLAGS_BINDER( m_Bindings, STexViewDescWrapper, AccessFlags, UAV_ACCESS_FLAG, m_UAVAccessFlagEnumMapping );
- };
-
- void TextureViewParser::CreateObj( lua_State *L )
- {
- INIT_LUA_STACK_TRACKING(L);
-
- auto *pTexture = *GetUserData<ITexture**>( L, 1, m_TextureLibMetatableName.c_str() );
-
- STexViewDescWrapper TextureViewDesc;
- ParseLuaTable( L, 2, &TextureViewDesc, m_Bindings );
- CHECK_LUA_STACK_HEIGHT();
-
- auto ppTextureView = reinterpret_cast<ITextureView**>(lua_newuserdata( L, sizeof( ITextureView* ) ));
- *ppTextureView = nullptr;
- pTexture->CreateView( TextureViewDesc, ppTextureView );
- if( *ppTextureView == nullptr )
- SCRIPT_PARSING_ERROR(L, "Failed to create texture view")
-
- CHECK_LUA_STACK_HEIGHT( +1 );
- }
-
- int TextureViewParser::CreateView( lua_State *L )
- {
- // Note that LuaCreate is a static function.
- // However, this pointer to the TextureViewParser object
- // is stored in the upvalue. So LuaCreate will call
- // TextureViewParser::CreateObj()
- return LuaCreate(L);
- }
-
- int TextureViewParser::GetDefaultView( lua_State *L )
- {
- INIT_LUA_STACK_TRACKING( L );
-
- // Texture should be the first argument
- auto *pTexture = *GetUserData<ITexture**>( L, 1, m_TextureLibMetatableName.c_str() );
-
- // View type should be the second argument
- TEXTURE_VIEW_TYPE ViewType;
- m_ViewTypeParser.SetValue( L, 2, &ViewType );
-
- auto pView = pTexture->GetDefaultView( ViewType );
- if( !pView )
- SCRIPT_PARSING_ERROR( L, "Failed to get default texture view of type ", GetTexViewTypeLiteralName( ViewType ) );
-
- // Push existing object
- PushObject(L, pView);
-
- CHECK_LUA_STACK_HEIGHT( +1 );
-
- // Returning one value to Lua
- return 1;
- }
-
- int TextureViewParser::SetSampler( lua_State *L )
- {
- auto *pTexView = *GetUserData<ITextureView**>( L, 1, m_MetatableRegistryName.c_str() );
- auto *pSampler = *GetUserData<ISampler**>( L, 2, m_SamplerLibMetatableName.c_str() );
- pTexView->SetSampler( pSampler );
-
- // Returning nothing
- return 0;
- }
-}
diff --git a/RenderScript/src/ViewportParser.cpp b/RenderScript/src/ViewportParser.cpp
deleted file mode 100644
index b92c18f..0000000
--- a/RenderScript/src/ViewportParser.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * 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 "ViewportParser.h"
-
-namespace Diligent
-{
- const Char* ViewportParser::ViewportLibName = "Viewport";
-
- ViewportParser::ViewportParser( IRenderDevice *pRenderDevice, lua_State *L ) :
- EngineObjectParserBase( pRenderDevice, L, ViewportLibName ),
- m_SetViewportsBinding( this, L, "Context", "SetViewports", &ViewportParser::SetViewports )
- {
- m_Viewports.reserve( 8 );
-
- // NumVertices and NumIndices are in Union
- DEFINE_BINDER( m_Bindings, Viewport, TopLeftX );
- DEFINE_BINDER( m_Bindings, Viewport, TopLeftY );
- DEFINE_BINDER( m_Bindings, Viewport, Width );
- DEFINE_BINDER( m_Bindings, Viewport, Height );
- DEFINE_BINDER( m_Bindings, Viewport, MinDepth );
- DEFINE_BINDER( m_Bindings, Viewport, MaxDepth );
- };
-
- void ViewportParser::CreateObj( lua_State *L )
- {
- INIT_LUA_STACK_TRACKING(L);
-
- Viewport VP;
- ParseLuaTable( L, 1, &VP, m_Bindings );
- if( VP.Width < 0 )
- SCRIPT_PARSING_ERROR( L, "VP width (", VP.Width, ") cannot be negative" );
- if( VP.Height < 0 )
- SCRIPT_PARSING_ERROR( L, "VP height (", VP.Height, ") cannot be negative" );
- if( VP.MinDepth > VP.MaxDepth )
- SCRIPT_PARSING_ERROR( L, "VP depth range (", VP.MinDepth, ", ", VP.MaxDepth, ") is incorrect" );
-
- CHECK_LUA_STACK_HEIGHT();
-
- auto pViewport = reinterpret_cast<Viewport*>(lua_newuserdata( L, sizeof( Viewport ) ));
- memcpy(pViewport, &VP, sizeof(Viewport));
-
- CHECK_LUA_STACK_HEIGHT( +1 );
- }
-
- void ViewportParser::DestroyObj( void *pData )
- {
- // We do not need to do anything, because the whole object is
- // created as full user data and thus managed by Lua
- }
-
- void ViewportParser::ReadField( lua_State *L, void *pData, const Char *Field )
- {
- auto pViewport = reinterpret_cast<Viewport*>(pData);
- PushField( L, pViewport, Field, m_Bindings );
- }
-
- void ViewportParser::UpdateField( lua_State *L, void *pData, const Char *Field )
- {
- auto pViewport = reinterpret_cast<Viewport*>(pData);
- Diligent::UpdateField( L, -1, pViewport, Field, m_Bindings );
- }
-
- void ViewportParser::PushExistingObject( lua_State *L, const void *pObject )
- {
- auto pViewport = reinterpret_cast<Viewport*>(lua_newuserdata( L, sizeof( Viewport ) ));
- memcpy( pViewport, pObject, sizeof( Viewport ) );
- }
-
- int ViewportParser::SetViewports( lua_State *L )
- {
- auto *pContext = LoadDeviceContextFromRegistry( L );
- auto NumArgs = lua_gettop( L );
- if( NumArgs == 0 )
- pContext->SetViewports( 1, nullptr, 0, 0 );
- else
- {
- Uint32 RTWidth = 0;
- Uint32 RTHeight = 0;
- m_Viewports.clear();
- for( int Arg = 1; Arg <= NumArgs; ++Arg )
- {
- if( lua_type( L, Arg ) == LUA_TUSERDATA )
- {
- auto pViewport = GetUserData<Viewport*>( L, Arg, m_MetatableRegistryName.c_str() );
- m_Viewports.emplace_back( *pViewport );
- }
- else
- {
- if( RTWidth == 0 )
- RTWidth = ReadValueFromLua<Uint32>( L, Arg );
- else if( RTHeight == 0 )
- RTHeight = ReadValueFromLua<Uint32>( L, Arg );
- else
- SCRIPT_PARSING_ERROR( L, "Render target size already specified (", RTWidth, "x", RTHeight, ")." );
- }
- }
-
- if( (RTWidth == 0 && RTHeight != 0) || (RTWidth != 0 && RTHeight == 0) )
- SCRIPT_PARSING_ERROR( L, "Render target size is incomplete (", RTWidth, "x", RTHeight, "). Use either 0x0 or fully specified size" );
-
- Uint32 NumViewports = static_cast<Uint32>( m_Viewports.size() );
-
- if( NumViewports == 0 )
- SCRIPT_PARSING_ERROR( L, "At least one viewport must be specified" );
-
- pContext->SetViewports( NumViewports, m_Viewports.data(), RTWidth, RTHeight );
- }
-
- return 0;
- }
-}
diff --git a/RenderScript/src/pch.cpp b/RenderScript/src/pch.cpp
deleted file mode 100644
index 6feaa0c..0000000
--- a/RenderScript/src/pch.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright 2015-2018 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"
-