From 8c14255393ca877bb82914ce6ac568fdc6092599 Mon Sep 17 00:00:00 2001 From: assiduous Date: Thu, 24 Dec 2020 21:48:54 -0800 Subject: D3D12 and Vk backends: few minor code improvements --- .../include/ShaderResourceLayoutVk.hpp | 47 ++++++++++------------ .../src/PipelineStateVkImpl.cpp | 3 +- .../src/ShaderResourceLayoutVk.cpp | 20 +++------ 3 files changed, 27 insertions(+), 43 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.hpp b/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.hpp index 171d2047..2df3aaa3 100644 --- a/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.hpp +++ b/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.hpp @@ -206,37 +206,32 @@ public: #endif // clang-format on - VkResource(const ShaderResourceLayoutVk& _ParentLayout, - const char* _Name, - Uint16 _ArraySize, - ResourceType _Type, - RESOURCE_DIMENSION _ResourceDim, - bool _IsMS, - SHADER_RESOURCE_VARIABLE_TYPE _VariableType, - uint32_t _Binding, - uint32_t _DescriptorSet, - Uint32 _CacheOffset, - Uint32 _SamplerInd, - bool _ImmutableSamplerAssigned, - Uint32 _BufferStaticSize, - Uint32 _BufferStride) noexcept : + VkResource(const ShaderResourceLayoutVk& _ParentLayout, + const char* _Name, + const SPIRVShaderResourceAttribs& _Attribs, + SHADER_RESOURCE_VARIABLE_TYPE _VariableType, + uint32_t _Binding, + uint32_t _DescriptorSet, + Uint32 _CacheOffset, + Uint32 _SamplerInd, + bool _ImmutableSamplerAssigned) noexcept : // clang-format off Binding {static_cast(_Binding) }, DescriptorSet {static_cast(_DescriptorSet)}, - CacheOffset {_CacheOffset }, - SamplerInd {_SamplerInd }, - VariableType {_VariableType }, + CacheOffset {_CacheOffset }, + SamplerInd {_SamplerInd }, + VariableType {_VariableType}, ImmutableSamplerAssigned {_ImmutableSamplerAssigned ? 1U : 0U}, - ArraySize {_ArraySize }, - Type {_Type }, - ResourceDim {_ResourceDim }, - IsMS {_IsMS ? Uint8{1} : Uint8{0}}, + ArraySize {_Attribs.ArraySize }, + Type {_Attribs.Type }, + ResourceDim {_Attribs.ResourceDim}, + IsMS {_Attribs.IsMS }, #ifdef DILIGENT_DEVELOPMENT - BufferStaticSize {_BufferStaticSize}, - BufferStride {_BufferStride }, + BufferStaticSize {_Attribs.BufferStaticSize}, + BufferStride {_Attribs.BufferStride }, #endif - Name {_Name }, - ParentResLayout {_ParentLayout } + Name {_Name }, + ParentResLayout {_ParentLayout} // clang-format on { #if defined(_MSC_VER) && defined(_WIN64) && !defined(DILIGENT_DEVELOPMENT) @@ -248,7 +243,7 @@ public: VERIFY(_Binding <= std::numeric_limits::max(), "Binding (", _Binding, ") exceeds max representable value ", std::numeric_limits::max() ); VERIFY(_DescriptorSet <= std::numeric_limits::max(), "Descriptor set (", _DescriptorSet, ") exceeds max representable value ", std::numeric_limits::max()); VERIFY(_VariableType < (1 << VariableTypeBits), "Variable type (", Uint32{_VariableType}, ") exceeds max representable value ", (1 << VariableTypeBits) ); - VERIFY(_ResourceDim < (1 << ResourceDimBits), "Resource dimension (", Uint32{_ResourceDim}, ") exceeds max representable value ", (1 << ResourceDimBits) ); + VERIFY(_Attribs.ResourceDim < (1 << ResourceDimBits), "Resource dimension (", Uint32{_Attribs.ResourceDim}, ") exceeds max representable value ", (1 << ResourceDimBits) ); // clang-format on } diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp index 5d52dd86..35ef4240 100644 --- a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp @@ -756,8 +756,7 @@ PipelineStateVkImpl::PipelineStateVkImpl(IReferenceCounters* { try { - const auto& LogicalDevice = pDeviceVk->GetLogicalDevice(); - const auto ShaderGroupHandleSize = pDeviceVk->GetProperties().ShaderGroupHandleSize; + const auto& LogicalDevice = pDeviceVk->GetLogicalDevice(); std::vector vkShaderStages; std::vector ShaderModules; diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp index 1700c492..c85c194a 100644 --- a/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp +++ b/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp @@ -377,18 +377,13 @@ void ShaderResourceLayoutVk::InitializeStaticResourceLayout(const std::vector= 0, - Attribs.BufferStaticSize, - Attribs.BufferStride // + SrcImmutableSamplerInd >= 0 // }; } else @@ -667,18 +662,13 @@ void ShaderResourceLayoutVk::Initialize(IRenderDevice* pRende { ResLayout, stringPools[ShaderStageInd].CopyString(Attribs.Name), - Attribs.ArraySize, - Attribs.Type, - Attribs.GetResourceDimension(), - Attribs.IsMultisample(), + Attribs, VarType, Binding, DescriptorSet, CacheOffset, SamplerInd, - vkImmutableSampler != VK_NULL_HANDLE, - Attribs.BufferStaticSize, - Attribs.BufferStride // + vkImmutableSampler != VK_NULL_HANDLE // }; } else @@ -1322,7 +1312,7 @@ void ShaderResourceLayoutVk::InitializeStaticResources(const ShaderResourceLayou if (DstRes.Type == SPIRVShaderResourceAttribs::ResourceType::SeparateSampler && DstRes.IsImmutableSamplerAssigned()) - continue; // Skip immutable samplers + continue; // Skip immutable separate samplers for (Uint32 ArrInd = 0; ArrInd < DstRes.ArraySize; ++ArrInd) { -- cgit v1.2.3