diff options
Diffstat (limited to 'source/slang/parameter-binding.cpp')
| -rw-r--r-- | source/slang/parameter-binding.cpp | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/source/slang/parameter-binding.cpp b/source/slang/parameter-binding.cpp index f0256164c..dda3a8621 100644 --- a/source/slang/parameter-binding.cpp +++ b/source/slang/parameter-binding.cpp @@ -2345,7 +2345,6 @@ struct ScopeLayoutBuilder LayoutRulesImpl* m_rules = nullptr; RefPtr<StructTypeLayout> m_structLayout; UniformLayoutInfo m_structLayoutInfo; - bool m_needConstantBuffer = false; void beginLayout( ParameterBindingContext* context) @@ -2367,8 +2366,6 @@ struct ScopeLayoutBuilder LayoutSize uniformSize = layoutInfo ? layoutInfo->count : 0; if( uniformSize != 0 ) { - m_needConstantBuffer = true; - // Make sure uniform fields get laid out properly... UniformLayoutInfo fieldInfo( @@ -2424,25 +2421,25 @@ struct ScopeLayoutBuilder RefPtr<VarLayout> endLayout() { + // Finish computing the layout for the ordindary data (if any). + // m_rules->EndStructLayout(&m_structLayoutInfo); + // Copy the final layout information computed for ordinary data + // over to the struct type layout for the scope. + // + m_structLayout->addResourceUsage(LayoutResourceKind::Uniform, m_structLayoutInfo.size); + m_structLayout->uniformAlignment = m_structLayout->uniformAlignment; + RefPtr<TypeLayout> scopeTypeLayout = m_structLayout; - // If the caller decided to allocate a constant buffer for - // the ordinary data, then we need to wrap up the structure - // type (layout) in a constant buffer type (layout). + // If a constant buffer is needed (because there is a non-zero + // amount of uniform data), then we need to wrap up the layout + // to reflect the constant buffer that will be generated. // - if( m_needConstantBuffer ) - { - auto constantBufferLayout = createParameterGroupTypeLayout( - m_context->layoutContext, - nullptr, - m_rules, - m_rules->GetObjectLayout(ShaderParameterKind::ConstantBuffer), - m_structLayout); - - scopeTypeLayout = constantBufferLayout; - } + scopeTypeLayout = createConstantBufferTypeLayoutIfNeeded( + m_context->layoutContext, + scopeTypeLayout); // We now have a bunch of layout information, which we should // record into a suitable object that represents the scope |
