wde_renderer/passes/
pipeline_types.rs1use bevy::{asset::Handle, ecs::prelude::*};
2use wde_wgpu::{
3 bind_group::BindGroupLayout,
4 pipelines::{BlendState, ColorWrites},
5 render_pipeline::{DepthDescriptor, Face, RenderTopology, ShaderStages},
6 texture::TextureFormat
7};
8
9use crate::assets::Shader;
10
11#[derive(Clone)]
14pub struct PushConstantDescriptor {
15 pub stages: ShaderStages,
17 pub offset: u32,
19 pub size: u32
21}
22
23#[derive(Resource, Clone)]
25pub struct RenderPipelineDescriptor {
26 pub label: &'static str,
27 pub vert: Option<Handle<Shader>>,
28 pub frag: Option<Handle<Shader>>,
29
30 pub depth: DepthDescriptor,
32 pub render_targets: Option<Vec<TextureFormat>>,
34
35 pub bind_group_layouts: Vec<Option<BindGroupLayout>>,
37 pub push_constants: Vec<PushConstantDescriptor>,
39
40 pub topology: RenderTopology,
42 pub cull_mode: Option<Face>,
44 pub fragment_blend: Option<BlendState>,
46 pub color_write: ColorWrites,
48 pub sample_count: u32,
50 pub vertex_buffer: bool
52}
53impl Default for RenderPipelineDescriptor {
54 fn default() -> Self {
55 Self {
56 label: "Unknown Render Pipeline",
57 vert: None,
58 frag: None,
59 depth: DepthDescriptor::default(),
60 render_targets: None,
61 bind_group_layouts: vec![],
62 push_constants: vec![],
63 topology: RenderTopology::TriangleList,
64 cull_mode: Some(Face::Back),
65 fragment_blend: Some(BlendState::REPLACE),
66 color_write: ColorWrites::ALL,
67 sample_count: 1,
68 vertex_buffer: true
69 }
70 }
71}
72
73#[derive(Resource, Clone)]
75pub struct ComputePipelineDescriptor {
76 pub label: &'static str,
77 pub comp: Option<Handle<Shader>>,
78
79 pub bind_group_layouts: Vec<Option<BindGroupLayout>>,
81 pub push_constants: Vec<PushConstantDescriptor>
83}
84impl Default for ComputePipelineDescriptor {
85 fn default() -> Self {
86 Self {
87 label: "Unknown Compute Pipeline",
88 comp: None,
89 bind_group_layouts: vec![],
90 push_constants: vec![]
91 }
92 }
93}