From 34f9a5f3018b40476d1a126f02842914abc0f1dd Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 20 Jan 2016 11:11:30 -0800 Subject: [PATCH] nir/spirv: Pull texture dimensionality out of the image when available --- src/glsl/nir/spirv/spirv_to_nir.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/glsl/nir/spirv/spirv_to_nir.c b/src/glsl/nir/spirv/spirv_to_nir.c index 56fcd93..e8ce588 100644 --- a/src/glsl/nir/spirv/spirv_to_nir.c +++ b/src/glsl/nir/spirv/spirv_to_nir.c @@ -2512,11 +2512,16 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode, memcpy(instr->src, srcs, instr->num_srcs * sizeof(*instr->src)); - const struct glsl_type *sampler_type = - nir_deref_tail(&sampled.sampler->deref)->type; - instr->sampler_dim = glsl_get_sampler_dim(sampler_type); - instr->is_array = glsl_sampler_type_is_array(sampler_type); - instr->is_shadow = glsl_sampler_type_is_shadow(sampler_type); + const struct glsl_type *image_type; + if (sampled.image) { + image_type = nir_deref_tail(&sampled.image->deref)->type; + } else { + image_type = nir_deref_tail(&sampled.sampler->deref)->type; + } + + instr->sampler_dim = glsl_get_sampler_dim(image_type); + instr->is_array = glsl_sampler_type_is_array(image_type); + instr->is_shadow = glsl_sampler_type_is_shadow(image_type); instr->is_new_style_shadow = instr->is_shadow; if (has_coord) { @@ -2544,7 +2549,7 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode, instr->coord_components = 0; } - switch (glsl_get_sampler_result_type(sampler_type)) { + switch (glsl_get_sampler_result_type(image_type)) { case GLSL_TYPE_FLOAT: instr->dest_type = nir_type_float; break; case GLSL_TYPE_INT: instr->dest_type = nir_type_int; break; case GLSL_TYPE_UINT: instr->dest_type = nir_type_uint; break; -- 2.7.4