writer/hlsl: Use unsigned indices for UBOs

These indices were a mix of signed and unsigned.
Modulus on the signed integers was producing FXC warnings about performance.

Change-Id: Ib82f4296199a09d2f03be8b06314feefce0022e2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56765
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Ben Clayton 2021-07-02 19:27:42 +00:00
parent 2bb45389b7
commit 3124d43fda
16 changed files with 73 additions and 73 deletions

View File

@ -623,7 +623,7 @@ bool GeneratorImpl::EmitUniformBufferAccess(
std::string scalar_offset = UniqueIdentifier("scalar_offset");
{
auto pre = line();
pre << "const int " << scalar_offset << " = (";
pre << "const uint " << scalar_offset << " = (";
if (!EmitExpression(pre, params[1])) { // offset
return false;
}

View File

@ -14,10 +14,10 @@ struct S {
};
tint_array_wrapper tint_symbol_2(uint4 buffer[4], uint offset) {
const int scalar_offset = ((offset + 0u)) / 4;
const int scalar_offset_1 = ((offset + 16u)) / 4;
const int scalar_offset_2 = ((offset + 32u)) / 4;
const int scalar_offset_3 = ((offset + 48u)) / 4;
const uint scalar_offset = ((offset + 0u)) / 4;
const uint scalar_offset_1 = ((offset + 16u)) / 4;
const uint scalar_offset_2 = ((offset + 32u)) / 4;
const uint scalar_offset_3 = ((offset + 48u)) / 4;
const tint_array_wrapper tint_symbol_5 = {{{asint(buffer[scalar_offset / 4][scalar_offset % 4])}, {asint(buffer[scalar_offset_1 / 4][scalar_offset_1 % 4])}, {asint(buffer[scalar_offset_2 / 4][scalar_offset_2 % 4])}, {asint(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4])}}};
return tint_symbol_5;
}

View File

@ -14,10 +14,10 @@ struct S {
};
tint_array_wrapper tint_symbol_2(uint4 buffer[4], uint offset) {
const int scalar_offset = ((offset + 0u)) / 4;
const int scalar_offset_1 = ((offset + 16u)) / 4;
const int scalar_offset_2 = ((offset + 32u)) / 4;
const int scalar_offset_3 = ((offset + 48u)) / 4;
const uint scalar_offset = ((offset + 0u)) / 4;
const uint scalar_offset_1 = ((offset + 16u)) / 4;
const uint scalar_offset_2 = ((offset + 32u)) / 4;
const uint scalar_offset_3 = ((offset + 48u)) / 4;
const tint_array_wrapper tint_symbol_5 = {{{asint(buffer[scalar_offset / 4][scalar_offset % 4])}, {asint(buffer[scalar_offset_1 / 4][scalar_offset_1 % 4])}, {asint(buffer[scalar_offset_2 / 4][scalar_offset_2 % 4])}, {asint(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4])}}};
return tint_symbol_5;
}

View File

@ -14,10 +14,10 @@ struct S {
};
tint_array_wrapper tint_symbol_2(uint4 buffer[4], uint offset) {
const int scalar_offset = ((offset + 0u)) / 4;
const int scalar_offset_1 = ((offset + 16u)) / 4;
const int scalar_offset_2 = ((offset + 32u)) / 4;
const int scalar_offset_3 = ((offset + 48u)) / 4;
const uint scalar_offset = ((offset + 0u)) / 4;
const uint scalar_offset_1 = ((offset + 16u)) / 4;
const uint scalar_offset_2 = ((offset + 32u)) / 4;
const uint scalar_offset_3 = ((offset + 48u)) / 4;
const tint_array_wrapper tint_symbol_11 = {{{asint(buffer[scalar_offset / 4][scalar_offset % 4])}, {asint(buffer[scalar_offset_1 / 4][scalar_offset_1 % 4])}, {asint(buffer[scalar_offset_2 / 4][scalar_offset_2 % 4])}, {asint(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4])}}};
return tint_symbol_11;
}

