* use offset_value.file to distinguish between no offset, a constant
* offset, and a non-constant offset.
*/
- offset_value = fs_reg(brw_texture_offset(ctx, const_offset));
+ offset_value =
+ fs_reg(brw_texture_offset(ctx, const_offset->value.i,
+ const_offset->type->vector_elements));
} else {
ir->offset->accept(this);
offset_value = this->result;
}
uint32_t
-brw_texture_offset(struct gl_context *ctx, ir_constant *offset)
+brw_texture_offset(struct gl_context *ctx, int *offsets,
+ unsigned num_components)
{
/* If the driver does not support GL_ARB_gpu_shader5, the offset
* must be constant.
*/
- assert(offset != NULL || ctx->Extensions.ARB_gpu_shader5);
+ assert(offsets != NULL || ctx->Extensions.ARB_gpu_shader5);
- if (!offset) return 0; /* nonconstant offset; caller will handle it. */
-
- signed char offsets[3];
- for (unsigned i = 0; i < offset->type->vector_elements; i++)
- offsets[i] = (signed char) offset->value.i[i];
+ if (!offsets) return 0; /* nonconstant offset; caller will handle it. */
/* Combine all three offsets into a single unsigned dword:
*
* bits 3:0 - R Offset (Z component)
*/
unsigned offset_bits = 0;
- for (unsigned i = 0; i < offset->type->vector_elements; i++) {
+ for (unsigned i = 0; i < num_components; i++) {
const unsigned shift = 4 * (2 - i);
offset_bits |= (offsets[i] << shift) & (0xF << shift);
}
virtual void invalidate_live_intervals() = 0;
};
-uint32_t brw_texture_offset(struct gl_context *ctx, ir_constant *offset);
+uint32_t brw_texture_offset(struct gl_context *ctx, int *offsets,
+ unsigned num_components);
#endif /* __cplusplus */
vec4_instruction *inst = new(mem_ctx) vec4_instruction(this, opcode);
- if (ir->offset != NULL)
- inst->texture_offset = brw_texture_offset(ctx, ir->offset->as_constant());
+ if (ir->offset != NULL && !has_nonconstant_offset) {
+ inst->texture_offset =
+ brw_texture_offset(ctx, ir->offset->as_constant()->value.i,
+ ir->offset->type->vector_elements);
+ }
/* Stuff the channel select bits in the top of the texture offset */
if (ir->op == ir_tg4)