From a0488c54c6c5017c71198d8b13c9ed75894791de Mon Sep 17 00:00:00 2001 From: azhirnov Date: Wed, 16 Sep 2020 22:41:57 +0300 Subject: use NUM_SHADER_TYPES constant instead of magic number, use std::array instead of c-style array. --- Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.hpp | 3 --- Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.hpp | 2 +- Graphics/GraphicsEngineD3D12/include/RootSignature.hpp | 4 ++-- .../GraphicsEngineD3D12/include/ShaderResourceBindingD3D12Impl.hpp | 6 +++--- Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp | 1 + 5 files changed, 7 insertions(+), 9 deletions(-) (limited to 'Graphics/GraphicsEngineD3D12') diff --git a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.hpp index e14903dd..91c1610a 100644 --- a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.hpp @@ -260,9 +260,6 @@ public: /// Implementation of IDeviceContextD3D12::ID3D12GraphicsCommandList() in Direct3D12 backend. virtual ID3D12GraphicsCommandList* DILIGENT_CALL_TYPE GetD3D12CommandList() override final; - ///// Number of different shader types (Vertex, Pixel, Geometry, Domain, Hull, Compute) - //static constexpr int NumShaderTypes = 6; - void UpdateBufferRegion(class BufferD3D12Impl* pBuffD3D12, D3D12DynamicAllocation& Allocation, Uint64 DstOffset, diff --git a/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.hpp index 7e5b5fdd..b4d2fce9 100644 --- a/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.hpp @@ -129,7 +129,7 @@ private: ShaderResourceCacheD3D12* m_pStaticResourceCaches = nullptr; ShaderVariableManagerD3D12* m_pStaticVarManagers = nullptr; // Resource layout index in m_ResourceLayouts[] array for every shader stage - Int8 m_ResourceLayoutIndex[6] = {-1, -1, -1, -1, -1, -1}; + std::array m_ResourceLayoutIndex; }; } // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D12/include/RootSignature.hpp b/Graphics/GraphicsEngineD3D12/include/RootSignature.hpp index a3bc8d11..c62c8198 100644 --- a/Graphics/GraphicsEngineD3D12/include/RootSignature.hpp +++ b/Graphics/GraphicsEngineD3D12/include/RootSignature.hpp @@ -474,9 +474,9 @@ private: // in m_RootParams (NOT the Root Index!), for every variable type // (static, mutable, dynamic) and every shader type, // or -1, if the table is not yet assigned to the combination - std::array m_SrvCbvUavRootTablesMap; + std::array m_SrvCbvUavRootTablesMap; // This array contains the same data for Sampler root table - std::array m_SamplerRootTablesMap; + std::array m_SamplerRootTablesMap; RootParamsManager m_RootParams; diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderResourceBindingD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/ShaderResourceBindingD3D12Impl.hpp index 09854e17..7c83ddbf 100644 --- a/Graphics/GraphicsEngineD3D12/include/ShaderResourceBindingD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/ShaderResourceBindingD3D12Impl.hpp @@ -80,9 +80,9 @@ private: ShaderResourceCacheD3D12 m_ShaderResourceCache; ShaderVariableManagerD3D12* m_pShaderVarMgrs = nullptr; // Resource layout index in m_ResourceLayouts[] array for every shader stage - Int8 m_ResourceLayoutIndex[6] = {-1, -1, -1, -1, -1, -1}; - bool m_bStaticResourcesInitialized = false; - const Uint8 m_NumShaders = 0; + std::array m_ResourceLayoutIndex; + bool m_bStaticResourcesInitialized = false; + const Uint8 m_NumShaders = 0; }; } // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp index 19ad36bc..94d65cda 100644 --- a/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp @@ -48,6 +48,7 @@ ShaderResourceBindingD3D12Impl::ShaderResourceBindingD3D12Impl(IReferenceCounter m_NumShaders {static_cast(pPSO->GetNumShaders())} // clang-format on { + m_ResourceLayoutIndex.fill(-1); auto* ppShaders = pPSO->GetShaders(); auto* pRenderDeviceD3D12Impl = ValidatedCast(pPSO->GetDevice()); -- cgit v1.2.3