Skip to content

Fix various shader warnings #3158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ void EvaluateAPVL1(APVResources apvRes, float3 L0, float3 N, float3 backN, float
bool TryToGetPoolUVW(APVResources apvRes, float3 posWS, float3 normalWS, out float3 uvw)
{
uvw = 0;
// Note: we could instead early return when we know we'll have invalid UVs, but some bade code gen on Vulkan generates shader warnings if we do.
bool hasValidUVW = true;

APVConstants apvConst = LoadAPVConstants(apvRes.index);
// transform into APV space
Expand All @@ -106,7 +108,7 @@ bool TryToGetPoolUVW(APVResources apvRes, float3 posWS, float3 normalWS, out flo
if (any(abs(posRS) > float3(apvConst.indexDim / 2)))
#endif
{
return false;
hasValidUVW = false;
}

// convert to index
Expand All @@ -118,7 +120,7 @@ bool TryToGetPoolUVW(APVResources apvRes, float3 posWS, float3 normalWS, out flo
int yoffset = apvRes.index[kAPVConstantsSize + index.z * apvConst.indexDim.x + index.x];
if (yoffset == -1 || posRS.y < yoffset || posRS.y >= float(apvConst.indexDim.y))
{
return false;
hasValidUVW = false;
}

index.y = posRS.y - yoffset;
Expand All @@ -132,7 +134,7 @@ bool TryToGetPoolUVW(APVResources apvRes, float3 posWS, float3 normalWS, out flo
// no valid brick loaded for this index, fallback to ambient probe
if (packed_pool_idx == 0xffffffff)
{
return false;
hasValidUVW = false;
}

// unpack pool idx
Expand All @@ -153,7 +155,7 @@ bool TryToGetPoolUVW(APVResources apvRes, float3 posWS, float3 normalWS, out flo
offset *= 3.0 / (float3) apvConst.poolDim; // convert brick footprint to texels footprint in pool texel space
uvw += offset; // add the final offset

return true;
return hasValidUVW;
}

void EvaluateAdaptiveProbeVolume(in float3 posWS, in float3 normalWS, in float3 backNormalWS, in APVResources apvRes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ float ComputeTotalSum(uint threadID, float threadVal)
GroupMemoryBarrierWithGroupSync();

sum = gs_partialSums[0];
[unroll]
for (uint i = 1u; i < waveCount; ++i)
{
sum += gs_partialSums[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,15 @@ uint ScalarizeElementIndex(uint v_elementIdx, bool fastPath)
{
// If we are not in fast path, v_elementIdx is not scalar, so we need to query the Min value across the wave.
s_elementIdx = WaveActiveMin(v_elementIdx);
// If WaveActiveMin returns 0xffffffff it means that all lanes are actually dead, so we can safely ignore the loop and move forward.
// This could happen as an helper lane could reach this point, hence having a valid v_elementIdx, but their values will be ignored by the WaveActiveMin
if (s_elementIdx == -1)
{
return -1;
}
}
// Note that the WaveReadLaneFirst should not be needed, but the compiler might insist in putting the result in VGPR.
// However, we are certain at this point that the index is scalar.
s_elementIdx = WaveReadLaneFirst(s_elementIdx);
// If WaveActiveMin returns 0xffffffff it means that all lanes are actually dead, so we can safely ignore the loop and move forward.
// This could happen as an helper lane could reach this point, hence having a valid v_elementIdx, but their values will be ignored by the WaveActiveMin.
// If that's not the case we make sure the index is put into a scalar register.
if (s_elementIdx != -1)
{
s_elementIdx = WaveReadLaneFirst(s_elementIdx);
}

#endif
return s_elementIdx;
}
Expand Down