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 =
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::<Uniforms>() 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::<Instance>() 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,

View File

@ -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,

View File

@ -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::<Uniforms>() 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::<layer::Quad>() as u64 * MAX_INSTANCES as u64,
usage: wgpu::BufferUsage::VERTEX | wgpu::BufferUsage::COPY_DST,
mapped_at_creation: false,

View File

@ -25,6 +25,7 @@ pub(crate) struct Pipeline {
#[derive(Debug)]
struct Buffer<T> {
label: &'static str,
raw: wgpu::Buffer,
size: usize,
usage: wgpu::BufferUsage,
@ -33,18 +34,20 @@ struct Buffer<T> {
impl<T> Buffer<T> {
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::<T>() * size) as u64,
usage,
mapped_at_creation: false,
});
Buffer {
label,
raw,
size,
usage,
@ -57,7 +60,7 @@ impl<T> Buffer<T> {
if needs_resize {
self.raw = device.create_buffer(&wgpu::BufferDescriptor {
label: None,
label: Some(self.label),
size: (std::mem::size_of::<T>() * 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,

View File

@ -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,

View File

@ -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 {