From 077198f0f36048c739bbda3a6d08b2bd07c1c673 Mon Sep 17 00:00:00 2001 From: botoddly <250804054+botoddly@users.noreply.github.com> Date: Mon, 26 Oct 2026 20:32:58 +0100 Subject: [PATCH] Add ColorTargetSettings.Load to match the render pass docs --- docs/render-pass-flow.md | 2 +- src/Pixely.Ui/UiRenderer.cs | 4 +--- src/Pixely/Gpu/ColorTargetSettings.cs | 1 + 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/render-pass-flow.md b/docs/render-pass-flow.md index 1b838ff6..b1c86ca4 100644 --- a/docs/render-pass-flow.md +++ b/docs/render-pass-flow.md @@ -106,7 +106,7 @@ new RenderPassBuilder(commandBuffer) **ColorTargetSettings options:** - `Clear` - Clear the target before rendering - `Load` - Keep existing contents -- Others may exist for different load/store operations +- Other combinations: `new ColorTargetSettings { LoadOperation = ..., StoreOperation = ..., ClearColorValue = ... }` Add multiple color targets for deferred rendering (G-buffer). A pass takes at most 8 color targets, SDL's limit. diff --git a/src/Pixely.Ui/UiRenderer.cs b/src/Pixely.Ui/UiRenderer.cs index fca09005..ea04ce72 100644 --- a/src/Pixely.Ui/UiRenderer.cs +++ b/src/Pixely.Ui/UiRenderer.cs @@ -22,8 +22,6 @@ internal sealed class UiRenderer : IRenderer, ID ClearColorValue = LinearColors.Transparent }; - private static readonly ColorTargetSettings _loadColorTargetSettings = new() { LoadOperation = LoadOperation.Load }; - private static readonly Matrix4x4 _presentViewProjection = Matrix4x4.CreateOrthographicOffCenterLeftHanded(0, 1, 1, 0, 0, 1); @@ -287,7 +285,7 @@ private static void ClearTarget(CommandBuffer commandBuffer, Texture target) private void Present(CommandBuffer commandBuffer, Texture target, Texture retainedTexture, Matrix4x4 world) { - ColorTargetSettings settings = _clearTarget ? ColorTargetSettings.Clear : _loadColorTargetSettings; + ColorTargetSettings settings = _clearTarget ? ColorTargetSettings.Clear : ColorTargetSettings.Load; using RenderPass presentPass = new RenderPassBuilder(commandBuffer) .AddColorTarget(target, settings) diff --git a/src/Pixely/Gpu/ColorTargetSettings.cs b/src/Pixely/Gpu/ColorTargetSettings.cs index f1b32a5b..37c4a848 100644 --- a/src/Pixely/Gpu/ColorTargetSettings.cs +++ b/src/Pixely/Gpu/ColorTargetSettings.cs @@ -6,4 +6,5 @@ public class ColorTargetSettings public LoadOperation LoadOperation { get; init; } = LoadOperation.Clear; public StoreOperation StoreOperation { get; init; } = StoreOperation.Store; public static readonly ColorTargetSettings Clear = new(); + public static readonly ColorTargetSettings Load = new() { LoadOperation = LoadOperation.Load }; } \ No newline at end of file