From 73fb9ea6bc3ca5d4393c53dbfa1feaf4d5cfdbc7 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Mon, 21 Sep 2026 19:47:51 -0700 Subject: [PATCH] [hal]: Document pipeline creation lifetime requirements. --- wgpu-hal/src/lib.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/wgpu-hal/src/lib.rs b/wgpu-hal/src/lib.rs index 1695eacc3..a6ba1c000 100644 --- a/wgpu-hal/src/lib.rs +++ b/wgpu-hal/src/lib.rs @@ -1107,6 +1107,12 @@ pub trait Device: WasmNotSendSync { ) -> Result<::ShaderModule, ShaderError>; unsafe fn destroy_shader_module(&self, module: ::ShaderModule); + /// Create a render pipeline according to `desc`. + /// + /// The returned pipeline's lifetime is independent of that of + /// `desc.layout`, `desc.cache`, and all the shader modules in any + /// [`ProgrammableStage`] values in `desc`. The pipeline is safe to use even + /// after those resources have been destroyed. #[allow(clippy::type_complexity)] unsafe fn create_render_pipeline( &self, @@ -1118,6 +1124,11 @@ pub trait Device: WasmNotSendSync { ) -> Result<::RenderPipeline, PipelineError>; unsafe fn destroy_render_pipeline(&self, pipeline: ::RenderPipeline); + /// Create a compute pipeline according to `desc`. + /// + /// The returned pipeline's lifetime is independent of that of + /// `desc.layout`, `desc.stage.module`, and `desc.cache`. The pipeline is + /// safe to use even after those resources have been destroyed. #[allow(clippy::type_complexity)] unsafe fn create_compute_pipeline( &self, @@ -1129,6 +1140,12 @@ pub trait Device: WasmNotSendSync { ) -> Result<::ComputePipeline, PipelineError>; unsafe fn destroy_compute_pipeline(&self, pipeline: ::ComputePipeline); + /// Create a ray tracing pipeline according to `desc`. + /// + /// The returned pipeline's lifetime is independent of that of + /// `desc.layout`, `desc.cache`, and all the shader modules in any + /// [`ProgrammableStage`] values in `desc`. The pipeline is safe to use even + /// after those resources have been destroyed. #[allow(clippy::type_complexity)] unsafe fn create_ray_tracing_pipeline( &self,