Skip to content

UI only shows if in last pass #5721

@HackerFoo

Description

@HackerFoo

Bevy version

f1be89d

Relevant system information

Tested on MacOS and iOS, with 4x MSAA

What you did

I used UiCameraConfig to enable show_ui on only one pass that was not the last pass (using camera priority.)

What went wrong

The UI did not show, but I could see it was being rendered using the Metal debugger.

Additional information

I suspected that the wrong color attachment was being used, so that the rendered UI was accidentally discarded.

So I made the following changes:

diff --git a/crates/bevy_ui/src/render/pipeline.rs b/crates/bevy_ui/src/render/pipeline.rs
index e199cef52..7914d3b8f 100644
--- a/crates/bevy_ui/src/render/pipeline.rs
+++ b/crates/bevy_ui/src/render/pipeline.rs
@@ -105,7 +105,7 @@ impl SpecializedRenderPipeline for UiPipeline {
             },
             depth_stencil: None,
             multisample: MultisampleState {
-                count: 1,
+                count: 4,
                 mask: !0,
                 alpha_to_coverage_enabled: false,
             },
diff --git a/crates/bevy_ui/src/render/render_pass.rs b/crates/bevy_ui/src/render/render_pass.rs
index 66445c92a..9308b7a26 100644
--- a/crates/bevy_ui/src/render/render_pass.rs
+++ b/crates/bevy_ui/src/render/render_pass.rs
@@ -81,14 +81,10 @@ impl Node for UiPassNode {
         };
         let pass_descriptor = RenderPassDescriptor {
             label: Some("ui_pass"),
-            color_attachments: &[Some(RenderPassColorAttachment {
-                view: &target.view,
-                resolve_target: None,
-                ops: Operations {
-                    load: LoadOp::Load,
-                    store: true,
-                },
-            })],
+            color_attachments: &[Some(target.get_color_attachment(Operations {
+                load: LoadOp::Load,
+                store: true,
+            }))],
             depth_stencil_attachment: None,
         };

and it works as expected now, but it's probably not necessary to use MSAA for the UI, so I'm not sure what the correct way to do this is. Obviously hardcoding the multisample count is a bad idea; it would have to be passed through the key if this is actually the correct solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenA-UIGraphical user interfaces, styles, layouts, and widgetsC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions