From 4137f9d4a58462ed94ed658ac0d722c830c3eb89 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Thu, 14 Dec 2017 11:51:29 -0800 Subject: More fixups for Vulkan parameter block bindings (#309) I'm adding a small cross-compilation test to try to make sure that we are testing the binding generation for GLSL output. We probably still need a more complex test that uses multiple blocks, plus variables not in a block. The big changes here are: - Change the `containerTypeLayout` field to a `containerVarLayout` in the `ParameterGroupTypeLayout`, so that we can store the base offsets for the fields in a uniform fashion (even though these will all be zero). - Switch the emit logic to carefully use either the container or element var layout depending on what they are emitting bindings for. This involved adding something akin to the "reflection path" notion that Falcor has to use, but only for the emit step. --- source/slang/type-layout.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'source/slang/type-layout.cpp') diff --git a/source/slang/type-layout.cpp b/source/slang/type-layout.cpp index da1337778..9689fde0c 100644 --- a/source/slang/type-layout.cpp +++ b/source/slang/type-layout.cpp @@ -1065,22 +1065,29 @@ createParameterGroupTypeLayout( // Note: at the moment, constant buffers apply their own offsetting // logic elsewhere, so we need to only do this logic for parameter blocks RefPtr offsetTypeLayout = applyOffsetToTypeLayout(rawElementTypeLayout, containerTypeLayout); - - typeLayout->containerTypeLayout = containerTypeLayout; typeLayout->offsetElementTypeLayout = offsetTypeLayout; + + RefPtr containerVarLayout = new VarLayout(); + containerVarLayout->typeLayout = containerTypeLayout; + for( auto typeResInfo : containerTypeLayout->resourceInfos ) + { + containerVarLayout->findOrAddResourceInfo(typeResInfo.kind); + } + typeLayout->containerVarLayout = containerVarLayout; + // We will construct a dummy variable layout to represent the offsettting // that needs to be applied to the element type to put it after the // container. RefPtr elementVarLayout = new VarLayout(); elementVarLayout->typeLayout = rawElementTypeLayout; - for (auto containerResourceInfo : containerTypeLayout->resourceInfos) + for( auto elementTypeResInfo : rawElementTypeLayout->resourceInfos ) { - auto kind = containerResourceInfo.kind; - if (auto elementResourceInfo = rawElementTypeLayout->FindResourceInfo(kind)) + auto kind = elementTypeResInfo.kind; + auto elementVarResInfo = elementVarLayout->findOrAddResourceInfo(kind); + if( auto containerTypeResInfo = containerTypeLayout->FindResourceInfo(kind) ) { - auto varResourceInfo = elementVarLayout->findOrAddResourceInfo(kind); - varResourceInfo->index += containerResourceInfo.count; + elementVarResInfo->index += containerTypeResInfo->count; } } typeLayout->elementVarLayout = elementVarLayout; -- cgit v1.2.3