mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-02 03:38:06 +02:00
zink: add some spirv builder functions for spec constants
we'll be using these soon Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9242>
This commit is contained in:
parent
5d503bf783
commit
10c05f083f
2 changed files with 44 additions and 0 deletions
|
|
@ -214,6 +214,13 @@ spirv_builder_emit_decoration(struct spirv_builder *b, SpvId target,
|
|||
emit_decoration(b, target, decoration, NULL, 0);
|
||||
}
|
||||
|
||||
void
|
||||
spirv_builder_emit_specid(struct spirv_builder *b, SpvId target, uint32_t id)
|
||||
{
|
||||
uint32_t args[] = { id };
|
||||
emit_decoration(b, target, SpvDecorationSpecId, args, ARRAY_SIZE(args));
|
||||
}
|
||||
|
||||
void
|
||||
spirv_builder_emit_location(struct spirv_builder *b, SpvId target,
|
||||
uint32_t location)
|
||||
|
|
@ -1406,6 +1413,13 @@ spirv_builder_const_uint(struct spirv_builder *b, int width, uint64_t val)
|
|||
return emit_constant_64(b, type, val);
|
||||
}
|
||||
|
||||
SpvId
|
||||
spirv_builder_spec_const_uint(struct spirv_builder *b, int width)
|
||||
{
|
||||
assert(width <= 32);
|
||||
return spirv_builder_emit_unop(b, SpvOpSpecConstant, spirv_builder_type_uint(b, width), UINT_MAX);
|
||||
}
|
||||
|
||||
SpvId
|
||||
spirv_builder_const_float(struct spirv_builder *b, int width, double val)
|
||||
{
|
||||
|
|
@ -1427,6 +1441,25 @@ spirv_builder_const_composite(struct spirv_builder *b, SpvId result_type,
|
|||
num_constituents);
|
||||
}
|
||||
|
||||
SpvId
|
||||
spirv_builder_spec_const_composite(struct spirv_builder *b, SpvId result_type,
|
||||
const SpvId constituents[],
|
||||
size_t num_constituents)
|
||||
{
|
||||
SpvId result = spirv_builder_new_id(b);
|
||||
|
||||
assert(num_constituents > 0);
|
||||
int words = 3 + num_constituents;
|
||||
spirv_buffer_prepare(&b->instructions, b->mem_ctx, words);
|
||||
spirv_buffer_emit_word(&b->instructions,
|
||||
SpvOpSpecConstantComposite | (words << 16));
|
||||
spirv_buffer_emit_word(&b->instructions, result_type);
|
||||
spirv_buffer_emit_word(&b->instructions, result);
|
||||
for (int i = 0; i < num_constituents; ++i)
|
||||
spirv_buffer_emit_word(&b->instructions, constituents[i]);
|
||||
return result;
|
||||
}
|
||||
|
||||
SpvId
|
||||
spirv_builder_emit_var(struct spirv_builder *b, SpvId type,
|
||||
SpvStorageClass storage_class)
|
||||
|
|
|
|||
|
|
@ -89,6 +89,9 @@ void
|
|||
spirv_builder_emit_decoration(struct spirv_builder *b, SpvId target,
|
||||
SpvDecoration decoration);
|
||||
|
||||
void
|
||||
spirv_builder_emit_specid(struct spirv_builder *b, SpvId target, uint32_t id);
|
||||
|
||||
void
|
||||
spirv_builder_emit_location(struct spirv_builder *b, SpvId target,
|
||||
uint32_t location);
|
||||
|
|
@ -400,6 +403,9 @@ spirv_builder_const_int(struct spirv_builder *b, int width, int64_t val);
|
|||
SpvId
|
||||
spirv_builder_const_uint(struct spirv_builder *b, int width, uint64_t val);
|
||||
|
||||
SpvId
|
||||
spirv_builder_spec_const_uint(struct spirv_builder *b, int width);
|
||||
|
||||
SpvId
|
||||
spirv_builder_const_float(struct spirv_builder *b, int width, double val);
|
||||
|
||||
|
|
@ -408,6 +414,11 @@ spirv_builder_const_composite(struct spirv_builder *b, SpvId result_type,
|
|||
const SpvId constituents[],
|
||||
size_t num_constituents);
|
||||
|
||||
SpvId
|
||||
spirv_builder_spec_const_composite(struct spirv_builder *b, SpvId result_type,
|
||||
const SpvId constituents[],
|
||||
size_t num_constituents);
|
||||
|
||||
SpvId
|
||||
spirv_builder_emit_var(struct spirv_builder *b, SpvId type,
|
||||
SpvStorageClass storage_class);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue