spirv_builder_emit_unop(struct spirv_builder *b, SpvOp op, SpvId result_type,
SpvId operand)
{
+ struct spirv_buffer *buf = op == SpvOpSpecConstant ? &b->types_const_defs : &b->instructions;
SpvId result = spirv_builder_new_id(b);
- spirv_buffer_prepare(&b->instructions, b->mem_ctx, 4);
- spirv_buffer_emit_word(&b->instructions, op | (4 << 16));
- spirv_buffer_emit_word(&b->instructions, result_type);
- spirv_buffer_emit_word(&b->instructions, result);
- spirv_buffer_emit_word(&b->instructions, operand);
+ spirv_buffer_prepare(buf, b->mem_ctx, 4);
+ spirv_buffer_emit_word(buf, op | (4 << 16));
+ spirv_buffer_emit_word(buf, result_type);
+ spirv_buffer_emit_word(buf, result);
+ spirv_buffer_emit_word(buf, operand);
return result;
}
spirv_builder_emit_triop(struct spirv_builder *b, SpvOp op, SpvId result_type,
SpvId operand0, SpvId operand1, SpvId operand2)
{
+ struct spirv_buffer *buf = op == SpvOpSpecConstantOp ? &b->types_const_defs : &b->instructions;
+
SpvId result = spirv_builder_new_id(b);
- spirv_buffer_prepare(&b->instructions, b->mem_ctx, 6);
- spirv_buffer_emit_word(&b->instructions, op | (6 << 16));
- spirv_buffer_emit_word(&b->instructions, result_type);
- spirv_buffer_emit_word(&b->instructions, result);
- spirv_buffer_emit_word(&b->instructions, operand0);
- spirv_buffer_emit_word(&b->instructions, operand1);
- spirv_buffer_emit_word(&b->instructions, operand2);
+ spirv_buffer_prepare(buf, b->mem_ctx, 6);
+ spirv_buffer_emit_word(buf, op | (6 << 16));
+ spirv_buffer_emit_word(buf, result_type);
+ spirv_buffer_emit_word(buf, result);
+ spirv_buffer_emit_word(buf, operand0);
+ spirv_buffer_emit_word(buf, operand1);
+ spirv_buffer_emit_word(buf, operand2);
return result;
}
spirv_builder_emit_quadop(struct spirv_builder *b, SpvOp op, SpvId result_type,
SpvId operand0, SpvId operand1, SpvId operand2, SpvId operand3)
{
+ struct spirv_buffer *buf = op == SpvOpSpecConstantOp ? &b->types_const_defs : &b->instructions;
+
SpvId result = spirv_builder_new_id(b);
- spirv_buffer_prepare(&b->instructions, b->mem_ctx, 7);
- spirv_buffer_emit_word(&b->instructions, op | (7 << 16));
- spirv_buffer_emit_word(&b->instructions, result_type);
- spirv_buffer_emit_word(&b->instructions, result);
- spirv_buffer_emit_word(&b->instructions, operand0);
- spirv_buffer_emit_word(&b->instructions, operand1);
- spirv_buffer_emit_word(&b->instructions, operand2);
- spirv_buffer_emit_word(&b->instructions, operand3);
+ spirv_buffer_prepare(buf, b->mem_ctx, 7);
+ spirv_buffer_emit_word(buf, op | (7 << 16));
+ spirv_buffer_emit_word(buf, result_type);
+ spirv_buffer_emit_word(buf, result);
+ spirv_buffer_emit_word(buf, operand0);
+ spirv_buffer_emit_word(buf, operand1);
+ spirv_buffer_emit_word(buf, operand2);
+ spirv_buffer_emit_word(buf, operand3);
return result;
}
SpvId operand0, SpvId operand1, SpvId operand2, SpvId operand3,
SpvId operand4, SpvId operand5)
{
+ struct spirv_buffer *buf = op == SpvOpSpecConstantOp ? &b->types_const_defs : &b->instructions;
+
SpvId result = spirv_builder_new_id(b);
- spirv_buffer_prepare(&b->instructions, b->mem_ctx, 9);
- spirv_buffer_emit_word(&b->instructions, op | (9 << 16));
- spirv_buffer_emit_word(&b->instructions, result_type);
- spirv_buffer_emit_word(&b->instructions, result);
- spirv_buffer_emit_word(&b->instructions, operand0);
- spirv_buffer_emit_word(&b->instructions, operand1);
- spirv_buffer_emit_word(&b->instructions, operand2);
- spirv_buffer_emit_word(&b->instructions, operand3);
- spirv_buffer_emit_word(&b->instructions, operand4);
- spirv_buffer_emit_word(&b->instructions, operand5);
+ spirv_buffer_prepare(buf, b->mem_ctx, 9);
+ spirv_buffer_emit_word(buf, op | (9 << 16));
+ spirv_buffer_emit_word(buf, result_type);
+ spirv_buffer_emit_word(buf, result);
+ spirv_buffer_emit_word(buf, operand0);
+ spirv_buffer_emit_word(buf, operand1);
+ spirv_buffer_emit_word(buf, operand2);
+ spirv_buffer_emit_word(buf, operand3);
+ spirv_buffer_emit_word(buf, operand4);
+ spirv_buffer_emit_word(buf, operand5);
return result;
}