Skip to content

Commit d41de7f

Browse files
authored
Fix MainTransparentPass2dNode attachment ordering (#18306)
Fix #17763. Attachment info needs to be created outside of the command encoding task, as it needs to be part of the serial node runners in order to get the ordering correct.
1 parent bc7416a commit d41de7f

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

Diff for: crates/bevy_core_pipeline/src/core_2d/main_transparent_pass_2d_node.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ impl ViewNode for MainTransparentPass2dNode {
4444

4545
let diagnostics = render_context.diagnostic_recorder();
4646

47+
let color_attachments = [Some(target.get_color_attachment())];
48+
// NOTE: For the transparent pass we load the depth buffer. There should be no
49+
// need to write to it, but store is set to `true` as a workaround for issue #3776,
50+
// https://github.com/bevyengine/bevy/issues/3776
51+
// so that wgpu does not clear the depth buffer.
52+
// As the opaque and alpha mask passes run first, opaque meshes can occlude
53+
// transparent ones.
54+
let depth_stencil_attachment = Some(depth.get_attachment(StoreOp::Store));
55+
4756
render_context.add_command_buffer_generation_task(move |render_device| {
4857
// Command encoder setup
4958
let mut command_encoder =
@@ -58,14 +67,8 @@ impl ViewNode for MainTransparentPass2dNode {
5867

5968
let render_pass = command_encoder.begin_render_pass(&RenderPassDescriptor {
6069
label: Some("main_transparent_pass_2d"),
61-
color_attachments: &[Some(target.get_color_attachment())],
62-
// NOTE: For the transparent pass we load the depth buffer. There should be no
63-
// need to write to it, but store is set to `true` as a workaround for issue #3776,
64-
// https://github.com/bevyengine/bevy/issues/3776
65-
// so that wgpu does not clear the depth buffer.
66-
// As the opaque and alpha mask passes run first, opaque meshes can occlude
67-
// transparent ones.
68-
depth_stencil_attachment: Some(depth.get_attachment(StoreOp::Store)),
70+
color_attachments: &color_attachments,
71+
depth_stencil_attachment,
6972
timestamp_writes: None,
7073
occlusion_query_set: None,
7174
});

0 commit comments

Comments
 (0)