Minor improvement: only one shader module is necessary (#175)
This commit is contained in:
parent
7913cbdb85
commit
338a63a40e
|
@ -14,8 +14,7 @@ impl NoiseRenderer {
|
||||||
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("../shaders/noise.wgsl"))),
|
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("../shaders/noise.wgsl"))),
|
||||||
flags: wgpu::ShaderFlags::VALIDATION,
|
flags: wgpu::ShaderFlags::VALIDATION,
|
||||||
};
|
};
|
||||||
let vs_module = device.create_shader_module(&shader);
|
let module = device.create_shader_module(&shader);
|
||||||
let fs_module = device.create_shader_module(&shader);
|
|
||||||
|
|
||||||
// Create a texture sampler with nearest neighbor
|
// Create a texture sampler with nearest neighbor
|
||||||
let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
|
let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
|
||||||
|
@ -108,7 +107,7 @@ impl NoiseRenderer {
|
||||||
label: Some("NoiseRenderer pipeline"),
|
label: Some("NoiseRenderer pipeline"),
|
||||||
layout: Some(&pipeline_layout),
|
layout: Some(&pipeline_layout),
|
||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &vs_module,
|
module: &module,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
},
|
},
|
||||||
|
@ -116,7 +115,7 @@ impl NoiseRenderer {
|
||||||
depth_stencil: None,
|
depth_stencil: None,
|
||||||
multisample: wgpu::MultisampleState::default(),
|
multisample: wgpu::MultisampleState::default(),
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &fs_module,
|
module: &module,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
targets: &[wgpu::ColorTargetState {
|
targets: &[wgpu::ColorTargetState {
|
||||||
format: wgpu::TextureFormat::Bgra8UnormSrgb,
|
format: wgpu::TextureFormat::Bgra8UnormSrgb,
|
||||||
|
|
|
@ -27,8 +27,7 @@ impl ScalingRenderer {
|
||||||
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("../shaders/scale.wgsl"))),
|
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("../shaders/scale.wgsl"))),
|
||||||
flags: wgpu::ShaderFlags::VALIDATION,
|
flags: wgpu::ShaderFlags::VALIDATION,
|
||||||
};
|
};
|
||||||
let vs_module = device.create_shader_module(&shader);
|
let module = device.create_shader_module(&shader);
|
||||||
let fs_module = device.create_shader_module(&shader);
|
|
||||||
|
|
||||||
// Create a texture sampler with nearest neighbor
|
// Create a texture sampler with nearest neighbor
|
||||||
let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
|
let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
|
||||||
|
@ -126,7 +125,7 @@ impl ScalingRenderer {
|
||||||
label: Some("pixels_scaling_renderer_pipeline"),
|
label: Some("pixels_scaling_renderer_pipeline"),
|
||||||
layout: Some(&pipeline_layout),
|
layout: Some(&pipeline_layout),
|
||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &vs_module,
|
module: &module,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
},
|
},
|
||||||
|
@ -134,7 +133,7 @@ impl ScalingRenderer {
|
||||||
depth_stencil: None,
|
depth_stencil: None,
|
||||||
multisample: wgpu::MultisampleState::default(),
|
multisample: wgpu::MultisampleState::default(),
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &fs_module,
|
module: &module,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
targets: &[wgpu::ColorTargetState {
|
targets: &[wgpu::ColorTargetState {
|
||||||
format: render_texture_format,
|
format: render_texture_format,
|
||||||
|
|
Loading…
Reference in a new issue