summaryrefslogtreecommitdiffstats
path: root/tests/reflection
diff options
context:
space:
mode:
Diffstat (limited to 'tests/reflection')
-rw-r--r--tests/reflection/arrays.hlsl27
-rw-r--r--tests/reflection/arrays.hlsl.expected103
-rw-r--r--tests/reflection/global-uniforms.hlsl21
-rw-r--r--tests/reflection/global-uniforms.hlsl.expected72
-rw-r--r--tests/reflection/multi-file-extra.hlsl63
-rw-r--r--tests/reflection/multi-file.hlsl56
-rw-r--r--tests/reflection/multi-file.hlsl.expected238
-rw-r--r--tests/reflection/reflection0.hlsl19
-rw-r--r--tests/reflection/reflection0.hlsl.expected44
-rw-r--r--tests/reflection/resource-in-cbuffer.hlsl21
-rw-r--r--tests/reflection/resource-in-cbuffer.hlsl.expected60
11 files changed, 724 insertions, 0 deletions
diff --git a/tests/reflection/arrays.hlsl b/tests/reflection/arrays.hlsl
new file mode 100644
index 000000000..8880aaebd
--- /dev/null
+++ b/tests/reflection/arrays.hlsl
@@ -0,0 +1,27 @@
+//TEST:SIMPLE:-profile ps_4_0 -target reflection-json
+
+// Confirm that we can generate reflection info for arrays
+//
+// Note: just working with fixed-size arrays for now.
+// Unbounded arrays may require more work.
+
+cbuffer MyConstantBuffer
+{
+ float x;
+
+ float a[10];
+
+ float y;
+}
+
+Texture2D tx;
+Texture2D ta[16];
+Texture2D ty;
+SamplerState sx;
+SamplerState sa[4];
+SamplerState sy;
+
+float4 main() : SV_Target
+{
+ return 0.0;
+} \ No newline at end of file
diff --git a/tests/reflection/arrays.hlsl.expected b/tests/reflection/arrays.hlsl.expected
new file mode 100644
index 000000000..052bd3927
--- /dev/null
+++ b/tests/reflection/arrays.hlsl.expected
@@ -0,0 +1,103 @@
+result code = 0
+standard error = {
+}
+standard output = {
+{
+ "parameters": [
+ {
+ "name": "MyConstantBuffer",
+ "binding": {"kind": "constantBuffer", "index": 0},
+ "type": {
+ "kind": "constantBuffer",
+ "elementType": {
+ "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}
+ }
+ ]
+ }
+ }
+ },
+ {
+ "name": "tx",
+ "binding": {"kind": "shaderResource", "index": 0},
+ "type": {
+ "kind": "resource",
+ "baseShape": "texture2D"
+ }
+ },
+ {
+ "name": "ta",
+ "binding": {"kind": "shaderResource", "index": 1, "count": 16},
+ "type": {
+ "kind": "array",
+ "elementCount": 16,
+ "elementType": {
+ "kind": "resource",
+ "baseShape": "texture2D"
+ }
+ }
+ },
+ {
+ "name": "ty",
+ "binding": {"kind": "shaderResource", "index": 17},
+ "type": {
+ "kind": "resource",
+ "baseShape": "texture2D"
+ }
+ },
+ {
+ "name": "sx",
+ "binding": {"kind": "samplerState", "index": 0},
+ "type": {
+ "kind": "samplerState"
+ }
+ },
+ {
+ "name": "sa",
+ "binding": {"kind": "samplerState", "index": 1, "count": 4},
+ "type": {
+ "kind": "array",
+ "elementCount": 4,
+ "elementType": {
+ "kind": "samplerState"
+ }
+ }
+ },
+ {
+ "name": "sy",
+ "binding": {"kind": "samplerState", "index": 5},
+ "type": {
+ "kind": "samplerState"
+ }
+ }
+ ]
+}
+}
diff --git a/tests/reflection/global-uniforms.hlsl b/tests/reflection/global-uniforms.hlsl
new file mode 100644
index 000000000..7845af4b6
--- /dev/null
+++ b/tests/reflection/global-uniforms.hlsl
@@ -0,0 +1,21 @@
+//TEST:SIMPLE:-profile ps_4_0 -target reflection-json
+
+// Confirm that we handle uniforms at global scope
+
+
+float4 u;
+
+Texture2D t;
+SamplerState s;
+
+cbuffer CB
+{
+ float4 v;
+}
+
+float4 w;
+
+float4 main() : SV_Target
+{
+ return u + v + w + t.Sample(s, u.xy);
+} \ No newline at end of file
diff --git a/tests/reflection/global-uniforms.hlsl.expected b/tests/reflection/global-uniforms.hlsl.expected
new file mode 100644
index 000000000..b40b2d69c
--- /dev/null
+++ b/tests/reflection/global-uniforms.hlsl.expected
@@ -0,0 +1,72 @@
+result code = 0
+standard error = {
+}
+standard output = {
+{
+ "parameters": [
+ {
+ "name": "u",
+ "binding": {"kind": "uniform", "offset": 0, "size": 16},
+ "type": {
+ "kind": "vector",
+ "elementCount": 4,
+ "elementType": {
+ "kind": "scalar",
+ "scalarType": "float32"
+ }
+ }
+ },
+ {
+ "name": "t",
+ "binding": {"kind": "shaderResource", "index": 0},
+ "type": {
+ "kind": "resource",
+ "baseShape": "texture2D"
+ }
+ },
+ {
+ "name": "s",
+ "binding": {"kind": "samplerState", "index": 0},
+ "type": {
+ "kind": "samplerState"
+ }
+ },
+ {
+ "name": "CB",
+ "binding": {"kind": "constantBuffer", "index": 1},
+ "type": {
+ "kind": "constantBuffer",
+ "elementType": {
+ "kind": "struct",
+ "fields": [
+ {
+ "name": "v",
+ "type": {
+ "kind": "vector",
+ "elementCount": 4,
+ "elementType": {
+ "kind": "scalar",
+ "scalarType": "float32"
+ }
+ },
+ "binding": {"kind": "uniform", "offset": 0, "size": 16}
+ }
+ ]
+ }
+ }
+ },
+ {
+ "name": "w",
+ "binding": {"kind": "uniform", "offset": 16, "size": 16},
+ "type": {
+ "kind": "vector",
+ "elementCount": 4,
+ "elementType": {
+ "kind": "scalar",
+ "scalarType": "float32"
+ }
+ }
+ }
+ ]
+}
+}
diff --git a/tests/reflection/multi-file-extra.hlsl b/tests/reflection/multi-file-extra.hlsl
new file mode 100644
index 000000000..569ec2ce9
--- /dev/null
+++ b/tests/reflection/multi-file-extra.hlsl
@@ -0,0 +1,63 @@
+//TEST_IGNORE_FILE:
+
+// Here we are going to test that we can correctly generating bindings when we
+// are presented with a program spanning multiple input files (and multiple entry points)
+
+// This file provides the fragment shader, and is only meant to be tested in combination with `multi-file.hlsl`
+
+// Let's make sure we generate correct output in cases
+// where there are non-trivial `packoffset`s needed
+
+#ifdef __SPIRE__
+#define R(X) /**/
+#else
+#define R(X) X
+#endif
+
+float4 use(float val) { return val; };
+float4 use(float2 val) { return float4(val,0.0,0.0); };
+float4 use(float3 val) { return float4(val,0.0); };
+float4 use(float4 val) { return val; };
+float4 use(Texture2D t, SamplerState s) { return t.Sample(s, 0.0); }
+
+// Start with some parameters that will appear in both shaders
+Texture2D sharedT;
+SamplerState sharedS;
+cbuffer sharedC
+{
+ float3 sharedCA;
+ float sharedCB;
+ float3 sharedCC;
+ float2 sharedCD;
+}
+
+// Then some parameters specific to this shader.
+// These will be placed *after* the ones from the main file,
+// and even after the parameters further down in this file
+// that end up being shared between the two files.
+
+Texture2D fragmentT;
+SamplerState fragmentS;
+cbuffer fragmentC
+{
+ float3 fragmentCA;
+ float fragmentCB;
+ float3 fragmentCC;
+ float2 fragmentCD;
+}
+
+// And end with some shared parameters again
+Texture2D sharedTV;
+Texture2D sharedTF;
+
+
+float4 main() : SV_Target
+{
+ // Go ahead and use everything here, just to make sure things got placed correctly
+ return use(sharedT, sharedS)
+ + use(sharedCD)
+ + use(fragmentT, fragmentS)
+ + use(fragmentCD)
+ + use(sharedTF, sharedS)
+ ;
+} \ No newline at end of file
diff --git a/tests/reflection/multi-file.hlsl b/tests/reflection/multi-file.hlsl
new file mode 100644
index 000000000..b263a6b71
--- /dev/null
+++ b/tests/reflection/multi-file.hlsl
@@ -0,0 +1,56 @@
+//TEST:SIMPLE:-profile ps_4_0 -target reflection-json Tests/bindings/multi-file-extra.hlsl
+
+// Here we are testing the case where multiple translation units are provided
+// at once, so that we want combined reflection information for the resulting
+// program. The other part of this program is in `multi-file-extra.hlsl`.
+
+float4 use(float val) { return val; };
+float4 use(float2 val) { return float4(val,0.0,0.0); };
+float4 use(float3 val) { return float4(val,0.0); };
+float4 use(float4 val) { return val; };
+float4 use(Texture2D t, SamplerState s)
+{
+ // This is the vertex shader, so we can't do implicit-gradient sampling
+ return t.SampleGrad(s, 0.0, 0.0, 0.0);
+}
+
+// Start with some parameters that will appear in both shaders
+Texture2D sharedT;
+SamplerState sharedS;
+cbuffer sharedC
+{
+ float3 sharedCA;
+ float sharedCB;
+ float3 sharedCC;
+ float2 sharedCD;
+}
+
+// Then some parameters specific to this shader
+// (these will get placed before the ones in the `extra` file,
+// based on how they get named on the command-line)
+
+Texture2D vertexT;
+SamplerState vertexS;
+cbuffer vertexC
+{
+ float3 vertexCA;
+ float vertexCB;
+ float3 vertexCC;
+ float2 vertexCD;
+}
+
+// And end with some shared parameters again
+Texture2D sharedTV;
+Texture2D sharedTF;
+
+
+float4 main() : SV_Position
+{
+ // Go ahead and use everything here, just to make sure things got placed correctly
+ return use(sharedT, sharedS)
+ + use(sharedCD)
+ + use(vertexT, vertexS)
+ + use(vertexCD)
+ + use(sharedTV, vertexS)
+ ;
+} \ No newline at end of file
diff --git a/tests/reflection/multi-file.hlsl.expected b/tests/reflection/multi-file.hlsl.expected
new file mode 100644
index 000000000..38d028ffe
--- /dev/null
+++ b/tests/reflection/multi-file.hlsl.expected
@@ -0,0 +1,238 @@
+result code = 0
+standard error = {
+}
+standard output = {
+{
+ "parameters": [
+ {
+ "name": "sharedT",
+ "binding": {"kind": "shaderResource", "index": 0},
+ "type": {
+ "kind": "resource",
+ "baseShape": "texture2D"
+ }
+ },
+ {
+ "name": "sharedS",
+ "binding": {"kind": "samplerState", "index": 0},
+ "type": {
+ "kind": "samplerState"
+ }
+ },
+ {
+ "name": "sharedC",
+ "binding": {"kind": "constantBuffer", "index": 0},
+ "type": {
+ "kind": "constantBuffer",
+ "elementType": {
+ "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}
+ }
+ ]
+ }
+ }
+ },
+ {
+ "name": "vertexT",
+ "binding": {"kind": "shaderResource", "index": 1},
+ "type": {
+ "kind": "resource",
+ "baseShape": "texture2D"
+ }
+ },
+ {
+ "name": "vertexS",
+ "binding": {"kind": "samplerState", "index": 1},
+ "type": {
+ "kind": "samplerState"
+ }
+ },
+ {
+ "name": "vertexC",
+ "binding": {"kind": "constantBuffer", "index": 1},
+ "type": {
+ "kind": "constantBuffer",
+ "elementType": {
+ "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}
+ }
+ ]
+ }
+ }
+ },
+ {
+ "name": "sharedTV",
+ "binding": {"kind": "shaderResource", "index": 2},
+ "type": {
+ "kind": "resource",
+ "baseShape": "texture2D"
+ }
+ },
+ {
+ "name": "sharedTF",
+ "binding": {"kind": "shaderResource", "index": 3},
+ "type": {
+ "kind": "resource",
+ "baseShape": "texture2D"
+ }
+ },
+ {
+ "name": "fragmentT",
+ "binding": {"kind": "shaderResource", "index": 4},
+ "type": {
+ "kind": "resource",
+ "baseShape": "texture2D"
+ }
+ },
+ {
+ "name": "fragmentS",
+ "binding": {"kind": "samplerState", "index": 2},
+ "type": {
+ "kind": "samplerState"
+ }
+ },
+ {
+ "name": "fragmentC",
+ "binding": {"kind": "constantBuffer", "index": 2},
+ "type": {
+ "kind": "constantBuffer",
+ "elementType": {
+ "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}
+ }
+ ]
+ }
+ }
+ }
+ ]
+}
+}
diff --git a/tests/reflection/reflection0.hlsl b/tests/reflection/reflection0.hlsl
new file mode 100644
index 000000000..1f138894f
--- /dev/null
+++ b/tests/reflection/reflection0.hlsl
@@ -0,0 +1,19 @@
+//TEST:SIMPLE:-profile ps_4_0 -target reflection-json
+
+// Confirm that basic reflection info can be output
+
+float4 use(float4 val) { return val; };
+float4 use(Texture2D t, SamplerState s) { return t.Sample(s, 0.0); }
+
+Texture2D t;
+SamplerState s;
+
+cbuffer C
+{
+ float c;
+}
+
+float4 main() : SV_Target
+{
+ return use(t,s) + use(c);
+} \ No newline at end of file
diff --git a/tests/reflection/reflection0.hlsl.expected b/tests/reflection/reflection0.hlsl.expected
new file mode 100644
index 000000000..3b74988b2
--- /dev/null
+++ b/tests/reflection/reflection0.hlsl.expected
@@ -0,0 +1,44 @@
+result code = 0
+standard error = {
+}
+standard output = {
+{
+ "parameters": [
+ {
+ "name": "t",
+ "binding": {"kind": "shaderResource", "index": 0},
+ "type": {
+ "kind": "resource",
+ "baseShape": "texture2D"
+ }
+ },
+ {
+ "name": "s",
+ "binding": {"kind": "samplerState", "index": 0},
+ "type": {
+ "kind": "samplerState"
+ }
+ },
+ {
+ "name": "C",
+ "binding": {"kind": "constantBuffer", "index": 0},
+ "type": {
+ "kind": "constantBuffer",
+ "elementType": {
+ "kind": "struct",
+ "fields": [
+ {
+ "name": "c",
+ "type": {
+ "kind": "scalar",
+ "scalarType": "float32"
+ },
+ "binding": {"kind": "uniform", "offset": 0, "size": 4}
+ }
+ ]
+ }
+ }
+ }
+ ]
+}
+}
diff --git a/tests/reflection/resource-in-cbuffer.hlsl b/tests/reflection/resource-in-cbuffer.hlsl
new file mode 100644
index 000000000..956387587
--- /dev/null
+++ b/tests/reflection/resource-in-cbuffer.hlsl
@@ -0,0 +1,21 @@
+//TEST:SIMPLE:-profile ps_4_0 -target reflection-json
+
+// Confirm that we can generate reflection
+// information for resources nested inside
+// a cbuffer:
+
+cbuffer MyConstantBuffer
+{
+ float3 v;
+
+ Texture2D myTexture;
+
+ float c;
+
+ SamplerState mySampler;
+}
+
+float4 main() : SV_Target
+{
+ return 0.0;
+} \ No newline at end of file
diff --git a/tests/reflection/resource-in-cbuffer.hlsl.expected b/tests/reflection/resource-in-cbuffer.hlsl.expected
new file mode 100644
index 000000000..faae1c8b7
--- /dev/null
+++ b/tests/reflection/resource-in-cbuffer.hlsl.expected
@@ -0,0 +1,60 @@
+result code = 0
+standard error = {
+}
+standard output = {
+{
+ "parameters": [
+ {
+ "name": "MyConstantBuffer",
+ "bindings": [
+ {"kind": "constantBuffer", "index": 0},
+ {"kind": "shaderResource", "index": 0},
+ {"kind": "samplerState", "index": 0}
+ ],
+ "type": {
+ "kind": "constantBuffer",
+ "elementType": {
+ "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}
+ }
+ ]
+ }
+ }
+ }
+ ]
+}
+}