dawn-cmake/test/tint/bug/tint/1121.wgsl.expected.dxc.hlsl
Antonio Maiorano 06844a5e24 tint/hlsl: remove [loop] attribute on all loops
I added the forcing of the "loop" attribute to all loops to address FXC
failing on uniformity errors related to gradients in loops. Since then,
Tint now implements UA and it recently became an error, so we no longer
need this hack. As a result, FXC is now better able to cope with loops
that it determines executes 0 times.

Most e2e tests are affected because so many use loops, but 27 tests that
were previously failing are now passing with this change:

tint/bug/tint/1538.wgsl.expected.fxc.hlsl
tint/bug/tint/1604.wgsl.expected.fxc.hlsl
tint/bug/tint/1605.wgsl.expected.fxc.hlsl
tint/unittest/reader/spirv/SpvParserCFGTest_ClassifyCFGEdges_LoopBreak_FromLoopHeader_SingleBlockLoop_TrueBranch.spvasm.expected.fxc.hlsl
tint/unittest/reader/spirv/SpvParserCFGTest_ComputeBlockOrder_Loop_HeaderHasBreakUnless.spvasm.expected.fxc.hlsl
tint/unittest/reader/spirv/SpvParserCFGTest_EmitBody_IfSelection_TrueBranch_LoopBreak.spvasm.expected.fxc.hlsl
tint/unittest/reader/spirv/SpvParserCFGTest_FindIfSelectionInternalHeaders_TrueBranch_LoopBreak_Ok.spvasm.expected.fxc.hlsl
tint/unittest/reader/spirv/SpvParserFunctionVarTest_EmitStatement_Phi_MultiBlockLoopIndex.spvasm.expected.fxc.hlsl
tint/unittest/reader/spirv/SpvParserFunctionVarTest_EmitStatement_Phi_SingleBlockLoopIndex.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/cov-dead-code-unreachable-merge/0-opt.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/cov-dead-code-unreachable-merge/0-opt.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/similar-nested-ifs/0-opt.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/similar-nested-ifs/0-opt.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/spv-load-from-frag-color/1.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/spv-load-from-frag-color/1.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-false-if-discard-loop/0.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-false-if-discard-loop/0.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-fragcoord-less-than-zero/0.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-fragcoord-less-than-zero/0.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-fragcoord-less-than-zero/1.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-fragcoord-less-than-zero/1.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-with-loop-read-write-global/0-opt.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-with-loop-read-write-global/0-opt.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-with-loop-read-write-global/1.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/stable-binarysearch-tree-with-loop-read-write-global/1.wgsl.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/write-red-after-search/0-opt.spvasm.expected.fxc.hlsl
tint/vk-gl-cts/graphicsfuzz/write-red-after-search/0-opt.wgsl.expected.fxc.hlsl

Bug: tint:1522
Bug: tint:1538
Bug: tint:1604
Bug: tint:1605
Change-Id: I530b846b6b8df122ab351ff7b85d3e1c9ac11526
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104121
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-29 16:53:58 +00:00

118 lines
4.7 KiB
HLSL

