Add "standard config" to pipeline builder

This commit is contained in:
Carter Anderson 2020-02-17 20:43:50 -08:00
parent ad7acb111a
commit e0e0e41c33
3 changed files with 26 additions and 24 deletions

View file

@ -6,14 +6,11 @@ Here is the current list of planned features. All items are sorted in approximat
* Text
* Styling
* Rendering
* Render Graph V2
* Textures
* Physically based rendering
* Skeletal animation
* Macro to produce vertex buffer attributes (and maybe descriptors) from structs
* Add runtime type safety to uniform bindings (and maybe compile time)
* Dynamic / user defined shaders
* consider using shaderc-rs. but this introduces compile complexity and requires other C++ build systems
* Error Handling
* Custom error type?
* Remove as many panics / unwraps as possible

View file

@ -4,7 +4,7 @@ use bevy::{
render_graph::{
resource_name, resource_providers::UniformResourceProvider, PipelineDescriptor,
},
Shader, ShaderStage, Vertex,
Shader, ShaderStage,
},
};
@ -60,23 +60,7 @@ fn main() {
}
"#,
))
.with_depth_stencil_state(wgpu::DepthStencilStateDescriptor {
format: wgpu::TextureFormat::Depth32Float,
depth_write_enabled: true,
depth_compare: wgpu::CompareFunction::Less,
stencil_front: wgpu::StencilStateFaceDescriptor::IGNORE,
stencil_back: wgpu::StencilStateFaceDescriptor::IGNORE,
stencil_read_mask: 0,
stencil_write_mask: 0,
})
.add_color_state(wgpu::ColorStateDescriptor {
format: wgpu::TextureFormat::Bgra8UnormSrgb,
color_blend: wgpu::BlendDescriptor::REPLACE,
alpha_blend: wgpu::BlendDescriptor::REPLACE,
write_mask: wgpu::ColorWrite::ALL,
})
.add_vertex_buffer_descriptor(Vertex::get_vertex_buffer_descriptor())
.add_draw_target(resource_name::draw_target::ASSIGNED_MESHES)
.with_standard_config()
.build(),
)
})
@ -95,7 +79,7 @@ fn setup(world: &mut World) {
.add_archetype(MeshMaterialEntity::<MyMaterial> {
mesh: cube_handle,
renderable: Renderable {
pipelines: vec![Handle::new(2)],
pipelines: vec![Handle::new(2)], // TODO: make this pipeline assignment cleaner
..Default::default()
},
material: MyMaterial {

View file

@ -1,6 +1,6 @@
use crate::{asset::{AssetStorage, Handle}, render::{
render_graph::{BindGroup, PipelineLayout},
shader::{Shader, ShaderStages},
render_graph::{BindGroup, PipelineLayout, resource_name},
shader::{Shader, ShaderStages}, Vertex,
}};
#[derive(Clone, Debug)]
@ -206,4 +206,25 @@ impl<'a> PipelineBuilder<'a> {
self.pipeline.sample_mask = sample_mask;
self
}
pub fn with_standard_config(self) -> Self {
self
.with_depth_stencil_state(wgpu::DepthStencilStateDescriptor {
format: wgpu::TextureFormat::Depth32Float,
depth_write_enabled: true,
depth_compare: wgpu::CompareFunction::Less,
stencil_front: wgpu::StencilStateFaceDescriptor::IGNORE,
stencil_back: wgpu::StencilStateFaceDescriptor::IGNORE,
stencil_read_mask: 0,
stencil_write_mask: 0,
})
.add_color_state(wgpu::ColorStateDescriptor {
format: wgpu::TextureFormat::Bgra8UnormSrgb,
color_blend: wgpu::BlendDescriptor::REPLACE,
alpha_blend: wgpu::BlendDescriptor::REPLACE,
write_mask: wgpu::ColorWrite::ALL,
})
.add_vertex_buffer_descriptor(Vertex::get_vertex_buffer_descriptor())
.add_draw_target(resource_name::draw_target::ASSIGNED_MESHES)
}
}