Skip to content

Commit f649986

Browse files
laylaarabEvergreen
authored andcommitted
[UUM-66201] Fixed static numDecalsThisFrame causing IndexOutOfRange exceptions
Fix [UUM-66021](https://jira.unity3d.com/browse/UUM-66021) Fixed IndexOutOfRange errors in the decal system when using multiple cameras. This was caused by the static variable `m_DecalsVisibleThisFrame` being updated during culling, so the number of decals visible were only considered for the last camera the decal culling ran on.
1 parent 28b4e0a commit f649986

File tree

1 file changed

+10
-1
lines changed
  • Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal

1 file changed

+10
-1
lines changed

Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalSystem.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ static class DecalShaderIds
4242

4343
public class CullResult : IDisposable
4444
{
45+
int m_NumResults;
46+
47+
public int numResults
48+
{
49+
get => m_NumResults;
50+
set => m_NumResults = value;
51+
}
52+
4553
public class Set : IDisposable
4654
{
4755
int m_NumResults;
@@ -1354,7 +1362,7 @@ private int QueryCullResults(CullRequest decalCullRequest, CullResult cullResult
13541362

13551363
public void EndCull(CullRequest cullRequest, CullResult cullResults)
13561364
{
1357-
m_DecalsVisibleThisFrame = QueryCullResults(cullRequest, cullResults);
1365+
cullResults.numResults = QueryCullResults(cullRequest, cullResults);
13581366
foreach (var pair in m_DecalSets)
13591367
pair.Value.EndCull(cullRequest[pair.Key]);
13601368
}
@@ -1670,6 +1678,7 @@ public void RenderDebugOverlay(HDCamera hdCamera, CommandBuffer cmd, int mipLeve
16701678

16711679
public void LoadCullResults(CullResult cullResult)
16721680
{
1681+
m_DecalsVisibleThisFrame = cullResult.numResults;
16731682
using (var enumerator = cullResult.requests.GetEnumerator())
16741683
{
16751684
while (enumerator.MoveNext())

0 commit comments

Comments
 (0)