tint/transform: Fix index 0 accessing in DecomposeMemoryAccess

This patch fix a bug in DecomposeMemoryAccess, allowing access index 0
of a member in uniform and storage buffer being recognized as constant
index.

Bug: tint:1652
Change-Id: Ia428de17c860bdafe87c3af9e46426c74fe8fd68
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99480
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Zhaoming Jiang <zhaoming.jiang@intel.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Zhaoming Jiang 2022-08-17 18:15:00 +00:00 committed by Dawn LUCI CQ
parent dce63f5717
commit ff1330240b
15 changed files with 29 additions and 31 deletions

View File

@ -328,7 +328,7 @@ struct DecomposeMemoryAccess::State {
/// @returns an Offset for the given ast::Expression
const Offset* ToOffset(const ast::Expression* expr) {
if (auto* lit = expr->As<ast::IntLiteralExpression>()) {
if (lit->value > 0) {
if (lit->value >= 0) {
return offsets_.Create<OffsetLiteral>(static_cast<uint32_t>(lit->value));
}
}

View File

@ -16,6 +16,6 @@ S tint_symbol_4(ByteAddressBuffer buffer, uint offset) {
[numthreads(1, 1, 1)]
void main() {
tint_symbol_2(tint_symbol_1, (4u * 0u), tint_symbol_4(tint_symbol, (4u * 0u)));
tint_symbol_2(tint_symbol_1, 0u, tint_symbol_4(tint_symbol, 0u));
return;
}

View File

@ -16,6 +16,6 @@ S tint_symbol_4(ByteAddressBuffer buffer, uint offset) {
[numthreads(1, 1, 1)]
void main() {
tint_symbol_2(tint_symbol_1, (4u * 0u), tint_symbol_4(tint_symbol, (4u * 0u)));
tint_symbol_2(tint_symbol_1, 0u, tint_symbol_4(tint_symbol, 0u));
return;
}

View File

@ -60,10 +60,10 @@ int tint_atomicLoad_1(RWByteAddressBuffer buffer, uint offset) {
void doIgnore() {
uint g43 = uniforms[0].x;
uint kj6 = dbg.Load(20u);
uint b53 = tint_atomicLoad(counters, (4u * 0u));
uint rwg = indices.Load((4u * 0u));
float rb5 = asfloat(positions.Load((4u * 0u)));
int g55 = tint_atomicLoad_1(LUT, (4u * 0u));
uint b53 = tint_atomicLoad(counters, 0u);
uint rwg = indices.Load(0u);
float rb5 = asfloat(positions.Load(0u));
int g55 = tint_atomicLoad_1(LUT, 0u);
}
struct tint_symbol_1 {

View File

@ -60,10 +60,10 @@ int tint_atomicLoad_1(RWByteAddressBuffer buffer, uint offset) {
void doIgnore() {
uint g43 = uniforms[0].x;
uint kj6 = dbg.Load(20u);
uint b53 = tint_atomicLoad(counters, (4u * 0u));
uint rwg = indices.Load((4u * 0u));
float rb5 = asfloat(positions.Load((4u * 0u)));
int g55 = tint_atomicLoad_1(LUT, (4u * 0u));
uint b53 = tint_atomicLoad(counters, 0u);
uint rwg = indices.Load(0u);
float rb5 = asfloat(positions.Load(0u));
int g55 = tint_atomicLoad_1(LUT, 0u);
}
struct tint_symbol_1 {

View File

@ -28,7 +28,7 @@ Particle tint_symbol_2(ByteAddressBuffer buffer, uint offset) {
[numthreads(1, 1, 1)]
void main() {
Particle particle = tint_symbol_2(particles, (176u * 0u));
Particle particle = tint_symbol_2(particles, 0u);
{
float3 tint_symbol_1[8] = particle.position;
tint_symbol_1[sim[0].x] = particle.position[sim[0].x];

View File

@ -28,7 +28,7 @@ Particle tint_symbol_2(ByteAddressBuffer buffer, uint offset) {
[numthreads(1, 1, 1)]
void main() {
Particle particle = tint_symbol_2(particles, (176u * 0u));
Particle particle = tint_symbol_2(particles, 0u);
{
float3 tint_symbol_1[8] = particle.position;
tint_symbol_1[sim[0].x] = particle.position[sim[0].x];

View File

@ -23,8 +23,7 @@ void main_1() {
const float4 x_21 = q;
p = float3(x_21.x, x_21.y, x_21.z);
const float x_27 = p.x;
const uint scalar_offset_4 = ((208u + (16u * 0u))) / 4;
const float x_41 = asfloat(x_14[scalar_offset_4 / 4][scalar_offset_4 % 4]);
const float x_41 = asfloat(x_14[13].x);
const float x_45 = position.y;
const float x_49 = asfloat(x_14[4].x);
p.x = (x_27 + sin(((x_41 * x_45) + x_49)));

View File

@ -23,8 +23,7 @@ void main_1() {
const float4 x_21 = q;
p = float3(x_21.x, x_21.y, x_21.z);
const float x_27 = p.x;
const uint scalar_offset_4 = ((208u + (16u * 0u))) / 4;
const float x_41 = asfloat(x_14[scalar_offset_4 / 4][scalar_offset_4 % 4]);
const float x_41 = asfloat(x_14[13].x);
const float x_45 = position.y;
const float x_49 = asfloat(x_14[4].x);
p.x = (x_27 + sin(((x_41 * x_45) + x_49)));

View File

@ -57,10 +57,10 @@ int tint_atomicLoad_1(RWByteAddressBuffer buffer, uint offset) {
void doIgnore() {
uint g42 = uniforms[0].x;
uint kj6 = dbg.Load(20u);
uint b53 = tint_atomicLoad(counters, (4u * 0u));
uint rwg = indices.Load((4u * 0u));
float rb5 = asfloat(positions.Load((4u * 0u)));
int g55 = tint_atomicLoad_1(LUT, (4u * 0u));
uint b53 = tint_atomicLoad(counters, 0u);
uint rwg = indices.Load(0u);
float rb5 = asfloat(positions.Load(0u));
int g55 = tint_atomicLoad_1(LUT, 0u);
}
struct tint_symbol_1 {

View File

@ -57,10 +57,10 @@ int tint_atomicLoad_1(RWByteAddressBuffer buffer, uint offset) {
void doIgnore() {
uint g42 = uniforms[0].x;
uint kj6 = dbg.Load(20u);
uint b53 = tint_atomicLoad(counters, (4u * 0u));
uint rwg = indices.Load((4u * 0u));
float rb5 = asfloat(positions.Load((4u * 0u)));
int g55 = tint_atomicLoad_1(LUT, (4u * 0u));
uint b53 = tint_atomicLoad(counters, 0u);
uint rwg = indices.Load(0u);
float rb5 = asfloat(positions.Load(0u));
int g55 = tint_atomicLoad_1(LUT, 0u);
}
struct tint_symbol_1 {

View File

@ -1,7 +1,7 @@
ByteAddressBuffer data : register(t1, space0);
int foo() {
return asint(data.Load((4u * 0u)));
return asint(data.Load(0u));
}
[numthreads(16, 16, 1)]

View File

@ -1,7 +1,7 @@
ByteAddressBuffer data : register(t1, space0);
int foo() {
return asint(data.Load((4u * 0u)));
return asint(data.Load(0u));
}
[numthreads(16, 16, 1)]

View File

@ -199,7 +199,7 @@ void main1() {
if ((x_e52.x == 2.0f)) {
{
const float3 x_e59 = a_Normal1;
const Mat4x2_ x_e64 = tint_symbol_8(global1, (32u * 0u));
const Mat4x2_ x_e64 = tint_symbol_8(global1, 0u);
const float2 x_e68 = Mul2(x_e64, float4(a_Normal1, 1.0f));
v_TexCoord = x_e68.xy;
return;
@ -207,7 +207,7 @@ void main1() {
} else {
{
const float2 x_e73 = a_UV1;
const Mat4x2_ x_e79 = tint_symbol_8(global1, (32u * 0u));
const Mat4x2_ x_e79 = tint_symbol_8(global1, 0u);
const float2 x_e84 = Mul2(x_e79, float4(a_UV1, 1.0f, 1.0f));
v_TexCoord = x_e84.xy;
return;

View File

@ -199,7 +199,7 @@ void main1() {
if ((x_e52.x == 2.0f)) {
{
const float3 x_e59 = a_Normal1;
const Mat4x2_ x_e64 = tint_symbol_8(global1, (32u * 0u));
const Mat4x2_ x_e64 = tint_symbol_8(global1, 0u);
const float2 x_e68 = Mul2(x_e64, float4(a_Normal1, 1.0f));
v_TexCoord = x_e68.xy;
return;
@ -207,7 +207,7 @@ void main1() {
} else {
{
const float2 x_e73 = a_UV1;
const Mat4x2_ x_e79 = tint_symbol_8(global1, (32u * 0u));
const Mat4x2_ x_e79 = tint_symbol_8(global1, 0u);
const float2 x_e84 = Mul2(x_e79, float4(a_UV1, 1.0f, 1.0f));
v_TexCoord = x_e84.xy;
return;