From c5a27b5939427bdc95c926b450ed3de1ff4baafb Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sat, 8 Jan 2011 23:49:23 -0800 Subject: glsl: Change texel offsets to a single vector rvalue. Having these as actual integer values makes it difficult to implement the texture*Offset built-in functions, since the offset is actually a function parameter (which doesn't have a constant value). The original rationale was that some hardware needs these offset baked into the instruction opcode. However, at least i965 should be able to support non-constant offsets. Others should be able to rely on inlining and constant propagation. --- src/glsl/ir_reader.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/glsl/ir_reader.cpp') diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index bff75ed0e8..9ed3d23508 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -869,7 +869,7 @@ ir_reader::read_texture(s_expression *expr) s_symbol *tag = NULL; s_expression *s_sampler = NULL; s_expression *s_coord = NULL; - s_list *s_offset = NULL; + s_expression *s_offset = NULL; s_expression *s_proj = NULL; s_list *s_shadow = NULL; s_expression *s_lod = NULL; @@ -915,18 +915,15 @@ ir_reader::read_texture(s_expression *expr) return NULL; } - // Read texel offset, i.e. (0 0 0) - s_int *offset_x; - s_int *offset_y; - s_int *offset_z; - s_pattern offset_pat[] = { offset_x, offset_y, offset_z }; - if (!MATCH(s_offset, offset_pat)) { - ir_read_error(s_offset, "expected ( )"); - return NULL; + // Read texel offset - either 0 or an rvalue. + s_int *si_offset = SX_AS_INT(s_offset); + if (si_offset == NULL || si_offset->value() != 0) { + tex->offset = read_rvalue(s_offset); + if (tex->offset == NULL) { + ir_read_error(s_offset, "expected 0 or an expression"); + return NULL; + } } - tex->offsets[0] = offset_x->value(); - tex->offsets[1] = offset_y->value(); - tex->offsets[2] = offset_z->value(); if (op != ir_txf) { s_int *proj_as_int = SX_AS_INT(s_proj); -- cgit v1.2.3