diff --git a/examples/wgpu/wgpu_image/wgpu_image.rs b/examples/wgpu/wgpu_image/wgpu_image.rs index 9b26ddf63..fec543abd 100644 --- a/examples/wgpu/wgpu_image/wgpu_image.rs +++ b/examples/wgpu/wgpu_image/wgpu_image.rs @@ -156,7 +156,7 @@ fn create_render_pipeline( wgpu::RenderPipelineBuilder::from_layout(layout, vs_mod) .fragment_shader(fs_mod) .color_format(dst_format) - .add_vertex_buffer::(&wgpu::vertex_attr_array![0 => Float2]) + .add_vertex_buffer::(&wgpu::vertex_attr_array![0 => Float32x2]) .sample_count(sample_count) .primitive_topology(wgpu::PrimitiveTopology::TriangleStrip) .build(device) diff --git a/examples/wgpu/wgpu_image_sequence/wgpu_image_sequence.rs b/examples/wgpu/wgpu_image_sequence/wgpu_image_sequence.rs index 7a54f9753..b9ed608c5 100644 --- a/examples/wgpu/wgpu_image_sequence/wgpu_image_sequence.rs +++ b/examples/wgpu/wgpu_image_sequence/wgpu_image_sequence.rs @@ -146,7 +146,7 @@ fn update(app: &App, model: &mut Model, update: Update) { ); // Update which layer we are viewing based on the playback speed and layer count. - let layer_count = model.texture_array.extent().depth; + let layer_count = model.texture_array.extent().depth_or_array_layers; model.current_layer = fmod( model.current_layer + update.since_last.secs() as f32 * fps, layer_count as f32, @@ -250,7 +250,7 @@ fn create_render_pipeline( wgpu::RenderPipelineBuilder::from_layout(layout, vs_mod) .fragment_shader(fs_mod) .color_format(dst_format) - .add_vertex_buffer::(&wgpu::vertex_attr_array![0 => Float2]) + .add_vertex_buffer::(&wgpu::vertex_attr_array![0 => Float32x2]) .sample_count(sample_count) .primitive_topology(wgpu::PrimitiveTopology::TriangleStrip) .build(device) diff --git a/examples/wgpu/wgpu_instancing/shaders/frag.spv b/examples/wgpu/wgpu_instancing/shaders/frag.spv index 454fd2acc..dffe7a849 100644 Binary files a/examples/wgpu/wgpu_instancing/shaders/frag.spv and b/examples/wgpu/wgpu_instancing/shaders/frag.spv differ diff --git a/examples/wgpu/wgpu_instancing/shaders/shader.vert b/examples/wgpu/wgpu_instancing/shaders/shader.vert index f2a454705..65c199cff 100644 --- a/examples/wgpu/wgpu_instancing/shaders/shader.vert +++ b/examples/wgpu/wgpu_instancing/shaders/shader.vert @@ -8,9 +8,13 @@ layout(location = 0) in vec3 position; layout(location = 1) in vec3 normal; -//locations 3,4,5, are implicitely taken by `instance_transform` -//since one location can contain at max vec4 -layout(location = 2) in mat4 instance_transform; + +// This is the instance data for a 4x4 matrix that we reconstruct in main +// Using a mat4 with location = 2 is not supported. +layout(location = 2) in vec4 model_matrix_0; +layout(location = 3) in vec4 model_matrix_1; +layout(location = 4) in vec4 model_matrix_2; +layout(location = 5) in vec4 model_matrix_3; layout(location = 6) in vec3 instance_color; layout(location = 0) out vec3 v_normal; @@ -22,9 +26,37 @@ layout(set = 0, binding = 0) uniform Data { mat4 proj; } uniforms; +// Temporary manual inverse hack until this is solved +// https://github.com/gfx-rs/naga/issues/893 +mat3x3 custom_inverse(mat3x3 m) { + float determinant = determinant(m); + + float invdet = 1.0 / determinant; + + mat3x3 minv; + minv[0][0] = (m[1][1] * m[2][2] - m[2][1] * m[1][2]) * invdet; + minv[0][1] = (m[0][2] * m[2][1] - m[0][1] * m[2][2]) * invdet; + minv[0][2] = (m[0][1] * m[1][2] - m[0][2] * m[1][1]) * invdet; + minv[1][0] = (m[1][2] * m[2][0] - m[1][0] * m[2][2]) * invdet; + minv[1][1] = (m[0][0] * m[2][2] - m[0][2] * m[2][0]) * invdet; + minv[1][2] = (m[1][0] * m[0][2] - m[0][0] * m[1][2]) * invdet; + minv[2][0] = (m[1][0] * m[2][1] - m[2][0] * m[1][1]) * invdet; + minv[2][1] = (m[2][0] * m[0][1] - m[0][0] * m[2][1]) * invdet; + minv[2][2] = (m[0][0] * m[1][1] - m[1][0] * m[0][1]) * invdet; + + return minv; +} + void main() { + mat4 instance_transform = mat4( + model_matrix_0, + model_matrix_1, + model_matrix_2, + model_matrix_3 + ); + mat4 worldview = uniforms.view * uniforms.world * instance_transform; - v_normal = transpose(inverse(mat3(worldview))) * normal; + v_normal = transpose(custom_inverse(mat3(worldview))) * normal; v_color = instance_color; gl_Position = uniforms.proj * worldview * vec4(position, 1.0); } diff --git a/examples/wgpu/wgpu_instancing/shaders/vert.spv b/examples/wgpu/wgpu_instancing/shaders/vert.spv index 47d27bfcb..5be65c88a 100644 Binary files a/examples/wgpu/wgpu_instancing/shaders/vert.spv and b/examples/wgpu/wgpu_instancing/shaders/vert.spv differ diff --git a/examples/wgpu/wgpu_instancing/wgpu_instancing.rs b/examples/wgpu/wgpu_instancing/wgpu_instancing.rs index 802282976..15273eb02 100644 --- a/examples/wgpu/wgpu_instancing/wgpu_instancing.rs +++ b/examples/wgpu/wgpu_instancing/wgpu_instancing.rs @@ -428,35 +428,35 @@ fn create_render_pipeline( wgpu::RenderPipelineBuilder::from_layout(layout, vs_mod) .fragment_shader(&fs_mod) .color_format(dst_format) - .color_blend(wgpu::BlendState::REPLACE) - .alpha_blend(wgpu::BlendState::REPLACE) - .add_vertex_buffer::(&wgpu::vertex_attr_array![0 => Float3]) - .add_vertex_buffer::(&wgpu::vertex_attr_array![1 => Float3]) + .color_blend(wgpu::BlendComponent::REPLACE) + .alpha_blend(wgpu::BlendComponent::REPLACE) + .add_vertex_buffer::(&wgpu::vertex_attr_array![0 => Float32x3]) + .add_vertex_buffer::(&wgpu::vertex_attr_array![1 => Float32x3]) // TODO: this can use the macro again when https://github.com/gfx-rs/wgpu/issues/836 is fixed .add_instance_buffer::(&[ wgpu::VertexAttribute { shader_location: 2, - format: wgpu::VertexFormat::Float4, + format: wgpu::VertexFormat::Float32x4, offset: std::mem::size_of::<[f32; 4]>() as u64 * 0, }, wgpu::VertexAttribute { shader_location: 3, - format: wgpu::VertexFormat::Float4, + format: wgpu::VertexFormat::Float32x4, offset: std::mem::size_of::<[f32; 4]>() as u64 * 1, }, wgpu::VertexAttribute { shader_location: 4, - format: wgpu::VertexFormat::Float4, + format: wgpu::VertexFormat::Float32x4, offset: std::mem::size_of::<[f32; 4]>() as u64 * 2, }, wgpu::VertexAttribute { shader_location: 5, - format: wgpu::VertexFormat::Float4, + format: wgpu::VertexFormat::Float32x4, offset: std::mem::size_of::<[f32; 4]>() as u64 * 3, }, wgpu::VertexAttribute { shader_location: 6, - format: wgpu::VertexFormat::Float4, + format: wgpu::VertexFormat::Float32x4, offset: std::mem::size_of::<[f32; 4]>() as u64 * 4, }, ]) diff --git a/examples/wgpu/wgpu_teapot/shaders/shader.vert b/examples/wgpu/wgpu_teapot/shaders/shader.vert index eeb08f81a..c104a3ae4 100644 --- a/examples/wgpu/wgpu_teapot/shaders/shader.vert +++ b/examples/wgpu/wgpu_teapot/shaders/shader.vert @@ -17,8 +17,29 @@ layout(set = 0, binding = 0) uniform Data { mat4 proj; } uniforms; +// Temporary manual inverse hack until this is solved +// https://github.com/gfx-rs/naga/issues/893 +mat3x3 custom_inverse(mat3x3 m) { + float determinant = determinant(m); + + float invdet = 1.0 / determinant; + + mat3x3 minv; + minv[0][0] = (m[1][1] * m[2][2] - m[2][1] * m[1][2]) * invdet; + minv[0][1] = (m[0][2] * m[2][1] - m[0][1] * m[2][2]) * invdet; + minv[0][2] = (m[0][1] * m[1][2] - m[0][2] * m[1][1]) * invdet; + minv[1][0] = (m[1][2] * m[2][0] - m[1][0] * m[2][2]) * invdet; + minv[1][1] = (m[0][0] * m[2][2] - m[0][2] * m[2][0]) * invdet; + minv[1][2] = (m[1][0] * m[0][2] - m[0][0] * m[1][2]) * invdet; + minv[2][0] = (m[1][0] * m[2][1] - m[2][0] * m[1][1]) * invdet; + minv[2][1] = (m[2][0] * m[0][1] - m[0][0] * m[2][1]) * invdet; + minv[2][2] = (m[0][0] * m[1][1] - m[1][0] * m[0][1]) * invdet; + + return minv; +} + void main() { mat4 worldview = uniforms.view * uniforms.world; - v_normal = transpose(inverse(mat3(worldview))) * normal; + v_normal = transpose(custom_inverse(mat3(worldview))) * normal; gl_Position = uniforms.proj * worldview * vec4(position, 1.0); } diff --git a/examples/wgpu/wgpu_teapot/shaders/vert.spv b/examples/wgpu/wgpu_teapot/shaders/vert.spv index e6bd42254..b9bf71b73 100644 Binary files a/examples/wgpu/wgpu_teapot/shaders/vert.spv and b/examples/wgpu/wgpu_teapot/shaders/vert.spv differ diff --git a/examples/wgpu/wgpu_teapot/wgpu_teapot.rs b/examples/wgpu/wgpu_teapot/wgpu_teapot.rs index e9af00b66..9e1e69a69 100644 --- a/examples/wgpu/wgpu_teapot/wgpu_teapot.rs +++ b/examples/wgpu/wgpu_teapot/wgpu_teapot.rs @@ -239,10 +239,10 @@ fn create_render_pipeline( wgpu::RenderPipelineBuilder::from_layout(layout, vs_mod) .fragment_shader(&fs_mod) .color_format(dst_format) - .color_blend(wgpu::BlendState::REPLACE) - .alpha_blend(wgpu::BlendState::REPLACE) - .add_vertex_buffer::(&wgpu::vertex_attr_array![0 => Float3]) - .add_vertex_buffer::(&wgpu::vertex_attr_array![1 => Float3]) + .color_blend(wgpu::BlendComponent::REPLACE) + .alpha_blend(wgpu::BlendComponent::REPLACE) + .add_vertex_buffer::(&wgpu::vertex_attr_array![0 => Float32x3]) + .add_vertex_buffer::(&wgpu::vertex_attr_array![1 => Float32x3]) .depth_format(depth_format) .sample_count(sample_count) .build(device) diff --git a/examples/wgpu/wgpu_teapot_camera/shaders/shader.vert b/examples/wgpu/wgpu_teapot_camera/shaders/shader.vert index eeb08f81a..c104a3ae4 100644 --- a/examples/wgpu/wgpu_teapot_camera/shaders/shader.vert +++ b/examples/wgpu/wgpu_teapot_camera/shaders/shader.vert @@ -17,8 +17,29 @@ layout(set = 0, binding = 0) uniform Data { mat4 proj; } uniforms; +// Temporary manual inverse hack until this is solved +// https://github.com/gfx-rs/naga/issues/893 +mat3x3 custom_inverse(mat3x3 m) { + float determinant = determinant(m); + + float invdet = 1.0 / determinant; + + mat3x3 minv; + minv[0][0] = (m[1][1] * m[2][2] - m[2][1] * m[1][2]) * invdet; + minv[0][1] = (m[0][2] * m[2][1] - m[0][1] * m[2][2]) * invdet; + minv[0][2] = (m[0][1] * m[1][2] - m[0][2] * m[1][1]) * invdet; + minv[1][0] = (m[1][2] * m[2][0] - m[1][0] * m[2][2]) * invdet; + minv[1][1] = (m[0][0] * m[2][2] - m[0][2] * m[2][0]) * invdet; + minv[1][2] = (m[1][0] * m[0][2] - m[0][0] * m[1][2]) * invdet; + minv[2][0] = (m[1][0] * m[2][1] - m[2][0] * m[1][1]) * invdet; + minv[2][1] = (m[2][0] * m[0][1] - m[0][0] * m[2][1]) * invdet; + minv[2][2] = (m[0][0] * m[1][1] - m[1][0] * m[0][1]) * invdet; + + return minv; +} + void main() { mat4 worldview = uniforms.view * uniforms.world; - v_normal = transpose(inverse(mat3(worldview))) * normal; + v_normal = transpose(custom_inverse(mat3(worldview))) * normal; gl_Position = uniforms.proj * worldview * vec4(position, 1.0); } diff --git a/examples/wgpu/wgpu_teapot_camera/shaders/vert.spv b/examples/wgpu/wgpu_teapot_camera/shaders/vert.spv index e6bd42254..b9bf71b73 100644 Binary files a/examples/wgpu/wgpu_teapot_camera/shaders/vert.spv and b/examples/wgpu/wgpu_teapot_camera/shaders/vert.spv differ diff --git a/examples/wgpu/wgpu_teapot_camera/wgpu_teapot_camera.rs b/examples/wgpu/wgpu_teapot_camera/wgpu_teapot_camera.rs index 9e1213b78..e3f0d5cd6 100644 --- a/examples/wgpu/wgpu_teapot_camera/wgpu_teapot_camera.rs +++ b/examples/wgpu/wgpu_teapot_camera/wgpu_teapot_camera.rs @@ -368,10 +368,10 @@ fn create_render_pipeline( wgpu::RenderPipelineBuilder::from_layout(layout, vs_mod) .fragment_shader(&fs_mod) .color_format(dst_format) - .color_blend(wgpu::BlendState::REPLACE) - .alpha_blend(wgpu::BlendState::REPLACE) - .add_vertex_buffer::(&wgpu::vertex_attr_array![0 => Float3]) - .add_vertex_buffer::(&wgpu::vertex_attr_array![1 => Float3]) + .color_blend(wgpu::BlendComponent::REPLACE) + .alpha_blend(wgpu::BlendComponent::REPLACE) + .add_vertex_buffer::(&wgpu::vertex_attr_array![0 => Float32x3]) + .add_vertex_buffer::(&wgpu::vertex_attr_array![1 => Float32x3]) .depth_format(depth_format) .sample_count(sample_count) .build(device) diff --git a/examples/wgpu/wgpu_triangle/wgpu_triangle.rs b/examples/wgpu/wgpu_triangle/wgpu_triangle.rs index 9669f14be..bddf13494 100644 --- a/examples/wgpu/wgpu_triangle/wgpu_triangle.rs +++ b/examples/wgpu/wgpu_triangle/wgpu_triangle.rs @@ -67,7 +67,7 @@ fn model(app: &App) -> Model { let render_pipeline = wgpu::RenderPipelineBuilder::from_layout(&pipeline_layout, &vs_mod) .fragment_shader(&fs_mod) .color_format(format) - .add_vertex_buffer::(&wgpu::vertex_attr_array![0 => Float2]) + .add_vertex_buffer::(&wgpu::vertex_attr_array![0 => Float32x2]) .sample_count(sample_count) .build(device); diff --git a/examples/wgpu/wgpu_triangle_raw_frame/wgpu_triangle_raw_frame.rs b/examples/wgpu/wgpu_triangle_raw_frame/wgpu_triangle_raw_frame.rs index e2b1199db..6a7dab885 100644 --- a/examples/wgpu/wgpu_triangle_raw_frame/wgpu_triangle_raw_frame.rs +++ b/examples/wgpu/wgpu_triangle_raw_frame/wgpu_triangle_raw_frame.rs @@ -61,7 +61,7 @@ fn model(app: &App) -> Model { let render_pipeline = wgpu::RenderPipelineBuilder::from_layout(&pipeline_layout, &vs_mod) .fragment_shader(&fs_mod) .color_format(format) - .add_vertex_buffer::(&wgpu::vertex_attr_array![0 => Float2]) + .add_vertex_buffer::(&wgpu::vertex_attr_array![0 => Float32x2]) .build(device); Model { diff --git a/guide/src/changelog.md b/guide/src/changelog.md index 87e6e90ea..bf06329f6 100644 --- a/guide/src/changelog.md +++ b/guide/src/changelog.md @@ -7,8 +7,14 @@ back to the origins. # Unreleased -*No unreleased changes as of yet. - +**Upgrade WGPU to 0.8** + +Most changes have been about renaming Blend-related data structres and fixing shaders to avoid sampling textures inside of conditionals (wgpu validation layer found this one). +- Item Name changes: + - `BlendState` -> `BlendComponent` + - `wgpu::Extend3d::depth` -> `wgpu::Extend3d::depth_of_array_layers` + - Float tpes are now typed more descripively. E.g., `Float2` -> `Float32x2` + --- # Version 0.16.0 (2021-04-21) diff --git a/guide/src/contributing/pr-checklist.md b/guide/src/contributing/pr-checklist.md index d49793be7..04d09d109 100644 --- a/guide/src/contributing/pr-checklist.md +++ b/guide/src/contributing/pr-checklist.md @@ -14,6 +14,10 @@ landing your changes go smoothly: last commit. Keep in mind that sometimes warnings already exist due to changes in the compiler's linter between versions. Try to at least make sure that your changes do not add any new ones :) +- **Check Examples** - Make sure the examples still work by running +`cargo run --bin run_all_examples`. This executes a script that builds and runs +all the examples in the project. You need to do a manual check to see +if examples have failed to run successfully (e.g. check for wgpu validation errors). - **Documentation** - If you have made any changes that could benefit from updating some code documentation, please be sure to do so! Try to put yourself in the shoes of someone reading your code for the first time. diff --git a/nannou/Cargo.toml b/nannou/Cargo.toml index b8e7d1a68..e4d82b480 100644 --- a/nannou/Cargo.toml +++ b/nannou/Cargo.toml @@ -15,8 +15,8 @@ default = ["notosans"] [dependencies] cgmath = { version = "0.17", features = ["serde"] } -conrod_core = "0.72" -conrod_wgpu = "0.72" +conrod_core = "0.73" +conrod_wgpu = "0.73" conrod_winit = "0.72" daggy = "0.6" find_folder = "0.3" @@ -36,5 +36,5 @@ serde_derive = "1" serde_json = "1" toml = "0.5" walkdir = "2" -wgpu_upstream = { version = "0.7.1", package = "wgpu" } +wgpu_upstream = { version = "0.8", package = "wgpu" } winit = "0.24" diff --git a/nannou/src/draw/mod.rs b/nannou/src/draw/mod.rs index 9ffa5e071..2de5d1b41 100644 --- a/nannou/src/draw/mod.rs +++ b/nannou/src/draw/mod.rs @@ -64,8 +64,7 @@ where #[derive(Clone, Debug, PartialEq)] pub struct Context { pub transform: Matrix4, - pub alpha_blend: wgpu::BlendState, - pub color_blend: wgpu::BlendState, + pub blend: wgpu::BlendState, pub scissor: Scissor, // TODO: Consider changing `PolygonMode` (added as of wgpu 0.7) rather than `PrimitiveTopology` // here. @@ -403,21 +402,21 @@ where } /// Produce a new **Draw** instance that will draw with the given alpha blend descriptor. - pub fn alpha_blend(&self, blend_descriptor: wgpu::BlendState) -> Self { + pub fn alpha_blend(&self, blend_descriptor: wgpu::BlendComponent) -> Self { let mut context = self.context.clone(); - context.alpha_blend = blend_descriptor; + context.blend.alpha = blend_descriptor; self.context(context) } /// Produce a new **Draw** instance that will draw with the given color blend descriptor. - pub fn color_blend(&self, blend_descriptor: wgpu::BlendState) -> Self { + pub fn color_blend(&self, blend_descriptor: wgpu::BlendComponent) -> Self { let mut context = self.context.clone(); - context.color_blend = blend_descriptor; + context.blend.color = blend_descriptor; self.context(context) } /// Short-hand for `color_blend`, the common use-case. - pub fn blend(&self, blend_descriptor: wgpu::BlendState) -> Self { + pub fn blend(&self, blend_descriptor: wgpu::BlendComponent) -> Self { self.color_blend(blend_descriptor) } @@ -672,8 +671,10 @@ where fn default() -> Self { Self { transform: Matrix4::identity(), - alpha_blend: wgpu::RenderPipelineBuilder::DEFAULT_ALPHA_BLEND, - color_blend: wgpu::RenderPipelineBuilder::DEFAULT_COLOR_BLEND, + blend: wgpu::BlendState { + color: wgpu::RenderPipelineBuilder::DEFAULT_COLOR_BLEND, + alpha: wgpu::RenderPipelineBuilder::DEFAULT_ALPHA_BLEND, + }, scissor: Scissor::Full, topology: wgpu::RenderPipelineBuilder::DEFAULT_PRIMITIVE_TOPOLOGY, sampler: wgpu::SamplerBuilder::new().into_descriptor(), diff --git a/nannou/src/draw/renderer/mod.rs b/nannou/src/draw/renderer/mod.rs index e7d6d7da0..0c95f9c61 100644 --- a/nannou/src/draw/renderer/mod.rs +++ b/nannou/src/draw/renderer/mod.rs @@ -609,8 +609,8 @@ impl Renderer { // Determine the new current bind group layout ID, pipeline ID, bind group ID // and scissor required for drawing this primitive. let new_pipeline_id = { - let color_id = blend_state_hash(&curr_ctxt.color_blend); - let alpha_id = blend_state_hash(&curr_ctxt.alpha_blend); + let color_id = blend_component_hash(&curr_ctxt.blend.color); + let alpha_id = blend_component_hash(&curr_ctxt.blend.alpha); let topology = curr_ctxt.topology; PipelineId { color_id, @@ -645,8 +645,8 @@ impl Renderer { // If necessary, push a new pipeline command. if pipeline_changed { curr_pipeline_id = Some(new_pipeline_id); - let color_blend = curr_ctxt.color_blend.clone(); - let alpha_blend = curr_ctxt.alpha_blend.clone(); + let color_blend = curr_ctxt.blend.color.clone(); + let alpha_blend = curr_ctxt.blend.alpha.clone(); let sampler_filtering = wgpu::sampler_filtering(&curr_ctxt.sampler); new_pipeline_ids.insert( new_pipeline_id, @@ -1117,18 +1117,20 @@ fn create_render_pipeline( dst_format: wgpu::TextureFormat, depth_format: wgpu::TextureFormat, sample_count: u32, - color_blend: wgpu::BlendState, - alpha_blend: wgpu::BlendState, + color_blend: wgpu::BlendComponent, + alpha_blend: wgpu::BlendComponent, topology: wgpu::PrimitiveTopology, ) -> wgpu::RenderPipeline { let bind_group_layouts = &[uniform_layout, text_layout, texture_layout]; wgpu::RenderPipelineBuilder::from_layout_descriptor(&bind_group_layouts[..], vs_mod) .fragment_shader(fs_mod) .color_format(dst_format) - .add_vertex_buffer::(&wgpu::vertex_attr_array![0 => Float3]) - .add_vertex_buffer::(&wgpu::vertex_attr_array![1 => Float4]) - .add_vertex_buffer::(&wgpu::vertex_attr_array![2 => Float2]) - .add_vertex_buffer::(&wgpu::vertex_attr_array![3 => Uint]) + .add_vertex_buffer::(&wgpu::vertex_attr_array![0 => Float32x3]) + .add_vertex_buffer::(&wgpu::vertex_attr_array![1 => Float32x4]) + .add_vertex_buffer::( + &wgpu::vertex_attr_array![2 => Float32x2], + ) + .add_vertex_buffer::(&wgpu::vertex_attr_array![3 => Uint32]) .depth_format(depth_format) .sample_count(sample_count) .color_blend(color_blend) @@ -1153,7 +1155,7 @@ fn sampler_descriptor_hash(desc: &wgpu::SamplerDescriptor) -> SamplerId { s.finish() } -fn blend_state_hash(desc: &wgpu::BlendState) -> BlendId { +fn blend_component_hash(desc: &wgpu::BlendComponent) -> BlendId { let mut s = std::collections::hash_map::DefaultHasher::new(); desc.src_factor.hash(&mut s); desc.dst_factor.hash(&mut s); diff --git a/nannou/src/draw/renderer/shaders/frag.spv b/nannou/src/draw/renderer/shaders/frag.spv index a850489e3..8140614c3 100644 Binary files a/nannou/src/draw/renderer/shaders/frag.spv and b/nannou/src/draw/renderer/shaders/frag.spv differ diff --git a/nannou/src/draw/renderer/shaders/shader.frag b/nannou/src/draw/renderer/shaders/shader.frag index b28f32c5a..616d215fa 100644 --- a/nannou/src/draw/renderer/shaders/shader.frag +++ b/nannou/src/draw/renderer/shaders/shader.frag @@ -18,19 +18,18 @@ layout(location = 2) flat in uint v_mode; layout(location = 0) out vec4 f_color; void main() { + vec4 tex_color = texture(sampler2D(tex, tex_sampler), v_tex_coords); + float text_alpha = texture(sampler2D(text, text_sampler), v_tex_coords).r; + // Color if (v_mode == uint(0)) { f_color = v_color; - // Texture } else if (v_mode == uint(1)) { - f_color = texture(sampler2D(tex, tex_sampler), v_tex_coords); - + f_color = tex_color; // Text } else if (v_mode == uint(2)) { - float tex_a = texture(sampler2D(text, text_sampler), v_tex_coords).r; - f_color = vec4(v_color.rgb, v_color.a * tex_a); - + f_color = vec4(v_color.rgb, v_color.a * text_alpha); // Unhandled mode - Indicate error with red. } else { f_color = vec4(1.0, 0.0, 0.0, 1.0); diff --git a/nannou/src/frame/mod.rs b/nannou/src/frame/mod.rs index 168a62064..3319800ba 100644 --- a/nannou/src/frame/mod.rs +++ b/nannou/src/frame/mod.rs @@ -220,14 +220,14 @@ impl<'swap_chain> Frame<'swap_chain> { self.render_data.size } - /// Short-hand for constructing a `wgpu::RenderPassColorAttachmentDescriptor` for use within a + /// Short-hand for constructing a `wgpu::RenderPassColorAttachment` for use within a /// render pass that targets this frame's texture. The returned descriptor's `attachment` will /// the same `wgpu::TextureView` returned by the `Frame::texture` method. /// /// Note that this method will not perform any resolving. In the case that `msaa_samples` is /// greater than `1`, a render pass will be automatically added after the `view` completes and /// before the texture is drawn to the swapchain. - pub fn color_attachment_descriptor(&self) -> wgpu::RenderPassColorAttachmentDescriptor { + pub fn color_attachment_descriptor(&self) -> wgpu::RenderPassColorAttachment { let load = wgpu::LoadOp::Load; let store = true; let attachment = match self.render_data.intermediary_lin_srgba.msaa_texture { @@ -235,8 +235,8 @@ impl<'swap_chain> Frame<'swap_chain> { Some((_, ref msaa_texture_view)) => msaa_texture_view, }; let resolve_target = None; - wgpu::RenderPassColorAttachmentDescriptor { - attachment, + wgpu::RenderPassColorAttachment { + view: attachment, resolve_target, ops: wgpu::Operations { load, store }, } diff --git a/nannou/src/ui.rs b/nannou/src/ui.rs index fd5d874f1..63f4b501c 100644 --- a/nannou/src/ui.rs +++ b/nannou/src/ui.rs @@ -467,7 +467,7 @@ pub fn encode_render_pass( ui: &Ui, window: &Window, primitives: conrod_core::render::Primitives, - color_attachment_desc: wgpu::RenderPassColorAttachmentDescriptor, + color_attachment_desc: wgpu::RenderPassColorAttachment, encoder: &mut wgpu::CommandEncoder, ) -> Result<(), DrawToFrameError> { // Feed the renderer primitives and update glyph cache texture if necessary. diff --git a/nannou/src/wgpu/bind_group_builder.rs b/nannou/src/wgpu/bind_group_builder.rs index 3840a6e86..ba4019465 100644 --- a/nannou/src/wgpu/bind_group_builder.rs +++ b/nannou/src/wgpu/bind_group_builder.rs @@ -1,3 +1,5 @@ +use wgpu_upstream::BufferBinding; + use crate::wgpu; /// A type aimed at simplifying the creation of a bind group layout. @@ -188,11 +190,11 @@ impl<'a> Builder<'a> { offset: wgpu::BufferAddress, size: Option, ) -> Self { - let resource = wgpu::BindingResource::Buffer { + let resource = wgpu::BindingResource::Buffer(BufferBinding { buffer, offset, size, - }; + }); self.binding(resource) } diff --git a/nannou/src/wgpu/blend.rs b/nannou/src/wgpu/blend.rs index e859db1b0..2880da1d5 100644 --- a/nannou/src/wgpu/blend.rs +++ b/nannou/src/wgpu/blend.rs @@ -2,38 +2,38 @@ use crate::wgpu; -pub const NORMAL: wgpu::BlendState = wgpu::BlendState { +pub const NORMAL: wgpu::BlendComponent = wgpu::BlendComponent { src_factor: wgpu::BlendFactor::SrcAlpha, dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha, operation: wgpu::BlendOperation::Add, }; -pub const ADD: wgpu::BlendState = wgpu::BlendState { - src_factor: wgpu::BlendFactor::SrcColor, - dst_factor: wgpu::BlendFactor::DstColor, +pub const ADD: wgpu::BlendComponent = wgpu::BlendComponent { + src_factor: wgpu::BlendFactor::Src, + dst_factor: wgpu::BlendFactor::Dst, operation: wgpu::BlendOperation::Add, }; -pub const SUBTRACT: wgpu::BlendState = wgpu::BlendState { - src_factor: wgpu::BlendFactor::SrcColor, - dst_factor: wgpu::BlendFactor::DstColor, +pub const SUBTRACT: wgpu::BlendComponent = wgpu::BlendComponent { + src_factor: wgpu::BlendFactor::Src, + dst_factor: wgpu::BlendFactor::Dst, operation: wgpu::BlendOperation::Subtract, }; -pub const REVERSE_SUBTRACT: wgpu::BlendState = wgpu::BlendState { - src_factor: wgpu::BlendFactor::SrcColor, - dst_factor: wgpu::BlendFactor::DstColor, +pub const REVERSE_SUBTRACT: wgpu::BlendComponent = wgpu::BlendComponent { + src_factor: wgpu::BlendFactor::Src, + dst_factor: wgpu::BlendFactor::Dst, operation: wgpu::BlendOperation::ReverseSubtract, }; -pub const DARKEST: wgpu::BlendState = wgpu::BlendState { - src_factor: wgpu::BlendFactor::SrcColor, - dst_factor: wgpu::BlendFactor::DstColor, +pub const DARKEST: wgpu::BlendComponent = wgpu::BlendComponent { + src_factor: wgpu::BlendFactor::One, + dst_factor: wgpu::BlendFactor::One, operation: wgpu::BlendOperation::Min, }; -pub const LIGHTEST: wgpu::BlendState = wgpu::BlendState { - src_factor: wgpu::BlendFactor::SrcColor, - dst_factor: wgpu::BlendFactor::DstColor, +pub const LIGHTEST: wgpu::BlendComponent = wgpu::BlendComponent { + src_factor: wgpu::BlendFactor::One, + dst_factor: wgpu::BlendFactor::One, operation: wgpu::BlendOperation::Max, }; diff --git a/nannou/src/wgpu/mod.rs b/nannou/src/wgpu/mod.rs index 50afbef6d..28d35cf42 100644 --- a/nannou/src/wgpu/mod.rs +++ b/nannou/src/wgpu/mod.rs @@ -56,29 +56,29 @@ pub use wgpu_upstream::{ util::{self, BufferInitDescriptor}, vertex_attr_array, Adapter, AdapterInfo, AddressMode, Backend, BackendBit, BindGroup, BindGroupDescriptor, BindGroupEntry, BindGroupLayout, BindGroupLayoutDescriptor, - BindGroupLayoutEntry, BindingResource, BindingType, BlendFactor, BlendOperation, BlendState, - Buffer, BufferAddress, BufferAsyncError, BufferBindingType, BufferCopyView, BufferCopyViewBase, + BindGroupLayoutEntry, BindingResource, BindingType, BlendComponent, BlendFactor, + BlendOperation, BlendState, Buffer, BufferAddress, BufferAsyncError, BufferBindingType, BufferDescriptor, BufferSize, BufferSlice, BufferUsage, BufferView, BufferViewMut, Color, ColorTargetState, ColorWrite, CommandBuffer, CommandBufferDescriptor, CommandEncoder, CommandEncoderDescriptor, CompareFunction, ComputePass, ComputePassDescriptor, ComputePipeline, - ComputePipelineDescriptor, CullMode, DepthBiasState, DepthStencilState, Device, - DeviceDescriptor, DeviceType, DynamicOffset, Error, Extent3d, Features, FilterMode, - FragmentState, FrontFace, IndexFormat, InputStepMode, Instance, Label, Limits, LoadOp, - Maintain, MapMode, MultisampleState, Operations, Origin3d, PipelineLayout, - PipelineLayoutDescriptor, PipelineStatisticsTypes, PolygonMode, PowerPreference, PresentMode, - PrimitiveState, PrimitiveTopology, PushConstantRange, QuerySet, QuerySetDescriptor, QueryType, - Queue, RenderBundle, RenderBundleDescriptor, RenderBundleEncoder, - RenderBundleEncoderDescriptor, RenderPass, RenderPassColorAttachmentDescriptor, - RenderPassDepthStencilAttachmentDescriptor, RenderPassDescriptor, RenderPipeline, - RenderPipelineDescriptor, RequestAdapterOptions, RequestAdapterOptionsBase, RequestDeviceError, - Sampler, SamplerBorderColor, SamplerDescriptor, ShaderFlags, ShaderLocation, ShaderModule, - ShaderModuleDescriptor, ShaderSource, ShaderStage, StencilFaceState, StencilOperation, - StencilState, StorageTextureAccess, Surface, SwapChain, SwapChainDescriptor, SwapChainError, - SwapChainFrame, SwapChainStatus, SwapChainTexture, Texture as TextureHandle, TextureAspect, - TextureCopyView, TextureCopyViewBase, TextureDataLayout, TextureDescriptor, TextureDimension, - TextureFormat, TextureSampleType, TextureUsage, TextureView as TextureViewHandle, - TextureViewDescriptor, TextureViewDimension, UncapturedErrorHandler, VertexAttribute, - VertexBufferLayout, VertexFormat, VertexState, BIND_BUFFER_ALIGNMENT, COPY_BUFFER_ALIGNMENT, + ComputePipelineDescriptor, DepthBiasState, DepthStencilState, Device, DeviceDescriptor, + DeviceType, DynamicOffset, Error, Extent3d, Face, Features, FilterMode, FragmentState, + FrontFace, ImageCopyBuffer, ImageCopyBufferBase, ImageCopyTexture, ImageCopyTextureBase, + ImageDataLayout, IndexFormat, InputStepMode, Instance, Label, Limits, LoadOp, Maintain, + MapMode, MultisampleState, Operations, Origin3d, PipelineLayout, PipelineLayoutDescriptor, + PipelineStatisticsTypes, PolygonMode, PowerPreference, PresentMode, PrimitiveState, + PrimitiveTopology, PushConstantRange, QuerySet, QuerySetDescriptor, QueryType, Queue, + RenderBundle, RenderBundleDescriptor, RenderBundleEncoder, RenderBundleEncoderDescriptor, + RenderPass, RenderPassColorAttachment, RenderPassDepthStencilAttachment, RenderPassDescriptor, + RenderPipeline, RenderPipelineDescriptor, RequestAdapterOptions, RequestAdapterOptionsBase, + RequestDeviceError, Sampler, SamplerBorderColor, SamplerDescriptor, ShaderFlags, + ShaderLocation, ShaderModule, ShaderModuleDescriptor, ShaderSource, ShaderStage, + StencilFaceState, StencilOperation, StencilState, StorageTextureAccess, Surface, SwapChain, + SwapChainDescriptor, SwapChainError, SwapChainFrame, SwapChainStatus, SwapChainTexture, + Texture as TextureHandle, TextureAspect, TextureDescriptor, TextureDimension, TextureFormat, + TextureSampleType, TextureUsage, TextureView as TextureViewHandle, TextureViewDescriptor, + TextureViewDimension, UncapturedErrorHandler, VertexAttribute, VertexBufferLayout, + VertexFormat, VertexState, BIND_BUFFER_ALIGNMENT, COPY_BUFFER_ALIGNMENT, COPY_BYTES_PER_ROW_ALIGNMENT, PUSH_CONSTANT_ALIGNMENT, }; diff --git a/nannou/src/wgpu/render_pass.rs b/nannou/src/wgpu/render_pass.rs index 40bc14073..e9623d095 100644 --- a/nannou/src/wgpu/render_pass.rs +++ b/nannou/src/wgpu/render_pass.rs @@ -3,20 +3,20 @@ use crate::wgpu::{self, Color, LoadOp}; /// A builder type to simplify the process of creating a render pass descriptor. #[derive(Debug, Default)] pub struct Builder<'a> { - color_attachments: Vec>, - depth_stencil_attachment: Option>, + color_attachments: Vec>, + depth_stencil_attachment: Option>, } /// A builder type to simplify the process of creating a render pass descriptor. #[derive(Debug)] pub struct ColorAttachmentDescriptorBuilder<'a> { - descriptor: wgpu::RenderPassColorAttachmentDescriptor<'a>, + descriptor: wgpu::RenderPassColorAttachment<'a>, } /// A builder type to simplify the process of creating a render pass descriptor. #[derive(Debug)] pub struct DepthStencilAttachmentDescriptorBuilder<'a> { - descriptor: wgpu::RenderPassDepthStencilAttachmentDescriptor<'a>, + descriptor: wgpu::RenderPassDepthStencilAttachment<'a>, } impl<'a> ColorAttachmentDescriptorBuilder<'a> { @@ -27,8 +27,8 @@ impl<'a> ColorAttachmentDescriptorBuilder<'a> { /// Begin building a new render pass color attachment descriptor. fn new(attachment: &'a wgpu::TextureViewHandle) -> Self { ColorAttachmentDescriptorBuilder { - descriptor: wgpu::RenderPassColorAttachmentDescriptor { - attachment, + descriptor: wgpu::RenderPassColorAttachment { + view: attachment, resolve_target: None, ops: wgpu::Operations { load: LoadOp::Clear(Color::TRANSPARENT), @@ -73,8 +73,8 @@ impl<'a> DepthStencilAttachmentDescriptorBuilder<'a> { fn new(attachment: &'a wgpu::TextureViewHandle) -> Self { DepthStencilAttachmentDescriptorBuilder { - descriptor: wgpu::RenderPassDepthStencilAttachmentDescriptor { - attachment, + descriptor: wgpu::RenderPassDepthStencilAttachment { + view: attachment, depth_ops: Some(wgpu::Operations { load: Self::DEFAULT_DEPTH_LOAD_OP, store: Self::DEFAULT_DEPTH_STORE_OP, @@ -196,8 +196,8 @@ impl<'a> Builder<'a> { pub fn into_inner( self, ) -> ( - Vec>, - Option>, + Vec>, + Option>, ) { let Builder { color_attachments, diff --git a/nannou/src/wgpu/render_pipeline_builder.rs b/nannou/src/wgpu/render_pipeline_builder.rs index 067f461a8..572f4d252 100644 --- a/nannou/src/wgpu/render_pipeline_builder.rs +++ b/nannou/src/wgpu/render_pipeline_builder.rs @@ -42,7 +42,7 @@ impl<'a> RenderPipelineBuilder<'a> { // Primitive state. pub const DEFAULT_FRONT_FACE: wgpu::FrontFace = wgpu::FrontFace::Ccw; - pub const DEFAULT_CULL_MODE: wgpu::CullMode = wgpu::CullMode::None; + pub const DEFAULT_CULL_MODE: Option = None; pub const DEFAULT_POLYGON_MODE: wgpu::PolygonMode = wgpu::PolygonMode::Fill; pub const DEFAULT_PRIMITIVE_TOPOLOGY: wgpu::PrimitiveTopology = wgpu::PrimitiveTopology::TriangleList; @@ -52,25 +52,30 @@ impl<'a> RenderPipelineBuilder<'a> { front_face: Self::DEFAULT_FRONT_FACE, cull_mode: Self::DEFAULT_CULL_MODE, polygon_mode: Self::DEFAULT_POLYGON_MODE, + clamp_depth: Self::DEFAULT_CLAMP_DEPTH, + conservative: false, }; // Color state defaults. pub const DEFAULT_COLOR_FORMAT: wgpu::TextureFormat = crate::frame::Frame::TEXTURE_FORMAT; - pub const DEFAULT_COLOR_BLEND: wgpu::BlendState = wgpu::BlendState { + pub const DEFAULT_COLOR_BLEND: wgpu::BlendComponent = wgpu::BlendComponent { src_factor: wgpu::BlendFactor::SrcAlpha, dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha, operation: wgpu::BlendOperation::Add, }; - pub const DEFAULT_ALPHA_BLEND: wgpu::BlendState = wgpu::BlendState { + pub const DEFAULT_ALPHA_BLEND: wgpu::BlendComponent = wgpu::BlendComponent { src_factor: wgpu::BlendFactor::One, dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha, operation: wgpu::BlendOperation::Add, }; pub const DEFAULT_COLOR_WRITE: wgpu::ColorWrite = wgpu::ColorWrite::ALL; + pub const DEFAULT_BLEND_STATE: wgpu::BlendState = wgpu::BlendState { + color: Self::DEFAULT_COLOR_BLEND, + alpha: Self::DEFAULT_ALPHA_BLEND, + }; pub const DEFAULT_COLOR_STATE: wgpu::ColorTargetState = wgpu::ColorTargetState { format: Self::DEFAULT_COLOR_FORMAT, - color_blend: Self::DEFAULT_COLOR_BLEND, - alpha_blend: Self::DEFAULT_ALPHA_BLEND, + blend: Some(Self::DEFAULT_BLEND_STATE), write_mask: Self::DEFAULT_COLOR_WRITE, }; @@ -103,7 +108,6 @@ impl<'a> RenderPipelineBuilder<'a> { depth_compare: Self::DEFAULT_DEPTH_COMPARE, stencil: Self::DEFAULT_STENCIL, bias: Self::DEFAULT_DEPTH_BIAS, - clamp_depth: Self::DEFAULT_CLAMP_DEPTH, }; // Multisample state. @@ -194,7 +198,7 @@ impl<'a> RenderPipelineBuilder<'a> { } /// The face culling mode. - pub fn cull_mode(mut self, cull_mode: wgpu::CullMode) -> Self { + pub fn cull_mode(mut self, cull_mode: Option) -> Self { self.primitive.cull_mode = cull_mode; self } @@ -237,16 +241,20 @@ impl<'a> RenderPipelineBuilder<'a> { } /// The color blending used for this pipeline. - pub fn color_blend(mut self, blend: wgpu::BlendState) -> Self { + pub fn color_blend(mut self, color_blend: wgpu::BlendComponent) -> Self { let state = self.color_state.get_or_insert(Self::DEFAULT_COLOR_STATE); - state.color_blend = blend; + let blend = state.blend.get_or_insert(Self::DEFAULT_BLEND_STATE); + blend.color = color_blend; + self } /// The alpha blending used for this pipeline. - pub fn alpha_blend(mut self, blend: wgpu::BlendState) -> Self { + pub fn alpha_blend(mut self, alpha_blend: wgpu::BlendComponent) -> Self { let state = self.color_state.get_or_insert(Self::DEFAULT_COLOR_STATE); - state.alpha_blend = blend; + let blend = state.blend.get_or_insert(Self::DEFAULT_BLEND_STATE); + blend.alpha = alpha_blend; + self } @@ -381,10 +389,7 @@ impl<'a> RenderPipelineBuilder<'a> { /// /// Requires `Features::DEPTH_CLAMPING` enabled. pub fn clamp_depth(mut self, b: bool) -> Self { - let state = self - .depth_stencil - .get_or_insert(Self::DEFAULT_DEPTH_STENCIL); - state.clamp_depth = b; + self.primitive.clamp_depth = b; self } diff --git a/nannou/src/wgpu/texture/image.rs b/nannou/src/wgpu/texture/image.rs index 6c8898df6..4227a428f 100644 --- a/nannou/src/wgpu/texture/image.rs +++ b/nannou/src/wgpu/texture/image.rs @@ -588,7 +588,7 @@ where .extent(wgpu::Extent3d { width, height, - depth: array_layers, + depth_or_array_layers: array_layers, }) .dimension(wgpu::TextureDimension::D2) // force an array .usage(wgpu::TextureBuilder::REQUIRED_IMAGE_TEXTURE_USAGE | usage) diff --git a/nannou/src/wgpu/texture/mod.rs b/nannou/src/wgpu/texture/mod.rs index cbd4a23d9..e86306550 100644 --- a/nannou/src/wgpu/texture/mod.rs +++ b/nannou/src/wgpu/texture/mod.rs @@ -223,7 +223,7 @@ impl Texture { pub fn view_dimension(&self) -> wgpu::TextureViewDimension { match self.dimension() { wgpu::TextureDimension::D1 => wgpu::TextureViewDimension::D1, - wgpu::TextureDimension::D2 => match self.descriptor.size.depth { + wgpu::TextureDimension::D2 => match self.descriptor.size.depth_or_array_layers { 1 => wgpu::TextureViewDimension::D2, _ => wgpu::TextureViewDimension::D2Array, }, @@ -290,7 +290,7 @@ impl Texture { encoder: &mut wgpu::CommandEncoder, ) -> wgpu::RowPaddedBuffer { assert_eq!( - self.extent().depth, + self.extent().depth_or_array_layers, 1, "cannot convert a 3d texture to a RowPaddedBuffer" ); @@ -414,7 +414,7 @@ impl Builder { pub const DEFAULT_SIZE: wgpu::Extent3d = wgpu::Extent3d { width: Self::DEFAULT_SIDE, height: Self::DEFAULT_SIDE, - depth: Self::DEFAULT_DEPTH, + depth_or_array_layers: Self::DEFAULT_DEPTH, }; pub const DEFAULT_ARRAY_LAYER_COUNT: u32 = 1; pub const DEFAULT_MIP_LEVEL_COUNT: u32 = 1; @@ -455,7 +455,7 @@ impl Builder { /// `wgpu::TextureDimension` of its inner `wgpu::TextureDescriptor` by examining its `size` /// field. Use `TextureBuilder::dimension()` to override this behavior. pub fn depth(mut self, depth: u32) -> Self { - self.descriptor.size.depth = depth; + self.descriptor.size.depth_or_array_layers = depth; self.infer_dimension_from_size(); self } @@ -510,7 +510,7 @@ impl Builder { // If `depth` is greater than `1` then `D3` is assumed, otherwise if `height` is greater than // `1` then `D2` is assumed, otherwise `D1` is assumed. fn infer_dimension_from_size(&mut self) { - if self.descriptor.size.depth > 1 { + if self.descriptor.size.depth_or_array_layers > 1 { self.descriptor.dimension = wgpu::TextureDimension::D3; } else if self.descriptor.size.height > 1 { self.descriptor.dimension = wgpu::TextureDimension::D2; @@ -597,6 +597,12 @@ impl<'a> ViewBuilder<'a> { /// /// If `None`, considered to include the rest of the array layers, but at least 1 in total. pub fn array_layer_count(mut self, array_layer_count: Option) -> Self { + match (self.info.dimension, array_layer_count.map(|n| n.get())) { + (wgpu::TextureViewDimension::D2Array, Some(1)) => { + self.info.dimension = wgpu::TextureViewDimension::D2; + } + _ => (), + } self.info.array_layer_count = array_layer_count; self } @@ -745,7 +751,7 @@ fn texture_view_id(texture_id: &TextureId, view_info: &TextureViewInfo) -> Textu pub fn data_size_bytes(desc: &wgpu::TextureDescriptor) -> usize { desc.size.width as usize * desc.size.height as usize - * desc.size.depth as usize + * desc.size.depth_or_array_layers as usize * format_size_bytes(desc.format) as usize } @@ -756,7 +762,7 @@ pub fn format_size_bytes(format: wgpu::TextureFormat) -> u32 { /// Returns `true` if the given `wgpu::Extent3d`s are equal. pub fn extent_3d_eq(a: &wgpu::Extent3d, b: &wgpu::Extent3d) -> bool { - a.width == b.width && a.height == b.height && a.depth == b.depth + a.width == b.width && a.height == b.height && a.depth_or_array_layers == b.depth_or_array_layers } /// Returns `true` if the given texture descriptors are equal. @@ -794,7 +800,7 @@ fn view_info_to_view_descriptor(info: &TextureViewInfo) -> wgpu::TextureViewDesc dimension: Some(info.dimension), aspect: info.aspect, base_mip_level: info.base_mip_level, - level_count: info.level_count, + mip_level_count: info.level_count, base_array_layer: info.base_array_layer, array_layer_count: info.array_layer_count, } diff --git a/nannou/src/wgpu/texture/reshaper/mod.rs b/nannou/src/wgpu/texture/reshaper/mod.rs index 05f2de7cc..3b26e6161 100644 --- a/nannou/src/wgpu/texture/reshaper/mod.rs +++ b/nannou/src/wgpu/texture/reshaper/mod.rs @@ -219,9 +219,9 @@ fn render_pipeline( wgpu::RenderPipelineBuilder::from_layout(layout, vs_mod) .fragment_shader(fs_mod) .color_format(dst_format) - .color_blend(wgpu::BlendState::REPLACE) - .alpha_blend(wgpu::BlendState::REPLACE) - .add_vertex_buffer::(&wgpu::vertex_attr_array![0 => Float2]) + .color_blend(wgpu::BlendComponent::REPLACE) + .alpha_blend(wgpu::BlendComponent::REPLACE) + .add_vertex_buffer::(&wgpu::vertex_attr_array![0 => Float32x2]) .primitive_topology(wgpu::PrimitiveTopology::TriangleStrip) .sample_count(dst_sample_count) .build(device) diff --git a/nannou/src/wgpu/texture/row_padded_buffer.rs b/nannou/src/wgpu/texture/row_padded_buffer.rs index 13f4c2fc9..6e343bb60 100644 --- a/nannou/src/wgpu/texture/row_padded_buffer.rs +++ b/nannou/src/wgpu/texture/row_padded_buffer.rs @@ -181,7 +181,7 @@ impl RowPaddedBuffer { destination: &wgpu::Texture, ) { assert_eq!( - destination.extent().depth, + destination.extent().depth_or_array_layers, 1, "use encode_copy_into_at for 3d textures" ); @@ -207,7 +207,7 @@ impl RowPaddedBuffer { /// The copy will not be performed until the encoded command buffer is submitted. pub fn encode_copy_from(&self, encoder: &mut wgpu::CommandEncoder, source: &wgpu::Texture) { assert_eq!( - source.extent().depth, + source.extent().depth_or_array_layers, 1, "use encode_copy_from_at for 3d textures" ); @@ -235,8 +235,8 @@ impl RowPaddedBuffer { texture: &'t wgpu::Texture, depth: u32, ) -> ( - wgpu::BufferCopyView<'s>, - wgpu::TextureCopyView<'t>, + wgpu::ImageCopyBuffer<'s>, + wgpu::ImageCopyTexture<'t>, wgpu::Extent3d, ) { let format_size_bytes = wgpu::texture_format_size_bytes(texture.format()); @@ -256,21 +256,24 @@ impl RowPaddedBuffer { self.height, "buffer is the wrong height" ); - assert!(depth <= texture.extent().depth, "texture not deep enough"); + assert!( + depth <= texture.extent().depth_or_array_layers, + "texture not deep enough" + ); let mut copy_size = texture.extent(); - copy_size.depth = 1; + copy_size.depth_or_array_layers = 1; - let buffer_view = wgpu::BufferCopyView { + let buffer_view = wgpu::ImageCopyBuffer { buffer: &self.buffer, // note: this is the layout of *this buffer*. - layout: wgpu::TextureDataLayout { + layout: wgpu::ImageDataLayout { offset: 0, - bytes_per_row: self.padded_width(), - rows_per_image: self.height, + bytes_per_row: std::num::NonZeroU32::new(self.padded_width()), + rows_per_image: std::num::NonZeroU32::new(self.height), }, }; - let texture_view = wgpu::TextureCopyView { + let texture_view = wgpu::ImageCopyTexture { texture, mip_level: 0, // TODO(jhg): should we handle this? origin: wgpu::Origin3d { diff --git a/nannou_isf/src/pipeline.rs b/nannou_isf/src/pipeline.rs index b9b09f3c2..7cc408c99 100644 --- a/nannou_isf/src/pipeline.rs +++ b/nannou_isf/src/pipeline.rs @@ -897,7 +897,7 @@ fn create_render_pipeline( wgpu::RenderPipelineBuilder::from_layout(layout, &vs_mod) .fragment_shader(fs_mod) .color_format(dst_format) - .add_vertex_buffer::(&wgpu::vertex_attr_array![0 => Float2]) + .add_vertex_buffer::(&wgpu::vertex_attr_array![0 => Float32x2]) .sample_count(sample_count) .primitive_topology(wgpu::PrimitiveTopology::TriangleStrip) .build(device) diff --git a/nannou_timeline/Cargo.toml b/nannou_timeline/Cargo.toml index 424409c9e..80758e1fd 100644 --- a/nannou_timeline/Cargo.toml +++ b/nannou_timeline/Cargo.toml @@ -10,8 +10,8 @@ repository = "https://github.com/nannou-org/nannou_timeline.git" homepage = "https://nannou.cc" [dependencies] -conrod_derive = "0.72" -conrod_core = "0.72" +conrod_derive = "0.73" +conrod_core = "0.73" envelope = "0.8" itertools = "0.4.16" num = "0.1.27"