summaryrefslogtreecommitdiffstats
path: root/source/slang/type-layout.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-12-14 11:51:29 -0800
committerGitHub <noreply@github.com>2017-12-14 11:51:29 -0800
commit4137f9d4a58462ed94ed658ac0d722c830c3eb89 (patch)
tree74e89ad6deb13e23a4a2a72020e87219c9a1879e /source/slang/type-layout.cpp
parent6d6142122b15461d6c8cabdb31292b0de688ba35 (diff)
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.
Diffstat (limited to 'source/slang/type-layout.cpp')
-rw-r--r--source/slang/type-layout.cpp21
1 files changed, 14 insertions, 7 deletions
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<TypeLayout> offsetTypeLayout = applyOffsetToTypeLayout(rawElementTypeLayout, containerTypeLayout);
-
- typeLayout->containerTypeLayout = containerTypeLayout;
typeLayout->offsetElementTypeLayout = offsetTypeLayout;
+
+ RefPtr<VarLayout> 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<VarLayout> 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;