From: Mike Blumenkrantz Date: Thu, 4 Jun 2020 21:01:58 +0000 (-0400) Subject: zink: add spirv_builder methods for OpVectorExtractDynamic and OpVectorInsertDynamic X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c3f6a59d57b657b88f11b62eda7eda5db7bdc08e;p=mesa.git zink: add spirv_builder methods for OpVectorExtractDynamic and OpVectorInsertDynamic based on spirv specs Reviewed-by: Erik Faye-Lund Part-of: --- diff --git a/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c b/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c index 4f4b790cddc..a03d08e06eb 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c +++ b/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c @@ -465,6 +465,42 @@ spirv_builder_emit_vector_shuffle(struct spirv_builder *b, SpvId result_type, return result; } +SpvId +spirv_builder_emit_vector_extract(struct spirv_builder *b, SpvId result_type, + SpvId vector_1, + uint32_t component) +{ + SpvId result = spirv_builder_new_id(b); + + int words = 5; + spirv_buffer_prepare(&b->instructions, words); + spirv_buffer_emit_word(&b->instructions, SpvOpVectorExtractDynamic | (words << 16)); + spirv_buffer_emit_word(&b->instructions, result_type); + spirv_buffer_emit_word(&b->instructions, result); + spirv_buffer_emit_word(&b->instructions, vector_1); + spirv_buffer_emit_word(&b->instructions, spirv_builder_const_uint(b, 32, component)); + return result; +} + +SpvId +spirv_builder_emit_vector_insert(struct spirv_builder *b, SpvId result_type, + SpvId vector_1, + SpvId component, + uint32_t index) +{ + SpvId result = spirv_builder_new_id(b); + + int words = 6; + spirv_buffer_prepare(&b->instructions, words); + spirv_buffer_emit_word(&b->instructions, SpvOpVectorInsertDynamic | (words << 16)); + spirv_buffer_emit_word(&b->instructions, result_type); + spirv_buffer_emit_word(&b->instructions, result); + spirv_buffer_emit_word(&b->instructions, vector_1); + spirv_buffer_emit_word(&b->instructions, component); + spirv_buffer_emit_word(&b->instructions, spirv_builder_const_uint(b, 32, index)); + return result; +} + void spirv_builder_emit_branch(struct spirv_builder *b, SpvId label) { diff --git a/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h b/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h index d13426a637a..00000cf4e99 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h +++ b/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h @@ -192,7 +192,15 @@ spirv_builder_emit_vector_shuffle(struct spirv_builder *b, SpvId result_type, SpvId vector_1, SpvId vector_2, const uint32_t components[], size_t num_components); - +SpvId +spirv_builder_emit_vector_extract(struct spirv_builder *b, SpvId result_type, + SpvId vector_1, + uint32_t component); +SpvId +spirv_builder_emit_vector_insert(struct spirv_builder *b, SpvId result_type, + SpvId vector_1, + SpvId component, + uint32_t index); void spirv_builder_emit_branch(struct spirv_builder *b, SpvId label);