Add labels to `iced_wgpu` internals

This commit is contained in:
Héctor Ramón Jiménez 2020-08-31 14:41:41 +02:00
parent 07880c392c
commit 44118263b5
6 changed files with 46 additions and 38 deletions

View File

@ -56,7 +56,7 @@ impl Pipeline {
let constant_layout = let constant_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: None, label: Some("iced_wgpu::image constants layout"),
entries: &[ entries: &[
wgpu::BindGroupLayoutEntry { wgpu::BindGroupLayoutEntry {
binding: 0, binding: 0,
@ -79,7 +79,7 @@ impl Pipeline {
}); });
let uniforms_buffer = device.create_buffer(&wgpu::BufferDescriptor { let uniforms_buffer = device.create_buffer(&wgpu::BufferDescriptor {
label: None, label: Some("iced_wgpu::image uniforms buffer"),
size: mem::size_of::<Uniforms>() as u64, size: mem::size_of::<Uniforms>() as u64,
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST, usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
mapped_at_creation: false, mapped_at_creation: false,
@ -87,7 +87,7 @@ impl Pipeline {
let constant_bind_group = let constant_bind_group =
device.create_bind_group(&wgpu::BindGroupDescriptor { device.create_bind_group(&wgpu::BindGroupDescriptor {
label: None, label: Some("iced_wgpu::image constants bind group"),
layout: &constant_layout, layout: &constant_layout,
entries: &[ entries: &[
wgpu::BindGroupEntry { wgpu::BindGroupEntry {
@ -105,7 +105,7 @@ impl Pipeline {
let texture_layout = let texture_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: None, label: Some("iced_wgpu::image texture atlas layout"),
entries: &[wgpu::BindGroupLayoutEntry { entries: &[wgpu::BindGroupLayoutEntry {
binding: 0, binding: 0,
visibility: wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::FRAGMENT,
@ -120,7 +120,7 @@ impl Pipeline {
let layout = let layout =
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: Some("iced_wgpu::image pipeline layout"),
push_constant_ranges: &[], push_constant_ranges: &[],
bind_group_layouts: &[&constant_layout, &texture_layout], bind_group_layouts: &[&constant_layout, &texture_layout],
}); });
@ -135,7 +135,7 @@ impl Pipeline {
let pipeline = let pipeline =
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: None, label: Some("iced_wgpu::image pipeline"),
layout: Some(&layout), layout: Some(&layout),
vertex_stage: wgpu::ProgrammableStageDescriptor { vertex_stage: wgpu::ProgrammableStageDescriptor {
module: &vs_module, module: &vs_module,
@ -218,20 +218,20 @@ impl Pipeline {
let vertices = let vertices =
device.create_buffer_init(&wgpu::util::BufferInitDescriptor { device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: None, label: Some("iced_wgpu::image vertex buffer"),
contents: QUAD_VERTS.as_bytes(), contents: QUAD_VERTS.as_bytes(),
usage: wgpu::BufferUsage::VERTEX, usage: wgpu::BufferUsage::VERTEX,
}); });
let indices = let indices =
device.create_buffer_init(&wgpu::util::BufferInitDescriptor { device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: None, label: Some("iced_wgpu::image index buffer"),
contents: QUAD_INDICES.as_bytes(), contents: QUAD_INDICES.as_bytes(),
usage: wgpu::BufferUsage::INDEX, usage: wgpu::BufferUsage::INDEX,
}); });
let instances = device.create_buffer(&wgpu::BufferDescriptor { let instances = device.create_buffer(&wgpu::BufferDescriptor {
label: None, label: Some("iced_wgpu::image instance buffer"),
size: mem::size_of::<Instance>() as u64 * Instance::MAX as u64, size: mem::size_of::<Instance>() as u64 * Instance::MAX as u64,
usage: wgpu::BufferUsage::VERTEX | wgpu::BufferUsage::COPY_DST, usage: wgpu::BufferUsage::VERTEX | wgpu::BufferUsage::COPY_DST,
mapped_at_creation: false, mapped_at_creation: false,
@ -240,7 +240,7 @@ impl Pipeline {
let texture_atlas = Atlas::new(device); let texture_atlas = Atlas::new(device);
let texture = device.create_bind_group(&wgpu::BindGroupDescriptor { let texture = device.create_bind_group(&wgpu::BindGroupDescriptor {
label: None, label: Some("iced_wgpu::image texture atlas bind group"),
layout: &texture_layout, layout: &texture_layout,
entries: &[wgpu::BindGroupEntry { entries: &[wgpu::BindGroupEntry {
binding: 0, binding: 0,
@ -362,7 +362,7 @@ impl Pipeline {
self.texture = self.texture =
device.create_bind_group(&wgpu::BindGroupDescriptor { device.create_bind_group(&wgpu::BindGroupDescriptor {
label: None, label: Some("iced_wgpu::image texture atlas bind group"),
layout: &self.texture_layout, layout: &self.texture_layout,
entries: &[wgpu::BindGroupEntry { entries: &[wgpu::BindGroupEntry {
binding: 0, binding: 0,

View File

@ -28,7 +28,7 @@ impl Atlas {
}; };
let texture = device.create_texture(&wgpu::TextureDescriptor { let texture = device.create_texture(&wgpu::TextureDescriptor {
label: None, label: Some("iced_wgpu::image texture atlas"),
size: extent, size: extent,
mip_level_count: 1, mip_level_count: 1,
sample_count: 1, sample_count: 1,
@ -103,7 +103,7 @@ impl Atlas {
let buffer = let buffer =
device.create_buffer_init(&wgpu::util::BufferInitDescriptor { device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: None, label: Some("iced_wgpu::image staging buffer"),
contents: &padded_data, contents: &padded_data,
usage: wgpu::BufferUsage::COPY_SRC, usage: wgpu::BufferUsage::COPY_SRC,
}); });
@ -330,7 +330,7 @@ impl Atlas {
} }
let new_texture = device.create_texture(&wgpu::TextureDescriptor { let new_texture = device.create_texture(&wgpu::TextureDescriptor {
label: None, label: Some("iced_wgpu::image texture atlas"),
size: wgpu::Extent3d { size: wgpu::Extent3d {
width: SIZE, width: SIZE,
height: SIZE, height: SIZE,

View File

@ -20,7 +20,7 @@ impl Pipeline {
pub fn new(device: &wgpu::Device, format: wgpu::TextureFormat) -> Pipeline { pub fn new(device: &wgpu::Device, format: wgpu::TextureFormat) -> Pipeline {
let constant_layout = let constant_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: None, label: Some("iced_wgpu::quad uniforms layout"),
entries: &[wgpu::BindGroupLayoutEntry { entries: &[wgpu::BindGroupLayoutEntry {
binding: 0, binding: 0,
visibility: wgpu::ShaderStage::VERTEX, visibility: wgpu::ShaderStage::VERTEX,
@ -35,14 +35,14 @@ impl Pipeline {
}); });
let constants_buffer = device.create_buffer(&wgpu::BufferDescriptor { let constants_buffer = device.create_buffer(&wgpu::BufferDescriptor {
label: None, label: Some("iced_wgpu::quad uniforms buffer"),
size: mem::size_of::<Uniforms>() as u64, size: mem::size_of::<Uniforms>() as u64,
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST, usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
mapped_at_creation: false, mapped_at_creation: false,
}); });
let constants = device.create_bind_group(&wgpu::BindGroupDescriptor { let constants = device.create_bind_group(&wgpu::BindGroupDescriptor {
label: None, label: Some("iced_wgpu::quad uniforms bind group"),
layout: &constant_layout, layout: &constant_layout,
entries: &[wgpu::BindGroupEntry { entries: &[wgpu::BindGroupEntry {
binding: 0, binding: 0,
@ -54,7 +54,7 @@ impl Pipeline {
let layout = let layout =
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: Some("iced_wgpu::quad pipeline layout"),
push_constant_ranges: &[], push_constant_ranges: &[],
bind_group_layouts: &[&constant_layout], bind_group_layouts: &[&constant_layout],
}); });
@ -67,7 +67,7 @@ impl Pipeline {
let pipeline = let pipeline =
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: None, label: Some("iced_wgpu::quad pipeline"),
layout: Some(&layout), layout: Some(&layout),
vertex_stage: wgpu::ProgrammableStageDescriptor { vertex_stage: wgpu::ProgrammableStageDescriptor {
module: &vs_module, module: &vs_module,
@ -155,20 +155,20 @@ impl Pipeline {
let vertices = let vertices =
device.create_buffer_init(&wgpu::util::BufferInitDescriptor { device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: None, label: Some("iced_wgpu::quad vertex buffer"),
contents: QUAD_VERTS.as_bytes(), contents: QUAD_VERTS.as_bytes(),
usage: wgpu::BufferUsage::VERTEX, usage: wgpu::BufferUsage::VERTEX,
}); });
let indices = let indices =
device.create_buffer_init(&wgpu::util::BufferInitDescriptor { device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: None, label: Some("iced_wgpu::quad index buffer"),
contents: QUAD_INDICES.as_bytes(), contents: QUAD_INDICES.as_bytes(),
usage: wgpu::BufferUsage::INDEX, usage: wgpu::BufferUsage::INDEX,
}); });
let instances = device.create_buffer(&wgpu::BufferDescriptor { let instances = device.create_buffer(&wgpu::BufferDescriptor {
label: None, label: Some("iced_wgpu::quad instance buffer"),
size: mem::size_of::<layer::Quad>() as u64 * MAX_INSTANCES as u64, size: mem::size_of::<layer::Quad>() as u64 * MAX_INSTANCES as u64,
usage: wgpu::BufferUsage::VERTEX | wgpu::BufferUsage::COPY_DST, usage: wgpu::BufferUsage::VERTEX | wgpu::BufferUsage::COPY_DST,
mapped_at_creation: false, mapped_at_creation: false,

View File

@ -25,6 +25,7 @@ pub(crate) struct Pipeline {
#[derive(Debug)] #[derive(Debug)]
struct Buffer<T> { struct Buffer<T> {
label: &'static str,
raw: wgpu::Buffer, raw: wgpu::Buffer,
size: usize, size: usize,
usage: wgpu::BufferUsage, usage: wgpu::BufferUsage,
@ -33,18 +34,20 @@ struct Buffer<T> {
impl<T> Buffer<T> { impl<T> Buffer<T> {
pub fn new( pub fn new(
label: &'static str,
device: &wgpu::Device, device: &wgpu::Device,
size: usize, size: usize,
usage: wgpu::BufferUsage, usage: wgpu::BufferUsage,
) -> Self { ) -> Self {
let raw = device.create_buffer(&wgpu::BufferDescriptor { let raw = device.create_buffer(&wgpu::BufferDescriptor {
label: None, label: Some(label),
size: (std::mem::size_of::<T>() * size) as u64, size: (std::mem::size_of::<T>() * size) as u64,
usage, usage,
mapped_at_creation: false, mapped_at_creation: false,
}); });
Buffer { Buffer {
label,
raw, raw,
size, size,
usage, usage,
@ -57,7 +60,7 @@ impl<T> Buffer<T> {
if needs_resize { if needs_resize {
self.raw = device.create_buffer(&wgpu::BufferDescriptor { self.raw = device.create_buffer(&wgpu::BufferDescriptor {
label: None, label: Some(self.label),
size: (std::mem::size_of::<T>() * size) as u64, size: (std::mem::size_of::<T>() * size) as u64,
usage: self.usage, usage: self.usage,
mapped_at_creation: false, mapped_at_creation: false,
@ -78,7 +81,7 @@ impl Pipeline {
) -> Pipeline { ) -> Pipeline {
let constants_layout = let constants_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: None, label: Some("iced_wgpu::triangle uniforms layout"),
entries: &[wgpu::BindGroupLayoutEntry { entries: &[wgpu::BindGroupLayoutEntry {
binding: 0, binding: 0,
visibility: wgpu::ShaderStage::VERTEX, visibility: wgpu::ShaderStage::VERTEX,
@ -93,6 +96,7 @@ impl Pipeline {
}); });
let constants_buffer = Buffer::new( let constants_buffer = Buffer::new(
"iced_wgpu::triangle uniforms buffer",
device, device,
UNIFORM_BUFFER_SIZE, UNIFORM_BUFFER_SIZE,
wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST, wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
@ -100,7 +104,7 @@ impl Pipeline {
let constant_bind_group = let constant_bind_group =
device.create_bind_group(&wgpu::BindGroupDescriptor { device.create_bind_group(&wgpu::BindGroupDescriptor {
label: None, label: Some("iced_wgpu::triangle uniforms bind group"),
layout: &constants_layout, layout: &constants_layout,
entries: &[wgpu::BindGroupEntry { entries: &[wgpu::BindGroupEntry {
binding: 0, binding: 0,
@ -114,7 +118,7 @@ impl Pipeline {
let layout = let layout =
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: Some("iced_wgpu::triangle pipeline layout"),
push_constant_ranges: &[], push_constant_ranges: &[],
bind_group_layouts: &[&constants_layout], bind_group_layouts: &[&constants_layout],
}); });
@ -129,7 +133,7 @@ impl Pipeline {
let pipeline = let pipeline =
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: None, label: Some("iced_wgpu::triangle pipeline"),
layout: Some(&layout), layout: Some(&layout),
vertex_stage: wgpu::ProgrammableStageDescriptor { vertex_stage: wgpu::ProgrammableStageDescriptor {
module: &vs_module, module: &vs_module,
@ -195,11 +199,13 @@ impl Pipeline {
constants: constant_bind_group, constants: constant_bind_group,
uniforms_buffer: constants_buffer, uniforms_buffer: constants_buffer,
vertex_buffer: Buffer::new( vertex_buffer: Buffer::new(
"iced_wgpu::triangle vertex buffer",
device, device,
VERTEX_BUFFER_SIZE, VERTEX_BUFFER_SIZE,
wgpu::BufferUsage::VERTEX | wgpu::BufferUsage::COPY_DST, wgpu::BufferUsage::VERTEX | wgpu::BufferUsage::COPY_DST,
), ),
index_buffer: Buffer::new( index_buffer: Buffer::new(
"iced_wgpu::triangle index buffer",
device, device,
INDEX_BUFFER_SIZE, INDEX_BUFFER_SIZE,
wgpu::BufferUsage::INDEX | wgpu::BufferUsage::COPY_DST, wgpu::BufferUsage::INDEX | wgpu::BufferUsage::COPY_DST,
@ -241,7 +247,7 @@ impl Pipeline {
if self.uniforms_buffer.expand(device, meshes.len()) { if self.uniforms_buffer.expand(device, meshes.len()) {
self.constants = self.constants =
device.create_bind_group(&wgpu::BindGroupDescriptor { device.create_bind_group(&wgpu::BindGroupDescriptor {
label: None, label: Some("iced_wgpu::triangle uniforms buffer"),
layout: &self.constants_layout, layout: &self.constants_layout,
entries: &[wgpu::BindGroupEntry { entries: &[wgpu::BindGroupEntry {
binding: 0, binding: 0,

View File

@ -28,7 +28,7 @@ impl Blit {
let constant_layout = let constant_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: None, label: Some("iced_wgpu::triangle:msaa uniforms layout"),
entries: &[wgpu::BindGroupLayoutEntry { entries: &[wgpu::BindGroupLayoutEntry {
binding: 0, binding: 0,
visibility: wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::FRAGMENT,
@ -39,7 +39,7 @@ impl Blit {
let constant_bind_group = let constant_bind_group =
device.create_bind_group(&wgpu::BindGroupDescriptor { device.create_bind_group(&wgpu::BindGroupDescriptor {
label: None, label: Some("iced_wgpu::triangle::msaa uniforms bind group"),
layout: &constant_layout, layout: &constant_layout,
entries: &[wgpu::BindGroupEntry { entries: &[wgpu::BindGroupEntry {
binding: 0, binding: 0,
@ -49,7 +49,7 @@ impl Blit {
let texture_layout = let texture_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: None, label: Some("iced_wgpu::triangle::msaa texture layout"),
entries: &[wgpu::BindGroupLayoutEntry { entries: &[wgpu::BindGroupLayoutEntry {
binding: 0, binding: 0,
visibility: wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::FRAGMENT,
@ -64,7 +64,7 @@ impl Blit {
let layout = let layout =
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: Some("iced_wgpu::triangle::msaa pipeline layout"),
push_constant_ranges: &[], push_constant_ranges: &[],
bind_group_layouts: &[&constant_layout, &texture_layout], bind_group_layouts: &[&constant_layout, &texture_layout],
}); });
@ -79,7 +79,7 @@ impl Blit {
let pipeline = let pipeline =
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: None, label: Some("iced_wgpu::triangle::msaa pipeline"),
layout: Some(&layout), layout: Some(&layout),
vertex_stage: wgpu::ProgrammableStageDescriptor { vertex_stage: wgpu::ProgrammableStageDescriptor {
module: &vs_module, module: &vs_module,
@ -221,7 +221,7 @@ impl Targets {
}; };
let attachment = device.create_texture(&wgpu::TextureDescriptor { let attachment = device.create_texture(&wgpu::TextureDescriptor {
label: None, label: Some("iced_wgpu::triangle::msaa attachment"),
size: extent, size: extent,
mip_level_count: 1, mip_level_count: 1,
sample_count, sample_count,
@ -231,7 +231,7 @@ impl Targets {
}); });
let resolve = device.create_texture(&wgpu::TextureDescriptor { let resolve = device.create_texture(&wgpu::TextureDescriptor {
label: None, label: Some("iced_wgpu::triangle::msaa resolve target"),
size: extent, size: extent,
mip_level_count: 1, mip_level_count: 1,
sample_count: 1, sample_count: 1,
@ -248,7 +248,7 @@ impl Targets {
resolve.create_view(&wgpu::TextureViewDescriptor::default()); resolve.create_view(&wgpu::TextureViewDescriptor::default());
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor { let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
label: None, label: Some("iced_wgpu::triangle::msaa texture bind group"),
layout: texture_layout, layout: texture_layout,
entries: &[wgpu::BindGroupEntry { entries: &[wgpu::BindGroupEntry {
binding: 0, binding: 0,

View File

@ -131,7 +131,9 @@ impl iced_graphics::window::Compositor for Compositor {
let frame = swap_chain.get_current_frame().expect("Next frame"); let frame = swap_chain.get_current_frame().expect("Next frame");
let mut encoder = self.device.create_command_encoder( 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 { let _ = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {