From d8341c59962278cecfa431ca61cdfa7845a73b3b Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Thu, 13 Aug 2020 12:14:19 -0400 Subject: [PATCH] Add labels to pipelines --- Cargo.lock | 2 +- player/Cargo.toml | 2 +- wgpu-core/src/device/mod.rs | 25 ++++++++++++++++--------- wgpu-core/src/pipeline.rs | 4 +++- wgpu-subscriber/Cargo.toml | 2 +- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c4a096606..0b35f9a80 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1594,7 +1594,7 @@ dependencies = [ [[package]] name = "wgpu-subscriber" -version = "0.5.0" +version = "0.1.0" dependencies = [ "parking_lot", "thread-id", diff --git a/player/Cargo.toml b/player/Cargo.toml index 9b8411faa..bf3cb4dc3 100644 --- a/player/Cargo.toml +++ b/player/Cargo.toml @@ -36,7 +36,7 @@ features = ["replay", "raw-window-handle"] [dependencies.wgpu-subscriber] path = "../wgpu-subscriber" -version = "0.5" +version = "0.1" [target.'cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))'.dependencies] gfx-backend-vulkan = { version = "0.5", features = ["x11"] } diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index 4e332e8c0..42bcbdcad 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -2878,7 +2878,7 @@ impl Global { parent, }; // TODO: cache - let pipeline = unsafe { + let raw = unsafe { device .raw .create_graphics_pipeline(&pipeline_desc, None) @@ -2887,9 +2887,12 @@ impl Global { _ => panic!("failed to create graphics pipeline: {}", err), })? }; + if let Some(_) = desc.label { + //TODO-0.6: device.set_graphics_pipeline_name(&mut raw, label) + } ( - pipeline, + raw, pipeline_layout_id, layout.life_guard.add_ref(), derived_bind_group_count, @@ -3130,20 +3133,24 @@ impl Global { parent, }; - match unsafe { device.raw.create_compute_pipeline(&pipeline_desc, None) } { - Ok(pipeline) => ( - pipeline, - pipeline_layout_id, - layout.life_guard.add_ref(), - derived_bind_group_count, - ), + let raw = match unsafe { device.raw.create_compute_pipeline(&pipeline_desc, None) } { + Ok(pipeline) => pipeline, Err(hal::pso::CreationError::OutOfMemory(_)) => { return Err(pipeline::CreateComputePipelineError::Device( DeviceError::OutOfMemory, )) } other => panic!("Compute pipeline creation error: {:?}", other), + }; + if let Some(_) = desc.label { + //TODO-0.6: device.raw.set_compute_pipeline_name(&mut raw, label); } + ( + raw, + pipeline_layout_id, + layout.life_guard.add_ref(), + derived_bind_group_count, + ) }; let pipeline = pipeline::ComputePipeline { diff --git a/wgpu-core/src/pipeline.rs b/wgpu-core/src/pipeline.rs index a41b2ebac..0db85a69a 100644 --- a/wgpu-core/src/pipeline.rs +++ b/wgpu-core/src/pipeline.rs @@ -7,7 +7,7 @@ use crate::{ device::{DeviceError, RenderPassContext}, id::{DeviceId, PipelineLayoutId, ShaderModuleId}, validation::StageError, - LifeGuard, RefCount, Stored, + Label, LifeGuard, RefCount, Stored, }; use std::borrow::{Borrow, Cow}; use thiserror::Error; @@ -68,6 +68,7 @@ pub enum ImplicitLayoutError { #[cfg_attr(feature = "trace", derive(serde::Serialize))] #[cfg_attr(feature = "replay", derive(serde::Deserialize))] pub struct ComputePipelineDescriptor<'a> { + pub label: Label<'a>, /// The layout of bind groups for this pipeline. pub layout: Option, /// The compiled compute stage and its entry point. @@ -129,6 +130,7 @@ pub struct VertexStateDescriptor<'a> { #[cfg_attr(feature = "trace", derive(serde::Serialize))] #[cfg_attr(feature = "replay", derive(serde::Deserialize))] pub struct RenderPipelineDescriptor<'a> { + pub label: Label<'a>, /// The layout of bind groups for this pipeline. pub layout: Option, /// The compiled vertex stage and its entry point. diff --git a/wgpu-subscriber/Cargo.toml b/wgpu-subscriber/Cargo.toml index 99e305db3..67153bef1 100644 --- a/wgpu-subscriber/Cargo.toml +++ b/wgpu-subscriber/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wgpu-subscriber" -version = "0.5.0" +version = "0.1.0" authors = ["wgpu developers"] edition = "2018" description = "WebGPU tracing subscriber"