diff --git a/Cargo.lock b/Cargo.lock index 53769a5a14..ecf6c6d248 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -327,12 +327,6 @@ dependencies = [ "syn 2.0.77", ] -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - [[package]] name = "bytes" version = "1.7.2" @@ -1046,15 +1040,6 @@ dependencies = [ "slab", ] -[[package]] -name = "fxhash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" -dependencies = [ - "byteorder", -] - [[package]] name = "gethostname" version = "0.4.3" @@ -1642,7 +1627,7 @@ dependencies = [ "log", "petgraph", "rustc-hash", - "spirv 0.3.0+sdk-1.3.268.0", + "spirv", "termcolor", "thiserror", "unicode-xid", @@ -2134,13 +2119,12 @@ checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" [[package]] name = "rspirv" -version = "0.11.0+1.5.4" +version = "0.12.0+sdk-1.3.268.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1503993b59ca9ae4127365c3293517576d7ce56be9f3d8abb1625c85ddc583ba" +checksum = "69cf3a93856b6e5946537278df0d3075596371b1950ccff012f02b0f7eafec8d" dependencies = [ - "fxhash", - "num-traits", - "spirv 0.2.0+1.5.4", + "rustc-hash", + "spirv", ] [[package]] @@ -2454,16 +2438,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "spirv" -version = "0.2.0+1.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "246bfa38fe3db3f1dfc8ca5a2cdeb7348c78be2112740cc0ec8ef18b6d94f830" -dependencies = [ - "bitflags 1.3.2", - "num-traits", -] - [[package]] name = "spirv" version = "0.3.0+sdk-1.3.268.0" diff --git a/crates/rustc_codegen_spirv-types/Cargo.toml b/crates/rustc_codegen_spirv-types/Cargo.toml index ef0616c8e3..e2d64d35cf 100644 --- a/crates/rustc_codegen_spirv-types/Cargo.toml +++ b/crates/rustc_codegen_spirv-types/Cargo.toml @@ -8,6 +8,6 @@ license.workspace = true repository.workspace = true [dependencies] -rspirv = "0.11" +rspirv = "0.12" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/crates/rustc_codegen_spirv/Cargo.toml b/crates/rustc_codegen_spirv/Cargo.toml index a5735a6b01..39fc2ebd27 100644 --- a/crates/rustc_codegen_spirv/Cargo.toml +++ b/crates/rustc_codegen_spirv/Cargo.toml @@ -50,7 +50,7 @@ regex = { version = "1", features = ["perf"] } ar = "0.9.0" either = "1.8.0" indexmap = "1.6.0" -rspirv = "0.11" +rspirv = "0.12" rustc_codegen_spirv-types.workspace = true rustc-demangle = "0.1.21" sanitize-filename = "0.4" diff --git a/crates/rustc_codegen_spirv/src/abi.rs b/crates/rustc_codegen_spirv/src/abi.rs index 7e8cf0a2e2..44188bfc5c 100644 --- a/crates/rustc_codegen_spirv/src/abi.rs +++ b/crates/rustc_codegen_spirv/src/abi.rs @@ -4,7 +4,7 @@ use crate::attr::{AggregatedSpirvAttributes, IntrinsicType}; use crate::codegen_cx::CodegenCx; use crate::spirv_type::SpirvType; -use rspirv::spirv::{StorageClass, Word}; +use rspirv::spirv::{Dim, ImageFormat, StorageClass, Word}; use rustc_data_structures::fx::FxHashMap; use rustc_errors::ErrorGuaranteed; use rustc_index::Idx; @@ -862,13 +862,35 @@ fn trans_intrinsic_type<'tcx>( // let image_format: spirv::ImageFormat = // type_from_variant_discriminant(cx, args.const_at(6)); - fn const_int_value<'tcx, P: FromPrimitive>( + trait FromU128Const: Sized { + fn from_u128_const(n: u128) -> Option; + } + + impl FromU128Const for u32 { + fn from_u128_const(n: u128) -> Option { + u32::from_u128(n) + } + } + + impl FromU128Const for Dim { + fn from_u128_const(n: u128) -> Option { + Dim::from_u32(u32::from_u128(n)?) + } + } + + impl FromU128Const for ImageFormat { + fn from_u128_const(n: u128) -> Option { + ImageFormat::from_u32(u32::from_u128(n)?) + } + } + + fn const_int_value<'tcx, P: FromU128Const>( cx: &CodegenCx<'tcx>, const_: Const<'tcx>, ) -> Result { assert!(const_.ty().is_integral()); let value = const_.eval_bits(cx.tcx, ParamEnv::reveal_all()); - match P::from_u128(value) { + match P::from_u128_const(value) { Some(v) => Ok(v), None => Err(cx .tcx diff --git a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs index b8841b45a8..c97a8a2ecb 100644 --- a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs +++ b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs @@ -1106,9 +1106,9 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { )) } else if signed { // this cast chain can probably be collapsed, but, whatever, be safe - Operand::LiteralInt32(v as u8 as i8 as i32 as u32) + Operand::LiteralBit32(v as u8 as i8 as i32 as u32) } else { - Operand::LiteralInt32(v as u8 as u32) + Operand::LiteralBit32(v as u8 as u32) } } fn construct_16(self_: &Builder<'_, '_>, signed: bool, v: u128) -> Operand { @@ -1117,9 +1117,9 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { "Switches to values above u16::MAX not supported: {v:?}" )) } else if signed { - Operand::LiteralInt32(v as u16 as i16 as i32 as u32) + Operand::LiteralBit32(v as u16 as i16 as i32 as u32) } else { - Operand::LiteralInt32(v as u16 as u32) + Operand::LiteralBit32(v as u16 as u32) } } fn construct_32(self_: &Builder<'_, '_>, _signed: bool, v: u128) -> Operand { @@ -1128,7 +1128,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { "Switches to values above u32::MAX not supported: {v:?}" )) } else { - Operand::LiteralInt32(v as u32) + Operand::LiteralBit32(v as u32) } } fn construct_64(self_: &Builder<'_, '_>, _signed: bool, v: u128) -> Operand { @@ -1137,7 +1137,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { "Switches to values above u64::MAX not supported: {v:?}" )) } else { - Operand::LiteralInt64(v as u64) + Operand::LiteralBit64(v as u64) } } // pass in signed into the closure to be able to unify closure types @@ -2915,7 +2915,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { // HACK(eddyb) avoid the logic below that assumes only ID operands if inst.class.opcode == Op::CompositeExtract { - if let (Some(r), &[Operand::IdRef(x), Operand::LiteralInt32(i)]) = + if let (Some(r), &[Operand::IdRef(x), Operand::LiteralBit32(i)]) = (inst.result_id, &inst.operands[..]) { return Some(Inst::CompositeExtract(r, x, i)); diff --git a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs index d10ddbb91d..9d7ad00057 100644 --- a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs +++ b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs @@ -2,13 +2,12 @@ use super::Builder; use crate::builder_spirv::{BuilderCursor, SpirvValue}; use crate::codegen_cx::CodegenCx; use crate::spirv_type::SpirvType; -use num_traits::FromPrimitive; use rspirv::dr; use rspirv::grammar::{reflect, LogicalOperand, OperandKind, OperandQuantifier}; use rspirv::spirv::{ - FPFastMathMode, FragmentShadingRate, FunctionControl, GroupOperation, ImageOperands, - KernelProfilingInfo, LoopControl, MemoryAccess, MemorySemantics, Op, RayFlags, - SelectionControl, StorageClass, Word, + CooperativeMatrixOperands, FPFastMathMode, FragmentShadingRate, FunctionControl, + GroupOperation, ImageOperands, KernelProfilingInfo, LoopControl, MemoryAccess, MemorySemantics, + Op, RayFlags, SelectionControl, StorageClass, Word, }; use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece}; use rustc_codegen_ssa::mir::place::PlaceRef; @@ -275,12 +274,12 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { Op::TypeVoid => SpirvType::Void.def(self.span(), self), Op::TypeBool => SpirvType::Bool.def(self.span(), self), Op::TypeInt => SpirvType::Integer( - inst.operands[0].unwrap_literal_int32(), - inst.operands[1].unwrap_literal_int32() != 0, + inst.operands[0].unwrap_literal_bit32(), + inst.operands[1].unwrap_literal_bit32() != 0, ) .def(self.span(), self), Op::TypeFloat => { - SpirvType::Float(inst.operands[0].unwrap_literal_int32()).def(self.span(), self) + SpirvType::Float(inst.operands[0].unwrap_literal_bit32()).def(self.span(), self) } Op::TypeStruct => { self.err("OpTypeStruct in asm! is not supported yet"); @@ -288,12 +287,12 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { } Op::TypeVector => SpirvType::Vector { element: inst.operands[0].unwrap_id_ref(), - count: inst.operands[1].unwrap_literal_int32(), + count: inst.operands[1].unwrap_literal_bit32(), } .def(self.span(), self), Op::TypeMatrix => SpirvType::Matrix { element: inst.operands[0].unwrap_id_ref(), - count: inst.operands[1].unwrap_literal_int32(), + count: inst.operands[1].unwrap_literal_bit32(), } .def(self.span(), self), Op::TypeArray => { @@ -324,10 +323,10 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { Op::TypeImage => SpirvType::Image { sampled_type: inst.operands[0].unwrap_id_ref(), dim: inst.operands[1].unwrap_dim(), - depth: inst.operands[2].unwrap_literal_int32(), - arrayed: inst.operands[3].unwrap_literal_int32(), - multisampled: inst.operands[4].unwrap_literal_int32(), - sampled: inst.operands[5].unwrap_literal_int32(), + depth: inst.operands[2].unwrap_literal_bit32(), + arrayed: inst.operands[3].unwrap_literal_bit32(), + multisampled: inst.operands[4].unwrap_literal_bit32(), + sampled: inst.operands[5].unwrap_literal_bit32(), image_format: inst.operands[6].unwrap_image_format(), } .def(self.span(), self), @@ -696,7 +695,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { let index_to_usize = || match *index { // FIXME(eddyb) support more than just literals, // by looking up `IdRef`s as constant integers. - dr::Operand::LiteralInt32(i) => usize::try_from(i).ok(), + dr::Operand::LiteralBit32(i) => usize::try_from(i).ok(), _ => None, }; @@ -1101,9 +1100,15 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { } (OperandKind::LiteralInteger, Some(word)) => match word.parse() { - Ok(v) => inst.operands.push(dr::Operand::LiteralInt32(v)), + Ok(v) => inst.operands.push(dr::Operand::LiteralBit32(v)), Err(e) => self.err(format!("invalid integer: {e}")), }, + (OperandKind::LiteralFloat, Some(word)) => match word.parse() { + Ok(v) => inst + .operands + .push(dr::Operand::LiteralBit32(f32::to_bits(v))), + Err(e) => self.err(format!("invalid float: {e}")), + }, (OperandKind::LiteralString, _) => { if let Token::String(value) = token { inst.operands.push(dr::Operand::LiteralString(value)); @@ -1118,34 +1123,34 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { } Ok(match ty { SpirvType::Integer(8, false) => { - dr::Operand::LiteralInt32(w.parse::().map_err(fmt)? as u32) + dr::Operand::LiteralBit32(w.parse::().map_err(fmt)? as u32) } SpirvType::Integer(16, false) => { - dr::Operand::LiteralInt32(w.parse::().map_err(fmt)? as u32) + dr::Operand::LiteralBit32(w.parse::().map_err(fmt)? as u32) } SpirvType::Integer(32, false) => { - dr::Operand::LiteralInt32(w.parse::().map_err(fmt)?) + dr::Operand::LiteralBit32(w.parse::().map_err(fmt)?) } SpirvType::Integer(64, false) => { - dr::Operand::LiteralInt64(w.parse::().map_err(fmt)?) + dr::Operand::LiteralBit64(w.parse::().map_err(fmt)?) } SpirvType::Integer(8, true) => { - dr::Operand::LiteralInt32(w.parse::().map_err(fmt)? as i32 as u32) + dr::Operand::LiteralBit32(w.parse::().map_err(fmt)? as i32 as u32) } SpirvType::Integer(16, true) => { - dr::Operand::LiteralInt32(w.parse::().map_err(fmt)? as i32 as u32) + dr::Operand::LiteralBit32(w.parse::().map_err(fmt)? as i32 as u32) } SpirvType::Integer(32, true) => { - dr::Operand::LiteralInt32(w.parse::().map_err(fmt)? as u32) + dr::Operand::LiteralBit32(w.parse::().map_err(fmt)? as u32) } SpirvType::Integer(64, true) => { - dr::Operand::LiteralInt64(w.parse::().map_err(fmt)? as u64) + dr::Operand::LiteralBit64(w.parse::().map_err(fmt)? as u64) } SpirvType::Float(32) => { - dr::Operand::LiteralFloat32(w.parse::().map_err(fmt)?) + dr::Operand::LiteralBit32(w.parse::().map_err(fmt)?.to_bits()) } SpirvType::Float(64) => { - dr::Operand::LiteralFloat64(w.parse::().map_err(fmt)?) + dr::Operand::LiteralBit64(w.parse::().map_err(fmt)?.to_bits()) } _ => return Err("expected number literal in OpConstant".to_string()), }) @@ -1176,7 +1181,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { inst.operands.push(dr::Operand::IdRef(id)); match tokens.next() { Some(Token::Word(word)) => match word.parse() { - Ok(v) => inst.operands.push(dr::Operand::LiteralInt32(v)), + Ok(v) => inst.operands.push(dr::Operand::LiteralBit32(v)), Err(e) => { self.err(format!("invalid integer: {e}")); } @@ -1386,6 +1391,60 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { .push(dr::Operand::RayQueryCandidateIntersectionType(x)), Err(()) => self.err(format!("unknown RayQueryCandidateIntersectionType {word}")), }, + (OperandKind::FPDenormMode, Some(word)) => match word.parse() { + Ok(x) => inst.operands.push(dr::Operand::FPDenormMode(x)), + Err(()) => self.err(format!("unknown FPDenormMode {word}")), + }, + (OperandKind::QuantizationModes, Some(word)) => match word.parse() { + Ok(x) => inst.operands.push(dr::Operand::QuantizationModes(x)), + Err(()) => self.err(format!("unknown QuantizationModes {word}")), + }, + (OperandKind::FPOperationMode, Some(word)) => match word.parse() { + Ok(x) => inst.operands.push(dr::Operand::FPOperationMode(x)), + Err(()) => self.err(format!("unknown FPOperationMode {word}")), + }, + (OperandKind::OverflowModes, Some(word)) => match word.parse() { + Ok(x) => inst.operands.push(dr::Operand::OverflowModes(x)), + Err(()) => self.err(format!("unknown OverflowModes {word}")), + }, + (OperandKind::PackedVectorFormat, Some(word)) => match word.parse() { + Ok(x) => inst.operands.push(dr::Operand::PackedVectorFormat(x)), + Err(()) => self.err(format!("unknown PackedVectorFormat {word}")), + }, + (OperandKind::HostAccessQualifier, Some(word)) => match word.parse() { + Ok(x) => inst.operands.push(dr::Operand::HostAccessQualifier(x)), + Err(()) => self.err(format!("unknown HostAccessQualifier {word}")), + }, + (OperandKind::CooperativeMatrixOperands, Some(word)) => { + match parse_bitflags_operand(COOPERATIVE_MATRIX_OPERANDS, word) { + Some(x) => inst + .operands + .push(dr::Operand::CooperativeMatrixOperands(x)), + None => self.err(format!("Unknown CooperativeMatrixOperands {word}")), + } + } + (OperandKind::CooperativeMatrixLayout, Some(word)) => match word.parse() { + Ok(x) => inst.operands.push(dr::Operand::CooperativeMatrixLayout(x)), + Err(()) => self.err(format!("unknown CooperativeMatrixLayout {word}")), + }, + (OperandKind::CooperativeMatrixUse, Some(word)) => match word.parse() { + Ok(x) => inst.operands.push(dr::Operand::CooperativeMatrixUse(x)), + Err(()) => self.err(format!("unknown CooperativeMatrixUse {word}")), + }, + (OperandKind::InitializationModeQualifier, Some(word)) => match word.parse() { + Ok(x) => inst + .operands + .push(dr::Operand::InitializationModeQualifier(x)), + Err(()) => self.err(format!("unknown InitializationModeQualifier {word}")), + }, + (OperandKind::LoadCacheControl, Some(word)) => match word.parse() { + Ok(x) => inst.operands.push(dr::Operand::LoadCacheControl(x)), + Err(()) => self.err(format!("unknown LoadCacheControl {word}")), + }, + (OperandKind::StoreCacheControl, Some(word)) => match word.parse() { + Ok(x) => inst.operands.push(dr::Operand::StoreCacheControl(x)), + Err(()) => self.err(format!("unknown StoreCacheControl {word}")), + }, (kind, None) => match token { Token::Word(_) => bug!(), Token::String(_) => { @@ -1557,6 +1616,29 @@ pub const FRAGMENT_SHADING_RATE: &[(&str, FragmentShadingRate)] = &[ FragmentShadingRate::HORIZONTAL4_PIXELS, ), ]; +pub const COOPERATIVE_MATRIX_OPERANDS: &[(&str, CooperativeMatrixOperands)] = &[ + ("NONE_KHR", CooperativeMatrixOperands::NONE_KHR), + ( + "MATRIX_A_SIGNED_COMPONENTS_KHR", + CooperativeMatrixOperands::MATRIX_A_SIGNED_COMPONENTS_KHR, + ), + ( + "MATRIX_B_SIGNED_COMPONENTS_KHR", + CooperativeMatrixOperands::MATRIX_B_SIGNED_COMPONENTS_KHR, + ), + ( + "MATRIX_C_SIGNED_COMPONENTS_KHR", + CooperativeMatrixOperands::MATRIX_C_SIGNED_COMPONENTS_KHR, + ), + ( + "MATRIX_RESULT_SIGNED_COMPONENTS_KHR", + CooperativeMatrixOperands::MATRIX_RESULT_SIGNED_COMPONENTS_KHR, + ), + ( + "SATURATING_ACCUMULATION_KHR", + CooperativeMatrixOperands::SATURATING_ACCUMULATION_KHR, + ), +]; fn parse_bitflags_operand + Copy>( values: &'static [(&'static str, T)], diff --git a/crates/rustc_codegen_spirv/src/builder_spirv.rs b/crates/rustc_codegen_spirv/src/builder_spirv.rs index 852ffddc83..339c16d18c 100644 --- a/crates/rustc_codegen_spirv/src/builder_spirv.rs +++ b/crates/rustc_codegen_spirv/src/builder_spirv.rs @@ -583,10 +583,8 @@ impl<'tcx> BuilderSpirv<'tcx> { } let val = val_with_type.val; let id = match val { - SpirvConst::U32(v) => builder.constant_u32(ty, v), - SpirvConst::U64(v) => builder.constant_u64(ty, v), - SpirvConst::F32(v) => builder.constant_f32(ty, f32::from_bits(v)), - SpirvConst::F64(v) => builder.constant_f64(ty, f64::from_bits(v)), + SpirvConst::U32(v) | SpirvConst::F32(v) => builder.constant_bit32(ty, v), + SpirvConst::U64(v) | SpirvConst::F64(v) => builder.constant_bit64(ty, v), SpirvConst::Bool(v) => { if v { builder.constant_true(ty) diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs b/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs index 4ab26f317e..04b8d72f91 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs @@ -353,7 +353,7 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> { self.tcx .dcx() .fatal("Non-zero scalar_to_backend ptr.offset not supported") - // let offset = self.constant_u64(ptr.offset.bytes()); + // let offset = self.constant_bit64(ptr.offset.bytes()); // self.gep(base_addr, once(offset)) }; if let Primitive::Pointer(_) = layout.primitive() { diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs b/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs index 2489e2ea79..865bcc7a77 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs @@ -447,11 +447,12 @@ impl<'tcx> CodegenCx<'tcx> { ), Err(SpecConstant { id, default }) => { let mut emit = self.emit_global(); - let spec_const_id = emit.spec_constant_u32(value_spirv_type, default.unwrap_or(0)); + let spec_const_id = + emit.spec_constant_bit32(value_spirv_type, default.unwrap_or(0)); emit.decorate( spec_const_id, Decoration::SpecId, - [Operand::LiteralInt32(id)], + [Operand::LiteralBit32(id)], ); ( Err("`#[spirv(spec_constant)]` is not an entry-point interface variable"), @@ -699,7 +700,7 @@ impl<'tcx> CodegenCx<'tcx> { self.emit_global().decorate( var_id.unwrap(), Decoration::DescriptorSet, - std::iter::once(Operand::LiteralInt32(descriptor_set.value)), + std::iter::once(Operand::LiteralBit32(descriptor_set.value)), ); decoration_supersedes_location = true; } @@ -713,7 +714,7 @@ impl<'tcx> CodegenCx<'tcx> { self.emit_global().decorate( var_id.unwrap(), Decoration::Binding, - std::iter::once(Operand::LiteralInt32(binding.value)), + std::iter::once(Operand::LiteralBit32(binding.value)), ); decoration_supersedes_location = true; } @@ -758,7 +759,7 @@ impl<'tcx> CodegenCx<'tcx> { self.emit_global().decorate( var_id.unwrap(), Decoration::InputAttachmentIndex, - std::iter::once(Operand::LiteralInt32(attachment_index.value)), + std::iter::once(Operand::LiteralBit32(attachment_index.value)), ); } else if is_subpass_input { self.tcx @@ -805,7 +806,7 @@ impl<'tcx> CodegenCx<'tcx> { self.emit_global().decorate( var_id.unwrap(), Decoration::Location, - std::iter::once(Operand::LiteralInt32(*location)), + std::iter::once(Operand::LiteralBit32(*location)), ); *location += 1; } diff --git a/crates/rustc_codegen_spirv/src/custom_decorations.rs b/crates/rustc_codegen_spirv/src/custom_decorations.rs index f1e992ed64..2193c1bd45 100644 --- a/crates/rustc_codegen_spirv/src/custom_decorations.rs +++ b/crates/rustc_codegen_spirv/src/custom_decorations.rs @@ -382,8 +382,8 @@ impl<'a> SpanRegenerator<'a> { let (file_id, line_start, line_end, col_start, col_end) = match inst.class.opcode { Op::Line => { let file = inst.operands[0].unwrap_id_ref(); - let line = inst.operands[1].unwrap_literal_int32(); - let col = inst.operands[2].unwrap_literal_int32(); + let line = inst.operands[1].unwrap_literal_bit32(); + let col = inst.operands[2].unwrap_literal_bit32(); (file, line, line, col, col) } Op::ExtInst @@ -400,7 +400,7 @@ impl<'a> SpanRegenerator<'a> { } => { let const_u32 = |operand: Operand| { spv_debug_info.id_to_op_constant_operand[&operand.unwrap_id_ref()] - .unwrap_literal_int32() + .unwrap_literal_bit32() }; ( file.unwrap_id_ref(), diff --git a/crates/rustc_codegen_spirv/src/linker/destructure_composites.rs b/crates/rustc_codegen_spirv/src/linker/destructure_composites.rs index 287537568e..9384eecf60 100644 --- a/crates/rustc_codegen_spirv/src/linker/destructure_composites.rs +++ b/crates/rustc_codegen_spirv/src/linker/destructure_composites.rs @@ -23,13 +23,13 @@ pub fn destructure_composites(function: &mut Function) { for inst in function.all_inst_iter_mut() { if inst.class.opcode == Op::CompositeExtract && inst.operands.len() == 2 { let mut composite = inst.operands[0].unwrap_id_ref(); - let index = inst.operands[1].unwrap_literal_int32(); + let index = inst.operands[1].unwrap_literal_bit32(); let origin = loop { if let Some(inst) = reference.get(&composite) { match inst.class.opcode { Op::CompositeInsert => { - let insert_index = inst.operands[2].unwrap_literal_int32(); + let insert_index = inst.operands[2].unwrap_literal_bit32(); if insert_index == index { break Some(inst.operands[0].unwrap_id_ref()); } diff --git a/crates/rustc_codegen_spirv/src/linker/duplicates.rs b/crates/rustc_codegen_spirv/src/linker/duplicates.rs index af2b91a1c3..0f8a36d8a0 100644 --- a/crates/rustc_codegen_spirv/src/linker/duplicates.rs +++ b/crates/rustc_codegen_spirv/src/linker/duplicates.rs @@ -267,7 +267,7 @@ pub fn remove_duplicate_types(module: &mut Module) { && (inst.class.opcode != Op::MemberName || member_name_ids.insert(( inst.operands[0].unwrap_id_ref(), - inst.operands[1].unwrap_literal_int32(), + inst.operands[1].unwrap_literal_bit32(), ))) }); } diff --git a/crates/rustc_codegen_spirv/src/linker/mem2reg.rs b/crates/rustc_codegen_spirv/src/linker/mem2reg.rs index 628be71c8d..ab567203f1 100644 --- a/crates/rustc_codegen_spirv/src/linker/mem2reg.rs +++ b/crates/rustc_codegen_spirv/src/linker/mem2reg.rs @@ -517,7 +517,7 @@ impl Renamer<'_> { ); let mut operands = vec![Operand::IdRef(val), Operand::IdRef(prev_comp)]; operands - .extend(var_info.indices.iter().copied().map(Operand::LiteralInt32)); + .extend(var_info.indices.iter().copied().map(Operand::LiteralBit32)); *inst = Instruction::new( Op::CompositeInsert, Some(self.base_var_type), @@ -545,7 +545,7 @@ impl Renamer<'_> { let new_id = id(self.header); let mut operands = vec![Operand::IdRef(current_obj)]; operands - .extend(var_info.indices.iter().copied().map(Operand::LiteralInt32)); + .extend(var_info.indices.iter().copied().map(Operand::LiteralBit32)); *inst = Instruction::new( Op::CompositeExtract, Some(var_info.ty), diff --git a/crates/rustc_codegen_spirv/src/linker/mod.rs b/crates/rustc_codegen_spirv/src/linker/mod.rs index a11fdf593b..8e9238b2e5 100644 --- a/crates/rustc_codegen_spirv/src/linker/mod.rs +++ b/crates/rustc_codegen_spirv/src/linker/mod.rs @@ -302,14 +302,14 @@ pub fn link( .insert(inst.result_id.unwrap(), inst.operands[1].unwrap_id_ref()); } Op::TypeInt - if inst.operands[0].unwrap_literal_int32() == 32 - && inst.operands[1].unwrap_literal_int32() == 0 => + if inst.operands[0].unwrap_literal_bit32() == 32 + && inst.operands[1].unwrap_literal_bit32() == 0 => { assert!(u32.is_none()); u32 = Some(inst.result_id.unwrap()); } Op::Constant if u32.is_some() && inst.result_type == u32 => { - let value = inst.operands[0].unwrap_literal_int32(); + let value = inst.operands[0].unwrap_literal_bit32(); constants.insert(inst.result_id.unwrap(), value); } _ => {} @@ -358,14 +358,14 @@ pub fn link( .insert(inst.result_id.unwrap(), inst.operands[1].unwrap_id_ref()); } Op::TypeInt - if inst.operands[0].unwrap_literal_int32() == 32 - && inst.operands[1].unwrap_literal_int32() == 0 => + if inst.operands[0].unwrap_literal_bit32() == 32 + && inst.operands[1].unwrap_literal_bit32() == 0 => { assert!(u32.is_none()); u32 = Some(inst.result_id.unwrap()); } Op::Constant if u32.is_some() && inst.result_type == u32 => { - let value = inst.operands[0].unwrap_literal_int32(); + let value = inst.operands[0].unwrap_literal_bit32(); constants.insert(inst.result_id.unwrap(), value); } _ => {} diff --git a/crates/rustc_codegen_spirv/src/linker/peephole_opts.rs b/crates/rustc_codegen_spirv/src/linker/peephole_opts.rs index 447028f671..3947b300ba 100644 --- a/crates/rustc_codegen_spirv/src/linker/peephole_opts.rs +++ b/crates/rustc_codegen_spirv/src/linker/peephole_opts.rs @@ -16,7 +16,7 @@ fn composite_count(types: &FxHashMap, ty_id: Word) -> Option< let ty = types.get(&ty_id)?; match ty.class.opcode { Op::TypeStruct => Some(ty.operands.len()), - Op::TypeVector => Some(ty.operands[1].unwrap_literal_int32() as usize), + Op::TypeVector => Some(ty.operands[1].unwrap_literal_bit32() as usize), Op::TypeArray => { let length_id = ty.operands[1].unwrap_id_ref(); let const_inst = types.get(&length_id)?; @@ -28,8 +28,8 @@ fn composite_count(types: &FxHashMap, ty_id: Word) -> Option< return None; } let const_value = match const_inst.operands[0] { - Operand::LiteralInt32(v) => v as usize, - Operand::LiteralInt64(v) => v as usize, + Operand::LiteralBit32(v) => v as usize, + Operand::LiteralBit64(v) => v as usize, _ => bug!(), }; Some(const_value) @@ -67,7 +67,7 @@ pub fn composite_construct(types: &FxHashMap, function: &mut break; } let value = cur_inst.operands[0].unwrap_id_ref(); - let index = cur_inst.operands[2].unwrap_literal_int32() as usize; + let index = cur_inst.operands[2].unwrap_literal_bit32() as usize; if index >= components.len() { // Theoretically shouldn't happen, as it's invalid SPIR-V if the index is out // of bounds, but just stop optimizing instead of panicking here. @@ -131,7 +131,7 @@ fn get_composite_and_index( return None; } let composite = inst.operands[0].unwrap_id_ref(); - let index = inst.operands[1].unwrap_literal_int32(); + let index = inst.operands[1].unwrap_literal_bit32(); let composite_def = defs.get(&composite).or_else(|| types.get(&composite))?; let vector_def = types.get(&composite_def.result_type.unwrap())?; @@ -140,7 +140,7 @@ fn get_composite_and_index( // Width mismatch would be doing something like `vec2(a.x + b.x, a.y + b.y)` where `a` is a // vec4 - if we optimized it to just `a + b`, it'd be incorrect. if vector_def.class.opcode != Op::TypeVector - || vector_width != vector_def.operands[1].unwrap_literal_int32() + || vector_width != vector_def.operands[1].unwrap_literal_bit32() { return None; } @@ -330,7 +330,7 @@ fn process_instruction( if vector_ty_inst.class.opcode != Op::TypeVector { return None; } - let vector_width = vector_ty_inst.operands[1].unwrap_literal_int32(); + let vector_width = vector_ty_inst.operands[1].unwrap_literal_bit32(); // `results` is the defining instruction for each scalar component of the final result. let results = match inst .operands @@ -463,7 +463,7 @@ fn can_fuse_bool( return None; } match inst.operands[0] { - Operand::LiteralInt32(v) => Some(v), + Operand::LiteralBit32(v) => Some(v), _ => None, } } diff --git a/crates/rustc_codegen_spirv/src/linker/specializer.rs b/crates/rustc_codegen_spirv/src/linker/specializer.rs index 5f548d9c87..6a32de5cd5 100644 --- a/crates/rustc_codegen_spirv/src/linker/specializer.rs +++ b/crates/rustc_codegen_spirv/src/linker/specializer.rs @@ -546,7 +546,7 @@ struct Specializer { // FIXME(eddyb) compact SPIR-V IDs to allow flatter maps. generics: IndexMap, - /// Integer `OpConstant`s (i.e. containing a `LiteralInt32`), to be used + /// Integer `OpConstant`s (i.e. containing a `LiteralBit32`), to be used /// for interpreting `TyPat::IndexComposite` (such as for `OpAccessChain`). int_consts: FxHashMap, } @@ -603,7 +603,7 @@ impl Specializer { // Record all integer `OpConstant`s (used for `IndexComposite`). if inst.class.opcode == Op::Constant { - if let Operand::LiteralInt32(x) = inst.operands[0] { + if let Operand::LiteralBit32(x) = inst.operands[0] { self.int_consts.insert(result_id, x); } } @@ -1194,7 +1194,7 @@ impl<'a> Match<'a> { // known `OpConstant`s (e.g. struct field indices). let maybe_idx = match operand { Operand::IdRef(id) => cx.specializer.int_consts.get(id), - Operand::LiteralInt32(idx) => Some(idx), + Operand::LiteralBit32(idx) => Some(idx), _ => None, }; match maybe_idx { @@ -1319,7 +1319,7 @@ impl<'a, S: Specialization> InferCx<'a, S> { TyPat::Array(pat) => simple(Op::TypeArray, pat), TyPat::Vector(pat) => simple(Op::TypeVector, pat), TyPat::Vector4(pat) => match ty_operands.operands { - [_, Operand::LiteralInt32(4)] => simple(Op::TypeVector, pat), + [_, Operand::LiteralBit32(4)] => simple(Op::TypeVector, pat), _ => Err(Unapplicable), }, TyPat::Matrix(pat) => simple(Op::TypeMatrix, pat), @@ -1726,7 +1726,7 @@ impl<'a, S: Specialization> InferCx<'a, S> { unreachable!("non-constant `OpTypeStruct` field index {}", id); }) } - &Operand::LiteralInt32(i) => i, + &Operand::LiteralBit32(i) => i, _ => { unreachable!("invalid `OpTypeStruct` field index operand {:?}", idx); } diff --git a/crates/rustc_codegen_spirv/src/linker/test.rs b/crates/rustc_codegen_spirv/src/linker/test.rs index 55750bf264..573516fc6d 100644 --- a/crates/rustc_codegen_spirv/src/linker/test.rs +++ b/crates/rustc_codegen_spirv/src/linker/test.rs @@ -287,7 +287,7 @@ fn standard() { OpMemoryModel Logical OpenCL OpDecorate %1 LinkageAttributes "foo" Export %2 = OpTypeFloat 32 - %3 = OpConstant %2 42.0 + %3 = OpConstant %2 42 %1 = OpVariable %2 Uniform %3"#; without_header_eq(result, expect); diff --git a/crates/rustc_codegen_spirv/src/spirv_type.rs b/crates/rustc_codegen_spirv/src/spirv_type.rs index ad97e78c52..f4ebd399bb 100644 --- a/crates/rustc_codegen_spirv/src/spirv_type.rs +++ b/crates/rustc_codegen_spirv/src/spirv_type.rs @@ -167,7 +167,7 @@ impl SpirvType<'_> { result, index as u32, Decoration::Offset, - [Operand::LiteralInt32(offset.bytes() as u32)] + [Operand::LiteralBit32(offset.bytes() as u32)] .iter() .cloned(), ); @@ -193,7 +193,7 @@ impl SpirvType<'_> { emit.decorate( result, Decoration::ArrayStride, - iter::once(Operand::LiteralInt32(element_size as u32)), + iter::once(Operand::LiteralBit32(element_size as u32)), ); result } @@ -209,7 +209,7 @@ impl SpirvType<'_> { emit.decorate( result, Decoration::ArrayStride, - iter::once(Operand::LiteralInt32(element_size as u32)), + iter::once(Operand::LiteralBit32(element_size as u32)), ); result } @@ -269,7 +269,7 @@ impl SpirvType<'_> { result, 0, Decoration::Offset, - [Operand::LiteralInt32(0)].iter().cloned(), + [Operand::LiteralBit32(0)].iter().cloned(), ); result } diff --git a/crates/rustc_codegen_spirv/src/spirv_type_constraints.rs b/crates/rustc_codegen_spirv/src/spirv_type_constraints.rs index 5d2d623998..c9693b7507 100644 --- a/crates/rustc_codegen_spirv/src/spirv_type_constraints.rs +++ b/crates/rustc_codegen_spirv/src/spirv_type_constraints.rs @@ -494,6 +494,12 @@ pub fn instruction_signatures(op: Op) -> Option<&'static [InstSig<'static>]> { Op::IAddCarry | Op::ISubBorrow | Op::UMulExtended | Op::SMulExtended => sig! { (T, T) -> Struct([T, T]) }, + Op::SDot | Op::UDot | Op::SUDot | Op::SDotAccSat | Op::UDotAccSat | Op::SUDotAccSat => { + sig! { + // FIXME(eddyb) missing equality constraint between two vectors + (Vector(T), T) -> Vector(T) + } + } // 3.37.14. Bit Instructions Op::ShiftRightLogical @@ -593,6 +599,8 @@ pub fn instruction_signatures(op: Op) -> Option<&'static [InstSig<'static>]> { }, // Capability: Kernel Op::AtomicFlagTestAndSet | Op::AtomicFlagClear => {} + // SPV_EXT_shader_atomic_float_min_max + Op::AtomicFMinEXT | Op::AtomicFMaxEXT => sig! { (Pointer(_, T), _, _, T) -> T }, // SPV_EXT_shader_atomic_float_add Op::AtomicFAddEXT => sig! { (Pointer(_, T), _, _, T) -> T }, @@ -821,7 +829,7 @@ pub fn instruction_signatures(op: Op) -> Option<&'static [InstSig<'static>]> { // Instructions not present in current SPIR-V specification // SPV_INTEL_function_pointers - Op::FunctionPointerINTEL | Op::FunctionPointerCallINTEL => { + Op::ConstantFunctionPointerINTEL | Op::FunctionPointerCallINTEL => { reserved!(SPV_INTEL_function_pointers); } // SPV_INTEL_device_side_avc_motion_estimation @@ -945,6 +953,181 @@ pub fn instruction_signatures(op: Op) -> Option<&'static [InstSig<'static>]> { | Op::SubgroupAvcSicGetInterRawSadsINTEL => { reserved!(SPV_INTEL_device_side_avc_motion_estimation); } + // SPV_EXT_mesh_shader + Op::EmitMeshTasksEXT | Op::SetMeshOutputsEXT => { + reserved!(SPV_EXT_mesh_shader) + } + // SPV_NV_ray_tracing_motion_blur + Op::TraceMotionNV | Op::TraceRayMotionNV => reserved!(SPV_NV_ray_tracing_motion_blur), + // SPV_NV_bindless_texture + Op::ConvertUToImageNV + | Op::ConvertUToSamplerNV + | Op::ConvertImageToUNV + | Op::ConvertSamplerToUNV + | Op::ConvertUToSampledImageNV + | Op::ConvertSampledImageToUNV + | Op::SamplerImageAddressingModeNV => reserved!(SPV_NV_bindless_texture), + // SPV_INTEL_inline_assembly + Op::AsmTargetINTEL | Op::AsmINTEL | Op::AsmCallINTEL => reserved!(SPV_NV_bindless_texture), + // SPV_INTEL_variable_length_array + Op::VariableLengthArrayINTEL => reserved!(SPV_INTEL_variable_length_array), + // SPV_KHR_uniform_group_instructions + Op::GroupIMulKHR + | Op::GroupFMulKHR + | Op::GroupBitwiseAndKHR + | Op::GroupBitwiseOrKHR + | Op::GroupBitwiseXorKHR + | Op::GroupLogicalAndKHR + | Op::GroupLogicalOrKHR + | Op::GroupLogicalXorKHR => reserved!(SPV_KHR_uniform_group_instructions), + // SPV_KHR_expect_assume + Op::AssumeTrueKHR | Op::ExpectKHR => reserved!(SPV_KHR_expect_assume), + // SPV_KHR_subgroup_rotate + Op::GroupNonUniformRotateKHR => reserved!(SPV_KHR_subgroup_rotate), + // SPV_NV_shader_invocation_reorder + Op::HitObjectRecordHitMotionNV + | Op::HitObjectRecordHitWithIndexMotionNV + | Op::HitObjectRecordMissMotionNV + | Op::HitObjectGetWorldToObjectNV + | Op::HitObjectGetObjectToWorldNV + | Op::HitObjectGetObjectRayDirectionNV + | Op::HitObjectGetObjectRayOriginNV + | Op::HitObjectTraceRayMotionNV + | Op::HitObjectGetShaderRecordBufferHandleNV + | Op::HitObjectGetShaderBindingTableRecordIndexNV + | Op::HitObjectRecordEmptyNV + | Op::HitObjectTraceRayNV + | Op::HitObjectRecordHitNV + | Op::HitObjectRecordHitWithIndexNV + | Op::HitObjectRecordMissNV + | Op::HitObjectExecuteShaderNV + | Op::HitObjectGetCurrentTimeNV + | Op::HitObjectGetAttributesNV + | Op::HitObjectGetHitKindNV + | Op::HitObjectGetPrimitiveIndexNV + | Op::HitObjectGetGeometryIndexNV + | Op::HitObjectGetInstanceIdNV + | Op::HitObjectGetInstanceCustomIndexNV + | Op::HitObjectGetWorldRayDirectionNV + | Op::HitObjectGetWorldRayOriginNV + | Op::HitObjectGetRayTMaxNV + | Op::HitObjectGetRayTMinNV + | Op::HitObjectIsEmptyNV + | Op::HitObjectIsHitNV + | Op::HitObjectIsMissNV + | Op::ReorderThreadWithHitObjectNV + | Op::ReorderThreadWithHintNV + | Op::TypeHitObjectNV => reserved!(SPV_NV_shader_invocation_reorder), + // SPV_INTEL_arbitrary_precision_floating_point + Op::ArbitraryFloatAddINTEL + | Op::ArbitraryFloatSubINTEL + | Op::ArbitraryFloatMulINTEL + | Op::ArbitraryFloatDivINTEL + | Op::ArbitraryFloatGTINTEL + | Op::ArbitraryFloatGEINTEL + | Op::ArbitraryFloatLTINTEL + | Op::ArbitraryFloatLEINTEL + | Op::ArbitraryFloatEQINTEL + | Op::ArbitraryFloatRecipINTEL + | Op::ArbitraryFloatRSqrtINTEL + | Op::ArbitraryFloatCbrtINTEL + | Op::ArbitraryFloatHypotINTEL + | Op::ArbitraryFloatSqrtINTEL + | Op::ArbitraryFloatLogINTEL + | Op::ArbitraryFloatLog2INTEL + | Op::ArbitraryFloatLog10INTEL + | Op::ArbitraryFloatLog1pINTEL + | Op::ArbitraryFloatExpINTEL + | Op::ArbitraryFloatExp2INTEL + | Op::ArbitraryFloatExp10INTEL + | Op::ArbitraryFloatExpm1INTEL + | Op::ArbitraryFloatSinINTEL + | Op::ArbitraryFloatCosINTEL + | Op::ArbitraryFloatSinCosINTEL + | Op::ArbitraryFloatSinPiINTEL + | Op::ArbitraryFloatCosPiINTEL + | Op::ArbitraryFloatSinCosPiINTEL + | Op::ArbitraryFloatASinINTEL + | Op::ArbitraryFloatASinPiINTEL + | Op::ArbitraryFloatACosINTEL + | Op::ArbitraryFloatACosPiINTEL + | Op::ArbitraryFloatATanINTEL + | Op::ArbitraryFloatATanPiINTEL + | Op::ArbitraryFloatATan2INTEL + | Op::ArbitraryFloatPowINTEL + | Op::ArbitraryFloatPowRINTEL + | Op::ArbitraryFloatPowNINTEL => { + reserved!(SPV_INTEL_arbitrary_precision_floating_point) + } + // TODO these instructions are outdated, and will be replaced by the ones in comments below. When updating, consider merging with the branch above. + Op::ArbitraryFloatCastINTEL + | Op::ArbitraryFloatCastFromIntINTEL + | Op::ArbitraryFloatCastToIntINTEL => { + // Op::ArbitraryFloatConvertINTEL + // | Op::ArbitraryFloatConvertFromUIntINTEL + // | Op::ArbitraryFloatConvertFromSIntINTEL + // | Op::ArbitraryFloatConvertToUIntINTEL + // | Op::ArbitraryFloatConvertToSIntINTEL + reserved!(SPV_INTEL_arbitrary_precision_floating_point) + } + // SPV_INTEL_arbitrary_precision_fixed_point + Op::FixedSqrtINTEL + | Op::FixedRecipINTEL + | Op::FixedRsqrtINTEL + | Op::FixedSinINTEL + | Op::FixedCosINTEL + | Op::FixedSinCosINTEL + | Op::FixedSinPiINTEL + | Op::FixedCosPiINTEL + | Op::FixedSinCosPiINTEL + | Op::FixedLogINTEL + | Op::FixedExpINTEL => reserved!(SPV_INTEL_arbitrary_precision_fixed_point), + // SPV_EXT_shader_tile_image + Op::ColorAttachmentReadEXT | Op::DepthAttachmentReadEXT | Op::StencilAttachmentReadEXT => { + reserved!(SPV_EXT_shader_tile_image) + } + // SPV_KHR_cooperative_matrix + Op::TypeCooperativeMatrixKHR + | Op::CooperativeMatrixLoadKHR + | Op::CooperativeMatrixStoreKHR + | Op::CooperativeMatrixMulAddKHR + | Op::CooperativeMatrixLengthKHR => reserved!(SPV_KHR_cooperative_matrix), + // SPV_QCOM_image_processing + Op::ImageSampleWeightedQCOM + | Op::ImageBoxFilterQCOM + | Op::ImageBlockMatchSSDQCOM + | Op::ImageBlockMatchSADQCOM => reserved!(SPV_QCOM_image_processing), + // SPV_AMDX_shader_enqueue + Op::FinalizeNodePayloadsAMDX + | Op::FinishWritingNodePayloadAMDX + | Op::InitializeNodePayloadsAMDX => reserved!(SPV_AMDX_shader_enqueue), + // SPV_NV_displacement_micromap + Op::FetchMicroTriangleVertexPositionNV | Op::FetchMicroTriangleVertexBarycentricNV => { + reserved!(SPV_NV_displacement_micromap) + } + // SPV_KHR_ray_tracing_position_fetch + Op::RayQueryGetIntersectionTriangleVertexPositionsKHR => { + reserved!(SPV_KHR_ray_tracing_position_fetch) + } + // SPV_INTEL_bfloat16_conversion + Op::ConvertFToBF16INTEL | Op::ConvertBF16ToFINTEL => { + reserved!(SPV_INTEL_bfloat16_conversion) + } + + // TODO unknown_extension_INTEL + Op::SaveMemoryINTEL + | Op::RestoreMemoryINTEL + | Op::AliasDomainDeclINTEL + | Op::AliasScopeDeclINTEL + | Op::AliasScopeListDeclINTEL + | Op::PtrCastToCrossWorkgroupINTEL + | Op::CrossWorkgroupCastToPtrINTEL + | Op::TypeBufferSurfaceINTEL + | Op::TypeStructContinuedINTEL + | Op::ConstantCompositeContinuedINTEL + | Op::SpecConstantCompositeContinuedINTEL + | Op::ControlBarrierArriveINTEL + | Op::ControlBarrierWaitINTEL => reserved!(unknown_extension_INTEL), } None diff --git a/crates/rustc_codegen_spirv/src/symbols.rs b/crates/rustc_codegen_spirv/src/symbols.rs index f6436099c8..d19db967e4 100644 --- a/crates/rustc_codegen_spirv/src/symbols.rs +++ b/crates/rustc_codegen_spirv/src/symbols.rs @@ -116,8 +116,10 @@ const BUILTINS: &[(&str, BuiltIn)] = { ("layer_per_view_nv", LayerPerViewNV), ("mesh_view_count_nv", MeshViewCountNV), ("mesh_view_indices_nv", MeshViewIndicesNV), - ("bary_coord_nv", BaryCoordNV), - ("bary_coord_no_persp_nv", BaryCoordNoPerspNV), + ("bary_coord_nv", BuiltIn::BaryCoordNV), + ("bary_coord_no_persp_nv", BuiltIn::BaryCoordNoPerspNV), + ("bary_coord", BaryCoordKHR), + ("bary_coord_no_persp", BaryCoordNoPerspKHR), ("frag_size_ext", FragSizeEXT), ("frag_invocation_count_ext", FragInvocationCountEXT), ("launch_id", BuiltIn::LaunchIdKHR), diff --git a/tests/ui/spirv-attr/all-builtins.rs b/tests/ui/spirv-attr/all-builtins.rs index 3f79ae484e..cd83259d39 100644 --- a/tests/ui/spirv-attr/all-builtins.rs +++ b/tests/ui/spirv-attr/all-builtins.rs @@ -1,6 +1,6 @@ // build-pass // only-vulkan1.1 -// compile-flags: -Ctarget-feature=+DeviceGroup,+DrawParameters,+FragmentBarycentricNV,+FragmentDensityEXT,+FragmentFullyCoveredEXT,+Geometry,+GroupNonUniform,+GroupNonUniformBallot,+MeshShadingNV,+MultiView,+MultiViewport,+RayTracingKHR,+SampleRateShading,+ShaderSMBuiltinsNV,+ShaderStereoViewNV,+StencilExportEXT,+Tessellation,+ext:SPV_AMD_shader_explicit_vertex_parameter,+ext:SPV_EXT_fragment_fully_covered,+ext:SPV_EXT_fragment_invocation_density,+ext:SPV_EXT_shader_stencil_export,+ext:SPV_KHR_ray_tracing,+ext:SPV_NV_fragment_shader_barycentric,+ext:SPV_NV_mesh_shader,+ext:SPV_NV_shader_sm_builtins,+ext:SPV_NV_stereo_view_rendering +// compile-flags: -Ctarget-feature=+DeviceGroup,+DrawParameters,+FragmentBarycentricNV,+FragmentBarycentricKHR,+FragmentDensityEXT,+FragmentFullyCoveredEXT,+Geometry,+GroupNonUniform,+GroupNonUniformBallot,+MeshShadingNV,+MultiView,+MultiViewport,+RayTracingKHR,+SampleRateShading,+ShaderSMBuiltinsNV,+ShaderStereoViewNV,+StencilExportEXT,+Tessellation,+ext:SPV_AMD_shader_explicit_vertex_parameter,+ext:SPV_EXT_fragment_fully_covered,+ext:SPV_EXT_fragment_invocation_density,+ext:SPV_EXT_shader_stencil_export,+ext:SPV_KHR_ray_tracing,+ext:SPV_NV_fragment_shader_barycentric,+ext:SPV_NV_mesh_shader,+ext:SPV_NV_shader_sm_builtins,+ext:SPV_NV_stereo_view_rendering use spirv_std::glam::*; use spirv_std::spirv; @@ -82,11 +82,11 @@ pub fn vertex( #[spirv(fragment)] pub fn fragment( + #[spirv(bary_coord_no_persp)] bary_coord_no_persp: Vec3, #[spirv(bary_coord_no_persp_amd)] bary_coord_no_persp_amd: Vec3, #[spirv(bary_coord_no_persp_centroid_amd)] bary_coord_no_persp_centroid_amd: Vec3, - #[spirv(bary_coord_no_persp_nv)] bary_coord_no_persp_nv: Vec3, #[spirv(bary_coord_no_persp_sample_amd)] bary_coord_no_persp_sample_amd: Vec3, - #[spirv(bary_coord_nv)] bary_coord_nv: Vec3, + #[spirv(bary_coord)] bary_coord: Vec3, #[spirv(bary_coord_pull_model_amd)] bary_coord_pull_model_amd: Vec3, #[spirv(bary_coord_smooth_amd)] bary_coord_smooth_amd: Vec3, #[spirv(bary_coord_smooth_centroid_amd)] bary_coord_smooth_centroid_amd: Vec3,