summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/language-feature/extensions/generic-extension-3.slang42
-rw-r--r--tests/language-feature/extensions/generic-extension-4.slang58
2 files changed, 100 insertions, 0 deletions
diff --git a/tests/language-feature/extensions/generic-extension-3.slang b/tests/language-feature/extensions/generic-extension-3.slang
new file mode 100644
index 000000000..358c3facd
--- /dev/null
+++ b/tests/language-feature/extensions/generic-extension-3.slang
@@ -0,0 +1,42 @@
+// Test that multiple functions from different extensions are properly linked.
+
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj
+interface IValuable
+{
+ int getValue();
+};
+
+__generic <Int : __BuiltinIntegerType>
+extension Int : IValuable
+{
+ int getValue()
+ {
+ return 0;
+ }
+};
+
+__generic <Float : __BuiltinFloatingPointType>
+extension Float : IValuable
+{
+ int getValue()
+ {
+ return 1;
+ }
+};
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+[shader("compute")]
+[numthreads(1, 1, 1)]
+void computeMain()
+{
+ uint i = 0;
+ float f = float(i) / float(10);
+
+ // CHECK: 0
+ outputBuffer[0] = i.getValue();
+
+ // CHECK: 1
+ outputBuffer[1] = f.getValue();
+} \ No newline at end of file
diff --git a/tests/language-feature/extensions/generic-extension-4.slang b/tests/language-feature/extensions/generic-extension-4.slang
new file mode 100644
index 000000000..61e1c1386
--- /dev/null
+++ b/tests/language-feature/extensions/generic-extension-4.slang
@@ -0,0 +1,58 @@
+// Test that multiple functions from different extensions are properly linked through their respective witness table.
+
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj
+interface IValuableImpl
+{
+ int getValue();
+}
+
+interface IValuable
+{
+ associatedtype Impl : IValuableImpl;
+ Impl getImpl();
+};
+
+__generic <Int : __BuiltinIntegerType>
+extension Int : IValuableImpl
+{
+ int getValue()
+ {
+ return 0;
+ }
+};
+
+__generic <Float : __BuiltinFloatingPointType>
+extension Float : IValuableImpl
+{
+ int getValue()
+ {
+ return 1;
+ }
+};
+
+__generic <ValuableImpl : IValuableImpl>
+extension ValuableImpl : IValuable
+{
+ typealias Impl = ValuableImpl;
+ ValuableImpl getImpl()
+ {
+ return this;
+ }
+};
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+[shader("compute")]
+[numthreads(1, 1, 1)]
+void computeMain()
+{
+ uint i = 0;
+ float f = float(i) / float(10);
+
+ // CHECK: 0
+ outputBuffer[0] = i.getImpl().getValue();
+
+ // CHECK: 1
+ outputBuffer[1] = f.getImpl().getValue();
+} \ No newline at end of file