[Mesa-dev] [PATCH 4/4] spirv: add support for image variables for image opcodes
Samuel Iglesias Gonsálvez
siglesias at igalia.com
Fri Oct 6 09:36:21 UTC 2017
From: Samuel Iglesias Gonsalvez <correo at samuelig.es>
Signed-off-by: Samuel Iglesias Gonsalvez <correo at samuelig.es>
---
src/compiler/spirv/spirv_to_nir.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index cf7617454de..bc3fb861397 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -1948,7 +1948,8 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,
return;
}
- struct vtn_image_pointer image;
+ struct vtn_image_pointer image = {NULL};
+ nir_deref_var *image_deref = NULL;
switch (opcode) {
case SpvOpAtomicExchange:
@@ -1974,13 +1975,23 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,
break;
case SpvOpImageQuerySize:
- image.image = vtn_value(b, w[3], vtn_value_type_pointer)->pointer;
+ if (vtn_untyped_value(b, w[3])->value_type == vtn_value_type_pointer) {
+ image.image = vtn_value(b, w[3], vtn_value_type_pointer)->pointer;
+ } else {
+ assert(vtn_untyped_value(b, w[3])->value_type == vtn_value_type_image_variable);
+ image_deref = nir_deref_var_create(b, vtn_value(b, w[3], vtn_value_type_image_variable)->var->var);
+ }
image.coord = NULL;
image.sample = NULL;
break;
case SpvOpImageRead:
- image.image = vtn_value(b, w[3], vtn_value_type_pointer)->pointer;
+ if (vtn_untyped_value(b, w[3])->value_type == vtn_value_type_pointer) {
+ image.image = vtn_value(b, w[3], vtn_value_type_pointer)->pointer;
+ } else {
+ assert(vtn_untyped_value(b, w[3])->value_type == vtn_value_type_image_variable);
+ image_deref = nir_deref_var_create(b, vtn_value(b, w[3], vtn_value_type_image_variable)->var->var);
+ }
image.coord = get_image_coord(b, w[4]);
if (count > 5 && (w[5] & SpvImageOperandsSampleMask)) {
@@ -1992,7 +2003,12 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,
break;
case SpvOpImageWrite:
- image.image = vtn_value(b, w[1], vtn_value_type_pointer)->pointer;
+ if (vtn_untyped_value(b, w[1])->value_type == vtn_value_type_pointer) {
+ image.image = vtn_value(b, w[1], vtn_value_type_pointer)->pointer;
+ } else {
+ assert(vtn_untyped_value(b, w[1])->value_type == vtn_value_type_image_variable);
+ image_deref = nir_deref_var_create(b, vtn_value(b, w[1], vtn_value_type_image_variable)->var->var);
+ }
image.coord = get_image_coord(b, w[2]);
/* texel = w[3] */
@@ -2037,7 +2053,8 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,
nir_intrinsic_instr *intrin = nir_intrinsic_instr_create(b->shader, op);
- nir_deref_var *image_deref = vtn_pointer_to_deref(b, image.image);
+ if (!image_deref)
+ image_deref = vtn_pointer_to_deref(b, image.image);
intrin->variables[0] = nir_deref_var_clone(image_deref, intrin);
/* ImageQuerySize doesn't take any extra parameters */
--
2.13.6
More information about the mesa-dev
mailing list