Skip to content

Commit

Permalink
thread access through to abi
Browse files Browse the repository at this point in the history
  • Loading branch information
schell committed Oct 11, 2024
1 parent c9ba1f7 commit 96ccdce
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions crates/rustc_codegen_spirv/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -892,6 +893,7 @@ fn trans_intrinsic_type<'tcx>(
multisampled,
sampled,
image_format,
access_qualifier,
};
Ok(ty.def(span, cx))
}
Expand Down
4 changes: 4 additions & 0 deletions crates/rustc_codegen_spirv/src/builder/spirv_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 12 additions & 2 deletions crates/rustc_codegen_spirv/src/spirv_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -74,6 +76,7 @@ pub enum SpirvType<'tcx> {
multisampled: u32,
sampled: u32,
image_format: ImageFormat,
access_qualifier: Option<AccessQualifier>,
},
Sampler,
SampledImage {
Expand Down Expand Up @@ -241,6 +244,7 @@ impl SpirvType<'_> {
multisampled,
sampled,
image_format,
access_qualifier,
} => cx.emit_global().type_image_id(
id,
sampled_type,
Expand All @@ -250,7 +254,7 @@ impl SpirvType<'_> {
multisampled,
sampled,
image_format,
None,
access_qualifier,
),
Self::Sampler => cx.emit_global().type_sampler_id(id),
Self::AccelerationStructureKhr => {
Expand Down Expand Up @@ -416,6 +420,7 @@ impl SpirvType<'_> {
multisampled,
sampled,
image_format,
access_qualifier,
} => SpirvType::Image {
sampled_type,
dim,
Expand All @@ -424,6 +429,7 @@ impl SpirvType<'_> {
multisampled,
sampled,
image_format,
access_qualifier,
},
SpirvType::Sampler => SpirvType::Sampler,
SpirvType::SampledImage { image_type } => SpirvType::SampledImage { image_type },
Expand Down Expand Up @@ -579,6 +585,7 @@ impl fmt::Debug for SpirvTypePrinter<'_, '_> {
multisampled,
sampled,
image_format,
access_qualifier,
} => f
.debug_struct("Image")
.field("id", &self.id)
Expand All @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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
Expand Down

0 comments on commit 96ccdce

Please sign in to comment.