Skip to content

Fixed an issue causing Render Graph execution errors after a random amount of time. #6329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

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

## [13.1.1] - 2021-10-04

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,21 @@ public bool IsValid()

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