summaryrefslogtreecommitdiffstats
path: root/tests/reflection
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-12-15 11:57:53 -0800
committerGitHub <noreply@github.com>2017-12-15 11:57:53 -0800
commit81c0cd872bcb94f1f05abc3b234d8918d237d77c (patch)
tree546fee3e8720a2c45ce483a3c046391586ea0d66 /tests/reflection
parent4137f9d4a58462ed94ed658ac0d722c830c3eb89 (diff)
More fixups for parameter block binding generation (#311)
* More fixups for parameter block binding generation The bug in this case arises when there is both a parameter block and global-scope resources, all of which are relying on automatic binding assignment. If the parameter block is the first global-scope parameter that gets encountered, then it is possible for it to allocate regsiter space/set zero for itself, which confuses the logic for handling other global-scope parameters (which assumes that *they* get space/set zero). I've also made some fixup to the reflection test harness and reflection API code: - Have the hardness handle register-space allocations when printing, and be sure to only show their `index` and not their `space` (since that would be redundant) - Have the reflection API only auto-redirect queries on a parameter group type layout to its container type layout *if* the container type layout has a non-zero number of resource allocations. The problem that arises here is a `ParameterBlock<X>` where `X` doesn't contain any uniforms, so that no container is needed. In that case the container ends up with no resource allocation(s). * Fixups for test failures. - The thread-group size tests failed because they had shader parameters with no resources to back them (built-in `SV_` inputs), and the printing of those changed. I fixed up the baseline, but also had to fix a few bugs in the reflection test fixture's printing logic. - The GLSL parameter block test revealed a corner case of the existing logic: because we always need to generate a binding for the "hack" sampler (even if code doesn't end up needing it), and that sampler should always go in the "default" set (should be set zero), the user's `ParameterBlock` will always end up as `set=1` or later, even if there are no other global-scope parameters. - This will be fixed once we don't have to rely on glslang's annoying behavior in this one case, either because glslang gets fixed, or because we implement our own SPIR-V codegen.
Diffstat (limited to 'tests/reflection')
-rw-r--r--tests/reflection/parameter-block.slang19
-rw-r--r--tests/reflection/parameter-block.slang.expected52
-rw-r--r--tests/reflection/thread-group-size.comp.expected5
-rw-r--r--tests/reflection/thread-group-size.hlsl.expected3
4 files changed, 72 insertions, 7 deletions
diff --git a/tests/reflection/parameter-block.slang b/tests/reflection/parameter-block.slang
new file mode 100644
index 000000000..c20337480
--- /dev/null
+++ b/tests/reflection/parameter-block.slang
@@ -0,0 +1,19 @@
+//TEST:REFLECTION:-profile glsl_fragment -target glsl
+
+// Confirm that we do parameter binding correctly
+// when we have both a parameter block *and* user-defined
+// resource parameters that both need automatic
+// binding allocation.
+
+struct Helper
+{
+ Texture2D t;
+ SamplerState s;
+};
+
+ParameterBlock<Helper> a;
+
+Texture2D b;
+
+float4 main() : SV_target
+{ return 0.0; }
diff --git a/tests/reflection/parameter-block.slang.expected b/tests/reflection/parameter-block.slang.expected
new file mode 100644
index 000000000..bc04d79ed
--- /dev/null
+++ b/tests/reflection/parameter-block.slang.expected
@@ -0,0 +1,52 @@
+result code = 0
+standard error = {
+}
+standard output = {
+{
+ "parameters": [
+ {
+ "name": "a",
+ "binding": {"kind": "registerSpace", "index": 1},
+ "type": {
+ "kind": "parameterBlock",
+ "elementType": {
+ "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}
+ }
+ ]
+ }
+ }
+ },
+ {
+ "name": "b",
+ "binding": {"kind": "descriptorTableSlot", "index": 0},
+ "type": {
+ "kind": "resource",
+ "baseShape": "texture2D"
+ }
+ },
+ {
+ "name": "SLANG_hack_samplerForTexelFetch",
+ "binding": {"kind": "descriptorTableSlot", "index": 1},
+ "type": {
+ "kind": "samplerState"
+ }
+ }
+ ]
+}
+}
diff --git a/tests/reflection/thread-group-size.comp.expected b/tests/reflection/thread-group-size.comp.expected
index ea7e97851..facd52cc0 100644
--- a/tests/reflection/thread-group-size.comp.expected
+++ b/tests/reflection/thread-group-size.comp.expected
@@ -21,10 +21,7 @@ standard output = {
"kind": "scalar",
"scalarType": "float32"
}
- },
- "bindings": [
-
- ]
+ }
}
]
}
diff --git a/tests/reflection/thread-group-size.hlsl.expected b/tests/reflection/thread-group-size.hlsl.expected
index a41c66248..cd5d09e35 100644
--- a/tests/reflection/thread-group-size.hlsl.expected
+++ b/tests/reflection/thread-group-size.hlsl.expected
@@ -21,9 +21,6 @@ standard output = {
"parameters": [
{
"name": "tid",
- "bindings": [
-
- ],
"semanticName": "SV_DISPATCHTHREADID",
"type": {
"kind": "vector",