diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2016-08-20 06:38:41 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2016-08-20 06:38:41 +0000 |
| commit | 8077ddaf62bdbff2169973eca565a5752501587d (patch) | |
| tree | 0532180e74cf5215736fd4e053216e291326fbcb /RenderScript/include | |
| parent | One more update to android build configuration (diff) | |
| download | DiligentTools-8077ddaf62bdbff2169973eca565a5752501587d.tar.gz DiligentTools-8077ddaf62bdbff2169973eca565a5752501587d.zip | |
Updated to Diligent Engine 2.0
Diffstat (limited to 'RenderScript/include')
30 files changed, 324 insertions, 142 deletions
diff --git a/RenderScript/include/BlendStateDescParser.h b/RenderScript/include/BlendStateDescParser.h new file mode 100644 index 0000000..59f5664 --- /dev/null +++ b/RenderScript/include/BlendStateDescParser.h @@ -0,0 +1,41 @@ +/* Copyright 2015-2016 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "PipelineState.h" +#include "LuaBindings.h" + +namespace Diligent +{ + template<> + class MemberBinder<BlendStateDesc> : 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; + }; +} diff --git a/RenderScript/include/BufferParser.h b/RenderScript/include/BufferParser.h index e9a6053..e375d19 100644 --- a/RenderScript/include/BufferParser.h +++ b/RenderScript/include/BufferParser.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/RenderScript/include/BufferViewParser.h b/RenderScript/include/BufferViewParser.h index a1b003d..03e6b10 100644 --- a/RenderScript/include/BufferViewParser.h +++ b/RenderScript/include/BufferViewParser.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/RenderScript/include/ClassMethodBinding.h b/RenderScript/include/ClassMethodBinding.h index 90c4259..141261a 100644 --- a/RenderScript/include/ClassMethodBinding.h +++ b/RenderScript/include/ClassMethodBinding.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/RenderScript/include/ConvenienceFunctions.h b/RenderScript/include/ConvenienceFunctions.h index 2a4df13..23a08f4 100644 --- a/RenderScript/include/ConvenienceFunctions.h +++ b/RenderScript/include/ConvenienceFunctions.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,9 @@ #include "ScriptParser.h" #include "DataBlobImpl.h" #ifdef _WIN32 -# define NOMINMAX +# ifndef NOMINMAX +# define NOMINMAX +# endif # include <Windows.h> #endif @@ -39,7 +41,7 @@ Diligent::RefCntAutoPtr<Diligent::ScriptParser> CreateRenderScriptFromFile( cons { bool bSuccess = true; Diligent::RefCntAutoPtr<Diligent::ScriptParser> pScriptParser; -#ifdef PLATFORM_WINDOWS +#ifdef PLATFORM_WIN32 do { #endif @@ -69,7 +71,7 @@ Diligent::RefCntAutoPtr<Diligent::ScriptParser> CreateRenderScriptFromFile( cons ErrorMsg = err.what(); } -#ifdef PLATFORM_WINDOWS +#ifdef PLATFORM_WIN32 if( !bSuccess ) { if( IDRETRY != MessageBoxA( NULL, "Failed to parse the script. Retry?", "Lua parser error", MB_ICONERROR | MB_ABORTRETRYIGNORE ) ) diff --git a/RenderScript/include/Debug.h b/RenderScript/include/Debug.h index bd22bfb..cd19f10 100644 --- a/RenderScript/include/Debug.h +++ b/RenderScript/include/Debug.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/RenderScript/include/DepthStencilStateParser.h b/RenderScript/include/DepthStencilStateDescParser.h index fb0f2cb..340d05e 100644 --- a/RenderScript/include/DepthStencilStateParser.h +++ b/RenderScript/include/DepthStencilStateDescParser.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,30 +23,21 @@ #pragma once -#include "LuaWrappers.h" +#include "PipelineState.h" #include "LuaBindings.h" -#include "EngineObjectParserCommon.h" -#include "ClassMethodBinding.h" +#include "EnumMappings.h" namespace Diligent { - class DepthStencilStateParser : public EngineObjectParserCommon<IDepthStencilState> + template<> + class MemberBinder<DepthStencilStateDesc> : public MemberBinderBase { public: - DepthStencilStateParser( IRenderDevice *pRenderDevice, lua_State *L ); - static const Char* DepthStencilStateLibName; - - protected: - virtual void CreateObj( lua_State *L ); - + 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: - // DepthStencilStateDesc structure does not provide storage for the Name field. - // We need to use ObjectDescWrapper<> to be able to store the field. - typedef ObjectDescWrapper<DepthStencilStateDesc> SDSSDescWrapper; - - int SetDepthStencilState( lua_State *L ); - ClassMethodCaller<DepthStencilStateParser> m_SetDepthStencilBinding; - + BindingsMapType m_Bindings; ComparisonFuncEnumMapping m_CmpFuncEnumMapping; }; } diff --git a/RenderScript/include/DeviceContextFuncBindings.h b/RenderScript/include/DeviceContextFuncBindings.h index bb2f880..a03c3f0 100644 --- a/RenderScript/include/DeviceContextFuncBindings.h +++ b/RenderScript/include/DeviceContextFuncBindings.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,12 +27,17 @@ #include "LuaBindings.h" #include "ClassMethodBinding.h" +namespace std +{ + DEFINE_ENUM_HASH( Diligent::COMMIT_SHADER_RESOURCES_FLAG ) +} + namespace Diligent { class DeviceContextFuncBindings { public: - DeviceContextFuncBindings( IRenderDevice *pRenderDevice, lua_State *L, class TextureViewParser *pTexViewPasrser ); + DeviceContextFuncBindings( IRenderDevice *pRenderDevice, lua_State *L, class TextureViewParser *pTexViewPasrser, class ShaderResourceBindingParser *pSRBParser, class PSODescParser *pPSOParser ); private: int SetRenderTargets( lua_State * ); @@ -44,6 +49,22 @@ namespace Diligent 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; + + EnumMapping<COMMIT_SHADER_RESOURCES_FLAG> m_CommitShaderResFlagsEnumMapping; + String m_TexViewMetatableName; + String m_ShaderResBindingMetatableName; + String m_PSOMetatableName; }; } diff --git a/RenderScript/include/DrawAttribsParser.h b/RenderScript/include/DrawAttribsParser.h index 0b855ac..88da020 100644 --- a/RenderScript/include/DrawAttribsParser.h +++ b/RenderScript/include/DrawAttribsParser.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/RenderScript/include/EngineObjectParserBase.h b/RenderScript/include/EngineObjectParserBase.h index 55c0baa..7e0265c 100644 --- a/RenderScript/include/EngineObjectParserBase.h +++ b/RenderScript/include/EngineObjectParserBase.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/RenderScript/include/EngineObjectParserCommon.h b/RenderScript/include/EngineObjectParserCommon.h index ba55e21..dfef174 100644 --- a/RenderScript/include/EngineObjectParserCommon.h +++ b/RenderScript/include/EngineObjectParserCommon.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/RenderScript/include/EnumMappings.h b/RenderScript/include/EnumMappings.h index 6b61161..bc8c76c 100644 --- a/RenderScript/include/EnumMappings.h +++ b/RenderScript/include/EnumMappings.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ template<>struct hash<Type> \ namespace std { - DEFINE_ENUM_HASH( Diligent::TEXTURE_TYPE ) + DEFINE_ENUM_HASH( Diligent::RESOURCE_DIMENSION ) DEFINE_ENUM_HASH( Diligent::TEXTURE_FORMAT ) DEFINE_ENUM_HASH( Diligent::VALUE_TYPE ) DEFINE_ENUM_HASH( Diligent::USAGE ) @@ -46,6 +46,7 @@ namespace std DEFINE_ENUM_HASH( Diligent::CPU_ACCESS_FLAG ) DEFINE_ENUM_HASH( Diligent::COMPARISON_FUNCTION ) DEFINE_ENUM_HASH( Diligent::BIND_SHADER_RESOURCES_FLAGS ) + DEFINE_ENUM_HASH( Diligent::SHADER_TYPE ) } namespace Diligent @@ -82,10 +83,10 @@ namespace Diligent TextureFormatEnumMapping(); }; - class TextureTypeEnumMapping : public EnumMapping < Diligent::TEXTURE_TYPE > + class ResourceDimEnumMapping : public EnumMapping < Diligent::RESOURCE_DIMENSION > { public: - TextureTypeEnumMapping(); + ResourceDimEnumMapping(); }; class ValueTypeEnumMapping : public EnumMapping < Diligent::VALUE_TYPE > @@ -105,4 +106,10 @@ namespace Diligent public: BindShaderResourcesFlagEnumMapping(); }; + + class ShaderTypeEnumMapping : public EnumMapping<SHADER_TYPE> + { + public: + ShaderTypeEnumMapping(); + }; } diff --git a/RenderScript/include/LayoutDescParser.h b/RenderScript/include/InputLayoutDescParser.h index 62d32dd..2da56ca 100644 --- a/RenderScript/include/LayoutDescParser.h +++ b/RenderScript/include/InputLayoutDescParser.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,31 +25,27 @@ #include "LuaWrappers.h" #include "LuaBindings.h" -#include "EngineObjectParserCommon.h" -#include "ClassMethodBinding.h" + +namespace std +{ + DEFINE_ENUM_HASH( Diligent::LayoutElement::FREQUENCY ) +} namespace Diligent { - class LayoutDescParser : public EngineObjectParserCommon<IVertexDescription> + template<> + class MemberBinder<InputLayoutDesc> : public MemberBinderBase { public: - LayoutDescParser( IRenderDevice *pRenderDevice, lua_State *L ); - static const Char* LayoutDescLibName; - - protected: - virtual void CreateObj( lua_State *L ); - + 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: - // LayoutDesc structure does not provide storage for the Name field, - // nor does it provide storage for layout elements. - // We need to use LayoutDescWrapper to be able to store the data. - struct LayoutDescWrapper : ObjectDescWrapper < LayoutDesc > - { - std::vector<LayoutElement> ElementsBuffer; - }; - - - int SetInputLayout( lua_State *L ); - ClassMethodCaller<LayoutDescParser> m_SetInputLayoutBinding; + 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 index b9dcace..2799bd1 100644 --- a/RenderScript/include/LuaBindings.h +++ b/RenderScript/include/LuaBindings.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -226,7 +226,8 @@ namespace Diligent }; - inline void ParseLuaTable( lua_State *L, int Index, void* pBasePointer, BindingsMapType &Bindings ) + template<typename TableElementParser> + inline void ParseLuaTable( lua_State *L, int Index, void* pBasePointer, TableElementParser ElemParser ) { CheckType( L, Index, LUA_TTABLE ); @@ -248,20 +249,31 @@ namespace Diligent // 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 ); - auto Binding = Bindings.find( Key ); - if( Binding != Bindings.end() ) - { - Binding->second->SetValue( L, -1, pBasePointer ); - } - else - { - SCRIPT_PARSING_ERROR( L, "Unknown Member ", Key ); - } + 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 ) { @@ -326,7 +338,7 @@ namespace Diligent } else { - SCRIPT_PARSING_ERROR( L, "Unknown Member ", Field ); + SCRIPT_PARSING_ERROR( L, "Unknown Member \"", Field, '\"' ); } } @@ -339,7 +351,7 @@ namespace Diligent } else { - SCRIPT_PARSING_ERROR( L, "Unknown Member ", Field ); + SCRIPT_PARSING_ERROR( L, "Unknown Member \"", Field, '\"' ); } } @@ -413,7 +425,7 @@ namespace Diligent } else { - UNEXPECTED( "Enum value not found in the map" ); + UNEXPECTED( "Enum value (", Val, ") not found in the map" ); SCRIPT_PARSING_ERROR( L, "Enum value (", Val, ") not found in the map" ); } } @@ -584,14 +596,21 @@ namespace Diligent VERIFY( Metatables.size() == 1, "Ambiguous metatable" ); const auto& MetatableName = *Metatables.begin(); auto pObject = GetMemberByOffest<ObjectType*>( pBasePointer, m_MemberOffset ); - 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 + 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 ) diff --git a/RenderScript/include/LuaFunctionBinding.h b/RenderScript/include/LuaFunctionBinding.h index a51a7b9..863becd 100644 --- a/RenderScript/include/LuaFunctionBinding.h +++ b/RenderScript/include/LuaFunctionBinding.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/RenderScript/include/LuaWrappers.h b/RenderScript/include/LuaWrappers.h index 6e17a65..bf7d653 100644 --- a/RenderScript/include/LuaWrappers.h +++ b/RenderScript/include/LuaWrappers.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/RenderScript/include/BlendStateParser.h b/RenderScript/include/PSODescParser.h index 9589488..01d8fc8 100644 --- a/RenderScript/include/BlendStateParser.h +++ b/RenderScript/include/PSODescParser.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,25 +27,30 @@ #include "LuaBindings.h" #include "EngineObjectParserCommon.h" #include "ClassMethodBinding.h" - +#include "PipelineState.h" namespace Diligent { - class BlendStateParser : public EngineObjectParserCommon<IBlendState> + class PSODescParser : public EngineObjectParserCommon<IPipelineState> { public: - BlendStateParser( IRenderDevice *pRenderDevice, lua_State *L ); - static const Char* BlendStateLibName; + PSODescParser( IRenderDevice *pRenderDevice, lua_State *L ); + static const Char* PSODescLibName; protected: virtual void CreateObj( lua_State *L ); private: - // BlendStateDesc structure does not provide storage for the Name field. + // PipelineStateDesc structure does not provide storage for the Name field. // We need to use ObjectDescWrapper<> to be able to store the field. - typedef ObjectDescWrapper<BlendStateDesc> SBSDescWrapper; + struct PSODescWrapper : PipelineStateDesc + { + String NameBuffer; + std::vector<LayoutElement> LayoutElementsBuffer; + }; + friend class MemberBinder<GraphicsPipelineDesc>; - int SetBlendState( lua_State *L ); - ClassMethodCaller<BlendStateParser> m_SetBlendBinding; + int SetPSO( lua_State *L ); + ClassMethodCaller<PSODescParser> m_SetPSOBinding; }; } diff --git a/RenderScript/include/ParsingErrors.h b/RenderScript/include/ParsingErrors.h index 5b7f860..8ca794b 100644 --- a/RenderScript/include/ParsingErrors.h +++ b/RenderScript/include/ParsingErrors.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/RenderScript/include/RasterizerStateParser.h b/RenderScript/include/RasterizerStateDescParser.h index 22ab5e9..78a0023 100644 --- a/RenderScript/include/RasterizerStateParser.h +++ b/RenderScript/include/RasterizerStateDescParser.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,11 +23,8 @@ #pragma once -#include "LuaWrappers.h" +#include "PipelineState.h" #include "LuaBindings.h" -#include "EngineObjectParserCommon.h" -#include "ClassMethodBinding.h" - namespace std { @@ -37,22 +34,15 @@ namespace std namespace Diligent { - class RasterizerStateParser : public EngineObjectParserCommon<IRasterizerState> + template<> + class MemberBinder<RasterizerStateDesc> : public MemberBinderBase { public: - RasterizerStateParser( IRenderDevice *pRenderDevice, lua_State *L ); - static const Char* RasterizerStateLibName; - - protected: - virtual void CreateObj( lua_State *L ); - + 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: - // RasterizerStateDesc structure does not provide storage for the Name field. - // We need to use ObjectDescWrapper<> to be able to store the field. - typedef ObjectDescWrapper<RasterizerStateDesc> SRSDescWrapper; - - int SetRasterizerState( lua_State *L ); - ClassMethodCaller<RasterizerStateParser> m_SetRasterizerBinding; + 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 index d191647..8be5f0a 100644 --- a/RenderScript/include/ResourceMappingParser.h +++ b/RenderScript/include/ResourceMappingParser.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,9 +50,6 @@ namespace Diligent virtual void PushExistingObject( lua_State *L, const void *pObject ); virtual void DestroyObj( void *pData ); - int BindShaderResources( lua_State *L ); - ClassMethodCaller < ResourceMappingParser > m_BindShaderResourcesBinding; - BindingsMapType m_Bindings; TextureViewParser *m_pTexViewParser; diff --git a/RenderScript/include/SamplerParser.h b/RenderScript/include/SamplerParser.h index 5829067..c3f0eb6 100644 --- a/RenderScript/include/SamplerParser.h +++ b/RenderScript/include/SamplerParser.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +37,57 @@ namespace std 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, FILTER_TYPE, FilterTypeEnumMapping ) + DEFINE_ENUM_BINDER( Bindings, StructType, MagFilter, FILTER_TYPE, FilterTypeEnumMapping ) + DEFINE_ENUM_BINDER( Bindings, StructType, MipFilter, FILTER_TYPE, 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, TEXTURE_ADDRESS_MODE, TexAddrModeEnumMapping ) + DEFINE_ENUM_BINDER( Bindings, StructType, AddressV, TEXTURE_ADDRESS_MODE, TexAddrModeEnumMapping ) + DEFINE_ENUM_BINDER( Bindings, StructType, AddressW, TEXTURE_ADDRESS_MODE, TexAddrModeEnumMapping ) + + + Validator<Float32> DummyValidatorF( SkipValidationFunc<float> ); + DEFINE_BINDER( Bindings, StructType, MipLODBias, Float32, DummyValidatorF ) + + Validator<Uint32> MaxAnisotropyValidator( "Max Anisotropy", 0, 32 ); + DEFINE_BINDER( Bindings, StructType, MaxAnisotropy, Uint32, MaxAnisotropyValidator ) + + DEFINE_ENUM_BINDER( Bindings, StructType, ComparisonFunc, COMPARISON_FUNCTION, CmpFuncEnumMapping ) + + DEFINE_BINDER( Bindings, StructType, BorderColor, RGBALoader, 0 ) + + DEFINE_BINDER( Bindings, StructType, MinLOD, Float32, DummyValidatorF ) + DEFINE_BINDER( Bindings, StructType, MaxLOD, Float32, DummyValidatorF ) + } + class SamplerParser : public EngineObjectParserCommon<ISampler> { public: diff --git a/RenderScript/include/ScissorRectParser.h b/RenderScript/include/ScissorRectParser.h index b887afc..e33544b 100644 --- a/RenderScript/include/ScissorRectParser.h +++ b/RenderScript/include/ScissorRectParser.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/RenderScript/include/ScriptParser.h b/RenderScript/include/ScriptParser.h index 8c960d8..93d47d1 100644 --- a/RenderScript/include/ScriptParser.h +++ b/RenderScript/include/ScriptParser.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,16 +66,13 @@ namespace Diligent void GetSamplerByName( const Char *SamplerName, ISampler** ppSampler ); - void GetVertexDescriptionByName( const Char *VertDescName, IVertexDescription** ppVertDesc ); 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 GetDepthStencilStateByName( const Char *DSStateName, IDepthStencilState** ppDSState ); - void GetRasterizerStateByName( const Char *RSName, IRasterizerState** ppRS ); - void GetBlendStateByName( const Char *BSName, IBlendState** ppRS ); + void GetPipelineStateByName( const Char *PSOName, IPipelineState** ppPSO ); void GetShaderVariableByName( const Char *ShaderVarName, IShaderVariable** ppShaderVar ); template<typename ValType> @@ -96,8 +93,6 @@ namespace Diligent void PushFuncStub( lua_State *L, const ISampler* pSampler ); void PushFuncStub( lua_State *L, const RefCntAutoPtr<ISampler> &pSampler ); - void PushFuncStub( lua_State *L, const IVertexDescription* pVertDesc ); - void PushFuncStub( lua_State *L, const RefCntAutoPtr<IVertexDescription> &pVertDesc ); 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 ); @@ -111,16 +106,14 @@ namespace Diligent 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 IDepthStencilState* pDSState ); - void PushFuncStub( lua_State *L, const RefCntAutoPtr<IDepthStencilState> &pDSState ); - void PushFuncStub( lua_State *L, const IRasterizerState* pRS ); - void PushFuncStub( lua_State *L, const RefCntAutoPtr<IRasterizerState> &pRS ); - void PushFuncStub( lua_State *L, const IBlendState* pBS ); - void PushFuncStub( lua_State *L, const RefCntAutoPtr<IBlendState> &pBS ); + 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 IShaderVariable* pShaderVar ); void PushFuncStub( lua_State *L, const RefCntAutoPtr<IShaderVariable> &pShaderVar ); + void PushFuncStub( lua_State *L, const IShaderResourceBinding* pShaderVar ); + void PushFuncStub( lua_State *L, const RefCntAutoPtr<IShaderResourceBinding> &pShaderVar ); private: ScriptParser *m_pScriptParser; @@ -132,7 +125,6 @@ namespace Diligent Diligent::RefCntAutoPtr<IRenderDevice> m_pRenderDevice; LuaState m_LuaState; std::unique_ptr<class SamplerParser> m_pSamplerParser; - std::unique_ptr<class LayoutDescParser> m_pLayoutDescParser; std::unique_ptr<class ShaderParser> m_pShaderParser; std::unique_ptr<class BufferParser> m_pBufferParser; std::unique_ptr<class TextureParser> m_pTextureParser; @@ -140,12 +132,11 @@ namespace Diligent 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 DepthStencilStateParser> m_pDSStateParser; - std::unique_ptr<class RasterizerStateParser> m_pRSParser; - std::unique_ptr<class BlendStateParser> m_pBSParser; + 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 index 2967dd5..fdfb3da 100644 --- a/RenderScript/include/ShaderParser.h +++ b/RenderScript/include/ShaderParser.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,9 +48,14 @@ namespace Diligent struct ShaderCreationAttribsWrapper : ShaderCreationAttribs { String NameBuffer; + String SourceBuffer; String FilePathBuffer; String EntryPointBuffer; String SearchDirectoriesBuffer; + std::vector<ShaderVariableDesc> m_VarDescBuffer; + std::vector<String> m_VarNamesBuffer; + std::vector<StaticSamplerDesc> m_StaticSamplersBuffer; + std::vector<String> m_StaticSamplerTexNamesBuffer; }; protected: @@ -59,9 +64,6 @@ namespace Diligent private: - int SetShaders( lua_State *L ); - ClassMethodCaller < ShaderParser > m_SetShadersBinding; - ClassMethodCaller< ShaderParser > m_BindResourcesBinding; int BindResources( lua_State *L ); diff --git a/RenderScript/include/ShaderResourceBindingParser.h b/RenderScript/include/ShaderResourceBindingParser.h new file mode 100644 index 0000000..281ac54 --- /dev/null +++ b/RenderScript/include/ShaderResourceBindingParser.h @@ -0,0 +1,69 @@ +/* Copyright 2015-2016 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "LuaWrappers.h" +#include "LuaBindings.h" +#include "EngineObjectParserBase.h" +#include "ClassMethodBinding.h" +#include "EngineObjectParserCommon.h" + +namespace Diligent +{ + class ShaderResourceBindingParser : public EngineObjectParserBase + { + public: + ShaderResourceBindingParser( IRenderDevice *pRenderDevice, lua_State *L, + const String &PSOLibMetatableName, + const String &ResMappingMetatableName, + const String &ShaderVarMetatableRegistryName); + static const Char* ShaderResourceBindingLibName; + + virtual void GetObjectByName( lua_State *L, const Char *ShaderName, IShaderResourceBinding** ppObject ); + + protected: + virtual void CreateObj( lua_State *L ); + virtual void DestroyObj( void *pData ); + virtual void ReadField( lua_State *L, void *pData, const Char *Field ); + virtual void UpdateField( lua_State *L, void *pData, const Char *Field ); + virtual void PushExistingObject( lua_State *L, const void *pObject ); + + 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_GetVariableBinding; + + int CreateShaderResourceBinding( lua_State *L ); + ClassMethodCaller<ShaderResourceBindingParser> m_CreateShaderResourceBinding; + }; +} diff --git a/RenderScript/include/ShaderVariableParser.h b/RenderScript/include/ShaderVariableParser.h index 5263e16..5641939 100644 --- a/RenderScript/include/ShaderVariableParser.h +++ b/RenderScript/include/ShaderVariableParser.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/RenderScript/include/TextureParser.h b/RenderScript/include/TextureParser.h index d6eb6a0..20aea0e 100644 --- a/RenderScript/include/TextureParser.h +++ b/RenderScript/include/TextureParser.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ namespace Diligent // We need to use ObjectDescWrapper<> to be able to store the field. typedef ObjectDescWrapper<TextureDesc> STexDescWrapper; - TextureTypeEnumMapping m_TexTypeEnumMapping; + ResourceDimEnumMapping m_TexTypeEnumMapping; TextureFormatEnumMapping m_TexFormatEnumMapping; // Note that different bind flags are allowed for different objects, diff --git a/RenderScript/include/TextureViewParser.h b/RenderScript/include/TextureViewParser.h index c97f28a..3ea135e 100644 --- a/RenderScript/include/TextureViewParser.h +++ b/RenderScript/include/TextureViewParser.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,7 +63,7 @@ namespace Diligent int SetSampler( lua_State * ); EnumMapping<TEXTURE_VIEW_TYPE> m_ViewTypeEnumMapping; - TextureTypeEnumMapping m_TexTypeEnumMapping; + 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 index 86cfaa0..9633f5e 100644 --- a/RenderScript/include/ViewportParser.h +++ b/RenderScript/include/ViewportParser.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/RenderScript/include/pch.h b/RenderScript/include/pch.h index 9bb451f..86aa6a5 100644 --- a/RenderScript/include/pch.h +++ b/RenderScript/include/pch.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. |
