[wgpu 0.7] Update triangle/msaa.rs

Notes:
- not sure if `filtering sampler` should be used, so for now it is not used
.
This commit is contained in:
Poly 2021-02-03 20:05:37 +01:00
parent 98d108d2b7
commit 5f935c34fd
1 changed files with 40 additions and 34 deletions

View File

@ -32,7 +32,10 @@ impl Blit {
entries: &[wgpu::BindGroupLayoutEntry { entries: &[wgpu::BindGroupLayoutEntry {
binding: 0, binding: 0,
visibility: wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Sampler { comparison: false }, ty: wgpu::BindingType::Sampler {
comparison: false,
filtering: true,
},
count: None, count: None,
}], }],
}); });
@ -53,9 +56,11 @@ impl Blit {
entries: &[wgpu::BindGroupLayoutEntry { entries: &[wgpu::BindGroupLayoutEntry {
binding: 0, binding: 0,
visibility: wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::SampledTexture { ty: wgpu::BindingType::Texture {
dimension: wgpu::TextureViewDimension::D2, sample_type: wgpu::TextureSampleType::Float {
component_type: wgpu::TextureComponentType::Float, filterable: true,
},
view_dimension: wgpu::TextureViewDimension::D2,
multisampled: false, multisampled: false,
}, },
count: None, count: None,
@ -69,11 +74,11 @@ impl Blit {
bind_group_layouts: &[&constant_layout, &texture_layout], bind_group_layouts: &[&constant_layout, &texture_layout],
}); });
let vs_module = device.create_shader_module(wgpu::include_spirv!( let vs_module = device.create_shader_module(&wgpu::include_spirv!(
"../shader/blit.vert.spv" "../shader/blit.vert.spv"
)); ));
let fs_module = device.create_shader_module(wgpu::include_spirv!( let fs_module = device.create_shader_module(&wgpu::include_spirv!(
"../shader/blit.frag.spv" "../shader/blit.frag.spv"
)); ));
@ -81,42 +86,42 @@ impl Blit {
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some("iced_wgpu::triangle::msaa pipeline"), label: Some("iced_wgpu::triangle::msaa pipeline"),
layout: Some(&layout), layout: Some(&layout),
vertex_stage: wgpu::ProgrammableStageDescriptor { vertex: wgpu::VertexState {
module: &vs_module, module: &vs_module,
entry_point: "main", entry_point: "main",
buffers: &[],
}, },
fragment_stage: Some(wgpu::ProgrammableStageDescriptor { fragment: Some(wgpu::FragmentState {
module: &fs_module, module: &fs_module,
entry_point: "main", entry_point: "main",
targets: &[wgpu::ColorTargetState {
format,
color_blend: wgpu::BlendState {
src_factor: wgpu::BlendFactor::SrcAlpha,
dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha,
operation: wgpu::BlendOperation::Add,
},
alpha_blend: wgpu::BlendState {
src_factor: wgpu::BlendFactor::One,
dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha,
operation: wgpu::BlendOperation::Add,
},
write_mask: wgpu::ColorWrite::ALL,
}],
}), }),
rasterization_state: Some(wgpu::RasterizationStateDescriptor { primitive: wgpu::PrimitiveState {
topology: wgpu::PrimitiveTopology::TriangleList,
front_face: wgpu::FrontFace::Cw, front_face: wgpu::FrontFace::Cw,
cull_mode: wgpu::CullMode::None, cull_mode: wgpu::CullMode::None,
..Default::default() ..Default::default()
}),
primitive_topology: wgpu::PrimitiveTopology::TriangleList,
color_states: &[wgpu::ColorStateDescriptor {
format,
color_blend: wgpu::BlendDescriptor {
src_factor: wgpu::BlendFactor::SrcAlpha,
dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha,
operation: wgpu::BlendOperation::Add,
},
alpha_blend: wgpu::BlendDescriptor {
src_factor: wgpu::BlendFactor::One,
dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha,
operation: wgpu::BlendOperation::Add,
},
write_mask: wgpu::ColorWrite::ALL,
}],
depth_stencil_state: None,
vertex_state: wgpu::VertexStateDescriptor {
index_format: wgpu::IndexFormat::Uint16,
vertex_buffers: &[],
}, },
sample_count: 1, depth_stencil: None,
sample_mask: !0,
alpha_to_coverage_enabled: false, multisample: wgpu::MultisampleState {
count: 1,
mask: !0,
alpha_to_coverage_enabled: false,
},
}); });
Blit { Blit {
@ -172,6 +177,7 @@ impl Blit {
) { ) {
let mut render_pass = let mut render_pass =
encoder.begin_render_pass(&wgpu::RenderPassDescriptor { encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("iced_wgpu::triangle::msaa Render Pass"),
color_attachments: &[ color_attachments: &[
wgpu::RenderPassColorAttachmentDescriptor { wgpu::RenderPassColorAttachmentDescriptor {
attachment: target, attachment: target,
@ -227,7 +233,7 @@ impl Targets {
sample_count, sample_count,
dimension: wgpu::TextureDimension::D2, dimension: wgpu::TextureDimension::D2,
format, format,
usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT, usage: wgpu::TextureUsage::RENDER_ATTACHMENT,
}); });
let resolve = device.create_texture(&wgpu::TextureDescriptor { let resolve = device.create_texture(&wgpu::TextureDescriptor {
@ -237,7 +243,7 @@ impl Targets {
sample_count: 1, sample_count: 1,
dimension: wgpu::TextureDimension::D2, dimension: wgpu::TextureDimension::D2,
format, format,
usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT usage: wgpu::TextureUsage::RENDER_ATTACHMENT
| wgpu::TextureUsage::SAMPLED, | wgpu::TextureUsage::SAMPLED,
}); });