zink: move spec constant emission to the types/consts block
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Mon, 17 Oct 2022 12:22:18 +0000 (08:22 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 20 Oct 2022 14:17:05 +0000 (14:17 +0000)
spec constants are used as constants, so emitting them in the instructions
block can create mismatched ordering of the constant usage with other types

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19116>

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

index ff87ba7..9bce374 100644 (file)
@@ -1539,7 +1539,13 @@ 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), 0);
+   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, result);
+   spirv_buffer_emit_word(&b->types_const_defs, 0);
+   return result;
 }
 
 SpvId