From 91dbc2c143a371bf0584e6c6a3cd2feb16535f8b Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sat, 2 Mar 2019 23:01:28 -0800 Subject: Reworked ShaderResourcesD3D11 to comply with the updated API --- .../include/ShaderResourcesD3D11.h | 8 ---- .../src/ShaderResourcesD3D11.cpp | 51 ++-------------------- 2 files changed, 3 insertions(+), 56 deletions(-) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderResourcesD3D11.h b/Graphics/GraphicsEngineD3D11/include/ShaderResourcesD3D11.h index da8d4a34..a241b486 100644 --- a/Graphics/GraphicsEngineD3D11/include/ShaderResourcesD3D11.h +++ b/Graphics/GraphicsEngineD3D11/include/ShaderResourcesD3D11.h @@ -113,8 +113,6 @@ public: const Char* GetShaderName() const { return m_ShaderName; } - void SetStaticSamplers(class ShaderResourceCacheD3D11& ResourceCache)const; - private: using MaxBindPointType = Int8; @@ -132,12 +130,6 @@ private: // ShaderResourcesD3D11 is part of the ShaderD3D11Impl object, so we can simply // reference shader name without the need to copy it const Char* const m_ShaderName; - - using StaticSamplerAttribs = std::pair>; - using StaticSamplerVector = std::vector>; - void InitStaticSamplers(StaticSamplerVector&& StaticSamplers); - - StaticSamplerVector m_StaticSamplers; }; } diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp index af72e1a0..78dfcf63 100755 --- a/Graphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp @@ -38,8 +38,7 @@ ShaderResourcesD3D11::ShaderResourcesD3D11(RenderDeviceD3D11Impl* pDeviceD3D11Im const ShaderDesc& ShdrDesc, const char* CombinedSamplerSuffix) : ShaderResources(ShdrDesc.ShaderType), - m_ShaderName(ShdrDesc.Name), - m_StaticSamplers(STD_ALLOCATOR_RAW_MEM(StaticSamplerAttribs, GetRawAllocator(), "Allocator for vector")) + m_ShaderName(ShdrDesc.Name) { class NewResourceHandler { @@ -51,8 +50,7 @@ ShaderResourcesD3D11::ShaderResourcesD3D11(RenderDeviceD3D11Impl* pDeviceD3D11Im pDeviceD3D11Impl (_pDeviceD3D11Impl), ShdrDesc (_ShdrDesc), CombinedSamplerSuffix(_CombinedSamplerSuffix), - Resources (_Resources), - m_StaticSamplers (STD_ALLOCATOR_RAW_MEM(StaticSamplerAttribs, GetRawAllocator(), "Allocator for vector")) + Resources (_Resources) {} void OnNewCB(const D3DShaderResourceAttribs& CBAttribs) @@ -83,24 +81,6 @@ ShaderResourcesD3D11::ShaderResourcesD3D11(RenderDeviceD3D11Impl* pDeviceD3D11Im { VERIFY( SamplerAttribs.BindPoint + SamplerAttribs.BindCount-1 <= MaxAllowedBindPoint, "Sampler bind point exceeds supported range" ); Resources.m_MaxSamplerBindPoint = std::max(Resources.m_MaxSamplerBindPoint, static_cast(SamplerAttribs.BindPoint + SamplerAttribs.BindCount-1)); - - if (SamplerAttribs.IsStaticSampler()) - { - // Find attributes of this static sampler - Uint32 ssd = 0; - for (; ssd < ShdrDesc.NumStaticSamplers; ++ssd) - { - const auto& StaticSamplerDesc = ShdrDesc.StaticSamplers[ssd]; - if (StreqSuff(SamplerAttribs.Name, StaticSamplerDesc.SamplerOrTextureName, CombinedSamplerSuffix)) - { - RefCntAutoPtr pSampler; - pDeviceD3D11Impl->CreateSampler(StaticSamplerDesc.Desc, &pSampler); - m_StaticSamplers.emplace_back(SamplerAttribs, std::move(pSampler)); - break; - } - } - VERIFY(ssd < ShdrDesc.NumStaticSamplers, "Unable to find sampler '", SamplerAttribs.Name, "' in the list of static samplers. This should never happen and likely indicates a bug in static sampler enumeration code."); - } } void OnNewTexSRV(const D3DShaderResourceAttribs& TexAttribs) @@ -111,7 +91,6 @@ ShaderResourcesD3D11::ShaderResourcesD3D11(RenderDeviceD3D11Impl* pDeviceD3D11Im ~NewResourceHandler() { - Resources.InitStaticSamplers(std::move(m_StaticSamplers)); } private: @@ -119,42 +98,20 @@ ShaderResourcesD3D11::ShaderResourcesD3D11(RenderDeviceD3D11Impl* pDeviceD3D11Im const ShaderDesc& ShdrDesc; const char* CombinedSamplerSuffix; ShaderResourcesD3D11& Resources; - - StaticSamplerVector m_StaticSamplers; }; Initialize( pShaderBytecode, NewResourceHandler{pDeviceD3D11Impl, ShdrDesc, CombinedSamplerSuffix, *this}, - ShdrDesc, + ShdrDesc.Name, CombinedSamplerSuffix); } -void ShaderResourcesD3D11::InitStaticSamplers(StaticSamplerVector&& StaticSamplers) -{ - m_StaticSamplers.reserve(StaticSamplers.size()); - for(auto& Sam : StaticSamplers) - m_StaticSamplers.emplace_back(std::move(Sam)); -} ShaderResourcesD3D11::~ShaderResourcesD3D11() { } -void ShaderResourcesD3D11::SetStaticSamplers(ShaderResourceCacheD3D11& ResourceCache)const -{ - auto NumCachedSamplers = ResourceCache.GetSamplerCount(); - for (const auto& SS : m_StaticSamplers) - { - const auto& SamAttribs = SS.first; - VERIFY_EXPR(SamAttribs.IsStaticSampler()); - auto* pSamplerD3D11Impl = const_cast(SS.second.RawPtr()); - // Limiting EndBindPoint is required when initializing static samplers in a Shader's static cache - auto EndBindPoint = std::min( static_cast(SamAttribs.BindPoint) + SamAttribs.BindCount, NumCachedSamplers); - for(Uint32 BindPoint = SamAttribs.BindPoint; BindPoint < EndBindPoint; ++BindPoint ) - ResourceCache.SetSampler(BindPoint, pSamplerD3D11Impl); - } -} #ifdef DEVELOPMENT static String DbgMakeResourceName(const D3DShaderResourceAttribs& Attr, Uint32 BindPoint) @@ -188,8 +145,6 @@ void ShaderResourcesD3D11::dvpVerifyCommittedResources(ID3D11Buffer* ResourceCache.GetUAVArrays (CachedUAVResources, d3d11UAVs); ProcessResources( - nullptr, 0, - [&](const D3DShaderResourceAttribs& cb, Uint32) { for (auto BindPoint = cb.BindPoint; BindPoint < cb.BindPoint + cb.BindCount; ++BindPoint) -- cgit v1.2.3