summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-11-06 14:40:38 -0800
committerGitHub <noreply@github.com>2023-11-06 14:40:38 -0800
commit46529df2c4f73a4655bdd79d48004f29374a99a8 (patch)
tree801e69e70a47ce702c055df68ada41a38158367b /tests
parentda9e0adb5cf2b1bed6075a3afe93cfdcceabe904 (diff)
Fix ICE when lowering an associatedtype declref from an derived interface. (#3312)
* Fix ICE when lowering an associatedtype declref from an derived interface. * Fixes. * Fix test. * Fix GLSL/SPIRV image subscript swizzle store regression. * Fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/autodiff/derived-interface.slang55
-rw-r--r--tests/diagnostics/interfaces/mutating-impl-of-non-mutating-req.slang.expected8
-rw-r--r--tests/hlsl-intrinsic/image-swizzle-write.slang15
3 files changed, 74 insertions, 4 deletions
diff --git a/tests/autodiff/derived-interface.slang b/tests/autodiff/derived-interface.slang
new file mode 100644
index 000000000..68e84ebad
--- /dev/null
+++ b/tests/autodiff/derived-interface.slang
@@ -0,0 +1,55 @@
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-slang -compute -shaderobj -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute -shaderobj -output-using-type
+
+//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<float> outputBuffer;
+
+interface IFoo : IDifferentiable
+{
+ [Differentiable]
+ __init<T:IFoo>(T d);
+
+ [Differentiable]
+ static This create(Differential d);
+
+ [Differentiable]
+ float getVal();
+}
+
+struct Impl : IFoo
+{
+ float x;
+ [Differentiable]
+ __init<T : IFoo>(T d)
+ {
+ this = (Impl)d;
+ }
+
+ [Differentiable]
+ static This create(Differential d)
+ {
+ This v;
+ v.x = d.x * d.x;
+ return v;
+ }
+
+ [Differentiable]
+ float getVal() { return x; }
+}
+
+[Differentiable]
+float test<T:IFoo>(T.Differential d)
+{
+ return T.create(d).getVal();
+}
+
+[numthreads(1,1,1)]
+void computeMain(uint threadId: SV_DispatchThreadID)
+{
+ Impl.Differential d;
+ d.x = 3.0;
+ Impl.Differential dd;
+ dd.x = 1.0;
+ outputBuffer[0] = fwd_diff(test<Impl>)(diffPair(d, dd)).d;
+ // CHECK: 6.0
+}
diff --git a/tests/diagnostics/interfaces/mutating-impl-of-non-mutating-req.slang.expected b/tests/diagnostics/interfaces/mutating-impl-of-non-mutating-req.slang.expected
index 3ac7dfa5f..f3382a688 100644
--- a/tests/diagnostics/interfaces/mutating-impl-of-non-mutating-req.slang.expected
+++ b/tests/diagnostics/interfaces/mutating-impl-of-non-mutating-req.slang.expected
@@ -1,9 +1,9 @@
result code = -1
standard error = {
-tests/diagnostics/interfaces/mutating-impl-of-non-mutating-req.slang(10): error 38100: type 'Counter' does not provide required interface member 'processValue'
-struct Counter : IThing
- ^~~~~~
-tests/diagnostics/interfaces/mutating-impl-of-non-mutating-req.slang(7): note: see declaration of 'processValue'
+tests/diagnostics/interfaces/mutating-impl-of-non-mutating-req.slang(14): error 38105: member 'processValue' does not match interface requirement.
+ [mutating] int processValue(int inValue)
+ ^~~~~~~~~~~~
+tests/diagnostics/interfaces/mutating-impl-of-non-mutating-req.slang(7): note: see interface requirement declaration of 'processValue'
int processValue(int inValue);
^~~~~~~~~~~~
}
diff --git a/tests/hlsl-intrinsic/image-swizzle-write.slang b/tests/hlsl-intrinsic/image-swizzle-write.slang
new file mode 100644
index 000000000..e8a006314
--- /dev/null
+++ b/tests/hlsl-intrinsic/image-swizzle-write.slang
@@ -0,0 +1,15 @@
+//TEST:SIMPLE(filecheck=CHECK): -entry computeMain -stage compute -target spirv -emit-spirv-directly
+//TEST:SIMPLE(filecheck=CHECK): -entry computeMain -stage compute -target spirv
+
+layout(rgba6f)
+RWTexture2D<float4> texture;
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ half h = 1.0h;
+ // CHECK: OpImageRead
+ // CEHCK: OpCompositeInsert
+ // CHECK: OpImageWrite
+ texture[dispatchThreadID.xy].a = h;
+}