Skip to content

Commit 30d6d86

Browse files
vincent-breysseEvergreen
authored andcommitted
Fixed "System.IndexOutOfRangeException: Index -1" in HDRP when zooming out in the scene view
Fixed an out of range exception in HDRP when reaching the max amount of shadows on screen. This happens when reaching the maximum number of shadows on screen because the request for room in the atlas would then fail and return -1 which was not handled well later down the line.
1 parent c581435 commit 30d6d86

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDShadowRequestUpdateJob.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ public void Execute()
142142

143143
for (int index = 0; index < shadowIndicesAndVisibleLightData.splitCount; index++)
144144
{
145+
if (!shadowIndicesAndVisibleLightData.isSplitValidMask[(uint)index])
146+
continue;
147+
145148
bool needToUpdateCachedContent = needCacheUpdateMask[(uint)index];
146149
HDShadowRequestHandle indexHandle = shadowRequestSetHandle[index];
147150
int shadowRequestIndex = requestIndicesStorage[indexHandle.storageIndexForRequestIndex];
@@ -190,6 +193,9 @@ public void Execute()
190193

191194
for (int index = 0; index < shadowIndicesAndVisibleLightData.splitCount; index++)
192195
{
196+
if (!shadowIndicesAndVisibleLightData.isSplitValidMask[(uint)index])
197+
continue;
198+
193199
HDShadowRequestHandle indexHandle = shadowRequestSetHandle[index];
194200
int shadowRequestIndex = requestIndicesStorage[indexHandle.storageIndexForRequestIndex];
195201
ref HDShadowResolutionRequest resolutionRequest = ref shadowManager.shadowResolutionRequestStorage.ElementAt(shadowRequestIndex);
@@ -557,6 +563,9 @@ public void UpdateNonDirectionalCachedRequests(LightType lightType,
557563

558564
for (int index = 0; index < shadowIndicesAndVisibleLightData.splitCount; index++)
559565
{
566+
if (!shadowIndicesAndVisibleLightData.isSplitValidMask[(uint)index])
567+
continue;
568+
560569
HDShadowRequestHandle indexHandle = shadowRequestSetHandle[index];
561570
int shadowRequestIndex = requestIndicesStorage[indexHandle.storageIndexForRequestIndex];
562571
ref HDShadowResolutionRequest resolutionRequest = ref shadowManager.shadowResolutionRequestStorage.ElementAt(shadowRequestIndex);
@@ -617,6 +626,9 @@ public void UpdateNonDirectionalDynamicRequests(LightType lightType,
617626

618627
for (int index = 0; index < shadowIndicesAndVisibleLightData.splitCount; index++)
619628
{
629+
if (!shadowIndicesAndVisibleLightData.isSplitValidMask[(uint)index])
630+
continue;
631+
620632
HDShadowRequestHandle indexHandle = shadowRequestSetHandle[index];
621633
int shadowRequestIndex = requestIndicesStorage[indexHandle.storageIndexForRequestIndex];
622634
ref HDShadowResolutionRequest resolutionRequest = ref shadowManager.shadowResolutionRequestStorage.ElementAt(shadowRequestIndex);

0 commit comments

Comments
 (0)