mirror of
https://github.com/ziglang/zig.git
synced 2024-11-13 23:52:57 +00:00
spirv: dont emit forward pointer for annotation instructions
This commit is contained in:
parent
89bd987f1c
commit
efb7539cb6
@ -4370,13 +4370,24 @@ const NavGen = struct {
|
||||
defer self.gpa.free(ids);
|
||||
|
||||
const result_id = self.spv.allocId();
|
||||
try self.func.body.emit(self.spv.gpa, .OpInBoundsPtrAccessChain, .{
|
||||
.id_result_type = result_ty_id,
|
||||
.id_result = result_id,
|
||||
.base = base,
|
||||
.element = element,
|
||||
.indexes = ids,
|
||||
});
|
||||
const target = self.getTarget();
|
||||
switch (target.os.tag) {
|
||||
.opencl => try self.func.body.emit(self.spv.gpa, .OpInBoundsPtrAccessChain, .{
|
||||
.id_result_type = result_ty_id,
|
||||
.id_result = result_id,
|
||||
.base = base,
|
||||
.element = element,
|
||||
.indexes = ids,
|
||||
}),
|
||||
.vulkan => try self.func.body.emit(self.spv.gpa, .OpPtrAccessChain, .{
|
||||
.id_result_type = result_ty_id,
|
||||
.id_result = result_id,
|
||||
.base = base,
|
||||
.element = element,
|
||||
.indexes = ids,
|
||||
}),
|
||||
else => unreachable,
|
||||
}
|
||||
return result_id;
|
||||
}
|
||||
|
||||
|
@ -511,6 +511,14 @@ pub fn run(parser: *BinaryModule.Parser, binary: *BinaryModule, progress: std.Pr
|
||||
}
|
||||
|
||||
if (maybe_result_id_offset == null or maybe_result_id_offset.? != i) {
|
||||
// Only emit forward pointers before type, constant, and global instructions.
|
||||
// Debug and Annotation instructions don't need the forward pointer, and it
|
||||
// messes up the logical layout of the module.
|
||||
switch (inst.opcode.class()) {
|
||||
.TypeDeclaration, .ConstantCreation, .Memory => {},
|
||||
else => continue,
|
||||
}
|
||||
|
||||
const id: ResultId = @enumFromInt(operand.*);
|
||||
const index = info.entities.getIndex(id) orelse continue;
|
||||
const entity = info.entities.values()[index];
|
||||
|
Loading…
Reference in New Issue
Block a user