[Mesa-dev] TGSI texture offset handling

Dave Airlie airlied at gmail.com
Fri Aug 26 09:26:53 PDT 2011

I've involuntarily started looking into this when I tried to add TXF
support, so we need to expand TGSI to add support for texture offsets.

the extreme requirement so far is for textureGatherOffsets which can
accept 4 x ivec2, the normal textureFetchOffset can accept an ivec3.
The hardware seems to only tolerate -8..+7 ranges, but the interface
is quite open and as Brian pointed out its queryable.

So adding extra src regs doesn't seem like the right answer going
forward (my last TXF patch did that). It really looks like expanding
the tgsi_instruction_texture token is the best plan, but it really
doesn't have the space to store 4 * ivec2 in it. Adding a new
tgsi_instruction_offset token with the values in it doesn't really
work so well either, since the GLSL compiler gives us ir_constant and
we parse those into the immediates file.

My current plan looks like

struct tgsi_instruction_texture
   unsigned Texture  : 8;    /* TGSI_TEXTURE_ */
   unsigned OffsetNum : 4;
   unsigned OffsetFile : 4;

struct tgsi_instruction_offset
   int Index:16;
   unsigned SwizzleX : 2;  /* TGSI_SWIZZLE_x */
   unsigned SwizzleY : 2;  /* TGSI_SWIZZLE_x */
   unsigned SwizzleZ : 2;  /* TGSI_SWIZZLE_x */

Where OffsetFile will most likely be always the IMMEDIATE file, then
we just add 4 tgsi_instruction_offset to tgsi_full_instruction and go
from there.

Anyone see any problems with this? I'm sure someone will have an
alternate method that I've tried today and given up on.

has some of the other ideas myself and calim have been back and
forwarding on today.


More information about the mesa-dev mailing list