mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-04 09:58:27 +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 {
|
||||
pub fn new(
|
||||
device: &wgpu::Device,
|
||||
config: &wgpu::SurfaceConfiguration,
|
||||
_: &wgpu::SurfaceConfiguration,
|
||||
shaders: &Shaders,
|
||||
uniforms: &wgpu::Buffer,
|
||||
) -> Self {
|
||||
@ -44,11 +44,7 @@ impl Pipeline {
|
||||
entry_point: Some("fragment"),
|
||||
compilation_options:
|
||||
wgpu::PipelineCompilationOptions::default(),
|
||||
targets: &[Some(wgpu::ColorTargetState {
|
||||
format: config.format,
|
||||
blend: Some(wgpu::BlendState::REPLACE),
|
||||
write_mask: wgpu::ColorWrites::all(),
|
||||
})],
|
||||
targets: &shaders.fragment_targets,
|
||||
}),
|
||||
primitive: wgpu::PrimitiveState {
|
||||
topology: wgpu::PrimitiveTopology::TriangleList,
|
||||
|
@ -59,7 +59,7 @@ impl Renderer {
|
||||
usage: wgpu::BufferUsages::UNIFORM,
|
||||
});
|
||||
|
||||
let shaders = Shaders::triangles(&device);
|
||||
let shaders = Shaders::triangles(&device, &config);
|
||||
let pipeline =
|
||||
Pipeline::new(&device, &config, &shaders, &transform_buffer);
|
||||
|
||||
|
@ -2,14 +2,27 @@ use glam::Mat4;
|
||||
|
||||
pub struct Shaders {
|
||||
pub shader_module: wgpu::ShaderModule,
|
||||
pub fragment_targets: [Option<wgpu::ColorTargetState>; 1],
|
||||
}
|
||||
|
||||
impl Shaders {
|
||||
pub fn triangles(device: &wgpu::Device) -> Self {
|
||||
pub fn triangles(
|
||||
device: &wgpu::Device,
|
||||
config: &wgpu::SurfaceConfiguration,
|
||||
) -> Self {
|
||||
let shader_module =
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user