Skip to content

Commit

Permalink
Add a separate pipeline constants error (#6094)
Browse files Browse the repository at this point in the history
  • Loading branch information
teoxoy authored Aug 12, 2024
1 parent 28e15dc commit 94f54b3
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 4 deletions.
6 changes: 6 additions & 0 deletions wgpu-core/src/device/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2762,6 +2762,9 @@ impl<A: HalApi> Device<A> {
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 {
Expand Down Expand Up @@ -3343,6 +3346,9 @@ impl<A: HalApi> Device<A> {
error: ENTRYPOINT_FAILURE_ERROR.to_string(),
}
}
hal::PipelineError::PipelineConstants(stage, error) => {
pipeline::CreateRenderPipelineError::PipelineConstants { stage, error }
}
})?;

let pass_context = RenderPassContext {
Expand Down
7 changes: 7 additions & 0 deletions wgpu-core/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down Expand Up @@ -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.")]
Expand Down
2 changes: 1 addition & 1 deletion wgpu-hal/src/dx12/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion wgpu-hal/src/gles/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions wgpu-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion wgpu-hal/src/metal/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
4 changes: 3 additions & 1 deletion wgpu-hal/src/vulkan/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 94f54b3

Please sign in to comment.