From 045a5c0260f47f0dbd9c0367a647e3781fb9f342 Mon Sep 17 00:00:00 2001 From: assiduous Date: Tue, 16 Feb 2021 17:15:58 -0800 Subject: Few updates to D3D12 resource signature --- Graphics/GraphicsEngine/include/BufferViewBase.hpp | 2 +- .../include/PipelineResourceSignatureBase.hpp | 32 ++++++++++++---------- Graphics/GraphicsEngine/interface/BufferView.h | 2 +- 3 files changed, 19 insertions(+), 17 deletions(-) (limited to 'Graphics/GraphicsEngine') diff --git a/Graphics/GraphicsEngine/include/BufferViewBase.hpp b/Graphics/GraphicsEngine/include/BufferViewBase.hpp index d9e12988..21b917e5 100644 --- a/Graphics/GraphicsEngine/include/BufferViewBase.hpp +++ b/Graphics/GraphicsEngine/include/BufferViewBase.hpp @@ -76,7 +76,7 @@ public: IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_BufferView, TDeviceObjectBase) /// Implementation of IBufferView::GetBuffer() - virtual IBuffer* DILIGENT_CALL_TYPE GetBuffer() override final + virtual IBuffer* DILIGENT_CALL_TYPE GetBuffer() const override final { return m_pBuffer; } diff --git a/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp b/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp index a49d354c..9f5b6cdc 100644 --- a/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp +++ b/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp @@ -153,12 +153,10 @@ protected: for (Uint32 i = 0; i < Desc.NumImmutableSamplers; ++i) { - VERIFY(Desc.ImmutableSamplers[i].SamplerOrTextureName != nullptr, - "SamplerOrTextureName can't be null. This error should've been caught by ValidatePipelineResourceSignatureDesc()."); - VERIFY(Desc.ImmutableSamplers[i].SamplerOrTextureName[0] != '\0', - "SamplerOrTextureName can't be empty. This error should've been caught by ValidatePipelineResourceSignatureDesc()."); - - Allocator.AddSpaceForString(Desc.ImmutableSamplers[i].SamplerOrTextureName); + const auto* SamOrTexName = Desc.ImmutableSamplers[i].SamplerOrTextureName; + VERIFY(SamOrTexName != nullptr, "SamplerOrTextureName can't be null. This error should've been caught by ValidatePipelineResourceSignatureDesc()."); + VERIFY(SamOrTexName[0] != '\0', "SamplerOrTextureName can't be empty. This error should've been caught by ValidatePipelineResourceSignatureDesc()."); + Allocator.AddSpaceForString(SamOrTexName); } if (Desc.UseCombinedTextureSamplers) @@ -172,12 +170,14 @@ protected: for (Uint32 i = 0; i < Desc.NumResources; ++i) { - auto& Dst = pResources[i]; - Dst = Desc.Resources[i]; - VERIFY_EXPR(Desc.Resources[i].Name != nullptr && Desc.Resources[i].Name[0] != '\0'); - Dst.Name = Allocator.CopyString(Desc.Resources[i].Name); + const auto& SrcRes = Desc.Resources[i]; + auto& DstRes = pResources[i]; + + DstRes = SrcRes; + VERIFY_EXPR(SrcRes.Name != nullptr && SrcRes.Name[0] != '\0'); + DstRes.Name = Allocator.CopyString(SrcRes.Name); - ++m_ResourceOffsets[Dst.VarType + 1]; + ++m_ResourceOffsets[DstRes.VarType + 1]; } // Sort resources by variable type (all static -> all mutable -> all dynamic) @@ -201,10 +201,12 @@ protected: for (Uint32 i = 0; i < Desc.NumImmutableSamplers; ++i) { - auto& Dst = pSamplers[i]; - Dst = Desc.ImmutableSamplers[i]; - VERIFY_EXPR(Desc.ImmutableSamplers[i].SamplerOrTextureName != nullptr && Desc.ImmutableSamplers[i].SamplerOrTextureName[0] != '\0'); - Dst.SamplerOrTextureName = Allocator.CopyString(Desc.ImmutableSamplers[i].SamplerOrTextureName); + const auto& SrcSam = Desc.ImmutableSamplers[i]; + auto& DstSam = pSamplers[i]; + + DstSam = SrcSam; + VERIFY_EXPR(SrcSam.SamplerOrTextureName != nullptr && SrcSam.SamplerOrTextureName[0] != '\0'); + DstSam.SamplerOrTextureName = Allocator.CopyString(SrcSam.SamplerOrTextureName); } this->m_Desc.Resources = pResources; diff --git a/Graphics/GraphicsEngine/interface/BufferView.h b/Graphics/GraphicsEngine/interface/BufferView.h index fa5df537..412397ae 100644 --- a/Graphics/GraphicsEngine/interface/BufferView.h +++ b/Graphics/GraphicsEngine/interface/BufferView.h @@ -163,7 +163,7 @@ DILIGENT_BEGIN_INTERFACE(IBufferView, IDeviceObject) /// The method does *NOT* call AddRef() on the returned interface, /// so Release() must not be called. - VIRTUAL struct IBuffer* METHOD(GetBuffer)(THIS) PURE; + VIRTUAL struct IBuffer* METHOD(GetBuffer)(THIS) CONST PURE; }; DILIGENT_END_INTERFACE -- cgit v1.2.3