Skip to content

Commit

Permalink
Prepare for adding more shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Nov 20, 2024
1 parent fb9d7f1 commit fad4ad6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
15 changes: 2 additions & 13 deletions experiments/2024-10-30/src/render/pipeline.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::shaders::{Shaders, TrianglesVertex};
use super::shaders::Shaders;

pub struct Pipeline {
render_pipeline: wgpu::RenderPipeline,
Expand Down Expand Up @@ -38,18 +38,7 @@ impl Pipeline {
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: None,
layout: Some(&layout),
vertex: wgpu::VertexState {
module: &shaders.shader_module,
entry_point: Some("vertex"),
compilation_options:
wgpu::PipelineCompilationOptions::default(),
buffers: &[wgpu::VertexBufferLayout {
array_stride: size_of::<TrianglesVertex>()
as wgpu::BufferAddress,
step_mode: wgpu::VertexStepMode::Vertex,
attributes: TrianglesVertex::ATTRIBUTES,
}],
},
vertex: shaders.vertex_state(),
fragment: Some(wgpu::FragmentState {
module: &shaders.shader_module,
entry_point: Some("fragment"),
Expand Down
14 changes: 14 additions & 0 deletions experiments/2024-10-30/src/render/shaders/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ impl Shaders {

Self { shader_module }
}

pub fn vertex_state(&self) -> wgpu::VertexState {
wgpu::VertexState {
module: &self.shader_module,
entry_point: Some("vertex"),
compilation_options: wgpu::PipelineCompilationOptions::default(),
buffers: &[wgpu::VertexBufferLayout {
array_stride: size_of::<TrianglesVertex>()
as wgpu::BufferAddress,
step_mode: wgpu::VertexStepMode::Vertex,
attributes: TrianglesVertex::ATTRIBUTES,
}],
}
}
}

#[derive(Clone, Copy, bytemuck::Pod, bytemuck::Zeroable)]
Expand Down

0 comments on commit fad4ad6

Please sign in to comment.