spirv: dont emit forward pointer for annotation instructions

This commit is contained in:
Robin Voetter 2024-11-02 19:01:41 +01:00
parent 89bd987f1c
commit efb7539cb6
No known key found for this signature in database
2 changed files with 26 additions and 7 deletions

View File

@ -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;
}

View File

@ -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];