From 99ab0285e459753838d0e0716fda9be7b4976a4c Mon Sep 17 00:00:00 2001 From: charlotte Date: Mon, 19 Aug 2024 17:51:15 -0700 Subject: [PATCH] Fix mesh2_manual exapmle. (#14831) Fix `mesh2d_manual` example from changes in #13069. ``` wgpu error: Validation Error Caused by: In RenderPass::end In a set_pipeline command Render pipeline targets are incompatible with render pass Incompatible depth-stencil attachment format: the RenderPass uses a texture with format Some(Depth32Float) but the RenderPipeline with 'colored_mesh2d_pipeline' label uses an attachment with format None ``` --- examples/2d/mesh2d_manual.rs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/examples/2d/mesh2d_manual.rs b/examples/2d/mesh2d_manual.rs index fabdafba4c8ab..6a7e97f6fd071 100644 --- a/examples/2d/mesh2d_manual.rs +++ b/examples/2d/mesh2d_manual.rs @@ -7,7 +7,7 @@ use bevy::{ color::palettes::basic::YELLOW, - core_pipeline::core_2d::Transparent2d, + core_pipeline::core_2d::{Transparent2d, CORE_2D_DEPTH_FORMAT}, math::FloatOrd, prelude::*, render::{ @@ -18,9 +18,10 @@ use bevy::{ ViewSortedRenderPhases, }, render_resource::{ - BlendState, ColorTargetState, ColorWrites, Face, FragmentState, FrontFace, - MultisampleState, PipelineCache, PolygonMode, PrimitiveState, PrimitiveTopology, - RenderPipelineDescriptor, SpecializedRenderPipeline, SpecializedRenderPipelines, + BlendState, ColorTargetState, ColorWrites, CompareFunction, DepthBiasState, + DepthStencilState, Face, FragmentState, FrontFace, MultisampleState, PipelineCache, + PolygonMode, PrimitiveState, PrimitiveTopology, RenderPipelineDescriptor, + SpecializedRenderPipeline, SpecializedRenderPipelines, StencilFaceState, StencilState, TextureFormat, VertexBufferLayout, VertexFormat, VertexState, VertexStepMode, }, texture::BevyDefault, @@ -198,7 +199,22 @@ impl SpecializedRenderPipeline for ColoredMesh2dPipeline { topology: key.primitive_topology(), strip_index_format: None, }, - depth_stencil: None, + depth_stencil: Some(DepthStencilState { + format: CORE_2D_DEPTH_FORMAT, + depth_write_enabled: false, + depth_compare: CompareFunction::GreaterEqual, + stencil: StencilState { + front: StencilFaceState::IGNORE, + back: StencilFaceState::IGNORE, + read_mask: 0, + write_mask: 0, + }, + bias: DepthBiasState { + constant: 0, + slope_scale: 0.0, + clamp: 0.0, + }, + }), multisample: MultisampleState { count: key.msaa_samples(), mask: !0,