[Mesa-dev] [PATCH 1/2] spirv: implement support for OpAtomicStore for image pointers
Samuel Iglesias Gonsálvez
siglesias at igalia.com
Wed Jul 4 08:10:59 UTC 2018
Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
---
src/compiler/spirv/spirv_to_nir.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index fb4211193fb..e8ab48012f5 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -2462,6 +2462,24 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,
vtn_fail("Invalid image opcode");
}
+ if (opcode == SpvOpAtomicStore) {
+ /* The image value to store is always 4 components but we may not have that
+ * many. Swizzle to compensate.
+ */
+ nir_ssa_def *val = vtn_ssa_value(b, w[4])->def;
+ const struct glsl_type *val_type = vtn_ssa_value(b, w[4])->type;
+ struct vtn_type *mem_type = vtn_value(b, w[1], vtn_value_type_image_pointer)->type->image;
+ unsigned swiz[4] = {0, 0, 0, 0};
+
+ assert(mem_type->type == val_type);
+
+ /* For nir_intrinsic_image_var_store, the value to write is a vec4 */
+ intrin->src[3] = nir_src_for_ssa(nir_swizzle(&b->nb, val,
+ swiz, 4, false));
+ nir_builder_instr_insert(&b->nb, &intrin->instr);
+ return;
+ }
+
if (opcode != SpvOpImageWrite) {
struct vtn_value *val = vtn_push_value(b, w[2], vtn_value_type_ssa);
struct vtn_type *type = vtn_value(b, w[1], vtn_value_type_type)->type;
--
2.17.1
More information about the mesa-dev
mailing list