View File

@ -14,10 +14,10 @@ struct S {
};
tint_array_wrapper tint_symbol_2(uint4 buffer[4], uint offset) {
const int scalar_offset = ((offset + 0u)) / 4;
const int scalar_offset_1 = ((offset + 16u)) / 4;
const int scalar_offset_2 = ((offset + 32u)) / 4;
const int scalar_offset_3 = ((offset + 48u)) / 4;
const uint scalar_offset = ((offset + 0u)) / 4;
const uint scalar_offset_1 = ((offset + 16u)) / 4;
const uint scalar_offset_2 = ((offset + 32u)) / 4;
const uint scalar_offset_3 = ((offset + 48u)) / 4;
const tint_array_wrapper tint_symbol_5 = {{{asint(buffer[scalar_offset / 4][scalar_offset % 4])}, {asint(buffer[scalar_offset_1 / 4][scalar_offset_1 % 4])}, {asint(buffer[scalar_offset_2 / 4][scalar_offset_2 % 4])}, {asint(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4])}}};
return tint_symbol_5;
}

View File

@ -22,18 +22,18 @@ tint_symbol_2 vs_main(tint_symbol_1 tint_symbol) {
tint_array_wrapper texcoord = {{float2(-0.5f, 0.0f), float2(1.5f, 0.0f), float2(0.5f, 2.0f)}};
VertexOutputs output = (VertexOutputs)0;
output.position = float4(((texcoord.arr[VertexIndex] * 2.0f) - float2(1.0f, 1.0f)), 0.0f, 1.0f);
const int scalar_offset = (4u) / 4;
const uint scalar_offset = (4u) / 4;
bool flipY = (asfloat(uniforms[scalar_offset / 4][scalar_offset % 4]) < 0.0f);
if (flipY) {
const int scalar_offset_1 = (0u) / 4;
const uint scalar_offset_1 = (0u) / 4;
uint4 ubo_load = uniforms[scalar_offset_1 / 4];
const int scalar_offset_2 = (8u) / 4;
const uint scalar_offset_2 = (8u) / 4;
uint4 ubo_load_1 = uniforms[scalar_offset_2 / 4];
output.texcoords = ((((texcoord.arr[VertexIndex] * asfloat(((scalar_offset_1 & 2) ? ubo_load.zw : ubo_load.xy))) + asfloat(((scalar_offset_2 & 2) ? ubo_load_1.zw : ubo_load_1.xy))) * float2(1.0f, -1.0f)) + float2(0.0f, 1.0f));
} else {
const int scalar_offset_3 = (0u) / 4;
const uint scalar_offset_3 = (0u) / 4;
uint4 ubo_load_2 = uniforms[scalar_offset_3 / 4];
const int scalar_offset_4 = (8u) / 4;
const uint scalar_offset_4 = (8u) / 4;
uint4 ubo_load_3 = uniforms[scalar_offset_4 / 4];
output.texcoords = ((((texcoord.arr[VertexIndex] * float2(1.0f, -1.0f)) + float2(0.0f, 1.0f)) * asfloat(((scalar_offset_3 & 2) ? ubo_load_2.zw : ubo_load_2.xy))) + asfloat(((scalar_offset_4 & 2) ? ubo_load_3.zw : ubo_load_3.xy)));
}

View File

@ -1,15 +1,15 @@
float2x2 tint_symbol_4(uint4 buffer[1], uint offset) {
const int scalar_offset = ((offset + 0u)) / 4;
const uint scalar_offset = ((offset + 0u)) / 4;
uint4 ubo_load = buffer[scalar_offset / 4];
const int scalar_offset_1 = ((offset + 8u)) / 4;
const uint scalar_offset_1 = ((offset + 8u)) / 4;
uint4 ubo_load_1 = buffer[scalar_offset_1 / 4];
return float2x2(asfloat(((scalar_offset & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_1 & 2) ? ubo_load_1.zw : ubo_load_1.xy)));
}
float2x2 tint_symbol_6(uint4 buffer[1], uint offset) {
const int scalar_offset_2 = ((offset + 0u)) / 4;
const uint scalar_offset_2 = ((offset + 0u)) / 4;
uint4 ubo_load_2 = buffer[scalar_offset_2 / 4];
const int scalar_offset_3 = ((offset + 8u)) / 4;
const uint scalar_offset_3 = ((offset + 8u)) / 4;
uint4 ubo_load_3 = buffer[scalar_offset_3 / 4];
return float2x2(asfloat(((scalar_offset_2 & 2) ? ubo_load_2.zw : ubo_load_2.xy)), asfloat(((scalar_offset_3 & 2) ? ubo_load_3.zw : ubo_load_3.xy)));
}

View File

@ -30,7 +30,7 @@ void main(tint_symbol_2 tint_symbol_1) {
int2 size = tint_tmp;
int2 dstTexCoord = int2(GlobalInvocationID.xy);
int2 srcTexCoord = dstTexCoord;
const int scalar_offset = (0u) / 4;
const uint scalar_offset = (0u) / 4;
if ((uniforms[scalar_offset / 4][scalar_offset % 4] == 1u)) {
srcTexCoord.y = ((size.y - dstTexCoord.y) - 1);
}
@ -42,7 +42,7 @@ void main(tint_symbol_2 tint_symbol_1) {
{
uint i = 0u;
while (true) {
const int scalar_offset_1 = (12u) / 4;
const uint scalar_offset_1 = (12u) / 4;
if (!((i < uniforms[scalar_offset_1 / 4][scalar_offset_1 % 4]))) {
break;
}

View File

@ -13,9 +13,9 @@ struct tint_symbol_1 {
void main(tint_symbol_1 tint_symbol) {
const uint3 global_id = tint_symbol.global_id;
const uint2 resultCell = uint2(global_id.y, global_id.x);
const int scalar_offset = (4u) / 4;
const uint scalar_offset = (4u) / 4;
const uint dimInner = uniforms[scalar_offset / 4][scalar_offset % 4];
const int scalar_offset_1 = (20u) / 4;
const uint scalar_offset_1 = (20u) / 4;
const uint dimOutter = uniforms[scalar_offset_1 / 4][scalar_offset_1 % 4];
uint result = 0u;
{

View File

@ -866,7 +866,7 @@ void main_1() {
const float2 x_762 = uv;
uv = float2(0.0f, 0.0f);
uv = x_762;
const int scalar_offset = (0u) / 4;
const uint scalar_offset = (0u) / 4;
uint4 ubo_load = x_188[scalar_offset / 4];
const float2 x_191 = asfloat(((scalar_offset & 2) ? ubo_load.zw : ubo_load.xy));
const QuicksortObject x_763 = obj;

View File

@ -25,22 +25,22 @@ void main(tint_symbol_2 tint_symbol_1) {
const uint2 dstTexCoord = uint2(GlobalInvocationID.xy);
const float4 nonCoveredColor = float4(0.0f, 1.0f, 0.0f, 1.0f);
bool success = true;
const int scalar_offset = (16u) / 4;
const uint scalar_offset = (16u) / 4;
bool tint_tmp_4 = (dstTexCoord.x < uniforms[scalar_offset / 4][scalar_offset % 4]);
if (!tint_tmp_4) {
const int scalar_offset_1 = (20u) / 4;
const uint scalar_offset_1 = (20u) / 4;
tint_tmp_4 = (dstTexCoord.y < uniforms[scalar_offset_1 / 4][scalar_offset_1 % 4]);
}
bool tint_tmp_3 = (tint_tmp_4);
if (!tint_tmp_3) {
const int scalar_offset_2 = (16u) / 4;
const int scalar_offset_3 = (24u) / 4;
const uint scalar_offset_2 = (16u) / 4;
const uint scalar_offset_3 = (24u) / 4;
tint_tmp_3 = (dstTexCoord.x >= (uniforms[scalar_offset_2 / 4][scalar_offset_2 % 4] + uniforms[scalar_offset_3 / 4][scalar_offset_3 % 4]));
}
bool tint_tmp_2 = (tint_tmp_3);
if (!tint_tmp_2) {
const int scalar_offset_4 = (20u) / 4;
const int scalar_offset_5 = (28u) / 4;
const uint scalar_offset_4 = (20u) / 4;
const uint scalar_offset_5 = (28u) / 4;
tint_tmp_2 = (dstTexCoord.y >= (uniforms[scalar_offset_4 / 4][scalar_offset_4 % 4] + uniforms[scalar_offset_5 / 4][scalar_offset_5 % 4]));
}
if ((tint_tmp_2)) {
@ -50,18 +50,18 @@ void main(tint_symbol_2 tint_symbol_1) {
}
success = (tint_tmp_5);
} else {
const int scalar_offset_6 = (16u) / 4;
const uint scalar_offset_6 = (16u) / 4;
uint4 ubo_load = uniforms[scalar_offset_6 / 4];
const int scalar_offset_7 = (8u) / 4;
const uint scalar_offset_7 = (8u) / 4;
uint4 ubo_load_1 = uniforms[scalar_offset_7 / 4];
uint2 srcTexCoord = ((dstTexCoord - ((scalar_offset_6 & 2) ? ubo_load.zw : ubo_load.xy)) + ((scalar_offset_7 & 2) ? ubo_load_1.zw : ubo_load_1.xy));
const int scalar_offset_8 = (0u) / 4;
const uint scalar_offset_8 = (0u) / 4;
if ((uniforms[scalar_offset_8 / 4][scalar_offset_8 % 4] == 1u)) {
srcTexCoord.y = ((uint(srcSize.y) - srcTexCoord.y) - 1u);
}
const float4 srcColor = src.Load(int3(srcTexCoord, 0));
const float4 dstColor = tint_symbol.Load(int3(dstTexCoord, 0));
const int scalar_offset_9 = (4u) / 4;
const uint scalar_offset_9 = (4u) / 4;
if ((uniforms[scalar_offset_9 / 4][scalar_offset_9 % 4] == 2u)) {
bool tint_tmp_7 = success;
if (tint_tmp_7) {

View File

@ -6,14 +6,14 @@ cbuffer cbuffer_uniforms : register(b3, space0) {
};
float mm_readA(uint row, uint col) {
const int scalar_offset = (0u) / 4;
const uint scalar_offset = (0u) / 4;
bool tint_tmp = (row < uniforms[scalar_offset / 4][scalar_offset % 4]);
if (tint_tmp) {
const int scalar_offset_1 = (4u) / 4;
const uint scalar_offset_1 = (4u) / 4;
tint_tmp = (col < uniforms[scalar_offset_1 / 4][scalar_offset_1 % 4]);
}
if ((tint_tmp)) {
const int scalar_offset_2 = (4u) / 4;
const uint scalar_offset_2 = (4u) / 4;
const float result = asfloat(firstMatrix.Load((4u * ((row * uniforms[scalar_offset_2 / 4][scalar_offset_2 % 4]) + col))));
return result;
}
@ -21,14 +21,14 @@ float mm_readA(uint row, uint col) {
}
float mm_readB(uint row, uint col) {
const int scalar_offset_3 = (4u) / 4;
const uint scalar_offset_3 = (4u) / 4;
bool tint_tmp_1 = (row < uniforms[scalar_offset_3 / 4][scalar_offset_3 % 4]);
if (tint_tmp_1) {
const int scalar_offset_4 = (8u) / 4;
const uint scalar_offset_4 = (8u) / 4;
tint_tmp_1 = (col < uniforms[scalar_offset_4 / 4][scalar_offset_4 % 4]);
}
if ((tint_tmp_1)) {
const int scalar_offset_5 = (8u) / 4;
const uint scalar_offset_5 = (8u) / 4;
const float result = asfloat(secondMatrix.Load((4u * ((row * uniforms[scalar_offset_5 / 4][scalar_offset_5 % 4]) + col))));
return result;
}
@ -36,14 +36,14 @@ float mm_readB(uint row, uint col) {
}
void mm_write(uint row, uint col, float value) {
const int scalar_offset_6 = (0u) / 4;
const uint scalar_offset_6 = (0u) / 4;
bool tint_tmp_2 = (row < uniforms[scalar_offset_6 / 4][scalar_offset_6 % 4]);
if (tint_tmp_2) {
const int scalar_offset_7 = (8u) / 4;
const uint scalar_offset_7 = (8u) / 4;
tint_tmp_2 = (col < uniforms[scalar_offset_7 / 4][scalar_offset_7 % 4]);
}
if ((tint_tmp_2)) {
const int scalar_offset_8 = (8u) / 4;
const uint scalar_offset_8 = (8u) / 4;
const uint index = (col + (row * uniforms[scalar_offset_8 / 4][scalar_offset_8 % 4]));
resultMatrix.Store((4u * index), asuint(value));
}
@ -93,7 +93,7 @@ void main(tint_symbol_1 tint_symbol) {
const uint tileCol = (local_id.x * ColPerThread);
const uint globalRow = (global_id.y * RowPerThread);
const uint globalCol = (global_id.x * ColPerThread);
const int scalar_offset_9 = (4u) / 4;
const uint scalar_offset_9 = (4u) / 4;
const uint numTiles = (((uniforms[scalar_offset_9 / 4][scalar_offset_9 % 4] - 1u) / TileInner) + 1u);
tint_array_wrapper_2 acc = (tint_array_wrapper_2)0;
float ACached = 0.0f;

View File

@ -15,25 +15,25 @@ struct Mat4x2_ {
};
Mat4x4_ tint_symbol_7(uint4 buffer[4], uint offset) {
const int scalar_offset = ((offset + 0u)) / 4;
const int scalar_offset_1 = ((offset + 16u)) / 4;
const int scalar_offset_2 = ((offset + 32u)) / 4;
const int scalar_offset_3 = ((offset + 48u)) / 4;
const uint scalar_offset = ((offset + 0u)) / 4;
const uint scalar_offset_1 = ((offset + 16u)) / 4;
const uint scalar_offset_2 = ((offset + 32u)) / 4;
const uint scalar_offset_3 = ((offset + 48u)) / 4;
const Mat4x4_ tint_symbol_10 = {asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]), asfloat(buffer[scalar_offset_3 / 4])};
return tint_symbol_10;
}
Mat4x2_ tint_symbol_9(uint4 buffer[3], uint offset) {
const int scalar_offset_4 = ((offset + 0u)) / 4;
const int scalar_offset_5 = ((offset + 16u)) / 4;
const uint scalar_offset_4 = ((offset + 0u)) / 4;
const uint scalar_offset_5 = ((offset + 16u)) / 4;
const Mat4x2_ tint_symbol_11 = {asfloat(buffer[scalar_offset_4 / 4]), asfloat(buffer[scalar_offset_5 / 4])};
return tint_symbol_11;
}
Mat4x3_ tint_symbol_5(uint4 buffer[96], uint offset) {
const int scalar_offset_6 = ((offset + 0u)) / 4;
const int scalar_offset_7 = ((offset + 16u)) / 4;
const int scalar_offset_8 = ((offset + 32u)) / 4;
const uint scalar_offset_6 = ((offset + 0u)) / 4;
const uint scalar_offset_7 = ((offset + 16u)) / 4;
const uint scalar_offset_8 = ((offset + 32u)) / 4;
const Mat4x3_ tint_symbol_12 = {asfloat(buffer[scalar_offset_6 / 4]), asfloat(buffer[scalar_offset_7 / 4]), asfloat(buffer[scalar_offset_8 / 4])};
return tint_symbol_12;
}
@ -259,7 +259,7 @@ void main1() {
gl_Position = _e49;
const float4 _e50 = a_Color1;
v_Color = _e50;
const int scalar_offset_9 = (32u) / 4;
const uint scalar_offset_9 = (32u) / 4;
const float4 _e52 = asfloat(global1[scalar_offset_9 / 4]);
if ((_e52.x == 2.0f)) {
{

View File

@ -4,7 +4,7 @@ cbuffer cbuffer_v : register(b0, space0) {
[numthreads(1, 1, 1)]
void main() {
const int scalar_offset = (0u) / 4;
const uint scalar_offset = (0u) / 4;
const int use = (asint(v[scalar_offset / 4][scalar_offset % 4]) + 1);
return;
}

View File

@ -66,16 +66,16 @@ void comp_main(tint_symbol_5 tint_symbol_4) {
}
pos = asfloat(particlesA.Load2((16u * i))).xy;
vel = asfloat(particlesA.Load2(((16u * i) + 8u))).xy;
const int scalar_offset = (4u) / 4;
const uint scalar_offset = (4u) / 4;
if ((distance(pos, vPos) < asfloat(params[scalar_offset / 4][scalar_offset % 4]))) {
cMass = (cMass + pos);
cMassCount = (cMassCount + 1);
}
const int scalar_offset_1 = (8u) / 4;
const uint scalar_offset_1 = (8u) / 4;
if ((distance(pos, vPos) < asfloat(params[scalar_offset_1 / 4][scalar_offset_1 % 4]))) {
colVel = (colVel - (pos - vPos));
}
const int scalar_offset_2 = (12u) / 4;
const uint scalar_offset_2 = (12u) / 4;
if ((distance(pos, vPos) < asfloat(params[scalar_offset_2 / 4][scalar_offset_2 % 4]))) {
cVel = (cVel + vel);
cVelCount = (cVelCount + 1);
@ -91,12 +91,12 @@ void comp_main(tint_symbol_5 tint_symbol_4) {
if ((cVelCount > 0)) {
cVel = (cVel / float2(float(cVelCount), float(cVelCount)));
}
const int scalar_offset_3 = (16u) / 4;
const int scalar_offset_4 = (20u) / 4;
const int scalar_offset_5 = (24u) / 4;
const uint scalar_offset_3 = (16u) / 4;
const uint scalar_offset_4 = (20u) / 4;
const uint scalar_offset_5 = (24u) / 4;
vVel = (((vVel + (cMass * asfloat(params[scalar_offset_3 / 4][scalar_offset_3 % 4]))) + (colVel * asfloat(params[scalar_offset_4 / 4][scalar_offset_4 % 4]))) + (cVel * asfloat(params[scalar_offset_5 / 4][scalar_offset_5 % 4])));
vVel = (normalize(vVel) * clamp(length(vVel), 0.0f, 0.100000001f));
const int scalar_offset_6 = (0u) / 4;
const uint scalar_offset_6 = (0u) / 4;
vPos = (vPos + (vVel * asfloat(params[scalar_offset_6 / 4][scalar_offset_6 % 4])));
if ((vPos.x < -1.0f)) {
vPos.x = 1.0f;

View File

@ -1,8 +1,8 @@
float4x4 tint_symbol_7(uint4 buffer[4], uint offset) {
const int scalar_offset = ((offset + 0u)) / 4;
const int scalar_offset_1 = ((offset + 16u)) / 4;
const int scalar_offset_2 = ((offset + 32u)) / 4;
const int scalar_offset_3 = ((offset + 48u)) / 4;
const uint scalar_offset = ((offset + 0u)) / 4;
const uint scalar_offset_1 = ((offset + 16u)) / 4;
const uint scalar_offset_2 = ((offset + 32u)) / 4;
const uint scalar_offset_3 = ((offset + 48u)) / 4;
return float4x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]), asfloat(buffer[scalar_offset_3 / 4]));
}