diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index a1946db5a9..e345a05f8c 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -25,13 +25,13 @@ vulkan-portability = ["wgc/gfx-backend-vulkan"] [target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "01733a2f45143ee43d2a3473bc618fd06cfc076d" +rev = "42a8dc5b343b1c882d7c5bb03b0718602ea03915" features = ["raw-window-handle"] [dependencies.wgt] package = "wgpu-types" git = "https://github.com/gfx-rs/wgpu" -rev = "01733a2f45143ee43d2a3473bc618fd06cfc076d" +rev = "42a8dc5b343b1c882d7c5bb03b0718602ea03915" [dependencies] arrayvec = "0.5" diff --git a/wgpu/examples/boids/main.rs b/wgpu/examples/boids/main.rs index 9aeda25ce4..81e9e21526 100644 --- a/wgpu/examples/boids/main.rs +++ b/wgpu/examples/boids/main.rs @@ -274,6 +274,7 @@ impl framework::Example for Example { }, }]; let render_pass_descriptor = wgpu::RenderPassDescriptor { + label: None, color_attachments: &color_attachments, depth_stencil_attachment: None, }; @@ -285,7 +286,8 @@ impl framework::Example for Example { command_encoder.push_debug_group("compute boid movement"); { // compute pass - let mut cpass = command_encoder.begin_compute_pass(); + let mut cpass = + command_encoder.begin_compute_pass(&wgpu::ComputePassDescriptor { label: None }); cpass.set_pipeline(&self.compute_pipeline); cpass.set_bind_group(0, &self.particle_bind_groups[self.frame_num % 2], &[]); cpass.dispatch(self.work_group_count, 1, 1); diff --git a/wgpu/examples/capture/main.rs b/wgpu/examples/capture/main.rs index 2ce3cefcc6..7c3e42e3f9 100644 --- a/wgpu/examples/capture/main.rs +++ b/wgpu/examples/capture/main.rs @@ -81,6 +81,7 @@ async fn create_red_image_with_dimensions( let mut encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None }); encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: None, color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { attachment: &texture.create_view(&wgpu::TextureViewDescriptor::default()), resolve_target: None, diff --git a/wgpu/examples/cube/main.rs b/wgpu/examples/cube/main.rs index 867d8d6d6a..48471a3231 100644 --- a/wgpu/examples/cube/main.rs +++ b/wgpu/examples/cube/main.rs @@ -390,6 +390,7 @@ impl framework::Example for Example { device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None }); { let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: None, color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { attachment: &frame.view, resolve_target: None, diff --git a/wgpu/examples/hello-compute/main.rs b/wgpu/examples/hello-compute/main.rs index ca1cdd0789..340e03d992 100644 --- a/wgpu/examples/hello-compute/main.rs +++ b/wgpu/examples/hello-compute/main.rs @@ -131,7 +131,7 @@ async fn execute_gpu(numbers: Vec) -> Vec { let mut encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None }); { - let mut cpass = encoder.begin_compute_pass(); + let mut cpass = encoder.begin_compute_pass(&wgpu::ComputePassDescriptor { label: None }); cpass.set_pipeline(&compute_pipeline); cpass.set_bind_group(0, &bind_group, &[]); cpass.insert_debug_marker("compute collatz iterations"); diff --git a/wgpu/examples/hello-triangle/main.rs b/wgpu/examples/hello-triangle/main.rs index 6a9ff8e67d..dcbe390a5c 100644 --- a/wgpu/examples/hello-triangle/main.rs +++ b/wgpu/examples/hello-triangle/main.rs @@ -1,9 +1,9 @@ +use std::borrow::Cow; use winit::{ event::{Event, WindowEvent}, event_loop::{ControlFlow, EventLoop}, window::Window, }; -use std::borrow::Cow; async fn run(event_loop: EventLoop<()>, window: Window, swapchain_format: wgpu::TextureFormat) { let size = window.inner_size(); @@ -84,12 +84,7 @@ async fn run(event_loop: EventLoop<()>, window: Window, swapchain_format: wgpu:: // Have the closure take ownership of the resources. // `event_loop.run` never returns, therefore we must do this to ensure // the resources are properly cleaned up. - let _ = ( - &instance, - &adapter, - &shader, - &pipeline_layout, - ); + let _ = (&instance, &adapter, &shader, &pipeline_layout); *control_flow = ControlFlow::Poll; match event { @@ -111,6 +106,7 @@ async fn run(event_loop: EventLoop<()>, window: Window, swapchain_format: wgpu:: device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None }); { let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: None, color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { attachment: &frame.view, resolve_target: None, diff --git a/wgpu/examples/hello-windows/main.rs b/wgpu/examples/hello-windows/main.rs index 8d0ae174bc..74b54787c2 100644 --- a/wgpu/examples/hello-windows/main.rs +++ b/wgpu/examples/hello-windows/main.rs @@ -125,6 +125,7 @@ async fn run( .create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None }); { let _rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: None, color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { attachment: &frame.view, resolve_target: None, diff --git a/wgpu/examples/mipmap/main.rs b/wgpu/examples/mipmap/main.rs index c579c3fc19..692bc485d7 100644 --- a/wgpu/examples/mipmap/main.rs +++ b/wgpu/examples/mipmap/main.rs @@ -155,6 +155,7 @@ impl Example { }); let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: None, color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { attachment: &views[target_mip], resolve_target: None, @@ -357,6 +358,7 @@ impl framework::Example for Example { a: 1.0, }; let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: None, color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { attachment: &frame.view, resolve_target: None, diff --git a/wgpu/examples/msaa-line/main.rs b/wgpu/examples/msaa-line/main.rs index ca8e855de1..ad5256cb1d 100644 --- a/wgpu/examples/msaa-line/main.rs +++ b/wgpu/examples/msaa-line/main.rs @@ -270,6 +270,7 @@ impl framework::Example for Example { encoder .begin_render_pass(&wgpu::RenderPassDescriptor { + label: None, color_attachments: &[rpass_color_attachment], depth_stencil_attachment: None, }) diff --git a/wgpu/examples/shadow/main.rs b/wgpu/examples/shadow/main.rs index cf79576b88..8c28624049 100644 --- a/wgpu/examples/shadow/main.rs +++ b/wgpu/examples/shadow/main.rs @@ -768,6 +768,7 @@ impl framework::Example for Example { encoder.insert_debug_marker("render entities"); { let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: None, color_attachments: &[], depth_stencil_attachment: Some( wgpu::RenderPassDepthStencilAttachmentDescriptor { @@ -799,6 +800,7 @@ impl framework::Example for Example { encoder.push_debug_group("forward rendering pass"); { let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: None, color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { attachment: &frame.view, resolve_target: None, diff --git a/wgpu/examples/skybox/main.rs b/wgpu/examples/skybox/main.rs index 333d060818..fdbd829d36 100644 --- a/wgpu/examples/skybox/main.rs +++ b/wgpu/examples/skybox/main.rs @@ -276,6 +276,7 @@ impl framework::Example for Skybox { { let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: None, color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { attachment: &frame.view, resolve_target: None, diff --git a/wgpu/examples/texture-arrays/main.rs b/wgpu/examples/texture-arrays/main.rs index f02009b36b..89185fc504 100644 --- a/wgpu/examples/texture-arrays/main.rs +++ b/wgpu/examples/texture-arrays/main.rs @@ -314,6 +314,7 @@ impl framework::Example for Example { }); let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: None, color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { attachment: &frame.view, resolve_target: None, diff --git a/wgpu/examples/water/main.rs b/wgpu/examples/water/main.rs index e39227f255..df4dbbd13a 100644 --- a/wgpu/examples/water/main.rs +++ b/wgpu/examples/water/main.rs @@ -710,6 +710,7 @@ impl framework::Example for Example { // First pass: render the reflection. { let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: None, color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { attachment: &self.reflect_view, resolve_target: None, @@ -738,6 +739,7 @@ impl framework::Example for Example { // depth values, so we must use StoreOp::Store. { let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: None, color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { attachment: &frame.view, resolve_target: None, @@ -764,6 +766,7 @@ impl framework::Example for Example { // to it, so it cannot be in the same render pass. { let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: None, color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { attachment: &frame.view, resolve_target: None, diff --git a/wgpu/src/backend/direct.rs b/wgpu/src/backend/direct.rs index c15eeacec6..80086ac1e5 100644 --- a/wgpu/src/backend/direct.rs +++ b/wgpu/src/backend/direct.rs @@ -1,8 +1,8 @@ use crate::{ backend::{error::ContextError, native_gpu_future}, BindGroupDescriptor, BindGroupLayoutDescriptor, BindingResource, CommandEncoderDescriptor, - ComputePipelineDescriptor, Features, Label, Limits, LoadOp, MapMode, Operations, - PipelineLayoutDescriptor, RenderBundleEncoderDescriptor, RenderPipelineDescriptor, + ComputePassDescriptor, ComputePipelineDescriptor, Features, Label, Limits, LoadOp, MapMode, + Operations, PipelineLayoutDescriptor, RenderBundleEncoderDescriptor, RenderPipelineDescriptor, SamplerDescriptor, ShaderModuleDescriptor, ShaderSource, SwapChainStatus, TextureDescriptor, TextureViewDescriptor, }; @@ -1503,8 +1503,14 @@ impl crate::Context for Context { fn command_encoder_begin_compute_pass( &self, encoder: &Self::CommandEncoderId, + desc: &ComputePassDescriptor, ) -> Self::ComputePassId { - wgc::command::ComputePass::new(encoder.id) + wgc::command::ComputePass::new( + encoder.id, + &wgc::command::ComputePassDescriptor { + label: desc.label.map(Borrowed), + }, + ) } fn command_encoder_end_compute_pass( @@ -1553,7 +1559,8 @@ impl crate::Context for Context { wgc::command::RenderPass::new( encoder.id, - wgc::command::RenderPassDescriptor { + &wgc::command::RenderPassDescriptor { + label: desc.label.map(Borrowed), color_attachments: Borrowed(&colors), depth_stencil_attachment: depth_stencil.as_ref(), }, diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index 641651fca2..dbf18efe59 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -1,10 +1,10 @@ use crate::{ BindGroupDescriptor, BindGroupLayoutDescriptor, BindingResource, BindingType, - BufferBindingType, BufferDescriptor, CommandEncoderDescriptor, ComputePipelineDescriptor, - LoadOp, PipelineLayoutDescriptor, ProgrammableStageDescriptor, RenderBundleEncoderDescriptor, - RenderPipelineDescriptor, SamplerDescriptor, ShaderModuleDescriptor, ShaderSource, - StorageTextureAccess, SwapChainStatus, TextureDescriptor, TextureViewDescriptor, - TextureViewDimension, + BufferBindingType, BufferDescriptor, CommandEncoderDescriptor, ComputePassDescriptor, + ComputePipelineDescriptor, LoadOp, PipelineLayoutDescriptor, ProgrammableStageDescriptor, + RenderBundleEncoderDescriptor, RenderPipelineDescriptor, SamplerDescriptor, + ShaderModuleDescriptor, ShaderSource, StorageTextureAccess, SwapChainStatus, TextureDescriptor, + TextureViewDescriptor, TextureViewDimension, }; use futures::FutureExt; @@ -972,9 +972,7 @@ impl crate::Context for Context { ShaderSource::SpirV(ref spv) => { web_sys::GpuShaderModuleDescriptor::new(&js_sys::Uint32Array::from(&**spv)) } - ShaderSource::Wgsl(_) => { - panic!("WGSL is not yet supported by the Web backend") - } + ShaderSource::Wgsl(_) => panic!("WGSL is not yet supported by the Web backend"), }; if let Some(ref label) = desc.label { descriptor.label(label); @@ -1546,9 +1544,10 @@ impl crate::Context for Context { fn command_encoder_begin_compute_pass( &self, encoder: &Self::CommandEncoderId, + desc: &ComputePassDescriptor, ) -> Self::ComputePassId { let mut mapped_desc = web_sys::GpuComputePassDescriptor::new(); - if let Some(ref label) = encoder.label() { + if let Some(ref label) = desc.label { mapped_desc.label(label); } ComputePass(encoder.begin_compute_pass_with_descriptor(&mapped_desc)) diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index cf98bb414c..2191cb933b 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -359,6 +359,7 @@ trait Context: Debug + Send + Sized + Sync { fn command_encoder_begin_compute_pass( &self, encoder: &Self::CommandEncoderId, + desc: &ComputePassDescriptor, ) -> Self::ComputePassId; fn command_encoder_end_compute_pass( &self, @@ -1115,6 +1116,8 @@ pub struct ProgrammableStageDescriptor<'a> { /// Describes the attachments of a render pass. #[derive(Clone, Debug, Default)] pub struct RenderPassDescriptor<'a, 'b> { + /// Debug label of the render pass. This will show up in graphics debuggers for easy identification. + pub label: Option<&'a str>, /// The color attachments of the render pass. pub color_attachments: &'b [RenderPassColorAttachmentDescriptor<'a>], /// The depth and stencil attachment of the render pass, if any. @@ -1157,6 +1160,13 @@ pub struct RenderPipelineDescriptor<'a> { pub alpha_to_coverage_enabled: bool, } +/// Describes the attachments of a compute pass. +#[derive(Clone, Debug, Default)] +pub struct ComputePassDescriptor<'a> { + /// Debug label of the compute pass. This will show up in graphics debuggers for easy identification. + pub label: Option<&'a str>, +} + /// Describes a compute pipeline. #[derive(Clone, Debug)] pub struct ComputePipelineDescriptor<'a> { @@ -1848,9 +1858,9 @@ impl CommandEncoder { /// Begins recording of a compute pass. /// /// This function returns a [`ComputePass`] object which records a single compute pass. - pub fn begin_compute_pass(&mut self) -> ComputePass { + pub fn begin_compute_pass(&mut self, desc: &ComputePassDescriptor) -> ComputePass { ComputePass { - id: Context::command_encoder_begin_compute_pass(&*self.context, &self.id), + id: Context::command_encoder_begin_compute_pass(&*self.context, &self.id, desc), parent: self, } }