diff --git a/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolume.hlsl b/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolume.hlsl index 4b727772b42..f3c630f60dc 100644 --- a/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolume.hlsl +++ b/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolume.hlsl @@ -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 @@ -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 @@ -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; @@ -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 @@ -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, diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/HistogramExposure.compute b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/HistogramExposure.compute index 3be9ef43963..9db80c179e9 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/HistogramExposure.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/HistogramExposure.compute @@ -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]; diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesFunctions.hlsl b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesFunctions.hlsl index 69a5c5e5011..3de4892d739 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesFunctions.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesFunctions.hlsl @@ -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; }