Skip to content

Commit ab12d08

Browse files
[URP] make the Vulkan RenderTexture MSAA support fallback work in the same way as the swapchain backend implementation (#6180)
* made the Vulkan MSAA support fallback behaviour behave in the same way as the swapchain's backend code * added comments to the Vulkan MSAA fallback code * Added changelog entry Co-authored-by: Felipe Lira <[email protected]>
1 parent 8a41597 commit ab12d08

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
3535
- Fix for rendering thumbnails. [case 1348209](https://issuetracker.unity3d.com/issues/preview-of-assets-do-not-show-in-the-project-window)
3636
- Fixed a regression bug where XR camera postion can not be modified in beginCameraRendering [case 1365000]
3737
- Fixed an issue in where installing the Adaptive Performance package caused errors to the inspector UI [1368161](https://issuetracker.unity3d.com/issues/urp-package-throws-compilation-error-cs1525-when-imported-together-with-adaptive-performance-package)
38+
- Fixed an issue with MSAA falling back to the incorrect value when sample count 2 is not supported on some Android GPUs
3839
- Fixed decals to work with native render pass [case 1353141](https://issuetracker.unity3d.com/issues/urp-decals-are-not-visible-in-game-view-after-modifying-urp-asset-properties)
3940
- Fixed decals to work with render scale [1353885](https://issuetracker.unity3d.com/issues/urp-builtin-to-urp-render-pipeline-converter-freezes-the-editor-when-converting-rendering-settings)
4041
- Fixed a regression where filtering the scene view yielded incorrect visual results [1360233](https://issuetracker.unity3d.com/product/unity/issues/guid/1360233)

com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineCore.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,19 @@ static RenderTextureDescriptor CreateRenderTextureDescriptor(Camera camera, floa
572572
desc.bindMS = false;
573573
desc.useDynamicScale = camera.allowDynamicResolution;
574574

575+
// The way RenderTextures handle MSAA fallback when an unsupported sample count of 2 is requested (falling back to numSamples = 1), differs fom the way
576+
// the fallback is handled when setting up the Vulkan swapchain (rounding up numSamples to 4, if supported). This caused an issue on Mali GPUs which don't support
577+
// 2x MSAA.
578+
// The following code makes sure that on Vulkan the MSAA unsupported fallback behaviour is consistent between RenderTextures and Swapchain.
579+
// TODO: we should review how all backends handle MSAA fallbacks and move these implementation details in engine code.
580+
if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Vulkan)
581+
{
582+
// if the requested number of samples is 2, and the supported value is 1x, it means that 2x is unsupported on this GPU.
583+
// Then we bump up the requested value to 4.
584+
if (desc.msaaSamples == 2 && SystemInfo.GetRenderTextureSupportedMSAASampleCount(desc) == 1)
585+
desc.msaaSamples = 4;
586+
}
587+
575588
// check that the requested MSAA samples count is supported by the current platform. If it's not supported,
576589
// replace the requested desc.msaaSamples value with the actual value the engine falls back to
577590
desc.msaaSamples = SystemInfo.GetRenderTextureSupportedMSAASampleCount(desc);

com.unity.render-pipelines.universal/Runtime/UniversalRenderer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ bool CanCopyDepth(ref CameraData cameraData)
11271127

11281128
// copying depth on GLES3 is giving invalid results. Needs investigation (Fogbugz issue 1339401)
11291129
if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.OpenGLES3)
1130-
msaaDepthResolve = false;
1130+
return false;
11311131

11321132
return supportsDepthCopy || msaaDepthResolve;
11331133
}

0 commit comments

Comments
 (0)