summaryrefslogtreecommitdiffstats
path: root/RenderScript
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
parentappveyor: swithced to VS2019 and enabled tests (diff)
downloadDiligentTools-d9ff664e3d796f9526ed29b7a1066b3d3fb443b1.tar.gz
DiligentTools-d9ff664e3d796f9526ed29b7a1066b3d3fb443b1.zip
Removed RenderScript and lua
Diffstat (limited to 'RenderScript')
-rw-r--r--RenderScript/CMakeLists.txt100
-rw-r--r--RenderScript/include/BlendStateDescParser.h41
-rw-r--r--RenderScript/include/BufferParser.h62
-rw-r--r--RenderScript/include/BufferViewParser.h58
-rw-r--r--RenderScript/include/ClassMethodBinding.h87
-rw-r--r--RenderScript/include/ConvenienceFunctions.h88
-rw-r--r--RenderScript/include/Debug.h63
-rw-r--r--RenderScript/include/DepthStencilStateDescParser.h43
-rw-r--r--RenderScript/include/DeviceContextFuncBindings.h67
-rw-r--r--RenderScript/include/DrawAttribsParser.h59
-rw-r--r--RenderScript/include/EngineObjectParserBase.h62
-rw-r--r--RenderScript/include/EngineObjectParserCommon.h70
-rw-r--r--RenderScript/include/EnumMappings.h98
-rw-r--r--RenderScript/include/InputLayoutDescParser.h46
-rw-r--r--RenderScript/include/LuaBindings.h684
-rw-r--r--RenderScript/include/LuaFunctionBinding.h100
-rw-r--r--RenderScript/include/LuaWrappers.h59
-rw-r--r--RenderScript/include/PSODescParser.h71
-rw-r--r--RenderScript/include/ParsingErrors.h53
-rw-r--r--RenderScript/include/RasterizerStateDescParser.h44
-rw-r--r--RenderScript/include/ResourceMappingParser.h62
-rw-r--r--RenderScript/include/SamplerParser.h103
-rw-r--r--RenderScript/include/ScissorRectParser.h51
-rw-r--r--RenderScript/include/ScriptParser.h169
-rw-r--r--RenderScript/include/ShaderParser.h61
-rw-r--r--RenderScript/include/ShaderResourceBindingParser.h73
-rw-r--r--RenderScript/include/ShaderVariableParser.h70
-rw-r--r--RenderScript/include/TextureParser.h61
-rw-r--r--RenderScript/include/TextureViewParser.h65
-rw-r--r--RenderScript/include/ViewportParser.h51
-rw-r--r--RenderScript/include/pch.h49
-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
57 files changed, 0 insertions, 7391 deletions
diff --git a/RenderScript/CMakeLists.txt b/RenderScript/CMakeLists.txt
deleted file mode 100644
index def9d76..0000000
--- a/RenderScript/CMakeLists.txt
+++ /dev/null
@@ -1,100 +0,0 @@
-cmake_minimum_required (VERSION 3.6)
-
-project(Diligent-RenderScript CXX)
-
-set(INCLUDE
- include/BlendStateDescParser.h
- include/BufferParser.h
- include/BufferViewParser.h
- include/ClassMethodBinding.h
- include/ConvenienceFunctions.h
- include/Debug.h
- include/DepthStencilStateDescParser.h
- include/DeviceContextFuncBindings.h
- include/DrawAttribsParser.h
- include/EngineObjectParserBase.h
- include/EngineObjectParserCommon.h
- include/EnumMappings.h
- include/InputLayoutDescParser.h
- include/LuaBindings.h
- include/LuaFunctionBinding.h
- include/LuaWrappers.h
- include/ParsingErrors.h
- include/pch.h
- include/PSODescParser.h
- include/RasterizerStateDescParser.h
- include/ResourceMappingParser.h
- include/SamplerParser.h
- include/ScissorRectParser.h
- include/ScriptParser.h
- include/ShaderParser.h
- include/ShaderResourceBindingParser.h
- include/ShaderVariableParser.h
- include/TextureParser.h
- include/TextureViewParser.h
- include/ViewportParser.h
-)
-
-set(SOURCE
- src/BlendStateDescParser.cpp
- src/BufferParser.cpp
- src/BufferViewParser.cpp
- src/DepthStencilStateDescParser.cpp
- src/DeviceContextFuncBindings.cpp
- src/DrawAttribsParser.cpp
- src/EngineObjectParserBase.cpp
- src/EnumMappings.cpp
- src/InputLayoutDescParser.cpp
- src/LuaBindings.cpp
- src/LuaFunctionBinding.cpp
- src/LuaWrappers.cpp
- src/ParsingErrors.cpp
- src/PSODescParser.cpp
- src/RasterizerStateDescParser.cpp
- src/ResourceMappingParser.cpp
- src/SamplerParser.cpp
- src/ScissorRectParser.cpp
- src/ScriptParser.cpp
- src/ShaderParser.cpp
- src/ShaderResourceBindingParser.cpp
- src/ShaderVariableParser.cpp
- src/TextureParser.cpp
- src/TextureViewParser.cpp
- src/ViewportParser.cpp
-)
-
-add_library(Diligent-RenderScript STATIC ${SOURCE} ${INCLUDE})
-set_common_target_properties(Diligent-RenderScript)
-
-target_include_directories(Diligent-RenderScript
-PUBLIC
- include
-)
-
-if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
- CMAKE_CXX_COMPILER_ID MATCHES "GNU")
- # Suppress warnings from applying the ‘offsetof’ macro to a non-POD type
- # warning: offset of on non-standard-layout type [-Winvalid-offsetof]
- # This is OK because the warning is generated for simple structs (such as TextureDesc)
- # that fail to be a POD type only by virtue of having a constructor and comparison operator
- target_compile_options(Diligent-RenderScript PRIVATE -Wno-invalid-offsetof)
-endif()
-
-source_group("source" FILES ${SOURCE})
-source_group("include" FILES ${INCLUDE})
-
-target_link_libraries(Diligent-RenderScript
-PUBLIC
- Lua
-PRIVATE
- Diligent-BuildSettings
- Diligent-GraphicsEngineInterface
- Diligent-GraphicsAccessories
- Diligent-Common
- Diligent-PlatformInterface
- Diligent-GraphicsTools
-)
-
-set_target_properties(Diligent-RenderScript PROPERTIES
- FOLDER DiligentTools
-) \ No newline at end of file
diff --git a/RenderScript/include/BlendStateDescParser.h b/RenderScript/include/BlendStateDescParser.h
deleted file mode 100644
index b34152b..0000000
--- a/RenderScript/include/BlendStateDescParser.h
+++ /dev/null
@@ -1,41 +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.
- */
-
-#pragma once
-
-#include "PipelineState.h"
-#include "LuaBindings.h"
-
-namespace Diligent
-{
- template<>
- class MemberBinder<BlendStateDesc> final : public MemberBinderBase
- {
- public:
- MemberBinder( size_t MemberOffset, size_t Dummy ) ;
- virtual void GetValue( lua_State *L, const void* pBasePointer )override final;
- virtual void SetValue( lua_State *L, int Index, void* pBasePointer )override final;
- private:
- BindingsMapType m_Bindings;
- };
-}
diff --git a/RenderScript/include/BufferParser.h b/RenderScript/include/BufferParser.h
deleted file mode 100644
index ebe6c58..0000000
--- a/RenderScript/include/BufferParser.h
+++ /dev/null
@@ -1,62 +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.
- */
-
-#pragma once
-
-#include "LuaWrappers.h"
-#include "LuaBindings.h"
-#include "EngineObjectParserCommon.h"
-#include "ClassMethodBinding.h"
-
-namespace Diligent
-{
- class BufferParser final : public EngineObjectParserCommon<IBuffer>
- {
- public:
- BufferParser( IRenderDevice *pRenderDevice, lua_State *L );
- static const Char* BufferLibName;
-
- protected:
- virtual void CreateObj( lua_State *L )override final;
-
- private:
- // BufferDesc structure does not provide storage for the Name field.
- // We need to use ObjectDescWrapper<> to be able to store the field.
- typedef ObjectDescWrapper<BufferDesc> SBuffDescWrapper;
-
- int SetVertexBuffers( lua_State * );
- ClassMethodCaller<BufferParser> m_SetVertexBuffersBinding;
- int SetIndexBuffer( lua_State * );
- ClassMethodCaller<BufferParser> m_SetIndexBufferBinding;
-
- UsageEnumMapping m_UsageEnumMapping;
- // Explicit namespace declaraion is necesseary to avoid
- // name conflicts when building for windows store
- EnumMapping<Diligent::BIND_FLAGS> m_BindFlagEnumMapping;
- CpuAccessFlagEnumMapping m_CpuAccessFlagEnumMapping;
- NumericArrayLoader m_ArrayLoader;
- EnumMapping<BUFFER_MODE> m_BuffModeEnumMapping;
- EnumMapping<SET_VERTEX_BUFFERS_FLAGS> m_SetVBFlagEnumMapping;
- StateTransitionModeEnumMapping m_StateTransitionModeMapping;
- };
-}
diff --git a/RenderScript/include/BufferViewParser.h b/RenderScript/include/BufferViewParser.h
deleted file mode 100644
index d73ce3a..0000000
--- a/RenderScript/include/BufferViewParser.h
+++ /dev/null
@@ -1,58 +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.
- */
-
-#pragma once
-
-#include "LuaWrappers.h"
-#include "LuaBindings.h"
-#include "EngineObjectParserCommon.h"
-#include "ClassMethodBinding.h"
-
-namespace Diligent
-{
- class BufferViewParser final : public EngineObjectParserCommon<IBufferView>
- {
- public:
- BufferViewParser( class BufferParser *pBufParser, IRenderDevice *pRenderDevice, lua_State *L );
- static const Char *BufferViewLibName;
-
- protected:
- virtual void CreateObj( lua_State *L )override final;
-
- private:
- // BufferViewDesc structure does not provide storage for the Name field.
- // We need to use ObjectDescWrapper<> to be able to store the field.
- typedef ObjectDescWrapper<BufferViewDesc> SBuffViewDescWrapper;
-
- const String m_BufferLibMetatableName;
-
- ClassMethodCaller<BufferViewParser> m_CreateViewBinding;
- int CreateView( lua_State *L );
-
- ClassMethodCaller<BufferViewParser> m_GetDefaultViewBinding;
- int GetDefaultView( lua_State * );
-
- EnumMapping<BUFFER_VIEW_TYPE> m_ViewTypeEnumMapping;
- EnumMemberBinder<BUFFER_VIEW_TYPE> m_ViewTypeParser;
- };
-}
diff --git a/RenderScript/include/ClassMethodBinding.h b/RenderScript/include/ClassMethodBinding.h
deleted file mode 100644
index bf751a8..0000000
--- a/RenderScript/include/ClassMethodBinding.h
+++ /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.
- */
-
-#pragma once
-
-namespace Diligent
-{
- template<typename OwnerClassType>
- class ClassMethodCaller
- {
- public:
- typedef int(OwnerClassType::*MemberFunctionType)(lua_State *LuaState);
-
- ClassMethodCaller( OwnerClassType *pOwner,
- lua_State *L,
- const Char *LuaTableName,
- const Char *LuaFunctionName,
- MemberFunctionType MemberFunction) :
- m_MemberFunction( MemberFunction )
- {
- INIT_LUA_STACK_TRACKING( L );
-
- lua_getglobal( L, LuaTableName ); // -0 | +1 -> +1
- if( lua_type( L, -1 ) == LUA_TNIL )
- {
- // Global name is not found, try to find metatable with that name
- // Pop nil from the stack
- lua_pop( L, 1 ); // -1 | +0 -> -1
- luaL_getmetatable( L, LuaTableName ); // -0 | +1 -> +1
- }
- CheckType( L, -1, LUA_TTABLE );
- lua_pushstring( L, LuaFunctionName ); // -0 | +1 -> +1
- lua_pushlightuserdata( L, pOwner ); // -0 | +1 -> +1
- lua_pushlightuserdata( L, this ); // -0 | +1 -> +1
- lua_pushcclosure( L, LuaEntry, 2 ); // -2 | +0 -> -2
- lua_settable( L, -3 ); // -1 | +0 -> -1
- // Pop table
- lua_pop( L, 1 ); // -1 | +0 -> -1
-
- CHECK_LUA_STACK_HEIGHT();
- };
-
- private:
- MemberFunctionType m_MemberFunction;
-
- static int LuaEntry( lua_State *L )
- {
- auto pOwner = static_cast<OwnerClassType*>(lua_touserdata( L, lua_upvalueindex( 1 ) ));
- VERIFY( pOwner, "Owner pointer is null" );
-
- auto pThis = static_cast<ClassMethodCaller*>(lua_touserdata( L, lua_upvalueindex( 2 ) ));
- VERIFY( pThis, "This pointer is null" );
-
- if( pOwner && pThis )
- {
- auto MemberFunction = pThis->m_MemberFunction;
-
- // A C function returns an integer with the number of values it is returning in Lua.
- // Therefore, the function does not need to clear the stack before pushing its results.
- // After it returns, Lua automatically removes whatever is in the stack below the results.
- return (pOwner->*MemberFunction)(L);
- }
- else
- return 0;
- }
- };
-}
diff --git a/RenderScript/include/ConvenienceFunctions.h b/RenderScript/include/ConvenienceFunctions.h
deleted file mode 100644
index 3fb8782..0000000
--- a/RenderScript/include/ConvenienceFunctions.h
+++ /dev/null
@@ -1,88 +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.
- */
-
-#pragma once
-
-#include <string>
-
-#include "Errors.h"
-#include "FileWrapper.h"
-#include "ScriptParser.h"
-#include "DataBlobImpl.h"
-#ifdef _WIN32
-# ifndef NOMINMAX
-# define NOMINMAX
-# endif
-# include <Windows.h>
-#endif
-
-inline void SetGlobalVarsStub( Diligent::ScriptParser * ){}
-
-template<typename TSetGlobalVars>
-Diligent::RefCntAutoPtr<Diligent::ScriptParser> CreateRenderScriptFromFile( const Diligent::Char *FilePath, Diligent::IRenderDevice *pRenderDevice, Diligent::IDeviceContext *pContext, TSetGlobalVars SetGlobalVars )
-{
- bool bSuccess = true;
- Diligent::RefCntAutoPtr<Diligent::ScriptParser> pScriptParser;
-#if PLATFORM_WIN32
- do
- {
-#endif
- std::string ErrorMsg;
- bSuccess = true;
- try
- {
- Diligent::FileWrapper ScriptFile(FilePath);
- if( !ScriptFile )
- LOG_ERROR_AND_THROW( "Failed to open Lua source file" );
- Diligent::RefCntAutoPtr<Diligent::IDataBlob> pFileData( Diligent::MakeNewRCObj<Diligent::DataBlobImpl>()(0) );
- ScriptFile->Read( pFileData );
-
- // Null-terminator is not read from the stream
- pFileData->Resize(pFileData->GetSize() + 1);
- auto *ScriptText = reinterpret_cast<char*>(pFileData->GetDataPtr());
- ScriptText[pFileData->GetSize() - 1] = 0;
-
- pScriptParser = Diligent::MakeNewRCObj<Diligent::ScriptParser>()( pRenderDevice );
- pScriptParser->Parse( ScriptText );
- SetGlobalVars( pScriptParser );
- pScriptParser->Run( pContext );
- }
- catch( const std::runtime_error &err )
- {
- bSuccess = false;
- ErrorMsg = err.what();
- }
-
-#if PLATFORM_WIN32
- if( !bSuccess )
- {
- if( IDRETRY != MessageBoxA( NULL, "Failed to parse the script. Retry?", "Lua parser error", MB_ICONERROR | MB_ABORTRETRYIGNORE ) )
- {
- abort();
- }
- }
- } while( !bSuccess );
-#endif
-
- return pScriptParser;
-}
diff --git a/RenderScript/include/Debug.h b/RenderScript/include/Debug.h
deleted file mode 100644
index 5ace8c3..0000000
--- a/RenderScript/include/Debug.h
+++ /dev/null
@@ -1,63 +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.
- */
-
-#pragma once
-
-#ifdef _DEBUG
-
-class LuaStackHeightTracker
-{
-public:
- LuaStackHeightTracker( lua_State *L ) :
- m_L( L ),
- m_StackTop(0)
- {
- Record();
- }
-
- void Record()
- {
- m_StackTop = lua_gettop( m_L );
- }
-
- void Check(int Adjustment = 0)
- {
- auto CurrHeight = lua_gettop( m_L );
- VERIFY( CurrHeight == m_StackTop + Adjustment, "Unexpected stack height" );
- }
-private:
- lua_State *m_L;
- int m_StackTop;
-};
-
-#define INIT_LUA_STACK_TRACKING(L) LuaStackHeightTracker LuaStackHeightTracker(L)
-#define RECORD_LUA_STACK_HEIGHT() LuaStackHeightTracker.Record()
-#define CHECK_LUA_STACK_HEIGHT(...) LuaStackHeightTracker.Check(__VA_ARGS__)
-
-#else
-
-#define INIT_LUA_STACK_TRACKING(L)
-#define RECORD_LUA_STACK_HEIGHT()
-#define CHECK_LUA_STACK_HEIGHT(...)
-
-#endif
diff --git a/RenderScript/include/DepthStencilStateDescParser.h b/RenderScript/include/DepthStencilStateDescParser.h
deleted file mode 100644
index 6a181e2..0000000
--- a/RenderScript/include/DepthStencilStateDescParser.h
+++ /dev/null
@@ -1,43 +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.
- */
-
-#pragma once
-
-#include "PipelineState.h"
-#include "LuaBindings.h"
-#include "EnumMappings.h"
-
-namespace Diligent
-{
- template<>
- class MemberBinder<DepthStencilStateDesc> : public MemberBinderBase
- {
- public:
- MemberBinder( size_t MemberOffset, size_t Dummy ) ;
- virtual void GetValue( lua_State *L, const void* pBasePointer )override;
- virtual void SetValue( lua_State *L, int Index, void* pBasePointer )override;
- private:
- BindingsMapType m_Bindings;
- ComparisonFuncEnumMapping m_CmpFuncEnumMapping;
- };
-}
diff --git a/RenderScript/include/DeviceContextFuncBindings.h b/RenderScript/include/DeviceContextFuncBindings.h
deleted file mode 100644
index d1b6487..0000000
--- a/RenderScript/include/DeviceContextFuncBindings.h
+++ /dev/null
@@ -1,67 +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.
- */
-
-#pragma once
-
-#include "LuaWrappers.h"
-#include "LuaBindings.h"
-#include "ClassMethodBinding.h"
-#include "EnumMappings.h"
-
-namespace Diligent
-{
- class DeviceContextFuncBindings
- {
- public:
- DeviceContextFuncBindings( IRenderDevice *pRenderDevice, lua_State *L, class TextureViewParser *pTexViewPasrser, class ShaderResourceBindingParser *pSRBParser, class PSODescParser *pPSOParser );
-
- private:
- int SetRenderTargets( lua_State * );
- ClassMethodCaller<DeviceContextFuncBindings> m_SetRenderTargetsBinding;
-
- int ClearRenderTarget( lua_State * );
- ClassMethodCaller<DeviceContextFuncBindings> m_ClearRenderTargetBinding;
-
- int ClearDepthStencil( lua_State * );
- ClassMethodCaller<DeviceContextFuncBindings> m_ClearDepthStencilBinding;
-
- int SetStencilRef( lua_State * );
- ClassMethodCaller<DeviceContextFuncBindings> m_SetStencilRefBinding;
-
- int SetBlendFactors( lua_State * );
- ClassMethodCaller<DeviceContextFuncBindings> m_SetBlendFactorsBinding;
-
- int CommitShaderResources( lua_State * );
- ClassMethodCaller<DeviceContextFuncBindings> m_CommitShaderResourcesBinding;
-
- int TransitionShaderResources( lua_State * );
- ClassMethodCaller<DeviceContextFuncBindings> m_TransitionShaderResourcesBinding;
-
- StateTransitionModeEnumMapping m_StateTransitionModeMapping;
- EnumMapping<CLEAR_DEPTH_STENCIL_FLAGS> m_ClearDepthStencilFlagsEnumMapping;
-
- String m_TexViewMetatableName;
- String m_ShaderResBindingMetatableName;
- String m_PSOMetatableName;
- };
-}
diff --git a/RenderScript/include/DrawAttribsParser.h b/RenderScript/include/DrawAttribsParser.h
deleted file mode 100644
index 0b3ea31..0000000
--- a/RenderScript/include/DrawAttribsParser.h
+++ /dev/null
@@ -1,59 +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.
- */
-
-#pragma once
-
-#include "LuaWrappers.h"
-#include "LuaBindings.h"
-#include "EngineObjectParserCommon.h"
-#include "ClassMethodBinding.h"
-
-namespace Diligent
-{
- class DrawAttribsParser final : public EngineObjectParserBase
- {
- public:
- DrawAttribsParser( class BufferParser *pBuffParser, IRenderDevice *pRenderDevice, lua_State *L );
- static const Char* DrawAttribsLibName;
-
- protected:
- virtual void CreateObj( lua_State *L )override final;
- virtual void DestroyObj( void *pData )override final;
- virtual void ReadField( lua_State *L, void *pData, const Char *Field )override final;
- virtual void UpdateField( lua_State *L, void *pData, const Char *Field )override final;
- virtual void PushExistingObject( lua_State *L, const void *pObject )override final;
-
- private:
- int Draw( lua_State * );
- ClassMethodCaller<DrawAttribsParser> m_DrawBinding;
-
- int DispatchCompute( lua_State * );
- ClassMethodCaller<DrawAttribsParser> m_DispatchComputeBinding;
-
- EnumMapping<DRAW_FLAGS> m_DrawFlagsEnumMapping;
- EnumMapping<VALUE_TYPE> m_ValueTypeEnumMapping;
- StateTransitionModeEnumMapping m_StateTransitionModeEnumMapping;
-
- String m_BufferMetatableName;
- };
-}
diff --git a/RenderScript/include/EngineObjectParserBase.h b/RenderScript/include/EngineObjectParserBase.h
deleted file mode 100644
index 8e9cb89..0000000
--- a/RenderScript/include/EngineObjectParserBase.h
+++ /dev/null
@@ -1,62 +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.
- */
-
-#pragma once
-
-#include "LuaWrappers.h"
-#include "LuaBindings.h"
-
-namespace Diligent
-{
- class EngineObjectParserBase
- {
- public:
- EngineObjectParserBase( IRenderDevice *pRenderDevice, lua_State *L, const Char *LibName );
- void PushObject( lua_State *L, const void *pData );
- const String &GetMetatableName(){ return m_MetatableRegistryName; }
-
- static IDeviceContext* LoadDeviceContextFromRegistry( lua_State *L );
-
- protected:
- void RegisterTable( lua_State *L );
-
- static int LuaCreate( lua_State *L );
- virtual void CreateObj( lua_State *L ) = 0;
-
- static int LuaGC( lua_State *L );
- virtual void DestroyObj( void *pData ) = 0;
-
- static int LuaIndex( lua_State *L );
- virtual void ReadField( lua_State *L, void *pData, const Char *Field ) = 0;
-
- static int LuaNewIndex( lua_State *L );
- virtual void UpdateField( lua_State *L, void *pData, const Char *Field );
-
- virtual void PushExistingObject( lua_State *L, const void *pObject ) = 0;
-
- Diligent::RefCntAutoPtr<IRenderDevice> m_pRenderDevice;
- BindingsMapType m_Bindings;
- const String m_LibName;
- const String m_MetatableRegistryName;
- };
-}
diff --git a/RenderScript/include/EngineObjectParserCommon.h b/RenderScript/include/EngineObjectParserCommon.h
deleted file mode 100644
index 29b428d..0000000
--- a/RenderScript/include/EngineObjectParserCommon.h
+++ /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.
- */
-
-#pragma once
-
-#include "EngineObjectParserBase.h"
-
-namespace Diligent
-{
- template<typename ObjectType>
- class EngineObjectParserCommon : public EngineObjectParserBase
- {
- public:
- EngineObjectParserCommon( IRenderDevice *pRenderDevice, lua_State *L, const Char *LibName ) :
- EngineObjectParserBase( pRenderDevice, L, LibName )
- {}
-
- virtual void GetObjectByName( lua_State *L, const Char *ShaderName, ObjectType** ppObject )
- {
- auto pObject = *GetGlobalObject<ObjectType**>( L, ShaderName, m_MetatableRegistryName.c_str() );
- *ppObject = pObject;
- pObject->AddRef();
- }
-
- protected:
- virtual void PushExistingObject( lua_State *L, const void *pObject )
- {
- auto ppObject = reinterpret_cast<ObjectType**>(lua_newuserdata( L, sizeof( ObjectType* ) ));
- *ppObject = reinterpret_cast<ObjectType*>(const_cast<void*>(pObject));
- (*ppObject)->AddRef();
- }
-
- virtual void DestroyObj( void *pData )
- {
- if( pData != nullptr )
- {
- auto ppObject = reinterpret_cast<ObjectType**>(pData);
- if( *ppObject != nullptr )
- (*ppObject)->Release();
- }
- }
-
- virtual void ReadField( lua_State *L, void *pData, const Char *Field )
- {
- auto pObject = *reinterpret_cast<ObjectType**>(pData);
- const auto &Desc = pObject->GetDesc();
- PushField( L, &Desc, Field, m_Bindings );
- }
- };
-}
diff --git a/RenderScript/include/EnumMappings.h b/RenderScript/include/EnumMappings.h
deleted file mode 100644
index 5221b5a..0000000
--- a/RenderScript/include/EnumMappings.h
+++ /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.
- */
-
-#pragma once
-
-#include <unordered_map>
-#include "HashUtils.h"
-
-namespace Diligent
-{
- template<typename EnumType>
- struct EnumMapping
- {
- void AddMapping( const Char *Str, EnumType Val )
- {
- m_Str2ValMap.insert( std::make_pair( Diligent::HashMapStringKey(Str, true), Val ) );
- m_Val2StrMap.insert( std::make_pair( Val, Str ) );
- }
-
- std::unordered_map<HashMapStringKey, EnumType, HashMapStringKey::Hasher> m_Str2ValMap;
- std::unordered_map<EnumType, String, std::hash<typename std::underlying_type<EnumType>::type>> m_Val2StrMap;
- };
-#define DEFINE_ENUM_ELEMENT_MAPPING(EnumMapping, Elem) EnumMapping.AddMapping(#Elem, Elem)
-
- class CpuAccessFlagEnumMapping : public EnumMapping < Diligent::CPU_ACCESS_FLAGS >
- {
- public:
- CpuAccessFlagEnumMapping();
- };
-
- class UsageEnumMapping : public EnumMapping < Diligent::USAGE >
- {
- public:
- UsageEnumMapping();
- };
-
- class TextureFormatEnumMapping : public EnumMapping < Diligent::TEXTURE_FORMAT >
- {
- public:
- TextureFormatEnumMapping();
- };
-
- class ResourceDimEnumMapping : public EnumMapping < Diligent::RESOURCE_DIMENSION >
- {
- public:
- ResourceDimEnumMapping();
- };
-
- class ValueTypeEnumMapping : public EnumMapping < Diligent::VALUE_TYPE >
- {
- public:
- ValueTypeEnumMapping();
- };
-
- class ComparisonFuncEnumMapping : public EnumMapping < Diligent::COMPARISON_FUNCTION >
- {
- public:
- ComparisonFuncEnumMapping();
- };
-
- class BindShaderResourcesFlagEnumMapping : public EnumMapping < Diligent::BIND_SHADER_RESOURCES_FLAGS >
- {
- public:
- BindShaderResourcesFlagEnumMapping();
- };
-
- class ShaderTypeEnumMapping : public EnumMapping<SHADER_TYPE>
- {
- public:
- ShaderTypeEnumMapping();
- };
-
- class StateTransitionModeEnumMapping : public EnumMapping<RESOURCE_STATE_TRANSITION_MODE>
- {
- public:
- StateTransitionModeEnumMapping();
- };
-}
diff --git a/RenderScript/include/InputLayoutDescParser.h b/RenderScript/include/InputLayoutDescParser.h
deleted file mode 100644
index 4b702fd..0000000
--- a/RenderScript/include/InputLayoutDescParser.h
+++ /dev/null
@@ -1,46 +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.
- */
-
-#pragma once
-
-#include "LuaWrappers.h"
-#include "LuaBindings.h"
-
-namespace Diligent
-{
- template<>
- class MemberBinder<InputLayoutDesc> : public MemberBinderBase
- {
- public:
- MemberBinder( size_t InputLayoutOffset, size_t ElementsBufferOffset );
- virtual void GetValue( lua_State *L, const void* pBasePointer )override;
- virtual void SetValue( lua_State *L, int Index, void* pBasePointer )override;
-
- private:
- BindingsMapType m_Bindings;
- ValueTypeEnumMapping m_ValueTypeEnumMapping;
- EnumMapping < LayoutElement::FREQUENCY > m_FrequencyEnumMapping;
- size_t m_LayoutElementsBufferOffset;
- };
-
-}
diff --git a/RenderScript/include/LuaBindings.h b/RenderScript/include/LuaBindings.h
deleted file mode 100644
index 997b1b3..0000000
--- a/RenderScript/include/LuaBindings.h
+++ /dev/null
@@ -1,684 +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.
- */
-
-#pragma once
-
-#include "lua.h"
-#include "lualib.h"
-#include "lauxlib.h"
-#include "EnumMappings.h"
-
-namespace Diligent
-{
- template< typename ValueType>
- ValueType ReadValueFromLua( lua_State *L, int Index )
- {
- UNSUPPORTED( "Type is not supported" );
- return static_cast<ValueType>(0);
- }
- template<>int ReadValueFromLua<int>( lua_State *L, int Index );
- template<>double ReadValueFromLua<double>( lua_State *L, int Index );
- template<>float ReadValueFromLua<float>( lua_State *L, int Index );
- template<>String ReadValueFromLua<String>( lua_State *L, int Index );
- template<>const Char* ReadValueFromLua<const Char*>( lua_State *L, int Index );
- template<>Bool ReadValueFromLua<Bool>( lua_State *L, int Index );
- template<>Uint32 ReadValueFromLua<Uint32>( lua_State *L, int Index );
- template<>Uint8 ReadValueFromLua<Uint8>( lua_State *L, int Index );
-
-
- inline void CheckType( lua_State *L, int Index, int ExpectedType )
- {
- auto Type = lua_type( L, Index );
- if( Type != ExpectedType )
- {
- auto TypeName = lua_typename( L, Type );
- auto ExpectedTypeName = lua_typename( L, ExpectedType );
- auto Param = lua_tostring( L, Index );
- SCRIPT_PARSING_ERROR( L, "Incorrect argument: \"", Param ? Param : "<Unknown>", "\". \"", ExpectedTypeName, "\" is expected, while \"", TypeName, "\" is provided." );
- }
- }
-
- // 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 );
-
- template<typename DataType, typename MetatableNameType>
- DataType GetUserData( lua_State *L, int Index, MetatableNameType MetatableName )
- {
- CheckType( L, Index, LUA_TUSERDATA );
- auto pUserData = luaL_testudata( L, Index, MetatableName );
- if( pUserData == nullptr )
- {
- auto Type = lua_type( L, Index );
- auto TypeName = lua_typename( L, Type );
- SCRIPT_PARSING_ERROR( L, "Bad argument #", Index, ". User data with metatable \"", MetatableName, "\" is expected. \"", TypeName, "\" is provided." );
- }
- return reinterpret_cast<DataType>(pUserData);
- }
-
- template<typename DataType>
- DataType GetGlobalObject( lua_State *L, const Char* ObjectName, const Char* MetatableName )
- {
- INIT_LUA_STACK_TRACKING( L );
- // Pushes onto the stack the value of the given global name
- lua_getglobal( L, ObjectName ); // -0 | +1 -> +1
- auto pData = GetUserData<DataType>( L, -1, MetatableName ); // -0 | +0 -> 0
- lua_pop( L, 1 ); // -1 | +0 -> -1
- CHECK_LUA_STACK_HEIGHT();
- return pData;
- }
-
-
-
- template<typename Type>
- void PushValue( lua_State *L, Type )
- {
- UNSUPPORTED( "Type is not supported" );
- }
- // Forward declarations of template specializations
- template<> void PushValue<double>( lua_State *L, double Val );
- template<> void PushValue<const float&>( lua_State *L, const float& Val );
- template<> void PushValue<const Int32&>( lua_State *L, const Int32& Val );
- template<> void PushValue<const Uint32&>( lua_State *L, const Uint32& Val );
- template<> void PushValue<const Uint8&>( lua_State *L, const Uint8& Val );
- template<> void PushValue<const Char*>( lua_State *L, const Char* Val );
- template<> void PushValue<const Char* const&>( lua_State *L, const Char* const& Val );
- template<> void PushValue<const String&>( lua_State *L, const String& Val );
- template<> void PushValue<bool>( lua_State *L, bool Val );
- template<> void PushValue<const bool &>( lua_State *L, const bool &Val );
-
-
- class MemberBinderBase
- {
- public:
- MemberBinderBase( size_t MemberOffset ) :
- m_MemberOffset( MemberOffset )
- {}
- virtual ~MemberBinderBase(){}
- virtual void GetValue( lua_State *L, const void* pBasePointer ) = 0;
- virtual void SetValue( lua_State *L, int Index, void* pBasePointer ) = 0;
-
- protected:
- const size_t m_MemberOffset;
- };
- typedef std::unordered_map<HashMapStringKey, std::unique_ptr<MemberBinderBase>, HashMapStringKey::Hasher> BindingsMapType;
-
-#define DEFINE_BINDER_EX(BindingsMap, Struct, Member, type, ValidationFunc) \
- do{\
- auto *pNewBinder = new MemberBinder<type>( offsetof( Struct, Member ), ValidationFunc ); \
- /* No need to make a copy of #Member since it is constant string. */ \
- /* HashMapStringKey will simply keep pointer to it */ \
- BindingsMap.insert( std::make_pair( #Member, std::unique_ptr<MemberBinderBase>(pNewBinder) ) ); \
- }while(false)
-
-#define DEFINE_BINDER(BindingsMap, Struct, Member) DEFINE_BINDER_EX(BindingsMap, Struct, Member, decltype(Struct::Member), Validator<decltype(Struct::Member)>() )
-
- template<typename ValueType>
- void SkipValidationFunc( const ValueType & )
- {
- // Do nothing
- }
-
- template<typename ValueType>
- class Validator
- {
- public:
- typedef void( *ValidationFuncType )(const ValueType &);
- Validator( const char *pParameterName, ValueType MinValue, ValueType MaxValue ) :
- m_pParameterName( pParameterName ),
- m_MinValue( MinValue ),
- m_MaxValue( MaxValue ),
- m_ValidationFunc( nullptr )
- {}
-
- Validator( ValidationFuncType ValidationFunc = SkipValidationFunc<ValueType> ) :
- m_pParameterName( nullptr ),
- m_MinValue( ValueType() ),
- m_MaxValue( ValueType() ),
- m_ValidationFunc( ValidationFunc )
- {}
-
- void SetParameterName( const char *NewName ){ m_pParameterName = NewName; }
-
- void operator()( lua_State *L, const ValueType &Value )const
- {
- if( m_ValidationFunc )
- {
- m_ValidationFunc( Value );
- }
- else
- {
- if( Value < m_MinValue || Value > m_MaxValue )
- {
- SCRIPT_PARSING_ERROR( L, "Parameter '", m_pParameterName, "' (", Value, ") is out of range [", m_MinValue, ",", m_MaxValue, "]\n" );
- }
- }
- }
-
- private:
- const char *m_pParameterName;
- ValueType m_MinValue, m_MaxValue;
- ValidationFuncType m_ValidationFunc;
- };
-
- template<>
- class Validator < Bool >
- {
- public:
- void operator()( lua_State *L, const Bool & )const
- {
- // Do nothing
- }
- };
-
- template<typename MemberType>
- MemberType& GetMemberByOffest( void* pBasePointer, size_t Offset )
- {
- return *(reinterpret_cast<MemberType*>(reinterpret_cast<char*>(pBasePointer)+Offset));
- }
-
- template<typename MemberType>
- const MemberType& GetMemberByOffest( const void* pBasePointer, size_t Offset )
- {
- return *(reinterpret_cast<const MemberType*>(reinterpret_cast<const char*>(pBasePointer)+Offset));
- }
-
- template<typename MemberType>
- class MemberBinder : public MemberBinderBase
- {
- public:
- MemberBinder( size_t MemberOffset, Validator<MemberType> Validator ) :
- MemberBinderBase( MemberOffset ),
- m_Validator( Validator )
- {}
-
- virtual void GetValue( lua_State *L, const void* pBasePointer )
- {
- const auto &Value = GetMemberByOffest<MemberType>(pBasePointer, m_MemberOffset);
- PushValue<const MemberType &>( L, Value );
- }
-
- virtual void SetValue( lua_State *L, int Index, void* pBasePointer )
- {
- auto Value = ReadValueFromLua<MemberType>( L, Index );
- m_Validator( L, Value );
- GetMemberByOffest<MemberType>( pBasePointer, m_MemberOffset ) = Value;
- }
- protected:
- Validator<MemberType> m_Validator;
- };
-
-
- template<typename TableElementParser>
- inline void ParseLuaTable( lua_State *L, int Index, void* pBasePointer, TableElementParser ElemParser )
- {
- CheckType( L, Index, LUA_TTABLE );
-
- lua_pushnil( L ); // first key which will be popped out in the first call to lua_next()
- // lua_next() pops a key from the stack, and pushes a key–value pair from the table at the given index
- // (the "next" pair after the given key). If there are no more elements in the table, then lua_next returns
- // 0 (and pushes nothing).
- if( Index < 0 )
- --Index;
- while( lua_next( L, Index ) != 0 )
- {
- // Key is now at index -2 and Value is at index -1
- auto IsString = lua_isstring( L, -2 );
- if( !IsString )
- {
- SCRIPT_PARSING_ERROR( L, "Table key value must be string")
- }
- // 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 Key = lua_tostring( L, -2 );
- ElemParser(-1, pBasePointer, Key);
-
- // Pop value from the stack, but KEEP Key for the next iteration
- lua_pop( L, 1 );
- }
- }
-
- inline void ParseLuaTable( lua_State *L, int Index, void* pBasePointer, BindingsMapType &Bindings )
- {
- ParseLuaTable( L, Index, pBasePointer,
- [&](int Index, void* pBasePointer, const char *Key)
- {
- auto Binding = Bindings.find( Key );
- if( Binding != Bindings.end() )
- {
- Binding->second->SetValue( L, Index, pBasePointer );
- }
- else
- {
- SCRIPT_PARSING_ERROR( L, "Unknown Member \"", Key, '\"' );
- }
- }
- );
- }
-
- template<class ArrayElemParser>
- inline void ParseLuaArray( lua_State *L, int Index, void* pBasePointer, ArrayElemParser ElemParser )
- {
- CheckType( L, Index, LUA_TTABLE );
-
- lua_pushnil( L ); // first key which will be popped out in the first call to lua_next()
- // lua_next() pops a key from the stack, and pushes a key–value pair from the table at the given index
- // (the "next" pair after the given key). If there are no more elements in the table, then lua_next returns
- // 0 (and pushes nothing).
- if( Index < 0 )
- --Index;
- while( lua_next( L, Index ) != 0 )
- {
- // Key is now at index -2 and Value is at index -1
- CheckType( L, -2, LUA_TNUMBER );
-
- auto NewArrayIndex = static_cast<int>( lua_tointeger( L, -2 ) );
- ElemParser( pBasePointer, -1, NewArrayIndex );
-
- // Pop value from the stack, but KEEP Key for the next iteration
- lua_pop( L, 1 );
- }
- }
-
- inline void PushLuaTable( lua_State *L, const void* pBasePointer, BindingsMapType &Bindings )
- {
- lua_newtable( L );
- for( auto it = Bindings.begin(); it != Bindings.end(); ++it )
- {
- const auto &Field = it->first.GetStr();
- lua_pushstring( L, Field );
- it->second->GetValue( L, pBasePointer );
- lua_settable( L, -3 ); // Stack: 0
- }
- }
-
- template<typename ItType, class ElemPushAlg>
- void PushLuaArray( lua_State *L, ItType Begin, ItType End, ElemPushAlg PushAlg )
- {
- lua_newtable( L );
- int ArrayInd = 1; // Lua arrays are 1-based
- for( auto it = Begin; it != End; ++it, ++ArrayInd )
- {
- lua_pushnumber( L, ArrayInd ); // -0 | +1 -> +1
- PushAlg( *it ); // -0 | +1 -> +1
- lua_settable( L, -3 ); // -2 | +0 -> -2
- }
- }
-
- template<typename ArrayType, class ElemPushAlg>
- void PushLuaArray( lua_State *L, const ArrayType& Arr, ElemPushAlg PushAlg )
- {
- PushLuaArray( L, Arr.begin(), Arr.end(), PushAlg );
- }
-
- inline void PushField( lua_State *L, const void* pBasePointer, const Char *Field, BindingsMapType &Bindings )
- {
- auto It = Bindings.find( Field );
- if( It != Bindings.end() )
- {
- It->second->GetValue( L, pBasePointer );
- }
- else
- {
- SCRIPT_PARSING_ERROR( L, "Unknown Member \"", Field, '\"' );
- }
- }
-
- inline void UpdateField( lua_State *L, int Index, void* pBasePointer, const Char *Field, BindingsMapType &Bindings )
- {
- auto It = Bindings.find( Field );
- if( It != Bindings.end() )
- {
- It->second->SetValue( L, Index, pBasePointer );
- }
- else
- {
- SCRIPT_PARSING_ERROR( L, "Unknown Member \"", Field, '\"' );
- }
- }
-
- class RGBALoader; // Used only as a template switch
- template<>
- class MemberBinder<RGBALoader> : public MemberBinderBase
- {
- public:
- MemberBinder( size_t MemberOffset, size_t Dummy ) :
- MemberBinderBase( MemberOffset )
- {
- const char* Members[] = { "r", "g", "b", "a" };
- for( int c = 0; c < 4; ++c )
- {
- auto *pNewBinder = new MemberBinder<Float32>( MemberOffset + sizeof( Float32 )*c, Validator<float>() );
- // No need to make a copy of Members[c] since it is constant string.
- // HashMapStringKey will simply keep pointer to it
- Bindings.insert( std::make_pair( Members[c], std::unique_ptr<MemberBinderBase>( pNewBinder ) ) );
- }
- }
- virtual void GetValue( lua_State *L, const void* pBasePointer )
- {
- PushLuaTable( L, pBasePointer, Bindings );
- }
-
- virtual void SetValue( lua_State *L, int Index, void* pBasePointer )
- {
- ParseLuaTable( L, Index, pBasePointer, Bindings );
- }
- private:
- BindingsMapType Bindings;
- };
-
-
- template< typename EnumType >
- String GetEnumMappingsString( const EnumMapping<EnumType> &EnumMapping )
- {
- String Values;
- bool bFirst = true;
- for( auto it = EnumMapping.m_Str2ValMap.begin(); it != EnumMapping.m_Str2ValMap.end(); ++it )
- {
- if( !bFirst )
- Values += ", ";
- Values += '\"';
- Values.append( it->first.GetStr() );
- Values += '\"';
- bFirst = false;
- }
- return Values;
- }
-
- template<typename EnumType>
- class EnumMemberBinder : public MemberBinderBase
- {
- public:
- EnumMemberBinder( size_t MemberOffset, const Char* MemberName, const EnumMapping<EnumType> &EnumMapping ) :
- MemberBinderBase( MemberOffset ),
- m_MemberName( MemberName ),
- m_EnumMapping( EnumMapping )
- {
- }
-
- virtual void GetValue( lua_State *L, const void* pBasePointer )
- {
- const auto &Val = GetMemberByOffest<EnumType>( pBasePointer, m_MemberOffset );
- auto It = m_EnumMapping.m_Val2StrMap.find( Val );
- if( It != m_EnumMapping.m_Val2StrMap.end() )
- {
- const String& StrVal = It->second;
- PushValue<const String&>( L, StrVal );
- }
- else
- {
- UNEXPECTED( "Enum value (", static_cast<Int32>(Val), ") not found in the map" );
- SCRIPT_PARSING_ERROR( L, "Enum value (", static_cast<Int32>(Val), ") not found in the map" );
- }
- }
-
- virtual void SetValue( lua_State *L, int Index, void* pBasePointer )
- {
- auto Str = ReadValueFromLua<String>( L, Index );
- auto It = m_EnumMapping.m_Str2ValMap.find( Str.c_str() );
- if( It != m_EnumMapping.m_Str2ValMap.end() )
- {
- auto Val = It->second;
- GetMemberByOffest<EnumType>(pBasePointer, m_MemberOffset) = Val;
- }
- else
- {
- String AllowableValues = GetEnumMappingsString<EnumType>( m_EnumMapping );
- SCRIPT_PARSING_ERROR( L, "Unknown value (\"", Str, "\") provided for parameter ", m_MemberName, ". Only the following values are allowed:\n", AllowableValues );
- }
- }
-
- private:
- const Char *m_MemberName;
- const EnumMapping<EnumType> &m_EnumMapping;
- };
-
-#define DEFINE_ENUM_BINDER(BindingsMap, Struct, Member, EnumMapping ) \
- do{\
- auto *pNewBinder = new EnumMemberBinder<decltype(Struct::Member)>( offsetof( Struct, Member ), #Member, EnumMapping ); \
- /* No need to make a copy of #Member since it is constant string. */ \
- /* HashMapStringKey will simply keep pointer to it */ \
- BindingsMap.insert( std::make_pair( #Member, std::unique_ptr<MemberBinderBase>(pNewBinder) ) ); \
- }while(false)
-
- template< typename EnumType, typename FlagsType = typename std::underlying_type<EnumType>::type >
- class FlagsLoader : public MemberBinderBase
- {
- public:
- FlagsLoader( size_t MemberOffset, const Char* MemberName, const EnumMapping<EnumType> &EnumMapping ) :
- MemberBinderBase( MemberOffset ),
- m_MemberName( MemberName ),
- m_EnumMapping( EnumMapping )
- {
- }
- virtual void GetValue( lua_State *L, const void* pBasePointer )
- {
- auto Flags = GetMemberByOffest<FlagsType>( pBasePointer, m_MemberOffset );
- lua_newtable( L );
- int ArrayInd = 1;
- for( auto it = m_EnumMapping.m_Val2StrMap.begin(); it != m_EnumMapping.m_Val2StrMap.end(); ++it )
- {
- if( (it->first != 0 && static_cast<EnumType>(Flags & it->first) == it->first) ||
- (Flags == 0 && it->first == 0) )
- {
- lua_pushnumber( L, ArrayInd ); // -0 | +1 -> +1
- PushValue<const String&>( L, it->second ); // -0 | +1 -> +1
- lua_settable( L, -3 ); // -2 | +0 -> -2
- ++ArrayInd;
- }
- }
- }
-
- virtual void SetValue( lua_State *L, int Index, void* pBasePointer )
- {
- FlagsType Flags = static_cast<FlagsType>(0);
- if( lua_isnumber( L, Index ) )
- {
- Flags = static_cast<FlagsType>( ReadValueFromLua<Uint32>( L, Index ) );
- }
- else if( lua_isstring( L, Index ) )
- {
- Flags = ReadFlag( L, Index );
- }
- else if( lua_istable( L, Index ) )
- {
- ParseLuaArray( L, Index, pBasePointer, [ &]( void* _pBasePointer, int StackIndex, int NewArrayIndex )
- {
- auto CurrFlag = ReadFlag( L, StackIndex );
- Flags |= CurrFlag;
- }
- );
- }
- else
- {
- SCRIPT_PARSING_ERROR( L, m_MemberName, "must be specified as a single string or an array of strings." );
- }
- GetMemberByOffest<FlagsType>( pBasePointer, m_MemberOffset ) = Flags;
- }
-
- private:
- FlagsType ReadFlag( lua_State *L, int StackIndex )
- {
- auto CurrFlagName = ReadValueFromLua<const Char *>( L, StackIndex );
- auto It = m_EnumMapping.m_Str2ValMap.find( CurrFlagName );
- if( It != m_EnumMapping.m_Str2ValMap.end() )
- {
- return It->second;
- }
- else
- {
- String AllowableValues = GetEnumMappingsString<EnumType>( m_EnumMapping );
- SCRIPT_PARSING_ERROR( L, "Unknown flag (\"", CurrFlagName, "\") provided for parameter ", m_MemberName, ". Only the following flags are allowed:\n", AllowableValues );
- return static_cast<FlagsType>(0);
- }
- }
-
- const Char *m_MemberName;
- const EnumMapping<EnumType> &m_EnumMapping;
- };
-#define DEFINE_FLAGS_BINDER(BindingsMap, Struct, Member, type, EnumMapping ) \
- do{\
- auto *pNewBinder = new FlagsLoader<type, decltype(Struct::Member)>( offsetof( Struct, Member ), #Member, EnumMapping ); \
- /* No need to make a copy of #Member since it is constant string. */ \
- /* HashMapStringKey will simply keep pointer to it */ \
- BindingsMap.insert( std::make_pair( #Member, std::unique_ptr<MemberBinderBase>(pNewBinder) ) ); \
- }while(false)
-
-
- template<typename FieldType>
- void SetTableField( lua_State *L, const char *FieldName, int TableStackIndex, FieldType Value )
- {
- INIT_LUA_STACK_TRACKING( L );
-
- lua_pushstring( L, FieldName ); // -0 | +1 -> +1
- PushValue<FieldType>( L, Value ); // -0 | +1 -> +1
-
- // lua_settable() does the equivalent to t[k] = v, where t is the value at the given index,
- // v is the value at the top of the stack (-1), and k is the value just below the top (-2)
- // The function pops both the key and the value from the stack. As in Lua, this function may
- // trigger a metamethod for the "newindex" event
- lua_settable( L, TableStackIndex - 2 ); // -2 | +0 -> -2
-
- CHECK_LUA_STACK_HEIGHT();
- }
-
- class NumericArrayLoader
- {
- public:
- NumericArrayLoader();
- void LoadArray( lua_State *L, int StackIndex, std::vector< Uint8 >& RawData );
- private:
- EnumMapping<VALUE_TYPE> m_ValueTypeEnumMapping;
- EnumMemberBinder<VALUE_TYPE> m_ValueTypeBinder;
- typedef void (*ParseNumericArrayFuncType)(lua_State *L, int StackIndex, std::vector< Uint8 >& RawData);
- std::unordered_map< VALUE_TYPE, ParseNumericArrayFuncType, std::hash<std::underlying_type<VALUE_TYPE>::type> > m_ParseFuncJumpTbl;
- };
-
-
- template<typename EngineObjectType>
- class EngineObjectPtrLoader
- {
- public:
- typedef EngineObjectType ObjectType;
- };
-
- template<typename EngineObjectType>
- class MemberBinder< EngineObjectPtrLoader<EngineObjectType> > : public MemberBinderBase
- {
- public:
- typedef typename EngineObjectPtrLoader<EngineObjectType>::ObjectType ObjectType;
-
- MemberBinder( size_t MemberOffset, const std::vector<String> &_Metatables ) :
- MemberBinderBase( MemberOffset ),
- Metatables( _Metatables )
- {
- }
-
- virtual void GetValue( lua_State *L, const void* pBasePointer )
- {
- VERIFY( Metatables.size() == 1, "Ambiguous metatable" );
- const auto& MetatableName = *Metatables.begin();
- auto pObject = GetMemberByOffest<ObjectType*>( pBasePointer, m_MemberOffset );
- if( pObject )
- {
- auto ppNewObject = reinterpret_cast<ObjectType**>(lua_newuserdata( L, sizeof( ObjectType* ) ));
- *ppNewObject = pObject;
- pObject->AddRef();
- // Push onto the stack the metatable associated with name given in the registry
- luaL_getmetatable( L, MetatableName.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
- }
- else
- {
- lua_pushnil(L);
- }
- }
-
- virtual void SetValue( lua_State *L, int Index, void* pBasePointer )
- {
- ObjectType *pObject = nullptr;
- pObject = *GetUserData<ObjectType**>( L, -1, Metatables );
- GetMemberByOffest<ObjectType*>( pBasePointer, m_MemberOffset ) = pObject;
- }
- private:
- BindingsMapType Bindings;
- std::vector<String> Metatables;
- };
-
- // None of the graphics engine structures (such as BufferDesc or TextureDesc)
- // provide storage for strings, but only contain const Char* pointers.
- // The script wraps every such structure to provide the storage
- // This binder handles such strings
- class BufferedStringBinder : public MemberBinderBase
- {
- public:
- BufferedStringBinder(
- size_t StringPtrOffset, // This is the offset of the const Char* pointer
- size_t StringBuffOffset // This is the offset of the buffer that contains string data
- ) :
- MemberBinderBase( StringBuffOffset ),
- m_StringPtrOffset( StringPtrOffset )
- {
- }
-
- virtual void GetValue( lua_State *L, const void* pBasePointer )
- {
- // Always use const Char* pointer to push value to Lua as there
- // might be no valid buffer
- auto *StringPtr = GetMemberByOffest<const Char*>( pBasePointer, m_StringPtrOffset );
- PushValue<const Char*>( L, StringPtr );
- }
-
- virtual void SetValue( lua_State *L, int Index, void* pBasePointer )
- {
- // When reading the string from Lua, we need to make
- // sure that the string pointer contains the right data
- auto SrcString = ReadValueFromLua<String>( L, Index );
- // Set the const Char* pointer
- auto &DstStrBuff = GetMemberByOffest<String>( pBasePointer, m_MemberOffset );
- auto &DstStringPtr = GetMemberByOffest<const Char*>( pBasePointer, m_StringPtrOffset );
- DstStrBuff = SrcString;
- DstStringPtr = DstStrBuff.data();
- }
- protected:
- size_t m_StringPtrOffset;
- };
-
-#define DEFINE_BUFFERED_STRING_BINDER(BindingsMap, Struct, StringPtr, StringBuffer) \
- {\
- auto *pNewBinder = new BufferedStringBinder( offsetof( Struct, StringPtr ), offsetof( Struct, StringBuffer ) ); \
- /* No need to make a copy of #Member since it is constant string. */ \
- /* HashMapStringKey will simply keep pointer to it */ \
- BindingsMap.insert( std::make_pair( #StringPtr, std::unique_ptr<MemberBinderBase>(pNewBinder) ) ); \
- }
-
- // Object description wrapper that provides storage for
- // the Name field
- template<typename ObjectDescType>
- struct ObjectDescWrapper : ObjectDescType
- {
- String NameBuffer;
- };
-}
diff --git a/RenderScript/include/LuaFunctionBinding.h b/RenderScript/include/LuaFunctionBinding.h
deleted file mode 100644
index 6deb71a..0000000
--- a/RenderScript/include/LuaFunctionBinding.h
+++ /dev/null
@@ -1,100 +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.
- */
-
-#pragma once
-
-namespace Diligent
-{
- class LuaFunctionCallerBase
- {
- public:
- LuaFunctionCallerBase( lua_State *LuaState = nullptr ) :
- m_LuaState( LuaState )
- {
- };
-
- void SetLuaState( lua_State *LuaState )
- {
- m_LuaState = LuaState;
- }
-
- // We need these stubs to hide implementation details
- void PushFuncStub( lua_State *L, Bool Arg );
- void PushFuncStub( lua_State *L, Int32 Arg );
- void PushFuncStub( lua_State *L, Uint32 Arg );
- void PushFuncStub( lua_State *L, Int16 Arg );
- void PushFuncStub( lua_State *L, Uint16 Arg );
- void PushFuncStub( lua_State *L, Int8 Arg );
- void PushFuncStub( lua_State *L, Uint8 Arg );
- void PushFuncStub( lua_State *L, float Arg );
- void PushFuncStub( lua_State *L, const Char *Arg );
- void PushFuncStub( lua_State *L, const String &Arg );
-
- protected:
- void Run_internal( int NumArgs, const Char *FuncName );
-
- lua_State *m_LuaState;
- };
-
- class DummyPushFuncs
- {
- public:
- void PushFuncStub();
- };
-
- template<typename AdditionalPushFuncs = DummyPushFuncs>
- class LuaFunctionCaller : public LuaFunctionCallerBase, public AdditionalPushFuncs
- {
- public:
- void operator()()
- {
- operator()( nullptr );
- }
-
- template<typename... ArgsType>
- void operator()( const Char *FuncName, const ArgsType&... Args )
- {
- Run_internal( 0, FuncName, Args... );
- }
-
- // We need to make visible these parent-class definitions here
- using LuaFunctionCallerBase::PushFuncStub;
- using LuaFunctionCallerBase::Run_internal;
- using AdditionalPushFuncs::PushFuncStub;
-
- protected:
- template<typename ArgType>
- void Run_internal( int NumArgs, const Char *FuncName, const ArgType &Arg )
- {
- PushFuncStub( m_LuaState, Arg );
- Run_internal( NumArgs + 1, FuncName );
- }
-
- template<typename ArgType, typename... RestArgsType>
- void Run_internal( int NumArgs, const Char *FuncName, const ArgType &Arg, const RestArgsType&... RestArgs )
- {
- PushFuncStub( m_LuaState, Arg );
- Run_internal( NumArgs + 1, FuncName, RestArgs... ); // recursive call using pack expansion syntax
- }
- };
-}
diff --git a/RenderScript/include/LuaWrappers.h b/RenderScript/include/LuaWrappers.h
deleted file mode 100644
index 25f39f1..0000000
--- a/RenderScript/include/LuaWrappers.h
+++ /dev/null
@@ -1,59 +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.
- */
-
-#pragma once
-
-#include "lua.h"
-#include "lualib.h"
-#include "lauxlib.h"
-#include "BasicTypes.h"
-
-namespace Diligent
-{
- class LuaState
- {
- public:
- enum
- {
- LUA_LIB_BASE = 0x001,
- LUA_LIB_PACKAGE = 0x002,
- LUA_LIB_COROUTINE = 0x004,
- LUA_LIB_TABLE = 0x008,
- LUA_LIB_IO = 0x010,
- LUA_LIB_OS = 0x020,
- LUA_LIB_STRING = 0x040,
- LUA_LIB_BIT32 = 0x080,
- LUA_LIB_MATH = 0x100,
- LUA_LIB_DEBUG = 0x200
- };
- LuaState( Uint32 OpenLibFlags = static_cast<Uint32>(-1) );
- ~LuaState();
- void Close();
-
- operator lua_State *();
-
- private:
- lua_State *m_pLuaState;
- };
-
-} \ No newline at end of file
diff --git a/RenderScript/include/PSODescParser.h b/RenderScript/include/PSODescParser.h
deleted file mode 100644
index a25a728..0000000
--- a/RenderScript/include/PSODescParser.h
+++ /dev/null
@@ -1,71 +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.
- */
-
-#pragma once
-
-#include "LuaWrappers.h"
-#include "LuaBindings.h"
-#include "EngineObjectParserCommon.h"
-#include "ClassMethodBinding.h"
-#include "PipelineState.h"
-
-namespace Diligent
-{
- class PSODescParser final : public EngineObjectParserCommon<IPipelineState>
- {
- public:
- PSODescParser( IRenderDevice *pRenderDevice, lua_State *L, const String& ResMappingMetatableName );
- static const Char* PSODescLibName;
-
- protected:
- virtual void CreateObj( lua_State *L )override final;
-
- private:
- // PipelineStateDesc structure does not provide storage for the Name field.
- // We need to use ObjectDescWrapper<> to be able to store the field.
- struct PSODescWrapper : PipelineStateDesc
- {
- String NameBuffer;
- std::vector<ShaderResourceVariableDesc> m_VarDescBuffer;
- std::vector<String> m_VarNamesBuffer;
- std::vector<StaticSamplerDesc> m_StaticSamplersBuffer;
- std::vector<String> m_StaticSamplerTexNamesBuffer;
- std::vector<LayoutElement> LayoutElementsBuffer;
- };
- friend class MemberBinder<GraphicsPipelineDesc>;
-
- int SetPSO( lua_State *L );
- ClassMethodCaller<PSODescParser> m_SetPSOBinding;
-
- int IsCompatibleWith(lua_State *L);
- ClassMethodCaller<PSODescParser> m_IsCompatibleWithBinding;
-
- const String m_ResMappingMetatableName;
-
- ClassMethodCaller<PSODescParser> m_BindStaticResourcesBinding;
- int BindStaticResources( lua_State *L );
-
- BindShaderResourcesFlagEnumMapping m_BindShaderResFlagEnumMapping;
- ShaderTypeEnumMapping m_ShaderTypeEnumMapping;
- };
-}
diff --git a/RenderScript/include/ParsingErrors.h b/RenderScript/include/ParsingErrors.h
deleted file mode 100644
index baff4f5..0000000
--- a/RenderScript/include/ParsingErrors.h
+++ /dev/null
@@ -1,53 +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.
- */
-
-#pragma once
-
-#include <vector>
-
-template<typename SSType>
-SSType& operator << (SSType &ss, const std::vector<Diligent::String>& Arg )
-{
- bool bIsFirst = true;
- for( auto it = Arg.cbegin(); it != Arg.cend(); ++it )
- {
- if( !bIsFirst )
- ss << ", ";
- ss << *it;
- bIsFirst = false;
- }
- return ss;
-}
-
-void LuaDebugInformation( lua_State *L, std::stringstream &ss );
-
-#define SCRIPT_PARSING_ERROR(L, ...) \
-{ \
- std::stringstream ss; \
- ss << '\n'; \
- Diligent::FormatStrSS( ss, ##__VA_ARGS__ ); \
- ss << "\n\n"; \
- LuaDebugInformation(L, ss); \
- auto strFullMessage = ss.str(); \
- luaL_error(L, strFullMessage.c_str());\
-}
diff --git a/RenderScript/include/RasterizerStateDescParser.h b/RenderScript/include/RasterizerStateDescParser.h
deleted file mode 100644
index f6441cd..0000000
--- a/RenderScript/include/RasterizerStateDescParser.h
+++ /dev/null
@@ -1,44 +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.
- */
-
-#pragma once
-
-#include "PipelineState.h"
-#include "LuaBindings.h"
-
-namespace Diligent
-{
- template<>
- class MemberBinder<RasterizerStateDesc> final : public MemberBinderBase
- {
- public:
- MemberBinder( size_t MemberOffset, size_t Dummy ) ;
- virtual void GetValue( lua_State *L, const void* pBasePointer )override final;
- virtual void SetValue( lua_State *L, int Index, void* pBasePointer )override final;
- private:
- BindingsMapType m_Bindings;
-
- EnumMapping < FILL_MODE > m_FillModeEnumMapping;
- EnumMapping < CULL_MODE > m_CullModeEnumMapping;
- };
-}
diff --git a/RenderScript/include/ResourceMappingParser.h b/RenderScript/include/ResourceMappingParser.h
deleted file mode 100644
index 9d58196..0000000
--- a/RenderScript/include/ResourceMappingParser.h
+++ /dev/null
@@ -1,62 +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.
- */
-
-#pragma once
-
-#include "LuaWrappers.h"
-#include "LuaBindings.h"
-#include "EngineObjectParserBase.h"
-#include "ClassMethodBinding.h"
-
-namespace Diligent
-{
- class ResourceMappingParser final : public EngineObjectParserBase
- {
- public:
- ResourceMappingParser( IRenderDevice *pRenderDevice, lua_State *L,
- class TextureViewParser *pTexViewParser,
- class BufferParser *pBuffParser,
- class BufferViewParser *pBuffViewParser );
- void GetObjectByName( lua_State *L, const Char *ShaderName, IResourceMapping** ppObject );
-
- static const Char* ResourceMappingLibName;
-
- protected:
- virtual void CreateObj( lua_State *L )override final;
- virtual void ReadField( lua_State *L, void *pData, const Char *Field )override final;
- virtual void UpdateField( lua_State *L, void *pData, const Char *Field )override final;
-
- private:
- virtual void PushExistingObject( lua_State *L, const void *pObject )override final;
- virtual void DestroyObj( void *pData )override final;
-
- BindingsMapType m_Bindings;
-
- TextureViewParser *m_pTexViewParser;
- BufferParser *m_pBuffParser;
- BufferViewParser *m_pBuffViewParser;
- std::vector<String> m_MappedResourceMetatables;
-
- BindShaderResourcesFlagEnumMapping m_BindShaderResFlagEnumMapping;
- };
-}
diff --git a/RenderScript/include/SamplerParser.h b/RenderScript/include/SamplerParser.h
deleted file mode 100644
index 894929f..0000000
--- a/RenderScript/include/SamplerParser.h
+++ /dev/null
@@ -1,103 +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.
- */
-
-#pragma once
-
-#include "LuaWrappers.h"
-#include "LuaBindings.h"
-#include "EngineObjectParserBase.h"
-#include "ClassMethodBinding.h"
-#include "EngineObjectParserCommon.h"
-
-namespace Diligent
-{
- template<typename StructType>
- void InitSamplerParserBindings(BindingsMapType &Bindings,
- EnumMapping<FILTER_TYPE> &FilterTypeEnumMapping,
- EnumMapping<TEXTURE_ADDRESS_MODE> &TexAddrModeEnumMapping,
- ComparisonFuncEnumMapping &CmpFuncEnumMapping)
- {
- DEFINE_ENUM_ELEMENT_MAPPING( FilterTypeEnumMapping, FILTER_TYPE_POINT );
- DEFINE_ENUM_ELEMENT_MAPPING( FilterTypeEnumMapping, FILTER_TYPE_LINEAR );
- DEFINE_ENUM_ELEMENT_MAPPING( FilterTypeEnumMapping, FILTER_TYPE_ANISOTROPIC );
- DEFINE_ENUM_ELEMENT_MAPPING( FilterTypeEnumMapping, FILTER_TYPE_COMPARISON_POINT );
- DEFINE_ENUM_ELEMENT_MAPPING( FilterTypeEnumMapping, FILTER_TYPE_COMPARISON_LINEAR );
- DEFINE_ENUM_ELEMENT_MAPPING( FilterTypeEnumMapping, FILTER_TYPE_COMPARISON_ANISOTROPIC );
- DEFINE_ENUM_ELEMENT_MAPPING( FilterTypeEnumMapping, FILTER_TYPE_MINIMUM_POINT );
- DEFINE_ENUM_ELEMENT_MAPPING( FilterTypeEnumMapping, FILTER_TYPE_MINIMUM_LINEAR );
- DEFINE_ENUM_ELEMENT_MAPPING( FilterTypeEnumMapping, FILTER_TYPE_MINIMUM_ANISOTROPIC );
- DEFINE_ENUM_ELEMENT_MAPPING( FilterTypeEnumMapping, FILTER_TYPE_MAXIMUM_POINT );
- DEFINE_ENUM_ELEMENT_MAPPING( FilterTypeEnumMapping, FILTER_TYPE_MAXIMUM_LINEAR );
- DEFINE_ENUM_ELEMENT_MAPPING( FilterTypeEnumMapping, FILTER_TYPE_MAXIMUM_ANISOTROPIC );
- VERIFY( FilterTypeEnumMapping.m_Str2ValMap.size() == FILTER_TYPE_NUM_FILTERS - 1, "Unexpected map size. Did you update FILTER_TYPE enum?" );
- VERIFY( FilterTypeEnumMapping.m_Val2StrMap.size() == FILTER_TYPE_NUM_FILTERS - 1, "Unexpected map size. Did you update FILTER_TYPE enum?" );
- DEFINE_ENUM_BINDER( Bindings, StructType, MinFilter, FilterTypeEnumMapping );
- DEFINE_ENUM_BINDER( Bindings, StructType, MagFilter, FilterTypeEnumMapping );
- DEFINE_ENUM_BINDER( Bindings, StructType, MipFilter, FilterTypeEnumMapping );
-
-
- DEFINE_ENUM_ELEMENT_MAPPING( TexAddrModeEnumMapping, TEXTURE_ADDRESS_WRAP );
- DEFINE_ENUM_ELEMENT_MAPPING( TexAddrModeEnumMapping, TEXTURE_ADDRESS_MIRROR );
- DEFINE_ENUM_ELEMENT_MAPPING( TexAddrModeEnumMapping, TEXTURE_ADDRESS_CLAMP );
- DEFINE_ENUM_ELEMENT_MAPPING( TexAddrModeEnumMapping, TEXTURE_ADDRESS_BORDER );
- DEFINE_ENUM_ELEMENT_MAPPING( TexAddrModeEnumMapping, TEXTURE_ADDRESS_MIRROR_ONCE );
- VERIFY( TexAddrModeEnumMapping.m_Str2ValMap.size() == TEXTURE_ADDRESS_NUM_MODES - 1, "Unexpected map size. Did you update TEXTURE_ADDRESS_MODE enum?" );
- VERIFY( TexAddrModeEnumMapping.m_Val2StrMap.size() == TEXTURE_ADDRESS_NUM_MODES - 1, "Unexpected map size. Did you update TEXTURE_ADDRESS_MODE enum?" );
- DEFINE_ENUM_BINDER( Bindings, StructType, AddressU, TexAddrModeEnumMapping );
- DEFINE_ENUM_BINDER( Bindings, StructType, AddressV, TexAddrModeEnumMapping );
- DEFINE_ENUM_BINDER( Bindings, StructType, AddressW, TexAddrModeEnumMapping );
-
-
- DEFINE_BINDER( Bindings, StructType, MipLODBias );
-
- using MaxAnisotropyType = decltype(StructType::MaxAnisotropy);
- Validator<MaxAnisotropyType> MaxAnisotropyValidator( "Max Anisotropy", 0, 32 );
- DEFINE_BINDER_EX( Bindings, StructType, MaxAnisotropy, MaxAnisotropyType, MaxAnisotropyValidator );
-
- DEFINE_ENUM_BINDER( Bindings, StructType, ComparisonFunc, CmpFuncEnumMapping );
-
- DEFINE_BINDER_EX( Bindings, StructType, BorderColor, RGBALoader, 0 );
-
- DEFINE_BINDER( Bindings, StructType, MinLOD );
- DEFINE_BINDER( Bindings, StructType, MaxLOD );
- }
-
- class SamplerParser final : public EngineObjectParserCommon<ISampler>
- {
- public:
- SamplerParser( IRenderDevice *pRenderDevice, lua_State *L );
- static const Char* SamplerLibName;
-
- protected:
- virtual void CreateObj( lua_State *L )override final;
-
- private:
- // SamplerDesc structure does not provide storage for the Name field.
- // We need to use ObjectDescWrapper<> to be able to store the field.
- typedef ObjectDescWrapper<SamplerDesc> SSamDescWrapper;
-
- EnumMapping<FILTER_TYPE> m_FilterTypeEnumMapping;
- EnumMapping<TEXTURE_ADDRESS_MODE> m_TexAddrModeEnumMapping;
- ComparisonFuncEnumMapping m_CmpFuncEnumMapping;
- };
-}
diff --git a/RenderScript/include/ScissorRectParser.h b/RenderScript/include/ScissorRectParser.h
deleted file mode 100644
index b904511..0000000
--- a/RenderScript/include/ScissorRectParser.h
+++ /dev/null
@@ -1,51 +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.
- */
-
-#pragma once
-
-#include "LuaWrappers.h"
-#include "LuaBindings.h"
-#include "EngineObjectParserCommon.h"
-#include "ClassMethodBinding.h"
-
-namespace Diligent
-{
- class ScissorRectParser final : public EngineObjectParserBase
- {
- public:
- ScissorRectParser( IRenderDevice *pRenderDevice, lua_State *L );
- static const Char* ScissorRectLibName;
-
- protected:
- virtual void CreateObj( lua_State *L )override final;
- virtual void DestroyObj( void *pData )override final;
- virtual void ReadField( lua_State *L, void *pData, const Char *Field )override final;
- virtual void UpdateField( lua_State *L, void *pData, const Char *Field )override final;
- virtual void PushExistingObject( lua_State *L, const void *pObject )override final;
-
- private:
- int SetScissorRects( lua_State * );
- ClassMethodCaller<ScissorRectParser> m_SetScissorRectsBinding;
- std::vector<Rect> m_ScissorRects;
- };
-}
diff --git a/RenderScript/include/ScriptParser.h b/RenderScript/include/ScriptParser.h
deleted file mode 100644
index 9e5cf79..0000000
--- a/RenderScript/include/ScriptParser.h
+++ /dev/null
@@ -1,169 +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.
- */
-
-#pragma once
-
-#include <memory>
-#include "LuaWrappers.h"
-#include "LuaFunctionBinding.h"
-#include "RenderDevice.h"
-#include "DeviceContext.h"
-#include "RefCountedObjectImpl.h"
-#include "RefCntAutoPtr.h"
-
-namespace Diligent
-{
- class ScriptParser : public RefCountedObject<IObject>
- {
- public:
- struct CombinedDrawAttribs
- {
- union
- {
- Uint32 NumVertices = 0;
- Uint32 NumIndices;
- };
- VALUE_TYPE IndexType = VT_UNDEFINED;
- DRAW_FLAGS Flags = DRAW_FLAG_NONE;
- RESOURCE_STATE_TRANSITION_MODE IndirectAttribsBufferStateTransitionMode = RESOURCE_STATE_TRANSITION_MODE_NONE;
- Uint32 NumInstances = 1;
- Uint32 BaseVertex = 0;
- Uint32 IndirectDrawArgsOffset = 0;
- union
- {
- Uint32 StartVertexLocation = 0;
- Uint32 FirstIndexLocation;
- };
- Uint32 FirstInstanceLocation = 0;
- IBuffer* pIndirectDrawAttribs = nullptr;
- };
-
- typedef RefCountedObject<IObject> TBase;
-
- ScriptParser( IReferenceCounters* pRefCounters, IRenderDevice* pRenderDevice );
- ~ScriptParser();
-
- virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface );
-
- void Parse(const Char *pScript);
-
- template<typename... ArgsType>
- void Run(IDeviceContext *pContext, const ArgsType&... Args)
- {
- lua_pushstring( m_LuaState, DeviceContextRegistryKey ); // -0 | +1 -> +1
- lua_pushlightuserdata( m_LuaState, pContext ); // -0 | +1 -> +1
- lua_settable( m_LuaState, LUA_REGISTRYINDEX ); // -2 | +0 -> -2
-
- m_RunFunctionCaller(Args...);
- }
- template<typename... ArgsType>
- void Run( RefCntAutoPtr<IDeviceContext> &pContext, const ArgsType&... Args )
- {
- Run(pContext.RawPtr(), Args... );
- }
-
- template<typename... ArgsType>
- void Run( const ArgsType&... Args )
- {
- Run( static_cast<IDeviceContext *>(nullptr), Args... );
- }
-
-
- void GetSamplerByName( const Char *SamplerName, ISampler** ppSampler );
- void GetShaderByName( const Char *ShaderName, IShader** ppShader );
- void GetBufferByName( const Char *BufferName, IBuffer** ppBuffer );
- void GetTextureByName( const Char *TextureName, ITexture** ppTexture );
- void GetResourceMappingByName( const Char *ResourceMappingName, IResourceMapping** ppResourceMapping );
- void GetTextureViewByName( const Char *TextureViewName, ITextureView** ppTextureView );
- void GetBufferViewByName( const Char *BufferViewName, IBufferView** ppTextureView );
- void GetPipelineStateByName( const Char *PSOName, IPipelineState** ppPSO );
- void GetShaderVariableByName( const Char *ShaderVarName, IShaderResourceVariable** ppShaderVar );
- void GetShaderResourceBindingByName( const Char *SRBName, IShaderResourceBinding** ppSRB );
-
- template<typename ValType>
- void SetGlobalVariable( const Char *Name, ValType Var )
- {
- m_RunFunctionCaller.PushFuncStub( m_LuaState, Var );
- lua_setglobal( m_LuaState, Name );
- }
-
- static const Char* DeviceContextRegistryKey;
-
- private:
- class SpecialPushFuncs
- {
- public:
- SpecialPushFuncs() : m_pScriptParser( nullptr ){}
- void SetScriptParser( ScriptParser *pScriptParser ){ m_pScriptParser = pScriptParser; }
-
- void PushFuncStub( lua_State *L, const ISampler* pSampler );
- void PushFuncStub( lua_State *L, const RefCntAutoPtr<ISampler> &pSampler );
- void PushFuncStub( lua_State *L, const IShader* pShader );
- void PushFuncStub( lua_State *L, const RefCntAutoPtr<IShader> &pShader );
- void PushFuncStub( lua_State *L, const IBuffer* pBuffer );
- void PushFuncStub( lua_State *L, const RefCntAutoPtr<IBuffer> &pBuffer );
- void PushFuncStub( lua_State *L, const ITexture* pTexture );
- void PushFuncStub( lua_State *L, const RefCntAutoPtr<ITexture> &pTexture );
- void PushFuncStub( lua_State *L, const struct CombinedDrawAttribs &Attribs );
- void PushFuncStub( lua_State *L, const DrawAttribs &Attribs );
- void PushFuncStub( lua_State *L, const DrawIndexedAttribs &Attribs );
- void PushFuncStub( lua_State *L, const IResourceMapping* pResourceMapping );
- void PushFuncStub( lua_State *L, const RefCntAutoPtr<IResourceMapping> &pResourceMapping );
- void PushFuncStub( lua_State *L, const ITextureView* pTextureView );
- void PushFuncStub( lua_State *L, const RefCntAutoPtr<ITextureView> &pTextureView );
- void PushFuncStub( lua_State *L, const IBufferView* pBufferView );
- void PushFuncStub( lua_State *L, const RefCntAutoPtr<IBufferView> &pBufferView );
- void PushFuncStub( lua_State *L, const IPipelineState* pPSO );
- void PushFuncStub( lua_State *L, const RefCntAutoPtr<IPipelineState> &pPSO );
- void PushFuncStub( lua_State *L, const Viewport &Viewport );
- void PushFuncStub( lua_State *L, const Rect &Rect );
- void PushFuncStub( lua_State *L, const IShaderResourceVariable* pShaderVar );
- void PushFuncStub( lua_State *L, const RefCntAutoPtr<IShaderResourceVariable> &pShaderVar );
- void PushFuncStub( lua_State *L, const IShaderResourceBinding* pShaderVar );
- void PushFuncStub( lua_State *L, const RefCntAutoPtr<IShaderResourceBinding> &pShaderVar );
-
- private:
- ScriptParser *m_pScriptParser;
- };
- LuaFunctionCaller<SpecialPushFuncs> m_RunFunctionCaller;
-
- void DefineGlobalConstants( lua_State *L );
-
- Diligent::RefCntAutoPtr<IRenderDevice> m_pRenderDevice;
- LuaState m_LuaState;
- std::unique_ptr<class SamplerParser> m_pSamplerParser;
- std::unique_ptr<class ShaderParser> m_pShaderParser;
- std::unique_ptr<class BufferParser> m_pBufferParser;
- std::unique_ptr<class TextureParser> m_pTextureParser;
- std::unique_ptr<class DrawAttribsParser> m_pDrawAttribsParser;
- std::unique_ptr<class ResourceMappingParser> m_pResourceMappingParser;
- std::unique_ptr<class TextureViewParser> m_pTextureViewParser;
- std::unique_ptr<class BufferViewParser> m_pBufferViewParser;
- std::unique_ptr<class PSODescParser> m_pPSOParser;
- std::unique_ptr<class DeviceContextFuncBindings> m_pDeviceCtxFuncBindings;
- std::unique_ptr<class ViewportParser> m_pViewportParser;
- std::unique_ptr<class ScissorRectParser> m_pScissorRectParser;
- std::unique_ptr<class ShaderVariableParser> m_pShaderVariableParser;
- std::unique_ptr<class ShaderResourceBindingParser> m_pShaderResBindingParser;
- };
-}
diff --git a/RenderScript/include/ShaderParser.h b/RenderScript/include/ShaderParser.h
deleted file mode 100644
index 9469c95..0000000
--- a/RenderScript/include/ShaderParser.h
+++ /dev/null
@@ -1,61 +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.
- */
-
-#pragma once
-
-#include "LuaWrappers.h"
-#include "LuaBindings.h"
-#include "EngineObjectParserBase.h"
-#include "ClassMethodBinding.h"
-#include "EngineObjectParserCommon.h"
-
-namespace Diligent
-{
- class ShaderParser final : public EngineObjectParserCommon<IShader>
- {
- public:
- ShaderParser( IRenderDevice *pRenderDevice, lua_State *L);
- static const Char* ShaderLibName;
-
- // ShaderCreateInfo structure does not provide storage for the Name field,
- // nor does it provide storage for FilePath.
- // We need to use ShaderCreateInfoWrapper to be able to store the data.
- struct ShaderCreateInfoWrapper : ShaderCreateInfo
- {
- String NameBuffer;
- String SourceBuffer;
- String FilePathBuffer;
- String EntryPointBuffer;
- String SearchDirectoriesBuffer;
- String CombinedSamplerSuffixBuffer;
- const char *SearchDirectories = nullptr;
- };
-
- protected:
- virtual void CreateObj( lua_State *L )override final;
- virtual void ReadField( lua_State *L, void *pData, const Char *Field )override final;
-
- private:
- EnumMapping<SHADER_SOURCE_LANGUAGE> m_ShaderSourceLangEnumMapping;
- };
-}
diff --git a/RenderScript/include/ShaderResourceBindingParser.h b/RenderScript/include/ShaderResourceBindingParser.h
deleted file mode 100644
index e56e9ff..0000000
--- a/RenderScript/include/ShaderResourceBindingParser.h
+++ /dev/null
@@ -1,73 +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.
- */
-
-#pragma once
-
-#include "LuaWrappers.h"
-#include "LuaBindings.h"
-#include "EngineObjectParserBase.h"
-#include "ClassMethodBinding.h"
-#include "EngineObjectParserCommon.h"
-
-namespace Diligent
-{
- class ShaderResourceBindingParser final : public EngineObjectParserBase
- {
- public:
- ShaderResourceBindingParser( IRenderDevice *pRenderDevice, lua_State *L,
- const String &PSOLibMetatableName,
- const String &ResMappingMetatableName,
- const String &ShaderVarMetatableRegistryName);
- static const Char* ShaderResourceBindingLibName;
-
- void GetObjectByName( lua_State *L, const Char *ShaderName, IShaderResourceBinding** ppObject );
-
- protected:
- virtual void CreateObj( lua_State *L )override final;
- virtual void DestroyObj( void *pData )override final;
- virtual void ReadField( lua_State *L, void *pData, const Char *Field )override final;
- virtual void UpdateField( lua_State *L, void *pData, const Char *Field )override final;
- virtual void PushExistingObject( lua_State *L, const void *pObject )override final;
-
- private:
- String m_PSOLibMetatableName;
- String m_ResMappingMetatableName;
- String m_ShaderVarMetatableRegistryName;
-
- BindShaderResourcesFlagEnumMapping m_BindShaderResFlagEnumMapping;
- ShaderTypeEnumMapping m_ShaderTypeEnumMapping;
-
- int BindResources( lua_State *L );
- ClassMethodCaller < ShaderResourceBindingParser > m_BindResourcesBinding;
-
- int GetVariable( lua_State *L );
- ClassMethodCaller < ShaderResourceBindingParser > m_GetVariableByNameBinding;
- ClassMethodCaller < ShaderResourceBindingParser > m_GetVariableByIndexBinding;
-
- int CreateShaderResourceBinding( lua_State *L );
- ClassMethodCaller<ShaderResourceBindingParser> m_CreateShaderResourceBinding;
-
- int InitializeStaticResources( lua_State *L );
- ClassMethodCaller < ShaderResourceBindingParser > m_InitializeStaticResourcesBinding;
- };
-}
diff --git a/RenderScript/include/ShaderVariableParser.h b/RenderScript/include/ShaderVariableParser.h
deleted file mode 100644
index eea4385..0000000
--- a/RenderScript/include/ShaderVariableParser.h
+++ /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.
- */
-
-#pragma once
-
-#include "LuaWrappers.h"
-#include "LuaBindings.h"
-#include "EngineObjectParserBase.h"
-#include "ClassMethodBinding.h"
-#include "EngineObjectParserCommon.h"
-
-namespace Diligent
-{
- class ShaderVariableParser final : public EngineObjectParserBase
- {
- public:
- ShaderVariableParser( IRenderDevice *pRenderDevice, lua_State *L,
- const String &PSOLibMetatableName,
- const String &BufferLibMetatableName,
- const String &BufferViewLibMetatableName,
- const String &TexViewMetatableName );
- static const Char* ShaderVariableLibName;
-
- void GetObjectByName( lua_State *L, const Char *ShaderName, IShaderResourceVariable** ppObject );
-
- protected:
- virtual void CreateObj( lua_State *L )override final;
- virtual void DestroyObj( void *pData )override final;
- virtual void ReadField( lua_State *L, void *pData, const Char *Field )override final;
- virtual void UpdateField( lua_State *L, void *pData, const Char *Field )override final;
- virtual void PushExistingObject( lua_State *L, const void *pObject )override final;
-
- private:
- const String m_PSOLibMetatableName;
- const String m_BufferLibMetatableName;
- const String m_BufferViewLibMetatableName;
- const String m_TexViewMetatableName;
-
- ShaderTypeEnumMapping m_ShaderTypeEnumMapping;
-
- int Set( lua_State *L );
- ClassMethodCaller < ShaderVariableParser > m_SetBinding;
-
- ClassMethodCaller<ShaderVariableParser> m_GetStaticVariableByNameBinding;
- int GetStaticVariableByName( lua_State *L );
-
- ClassMethodCaller<ShaderVariableParser> m_GetStaticVariableByIndexBinding;
- int GetStaticVariableByIndex( lua_State *L );
- };
-}
diff --git a/RenderScript/include/TextureParser.h b/RenderScript/include/TextureParser.h
deleted file mode 100644
index fb6d2dd..0000000
--- a/RenderScript/include/TextureParser.h
+++ /dev/null
@@ -1,61 +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.
- */
-
-#pragma once
-
-#include "LuaWrappers.h"
-#include "LuaBindings.h"
-#include "EngineObjectParserCommon.h"
-#include "ClassMethodBinding.h"
-
-namespace Diligent
-{
- class TextureParser final : public EngineObjectParserCommon<ITexture>
- {
- public:
- TextureParser( IRenderDevice *pRenderDevice, lua_State *L );
- static const Char* TextureLibName;
-
- protected:
- virtual void CreateObj( lua_State *L )override final;
-
- private:
- // TextureDesc structure does not provide storage for the Name field.
- // We need to use ObjectDescWrapper<> to be able to store the field.
- typedef ObjectDescWrapper<TextureDesc> STexDescWrapper;
-
- ResourceDimEnumMapping m_TexTypeEnumMapping;
- TextureFormatEnumMapping m_TexFormatEnumMapping;
-
- // Note that different bind flags are allowed for different objects,
- // so we need to populate this enum with values suitable for textures only
- EnumMapping<Diligent::BIND_FLAGS> m_BindFlagEnumMapping;
- // Explicit namespace declaraion is necesseary to avoid
- // name conflicts when building for windows store
-
- EnumMapping<Diligent::MISC_TEXTURE_FLAGS> m_MiscFlagEnumMapping;
-
- UsageEnumMapping m_UsageEnumMapping;
- CpuAccessFlagEnumMapping m_CpuAccessFlagEnumMapping;
- };
-}
diff --git a/RenderScript/include/TextureViewParser.h b/RenderScript/include/TextureViewParser.h
deleted file mode 100644
index 732aaaa..0000000
--- a/RenderScript/include/TextureViewParser.h
+++ /dev/null
@@ -1,65 +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.
- */
-
-#pragma once
-
-#include "LuaWrappers.h"
-#include "LuaBindings.h"
-#include "EngineObjectParserCommon.h"
-#include "ClassMethodBinding.h"
-
-namespace Diligent
-{
- class TextureViewParser final : public EngineObjectParserCommon<ITextureView>
- {
- public:
- TextureViewParser( class TextureParser *pTexParser, class SamplerParser *pSamplerParser, IRenderDevice *pRenderDevice, lua_State *L );
- static const Char *TextureViewLibName;
-
- protected:
- virtual void CreateObj( lua_State *L )override final;
-
- private:
- // TextureViewDesc structure does not provide storage for the Name field.
- // We need to use ObjectDescWrapper<> to be able to store the field.
- typedef ObjectDescWrapper<TextureViewDesc> STexViewDescWrapper;
-
- const String m_TextureLibMetatableName;
- const String m_SamplerLibMetatableName;
-
- ClassMethodCaller<TextureViewParser> m_CreateViewBinding;
- int CreateView( lua_State *L );
-
- ClassMethodCaller<TextureViewParser> m_GetDefaultViewBinding;
- int GetDefaultView( lua_State * );
-
- ClassMethodCaller<TextureViewParser> m_SetSamplerBinding;
- int SetSampler( lua_State * );
-
- EnumMapping<TEXTURE_VIEW_TYPE> m_ViewTypeEnumMapping;
- ResourceDimEnumMapping m_TexTypeEnumMapping;
- TextureFormatEnumMapping m_TexFormatEnumMapping;
- EnumMemberBinder<TEXTURE_VIEW_TYPE> m_ViewTypeParser;
- EnumMapping<UAV_ACCESS_FLAG> m_UAVAccessFlagEnumMapping;
- };
-}
diff --git a/RenderScript/include/ViewportParser.h b/RenderScript/include/ViewportParser.h
deleted file mode 100644
index ed76f76..0000000
--- a/RenderScript/include/ViewportParser.h
+++ /dev/null
@@ -1,51 +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.
- */
-
-#pragma once
-
-#include "LuaWrappers.h"
-#include "LuaBindings.h"
-#include "EngineObjectParserCommon.h"
-#include "ClassMethodBinding.h"
-
-namespace Diligent
-{
- class ViewportParser final : public EngineObjectParserBase
- {
- public:
- ViewportParser( IRenderDevice *pRenderDevice, lua_State *L );
- static const Char* ViewportLibName;
-
- protected:
- virtual void CreateObj( lua_State *L )override final;
- virtual void DestroyObj( void *pData )override final;
- virtual void ReadField( lua_State *L, void *pData, const Char *Field )override final;
- virtual void UpdateField( lua_State *L, void *pData, const Char *Field )override final;
- virtual void PushExistingObject( lua_State *L, const void *pObject )override final;
-
- private:
- int SetViewports( lua_State * );
- ClassMethodCaller<ViewportParser> m_SetViewportsBinding;
- std::vector<Viewport> m_Viewports;
- };
-}
diff --git a/RenderScript/include/pch.h b/RenderScript/include/pch.h
deleted file mode 100644
index 8695248..0000000
--- a/RenderScript/include/pch.h
+++ /dev/null
@@ -1,49 +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.
- */
-
-// stdafx.h : include file for standard system include files,
-// or project specific include files that are used frequently, but
-// are changed infrequently
-//
-
-#pragma once
-
-#include <algorithm>
-#include <unordered_map>
-#include <memory>
-
-#include "lua.h"
-#include "lualib.h"
-#include "lauxlib.h"
-
-#include "BasicTypes.h"
-#include "ParsingErrors.h"
-#include "Errors.h"
-
-#include "RefCntAutoPtr.h"
-#include "RenderDevice.h"
-#include "DeviceContext.h"
-
-#include "LuaWrappers.h"
-#include "Debug.h"
-#include "DebugUtilities.h"
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"
-