Skip to content

Commit 4b7629d

Browse files
pigselatedEvergreen
authored andcommitted
UUM-85566: Backout PR#54311
See [UUM-85566](https://jira.unity3d.com/browse/UUM-85566) Bisected the issue to this [PR](https://github.cds.internal.unity3d.com/unity/unity/pull/54311). The PR comprises another [bug](https://jira.unity3d.com/browse/UUM-82299) fix, but it is an optimization and has lower UP. So for now the changes in the PR are reverted and then it can be reimplemented with the repro project in mind.
1 parent 82f1284 commit 4b7629d

1 file changed

Lines changed: 10 additions & 17 deletions

File tree

  • Packages/com.unity.render-pipelines.universal/Runtime/Tiling

Packages/com.unity.render-pipelines.universal/Runtime/Tiling/TilingJob.cs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -218,16 +218,16 @@ bool ConicPointIsValid(float3 p) =>
218218
// Intersect lines with y-plane and clip if needed.
219219
var l1t = math.dot(-lightPositionVS, planeNormal) / math.dot(l1, planeNormal);
220220
var l1x = lightPositionVS + l1 * l1t;
221-
if (l1t >= 0 && l1t <= 1 && l1x.z >= near) planeRange.Expand((short)ViewToTileSpace(l1x).x);
221+
if (l1t >= 0 && l1t <= 1 && l1x.z >= near) planeRange.Expand((short)math.clamp(ViewToTileSpace(l1x).x, 0, tileCount.x - 1));
222222

223223
var l2t = math.dot(-lightPositionVS, planeNormal) / math.dot(l2, planeNormal);
224224
var l2x = lightPositionVS + l2 * l2t;
225-
if (l2t >= 0 && l2t <= 1 && l2x.z >= near) planeRange.Expand((short)ViewToTileSpace(l2x).x);
225+
if (l2t >= 0 && l2t <= 1 && l2x.z >= near) planeRange.Expand((short)math.clamp(ViewToTileSpace(l2x).x, 0, tileCount.x - 1));
226226

227227
if (IntersectCircleYPlane(planeY, baseCenter, lightDirectionVS, baseUY, baseVY, baseRadius, out var circleTile0, out var circleTile1))
228228
{
229-
if (circleTile0.z >= near) planeRange.Expand((short)ViewToTileSpace(circleTile0).x);
230-
if (circleTile1.z >= near) planeRange.Expand((short)ViewToTileSpace(circleTile1).x);
229+
if (circleTile0.z >= near) planeRange.Expand((short)math.clamp(ViewToTileSpace(circleTile0).x, 0, tileCount.x - 1));
230+
if (circleTile1.z >= near) planeRange.Expand((short)math.clamp(ViewToTileSpace(circleTile1).x, 0, tileCount.x - 1));
231231
}
232232

233233
if (coneIsClipping)
@@ -237,21 +237,14 @@ bool ConicPointIsValid(float3 p) =>
237237
var theta = FindNearConicYTheta(near, lightPositionVS, lightDirectionVS, r, coneU, coneV, y);
238238
var p0 = math.float3(EvaluateNearConic(near, lightPositionVS, lightDirectionVS, r, coneU, coneV, theta.x).x, y, near);
239239
var p1 = math.float3(EvaluateNearConic(near, lightPositionVS, lightDirectionVS, r, coneU, coneV, theta.y).x, y, near);
240-
if (ConicPointIsValid(p0)) planeRange.Expand((short)ViewToTileSpace(p0).x);
241-
if (ConicPointIsValid(p1)) planeRange.Expand((short)ViewToTileSpace(p1).x);
240+
if (ConicPointIsValid(p0)) planeRange.Expand((short)math.clamp(ViewToTileSpace(p0).x, 0, tileCount.x - 1));
241+
if (ConicPointIsValid(p1)) planeRange.Expand((short)math.clamp(ViewToTileSpace(p1).x, 0, tileCount.x - 1));
242242
}
243243

244-
// Only consider ranges that intersect the tiling extents.
245-
// The logic in the below 'if' statement is a simplification of:
246-
// !((planeRange.start < 0) && (planeRange.end < 0)) && !((planeRange.start > tileCount.x - 1) && (planeRange.end > tileCount.x - 1))
247-
if (((planeRange.start >= 0) || (planeRange.end >= 0)) && ((planeRange.start <= tileCount.x - 1) || (planeRange.end <= tileCount.x - 1)))
248-
{
249-
// Write to tile ranges above and below the plane. Note that at `m_Offset` we store Y-range.
250-
var tileIndex = m_Offset + 1 + planeIndex;
251-
planeRange.Clamp(0, (short)(tileCount.x - 1));
252-
tileRanges[tileIndex] = InclusiveRange.Merge(tileRanges[tileIndex], planeRange);
253-
tileRanges[tileIndex - 1] = InclusiveRange.Merge(tileRanges[tileIndex - 1], planeRange);
254-
}
244+
// Write to tile ranges above and below the plane. Note that at `m_Offset` we store Y-range.
245+
var tileIndex = m_Offset + 1 + planeIndex;
246+
tileRanges[tileIndex] = InclusiveRange.Merge(tileRanges[tileIndex], planeRange);
247+
tileRanges[tileIndex - 1] = InclusiveRange.Merge(tileRanges[tileIndex - 1], planeRange);
255248
}
256249
}
257250

0 commit comments

Comments
 (0)