HLSL-IR: implement LocalizeStructArrayAssignment for FXC
Implements the same transform as on the AST path. Works around FXC's
compilation failure:
error X3500: array reference cannot be used as an l-value; not natively addressable
This happens in a few cases, but with this transform, we deal with the
case of dynamic indexing an array within a struct local/private
variable.
Bug; 368355095
Change-Id: I2e3c68679afa1cc1ad51fc0e104dca1af9540272
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/208614
Reviewed-by: James Price <jrprice@google.com>
Auto-Submit: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
diff --git a/test/tint/ptr_sugar/matrix.wgsl.expected.ir.fxc.hlsl b/test/tint/ptr_sugar/matrix.wgsl.expected.ir.fxc.hlsl
index 7f90e3e..fc5524e 100644
--- a/test/tint/ptr_sugar/matrix.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/ptr_sugar/matrix.wgsl.expected.ir.fxc.hlsl
@@ -1,16 +1,14 @@
void deref() {
float2x3 a = float2x3((0.0f).xxx, (0.0f).xxx);
- float2x3 p = a;
- float3 b = p[int(0)];
- p[int(0)] = float3(1.0f, 2.0f, 3.0f);
+ float3 b = a[int(0)];
+ a[int(0)] = float3(1.0f, 2.0f, 3.0f);
}
void no_deref() {
float2x3 a = float2x3((0.0f).xxx, (0.0f).xxx);
- float2x3 p = a;
- float3 b = p[int(0)];
- p[int(0)] = float3(1.0f, 2.0f, 3.0f);
+ float3 b = a[int(0)];
+ a[int(0)] = float3(1.0f, 2.0f, 3.0f);
}
[numthreads(1, 1, 1)]