mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-05 18:38:28 +00:00
Prepare for adding more shaders
This commit is contained in:
parent
4adef89aaf
commit
18df3cddd7
@ -8,7 +8,7 @@ pub struct Pipeline {
|
|||||||
impl Pipeline {
|
impl Pipeline {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
device: &wgpu::Device,
|
device: &wgpu::Device,
|
||||||
config: &wgpu::SurfaceConfiguration,
|
_: &wgpu::SurfaceConfiguration,
|
||||||
shaders: &Shaders,
|
shaders: &Shaders,
|
||||||
uniforms: &wgpu::Buffer,
|
uniforms: &wgpu::Buffer,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
@ -44,11 +44,7 @@ impl Pipeline {
|
|||||||
entry_point: Some("fragment"),
|
entry_point: Some("fragment"),
|
||||||
compilation_options:
|
compilation_options:
|
||||||
wgpu::PipelineCompilationOptions::default(),
|
wgpu::PipelineCompilationOptions::default(),
|
||||||
targets: &[Some(wgpu::ColorTargetState {
|
targets: &shaders.fragment_targets,
|
||||||
format: config.format,
|
|
||||||
blend: Some(wgpu::BlendState::REPLACE),
|
|
||||||
write_mask: wgpu::ColorWrites::all(),
|
|
||||||
})],
|
|
||||||
}),
|
}),
|
||||||
primitive: wgpu::PrimitiveState {
|
primitive: wgpu::PrimitiveState {
|
||||||
topology: wgpu::PrimitiveTopology::TriangleList,
|
topology: wgpu::PrimitiveTopology::TriangleList,
|
||||||
|
@ -59,7 +59,7 @@ impl Renderer {
|
|||||||
usage: wgpu::BufferUsages::UNIFORM,
|
usage: wgpu::BufferUsages::UNIFORM,
|
||||||
});
|
});
|
||||||
|
|
||||||
let shaders = Shaders::triangles(&device);
|
let shaders = Shaders::triangles(&device, &config);
|
||||||
let pipeline =
|
let pipeline =
|
||||||
Pipeline::new(&device, &config, &shaders, &transform_buffer);
|
Pipeline::new(&device, &config, &shaders, &transform_buffer);
|
||||||
|
|
||||||
|
@ -2,14 +2,27 @@ use glam::Mat4;
|
|||||||
|
|
||||||
pub struct Shaders {
|
pub struct Shaders {
|
||||||
pub shader_module: wgpu::ShaderModule,
|
pub shader_module: wgpu::ShaderModule,
|
||||||
|
pub fragment_targets: [Option<wgpu::ColorTargetState>; 1],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Shaders {
|
impl Shaders {
|
||||||
pub fn triangles(device: &wgpu::Device) -> Self {
|
pub fn triangles(
|
||||||
|
device: &wgpu::Device,
|
||||||
|
config: &wgpu::SurfaceConfiguration,
|
||||||
|
) -> Self {
|
||||||
let shader_module =
|
let shader_module =
|
||||||
device.create_shader_module(wgpu::include_wgsl!("triangles.wgsl"));
|
device.create_shader_module(wgpu::include_wgsl!("triangles.wgsl"));
|
||||||
|
|
||||||
Self { shader_module }
|
let fragment_targets = [Some(wgpu::ColorTargetState {
|
||||||
|
format: config.format,
|
||||||
|
blend: Some(wgpu::BlendState::REPLACE),
|
||||||
|
write_mask: wgpu::ColorWrites::all(),
|
||||||
|
})];
|
||||||
|
|
||||||
|
Self {
|
||||||
|
shader_module,
|
||||||
|
fragment_targets,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn vertex_state(&self) -> wgpu::VertexState {
|
pub fn vertex_state(&self) -> wgpu::VertexState {
|
||||||
|
Loading…
Reference in New Issue
Block a user