mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 00:58:05 +02:00
zink: add spirv_builder_function_call
It can be useful not just to create functions, but also being able to call them. This adds the spirv_builder-helper for this. Cc: mesa-stable Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18244>
This commit is contained in:
parent
41dfed6e12
commit
47d67912bd
2 changed files with 27 additions and 0 deletions
|
|
@ -404,6 +404,28 @@ spirv_builder_function_end(struct spirv_builder *b)
|
|||
spirv_buffer_emit_word(&b->instructions, SpvOpFunctionEnd | (1 << 16));
|
||||
}
|
||||
|
||||
SpvId
|
||||
spirv_builder_function_call(struct spirv_builder *b, SpvId result_type,
|
||||
SpvId function, const SpvId arguments[],
|
||||
size_t num_arguments)
|
||||
{
|
||||
SpvId result = spirv_builder_new_id(b);
|
||||
|
||||
int words = 4 + num_arguments;
|
||||
spirv_buffer_prepare(&b->instructions, b->mem_ctx, words);
|
||||
spirv_buffer_emit_word(&b->instructions,
|
||||
SpvOpFunctionCall | (words << 16));
|
||||
spirv_buffer_emit_word(&b->instructions, result_type);
|
||||
spirv_buffer_emit_word(&b->instructions, result);
|
||||
spirv_buffer_emit_word(&b->instructions, function);
|
||||
|
||||
for (int i = 0; i < num_arguments; ++i)
|
||||
spirv_buffer_emit_word(&b->instructions, arguments[i]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
spirv_builder_label(struct spirv_builder *b, SpvId label)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -413,6 +413,11 @@ spirv_builder_type_function(struct spirv_builder *b, SpvId return_type,
|
|||
const SpvId parameter_types[],
|
||||
size_t num_parameter_types);
|
||||
|
||||
SpvId
|
||||
spirv_builder_function_call(struct spirv_builder *b, SpvId result_type,
|
||||
SpvId function, const SpvId arguments[],
|
||||
size_t num_arguments);
|
||||
|
||||
SpvId
|
||||
spirv_builder_const_bool(struct spirv_builder *b, bool val);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue