From 5e3941de79b573b8798f6a6bcd4eaf544c48cde2 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sun, 12 Nov 2017 19:18:57 -0800 Subject: Updated to version 2.1 --- RenderScript/include/ConvenienceFunctions.h | 4 ++-- RenderScript/include/ScriptParser.h | 6 ++++-- RenderScript/include/ShaderParser.h | 1 + RenderScript/include/pch.h | 2 +- RenderScript/src/BufferParser.cpp | 8 ++++---- RenderScript/src/DrawAttribsParser.cpp | 32 +++++++++++++++++++++++++++++ RenderScript/src/ScissorRectParser.cpp | 2 +- RenderScript/src/ScriptParser.cpp | 3 ++- RenderScript/src/ShaderParser.cpp | 4 ++-- RenderScript/src/ViewportParser.cpp | 2 +- 10 files changed, 50 insertions(+), 14 deletions(-) (limited to 'RenderScript') diff --git a/RenderScript/include/ConvenienceFunctions.h b/RenderScript/include/ConvenienceFunctions.h index 334f4c9..01bcdf4 100644 --- a/RenderScript/include/ConvenienceFunctions.h +++ b/RenderScript/include/ConvenienceFunctions.h @@ -52,7 +52,7 @@ Diligent::RefCntAutoPtr CreateRenderScriptFromFile( cons Diligent::FileWrapper ScriptFile(FilePath); if( !ScriptFile ) LOG_ERROR_AND_THROW( "Failed to open Lua source file" ); - Diligent::RefCntAutoPtr pFileData( new Diligent::DataBlobImpl ); + Diligent::RefCntAutoPtr pFileData( Diligent::MakeNewRCObj()(0) ); ScriptFile->Read( pFileData ); // Null-terminator is not read from the stream @@ -60,7 +60,7 @@ Diligent::RefCntAutoPtr CreateRenderScriptFromFile( cons auto *ScriptText = reinterpret_cast(pFileData->GetDataPtr()); ScriptText[pFileData->GetSize() - 1] = 0; - pScriptParser = new Diligent::ScriptParser( pRenderDevice ); + pScriptParser = Diligent::MakeNewRCObj()( pRenderDevice ); pScriptParser->Parse( ScriptText ); SetGlobalVars( pScriptParser ); pScriptParser->Run( pContext ); diff --git a/RenderScript/include/ScriptParser.h b/RenderScript/include/ScriptParser.h index 828a945..137f0fd 100644 --- a/RenderScript/include/ScriptParser.h +++ b/RenderScript/include/ScriptParser.h @@ -33,10 +33,12 @@ namespace Diligent { - class ScriptParser : public Diligent::RefCountedObject + class ScriptParser : public RefCountedObject { public: - ScriptParser( IRenderDevice *pRenderDevice ); + typedef RefCountedObject TBase; + + ScriptParser( IReferenceCounters *pRefCounters, IRenderDevice *pRenderDevice ); ~ScriptParser(); virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ); diff --git a/RenderScript/include/ShaderParser.h b/RenderScript/include/ShaderParser.h index a1df356..b827def 100644 --- a/RenderScript/include/ShaderParser.h +++ b/RenderScript/include/ShaderParser.h @@ -52,6 +52,7 @@ namespace Diligent String FilePathBuffer; String EntryPointBuffer; String SearchDirectoriesBuffer; + const char *SearchDirectories = nullptr; std::vector m_VarDescBuffer; std::vector m_VarNamesBuffer; std::vector m_StaticSamplersBuffer; diff --git a/RenderScript/include/pch.h b/RenderScript/include/pch.h index eec1e6d..ffe6b1c 100644 --- a/RenderScript/include/pch.h +++ b/RenderScript/include/pch.h @@ -37,8 +37,8 @@ #include "lauxlib.h" #include "BasicTypes.h" -#include "Errors.h" #include "ParsingErrors.h" +#include "Errors.h" #include "RefCntAutoPtr.h" #include "RenderDevice.h" diff --git a/RenderScript/src/BufferParser.cpp b/RenderScript/src/BufferParser.cpp index 92cbc2e..40cda67 100644 --- a/RenderScript/src/BufferParser.cpp +++ b/RenderScript/src/BufferParser.cpp @@ -83,7 +83,7 @@ namespace Diligent DEFINE_FLAGS_BINDER( m_Bindings, SBuffDescWrapper, CPUAccessFlags, CPU_ACCESS_FLAG, m_CpuAccessFlagEnumMapping ); DEFINE_ENUM_ELEMENT_MAPPING( m_BuffModeEnumMapping, BUFFER_MODE_UNDEFINED ); - DEFINE_ENUM_ELEMENT_MAPPING( m_BuffModeEnumMapping, BUFFER_MODE_FORMATED ); + DEFINE_ENUM_ELEMENT_MAPPING( m_BuffModeEnumMapping, BUFFER_MODE_FORMATTED ); DEFINE_ENUM_ELEMENT_MAPPING( m_BuffModeEnumMapping, BUFFER_MODE_STRUCTURED ); static_assert(BUFFER_MODE_NUM_MODES == BUFFER_MODE_STRUCTURED + 1, "Not all buffer modes initialized."); VERIFY( m_BuffModeEnumMapping.m_Str2ValMap.size() == BUFFER_MODE_NUM_MODES, @@ -106,11 +106,11 @@ namespace Diligent ParseLuaTable( L, 1, &BufferDesc, m_Bindings ); CHECK_LUA_STACK_HEIGHT(); - if( BufferDesc.Mode == BUFFER_MODE_FORMATED ) + if( BufferDesc.Mode == BUFFER_MODE_FORMATTED ) { auto &BuffFmt = BufferDesc.Format; if( BuffFmt.ValueType == VT_UNDEFINED || BuffFmt.NumComponents == 0 ) - SCRIPT_PARSING_ERROR( L, "Valid format must be specified for a formated buffer" ); + SCRIPT_PARSING_ERROR( L, "Valid format must be specified for a formatted buffer" ); auto FmtSize = GetValueSize( BuffFmt.ValueType ) * BuffFmt.NumComponents; if( BufferDesc.ElementByteStride != 0 ) { @@ -128,7 +128,7 @@ namespace Diligent if( BufferDesc.Mode == BUFFER_MODE_STRUCTURED && BufferDesc.ElementByteStride == 0 ) SCRIPT_PARSING_ERROR( L, "UAV element byte stride of a structured buffer cannot be zero" ); - if( (BufferDesc.Mode == BUFFER_MODE_FORMATED || BufferDesc.Mode == BUFFER_MODE_STRUCTURED) && + if( (BufferDesc.Mode == BUFFER_MODE_FORMATTED || BufferDesc.Mode == BUFFER_MODE_STRUCTURED) && (BufferDesc.uiSizeInBytes % BufferDesc.ElementByteStride) != 0 ) SCRIPT_PARSING_ERROR( L, "Buffer size (", BufferDesc.uiSizeInBytes, ") is not multiple of element byte stride (", BufferDesc.ElementByteStride, ")." ); diff --git a/RenderScript/src/DrawAttribsParser.cpp b/RenderScript/src/DrawAttribsParser.cpp index f1be965..fd55c14 100644 --- a/RenderScript/src/DrawAttribsParser.cpp +++ b/RenderScript/src/DrawAttribsParser.cpp @@ -39,6 +39,38 @@ namespace Diligent DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ); DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_POINT_LIST ); DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_LINE_LIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST ); + DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST ); VERIFY( m_PrimTopologyEnumMapping.m_Str2ValMap.size() == PRIMITIVE_TOPOLOGY_NUM_TOPOLOGIES - 1, "Unexpected map size. Did you update PRIMITIVE_TOPOLOGY enum?" ); VERIFY( m_PrimTopologyEnumMapping.m_Val2StrMap.size() == PRIMITIVE_TOPOLOGY_NUM_TOPOLOGIES - 1, diff --git a/RenderScript/src/ScissorRectParser.cpp b/RenderScript/src/ScissorRectParser.cpp index ecc60a8..a36036d 100644 --- a/RenderScript/src/ScissorRectParser.cpp +++ b/RenderScript/src/ScissorRectParser.cpp @@ -108,7 +108,7 @@ namespace Diligent } } - if( RTWidth == 0 && RTHeight != 0 || RTWidth != 0 && RTHeight == 0 ) + if( (RTWidth == 0 && RTHeight != 0) || (RTWidth != 0 && RTHeight == 0) ) SCRIPT_PARSING_ERROR( L, "Render target size is incomplete (", RTWidth, "x", RTHeight, "). Use either 0x0 or fully specified size" ); Uint32 NumScissorRects = static_cast( m_ScissorRects.size() ); diff --git a/RenderScript/src/ScriptParser.cpp b/RenderScript/src/ScriptParser.cpp index 8f23f8d..8e65d75 100644 --- a/RenderScript/src/ScriptParser.cpp +++ b/RenderScript/src/ScriptParser.cpp @@ -85,7 +85,8 @@ namespace Diligent m_pScriptParser->m_pScissorRectParser->PushObject( L, &Rect ); } - ScriptParser::ScriptParser( IRenderDevice *pRenderDevice ) : + ScriptParser::ScriptParser( IReferenceCounters *pRefCounters, IRenderDevice *pRenderDevice ) : + TBase(pRefCounters), m_pRenderDevice( pRenderDevice ), m_LuaState( LuaState::LUA_LIB_BASE | LuaState::LUA_LIB_COROUTINE | LuaState::LUA_LIB_TABLE | LuaState::LUA_LIB_STRING | LuaState::LUA_LIB_BIT32 | LuaState::LUA_LIB_MATH ) diff --git a/RenderScript/src/ShaderParser.cpp b/RenderScript/src/ShaderParser.cpp index 10416e2..12d9157 100644 --- a/RenderScript/src/ShaderParser.cpp +++ b/RenderScript/src/ShaderParser.cpp @@ -86,7 +86,7 @@ namespace Diligent ); } - virtual void SetValue( lua_State *L, int Index, void* pBasePointer ) + virtual void SetValue( lua_State *L, int Index, void* pBasePointer )override { auto &ShaderVarDescBuffer = GetMemberByOffest>( pBasePointer, m_VarDescBufferOffset); auto &ShaderNamesBuffer = GetMemberByOffest>( pBasePointer, m_VarNamesBufferOffset); @@ -191,7 +191,7 @@ namespace Diligent ); } - virtual void SetValue( lua_State *L, int Index, void* pBasePointer ) + virtual void SetValue( lua_State *L, int Index, void* pBasePointer )override { auto &StaticSamplersBuffer = GetMemberByOffest>( pBasePointer, m_StaticSamplersBufferOffset); auto &StaticSamplerTexNamesBuffer = GetMemberByOffest>( pBasePointer, m_StaticSamplerTexNamesBufferOffset); diff --git a/RenderScript/src/ViewportParser.cpp b/RenderScript/src/ViewportParser.cpp index 3f4dc06..555baa3 100644 --- a/RenderScript/src/ViewportParser.cpp +++ b/RenderScript/src/ViewportParser.cpp @@ -117,7 +117,7 @@ namespace Diligent } } - if( RTWidth == 0 && RTHeight != 0 || RTWidth != 0 && RTHeight == 0 ) + if( (RTWidth == 0 && RTHeight != 0) || (RTWidth != 0 && RTHeight == 0) ) SCRIPT_PARSING_ERROR( L, "Render target size is incomplete (", RTWidth, "x", RTHeight, "). Use either 0x0 or fully specified size" ); Uint32 NumViewports = static_cast( m_Viewports.size() ); -- cgit v1.2.3