Add Pipelines

This commit is contained in:
Hanno Braun 2024-11-22 18:53:47 +01:00
parent d2a4d60b52
commit ccd9b7d472
2 changed files with 13 additions and 7 deletions

View File

@ -3,6 +3,11 @@ use super::{
shaders::{Shaders, Vertex}, shaders::{Shaders, Vertex},
}; };
pub struct Pipelines {
pub vertices: Pipeline,
pub triangles: Pipeline,
}
pub struct Pipeline { pub struct Pipeline {
render_pipeline: wgpu::RenderPipeline, render_pipeline: wgpu::RenderPipeline,
bind_group: wgpu::BindGroup, bind_group: wgpu::BindGroup,

View File

@ -9,7 +9,7 @@ use crate::geometry::Operation;
use super::{ use super::{
geometry::Geometry, geometry::Geometry,
pipelines::Pipeline, pipelines::{Pipeline, Pipelines},
shaders::{Shaders, Uniforms}, shaders::{Shaders, Uniforms},
}; };
@ -17,8 +17,7 @@ pub struct Renderer {
pub surface: wgpu::Surface<'static>, pub surface: wgpu::Surface<'static>,
pub device: wgpu::Device, pub device: wgpu::Device,
pub queue: wgpu::Queue, pub queue: wgpu::Queue,
pub vertices_pipeline: Pipeline, pub pipelines: Pipelines,
pub triangles_pipeline: Pipeline,
pub depth_view: wgpu::TextureView, pub depth_view: wgpu::TextureView,
} }
@ -94,8 +93,10 @@ impl Renderer {
surface, surface,
device, device,
queue, queue,
vertices_pipeline, pipelines: Pipelines {
triangles_pipeline, vertices: vertices_pipeline,
triangles: triangles_pipeline,
},
depth_view, depth_view,
}) })
} }
@ -140,13 +141,13 @@ impl Renderer {
}); });
} }
self.vertices_pipeline.draw( self.pipelines.vertices.draw(
&mut encoder, &mut encoder,
&color_view, &color_view,
&self.depth_view, &self.depth_view,
&vertices, &vertices,
); );
self.triangles_pipeline.draw( self.pipelines.triangles.draw(
&mut encoder, &mut encoder,
&color_view, &color_view,
&self.depth_view, &self.depth_view,