authorgravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2024-11-02 19:01:41+01:00
committergravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2024-11-09 01:53:13+01:00
logefb7539cb6cd4caf63e17f50c7eace198339460c
tree782befee2d7e15da55d2efea0224252ab5f45492
parent89bd987f1c5f9aed8c7d0f851eae93c7cbf1d70b
signaturebadge-check Signed by SSH key SHA256:ZS52FNyUv2WUXvO4njmVaFVO46RHojFuOrxRc4LuKzg

spirv: dont emit forward pointer for annotation instructions


2 files changed, 26 insertions(+), 7 deletions(-)

src/codegen/spirv.zig+18-7
......@@ -4370,13 +4370,24 @@ const NavGen = struct {
43704370 defer self.gpa.free(ids);
43714371
43724372 const result_id = self.spv.allocId();
4373 try self.func.body.emit(self.spv.gpa, .OpInBoundsPtrAccessChain, .{
4374 .id_result_type = result_ty_id,
4375 .id_result = result_id,
4376 .base = base,
4377 .element = element,
4378 .indexes = ids,
4379 });
4373 const target = self.getTarget();
4374 switch (target.os.tag) {
4375 .opencl => try self.func.body.emit(self.spv.gpa, .OpInBoundsPtrAccessChain, .{
4376 .id_result_type = result_ty_id,
4377 .id_result = result_id,
4378 .base = base,
4379 .element = element,
4380 .indexes = ids,
4381 }),
4382 .vulkan => try self.func.body.emit(self.spv.gpa, .OpPtrAccessChain, .{
4383 .id_result_type = result_ty_id,
4384 .id_result = result_id,
4385 .base = base,
4386 .element = element,
4387 .indexes = ids,
4388 }),
4389 else => unreachable,
4390 }
43804391 return result_id;
43814392 }
43824393
src/link/SpirV/deduplicate.zig+8
......@@ -511,6 +511,14 @@ pub fn run(parser: *BinaryModule.Parser, binary: *BinaryModule, progress: std.Pr
511511 }
512512
513513 if (maybe_result_id_offset == null or maybe_result_id_offset.? != i) {
514 // Only emit forward pointers before type, constant, and global instructions.
515 // Debug and Annotation instructions don't need the forward pointer, and it
516 // messes up the logical layout of the module.
517 switch (inst.opcode.class()) {
518 .TypeDeclaration, .ConstantCreation, .Memory => {},
519 else => continue,
520 }
521
514522 const id: ResultId = @enumFromInt(operand.*);
515523 const index = info.entities.getIndex(id) orelse continue;
516524 const entity = info.entities.values()[index];