diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2019-12-12 23:16:42 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2019-12-12 23:16:42 +0000 |
| commit | d9ff664e3d796f9526ed29b7a1066b3d3fb443b1 (patch) | |
| tree | bc94032e85347cdd26cc4c3c67d288bcfa9ef540 /RenderScript/include | |
| parent | appveyor: swithced to VS2019 and enabled tests (diff) | |
| download | DiligentTools-d9ff664e3d796f9526ed29b7a1066b3d3fb443b1.tar.gz DiligentTools-d9ff664e3d796f9526ed29b7a1066b3d3fb443b1.zip | |
Removed RenderScript and lua
Diffstat (limited to 'RenderScript/include')
30 files changed, 0 insertions, 2670 deletions
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" |
