diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index 463ede2cd..621149404 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -2762,6 +2762,9 @@ impl Device { hal::PipelineError::EntryPoint(_stage) => { pipeline::CreateComputePipelineError::Internal(ENTRYPOINT_FAILURE_ERROR.to_string()) } + hal::PipelineError::PipelineConstants(_stages, msg) => { + pipeline::CreateComputePipelineError::PipelineConstants(msg) + } })?; let pipeline = pipeline::ComputePipeline { @@ -3343,6 +3346,9 @@ impl Device { error: ENTRYPOINT_FAILURE_ERROR.to_string(), } } + hal::PipelineError::PipelineConstants(stage, error) => { + pipeline::CreateRenderPipelineError::PipelineConstants { stage, error } + } })?; let pass_context = RenderPassContext { diff --git a/wgpu-core/src/pipeline.rs b/wgpu-core/src/pipeline.rs index da0a47eee..68e92ca4b 100644 --- a/wgpu-core/src/pipeline.rs +++ b/wgpu-core/src/pipeline.rs @@ -234,6 +234,8 @@ pub enum CreateComputePipelineError { Stage(#[from] validation::StageError), #[error("Internal error: {0}")] Internal(String), + #[error("Pipeline constant error: {0}")] + PipelineConstants(String), #[error(transparent)] MissingDownlevelFlags(#[from] MissingDownlevelFlags), } @@ -525,6 +527,11 @@ pub enum CreateRenderPipelineError { stage: wgt::ShaderStages, error: String, }, + #[error("Pipeline constant error in {stage:?} shader: {error}")] + PipelineConstants { + stage: wgt::ShaderStages, + error: String, + }, #[error("In the provided shader, the type given for group {group} binding {binding} has a size of {size}. As the device does not support `DownlevelFlags::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED`, the type must have a size that is a multiple of 16 bytes.")] UnalignedShader { group: u32, binding: u32, size: u64 }, #[error("Using the blend factor {factor:?} for render target {target} is not possible. Only the first render target may be used when dual-source blending.")] diff --git a/wgpu-hal/src/dx12/device.rs b/wgpu-hal/src/dx12/device.rs index 8012086a9..b3204a8cc 100644 --- a/wgpu-hal/src/dx12/device.rs +++ b/wgpu-hal/src/dx12/device.rs @@ -234,7 +234,7 @@ impl super::Device { &stage.module.naga.info, stage.constants, ) - .map_err(|e| crate::PipelineError::Linkage(stage_bit, format!("HLSL: {e:?}")))?; + .map_err(|e| crate::PipelineError::PipelineConstants(stage_bit, format!("HLSL: {e:?}")))?; let needs_temp_options = stage.zero_initialize_workgroup_memory != layout.naga_options.zero_initialize_workgroup_memory; diff --git a/wgpu-hal/src/gles/device.rs b/wgpu-hal/src/gles/device.rs index 0f8c381b5..77c08c8ce 100644 --- a/wgpu-hal/src/gles/device.rs +++ b/wgpu-hal/src/gles/device.rs @@ -223,7 +223,7 @@ impl super::Device { ) .map_err(|e| { let msg = format!("{e}"); - crate::PipelineError::Linkage(map_naga_stage(naga_stage), msg) + crate::PipelineError::PipelineConstants(map_naga_stage(naga_stage), msg) })?; let entry_point_index = module diff --git a/wgpu-hal/src/lib.rs b/wgpu-hal/src/lib.rs index 9b6d49135..bd60b029e 100644 --- a/wgpu-hal/src/lib.rs +++ b/wgpu-hal/src/lib.rs @@ -321,6 +321,8 @@ pub enum PipelineError { EntryPoint(naga::ShaderStage), #[error(transparent)] Device(#[from] DeviceError), + #[error("Pipeline constant error for stage {0:?}: {1}")] + PipelineConstants(wgt::ShaderStages, String), } #[derive(Clone, Debug, Eq, PartialEq, Error)] diff --git a/wgpu-hal/src/metal/device.rs b/wgpu-hal/src/metal/device.rs index 18b9c2dba..4ca392bc1 100644 --- a/wgpu-hal/src/metal/device.rs +++ b/wgpu-hal/src/metal/device.rs @@ -112,7 +112,7 @@ impl super::Device { &stage.module.naga.info, stage.constants, ) - .map_err(|e| crate::PipelineError::Linkage(stage_bit, format!("MSL: {:?}", e)))?; + .map_err(|e| crate::PipelineError::PipelineConstants(stage_bit, format!("MSL: {:?}", e)))?; let ep_resources = &layout.per_stage_map[naga_stage]; diff --git a/wgpu-hal/src/vulkan/device.rs b/wgpu-hal/src/vulkan/device.rs index 2f2e045fd..a71263df5 100644 --- a/wgpu-hal/src/vulkan/device.rs +++ b/wgpu-hal/src/vulkan/device.rs @@ -764,7 +764,9 @@ impl super::Device { &naga_shader.info, stage.constants, ) - .map_err(|e| crate::PipelineError::Linkage(stage_flags, format!("{e}")))?; + .map_err(|e| { + crate::PipelineError::PipelineConstants(stage_flags, format!("{e}")) + })?; let spv = { profiling::scope!("naga::spv::write_vec");