diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-03-06 06:05:17 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-03-06 06:05:17 +0000 |
| commit | 772ef0e6cfbb218814ad4e7d25dd94b697a6b4f3 (patch) | |
| tree | cc60120d48012dc8cd45e27d5f39931bae751d0b /Graphics | |
| parent | Keep fixing metal back-end (diff) | |
| download | DiligentCore-772ef0e6cfbb218814ad4e7d25dd94b697a6b4f3.tar.gz DiligentCore-772ef0e6cfbb218814ad4e7d25dd94b697a6b4f3.zip | |
Keep fixing Metal backend + few other minor changes
Diffstat (limited to 'Graphics')
7 files changed, 19 insertions, 10 deletions
diff --git a/Graphics/GLSLTools/include/SPIRVShaderResources.h b/Graphics/GLSLTools/include/SPIRVShaderResources.h index 523ccc29..b117c05a 100644 --- a/Graphics/GLSLTools/include/SPIRVShaderResources.h +++ b/Graphics/GLSLTools/include/SPIRVShaderResources.h @@ -28,8 +28,8 @@ // SPIRVShaderResources class uses continuous chunk of memory to store all resources, as follows: // -// m_MemoryBuffer m_TotalResources -// | | +// m_MemoryBuffer m_TotalResources end of names data may not be aligned +// | | | // | Uniform Buffers | Storage Buffers | Storage Images | Sampled Images | Atomic Counters | Separate Samplers | Separate Images | Stage Inputs | Resource Names | #include <memory> @@ -333,6 +333,8 @@ private: // Memory buffer that holds all resources as continuous chunk of memory: // | UBs | SBs | StrgImgs | SmplImgs | ACs | SepSamplers | SepImgs | Stage Inputs | Resource Names | + // | + // end of names data may not be aligned std::unique_ptr< void, STDDeleterRawMem<void> > m_MemoryBuffer; StringPool m_ResourceNames; diff --git a/Graphics/GLSLTools/src/SPIRVShaderResources.cpp b/Graphics/GLSLTools/src/SPIRVShaderResources.cpp index 7289e9fd..82743cfd 100644 --- a/Graphics/GLSLTools/src/SPIRVShaderResources.cpp +++ b/Graphics/GLSLTools/src/SPIRVShaderResources.cpp @@ -28,6 +28,7 @@ #include "ShaderBase.h" #include "GraphicsAccessories.h" #include "StringTools.h" +#include "Align.h" namespace Diligent { @@ -439,10 +440,12 @@ void SPIRVShaderResources::Initialize(IMemoryAllocator& Allocator, VERIFY(NumShaderStageInputs <= MaxOffset, "Max offset exceeded"); m_NumShaderStageInputs = static_cast<OffsetType>(NumShaderStageInputs); + auto AlignedResourceNamesPoolSize = Align(ResourceNamesPoolSize, sizeof(void*)); + static_assert(sizeof(SPIRVShaderResourceAttribs) % sizeof(void*) == 0, "Size of SPIRVShaderResourceAttribs struct must be multiple of sizeof(void*)"); - auto MemorySize = m_TotalResources * sizeof(SPIRVShaderResourceAttribs) + - m_NumShaderStageInputs * sizeof(SPIRVShaderStageInputAttribs) + - ResourceNamesPoolSize * sizeof(char); + auto MemorySize = m_TotalResources * sizeof(SPIRVShaderResourceAttribs) + + m_NumShaderStageInputs * sizeof(SPIRVShaderStageInputAttribs) + + AlignedResourceNamesPoolSize * sizeof(char); VERIFY_EXPR(GetNumUBs() == Counters.NumUBs); VERIFY_EXPR(GetNumSBs() == Counters.NumSBs); diff --git a/Graphics/GraphicsEngine/interface/Shader.h b/Graphics/GraphicsEngine/interface/Shader.h index d6c07629..efd4acb1 100644 --- a/Graphics/GraphicsEngine/interface/Shader.h +++ b/Graphics/GraphicsEngine/interface/Shader.h @@ -190,7 +190,7 @@ struct ShaderCreateInfo }; /// Describes shader resource type -enum SHADER_RESOURCE_TYPE +enum SHADER_RESOURCE_TYPE : Uint8 { /// Shader resource type is unknown SHADER_RESOURCE_TYPE_UNKNOWN = 0, diff --git a/Graphics/GraphicsEngineD3DBase/include/ShaderResources.h b/Graphics/GraphicsEngineD3DBase/include/ShaderResources.h index f8f6917b..e12049e4 100644 --- a/Graphics/GraphicsEngineD3DBase/include/ShaderResources.h +++ b/Graphics/GraphicsEngineD3DBase/include/ShaderResources.h @@ -399,6 +399,9 @@ private: // Memory buffer that holds all resources as continuous chunk of memory: // | CBs | TexSRVs | TexUAVs | BufSRVs | BufUAVs | Samplers | Resource Names | + // | + // end of names data may not be aligned + std::unique_ptr< void, STDDeleterRawMem<void> > m_MemoryBuffer; StringPool m_ResourceNames; diff --git a/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp b/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp index a3efe9f3..c52b2cee 100644 --- a/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp +++ b/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp @@ -27,6 +27,7 @@ #include "ShaderResources.h" #include "HashUtils.h" #include "ShaderResourceVariableBase.h" +#include "Align.h" namespace Diligent { @@ -74,7 +75,8 @@ void ShaderResources::AllocateMemory(IMemoryAllocator& Allocator, m_SamplersOffset = AdvanceOffset(ResCounters.NumSamplers); m_TotalResources = AdvanceOffset(0); - auto MemorySize = m_TotalResources * sizeof(D3DShaderResourceAttribs) + ResourceNamesPoolSize * sizeof(char); + auto AlignedResourceNamesPoolSize = Align(ResourceNamesPoolSize, sizeof(void*)); + auto MemorySize = m_TotalResources * sizeof(D3DShaderResourceAttribs) + AlignedResourceNamesPoolSize * sizeof(char); VERIFY_EXPR(GetNumCBs() == ResCounters.NumCBs); VERIFY_EXPR(GetNumTexSRV() == ResCounters.NumTexSRVs); diff --git a/Graphics/GraphicsEngineMetal/include/ShaderResourceBindingMtlImpl.h b/Graphics/GraphicsEngineMetal/include/ShaderResourceBindingMtlImpl.h index 95642031..89431cee 100644 --- a/Graphics/GraphicsEngineMetal/include/ShaderResourceBindingMtlImpl.h +++ b/Graphics/GraphicsEngineMetal/include/ShaderResourceBindingMtlImpl.h @@ -50,11 +50,11 @@ public: virtual void BindResources(Uint32 ShaderFlags, IResourceMapping* pResMapping, Uint32 Flags)override final; - virtual IShaderVariable* GetVariable(SHADER_TYPE ShaderType, const char *Name)override final; + virtual IShaderResourceVariable* GetVariable(SHADER_TYPE ShaderType, const char *Name)override final; virtual Uint32 GetVariableCount(SHADER_TYPE ShaderType) const override final; - virtual IShaderVariable* GetVariable(SHADER_TYPE ShaderType, Uint32 Index)override final; + virtual IShaderResourceVariable* GetVariable(SHADER_TYPE ShaderType, Uint32 Index)override final; virtual void InitializeStaticResources(const IPipelineState* pPipelineState)override final; diff --git a/Graphics/GraphicsEngineMetal/src/DeviceContextMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/DeviceContextMtlImpl.mm index 93532ab0..c861002b 100644 --- a/Graphics/GraphicsEngineMetal/src/DeviceContextMtlImpl.mm +++ b/Graphics/GraphicsEngineMetal/src/DeviceContextMtlImpl.mm @@ -30,7 +30,6 @@ #include "PipelineStateMtlImpl.h" #include "SwapChainMtl.h" #include "ShaderResourceBindingMtlImpl.h" -#include "EngineMtlAttribs.h" #include "CommandListMtlImpl.h" #include "RenderDeviceMtlImpl.h" #include "FenceMtlImpl.h" |
