Skip to content

Commit 0d13f98

Browse files
Fixed an issue causing Render Graph execution errors after a random amount of time. (#6329)
* Fixed an issue causing Render Graph execution errors after a random amount of time. * Made sure of no collision when going for fallback validity bits * Update CHANGELOG.md
1 parent 5cecf4e commit 0d13f98

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

com.unity.render-pipelines.core/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1212

1313
### Fixed
1414
- Fixed issue when changing volume profiles at runtime with a script (case 1364256).
15+
- Fixed an issue causing Render Graph execution errors after a random amount of time.
1516

1617
## [13.1.1] - 2021-10-04
1718

com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResources.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,21 @@ public bool IsValid()
4848

4949
static public void NewFrame(int executionIndex)
5050
{
51+
uint previousValidBit = s_CurrentValidBit;
5152
// Scramble frame count to avoid collision when wrapping around.
5253
s_CurrentValidBit = (uint)(((executionIndex >> 16) ^ (executionIndex & 0xffff) * 58546883) << 16);
5354
// In case the current valid bit is 0, even though perfectly valid, 0 represents an invalid handle, hence we'll
5455
// trigger an invalid state incorrectly. To account for this, we actually skip 0 as a viable s_CurrentValidBit and
5556
// start from 1 again.
56-
if (s_CurrentValidBit == 0)
57+
// In the same spirit, s_SharedResourceValidBit is reserved for shared textures so we should never use it otherwise
58+
// resources could be considered valid at frame N+1 (because shared) even though they aren't.
59+
if (s_CurrentValidBit == 0 || s_CurrentValidBit == s_SharedResourceValidBit)
5760
{
58-
s_CurrentValidBit = 1 << 16;
61+
// We need to make sure we don't pick the same value twice.
62+
uint value = 1;
63+
while (previousValidBit == (value << 16))
64+
value++;
65+
s_CurrentValidBit = (value << 16);
5966
}
6067
}
6168
}

0 commit comments

Comments
 (0)