mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-21 23:11:01 +01:00
[core] Include the shader stage in MissingEntryPoint errors. (#10544)
This commit is contained in:
1 parent
3050396df2
commit
28a16856de
3 files changed
+45
-25
No files matched your search
@@ -188,6 +188,7 @@ By @sagudev in [#10307](https://github.com/gfx-rs/wgpu/pull/10307).
|
||||
- `BufferUsages` is now composed of `BufferUsagesWebGPU` and `BufferUsagesWGPU`, similarly to `Features`. In most cases this is not expected to be a breaking change, but changes might be required for converting `BufferUsages` to/from `u32`. By @sagudev in [#10195](https://github.com/gfx-rs/wgpu/pull/10195).
|
||||
- `ShaderStages` is now composed of `ShaderStagesWebGPU` and `ShaderStagesWGPU`, similarly to `Features`. In most cases this is not expected to be a breaking change, but changes might be required for converting `ShaderStages` to/from `u32`. By @sagudev in [#10313](https://github.com/gfx-rs/wgpu/pull/10313).
|
||||
- `request_adapter` will return error on `InstanceFlags::STRICT_WEBGPU_COMPLIANCE` if the adapter has already been consumed by a previous `request_device`. By @sagudev in [#10444](https://github.com/gfx-rs/wgpu/pull/10444).
|
||||
- The variants of `wgpu_core::validation::StageError` related to entry point selection have been reorganized. By @jimblandy in [#10544](https://github.com/gfx-rs/wgpu/pull/10544).
|
||||
|
||||
#### naga
|
||||
|
||||
|
||||
@@ -179,19 +179,19 @@ fn finalize_passthrough_entry_point_name(
|
||||
return if interface.entry_point_names.contains(ep) {
|
||||
Ok(ep.to_owned())
|
||||
} else {
|
||||
Err(validation::StageError::MissingEntryPoint(ep.to_owned()))
|
||||
Err(validation::StageError::NoEntryPointWithName(ep.to_owned()))
|
||||
};
|
||||
}
|
||||
|
||||
match interface.entry_point_names.len() {
|
||||
0 => Err(validation::StageError::NoEntryPointFound),
|
||||
0 => Err(validation::StageError::NoEntryPoints),
|
||||
1 => Ok(interface
|
||||
.entry_point_names
|
||||
.iter()
|
||||
.next()
|
||||
.unwrap()
|
||||
.to_owned()),
|
||||
_ => Err(validation::StageError::MultipleEntryPointsFound),
|
||||
_ => Err(validation::StageError::AmbiguousEntryPoint),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1326,7 +1326,7 @@ mod tests {
|
||||
let empty = passthrough_interface(&[]);
|
||||
assert!(matches!(
|
||||
finalize_passthrough_entry_point_name(&empty, None),
|
||||
Err(validation::StageError::NoEntryPointFound)
|
||||
Err(validation::StageError::NoEntryPoints)
|
||||
));
|
||||
|
||||
let single = passthrough_interface(&["main"]);
|
||||
@@ -1338,7 +1338,7 @@ mod tests {
|
||||
let multiple = passthrough_interface(&["vertex", "fragment"]);
|
||||
assert!(matches!(
|
||||
finalize_passthrough_entry_point_name(&multiple, None),
|
||||
Err(validation::StageError::MultipleEntryPointsFound)
|
||||
Err(validation::StageError::AmbiguousEntryPoint)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1351,7 +1351,7 @@ mod tests {
|
||||
);
|
||||
assert!(matches!(
|
||||
finalize_passthrough_entry_point_name(&interface, Some("missing")),
|
||||
Err(validation::StageError::MissingEntryPoint(name)) if name == "missing"
|
||||
Err(validation::StageError::NoEntryPointWithName(name)) if name == "missing"
|
||||
));
|
||||
}
|
||||
}
|
||||
+38
-19
@@ -515,10 +515,29 @@ impl WebGpuError for InputError {
|
||||
#[derive(Clone, Debug, Error)]
|
||||
#[non_exhaustive]
|
||||
pub enum StageError {
|
||||
#[error("Unable to find entry point {0:?}")]
|
||||
NoEntryPointWithName(String),
|
||||
#[error("Unable to find entry point `{name}` for stage `{stage:?}`")]
|
||||
NoEntryPointWithNameForStage {
|
||||
name: String,
|
||||
stage: naga::ShaderStage,
|
||||
},
|
||||
#[error(
|
||||
"Unable to select an entry point: no entry points found in the provided shader module"
|
||||
)]
|
||||
NoEntryPoints,
|
||||
#[error("No entry point found for stage `{0:?}`")]
|
||||
NoEntryPointForStage(naga::ShaderStage),
|
||||
#[error(
|
||||
"Unable to select an entry point: \
|
||||
multiple entry points were found in the provided shader module, \
|
||||
but no entry point was specified"
|
||||
)]
|
||||
AmbiguousEntryPoint,
|
||||
#[error("More than one entry point present in module for stage `{0:?}`, entry point name must be provided")]
|
||||
AmbiguousEntryPointForStage(naga::ShaderStage),
|
||||
#[error(transparent)]
|
||||
InvalidWorkgroupSize(#[from] InvalidWorkgroupSizeError),
|
||||
#[error("Unable to find entry point '{0}'")]
|
||||
MissingEntryPoint(String),
|
||||
#[error("Shader global {0:?} is not available in the pipeline layout")]
|
||||
Binding(naga::ResourceBinding, #[source] BindingError),
|
||||
#[error("Unable to filter the texture ({texture:?}) by the sampler ({sampler:?})")]
|
||||
@@ -535,16 +554,6 @@ pub enum StageError {
|
||||
#[source]
|
||||
error: InputError,
|
||||
},
|
||||
#[error(
|
||||
"Unable to select an entry point: no entry point was found in the provided shader module"
|
||||
)]
|
||||
NoEntryPointFound,
|
||||
#[error(
|
||||
"Unable to select an entry point: \
|
||||
multiple entry points were found in the provided shader module, \
|
||||
but no entry point was specified"
|
||||
)]
|
||||
MultipleEntryPointsFound,
|
||||
#[error(transparent)]
|
||||
InvalidResource(#[from] InvalidResourceError),
|
||||
#[error(
|
||||
@@ -648,10 +657,13 @@ impl WebGpuError for StageError {
|
||||
var: _,
|
||||
error,
|
||||
} => error.webgpu_error_type(),
|
||||
Self::InvalidWorkgroupSize { .. }
|
||||
| Self::MissingEntryPoint(..)
|
||||
| Self::NoEntryPointFound
|
||||
| Self::MultipleEntryPointsFound
|
||||
Self::NoEntryPointWithName { .. }
|
||||
| Self::NoEntryPointWithNameForStage { .. }
|
||||
| Self::NoEntryPoints
|
||||
| Self::NoEntryPointForStage(_)
|
||||
| Self::AmbiguousEntryPoint
|
||||
| Self::AmbiguousEntryPointForStage(_)
|
||||
| Self::InvalidWorkgroupSize { .. }
|
||||
| Self::VertexOutputLocationTooLarge { .. }
|
||||
| Self::TooManyUserDefinedVertexOutputs { .. }
|
||||
| Self::FragmentInputLocationTooLarge { .. }
|
||||
@@ -1531,9 +1543,11 @@ impl Interface {
|
||||
.filter_map(|EntryPointKey(ep_stage, name)| {
|
||||
(ep_stage == &stage).then_some(name)
|
||||
});
|
||||
let first = entry_points.next().ok_or(StageError::NoEntryPointFound)?;
|
||||
let first = entry_points
|
||||
.next()
|
||||
.ok_or(StageError::NoEntryPointForStage(stage))?;
|
||||
if entry_points.next().is_some() {
|
||||
return Err(StageError::MultipleEntryPointsFound);
|
||||
return Err(StageError::AmbiguousEntryPointForStage(stage));
|
||||
}
|
||||
Ok(first.clone())
|
||||
})
|
||||
@@ -1574,7 +1588,12 @@ impl Interface {
|
||||
let pair = EntryPointKeyRef(shader_stage.to_naga(), entry_point_name);
|
||||
let entry_point = match self.entry_points.get(&pair) {
|
||||
Some(some) => some,
|
||||
None => return Err(StageError::MissingEntryPoint(pair.1.to_string())),
|
||||
None => {
|
||||
return Err(StageError::NoEntryPointWithNameForStage {
|
||||
name: pair.1.to_string(),
|
||||
stage: shader_stage.to_naga(),
|
||||
})
|
||||
}
|
||||
};
|
||||
let EntryPointKeyRef(_, entry_point_name) = pair;
|
||||
|
||||
|
||||
Reference in new issue
Block a user