zink: add spirv builder for unops with a const operand

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10510>
This commit is contained in:
Mike Blumenkrantz 2021-04-05 09:54:05 -04:00
parent 73210e3a99
commit 0fba3bc236
2 changed files with 16 additions and 0 deletions

View file

@ -467,6 +467,19 @@ spirv_builder_emit_interlock(struct spirv_builder *b, bool end)
spirv_buffer_emit_word(&b->instructions, (end ? SpvOpEndInvocationInterlockEXT : SpvOpBeginInvocationInterlockEXT) | (1 << 16));
}
SpvId
spirv_builder_emit_unop_const(struct spirv_builder *b, SpvOp op, SpvId result_type, uint64_t operand)
{
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, spirv_builder_const_uint(b, 32, operand));
return result;
}
SpvId
spirv_builder_emit_unop(struct spirv_builder *b, SpvOp op, SpvId result_type,
SpvId operand)

View file

@ -190,6 +190,9 @@ spirv_builder_emit_access_chain(struct spirv_builder *b, SpvId result_type,
void
spirv_builder_emit_interlock(struct spirv_builder *b, bool end);
SpvId
spirv_builder_emit_unop_const(struct spirv_builder *b, SpvOp op, SpvId result_type, uint64_t operand);
SpvId
spirv_builder_emit_unop(struct spirv_builder *b, SpvOp op, SpvId result_type,
SpvId operand);