From 44118263b5de7bc32f6280ee3d1dc170a9b034d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Mon, 31 Aug 2020 14:41:41 +0200 Subject: [PATCH] Add labels to `iced_wgpu` internals --- wgpu/src/image.rs | 22 +++++++++++----------- wgpu/src/image/atlas.rs | 6 +++--- wgpu/src/quad.rs | 16 ++++++++-------- wgpu/src/triangle.rs | 20 +++++++++++++------- wgpu/src/triangle/msaa.rs | 16 ++++++++-------- wgpu/src/window/compositor.rs | 4 +++- 6 files changed, 46 insertions(+), 38 deletions(-) diff --git a/wgpu/src/image.rs b/wgpu/src/image.rs index 814eefea..891dba1e 100644 --- a/wgpu/src/image.rs +++ b/wgpu/src/image.rs @@ -56,7 +56,7 @@ impl Pipeline { let constant_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { - label: None, + label: Some("iced_wgpu::image constants layout"), entries: &[ wgpu::BindGroupLayoutEntry { binding: 0, @@ -79,7 +79,7 @@ impl Pipeline { }); let uniforms_buffer = device.create_buffer(&wgpu::BufferDescriptor { - label: None, + label: Some("iced_wgpu::image uniforms buffer"), size: mem::size_of::() as u64, usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST, mapped_at_creation: false, @@ -87,7 +87,7 @@ impl Pipeline { let constant_bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor { - label: None, + label: Some("iced_wgpu::image constants bind group"), layout: &constant_layout, entries: &[ wgpu::BindGroupEntry { @@ -105,7 +105,7 @@ impl Pipeline { let texture_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { - label: None, + label: Some("iced_wgpu::image texture atlas layout"), entries: &[wgpu::BindGroupLayoutEntry { binding: 0, visibility: wgpu::ShaderStage::FRAGMENT, @@ -120,7 +120,7 @@ impl Pipeline { let layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { - label: None, + label: Some("iced_wgpu::image pipeline layout"), push_constant_ranges: &[], bind_group_layouts: &[&constant_layout, &texture_layout], }); @@ -135,7 +135,7 @@ impl Pipeline { let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { - label: None, + label: Some("iced_wgpu::image pipeline"), layout: Some(&layout), vertex_stage: wgpu::ProgrammableStageDescriptor { module: &vs_module, @@ -218,20 +218,20 @@ impl Pipeline { let vertices = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { - label: None, + label: Some("iced_wgpu::image vertex buffer"), contents: QUAD_VERTS.as_bytes(), usage: wgpu::BufferUsage::VERTEX, }); let indices = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { - label: None, + label: Some("iced_wgpu::image index buffer"), contents: QUAD_INDICES.as_bytes(), usage: wgpu::BufferUsage::INDEX, }); let instances = device.create_buffer(&wgpu::BufferDescriptor { - label: None, + label: Some("iced_wgpu::image instance buffer"), size: mem::size_of::() as u64 * Instance::MAX as u64, usage: wgpu::BufferUsage::VERTEX | wgpu::BufferUsage::COPY_DST, mapped_at_creation: false, @@ -240,7 +240,7 @@ impl Pipeline { let texture_atlas = Atlas::new(device); let texture = device.create_bind_group(&wgpu::BindGroupDescriptor { - label: None, + label: Some("iced_wgpu::image texture atlas bind group"), layout: &texture_layout, entries: &[wgpu::BindGroupEntry { binding: 0, @@ -362,7 +362,7 @@ impl Pipeline { self.texture = device.create_bind_group(&wgpu::BindGroupDescriptor { - label: None, + label: Some("iced_wgpu::image texture atlas bind group"), layout: &self.texture_layout, entries: &[wgpu::BindGroupEntry { binding: 0, diff --git a/wgpu/src/image/atlas.rs b/wgpu/src/image/atlas.rs index 69f872e8..660ebe44 100644 --- a/wgpu/src/image/atlas.rs +++ b/wgpu/src/image/atlas.rs @@ -28,7 +28,7 @@ impl Atlas { }; let texture = device.create_texture(&wgpu::TextureDescriptor { - label: None, + label: Some("iced_wgpu::image texture atlas"), size: extent, mip_level_count: 1, sample_count: 1, @@ -103,7 +103,7 @@ impl Atlas { let buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { - label: None, + label: Some("iced_wgpu::image staging buffer"), contents: &padded_data, usage: wgpu::BufferUsage::COPY_SRC, }); @@ -330,7 +330,7 @@ impl Atlas { } let new_texture = device.create_texture(&wgpu::TextureDescriptor { - label: None, + label: Some("iced_wgpu::image texture atlas"), size: wgpu::Extent3d { width: SIZE, height: SIZE, diff --git a/wgpu/src/quad.rs b/wgpu/src/quad.rs index 0c54db15..d54f2577 100644 --- a/wgpu/src/quad.rs +++ b/wgpu/src/quad.rs @@ -20,7 +20,7 @@ impl Pipeline { pub fn new(device: &wgpu::Device, format: wgpu::TextureFormat) -> Pipeline { let constant_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { - label: None, + label: Some("iced_wgpu::quad uniforms layout"), entries: &[wgpu::BindGroupLayoutEntry { binding: 0, visibility: wgpu::ShaderStage::VERTEX, @@ -35,14 +35,14 @@ impl Pipeline { }); let constants_buffer = device.create_buffer(&wgpu::BufferDescriptor { - label: None, + label: Some("iced_wgpu::quad uniforms buffer"), size: mem::size_of::() as u64, usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST, mapped_at_creation: false, }); let constants = device.create_bind_group(&wgpu::BindGroupDescriptor { - label: None, + label: Some("iced_wgpu::quad uniforms bind group"), layout: &constant_layout, entries: &[wgpu::BindGroupEntry { binding: 0, @@ -54,7 +54,7 @@ impl Pipeline { let layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { - label: None, + label: Some("iced_wgpu::quad pipeline layout"), push_constant_ranges: &[], bind_group_layouts: &[&constant_layout], }); @@ -67,7 +67,7 @@ impl Pipeline { let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { - label: None, + label: Some("iced_wgpu::quad pipeline"), layout: Some(&layout), vertex_stage: wgpu::ProgrammableStageDescriptor { module: &vs_module, @@ -155,20 +155,20 @@ impl Pipeline { let vertices = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { - label: None, + label: Some("iced_wgpu::quad vertex buffer"), contents: QUAD_VERTS.as_bytes(), usage: wgpu::BufferUsage::VERTEX, }); let indices = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { - label: None, + label: Some("iced_wgpu::quad index buffer"), contents: QUAD_INDICES.as_bytes(), usage: wgpu::BufferUsage::INDEX, }); let instances = device.create_buffer(&wgpu::BufferDescriptor { - label: None, + label: Some("iced_wgpu::quad instance buffer"), size: mem::size_of::() as u64 * MAX_INSTANCES as u64, usage: wgpu::BufferUsage::VERTEX | wgpu::BufferUsage::COPY_DST, mapped_at_creation: false, diff --git a/wgpu/src/triangle.rs b/wgpu/src/triangle.rs index ed6af0ff..53ce454b 100644 --- a/wgpu/src/triangle.rs +++ b/wgpu/src/triangle.rs @@ -25,6 +25,7 @@ pub(crate) struct Pipeline { #[derive(Debug)] struct Buffer { + label: &'static str, raw: wgpu::Buffer, size: usize, usage: wgpu::BufferUsage, @@ -33,18 +34,20 @@ struct Buffer { impl Buffer { pub fn new( + label: &'static str, device: &wgpu::Device, size: usize, usage: wgpu::BufferUsage, ) -> Self { let raw = device.create_buffer(&wgpu::BufferDescriptor { - label: None, + label: Some(label), size: (std::mem::size_of::() * size) as u64, usage, mapped_at_creation: false, }); Buffer { + label, raw, size, usage, @@ -57,7 +60,7 @@ impl Buffer { if needs_resize { self.raw = device.create_buffer(&wgpu::BufferDescriptor { - label: None, + label: Some(self.label), size: (std::mem::size_of::() * size) as u64, usage: self.usage, mapped_at_creation: false, @@ -78,7 +81,7 @@ impl Pipeline { ) -> Pipeline { let constants_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { - label: None, + label: Some("iced_wgpu::triangle uniforms layout"), entries: &[wgpu::BindGroupLayoutEntry { binding: 0, visibility: wgpu::ShaderStage::VERTEX, @@ -93,6 +96,7 @@ impl Pipeline { }); let constants_buffer = Buffer::new( + "iced_wgpu::triangle uniforms buffer", device, UNIFORM_BUFFER_SIZE, wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST, @@ -100,7 +104,7 @@ impl Pipeline { let constant_bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor { - label: None, + label: Some("iced_wgpu::triangle uniforms bind group"), layout: &constants_layout, entries: &[wgpu::BindGroupEntry { binding: 0, @@ -114,7 +118,7 @@ impl Pipeline { let layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { - label: None, + label: Some("iced_wgpu::triangle pipeline layout"), push_constant_ranges: &[], bind_group_layouts: &[&constants_layout], }); @@ -129,7 +133,7 @@ impl Pipeline { let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { - label: None, + label: Some("iced_wgpu::triangle pipeline"), layout: Some(&layout), vertex_stage: wgpu::ProgrammableStageDescriptor { module: &vs_module, @@ -195,11 +199,13 @@ impl Pipeline { constants: constant_bind_group, uniforms_buffer: constants_buffer, vertex_buffer: Buffer::new( + "iced_wgpu::triangle vertex buffer", device, VERTEX_BUFFER_SIZE, wgpu::BufferUsage::VERTEX | wgpu::BufferUsage::COPY_DST, ), index_buffer: Buffer::new( + "iced_wgpu::triangle index buffer", device, INDEX_BUFFER_SIZE, wgpu::BufferUsage::INDEX | wgpu::BufferUsage::COPY_DST, @@ -241,7 +247,7 @@ impl Pipeline { if self.uniforms_buffer.expand(device, meshes.len()) { self.constants = device.create_bind_group(&wgpu::BindGroupDescriptor { - label: None, + label: Some("iced_wgpu::triangle uniforms buffer"), layout: &self.constants_layout, entries: &[wgpu::BindGroupEntry { binding: 0, diff --git a/wgpu/src/triangle/msaa.rs b/wgpu/src/triangle/msaa.rs index 14560281..db86f748 100644 --- a/wgpu/src/triangle/msaa.rs +++ b/wgpu/src/triangle/msaa.rs @@ -28,7 +28,7 @@ impl Blit { let constant_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { - label: None, + label: Some("iced_wgpu::triangle:msaa uniforms layout"), entries: &[wgpu::BindGroupLayoutEntry { binding: 0, visibility: wgpu::ShaderStage::FRAGMENT, @@ -39,7 +39,7 @@ impl Blit { let constant_bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor { - label: None, + label: Some("iced_wgpu::triangle::msaa uniforms bind group"), layout: &constant_layout, entries: &[wgpu::BindGroupEntry { binding: 0, @@ -49,7 +49,7 @@ impl Blit { let texture_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { - label: None, + label: Some("iced_wgpu::triangle::msaa texture layout"), entries: &[wgpu::BindGroupLayoutEntry { binding: 0, visibility: wgpu::ShaderStage::FRAGMENT, @@ -64,7 +64,7 @@ impl Blit { let layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { - label: None, + label: Some("iced_wgpu::triangle::msaa pipeline layout"), push_constant_ranges: &[], bind_group_layouts: &[&constant_layout, &texture_layout], }); @@ -79,7 +79,7 @@ impl Blit { let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { - label: None, + label: Some("iced_wgpu::triangle::msaa pipeline"), layout: Some(&layout), vertex_stage: wgpu::ProgrammableStageDescriptor { module: &vs_module, @@ -221,7 +221,7 @@ impl Targets { }; let attachment = device.create_texture(&wgpu::TextureDescriptor { - label: None, + label: Some("iced_wgpu::triangle::msaa attachment"), size: extent, mip_level_count: 1, sample_count, @@ -231,7 +231,7 @@ impl Targets { }); let resolve = device.create_texture(&wgpu::TextureDescriptor { - label: None, + label: Some("iced_wgpu::triangle::msaa resolve target"), size: extent, mip_level_count: 1, sample_count: 1, @@ -248,7 +248,7 @@ impl Targets { resolve.create_view(&wgpu::TextureViewDescriptor::default()); let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor { - label: None, + label: Some("iced_wgpu::triangle::msaa texture bind group"), layout: texture_layout, entries: &[wgpu::BindGroupEntry { binding: 0, diff --git a/wgpu/src/window/compositor.rs b/wgpu/src/window/compositor.rs index 0c94c281..c790f35f 100644 --- a/wgpu/src/window/compositor.rs +++ b/wgpu/src/window/compositor.rs @@ -131,7 +131,9 @@ impl iced_graphics::window::Compositor for Compositor { let frame = swap_chain.get_current_frame().expect("Next frame"); let mut encoder = self.device.create_command_encoder( - &wgpu::CommandEncoderDescriptor { label: None }, + &wgpu::CommandEncoderDescriptor { + label: Some("iced_wgpu encoder"), + }, ); let _ = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {