diff options
author | Mike Blumenkrantz <[email protected]> | 2020-06-04 17:01:58 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-06-17 20:42:01 +0000 |
commit | c3f6a59d57b657b88f11b62eda7eda5db7bdc08e (patch) | |
tree | 94e6dce16173eb89603e37d59d9784e811ed1d6e | |
parent | 14dbf51d7fdf2e1e601039f9fea8be9c28c58e1f (diff) |
zink: add spirv_builder methods for OpVectorExtractDynamic and OpVectorInsertDynamic
based on spirv specs
Reviewed-by: Erik Faye-Lund <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5163>
-rw-r--r-- | src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c | 36 | ||||
-rw-r--r-- | src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h | 10 |
2 files changed, 45 insertions, 1 deletions
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); |