[wgpu 0.7] Update integration example

This commit is contained in:
Poly 2021-02-03 22:38:45 +01:00
parent 1fb60c5dcb
commit 09a5348740
2 changed files with 24 additions and 24 deletions

View File

@ -36,7 +36,7 @@ pub fn main() {
let (mut device, queue) = futures::executor::block_on(async { let (mut device, queue) = futures::executor::block_on(async {
let adapter = instance let adapter = instance
.request_adapter(&wgpu::RequestAdapterOptions { .request_adapter(&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::Default, power_preference: wgpu::PowerPreference::HighPerformance,
compatible_surface: Some(&surface), compatible_surface: Some(&surface),
}) })
.await .await
@ -45,9 +45,9 @@ pub fn main() {
adapter adapter
.request_device( .request_device(
&wgpu::DeviceDescriptor { &wgpu::DeviceDescriptor {
label: None,
features: wgpu::Features::empty(), features: wgpu::Features::empty(),
limits: wgpu::Limits::default(), limits: wgpu::Limits::default(),
shader_validation: false,
}, },
None, None,
) )
@ -63,7 +63,7 @@ pub fn main() {
device.create_swap_chain( device.create_swap_chain(
&surface, &surface,
&wgpu::SwapChainDescriptor { &wgpu::SwapChainDescriptor {
usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT, usage: wgpu::TextureUsage::RENDER_ATTACHMENT,
format: format, format: format,
width: size.width, width: size.width,
height: size.height, height: size.height,
@ -157,7 +157,7 @@ pub fn main() {
swap_chain = device.create_swap_chain( swap_chain = device.create_swap_chain(
&surface, &surface,
&wgpu::SwapChainDescriptor { &wgpu::SwapChainDescriptor {
usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT, usage: wgpu::TextureUsage::RENDER_ATTACHMENT,
format: format, format: format,
width: size.width, width: size.width,
height: size.height, height: size.height,

View File

@ -19,6 +19,7 @@ impl Scene {
background_color: Color, background_color: Color,
) -> wgpu::RenderPass<'a> { ) -> wgpu::RenderPass<'a> {
encoder.begin_render_pass(&wgpu::RenderPassDescriptor { encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: None,
color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor {
attachment: target, attachment: target,
resolve_target: None, resolve_target: None,
@ -48,10 +49,10 @@ impl Scene {
fn build_pipeline(device: &wgpu::Device) -> wgpu::RenderPipeline { fn build_pipeline(device: &wgpu::Device) -> wgpu::RenderPipeline {
let vs_module = let vs_module =
device.create_shader_module(wgpu::include_spirv!("shader/vert.spv")); device.create_shader_module(&wgpu::include_spirv!("shader/vert.spv"));
let fs_module = let fs_module =
device.create_shader_module(wgpu::include_spirv!("shader/frag.spv")); device.create_shader_module(&wgpu::include_spirv!("shader/frag.spv"));
let pipeline_layout = let pipeline_layout =
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
@ -64,34 +65,33 @@ fn build_pipeline(device: &wgpu::Device) -> wgpu::RenderPipeline {
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: None, label: None,
layout: Some(&pipeline_layout), layout: Some(&pipeline_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: wgpu::TextureFormat::Bgra8UnormSrgb,
color_blend: wgpu::BlendState::REPLACE,
alpha_blend: wgpu::BlendState::REPLACE,
write_mask: wgpu::ColorWrite::ALL,
}],
}), }),
rasterization_state: Some(wgpu::RasterizationStateDescriptor { primitive: wgpu::PrimitiveState {
topology: wgpu::PrimitiveTopology::TriangleList,
front_face: wgpu::FrontFace::Ccw, front_face: wgpu::FrontFace::Ccw,
cull_mode: wgpu::CullMode::None, cull_mode: wgpu::CullMode::None,
..Default::default() ..Default::default()
}),
primitive_topology: wgpu::PrimitiveTopology::TriangleList,
color_states: &[wgpu::ColorStateDescriptor {
format: wgpu::TextureFormat::Bgra8UnormSrgb,
color_blend: wgpu::BlendDescriptor::REPLACE,
alpha_blend: wgpu::BlendDescriptor::REPLACE,
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, multisample: wgpu::MultisampleState {
alpha_to_coverage_enabled: false, count: 1,
mask: !0,
alpha_to_coverage_enabled: false,
},
}); });
pipeline pipeline