diff options
author | Jason Ekstrand <[email protected]> | 2016-02-08 22:12:18 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2016-02-09 10:29:05 -0800 |
commit | 1d65abfa582a371558113f699ffbf16d60b64c90 (patch) | |
tree | c9a021b238d20d480271cfe58ba60c312107819b /src/compiler/nir | |
parent | 209820739bd3869b6c9464737525b4efae33b535 (diff) |
nir/spirv: Better handle constant offsets in texture lookups
Diffstat (limited to 'src/compiler/nir')
-rw-r--r-- | src/compiler/nir/spirv/spirv_to_nir.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/compiler/nir/spirv/spirv_to_nir.c b/src/compiler/nir/spirv/spirv_to_nir.c index ee39b333c1a..c0dd92c36a4 100644 --- a/src/compiler/nir/spirv/spirv_to_nir.c +++ b/src/compiler/nir/spirv/spirv_to_nir.c @@ -1287,6 +1287,8 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode, unreachable("Unhandled opcode"); } + nir_constant *const_offset = NULL; + /* Now we need to handle some number of optional arguments */ if (idx < count) { uint32_t operands = w[idx++]; @@ -1310,8 +1312,12 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode, (*p++) = vtn_tex_src(b, w[idx++], nir_tex_src_ddy); } - if (operands & SpvImageOperandsOffsetMask || - operands & SpvImageOperandsConstOffsetMask) + if (operands & SpvImageOperandsConstOffsetMask) { + const_offset = + vtn_value(b, w[idx++], vtn_value_type_constant)->constant; + } + + if (operands & SpvImageOperandsOffsetMask) (*p++) = vtn_tex_src(b, w[idx++], nir_tex_src_offset); if (operands & SpvImageOperandsConstOffsetsMask) @@ -1343,6 +1349,11 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode, instr->is_shadow = glsl_sampler_type_is_shadow(image_type); instr->is_new_style_shadow = instr->is_shadow; + if (const_offset) { + for (unsigned i = 0; i < 4; i++) + instr->const_offset[i] = const_offset->value.u[i]; + } + if (has_coord) { switch (instr->sampler_dim) { case GLSL_SAMPLER_DIM_1D: |