diff options
| -rw-r--r-- | src/codegen/spirv.zig | 25 | ||||
| -rw-r--r-- | src/link/SpirV/deduplicate.zig | 8 |
2 files changed, 26 insertions, 7 deletions
diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig index e305b7ec92..16b4a6dfbd 100644 --- a/src/codegen/spirv.zig +++ b/src/codegen/spirv.zig @@ -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; } diff --git a/src/link/SpirV/deduplicate.zig b/src/link/SpirV/deduplicate.zig index f639644f7b..53d79b006f 100644 --- a/src/link/SpirV/deduplicate.zig +++ b/src/link/SpirV/deduplicate.zig @@ -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]; |
