summaryrefslogtreecommitdiff
path: root/tests/experiments/generic/type-to-value-4.slang
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-02-03 09:28:54 -0500
committerGitHub <noreply@github.com>2022-02-03 09:28:54 -0500
commit3aaa586c90a688e035e2941a2e0327bd96a681cb (patch)
tree31f73cb42bdb1bca65b294124f37e6109011b533 /tests/experiments/generic/type-to-value-4.slang
parent5deb82929d289d6341e1919ee95b18b10f6db789 (diff)
'Explicit specialization' experiments with extensions (#2099)
* #include an absolute path didn't work - because paths were taken to always be relative. * Explicit specialization with multiple parameters. * Fix tabs. * Small improvements in test comments.
Diffstat (limited to 'tests/experiments/generic/type-to-value-4.slang')
-rw-r--r--tests/experiments/generic/type-to-value-4.slang42
1 files changed, 35 insertions, 7 deletions
diff --git a/tests/experiments/generic/type-to-value-4.slang b/tests/experiments/generic/type-to-value-4.slang
index 986fffaf7..741b30791 100644
--- a/tests/experiments/generic/type-to-value-4.slang
+++ b/tests/experiments/generic/type-to-value-4.slang
@@ -2,12 +2,40 @@
/* Test here is to try and associate a value with a type
-This doesn't work - it produces dynamic dispatch code, that is uncompilable because cases
-are missing.
+This doesn't work without 'public' on struct B. This is necessary such that
+those implementations of `IGetE` are visible for dynamic dispatch.
-.slang(24): error : control reaches end of non-void function [-Wreturn-type]
-dxc: note : }
-dxc: note : ^
+Otherwise the error
+
+> tests/experiments/generic/type-to-value-4.slang(21): error 50100: No type conformances are found for interface 'IGetE'. Code generation for current target requires at least one implementation type present in the linkage.
+> interface IGetE
+ ^~~~~
+
+This is somewhat 'surprising' because the code *explicitly* instanciates B, so why is it necessary to make it
+public?
+
+If we make both struct A and struct B public, the following code uses dynamic dispatch in order to implement e.getE(). When it does this it introduces
+
+```HLSL
+struct Tuple_0
+{
+ uint2 value0_0;
+ uint2 value1_0;
+ AnyValue16 value2_0;
+};
+
+Tuple_0 _S1;
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID_0 : SV_DISPATCHTHREADID)
+{
+ int _S7 = U_S3tu05IGetE4getEp0p3tu04Enum_0(_S1.value1_0);
+
+ // ...
+}
+```
+
+But _S1 is never intialized (in HLSL it becomes a Global in a constant buffer). Why does creating a local variable produce something in a constant buffer?
*/
@@ -24,12 +52,12 @@ interface IGetE
static Enum getE();
};
-struct A : IGetE
+public struct A : IGetE
{
static Enum getE() { return Enum::A; }
};
-struct B : IGetE
+public struct B : IGetE
{
static Enum getE() { return Enum::B; }
};