diff options
author | Xiang, Haihao <haihao.xiang@intel.com> | 2008-01-07 14:08:36 +0800 |
---|---|---|
committer | Xiang, Haihao <haihao.xiang@intel.com> | 2008-01-07 14:08:36 +0800 |
commit | 3369cd9a6f943365242d7832e69788d4aede9a8f (patch) | |
tree | 2cf235e7a047cdd109d293cab7ac1f27e3abc5a9 /src/mesa/drivers/dri/i915/i915_program.c | |
parent | 601a6b872c33bfe3cb4ea03a5a8ba5ebe92dedaf (diff) |
i915: Keith Whitwell's swizzling TEX patch. fix #8283
Diffstat (limited to 'src/mesa/drivers/dri/i915/i915_program.c')
-rw-r--r-- | src/mesa/drivers/dri/i915/i915_program.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/src/mesa/drivers/dri/i915/i915_program.c b/src/mesa/drivers/dri/i915/i915_program.c index c6c6434023..f79d00ddcf 100644 --- a/src/mesa/drivers/dri/i915/i915_program.c +++ b/src/mesa/drivers/dri/i915/i915_program.c @@ -194,27 +194,43 @@ i915_emit_arith(struct i915_fragment_program * p, return dest; } +static GLuint get_free_rreg (struct i915_fragment_program *p, + GLuint live_regs) +{ + int bit = ffs(~live_regs); + if (!bit) { + i915_program_error(p, "Can't find free R reg"); + return UREG_BAD; + } + return UREG(REG_TYPE_R, bit - 1); +} + GLuint i915_emit_texld( struct i915_fragment_program *p, + GLuint live_regs, GLuint dest, GLuint destmask, GLuint sampler, GLuint coord, GLuint op ) { - if (coord != UREG(GET_UREG_TYPE(coord), GET_UREG_NR(coord))) { - /* No real way to work around this in the general case - need to - * allocate and declare a new temporary register (a utemp won't - * do). Will fallback for now. - */ - i915_program_error(p, "Can't (yet) swizzle TEX arguments"); - return 0; - } - - /* Don't worry about saturate as we only support + if (coord != UREG(GET_UREG_TYPE(coord), GET_UREG_NR(coord))) { + /* With the help of the "needed registers" table created earlier, pick + * a register we can MOV the swizzled TC to (since TEX doesn't support + * swizzled sources) */ + GLuint swizCoord = get_free_rreg(p, live_regs); + if (swizCoord == UREG_BAD) + return 0; + + i915_emit_arith( p, A0_MOV, swizCoord, A0_DEST_CHANNEL_ALL, 0, coord, 0, 0 ); + coord = swizCoord; + } + + /* Don't worry about saturate as we only support texture formats + * that are always in the 0..1 range. */ if (destmask != A0_DEST_CHANNEL_ALL) { GLuint tmp = i915_get_utemp(p); - i915_emit_texld( p, tmp, A0_DEST_CHANNEL_ALL, sampler, coord, op ); + i915_emit_texld( p, 0, tmp, A0_DEST_CHANNEL_ALL, sampler, coord, op ); i915_emit_arith( p, A0_MOV, dest, destmask, 0, tmp, 0, 0 ); return dest; } |