diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2020-01-08 14:45:06 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-08 14:45:06 -0800 |
| commit | 0a856f458ff9f17d76bc646d008602713c6c66d1 (patch) | |
| tree | 8b4642a374fb5b4d06411f2a9c383a6079a7426e /tests/reflection | |
| parent | cae5ddd4a2c9343ec7367c9049c5cc0c8628a9c4 (diff) | |
Cover a few corner cases in reflection API (#1163)
This change adds some new entry points to the reflection API to cover corner cases that a majority of applications won't care about.
These are most likely to come up for users who want to make a complete copy of the Slang reflection information into a data format of their own design.
All of the information is stuff that we already computed as part of layout, and just hadn't exposed:
* Alignment information for type layouts. This is only useful for ordinary/uniform data; in all other cases alignment is always one. Even for uniform/ordinary data, it is unlikely that any application would actually make use of it.
* Layout information for the result of an entry point function. This would be useful for applications that need to enumerate the varying outputs (user- or system-defined) of a shader. Having information available for `out` parameters but not the function result was inconsistent.
* The "element type" of a parameter block type (e.g., going from `ParameterBlock<X>` to `X`). This seems to have been an oversight since `ConstantBuffer<X>` appears to have been implemented, and the case for a type *layout* was handled.
* The "container" variable layout for a parameter block or constant buffer. It took a while for us to arrive at the current representation of layout for parameter groups, and most client code continues to use the original API that requires us to generated kludged "do what I mean" data. However, if we don't expose the more useful new representation fully, there is no way for users to take advantage of it!
The reflection test tool has been updated to print the new information where it makes sense, which provides us some level of coverage for the new code.
Unfortunately, this led to some cascading changes:
* First, a bunch of the tests had their output changed since they include new information. That's the easy bit.
* Next, the "container" and "element" var layouts don't actually have names (because there is no actual variable underlying them), which means that the code to emit variable names in the JSON dump needed to be condition.
* Making the `"name"` output conditional messed up a lot of the delicate logic that had been dealing with when to emit commas for the output JSON (JSON uses commas as separators, and doesn't allow trailing commas). I added a bit of new infrastructure to make it simple(-ish) to track when a comma actually needs to be output.
Diffstat (limited to 'tests/reflection')
25 files changed, 1509 insertions, 23 deletions
diff --git a/tests/reflection/arrays.hlsl.expected b/tests/reflection/arrays.hlsl.expected index f815ea88c..2152ed0df 100644 --- a/tests/reflection/arrays.hlsl.expected +++ b/tests/reflection/arrays.hlsl.expected @@ -42,6 +42,46 @@ standard output = { "binding": {"kind": "uniform", "offset": 164, "size": 4} } ] + }, + "containerVarLayout": { + "binding": {"kind": "constantBuffer", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "fields": [ + { + "name": "x", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + }, + { + "name": "a", + "type": { + "kind": "array", + "elementCount": 10, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + }, + "uniformStride": 16 + }, + "binding": {"kind": "uniform", "offset": 16, "size": 148} + }, + { + "name": "y", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 164, "size": 4} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 168} } } }, @@ -102,7 +142,20 @@ standard output = { "entryPoints": [ { "name": "main", - "stage:": "fragment" + "stage:": "fragment", + "result:": { + "stage": "fragment", + "binding": {"kind": "varyingOutput", "index": 0}, + "semanticName": "SV_TARGET", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } } ] } diff --git a/tests/reflection/attribute.slang.expected b/tests/reflection/attribute.slang.expected index 4348b898f..b15c87df8 100644 --- a/tests/reflection/attribute.slang.expected +++ b/tests/reflection/attribute.slang.expected @@ -45,6 +45,49 @@ standard output = { ] } ] + }, + "containerVarLayout": { + "binding": {"kind": "constantBuffer", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "name": "A", + "fields": [ + { + "name": "x", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + }, + { + "name": "y", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 4, "size": 4}, + "userAttribs": [{ + "name": "DefaultValue", + "arguments": [ + 1 + ] + } + ] + } + ], + "userAttribs": [{ + "name": "MyStruct", + "arguments": [ + 0, + 1.000000 + ] + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 8} } } }, @@ -89,6 +132,49 @@ standard output = { ] } ] + }, + "containerVarLayout": { + "binding": {"kind": "constantBuffer", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "name": "B", + "fields": [ + { + "name": "x", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + }, + { + "name": "z", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 4, "size": 4}, + "userAttribs": [{ + "name": "DefaultValue", + "arguments": [ + 2 + ] + } + ] + } + ], + "userAttribs": [{ + "name": "MyStruct", + "arguments": [ + 0, + 2.000000 + ] + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 8} } } } diff --git a/tests/reflection/binding-gl.hlsl.expected b/tests/reflection/binding-gl.hlsl.expected index 1b5e7354f..8c2e761b5 100644 --- a/tests/reflection/binding-gl.hlsl.expected +++ b/tests/reflection/binding-gl.hlsl.expected @@ -42,6 +42,46 @@ standard output = { "binding": {"kind": "uniform", "offset": 176, "size": 4} } ] + }, + "containerVarLayout": { + "binding": {"kind": "descriptorTableSlot", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "fields": [ + { + "name": "x", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + }, + { + "name": "a", + "type": { + "kind": "array", + "elementCount": 10, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + }, + "uniformStride": 16 + }, + "binding": {"kind": "uniform", "offset": 16, "size": 160} + }, + { + "name": "y", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 176, "size": 4} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 192} } } }, @@ -98,7 +138,20 @@ standard output = { "entryPoints": [ { "name": "main", - "stage:": "fragment" + "stage:": "fragment", + "result:": { + "stage": "fragment", + "binding": {"kind": "varyingOutput", "index": 0}, + "semanticName": "SV_TARGET", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } } ] } diff --git a/tests/reflection/binding-push-constant-gl.hlsl.expected b/tests/reflection/binding-push-constant-gl.hlsl.expected index ed6983364..13dfe2fcd 100644 --- a/tests/reflection/binding-push-constant-gl.hlsl.expected +++ b/tests/reflection/binding-push-constant-gl.hlsl.expected @@ -42,6 +42,46 @@ standard output = { "binding": {"kind": "uniform", "offset": 176, "size": 4} } ] + }, + "containerVarLayout": { + "binding": {"kind": "descriptorTableSlot", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "fields": [ + { + "name": "x", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + }, + { + "name": "a", + "type": { + "kind": "array", + "elementCount": 10, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + }, + "uniformStride": 16 + }, + "binding": {"kind": "uniform", "offset": 16, "size": 160} + }, + { + "name": "y", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 176, "size": 4} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 192} } } }, @@ -71,6 +111,34 @@ standard output = { "binding": {"kind": "uniform", "offset": 4, "size": 4} } ] + }, + "containerVarLayout": { + "binding": {"kind": "pushConstantBuffer", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "name": "MyPushConstantStruct", + "fields": [ + { + "name": "pushX", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + }, + { + "name": "pushY", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 4, "size": 4} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 16} } } }, @@ -127,7 +195,20 @@ standard output = { "entryPoints": [ { "name": "main", - "stage:": "fragment" + "stage:": "fragment", + "result:": { + "stage": "fragment", + "binding": {"kind": "varyingOutput", "index": 0}, + "semanticName": "SV_TARGET", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } } ] } diff --git a/tests/reflection/buffer-layout.slang.1.expected b/tests/reflection/buffer-layout.slang.1.expected index 890f31481..0b01f54a1 100644 --- a/tests/reflection/buffer-layout.slang.1.expected +++ b/tests/reflection/buffer-layout.slang.1.expected @@ -81,6 +81,85 @@ standard output = { "binding": {"kind": "uniform", "offset": 80, "size": 4} } ] + }, + "containerVarLayout": { + "binding": {"kind": "descriptorTableSlot", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "name": "S", + "fields": [ + { + "name": "z", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + }, + { + "name": "a", + "type": { + "kind": "struct", + "name": "A", + "fields": [ + { + "name": "x", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + }, + { + "name": "y", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 4, "size": 4} + } + ] + }, + "binding": {"kind": "uniform", "offset": 16, "size": 16} + }, + { + "name": "b", + "type": { + "kind": "scalar", + "scalarType": "int32" + }, + "binding": {"kind": "uniform", "offset": 32, "size": 4} + }, + { + "name": "c", + "type": { + "kind": "array", + "elementCount": 2, + "elementType": { + "kind": "vector", + "elementCount": 2, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "uniformStride": 16 + }, + "binding": {"kind": "uniform", "offset": 48, "size": 32} + }, + { + "name": "d", + "type": { + "kind": "scalar", + "scalarType": "int32" + }, + "binding": {"kind": "uniform", "offset": 80, "size": 4} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 96} } } }, diff --git a/tests/reflection/buffer-layout.slang.expected b/tests/reflection/buffer-layout.slang.expected index 25a41bc6d..4fc7b2381 100644 --- a/tests/reflection/buffer-layout.slang.expected +++ b/tests/reflection/buffer-layout.slang.expected @@ -81,6 +81,85 @@ standard output = { "binding": {"kind": "uniform", "offset": 56, "size": 4} } ] + }, + "containerVarLayout": { + "binding": {"kind": "constantBuffer", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "name": "S", + "fields": [ + { + "name": "z", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + }, + { + "name": "a", + "type": { + "kind": "struct", + "name": "A", + "fields": [ + { + "name": "x", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + }, + { + "name": "y", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 4, "size": 4} + } + ] + }, + "binding": {"kind": "uniform", "offset": 16, "size": 8} + }, + { + "name": "b", + "type": { + "kind": "scalar", + "scalarType": "int32" + }, + "binding": {"kind": "uniform", "offset": 24, "size": 4} + }, + { + "name": "c", + "type": { + "kind": "array", + "elementCount": 2, + "elementType": { + "kind": "vector", + "elementCount": 2, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "uniformStride": 16 + }, + "binding": {"kind": "uniform", "offset": 32, "size": 24} + }, + { + "name": "d", + "type": { + "kind": "scalar", + "scalarType": "int32" + }, + "binding": {"kind": "uniform", "offset": 56, "size": 4} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 60} } } }, diff --git a/tests/reflection/cross-compile.slang.expected b/tests/reflection/cross-compile.slang.expected index a54598d08..e3dd63095 100644 --- a/tests/reflection/cross-compile.slang.expected +++ b/tests/reflection/cross-compile.slang.expected @@ -40,6 +40,29 @@ standard output = { "binding": {"kind": "uniform", "offset": 0, "size": 12} } ] + }, + "containerVarLayout": { + "binding": {"kind": "descriptorTableSlot", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "fields": [ + { + "name": "c", + "type": { + "kind": "vector", + "elementCount": 3, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 0, "size": 12} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 16} } } } @@ -47,7 +70,20 @@ standard output = { "entryPoints": [ { "name": "main", - "stage:": "fragment" + "stage:": "fragment", + "result:": { + "stage": "fragment", + "binding": {"kind": "varyingOutput", "index": 0}, + "semanticName": "SV_TARGET", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } } ] } diff --git a/tests/reflection/default-space.slang.expected b/tests/reflection/default-space.slang.expected index 548de2be0..5ba17790c 100644 --- a/tests/reflection/default-space.slang.expected +++ b/tests/reflection/default-space.slang.expected @@ -30,6 +30,26 @@ standard output = { "binding": {"kind": "shaderResource", "index": 0} } ] + }, + "containerVarLayout": { + "binding": {"kind": "registerSpace", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "name": "B", + "fields": [ + { + "name": "b", + "type": { + "kind": "resource", + "baseShape": "texture2D" + }, + "binding": {"kind": "shaderResource", "index": 0} + } + ] + }, + "binding": {"kind": "shaderResource", "index": 0} } } } @@ -37,7 +57,20 @@ standard output = { "entryPoints": [ { "name": "main", - "stage:": "fragment" + "stage:": "fragment", + "result:": { + "stage": "fragment", + "binding": {"kind": "varyingOutput", "index": 0}, + "semanticName": "SV_TARGET", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } } ] } diff --git a/tests/reflection/explicit-register-space.slang.expected b/tests/reflection/explicit-register-space.slang.expected index c9e32c4f5..0c282f5f9 100644 --- a/tests/reflection/explicit-register-space.slang.expected +++ b/tests/reflection/explicit-register-space.slang.expected @@ -16,7 +16,20 @@ standard output = { "entryPoints": [ { "name": "main", - "stage:": "fragment" + "stage:": "fragment", + "result:": { + "stage": "fragment", + "binding": {"kind": "varyingOutput", "index": 0}, + "semanticName": "SV_TARGET", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } } ] } diff --git a/tests/reflection/global-type-params.slang.expected b/tests/reflection/global-type-params.slang.expected index 8f6ba2838..4fb7d0279 100644 --- a/tests/reflection/global-type-params.slang.expected +++ b/tests/reflection/global-type-params.slang.expected @@ -22,6 +22,26 @@ standard output = { "binding": {"kind": "generic", "index": 0} } ] + }, + "containerVarLayout": { + + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "name": "S", + "fields": [ + { + "name": "p", + "type": { + "kind": "GenericTypeParameter", + "name": "TParam2" + }, + "binding": {"kind": "generic", "index": 0} + } + ] + }, + "binding": {"kind": "generic", "index": 0} } } }, @@ -33,6 +53,16 @@ standard output = { "elementType": { "kind": "GenericTypeParameter", "name": "TParam" + }, + "containerVarLayout": { + + }, + "elementVarLayout": { + "type": { + "kind": "GenericTypeParameter", + "name": "TParam" + }, + "binding": {"kind": "generic", "index": 0} } } }, @@ -96,6 +126,53 @@ standard output = { "binding": {"kind": "uniform", "offset": 32, "size": 16} } ] + }, + "containerVarLayout": { + "binding": {"kind": "constantBuffer", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "fields": [ + { + "name": "u", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 0, "size": 16} + }, + { + "name": "v", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 16, "size": 16} + }, + { + "name": "w", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 32, "size": 16} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 48} } } } @@ -103,7 +180,20 @@ standard output = { "entryPoints": [ { "name": "main", - "stage:": "fragment" + "stage:": "fragment", + "result:": { + "stage": "fragment", + "binding": {"kind": "varyingOutput", "index": 0}, + "semanticName": "SV_TARGET", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } } ], "typeParams": diff --git a/tests/reflection/matrix-layout.slang.1.expected b/tests/reflection/matrix-layout.slang.1.expected index 57fd29c6d..0683a6edc 100644 --- a/tests/reflection/matrix-layout.slang.1.expected +++ b/tests/reflection/matrix-layout.slang.1.expected @@ -52,6 +52,56 @@ standard output = { "binding": {"kind": "uniform", "offset": 96, "size": 60} } ] + }, + "containerVarLayout": { + "binding": {"kind": "constantBuffer", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "fields": [ + { + "name": "aa", + "type": { + "kind": "matrix", + "rowCount": 3, + "columnCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 0, "size": 48} + }, + { + "name": "ab", + "type": { + "kind": "matrix", + "rowCount": 3, + "columnCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 48, "size": 48} + }, + { + "name": "ac", + "type": { + "kind": "matrix", + "rowCount": 3, + "columnCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 96, "size": 60} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 156} } } }, @@ -113,6 +163,66 @@ standard output = { "binding": {"kind": "uniform", "offset": 0, "size": 156} } ] + }, + "containerVarLayout": { + "binding": {"kind": "constantBuffer", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "fields": [ + { + "name": "b", + "type": { + "kind": "struct", + "name": "SB", + "fields": [ + { + "name": "ba", + "type": { + "kind": "matrix", + "rowCount": 3, + "columnCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 0, "size": 48} + }, + { + "name": "bb", + "type": { + "kind": "matrix", + "rowCount": 3, + "columnCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 48, "size": 48} + }, + { + "name": "bc", + "type": { + "kind": "matrix", + "rowCount": 3, + "columnCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 96, "size": 60} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 156} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 156} } } } @@ -120,7 +230,20 @@ standard output = { "entryPoints": [ { "name": "main", - "stage:": "fragment" + "stage:": "fragment", + "result:": { + "stage": "fragment", + "binding": {"kind": "varyingOutput", "index": 0}, + "semanticName": "SV_TARGET", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } } ] } diff --git a/tests/reflection/matrix-layout.slang.expected b/tests/reflection/matrix-layout.slang.expected index c8aeb2ae1..c81207216 100644 --- a/tests/reflection/matrix-layout.slang.expected +++ b/tests/reflection/matrix-layout.slang.expected @@ -52,6 +52,56 @@ standard output = { "binding": {"kind": "uniform", "offset": 112, "size": 60} } ] + }, + "containerVarLayout": { + "binding": {"kind": "constantBuffer", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "fields": [ + { + "name": "aa", + "type": { + "kind": "matrix", + "rowCount": 3, + "columnCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 0, "size": 60} + }, + { + "name": "ab", + "type": { + "kind": "matrix", + "rowCount": 3, + "columnCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 64, "size": 48} + }, + { + "name": "ac", + "type": { + "kind": "matrix", + "rowCount": 3, + "columnCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 112, "size": 60} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 172} } } }, @@ -113,6 +163,66 @@ standard output = { "binding": {"kind": "uniform", "offset": 0, "size": 172} } ] + }, + "containerVarLayout": { + "binding": {"kind": "constantBuffer", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "fields": [ + { + "name": "b", + "type": { + "kind": "struct", + "name": "SB", + "fields": [ + { + "name": "ba", + "type": { + "kind": "matrix", + "rowCount": 3, + "columnCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 0, "size": 60} + }, + { + "name": "bb", + "type": { + "kind": "matrix", + "rowCount": 3, + "columnCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 64, "size": 48} + }, + { + "name": "bc", + "type": { + "kind": "matrix", + "rowCount": 3, + "columnCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 112, "size": 60} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 172} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 172} } } } @@ -120,7 +230,20 @@ standard output = { "entryPoints": [ { "name": "main", - "stage:": "fragment" + "stage:": "fragment", + "result:": { + "stage": "fragment", + "binding": {"kind": "varyingOutput", "index": 0}, + "semanticName": "SV_TARGET", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } } ] } diff --git a/tests/reflection/multi-file.hlsl.expected b/tests/reflection/multi-file.hlsl.expected index 814c648e0..1cbc73f5c 100644 --- a/tests/reflection/multi-file.hlsl.expected +++ b/tests/reflection/multi-file.hlsl.expected @@ -72,6 +72,61 @@ standard output = { "binding": {"kind": "uniform", "offset": 32, "size": 8} } ] + }, + "containerVarLayout": { + "binding": {"kind": "constantBuffer", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "fields": [ + { + "name": "vertexCA", + "type": { + "kind": "vector", + "elementCount": 3, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 0, "size": 12} + }, + { + "name": "vertexCB", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 12, "size": 4} + }, + { + "name": "vertexCC", + "type": { + "kind": "vector", + "elementCount": 3, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 16, "size": 12} + }, + { + "name": "vertexCD", + "type": { + "kind": "vector", + "elementCount": 2, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 32, "size": 8} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 40} } } }, @@ -143,6 +198,61 @@ standard output = { "binding": {"kind": "uniform", "offset": 32, "size": 8} } ] + }, + "containerVarLayout": { + "binding": {"kind": "constantBuffer", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "fields": [ + { + "name": "fragmentCA", + "type": { + "kind": "vector", + "elementCount": 3, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 0, "size": 12} + }, + { + "name": "fragmentCB", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 12, "size": 4} + }, + { + "name": "fragmentCC", + "type": { + "kind": "vector", + "elementCount": 3, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 16, "size": 12} + }, + { + "name": "fragmentCD", + "type": { + "kind": "vector", + "elementCount": 2, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 32, "size": 8} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 40} } } }, @@ -214,6 +324,61 @@ standard output = { "binding": {"kind": "uniform", "offset": 32, "size": 8} } ] + }, + "containerVarLayout": { + "binding": {"kind": "constantBuffer", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "fields": [ + { + "name": "sharedCA", + "type": { + "kind": "vector", + "elementCount": 3, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 0, "size": 12} + }, + { + "name": "sharedCB", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 12, "size": 4} + }, + { + "name": "sharedCC", + "type": { + "kind": "vector", + "elementCount": 3, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 16, "size": 12} + }, + { + "name": "sharedCD", + "type": { + "kind": "vector", + "elementCount": 2, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 32, "size": 8} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 40} } } }, @@ -237,11 +402,35 @@ standard output = { "entryPoints": [ { "name": "mainVS", - "stage:": "vertex" + "stage:": "vertex", + "result:": { + "semanticName": "SV_POSITION", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } }, { "name": "mainFS", - "stage:": "fragment" + "stage:": "fragment", + "result:": { + "stage": "fragment", + "binding": {"kind": "varyingOutput", "index": 0}, + "semanticName": "SV_TARGET", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } } ] } diff --git a/tests/reflection/parameter-block-explicit-space.slang.expected b/tests/reflection/parameter-block-explicit-space.slang.expected index f7944c644..a96f95961 100644 --- a/tests/reflection/parameter-block-explicit-space.slang.expected +++ b/tests/reflection/parameter-block-explicit-space.slang.expected @@ -52,6 +52,60 @@ standard output = { "binding": {"kind": "samplerState", "index": 0} } ] + }, + "containerVarLayout": { + "bindings": [ + {"kind": "constantBuffer", "index": 0}, + {"kind": "registerSpace", "index": 0} + ] + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "name": "A", + "fields": [ + { + "name": "au", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 0, "size": 16} + }, + { + "name": "at1", + "type": { + "kind": "resource", + "baseShape": "texture2D" + }, + "binding": {"kind": "shaderResource", "index": 0} + }, + { + "name": "at2", + "type": { + "kind": "resource", + "baseShape": "texture2D" + }, + "binding": {"kind": "shaderResource", "index": 1} + }, + { + "name": "as", + "type": { + "kind": "samplerState" + }, + "binding": {"kind": "samplerState", "index": 0} + } + ] + }, + "bindings": [ + {"kind": "shaderResource", "index": 0, "count": 2}, + {"kind": "samplerState", "index": 0}, + {"kind": "uniform", "offset": 0, "size": 16} + ] } } }, @@ -95,6 +149,52 @@ standard output = { "binding": {"kind": "samplerState", "index": 0} } ] + }, + "containerVarLayout": { + "bindings": [ + {"kind": "constantBuffer", "index": 0}, + {"kind": "registerSpace", "index": 0} + ] + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "name": "B", + "fields": [ + { + "name": "bu", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 0, "size": 16} + }, + { + "name": "bt", + "type": { + "kind": "resource", + "baseShape": "texture2D" + }, + "binding": {"kind": "shaderResource", "index": 0} + }, + { + "name": "bs", + "type": { + "kind": "samplerState" + }, + "binding": {"kind": "samplerState", "index": 0} + } + ] + }, + "bindings": [ + {"kind": "shaderResource", "index": 0}, + {"kind": "samplerState", "index": 0}, + {"kind": "uniform", "offset": 0, "size": 16} + ] } } } @@ -102,7 +202,20 @@ standard output = { "entryPoints": [ { "name": "main", - "stage:": "fragment" + "stage:": "fragment", + "result:": { + "stage": "fragment", + "binding": {"kind": "varyingOutput", "index": 0}, + "semanticName": "SV_TARGET", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } } ] } diff --git a/tests/reflection/parameter-block.slang.1.expected b/tests/reflection/parameter-block.slang.1.expected index bbd52a784..b8f462e60 100644 --- a/tests/reflection/parameter-block.slang.1.expected +++ b/tests/reflection/parameter-block.slang.1.expected @@ -32,6 +32,36 @@ standard output = { "binding": {"kind": "samplerState", "index": 0} } ] + }, + "containerVarLayout": { + + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "name": "Helper", + "fields": [ + { + "name": "t", + "type": { + "kind": "resource", + "baseShape": "texture2D" + }, + "binding": {"kind": "shaderResource", "index": 0} + }, + { + "name": "s", + "type": { + "kind": "samplerState" + }, + "binding": {"kind": "samplerState", "index": 0} + } + ] + }, + "bindings": [ + {"kind": "shaderResource", "index": 0}, + {"kind": "samplerState", "index": 0} + ] } } }, @@ -47,7 +77,20 @@ standard output = { "entryPoints": [ { "name": "main", - "stage:": "fragment" + "stage:": "fragment", + "result:": { + "stage": "fragment", + "binding": {"kind": "varyingOutput", "index": 0}, + "semanticName": "SV_TARGET", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } } ] } diff --git a/tests/reflection/parameter-block.slang.2.expected b/tests/reflection/parameter-block.slang.2.expected index e692718e8..e4bf9b6cb 100644 --- a/tests/reflection/parameter-block.slang.2.expected +++ b/tests/reflection/parameter-block.slang.2.expected @@ -29,6 +29,36 @@ standard output = { "binding": {"kind": "samplerState", "index": 0} } ] + }, + "containerVarLayout": { + "binding": {"kind": "registerSpace", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "name": "Helper", + "fields": [ + { + "name": "t", + "type": { + "kind": "resource", + "baseShape": "texture2D" + }, + "binding": {"kind": "shaderResource", "index": 0} + }, + { + "name": "s", + "type": { + "kind": "samplerState" + }, + "binding": {"kind": "samplerState", "index": 0} + } + ] + }, + "bindings": [ + {"kind": "shaderResource", "index": 0}, + {"kind": "samplerState", "index": 0} + ] } } }, @@ -44,7 +74,20 @@ standard output = { "entryPoints": [ { "name": "main", - "stage:": "fragment" + "stage:": "fragment", + "result:": { + "stage": "fragment", + "binding": {"kind": "varyingOutput", "index": 0}, + "semanticName": "SV_TARGET", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } } ] } diff --git a/tests/reflection/parameter-block.slang.expected b/tests/reflection/parameter-block.slang.expected index 58344bc12..0909dc8cf 100644 --- a/tests/reflection/parameter-block.slang.expected +++ b/tests/reflection/parameter-block.slang.expected @@ -29,6 +29,33 @@ standard output = { "binding": {"kind": "descriptorTableSlot", "index": 1} } ] + }, + "containerVarLayout": { + "binding": {"kind": "registerSpace", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "name": "Helper", + "fields": [ + { + "name": "t", + "type": { + "kind": "resource", + "baseShape": "texture2D" + }, + "binding": {"kind": "descriptorTableSlot", "index": 0} + }, + { + "name": "s", + "type": { + "kind": "samplerState" + }, + "binding": {"kind": "descriptorTableSlot", "index": 1} + } + ] + }, + "binding": {"kind": "descriptorTableSlot", "index": 0, "count": 2} } } }, @@ -44,7 +71,20 @@ standard output = { "entryPoints": [ { "name": "main", - "stage:": "fragment" + "stage:": "fragment", + "result:": { + "stage": "fragment", + "binding": {"kind": "varyingOutput", "index": 0}, + "semanticName": "SV_TARGET", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } } ] } diff --git a/tests/reflection/reflect-imported-code.hlsl.expected b/tests/reflection/reflect-imported-code.hlsl.expected index 78e7ce195..5d51ddb5c 100644 --- a/tests/reflection/reflect-imported-code.hlsl.expected +++ b/tests/reflection/reflect-imported-code.hlsl.expected @@ -36,6 +36,25 @@ standard output = { "binding": {"kind": "uniform", "offset": 0, "size": 4} } ] + }, + "containerVarLayout": { + "binding": {"kind": "constantBuffer", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "fields": [ + { + "name": "c", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} } } }, @@ -71,6 +90,25 @@ standard output = { "binding": {"kind": "uniform", "offset": 0, "size": 4} } ] + }, + "containerVarLayout": { + "binding": {"kind": "constantBuffer", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "fields": [ + { + "name": "c_i", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} } } } @@ -78,7 +116,20 @@ standard output = { "entryPoints": [ { "name": "main", - "stage:": "fragment" + "stage:": "fragment", + "result:": { + "stage": "fragment", + "binding": {"kind": "varyingOutput", "index": 0}, + "semanticName": "SV_TARGET", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } } ] } diff --git a/tests/reflection/reflection0.hlsl.expected b/tests/reflection/reflection0.hlsl.expected index e4d6070ca..64b8fcd85 100644 --- a/tests/reflection/reflection0.hlsl.expected +++ b/tests/reflection/reflection0.hlsl.expected @@ -36,6 +36,25 @@ standard output = { "binding": {"kind": "uniform", "offset": 0, "size": 4} } ] + }, + "containerVarLayout": { + "binding": {"kind": "constantBuffer", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "fields": [ + { + "name": "c", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} } } } @@ -43,7 +62,20 @@ standard output = { "entryPoints": [ { "name": "main", - "stage:": "fragment" + "stage:": "fragment", + "result:": { + "stage": "fragment", + "binding": {"kind": "varyingOutput", "index": 0}, + "semanticName": "SV_TARGET", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } } ] } diff --git a/tests/reflection/resource-in-cbuffer.hlsl.expected b/tests/reflection/resource-in-cbuffer.hlsl.expected index d14fbe577..03299a8e0 100644 --- a/tests/reflection/resource-in-cbuffer.hlsl.expected +++ b/tests/reflection/resource-in-cbuffer.hlsl.expected @@ -48,6 +48,56 @@ standard output = { "binding": {"kind": "samplerState", "index": 0} } ] + }, + "containerVarLayout": { + "binding": {"kind": "constantBuffer", "index": 0} + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "fields": [ + { + "name": "v", + "type": { + "kind": "vector", + "elementCount": 3, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + }, + "binding": {"kind": "uniform", "offset": 0, "size": 12} + }, + { + "name": "myTexture", + "type": { + "kind": "resource", + "baseShape": "texture2D" + }, + "binding": {"kind": "shaderResource", "index": 0} + }, + { + "name": "c", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 12, "size": 4} + }, + { + "name": "mySampler", + "type": { + "kind": "samplerState" + }, + "binding": {"kind": "samplerState", "index": 0} + } + ] + }, + "bindings": [ + {"kind": "shaderResource", "index": 0}, + {"kind": "samplerState", "index": 0}, + {"kind": "uniform", "offset": 0, "size": 16} + ] } } } @@ -55,7 +105,20 @@ standard output = { "entryPoints": [ { "name": "main", - "stage:": "fragment" + "stage:": "fragment", + "result:": { + "stage": "fragment", + "binding": {"kind": "varyingOutput", "index": 0}, + "semanticName": "SV_TARGET", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } } ] } diff --git a/tests/reflection/sample-index-input.hlsl.expected b/tests/reflection/sample-index-input.hlsl.expected index 5bf5f297e..d0bc3c1b9 100644 --- a/tests/reflection/sample-index-input.hlsl.expected +++ b/tests/reflection/sample-index-input.hlsl.expected @@ -45,7 +45,20 @@ standard output = { } } ], - "usesAnySampleRateInput": true + "usesAnySampleRateInput": true, + "result:": { + "stage": "fragment", + "binding": {"kind": "varyingOutput", "index": 0}, + "semanticName": "SV_TARGET", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } } ] } diff --git a/tests/reflection/sample-rate-input.hlsl.expected b/tests/reflection/sample-rate-input.hlsl.expected index 0c86ebecb..485594fae 100644 --- a/tests/reflection/sample-rate-input.hlsl.expected +++ b/tests/reflection/sample-rate-input.hlsl.expected @@ -51,7 +51,20 @@ standard output = { } } ], - "usesAnySampleRateInput": true + "usesAnySampleRateInput": true, + "result:": { + "stage": "fragment", + "binding": {"kind": "varyingOutput", "index": 0}, + "semanticName": "SV_TARGET", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } } ] } diff --git a/tests/reflection/shared-modifier.hlsl.expected b/tests/reflection/shared-modifier.hlsl.expected index ddb982177..782e038de 100644 --- a/tests/reflection/shared-modifier.hlsl.expected +++ b/tests/reflection/shared-modifier.hlsl.expected @@ -40,7 +40,20 @@ standard output = { } } } - ] + ], + "result:": { + "stage": "fragment", + "binding": {"kind": "varyingOutput", "index": 0}, + "semanticName": "SV_TARGET", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } } ] } diff --git a/tests/reflection/structured-buffer.slang.expected b/tests/reflection/structured-buffer.slang.expected index 3e79fd1c5..d0cb3e501 100644 --- a/tests/reflection/structured-buffer.slang.expected +++ b/tests/reflection/structured-buffer.slang.expected @@ -78,7 +78,20 @@ standard output = { "entryPoints": [ { "name": "main", - "stage:": "fragment" + "stage:": "fragment", + "result:": { + "stage": "fragment", + "binding": {"kind": "varyingOutput", "index": 0}, + "semanticName": "SV_TARGET", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } } ] } diff --git a/tests/reflection/vertex-input-semantics.hlsl.expected b/tests/reflection/vertex-input-semantics.hlsl.expected index 06b7bc95a..e15a3a258 100644 --- a/tests/reflection/vertex-input-semantics.hlsl.expected +++ b/tests/reflection/vertex-input-semantics.hlsl.expected @@ -160,7 +160,18 @@ standard output = { ] } } - ] + ], + "result:": { + "semanticName": "SV_POSITION", + "type": { + "kind": "vector", + "elementCount": 4, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } } ] } |
