Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added image access qualifier, fixes #28 #30

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 53 additions & 53 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion crates/rustc_codegen_spirv/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{AccessQualifier, StorageClass, Word};
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::ErrorGuaranteed;
use rustc_index::Idx;
Expand Down Expand Up @@ -883,6 +883,18 @@ 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 = match const_int_value(cx, args.const_at(8))? {
0u32 => Some(AccessQualifier::ReadOnly),
1u32 => Some(AccessQualifier::WriteOnly),
2u32 => Some(AccessQualifier::ReadWrite),
3u32 => None,
n => {
return Err(cx
.tcx
.dcx()
.err(format!("Invalid value for Image access qualifier: {n}")));
}
};

let ty = SpirvType::Image {
sampled_type,
Expand All @@ -892,6 +904,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
Loading