SPIR-V: Make emitting binary more efficient

This commit is contained in:
Robin Voetter
2021-01-19 01:29:01 +01:00
parent 02c138fe70
commit 71ac82ecb0
2 changed files with 66 additions and 19 deletions

View File

@@ -19,4 +19,10 @@ pub const SPIRVModule = struct {
pub fn genDecl(self: SPIRVModule, id: u32, code: *std.ArrayList(u32), decl: *Decl) !void {
}
pub fn writeInstruction(code: *std.ArrayList(u32), instr: spec.Opcode, args: []const u32) !void {
const word_count = @intCast(u32, args.len + 1);
try code.append((word_count << 16) | @enumToInt(instr));
try code.appendSlice(args);
}
};