RWByteAddressBuffer lightsBuffer : register(u0, space0);
RWByteAddressBuffer tileLightId : register(u0, space1);
cbuffer cbuffer_config : register(b0, space2) {
uint4 config[2];
};
cbuffer cbuffer_uniforms : register(b0, space3) {
uint4 uniforms[11];
};
struct tint_symbol_1 {
uint3 GlobalInvocationID : SV_DispatchThreadID;
};
float4x4 tint_symbol_6(uint4 buffer[11], uint offset) {
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]));
}
uint tint_atomicAdd(RWByteAddressBuffer buffer, uint offset, uint value) {
uint original_value = 0;
buffer.InterlockedAdd(offset, value, original_value);
return original_value;
}
void main_inner(uint3 GlobalInvocationID) {
uint index = GlobalInvocationID.x;
if ((index >= config[0].x)) {
return;
}
lightsBuffer.Store(((32u * index) + 4u), asuint(((asfloat(lightsBuffer.Load(((32u * index) + 4u))) - 0.100000001f) + (0.001f * (float(index) - (64.0f * floor((float(index) / 64.0f))))))));
if ((asfloat(lightsBuffer.Load(((32u * index) + 4u))) < asfloat(uniforms[0].y))) {
lightsBuffer.Store(((32u * index) + 4u), asuint(asfloat(uniforms[1].y)));
}
float4x4 M = tint_symbol_6(uniforms, 96u);
float viewNear = (-(M[3][2]) / (-1.0f + M[2][2]));
float viewFar = (-(M[3][2]) / (1.0f + M[2][2]));
float4 lightPos = asfloat(lightsBuffer.Load4((32u * index)));
lightPos = mul(lightPos, tint_symbol_6(uniforms, 32u));
lightPos = (lightPos / lightPos.w);
float lightRadius = asfloat(lightsBuffer.Load(((32u * index) + 28u)));
float4 boxMin = (lightPos - float4(float3((lightRadius).xxx), 0.0f));
float4 boxMax = (lightPos + float4(float3((lightRadius).xxx), 0.0f));
float4 frustumPlanes[6] = (float4[6])0;
frustumPlanes[4] = float4(0.0f, 0.0f, -1.0f, viewNear);
frustumPlanes[5] = float4(0.0f, 0.0f, 1.0f, -(viewFar));
const int TILE_SIZE = 16;
const int TILE_COUNT_X = 2;
const int TILE_COUNT_Y = 2;
{
for(int y_1 = 0; (y_1 < TILE_COUNT_Y); y_1 = (y_1 + 1)) {
{
for(int x_1 = 0; (x_1 < TILE_COUNT_X); x_1 = (x_1 + 1)) {
int2 tilePixel0Idx = int2((x_1 * TILE_SIZE), (y_1 * TILE_SIZE));
float2 floorCoord = (((2.0f * float2(tilePixel0Idx)) / asfloat(uniforms[10]).xy) - (1.0f).xx);
float2 ceilCoord = (((2.0f * float2((tilePixel0Idx + int2((TILE_SIZE).xx)))) / asfloat(uniforms[10]).xy) - (1.0f).xx);
float2 viewFloorCoord = float2((((-(viewNear) * floorCoord.x) - (M[2][0] * viewNear)) / M[0][0]), (((-(viewNear) * floorCoord.y) - (M[2][1] * viewNear)) / M[1][1]));
float2 viewCeilCoord = float2((((-(viewNear) * ceilCoord.x) - (M[2][0] * viewNear)) / M[0][0]), (((-(viewNear) * ceilCoord.y) - (M[2][1] * viewNear)) / M[1][1]));
frustumPlanes[0] = float4(1.0f, 0.0f, (-(viewFloorCoord.x) / viewNear), 0.0f);
frustumPlanes[1] = float4(-1.0f, 0.0f, (viewCeilCoord.x / viewNear), 0.0f);
frustumPlanes[2] = float4(0.0f, 1.0f, (-(viewFloorCoord.y) / viewNear), 0.0f);
frustumPlanes[3] = float4(0.0f, -1.0f, (viewCeilCoord.y / viewNear), 0.0f);
float dp = 0.0f;
{
for(uint i = 0u; (i < 6u); i = (i + 1u)) {
float4 p = float4(0.0f, 0.0f, 0.0f, 0.0f);
if ((frustumPlanes[i].x > 0.0f)) {
p.x = boxMax.x;
} else {
p.x = boxMin.x;
}
if ((frustumPlanes[i].y > 0.0f)) {
p.y = boxMax.y;
} else {
p.y = boxMin.y;
}
if ((frustumPlanes[i].z > 0.0f)) {
p.z = boxMax.z;
} else {
p.z = boxMin.z;
}
p.w = 1.0f;
dp = (dp + min(0.0f, dot(p, frustumPlanes[i])));
}
}
if ((dp >= 0.0f)) {
uint tileId = uint((x_1 + (y_1 * TILE_COUNT_X)));
bool tint_tmp = (tileId < 0u);
if (!tint_tmp) {
tint_tmp = (tileId >= config[0].y);
}
if ((tint_tmp)) {
continue;
}
uint offset = tint_atomicAdd(tileLightId, (260u * tileId), 1u);
if ((offset >= config[1].x)) {
continue;
}
tileLightId.Store((((260u * tileId) + 4u) + (4u * offset)), asuint(GlobalInvocationID.x));
}
}
}
}
}
}
[numthreads(64, 1, 1)]
void main(tint_symbol_1 tint_symbol) {
main_inner(tint_symbol.GlobalInvocationID);
return;
}