[core] Turn ShaderMetaData into a Naga-vs.-passthrough enum.

Rename the `ShaderMetaData::Interface` variant to `NagaModule`,
and make it a struct-like variant.

Delete `ShaderMetaData::interface`, and update its call sites to use a
`match` expression directly on the enum instead. This makes the use
sites clearer, by making it apparent which style of module we're
processing.
This commit is contained in:
Jim Blandy authored and mergify[bot] committed 2026-10-26 23:42:33 +00:00
1 parent 7f5c0714ff
commit 69863648a8
3 files changed
+37 -33

No files matched your search

+33 -21
View File
@@ -2718,7 +2718,7 @@ impl Device {
let module = pipeline::ShaderModule {
state: ResourceState::Valid(pipeline::ShaderModuleState {
raw,
interface: ShaderMetaData::Interface(interface),
interface: ShaderMetaData::NagaModule { interface },
}),
device: self.clone(),
label: desc.label.to_string(),
@@ -2878,13 +2878,15 @@ impl Device {
let module = pipeline::ShaderModule {
state: ResourceState::Valid(pipeline::ShaderModuleState {
raw,
interface: ShaderMetaData::Passthrough(PassthroughInterface {
entry_point_names: descriptor
.entry_points
.iter()
.map(|e| e.name.to_string())
.collect(),
}),
interface: ShaderMetaData::Passthrough {
interface: PassthroughInterface {
entry_point_names: descriptor
.entry_points
.iter()
.map(|e| e.name.to_string())
.collect(),
},
},
}),
device: self.clone(),
label: descriptor.label.to_string(),
@@ -4561,10 +4563,12 @@ impl Device {
None => None,
};
if shader_module_state.interface.interface().is_none() && pipeline_layout.is_none() {
return Err(pipeline::CreatePipelineError::Implicit(
pipeline::ImplicitLayoutError::Passthrough(wgt::ShaderStages::COMPUTE),
));
if let ShaderMetaData::Passthrough { .. } = shader_module_state.interface {
if pipeline_layout.is_none() {
return Err(pipeline::CreatePipelineError::Implicit(
pipeline::ImplicitLayoutError::Passthrough(wgt::ShaderStages::COMPUTE),
));
}
}
let mut binding_layout_source = match pipeline_layout {
@@ -4590,7 +4594,7 @@ impl Device {
)
.map_err(stage_err)?;
if let Some(interface) = shader_module_state.interface.interface() {
if let ShaderMetaData::NagaModule { ref interface } = shader_module_state.interface {
io = interface
.check_stage(
&mut binding_layout_source,
@@ -5181,7 +5185,8 @@ impl Device {
.map_err(stage_err)?;
vertex_shader_module.same_device(self)?;
if vertex_shader_module_state.interface.interface().is_none() {
if let ShaderMetaData::Passthrough { .. } = vertex_shader_module_state.interface
{
passthrough_stages |= stage_bit;
}
@@ -5192,7 +5197,9 @@ impl Device {
)
.map_err(stage_err)?;
if let Some(interface) = vertex_shader_module_state.interface.interface() {
if let ShaderMetaData::NagaModule { ref interface } =
vertex_shader_module_state.interface
{
io = interface
.check_stage(
&mut binding_layout_source,
@@ -5233,7 +5240,7 @@ impl Device {
.map_err(stage_err)?;
task_shader_module.same_device(self)?;
if task_shader_module_state.interface.interface().is_none() {
if let ShaderMetaData::Passthrough { .. } = task_shader_module_state.interface {
passthrough_stages |= stage_bit;
}
@@ -5244,7 +5251,9 @@ impl Device {
)
.map_err(stage_err)?;
if let Some(interface) = task_shader_module_state.interface.interface() {
if let ShaderMetaData::NagaModule { ref interface } =
task_shader_module_state.interface
{
io = interface
.check_stage(
&mut binding_layout_source,
@@ -5283,7 +5292,7 @@ impl Device {
.map_err(stage_err)?;
mesh_shader_module.same_device(self)?;
if mesh_shader_module_state.interface.interface().is_none() {
if let ShaderMetaData::Passthrough { .. } = mesh_shader_module_state.interface {
passthrough_stages |= stage_bit;
}
@@ -5294,7 +5303,9 @@ impl Device {
)
.map_err(stage_err)?;
if let Some(interface) = mesh_shader_module_state.interface.interface() {
if let ShaderMetaData::NagaModule { ref interface } =
mesh_shader_module_state.interface
{
io = interface
.check_stage(
&mut binding_layout_source,
@@ -5338,7 +5349,7 @@ impl Device {
.map_err(stage_err)?;
shader_module.same_device(self)?;
if shader_module_state.interface.interface().is_none() {
if let ShaderMetaData::Passthrough { .. } = shader_module_state.interface {
passthrough_stages |= stage_bit;
}
@@ -5353,7 +5364,8 @@ impl Device {
)
.map_err(stage_err)?;
if let Some(interface) = shader_module_state.interface.interface() {
if let ShaderMetaData::NagaModule { ref interface } = shader_module_state.interface
{
io = interface
.check_stage(
&mut binding_layout_source,
+2 -2
View File
@@ -158,10 +158,10 @@ impl ShaderModule {
) -> Result<String, validation::StageError> {
let state = self.state()?;
match state.interface {
ShaderMetaData::Interface(ref interface) => {
ShaderMetaData::NagaModule { ref interface } => {
interface.finalize_entry_point_name(stage, entry_point)
}
ShaderMetaData::Passthrough(ref interface) => {
ShaderMetaData::Passthrough { ref interface } => {
finalize_passthrough_entry_point_name(interface, entry_point)
}
}
+2 -10
View File
@@ -412,16 +412,8 @@ pub struct PassthroughInterface {
#[expect(clippy::large_enum_variant)]
#[derive(Debug)]
pub enum ShaderMetaData {
Interface(Interface),
Passthrough(PassthroughInterface),
}
impl ShaderMetaData {
pub fn interface(&self) -> Option<&Interface> {
match self {
Self::Interface(i) => Some(i),
Self::Passthrough(_) => None,
}
}
NagaModule { interface: Interface },
Passthrough { interface: PassthroughInterface },
}
#[derive(Clone, Debug, Error)]