spirv: more fixes and improvements

- Formatting.
- Improve `decorate` helper function to generate a decoration for a result-id.
- Reorder some functions in a more logical way
This commit is contained in:
Robin Voetter
2022-11-29 23:44:31 +01:00
parent 700dee34d5
commit 8a00ec162c
3 changed files with 132 additions and 139 deletions

View File

@@ -65,34 +65,6 @@ pub fn emit(
section.writeOperands(opcode.Operands(), operands);
}
/// Decorate a result-id.
pub fn decorate(
section: *Section,
allocator: Allocator,
target: spec.IdRef,
decoration: spec.Decoration.Extended,
) !void {
try section.emit(allocator, .OpDecorate, .{
.target = target,
.decoration = decoration,
});
}
/// Decorate a result-id which is a member of some struct.
pub fn decorateMember(
section: *Section,
allocator: Allocator,
structure_type: spec.IdRef,
member: u32,
decoration: spec.Decoration.Extended,
) !void {
try section.emit(allocator, .OpMemberDecorate, .{
.structure_type = structure_type,
.member = member,
.decoration = decoration,
});
}
pub fn writeWord(section: *Section, word: Word) void {
section.instructions.appendAssumeCapacity(word);
}