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
```
This commit is contained in:
charlotte 2024-08-19 17:51:15 -07:00 committed by GitHub
parent 491aec8e5b
commit 99ab0285e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,