zink: fix spirv_builder_spec_const_uint
authorKarol Herbst <kherbst@redhat.com>
Tue, 25 Oct 2022 22:02:15 +0000 (00:02 +0200)
committerKarol Herbst <kherbst@redhat.com>
Tue, 25 Oct 2022 22:02:37 +0000 (00:02 +0200)
We need to create the type upfront otherwise the spir-v binary gets
corrupted.

Fixes: c305a2c9625 ("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>

src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c

index 0108826..cd9cae6 100644 (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