summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2018-01-02 22:04:50 -0800
committerTim Foley <tfoleyNV@users.noreply.github.com>2018-01-02 22:04:50 -0800
commit1e0aabf4b28f48bfbfee7b1a9c08031892c004d0 (patch)
tree2ad25a371def11f89cfd77e61116002d6d028bdd /tests
parent66f9a7cefe351d7e0a27fa77fbfe5ca93f2d8133 (diff)
no-codegen compile flag and global generics reflection (#347)
* no-codegen compile flag and global generics reflection 1. Add SLANG_COMPILE_FLAG_NO_CODEGEN (-no-codegen) compiler flag to skip code generation stage, so that a shader that uses global generic type parmameters can be parsed, checked and introspected without knowing the final specialization. 2. Add reflection API to query for global generic type parameters, global parameters of generic type, and the generic type parameter index related to a global generic parameter. 3. Add a reflection test case for global generic type parameters. * add expected result for global-type-params test case. * fix reflection json output. * fix branch condition errors * fix expected result for global-type-params.slang * fix expected test case output
Diffstat (limited to 'tests')
-rw-r--r--tests/reflection/global-type-params.slang35
-rw-r--r--tests/reflection/global-type-params.slang.expected127
2 files changed, 162 insertions, 0 deletions
diff --git a/tests/reflection/global-type-params.slang b/tests/reflection/global-type-params.slang
new file mode 100644
index 000000000..bfeb7fb2e
--- /dev/null
+++ b/tests/reflection/global-type-params.slang
@@ -0,0 +1,35 @@
+//TEST:REFLECTION:-profile ps_4_0 -target hlsl -no-codegen
+
+// Confirm that we handle global generic parameters
+
+
+float4 u;
+
+interface IBase
+{};
+
+__generic_param TParam : IBase;
+__generic_param TParam2 : IBase;
+
+struct S
+{
+ TParam2 p;
+};
+
+ParameterBlock<S> arg;
+ParameterBlock<TParam> arg1;
+
+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-type-params.slang.expected b/tests/reflection/global-type-params.slang.expected
new file mode 100644
index 000000000..1e3a6aa99
--- /dev/null
+++ b/tests/reflection/global-type-params.slang.expected
@@ -0,0 +1,127 @@
+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": "arg",
+ "binding": {"kind": "generic", "index": 0},
+ "type": {
+ "kind": "parameterBlock",
+ "elementType": {
+ "kind": "struct",
+ "name": "S",
+ "fields": [
+ {
+ "name": "p",
+ "type": {
+ "kind": "GenericTypeParameter",
+ "name": "TParam2"
+ },
+ "binding": {"kind": "generic", "index": 0}
+ }
+ ]
+ }
+ }
+ },
+ {
+ "name": "arg1",
+ "binding": {"kind": "generic", "index": 0},
+ "type": {
+ "kind": "parameterBlock",
+ "elementType": {
+ "kind": "GenericTypeParameter",
+ "name": "TParam"
+ }
+ }
+ },
+ {
+ "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"
+ }
+ }
+ }
+ ],
+ "typeParams":
+ [
+ {
+ "name": "TParam",
+ constraints:
+ [
+ {
+ "kind": "Interface",
+ "name": "IBase"
+ }
+ ]
+ },
+ {
+ "name": "TParam2",
+ constraints:
+ [
+ {
+ "kind": "Interface",
+ "name": "IBase"
+ }
+ ]
+ }
+ ]
+}
+}