zink: fix spirv_builder_spec_const_uint

We need to create the type upfront otherwise the spir-v binary gets
corrupted.

Fixes: c305a2c962 ("zink: move spec constant emission to the types/consts block")
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19310>
This commit is contained in:
Karol Herbst 2022-10-26 00:02:15 +02:00
parent 0c4676a3aa
commit 3128a8cada

View file

@ -1547,10 +1547,11 @@ SpvId
spirv_builder_spec_const_uint(struct spirv_builder *b, int width)
{
assert(width <= 32);
SpvId const_type = spirv_builder_type_uint(b, width);
SpvId result = spirv_builder_new_id(b);
spirv_buffer_prepare(&b->types_const_defs, b->mem_ctx, 4);
spirv_buffer_emit_word(&b->types_const_defs, SpvOpSpecConstant | (4 << 16));
spirv_buffer_emit_word(&b->types_const_defs, spirv_builder_type_uint(b, width));
spirv_buffer_emit_word(&b->types_const_defs, const_type);
spirv_buffer_emit_word(&b->types_const_defs, result);
/* this is the default value for spec constants;
* if any users need a different default, add a param to pass for it