diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2020-01-23 12:24:13 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-23 12:24:13 -0800 |
| commit | 394983d61efa2bf99ba96aa68a47df8927a8a634 (patch) | |
| tree | 3a35ed930d8f817d03f19214cad96061ea8d3825 /tests | |
| parent | b9c0662af02bcacb93f0dddb970a2ba13288ed79 (diff) | |
Fix a bug in handling explicit register space bindings (#1175)
The logic for handling explicit `space`/`set` bindings on shader parameters for parameter blocks was not correctly marking the `space`/`set` that gets grabbed as used, and as a result it was possible for another parameter block that relies on implicit assignment to end up with a conflicting space.
This change fixes the original oversight, and adds a test case to prevent against regression.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/reflection/mix-explicit-and-implicit-spaces.slang | 18 | ||||
| -rw-r--r-- | tests/reflection/mix-explicit-and-implicit-spaces.slang.expected | 157 |
2 files changed, 175 insertions, 0 deletions
diff --git a/tests/reflection/mix-explicit-and-implicit-spaces.slang b/tests/reflection/mix-explicit-and-implicit-spaces.slang new file mode 100644 index 000000000..52dd4321e --- /dev/null +++ b/tests/reflection/mix-explicit-and-implicit-spaces.slang @@ -0,0 +1,18 @@ +// mix-explicit-and-implicit-spaces.slang +//TEST:REFLECTION:-profile cs_5_1 -target hlsl + +// Ensure that correct layout/reflection is computed +// when mixing implicit and explicit spaces for +// parameter blocks. + +struct A { float x; } +ParameterBlock<A> a : register(space0); + +struct B { float y; } +ParameterBlock<B> b : register(space1); + +struct C { float z; } +ParameterBlock<C> c; + +void main() +{} diff --git a/tests/reflection/mix-explicit-and-implicit-spaces.slang.expected b/tests/reflection/mix-explicit-and-implicit-spaces.slang.expected new file mode 100644 index 000000000..2e4ead342 --- /dev/null +++ b/tests/reflection/mix-explicit-and-implicit-spaces.slang.expected @@ -0,0 +1,157 @@ +result code = 0 +standard error = { +} +standard output = { +{ + "parameters": [ + { + "name": "a", + "bindings": [ + {"kind": "constantBuffer", "index": 0, "count": 0}, + {"kind": "registerSpace", "index": 0} + ], + "type": { + "kind": "parameterBlock", + "elementType": { + "kind": "struct", + "name": "A", + "fields": [ + { + "name": "x", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + } + ] + }, + "containerVarLayout": { + "bindings": [ + {"kind": "constantBuffer", "index": 0}, + {"kind": "registerSpace", "index": 0} + ] + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "name": "A", + "fields": [ + { + "name": "x", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + } + } + }, + { + "name": "b", + "bindings": [ + {"kind": "constantBuffer", "index": 0, "count": 0}, + {"kind": "registerSpace", "index": 1} + ], + "type": { + "kind": "parameterBlock", + "elementType": { + "kind": "struct", + "name": "B", + "fields": [ + { + "name": "y", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + } + ] + }, + "containerVarLayout": { + "bindings": [ + {"kind": "constantBuffer", "index": 0}, + {"kind": "registerSpace", "index": 0} + ] + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "name": "B", + "fields": [ + { + "name": "y", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + } + } + }, + { + "name": "c", + "bindings": [ + {"kind": "constantBuffer", "index": 0, "count": 0}, + {"kind": "registerSpace", "index": 2} + ], + "type": { + "kind": "parameterBlock", + "elementType": { + "kind": "struct", + "name": "C", + "fields": [ + { + "name": "z", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + } + ] + }, + "containerVarLayout": { + "bindings": [ + {"kind": "constantBuffer", "index": 0}, + {"kind": "registerSpace", "index": 0} + ] + }, + "elementVarLayout": { + "type": { + "kind": "struct", + "name": "C", + "fields": [ + { + "name": "z", + "type": { + "kind": "scalar", + "scalarType": "float32" + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + } + ] + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + } + } + } + ], + "entryPoints": [ + { + "name": "main", + "stage:": "compute", + "threadGroupSize": [1, 1, 1] + } + ] +} +} |
