================
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute 
-finclude-default-header -verify %s
+
+struct A {
+  RWBuffer<float> Buf;
+  RWBuffer<float> ManyBufs[5];
+};
+
+A array[10] : register(u10);
+
+[numthreads(4,1,1)]
+void main(uint GI : SV_GroupThreadID) {
+  
+  // expected-error@+1 {{index for struct array inside cbuffer that contains 
resources must be a literal expression}}
+  array[GI].Buf[0] = 1.0f; 
+
+  array[2].Buf[GI] = 2.0f; // ok
+
+  // expected-error@+1 {{index for struct array inside cbuffer that contains 
resources must be a literal expression}}
+  array[GI].ManyBufs[3][0] = 3.0f;
+
+  array[1].ManyBufs[GI][0] = 4.0f; // ok
----------------
hekota wrote:

Ok, I see what you mean. The value of the local variable in this case is known 
at compile time, but that does not have to be the case everytime. If we add `if 
(GI > 2) x = 1;` then the value of 'x' it can no longer be determined, which 
makes it the same as the `GI` case. Since we are changing the behavior from 
DXC, I will add the test case for completeness.

https://github.com/llvm/llvm-project/pull/187132
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to