mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 13:38:00 +00:00
writer/hlsl: Simplify UBO accesses for static indexing
Use the new semantic constant value information to significantly reduce the complex indexing logic emitted for UBO accesses. This will dramatically reduce the number of `for` loops that are decayed to `while` loops. Change-Id: I1b0adb5edde2b4ed39c6beafc2e28106b86e0edd Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57701 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
@@ -59,17 +59,14 @@ 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 uint scalar_offset = (4u) / 4;
|
||||
if ((distance(pos, vPos) < asfloat(params[scalar_offset / 4][scalar_offset % 4]))) {
|
||||
if ((distance(pos, vPos) < asfloat(params[0].y))) {
|
||||
cMass = (cMass + pos);
|
||||
cMassCount = (cMassCount + 1);
|
||||
}
|
||||
const uint scalar_offset_1 = (8u) / 4;
|
||||
if ((distance(pos, vPos) < asfloat(params[scalar_offset_1 / 4][scalar_offset_1 % 4]))) {
|
||||
if ((distance(pos, vPos) < asfloat(params[0].z))) {
|
||||
colVel = (colVel - (pos - vPos));
|
||||
}
|
||||
const uint scalar_offset_2 = (12u) / 4;
|
||||
if ((distance(pos, vPos) < asfloat(params[scalar_offset_2 / 4][scalar_offset_2 % 4]))) {
|
||||
if ((distance(pos, vPos) < asfloat(params[0].w))) {
|
||||
cVel = (cVel + vel);
|
||||
cVelCount = (cVelCount + 1);
|
||||
}
|
||||
@@ -81,13 +78,9 @@ void comp_main(tint_symbol_5 tint_symbol_4) {
|
||||
if ((cVelCount > 0)) {
|
||||
cVel = (cVel / float2(float(cVelCount), float(cVelCount)));
|
||||
}
|
||||
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 = (((vVel + (cMass * asfloat(params[1].x))) + (colVel * asfloat(params[1].y))) + (cVel * asfloat(params[1].z)));
|
||||
vVel = (normalize(vVel) * clamp(length(vVel), 0.0f, 0.100000001f));
|
||||
const uint scalar_offset_6 = (0u) / 4;
|
||||
vPos = (vPos + (vVel * asfloat(params[scalar_offset_6 / 4][scalar_offset_6 % 4])));
|
||||
vPos = (vPos + (vVel * asfloat(params[0].x)));
|
||||
if ((vPos.x < -1.0f)) {
|
||||
vPos.x = 1.0f;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user