Skip to content

Commit 45e5e50

Browse files
kechosebastienlagarde
authored andcommitted
[Fogbugz # 1383093] Fixing leaky state of hardware resolution when turned off from camera #6492
1 parent ee8ffe8 commit 45e5e50

4 files changed

Lines changed: 16 additions & 9 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [13.1.4] - 2021-12-04
88

9-
Version Updated
10-
The version number for this package has increased due to a version update of a related graphics package.
9+
### Fixed
10+
- Fixed issue in DynamicResolutionHandler when camera request was turned off at runtime, the ScalableBufferManager would leak state and not unset DRS state (case 1383093).
1111

1212
## [13.1.3] - 2021-11-17
1313

com.unity.render-pipelines.core/Runtime/Common/DynamicResolutionHandler.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ private bool FlushScalableBufferManagerState()
144144

145145
s_GlobalHwUpresActive = HardwareDynamicResIsEnabled();
146146
s_GlobalHwFraction = m_CurrentFraction;
147-
ScalableBufferManager.ResizeBuffers(s_GlobalHwFraction, s_GlobalHwFraction);
147+
float currentFraction = s_GlobalHwUpresActive ? s_GlobalHwFraction : 1.0f;
148+
ScalableBufferManager.ResizeBuffers(currentFraction, currentFraction);
148149
return true;
149150
}
150151

@@ -418,6 +419,7 @@ public void Update(GlobalDynamicResolutionSettings settings, Action OnResolution
418419

419420
if (!m_Enabled || !s_ActiveInstanceDirty)
420421
{
422+
FlushScalableBufferManagerState();
421423
s_ActiveInstanceDirty = false;
422424
return;
423425
}

com.unity.render-pipelines.high-definition/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2727
- Fixed the ray tracing fallbacks being broken since an Nvidia Driver Update.
2828
- Render Graph object pools are now cleared with render graph cleanup
2929
- Fixed a shader warning in UnityInstancing.hlsl
30-
- Fixed misc shader warnings.
30+
- Fixed AO dissapearing when DRS would be turned off through a camera, while hardware drs is active in DX12 or Vulkan (case 1383093).
3131

3232
## [13.1.3] - 2021-11-17
3333

com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,13 @@ internal static void RestoreRenderPipelineAsset(bool wasUnsetFromQuality, Render
593593
internal struct PackedMipChainInfo
594594
{
595595
public Vector2Int textureSize;
596-
public Vector2Int hardwareTextureSize;
597596
public int mipLevelCount;
598597
public Vector2Int[] mipLevelSizes;
599598
public Vector2Int[] mipLevelOffsets;
600599

600+
private Vector2 cachedTextureScale;
601+
private Vector2Int cachedHardwareTextureSize;
602+
601603
private bool m_OffsetBufferWillNeedUpdate;
602604

603605
public void Allocate()
@@ -612,13 +614,16 @@ public void Allocate()
612614
// This function is NOT fast, but it is illustrative, and can be optimized later.
613615
public void ComputePackedMipChainInfo(Vector2Int viewportSize)
614616
{
617+
bool isHardwareDrsOn = DynamicResolutionHandler.instance.HardwareDynamicResIsEnabled();
618+
Vector2Int hardwareTextureSize = isHardwareDrsOn ? DynamicResolutionHandler.instance.ApplyScalesOnSize(viewportSize) : viewportSize;
619+
Vector2 textureScale = isHardwareDrsOn ? new Vector2((float)viewportSize.x / (float)hardwareTextureSize.x, (float)viewportSize.y / (float)hardwareTextureSize.y) : new Vector2(1.0f, 1.0f);
620+
615621
// No work needed.
616-
if (viewportSize == mipLevelSizes[0])
622+
if (cachedHardwareTextureSize == hardwareTextureSize && cachedTextureScale == textureScale)
617623
return;
618624

619-
bool isHardwareDrsOn = DynamicResolutionHandler.instance.HardwareDynamicResIsEnabled();
620-
hardwareTextureSize = isHardwareDrsOn ? DynamicResolutionHandler.instance.ApplyScalesOnSize(viewportSize) : viewportSize;
621-
Vector2 textureScale = isHardwareDrsOn ? new Vector2((float)viewportSize.x / (float)hardwareTextureSize.x, (float)viewportSize.y / (float)hardwareTextureSize.y) : new Vector2(1.0f, 1.0f);
625+
cachedHardwareTextureSize = hardwareTextureSize;
626+
cachedTextureScale = textureScale;
622627

623628
mipLevelSizes[0] = hardwareTextureSize;
624629
mipLevelOffsets[0] = Vector2Int.zero;

0 commit comments

Comments
 (0)