Skip to content

Commit

Permalink
mesh shaders: fix per_primitive_ext validation for fragment shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
Firestar99 committed Oct 28, 2024
1 parent 0dc8107 commit d7df74f
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions crates/rustc_codegen_spirv/src/codegen_cx/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,20 +739,31 @@ impl<'tcx> CodegenCx<'tcx> {
.decorate(var_id.unwrap(), Decoration::Invariant, std::iter::empty());
}
if let Some(per_primitive_ext) = attrs.per_primitive_ext {
if storage_class != Ok(StorageClass::Output) {
self.tcx.dcx().span_fatal(
per_primitive_ext.span,
"`#[spirv(per_primitive_ext)]` is only valid on Output variables",
);
}
if !(execution_model == ExecutionModel::MeshEXT
|| execution_model == ExecutionModel::MeshNV)
{
self.tcx.dcx().span_fatal(
per_primitive_ext.span,
"`#[spirv(per_primitive_ext)]` is only valid in mesh shaders",
);
match execution_model {
ExecutionModel::Fragment => {
if storage_class != Ok(StorageClass::Input) {
self.tcx.dcx().span_fatal(
per_primitive_ext.span,
"`#[spirv(per_primitive_ext)]` in fragment shaders is only valid on Input variables",
);
}
}
ExecutionModel::MeshNV | ExecutionModel::MeshEXT => {
if storage_class != Ok(StorageClass::Output) {
self.tcx.dcx().span_fatal(
per_primitive_ext.span,
"`#[spirv(per_primitive_ext)]` in mesh shaders is only valid on Output variables",
);
}
}
_ => {
self.tcx.dcx().span_fatal(
per_primitive_ext.span,
"`#[spirv(per_primitive_ext)]` is only valid in fragment or mesh shaders",
);
}
}

self.emit_global().decorate(
var_id.unwrap(),
Decoration::PerPrimitiveEXT,
Expand Down

0 comments on commit d7df74f

Please sign in to comment.