diff options
author | Kenneth Graunke <[email protected]> | 2011-10-26 13:51:28 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2011-12-19 16:33:10 -0800 |
commit | 475d70d6ef5feb94efab3923e5607e625f2aee67 (patch) | |
tree | 1d97480557d4a4ab6ba95ac855f0b6084d9c8d62 /src/mesa/drivers/dri/i965/brw_shader.cpp | |
parent | d93aa54d2dea79d8216e10b6bbbb00b0c8443dc2 (diff) |
i965/fs: Factor out texture offset bitfield computation.
We'll want to reuse this for the VS, and it's complex enough that I'd
rather not cut and paste it.
Signed-off-by: Kenneth Graunke <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_shader.cpp')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_shader.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp index 33c9ae57ac2..1845c3d7618 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.cpp +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp @@ -239,3 +239,26 @@ brw_math_function(enum opcode op) return 0; } } + +uint32_t +brw_texture_offset(ir_constant *offset) +{ + assert(offset != NULL); + + signed char offsets[3]; + for (unsigned i = 0; i < offset->type->vector_elements; i++) + offsets[i] = (signed char) offset->value.i[i]; + + /* Combine all three offsets into a single unsigned dword: + * + * bits 11:8 - U Offset (X component) + * bits 7:4 - V Offset (Y component) + * bits 3:0 - R Offset (Z component) + */ + unsigned offset_bits = 0; + for (unsigned i = 0; i < offset->type->vector_elements; i++) { + const unsigned shift = 4 * (2 - i); + offset_bits |= (offsets[i] << shift) & (0xF << shift); + } + return offset_bits; +} |