Skip to content

Commit dd22da8

Browse files
committed
Fix clear code in LightweightPipeline
The clear code wasn't clearing depth if the camera clear flag was set to Skybox. The skybox rendering is dependent on depth being cleared initially, so it can fill in areas that opaque rendering hasn't covered. But right now, depth is not being cleared, which breaks rendering. This is a temporary fix for the clear code, as it isn't entirely optimal for TBDR GPUs. Ideally, the first camera in the camera stack will clear both depth and color in order to prevent tile initialization. Then the following cameras will avoid color clearing as they will need to load the contents from the previous camera render. This code will be amended when Felipe adds camera stack support to LightweightPipeline.
1 parent c2f763a commit dd22da8

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

Assets/ScriptableRenderPipeline/LightweightPipeline/LightweightPipeline.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,12 @@ private void BeginForwardRendering(Camera camera, ref ScriptableRenderContext co
583583
// Clear RenderTarget to avoid tile initialization on mobile GPUs
584584
// https://community.arm.com/graphics/b/blog/posts/mali-performance-2-how-to-correctly-handle-framebuffers
585585
if (camera.clearFlags != CameraClearFlags.Nothing)
586-
cmd.ClearRenderTarget(camera.clearFlags == CameraClearFlags.Color, camera.clearFlags == CameraClearFlags.Color || camera.clearFlags == CameraClearFlags.Depth, camera.backgroundColor);
586+
{
587+
bool clearDepth = (camera.clearFlags != CameraClearFlags.Nothing);
588+
bool clearColor = (camera.clearFlags == CameraClearFlags.Color);
589+
cmd.ClearRenderTarget(clearDepth, clearColor, camera.backgroundColor);
590+
591+
}
587592

588593
context.ExecuteCommandBuffer(cmd);
589594
CommandBufferPool.Release(cmd);

0 commit comments

Comments
 (0)