aboutsummaryrefslogtreecommitdiffstats
path: root/src/intel/compiler/brw_shader.cpp
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2019-03-27 17:34:10 -0500
committerKarol Herbst <[email protected]>2019-04-14 22:25:56 +0200
commit6b1c398bcbf1dd1a11db8895e5d642ac3267bdad (patch)
tree168bd53fdc8eefd05f58cfd35c798356986e7a72 /src/intel/compiler/brw_shader.cpp
parent2a36699ed36f753cccaee211a0da4f1b162ff281 (diff)
intel/nir: Take a nir_tex_instr and src index in brw_texture_offset
This makes things a bit simpler and it's also more robust because it no longer has a hard dependency on the offset being a 32-bit value.
Diffstat (limited to 'src/intel/compiler/brw_shader.cpp')
-rw-r--r--src/intel/compiler/brw_shader.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/intel/compiler/brw_shader.cpp b/src/intel/compiler/brw_shader.cpp
index 1b0eeed8415..06f613cf6b5 100644
--- a/src/intel/compiler/brw_shader.cpp
+++ b/src/intel/compiler/brw_shader.cpp
@@ -129,14 +129,13 @@ brw_math_function(enum opcode op)
}
bool
-brw_texture_offset(int *offsets, unsigned num_components, uint32_t *offset_bits)
+brw_texture_offset(const nir_tex_instr *tex, unsigned src,
+ uint32_t *offset_bits_out)
{
- if (!offsets) return false; /* nonconstant offset; caller will handle it. */
+ if (!nir_src_is_const(tex->src[src].src))
+ return false;
- /* offset out of bounds; caller will handle it. */
- for (unsigned i = 0; i < num_components; i++)
- if (offsets[i] > 7 || offsets[i] < -8)
- return false;
+ const unsigned num_components = nir_tex_instr_src_size(tex, src);
/* Combine all three offsets into a single unsigned dword:
*
@@ -144,11 +143,20 @@ brw_texture_offset(int *offsets, unsigned num_components, uint32_t *offset_bits)
* bits 7:4 - V Offset (Y component)
* bits 3:0 - R Offset (Z component)
*/
- *offset_bits = 0;
+ uint32_t offset_bits = 0;
for (unsigned i = 0; i < num_components; i++) {
+ int offset = nir_src_comp_as_int(tex->src[src].src, i);
+
+ /* offset out of bounds; caller will handle it. */
+ if (offset > 7 || offset < -8)
+ return false;
+
const unsigned shift = 4 * (2 - i);
- *offset_bits |= (offsets[i] << shift) & (0xF << shift);
+ offset_bits |= (offset << shift) & (0xF << shift);
}
+
+ *offset_bits_out = offset_bits;
+
return true;
}