diff --git a/code/intermediate/tutorial10-lighting/src/main.rs b/code/intermediate/tutorial10-lighting/src/main.rs index 9b141ec5..645de620 100644 --- a/code/intermediate/tutorial10-lighting/src/main.rs +++ b/code/intermediate/tutorial10-lighting/src/main.rs @@ -265,12 +265,12 @@ fn create_render_pipeline( layout: &wgpu::PipelineLayout, color_format: wgpu::TextureFormat, depth_format: Option, - vertex_descs: &[wgpu::VertexBufferLayout], - vs_src: wgpu::ShaderModuleSource, - fs_src: wgpu::ShaderModuleSource, + vertex_layouts: &[wgpu::VertexBufferLayout], + vs_src: wgpu::ShaderModuleDescriptor, + fs_src: wgpu::ShaderModuleDescriptor, ) -> wgpu::RenderPipeline { - let vs_module = device.create_shader_module(vs_src); - let fs_module = device.create_shader_module(fs_src); + let vs_module = device.create_shader_module(&vs_src); + let fs_module = device.create_shader_module(&fs_src); device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { label: Some("Render Pipeline"), @@ -278,18 +278,17 @@ fn create_render_pipeline( vertex: wgpu::VertexState { module: &vs_module, entry_point: "main", + buffers: vertex_layouts, }, fragment: Some(wgpu::FragmentState { module: &fs_module, entry_point: "main", - }), - rasterization_state: Some(wgpu::RasterizationStateDescriptor { - front_face: wgpu::FrontFace::Ccw, - cull_mode: wgpu::CullMode::Back, - depth_bias: 0, - depth_bias_slope_scale: 0.0, - depth_bias_clamp: 0.0, - clamp_depth: false, + targets: &[wgpu::ColorTargetState { + format: color_format, + alpha_blend: wgpu::BlendState::REPLACE, + color_blend: wgpu::BlendState::REPLACE, + write_mask: wgpu::ColorWrite::ALL, + }], }), primitive: wgpu::PrimitiveState { topology: wgpu::PrimitiveTopology::TriangleList, @@ -299,26 +298,19 @@ fn create_render_pipeline( // Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE polygon_mode: wgpu::PolygonMode::Fill, }, - color_states: &[wgpu::ColorStateDescriptor { - format: color_format, - color_blend: wgpu::BlendDescriptor::REPLACE, - alpha_blend: wgpu::BlendDescriptor::REPLACE, - write_mask: wgpu::ColorWrite::ALL, - }], depth_stencil: depth_format.map(|format| wgpu::DepthStencilState { format, depth_write_enabled: true, depth_compare: wgpu::CompareFunction::Less, stencil: wgpu::StencilState::default(), - bias: wgpu::DepthBiasState::default(), - // Setting this to true requires Features::DEPTH_CLAMPING - clamp_depth: false, }), - sample_count: 1, - sample_mask: !0, - alpha_to_coverage_enabled: false, - vertex_state: wgpu::VertexStateDescriptor { - index_format: wgpu::IndexFormat::Uint32, - vertex_buffers: vertex_descs, + bias: wgpu::DepthBiasState::default(), + // Setting this to true requires Features::DEPTH_CLAMPING + clamp_depth: false, + }), + multisample: wgpu::MultisampleState { + count: 1, + mask: !0, + alpha_to_coverage_enabled: false, }, }) } @@ -504,7 +496,7 @@ impl State { layout: &light_bind_group_layout, entries: &[wgpu::BindGroupEntry { binding: 0, - resource: wgpu::BindingResource::Buffer(light_buffer.slice(..)), + resource: light_buffer.as_entire_binding(), }], label: None, }); diff --git a/code/intermediate/tutorial10-lighting/src/shader.vert b/code/intermediate/tutorial10-lighting/src/shader.vert index 59454dab..9de05024 100644 --- a/code/intermediate/tutorial10-lighting/src/shader.vert +++ b/code/intermediate/tutorial10-lighting/src/shader.vert @@ -20,6 +20,12 @@ layout(location=7) in vec4 model_matrix_2; layout(location=8) in vec4 model_matrix_3; void main() { + mat4 model_matrix = mat4( + model_matrix_0, + model_matrix_1, + model_matrix_2, + model_matrix_3 + ); v_tex_coords = a_tex_coords; mat3 normal_matrix = mat3(transpose(inverse(model_matrix))); v_normal = normal_matrix * a_normal; diff --git a/code/intermediate/tutorial10-lighting/src/shader.vert.spv b/code/intermediate/tutorial10-lighting/src/shader.vert.spv index dd73c30c..cf6af917 100644 Binary files a/code/intermediate/tutorial10-lighting/src/shader.vert.spv and b/code/intermediate/tutorial10-lighting/src/shader.vert.spv differ diff --git a/code/intermediate/tutorial11-normals/src/main.rs b/code/intermediate/tutorial11-normals/src/main.rs index 1865c03c..41055067 100644 --- a/code/intermediate/tutorial11-normals/src/main.rs +++ b/code/intermediate/tutorial11-normals/src/main.rs @@ -262,12 +262,12 @@ fn create_render_pipeline( layout: &wgpu::PipelineLayout, color_format: wgpu::TextureFormat, depth_format: Option, - vertex_descs: &[wgpu::VertexBufferLayout], - vs_src: wgpu::ShaderModuleSource, - fs_src: wgpu::ShaderModuleSource, + vertex_layouts: &[wgpu::VertexBufferLayout], + vs_src: wgpu::ShaderModuleDescriptor, + fs_src: wgpu::ShaderModuleDescriptor, ) -> wgpu::RenderPipeline { - let vs_module = device.create_shader_module(vs_src); - let fs_module = device.create_shader_module(fs_src); + let vs_module = device.create_shader_module(&vs_src); + let fs_module = device.create_shader_module(&fs_src); device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { label: Some("Render Pipeline"), @@ -275,18 +275,17 @@ fn create_render_pipeline( vertex: wgpu::VertexState { module: &vs_module, entry_point: "main", + buffers: vertex_layouts, }, fragment: Some(wgpu::FragmentState { module: &fs_module, entry_point: "main", - }), - rasterization_state: Some(wgpu::RasterizationStateDescriptor { - front_face: wgpu::FrontFace::Ccw, - cull_mode: wgpu::CullMode::Back, - depth_bias: 0, - depth_bias_slope_scale: 0.0, - depth_bias_clamp: 0.0, - clamp_depth: false, + targets: &[wgpu::ColorTargetState { + format: color_format, + alpha_blend: wgpu::BlendState::REPLACE, + color_blend: wgpu::BlendState::REPLACE, + write_mask: wgpu::ColorWrite::ALL, + }], }), primitive: wgpu::PrimitiveState { topology: wgpu::PrimitiveTopology::TriangleList, @@ -296,26 +295,19 @@ fn create_render_pipeline( // Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE polygon_mode: wgpu::PolygonMode::Fill, }, - color_states: &[wgpu::ColorStateDescriptor { - format: color_format, - color_blend: wgpu::BlendDescriptor::REPLACE, - alpha_blend: wgpu::BlendDescriptor::REPLACE, - write_mask: wgpu::ColorWrite::ALL, - }], depth_stencil: depth_format.map(|format| wgpu::DepthStencilState { format, depth_write_enabled: true, depth_compare: wgpu::CompareFunction::Less, stencil: wgpu::StencilState::default(), - bias: wgpu::DepthBiasState::default(), - // Setting this to true requires Features::DEPTH_CLAMPING - clamp_depth: false, }), - sample_count: 1, - sample_mask: !0, - alpha_to_coverage_enabled: false, - vertex_state: wgpu::VertexStateDescriptor { - index_format: wgpu::IndexFormat::Uint32, - vertex_buffers: vertex_descs, + bias: wgpu::DepthBiasState::default(), + // Setting this to true requires Features::DEPTH_CLAMPING + clamp_depth: false, + }), + multisample: wgpu::MultisampleState { + count: 1, + mask: !0, + alpha_to_coverage_enabled: false, }, }) } @@ -363,10 +355,10 @@ impl State { wgpu::BindGroupLayoutEntry { binding: 0, visibility: wgpu::ShaderStage::FRAGMENT, - ty: wgpu::BindingType::SampledTexture { + ty: wgpu::BindingType::Texture { multisampled: false, - component_type: wgpu::TextureComponentType::Float, - dimension: wgpu::TextureViewDimension::D2, + sample_type: wgpu::TextureSampleType::Float { filterable: true }, + view_dimension: wgpu::TextureViewDimension::D2, }, count: None, }, @@ -383,10 +375,10 @@ impl State { wgpu::BindGroupLayoutEntry { binding: 2, visibility: wgpu::ShaderStage::FRAGMENT, - ty: wgpu::BindingType::SampledTexture { + ty: wgpu::BindingType::Texture { multisampled: false, - component_type: wgpu::TextureComponentType::Float, - dimension: wgpu::TextureViewDimension::D2, + sample_type: wgpu::TextureSampleType::Float { filterable: true }, + view_dimension: wgpu::TextureViewDimension::D2, }, count: None, }, @@ -521,7 +513,7 @@ impl State { layout: &light_bind_group_layout, entries: &[wgpu::BindGroupEntry { binding: 0, - resource: wgpu::BindingResource::Buffer(light_buffer.slice(..)), + resource: light_buffer.as_entire_binding(), }], label: None, }); diff --git a/code/intermediate/tutorial11-normals/src/shader-wrong.vert b/code/intermediate/tutorial11-normals/src/shader-wrong.vert index 2f987f9f..5d4a0c40 100644 --- a/code/intermediate/tutorial11-normals/src/shader-wrong.vert +++ b/code/intermediate/tutorial11-normals/src/shader-wrong.vert @@ -29,6 +29,12 @@ layout(set=2, binding=0) uniform Light { }; void main() { + mat4 model_matrix = mat4( + model_matrix_0, + model_matrix_1, + model_matrix_2, + model_matrix_3 + ); v_tex_coords = a_tex_coords; mat3 normal_matrix = mat3(transpose(inverse(model_matrix))); diff --git a/code/intermediate/tutorial11-normals/src/shader-wrong.vert.spv b/code/intermediate/tutorial11-normals/src/shader-wrong.vert.spv index af0f7e5c..f4200a95 100644 Binary files a/code/intermediate/tutorial11-normals/src/shader-wrong.vert.spv and b/code/intermediate/tutorial11-normals/src/shader-wrong.vert.spv differ diff --git a/code/intermediate/tutorial11-normals/src/shader.vert b/code/intermediate/tutorial11-normals/src/shader.vert index c3d56103..511cd0b5 100644 --- a/code/intermediate/tutorial11-normals/src/shader.vert +++ b/code/intermediate/tutorial11-normals/src/shader.vert @@ -29,6 +29,12 @@ layout(set=2, binding=0) uniform Light { }; void main() { + mat4 model_matrix = mat4( + model_matrix_0, + model_matrix_1, + model_matrix_2, + model_matrix_3 + ); v_tex_coords = a_tex_coords; mat3 normal_matrix = mat3(transpose(inverse(model_matrix))); diff --git a/code/intermediate/tutorial11-normals/src/shader.vert.spv b/code/intermediate/tutorial11-normals/src/shader.vert.spv index e474927f..84e6c50d 100644 Binary files a/code/intermediate/tutorial11-normals/src/shader.vert.spv and b/code/intermediate/tutorial11-normals/src/shader.vert.spv differ diff --git a/code/intermediate/tutorial11-normals/src/world_space.vert b/code/intermediate/tutorial11-normals/src/world_space.vert index 6e99b776..61296b9f 100644 --- a/code/intermediate/tutorial11-normals/src/world_space.vert +++ b/code/intermediate/tutorial11-normals/src/world_space.vert @@ -23,6 +23,12 @@ layout(location=7) in vec4 model_matrix_2; layout(location=8) in vec4 model_matrix_3; void main() { + mat4 model_matrix = mat4( + model_matrix_0, + model_matrix_1, + model_matrix_2, + model_matrix_3 + ); v_tex_coords = a_tex_coords; mat3 normal_matrix = mat3(transpose(inverse(model_matrix))); diff --git a/code/intermediate/tutorial11-normals/src/world_space.vert.spv b/code/intermediate/tutorial11-normals/src/world_space.vert.spv index 2f631da6..566477c0 100644 Binary files a/code/intermediate/tutorial11-normals/src/world_space.vert.spv and b/code/intermediate/tutorial11-normals/src/world_space.vert.spv differ diff --git a/code/intermediate/tutorial12-camera/src/main.rs b/code/intermediate/tutorial12-camera/src/main.rs index 1d0c326b..19cb6127 100644 --- a/code/intermediate/tutorial12-camera/src/main.rs +++ b/code/intermediate/tutorial12-camera/src/main.rs @@ -3,7 +3,6 @@ use std::iter; use cgmath::prelude::*; use wgpu::util::DeviceExt; use winit::{ - dpi::PhysicalPosition, event::*, event_loop::{ControlFlow, EventLoop}, window::Window, @@ -143,12 +142,12 @@ fn create_render_pipeline( layout: &wgpu::PipelineLayout, color_format: wgpu::TextureFormat, depth_format: Option, - vertex_descs: &[wgpu::VertexBufferLayout], - vs_src: wgpu::ShaderModuleSource, - fs_src: wgpu::ShaderModuleSource, + vertex_layouts: &[wgpu::VertexBufferLayout], + vs_src: wgpu::ShaderModuleDescriptor, + fs_src: wgpu::ShaderModuleDescriptor, ) -> wgpu::RenderPipeline { - let vs_module = device.create_shader_module(vs_src); - let fs_module = device.create_shader_module(fs_src); + let vs_module = device.create_shader_module(&vs_src); + let fs_module = device.create_shader_module(&fs_src); device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { label: Some("Render Pipeline"), @@ -156,18 +155,17 @@ fn create_render_pipeline( vertex: wgpu::VertexState { module: &vs_module, entry_point: "main", + buffers: vertex_layouts, }, fragment: Some(wgpu::FragmentState { module: &fs_module, entry_point: "main", - }), - rasterization_state: Some(wgpu::RasterizationStateDescriptor { - front_face: wgpu::FrontFace::Ccw, - cull_mode: wgpu::CullMode::Back, - depth_bias: 0, - depth_bias_slope_scale: 0.0, - depth_bias_clamp: 0.0, - clamp_depth: false, + targets: &[wgpu::ColorTargetState { + format: color_format, + alpha_blend: wgpu::BlendState::REPLACE, + color_blend: wgpu::BlendState::REPLACE, + write_mask: wgpu::ColorWrite::ALL, + }], }), primitive: wgpu::PrimitiveState { topology: wgpu::PrimitiveTopology::TriangleList, @@ -177,26 +175,19 @@ fn create_render_pipeline( // Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE polygon_mode: wgpu::PolygonMode::Fill, }, - color_states: &[wgpu::ColorStateDescriptor { - format: color_format, - color_blend: wgpu::BlendDescriptor::REPLACE, - alpha_blend: wgpu::BlendDescriptor::REPLACE, - write_mask: wgpu::ColorWrite::ALL, - }], depth_stencil: depth_format.map(|format| wgpu::DepthStencilState { format, depth_write_enabled: true, depth_compare: wgpu::CompareFunction::Less, stencil: wgpu::StencilState::default(), - bias: wgpu::DepthBiasState::default(), - // Setting this to true requires Features::DEPTH_CLAMPING - clamp_depth: false, }), - sample_count: 1, - sample_mask: !0, - alpha_to_coverage_enabled: false, - vertex_state: wgpu::VertexStateDescriptor { - index_format: wgpu::IndexFormat::Uint32, - vertex_buffers: vertex_descs, + bias: wgpu::DepthBiasState::default(), + // Setting this to true requires Features::DEPTH_CLAMPING + clamp_depth: false, + }), + multisample: wgpu::MultisampleState { + count: 1, + mask: !0, + alpha_to_coverage_enabled: false, }, }) } @@ -244,10 +235,10 @@ impl State { wgpu::BindGroupLayoutEntry { binding: 0, visibility: wgpu::ShaderStage::FRAGMENT, - ty: wgpu::BindingType::SampledTexture { + ty: wgpu::BindingType::Texture { multisampled: false, - component_type: wgpu::TextureComponentType::Float, - dimension: wgpu::TextureViewDimension::D2, + sample_type: wgpu::TextureSampleType::Float { filterable: true }, + view_dimension: wgpu::TextureViewDimension::D2, }, count: None, }, @@ -264,10 +255,10 @@ impl State { wgpu::BindGroupLayoutEntry { binding: 2, visibility: wgpu::ShaderStage::FRAGMENT, - ty: wgpu::BindingType::SampledTexture { + ty: wgpu::BindingType::Texture { multisampled: false, - component_type: wgpu::TextureComponentType::Float, - dimension: wgpu::TextureViewDimension::D2, + sample_type: wgpu::TextureSampleType::Float { filterable: true }, + view_dimension: wgpu::TextureViewDimension::D2, }, count: None, }, @@ -398,7 +389,7 @@ impl State { layout: &light_bind_group_layout, entries: &[wgpu::BindGroupEntry { binding: 0, - resource: wgpu::BindingResource::Buffer(light_buffer.slice(..)), + resource: light_buffer.as_entire_binding(), }], label: None, }); diff --git a/code/intermediate/tutorial12-camera/src/shader.vert b/code/intermediate/tutorial12-camera/src/shader.vert index c3d56103..511cd0b5 100644 --- a/code/intermediate/tutorial12-camera/src/shader.vert +++ b/code/intermediate/tutorial12-camera/src/shader.vert @@ -29,6 +29,12 @@ layout(set=2, binding=0) uniform Light { }; void main() { + mat4 model_matrix = mat4( + model_matrix_0, + model_matrix_1, + model_matrix_2, + model_matrix_3 + ); v_tex_coords = a_tex_coords; mat3 normal_matrix = mat3(transpose(inverse(model_matrix))); diff --git a/code/intermediate/tutorial12-camera/src/shader.vert.spv b/code/intermediate/tutorial12-camera/src/shader.vert.spv index e474927f..84e6c50d 100644 Binary files a/code/intermediate/tutorial12-camera/src/shader.vert.spv and b/code/intermediate/tutorial12-camera/src/shader.vert.spv differ diff --git a/code/intermediate/tutorial13-threading/src/main.rs b/code/intermediate/tutorial13-threading/src/main.rs index c7db1e4e..251ab93e 100644 --- a/code/intermediate/tutorial13-threading/src/main.rs +++ b/code/intermediate/tutorial13-threading/src/main.rs @@ -3,7 +3,6 @@ use rayon::prelude::*; use std::iter; use wgpu::util::DeviceExt; use winit::{ - dpi::PhysicalPosition, event::*, event_loop::{ControlFlow, EventLoop}, window::Window, @@ -134,7 +133,6 @@ struct State { light_render_pipeline: wgpu::RenderPipeline, #[allow(dead_code)] debug_material: model::Material, - last_mouse_pos: PhysicalPosition, mouse_pressed: bool, } @@ -143,12 +141,12 @@ fn create_render_pipeline( layout: &wgpu::PipelineLayout, color_format: wgpu::TextureFormat, depth_format: Option, - vertex_descs: &[wgpu::VertexBufferLayout], - vs_src: wgpu::ShaderModuleSource, - fs_src: wgpu::ShaderModuleSource, + vertex_layouts: &[wgpu::VertexBufferLayout], + vs_src: wgpu::ShaderModuleDescriptor, + fs_src: wgpu::ShaderModuleDescriptor, ) -> wgpu::RenderPipeline { - let vs_module = device.create_shader_module(vs_src); - let fs_module = device.create_shader_module(fs_src); + let vs_module = device.create_shader_module(&vs_src); + let fs_module = device.create_shader_module(&fs_src); device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { label: Some("Render Pipeline"), @@ -156,18 +154,17 @@ fn create_render_pipeline( vertex: wgpu::VertexState { module: &vs_module, entry_point: "main", + buffers: vertex_layouts, }, fragment: Some(wgpu::FragmentState { module: &fs_module, entry_point: "main", - }), - rasterization_state: Some(wgpu::RasterizationStateDescriptor { - front_face: wgpu::FrontFace::Ccw, - cull_mode: wgpu::CullMode::Back, - depth_bias: 0, - depth_bias_slope_scale: 0.0, - depth_bias_clamp: 0.0, - clamp_depth: false, + targets: &[wgpu::ColorTargetState { + format: color_format, + alpha_blend: wgpu::BlendState::REPLACE, + color_blend: wgpu::BlendState::REPLACE, + write_mask: wgpu::ColorWrite::ALL, + }], }), primitive: wgpu::PrimitiveState { topology: wgpu::PrimitiveTopology::TriangleList, @@ -177,26 +174,19 @@ fn create_render_pipeline( // Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE polygon_mode: wgpu::PolygonMode::Fill, }, - color_states: &[wgpu::ColorStateDescriptor { - format: color_format, - color_blend: wgpu::BlendDescriptor::REPLACE, - alpha_blend: wgpu::BlendDescriptor::REPLACE, - write_mask: wgpu::ColorWrite::ALL, - }], depth_stencil: depth_format.map(|format| wgpu::DepthStencilState { format, depth_write_enabled: true, depth_compare: wgpu::CompareFunction::Less, stencil: wgpu::StencilState::default(), - bias: wgpu::DepthBiasState::default(), - // Setting this to true requires Features::DEPTH_CLAMPING - clamp_depth: false, }), - sample_count: 1, - sample_mask: !0, - alpha_to_coverage_enabled: false, - vertex_state: wgpu::VertexStateDescriptor { - index_format: wgpu::IndexFormat::Uint32, - vertex_buffers: vertex_descs, + bias: wgpu::DepthBiasState::default(), + // Setting this to true requires Features::DEPTH_CLAMPING + clamp_depth: false, + }), + multisample: wgpu::MultisampleState { + count: 1, + mask: !0, + alpha_to_coverage_enabled: false, }, }) } @@ -244,10 +234,10 @@ impl State { wgpu::BindGroupLayoutEntry { binding: 0, visibility: wgpu::ShaderStage::FRAGMENT, - ty: wgpu::BindingType::SampledTexture { + ty: wgpu::BindingType::Texture { multisampled: false, - component_type: wgpu::TextureComponentType::Float, - dimension: wgpu::TextureViewDimension::D2, + sample_type: wgpu::TextureSampleType::Float { filterable: true }, + view_dimension: wgpu::TextureViewDimension::D2, }, count: None, }, @@ -264,10 +254,10 @@ impl State { wgpu::BindGroupLayoutEntry { binding: 2, visibility: wgpu::ShaderStage::FRAGMENT, - ty: wgpu::BindingType::SampledTexture { + ty: wgpu::BindingType::Texture { multisampled: false, - component_type: wgpu::TextureComponentType::Float, - dimension: wgpu::TextureViewDimension::D2, + sample_type: wgpu::TextureSampleType::Float { filterable: true }, + view_dimension: wgpu::TextureViewDimension::D2, }, count: None, }, @@ -398,7 +388,7 @@ impl State { layout: &light_bind_group_layout, entries: &[wgpu::BindGroupEntry { binding: 0, - resource: wgpu::BindingResource::Buffer(light_buffer.slice(..)), + resource: light_buffer.as_entire_binding(), }], label: None, }); @@ -499,7 +489,6 @@ impl State { light_render_pipeline, #[allow(dead_code)] debug_material, - last_mouse_pos: (0.0, 0.0).into(), mouse_pressed: false, } } diff --git a/code/intermediate/tutorial13-threading/src/shader.vert b/code/intermediate/tutorial13-threading/src/shader.vert index c3d56103..511cd0b5 100644 --- a/code/intermediate/tutorial13-threading/src/shader.vert +++ b/code/intermediate/tutorial13-threading/src/shader.vert @@ -29,6 +29,12 @@ layout(set=2, binding=0) uniform Light { }; void main() { + mat4 model_matrix = mat4( + model_matrix_0, + model_matrix_1, + model_matrix_2, + model_matrix_3 + ); v_tex_coords = a_tex_coords; mat3 normal_matrix = mat3(transpose(inverse(model_matrix))); diff --git a/code/intermediate/tutorial13-threading/src/shader.vert.spv b/code/intermediate/tutorial13-threading/src/shader.vert.spv index e474927f..84e6c50d 100644 Binary files a/code/intermediate/tutorial13-threading/src/shader.vert.spv and b/code/intermediate/tutorial13-threading/src/shader.vert.spv differ diff --git a/code/research/performance/src/main.rs b/code/research/performance/src/main.rs index dc137110..c2bdb418 100644 --- a/code/research/performance/src/main.rs +++ b/code/research/performance/src/main.rs @@ -260,10 +260,10 @@ impl State { wgpu::BindGroupLayoutEntry { binding: 0, visibility: wgpu::ShaderStage::FRAGMENT, - ty: wgpu::BindingType::SampledTexture { + ty: wgpu::BindingType::Texture { multisampled: false, - component_type: wgpu::TextureComponentType::Float, - dimension: wgpu::TextureViewDimension::D2, + sample_type: wgpu::TextureSampleType::Float { filterable: true }, + view_dimension: wgpu::TextureViewDimension::D2, }, }, wgpu::BindGroupLayoutEntry { @@ -278,10 +278,10 @@ impl State { wgpu::BindGroupLayoutEntry { binding: 2, visibility: wgpu::ShaderStage::FRAGMENT, - ty: wgpu::BindingType::SampledTexture { + ty: wgpu::BindingType::Texture { multisampled: false, - component_type: wgpu::TextureComponentType::Float, - dimension: wgpu::TextureViewDimension::D2, + sample_type: wgpu::TextureSampleType::Float { filterable: true }, + view_dimension: wgpu::TextureViewDimension::D2, }, }, wgpu::BindGroupLayoutEntry { diff --git a/code/research/performance/src/texture.rs b/code/research/performance/src/texture.rs index 93dab4d8..b0f4547c 100644 --- a/code/research/performance/src/texture.rs +++ b/code/research/performance/src/texture.rs @@ -198,7 +198,7 @@ impl Texture { visibility: wgpu::ShaderStage::FRAGMENT, ty: wgpu::BindingType::SampledTexture { multisampled: false, - component_type: wgpu::TextureComponentType::Float, + component_type: wgpu::TextureSampleType::Float { filterable: true }, dimension: wgpu::TextureViewDimension::D2, }, }, diff --git a/code/showcase/compute/src/main.rs b/code/showcase/compute/src/main.rs index d270f27e..e4e521ef 100644 --- a/code/showcase/compute/src/main.rs +++ b/code/showcase/compute/src/main.rs @@ -184,10 +184,10 @@ impl State { wgpu::BindGroupLayoutEntry { binding: 0, visibility: wgpu::ShaderStage::FRAGMENT, - ty: wgpu::BindingType::SampledTexture { + ty: wgpu::BindingType::Texture { multisampled: false, - component_type: wgpu::TextureComponentType::Float, - dimension: wgpu::TextureViewDimension::D2, + sample_type: wgpu::TextureSampleType::Float { filterable: true }, + view_dimension: wgpu::TextureViewDimension::D2, }, count: None, }, @@ -204,10 +204,10 @@ impl State { wgpu::BindGroupLayoutEntry { binding: 2, visibility: wgpu::ShaderStage::FRAGMENT, - ty: wgpu::BindingType::SampledTexture { + ty: wgpu::BindingType::Texture { multisampled: false, - component_type: wgpu::TextureComponentType::Float, - dimension: wgpu::TextureViewDimension::D2, + sample_type: wgpu::TextureSampleType::Float { filterable: true }, + view_dimension: wgpu::TextureViewDimension::D2, }, count: None, }, @@ -342,7 +342,7 @@ impl State { layout: &light_bind_group_layout, entries: &[wgpu::BindGroupEntry { binding: 0, - resource: wgpu::BindingResource::Buffer(light_buffer.slice(..)), + resource: light_buffer.as_entire_binding(), }], label: None, }); diff --git a/code/showcase/compute/src/pipeline.rs b/code/showcase/compute/src/pipeline.rs index 586e107d..65514909 100644 --- a/code/showcase/compute/src/pipeline.rs +++ b/code/showcase/compute/src/pipeline.rs @@ -39,12 +39,12 @@ pub fn create_render_pipeline( layout: &wgpu::PipelineLayout, color_format: wgpu::TextureFormat, depth_format: Option, - vertex_descs: &[wgpu::VertexBufferLayout], - vs_src: wgpu::ShaderModuleSource, - fs_src: wgpu::ShaderModuleSource, + vertex_layouts: &[wgpu::VertexBufferLayout], + vs_src: wgpu::ShaderModuleDescriptor, + fs_src: wgpu::ShaderModuleDescriptor, ) -> wgpu::RenderPipeline { - let vs_module = device.create_shader_module(vs_src); - let fs_module = device.create_shader_module(fs_src); + let vs_module = device.create_shader_module(&vs_src); + let fs_module = device.create_shader_module(&fs_src); device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { label: Some("Render Pipeline"), @@ -92,7 +92,7 @@ pub fn create_render_pipeline( alpha_to_coverage_enabled: false, vertex_state: wgpu::VertexStateDescriptor { index_format: wgpu::IndexFormat::Uint32, - vertex_buffers: vertex_descs, + vertex_buffers: vertex_layouts, }, }) } @@ -100,7 +100,7 @@ pub fn create_render_pipeline( pub fn create_compute_pipeline( device: &wgpu::Device, bind_group_layouts: &[&wgpu::BindGroupLayout], - shader_src: wgpu::ShaderModuleSource, + shader_src: wgpu::ShaderModuleDescriptor, label: Option<&str>, ) -> wgpu::ComputePipeline { let layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { diff --git a/code/showcase/framework/src/pipeline.rs b/code/showcase/framework/src/pipeline.rs index 3d0e6369..90e4f3ba 100644 --- a/code/showcase/framework/src/pipeline.rs +++ b/code/showcase/framework/src/pipeline.rs @@ -3,8 +3,8 @@ use anyhow::*; pub struct RenderPipelineBuilder<'a> { layout: Option<&'a wgpu::PipelineLayout>, - vertex_shader: Option>, - fragment_shader: Option>, + vertex_shader: Option>, + fragment_shader: Option>, front_face: wgpu::FrontFace, cull_mode: wgpu::CullMode, depth_bias: i32, @@ -51,12 +51,12 @@ impl<'a> RenderPipelineBuilder<'a> { self } - pub fn vertex_shader(&mut self, src: wgpu::ShaderModuleSource<'a>) -> &mut Self { + pub fn vertex_shader(&mut self, src: wgpu::ShaderModuleDescriptor<'a>) -> &mut Self { self.vertex_shader = Some(src); self } - pub fn fragment_shader(&mut self, src: wgpu::ShaderModuleSource<'a>) -> &mut Self { + pub fn fragment_shader(&mut self, src: wgpu::ShaderModuleDescriptor<'a>) -> &mut Self { self.fragment_shader = Some(src); self } @@ -242,7 +242,7 @@ impl<'a> RenderPipelineBuilder<'a> { fn create_shader_module( device: &wgpu::Device, - spirv: wgpu::ShaderModuleSource, + spirv: wgpu::ShaderModuleDescriptor, ) -> wgpu::ShaderModule { device.create_shader_module(spirv) } diff --git a/code/showcase/framework/src/shader_canvas.rs b/code/showcase/framework/src/shader_canvas.rs index 1fa3db8f..d16e5c94 100644 --- a/code/showcase/framework/src/shader_canvas.rs +++ b/code/showcase/framework/src/shader_canvas.rs @@ -100,8 +100,8 @@ pub struct ShaderCanvasBuilder<'a> { clear_color: [f32; 4], label: Option<&'a str>, display_format: Option, - frag_code: Option>, - vert_code: Option>, + frag_code: Option>, + vert_code: Option>, } impl<'a> ShaderCanvasBuilder<'a> { @@ -131,12 +131,12 @@ impl<'a> ShaderCanvasBuilder<'a> { self.canvas_size(sc_desc.width as f32, sc_desc.height as f32) } - pub fn fragment_shader(&mut self, code: wgpu::ShaderModuleSource<'a>) -> &mut Self { + pub fn fragment_shader(&mut self, code: wgpu::ShaderModuleDescriptor<'a>) -> &mut Self { self.frag_code = Some(code); self } - pub fn vertex_shader(&mut self, code: wgpu::ShaderModuleSource<'a>) -> &mut Self { + pub fn vertex_shader(&mut self, code: wgpu::ShaderModuleDescriptor<'a>) -> &mut Self { self.vert_code = Some(code); self } diff --git a/code/showcase/gifs/src/main.rs b/code/showcase/gifs/src/main.rs index 39e2c155..547d9202 100644 --- a/code/showcase/gifs/src/main.rs +++ b/code/showcase/gifs/src/main.rs @@ -166,8 +166,8 @@ fn create_render_pipeline( ) -> wgpu::RenderPipeline { let vs_src = wgpu::include_spirv!("shader.vert.spv"); let fs_src = wgpu::include_spirv!("shader.frag.spv"); - let vs_module = device.create_shader_module(vs_src); - let fs_module = device.create_shader_module(fs_src); + let vs_module = device.create_shader_module(&vs_src); + let fs_module = device.create_shader_module(&fs_src); let render_pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { label: Some("Render Pipeline Layout"), diff --git a/code/showcase/pong/src/render/mod.rs b/code/showcase/pong/src/render/mod.rs index 6e9bff6d..ade77d0b 100644 --- a/code/showcase/pong/src/render/mod.rs +++ b/code/showcase/pong/src/render/mod.rs @@ -231,12 +231,12 @@ fn create_render_pipeline( device: &wgpu::Device, layout: &wgpu::PipelineLayout, color_format: wgpu::TextureFormat, - vertex_descs: &[wgpu::VertexBufferLayout], - vs_src: wgpu::ShaderModuleSource, - fs_src: wgpu::ShaderModuleSource, + vertex_layouts: &[wgpu::VertexBufferLayout], + vs_src: wgpu::ShaderModuleDescriptor, + fs_src: wgpu::ShaderModuleDescriptor, ) -> wgpu::RenderPipeline { - let vs_module = device.create_shader_module(vs_src); - let fs_module = device.create_shader_module(fs_src); + let vs_module = device.create_shader_module(&vs_src); + let fs_module = device.create_shader_module(&fs_src); device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { label: Some("Render Pipeline"), @@ -270,7 +270,7 @@ fn create_render_pipeline( alpha_to_coverage_enabled: false, vertex_state: wgpu::VertexStateDescriptor { index_format: wgpu::IndexFormat::Uint32, - vertex_buffers: vertex_descs, + vertex_buffers: vertex_layouts, }, }) } diff --git a/docs/beginner/tutorial5-textures/README.md b/docs/beginner/tutorial5-textures/README.md index a885e453..73ff8942 100644 --- a/docs/beginner/tutorial5-textures/README.md +++ b/docs/beginner/tutorial5-textures/README.md @@ -172,7 +172,7 @@ let texture_bind_group_layout = device.create_bind_group_layout( ty: wgpu::BindingType::SampledTexture { multisampled: false, dimension: wgpu::TextureViewDimension::D2, - component_type: wgpu::TextureComponentType::Uint, + component_type: wgpu::TextureSampleType::Uint, }, count: None, }, diff --git a/docs/intermediate/tutorial10-lighting/README.md b/docs/intermediate/tutorial10-lighting/README.md index dbfa84b7..aa15372e 100644 --- a/docs/intermediate/tutorial10-lighting/README.md +++ b/docs/intermediate/tutorial10-lighting/README.md @@ -118,7 +118,7 @@ fn create_render_pipeline( layout: &wgpu::PipelineLayout, color_format: wgpu::TextureFormat, depth_format: Option, - vertex_descs: &[wgpu::VertexBufferLayout], + vertex_layouts: &[wgpu::VertexBufferLayout], vs_src: &str, fs_src: &str, ) -> wgpu::RenderPipeline { @@ -181,7 +181,7 @@ fn create_render_pipeline( alpha_to_coverage_enabled: false, vertex_state: wgpu::VertexStateDescriptor { index_format: wgpu::IndexFormat::Uint32, - vertex_buffers: vertex_descs, + vertex_buffers: vertex_layouts, }, }) } diff --git a/docs/intermediate/tutorial11-normals/README.md b/docs/intermediate/tutorial11-normals/README.md index 20e7654d..517fe23b 100644 --- a/docs/intermediate/tutorial11-normals/README.md +++ b/docs/intermediate/tutorial11-normals/README.md @@ -33,7 +33,7 @@ let texture_bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroup visibility: wgpu::ShaderStage::FRAGMENT, ty: wgpu::BindingType::SampledTexture { multisampled: false, - component_type: wgpu::TextureComponentType::Float, + component_type: wgpu::TextureSampleType::Float { filterable: true }, dimension: wgpu::TextureViewDimension::D2, }, count: None,