summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/compute/assoctype-lookup.slang58
-rw-r--r--tests/compute/assoctype-lookup.slang.expected.txt4
2 files changed, 62 insertions, 0 deletions
diff --git a/tests/compute/assoctype-lookup.slang b/tests/compute/assoctype-lookup.slang
new file mode 100644
index 000000000..1dccc8e12
--- /dev/null
+++ b/tests/compute/assoctype-lookup.slang
@@ -0,0 +1,58 @@
+// assoctype-nested.slang
+
+// Confirm that an associated type can be correctly looked up.
+
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cpu
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute
+
+interface IBoneWeightSet
+{
+ associatedtype PackedType;
+};
+
+struct StandardBoneWeightSet : IBoneWeightSet
+{
+ struct PackedType
+ {
+ uint boneIds : BONEIDS;
+ uint boneWeights : BONEWEIGHTS;
+ };
+ PackedType field;
+};
+
+interface IVertexFormat
+{
+ associatedtype BoneWeightSet : IBoneWeightSet;
+};
+
+struct VertexFormat<TBoneWeightSet : IBoneWeightSet> : IVertexFormat
+{
+ typedef TBoneWeightSet BoneWeightSet;
+ TBoneWeightSet.PackedType weightSet;
+};
+
+struct OutputType
+{
+ VertexFormat<StandardBoneWeightSet>.BoneWeightSet.PackedType field;
+};
+
+int test(int val)
+{
+ OutputType rs;
+ rs.field.boneIds = 256;
+ return rs.field.boneIds;
+}
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer
+RWStructuredBuffer<int> gOutputBuffer;
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+ int inputVal = tid;
+ int outputVal = test(inputVal);
+ gOutputBuffer[tid] = outputVal;
+} \ No newline at end of file
diff --git a/tests/compute/assoctype-lookup.slang.expected.txt b/tests/compute/assoctype-lookup.slang.expected.txt
new file mode 100644
index 000000000..54248c25a
--- /dev/null
+++ b/tests/compute/assoctype-lookup.slang.expected.txt
@@ -0,0 +1,4 @@
+100
+100
+100
+100 \ No newline at end of file