From 96ccdcebbaa422c43694880ad7d8803985065397 Mon Sep 17 00:00:00 2001 From: Schell Carl Scivally Date: Fri, 11 Oct 2024 17:14:02 +1300 Subject: [PATCH] thread access through to abi --- crates/rustc_codegen_spirv/src/abi.rs | 2 ++ .../rustc_codegen_spirv/src/builder/spirv_asm.rs | 4 ++++ crates/rustc_codegen_spirv/src/spirv_type.rs | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/crates/rustc_codegen_spirv/src/abi.rs b/crates/rustc_codegen_spirv/src/abi.rs index 7e8cf0a2e2..9401ae0dee 100644 --- a/crates/rustc_codegen_spirv/src/abi.rs +++ b/crates/rustc_codegen_spirv/src/abi.rs @@ -883,6 +883,7 @@ fn trans_intrinsic_type<'tcx>( let multisampled = const_int_value(cx, args.const_at(4))?; let sampled = const_int_value(cx, args.const_at(5))?; let image_format = const_int_value(cx, args.const_at(6))?; + let access_qualifier = const_int_value(cx, args.const_at(7)).ok(); let ty = SpirvType::Image { sampled_type, @@ -892,6 +893,7 @@ fn trans_intrinsic_type<'tcx>( multisampled, sampled, image_format, + access_qualifier, }; Ok(ty.def(span, cx)) } diff --git a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs index d10ddbb91d..d01eafa211 100644 --- a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs +++ b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs @@ -329,6 +329,10 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { multisampled: inst.operands[4].unwrap_literal_int32(), sampled: inst.operands[5].unwrap_literal_int32(), image_format: inst.operands[6].unwrap_image_format(), + access_qualifier: inst + .operands + .get(7) + .map(rspirv::dr::Operand::unwrap_access_qualifier), } .def(self.span(), self), Op::TypeSampledImage => SpirvType::SampledImage { diff --git a/crates/rustc_codegen_spirv/src/spirv_type.rs b/crates/rustc_codegen_spirv/src/spirv_type.rs index ad97e78c52..5545881942 100644 --- a/crates/rustc_codegen_spirv/src/spirv_type.rs +++ b/crates/rustc_codegen_spirv/src/spirv_type.rs @@ -3,7 +3,9 @@ use crate::builder_spirv::SpirvValue; use crate::codegen_cx::CodegenCx; use indexmap::IndexSet; use rspirv::dr::Operand; -use rspirv::spirv::{Capability, Decoration, Dim, ImageFormat, StorageClass, Word}; +use rspirv::spirv::{ + AccessQualifier, Capability, Decoration, Dim, ImageFormat, StorageClass, Word, +}; use rustc_data_structures::fx::FxHashMap; use rustc_middle::span_bug; use rustc_span::def_id::DefId; @@ -74,6 +76,7 @@ pub enum SpirvType<'tcx> { multisampled: u32, sampled: u32, image_format: ImageFormat, + access_qualifier: Option, }, Sampler, SampledImage { @@ -241,6 +244,7 @@ impl SpirvType<'_> { multisampled, sampled, image_format, + access_qualifier, } => cx.emit_global().type_image_id( id, sampled_type, @@ -250,7 +254,7 @@ impl SpirvType<'_> { multisampled, sampled, image_format, - None, + access_qualifier, ), Self::Sampler => cx.emit_global().type_sampler_id(id), Self::AccelerationStructureKhr => { @@ -416,6 +420,7 @@ impl SpirvType<'_> { multisampled, sampled, image_format, + access_qualifier, } => SpirvType::Image { sampled_type, dim, @@ -424,6 +429,7 @@ impl SpirvType<'_> { multisampled, sampled, image_format, + access_qualifier, }, SpirvType::Sampler => SpirvType::Sampler, SpirvType::SampledImage { image_type } => SpirvType::SampledImage { image_type }, @@ -579,6 +585,7 @@ impl fmt::Debug for SpirvTypePrinter<'_, '_> { multisampled, sampled, image_format, + access_qualifier, } => f .debug_struct("Image") .field("id", &self.id) @@ -589,6 +596,7 @@ impl fmt::Debug for SpirvTypePrinter<'_, '_> { .field("multisampled", &multisampled) .field("sampled", &sampled) .field("image_format", &image_format) + .field("access_qualifier", &access_qualifier) .finish(), SpirvType::Sampler => f.debug_struct("Sampler").field("id", &self.id).finish(), SpirvType::SampledImage { image_type } => f @@ -734,6 +742,7 @@ impl SpirvTypePrinter<'_, '_> { multisampled, sampled, image_format, + access_qualifier, } => f .debug_struct("Image") .field("sampled_type", &self.cx.debug_type(sampled_type)) @@ -743,6 +752,7 @@ impl SpirvTypePrinter<'_, '_> { .field("multisampled", &multisampled) .field("sampled", &sampled) .field("image_format", &image_format) + .field("access_qualifier", &access_qualifier) .finish(), SpirvType::Sampler => f.write_str("Sampler"), SpirvType::SampledImage { image_type } => f