Skip to content

Commit 254f92c

Browse files
committed
asm vector: deny OpTypeVector in asm
1 parent b651312 commit 254f92c

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

crates/rustc_codegen_spirv/src/builder/spirv_asm.rs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,20 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
367367
SpirvType::Float(inst.operands[0].unwrap_literal_bit32()).def(self.span(), self)
368368
}
369369
Op::TypeStruct => {
370-
self.err("OpTypeStruct in asm! is not supported yet");
370+
self.err("`OpTypeStruct` in asm! is not supported");
371371
return;
372372
}
373-
Op::TypeVector => SpirvType::Vector {
374-
element: inst.operands[0].unwrap_id_ref(),
375-
count: inst.operands[1].unwrap_literal_bit32(),
373+
Op::TypeVector => {
374+
self.struct_err(
375+
"`OpTypeVector` in asm! is not supported, since `#[spirv(vector)]` structs can \
376+
create different vector types due to varying size and alignment",
377+
)
378+
.with_note(
379+
"pass `glam::VecN` as parameters and use `typeof{foo}` to resolve vector type",
380+
)
381+
.emit();
382+
return;
376383
}
377-
.def(self.span(), self),
378384
Op::TypeMatrix => SpirvType::Matrix {
379385
element: inst.operands[0].unwrap_id_ref(),
380386
count: inst.operands[1].unwrap_literal_bit32(),
@@ -717,13 +723,6 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
717723
(TyPat::Void, SpirvType::Void) => Ok([None]),
718724
(TyPat::Pointer(_, pat), SpirvType::Pointer { pointee: ty, .. })
719725
| (TyPat::Vector(pat), SpirvType::Vector { element: ty, .. })
720-
| (
721-
TyPat::Vector4(pat),
722-
SpirvType::Vector {
723-
element: ty,
724-
count: 4,
725-
},
726-
)
727726
| (
728727
TyPat::Image(pat),
729728
SpirvType::Image {
@@ -762,12 +761,6 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
762761
}
763762
.def(DUMMY_SP, cx),
764763

765-
TyPat::Vector4(pat) => SpirvType::Vector {
766-
element: subst_ty_pat(cx, pat, ty_vars, leftover_operands)?,
767-
count: 4,
768-
}
769-
.def(DUMMY_SP, cx),
770-
771764
TyPat::SampledImage(pat) => SpirvType::SampledImage {
772765
image_type: subst_ty_pat(cx, pat, ty_vars, leftover_operands)?,
773766
}

0 commit comments

Comments
 (0)