Skip to content
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
7 changes: 6 additions & 1 deletion crates/rustc_codegen_spirv/src/codegen_cx/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ impl<'tcx> CodegenCx<'tcx> {
);
has_location = false;
}
SpirvAttribute::Location(index) => {
// Overwrite the current location value for the given storage class.
// The decoration will be assigned below.
decoration_locations.insert(storage_class, index);
}
SpirvAttribute::DescriptorSet(index) => {
self.emit_global().decorate(
variable,
Expand All @@ -195,7 +200,7 @@ impl<'tcx> CodegenCx<'tcx> {
// Assign locations from left to right, incrementing each storage class
// individually.
// TODO: Is this right for UniformConstant? Do they share locations with
// input/outpus?
// input/outputs?
if has_location {
let location = decoration_locations
.entry(storage_class)
Expand Down
8 changes: 8 additions & 0 deletions crates/rustc_codegen_spirv/src/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub struct Symbols {
pub spirv13: Symbol,
pub spirv14: Symbol,
pub spirv15: Symbol,
location: Symbol,
descriptor_set: Symbol,
binding: Symbol,
image: Symbol,
Expand Down Expand Up @@ -383,6 +384,7 @@ impl Symbols {
spirv13: Symbol::intern("spirv1.3"),
spirv14: Symbol::intern("spirv1.4"),
spirv15: Symbol::intern("spirv1.5"),
location: Symbol::intern("location"),
descriptor_set: Symbol::intern("descriptor_set"),
binding: Symbol::intern("binding"),
image: Symbol::intern("image"),
Expand Down Expand Up @@ -442,6 +444,7 @@ pub enum SpirvAttribute {
Builtin(BuiltIn),
StorageClass(StorageClass),
Entry(Entry),
Location(u32),
DescriptorSet(u32),
Binding(u32),
ReallyUnsafeIgnoreBitcasts,
Expand Down Expand Up @@ -499,6 +502,11 @@ pub fn parse_attrs(
Some(x) => Some(SpirvAttribute::DescriptorSet(x)),
None => None,
}
} else if arg.has_name(cx.sym.location) {
match parse_attr_int_value(cx, arg) {
Some(x) => Some(SpirvAttribute::Location(x)),
None => None,
}
} else if arg.has_name(cx.sym.binding) {
match parse_attr_int_value(cx, arg) {
Some(x) => Some(SpirvAttribute::Binding(x)),
Expand Down