[Mesa-dev] [PATCH 0/2 v3] Add support for clip distances in Gallium

Christoph Bumiller e0425955 at student.tuwien.ac.at
Sun Dec 18 05:55:22 PST 2011


On 17.12.2011 23:15, Bryan Cain wrote:
> This is the third revision of my changes to add support for gl_ClipDistance
> with Gallium.  The difference between this set and v2 is that this set does
> not add a new TGSI_PROPERTY indicating the number of clip distances used.
> Instead, the UsageMask of the CLIPDIST output registers is set to indicate
> which clip distances are used.  Some changes to ureg were necessary to set
> the UsageMask to a value other than XYZW.
 
Looks like it would work, except that the final write to the clip
distance output writes invalid (undeclared) components.

const char *vertprog = "#version 130\n"
   "out float gl_ClipDistance[3];\n"
   "uniform int i;\n"
   "void main() {\n"
   "   gl_FrontColor = gl_Color;\n"
   "   gl_Position = ftransform();\n"
   "   gl_ClipDistance[0] = 1.0;\n"
   "   gl_ClipDistance[1] = 1.0;\n"
   "   gl_ClipDistance[2] = 1.0;\n"
   "   gl_ClipDistance[i] = -0.56;\n"
   "}\n";

VERT
DCL IN[0]
DCL IN[1]
DCL OUT[0], POSITION
DCL OUT[1], COLOR
DCL OUT[2].xyz, CLIPDIST
DCL CONST[0..4]
DCL TEMP[0..4]
DCL ADDR[0]
IMM FLT32 {    1.0000,    -0.5600,     0.0000,     0.0000}
IMM INT32 {3, 0, 1, 2}
  0: MOV OUT[1], IN[1]
  1: MUL TEMP[0], CONST[1], IN[0].xxxx
  2: MAD TEMP[1], CONST[2], IN[0].yyyy, TEMP[0]
  3: MAD TEMP[1], CONST[3], IN[0].zzzz, TEMP[1]
  4: MAD OUT[0], CONST[4], IN[0].wwww, TEMP[1]
  5: MOV TEMP[0].x, IMM[0].xxxx (gl_ClipDistance[0] = 0.0)
  6: MOV TEMP[0].y, IMM[0].xxxx
  7: MOV TEMP[0].z, IMM[0].xxxx
  8: AND TEMP[1].x, CONST[0].xxxx, IMM[1].xxxx
  9: USEQ TEMP[1], TEMP[1].xxxx, IMM[1].yzwx (TEMP[1] = booleans for
each component)
 10: ISHR TEMP[2].x, CONST[0].xxxx, IMM[1].wwww (TEMP[2] == which vec4)
 11: I2F TEMP[3], TEMP[1].xxxx (TEMP[3] == whether to modify x component
(-1.0f if true))
 12: UARL ADDR[0].x, TEMP[2].xxxx
 13: UARL ADDR[0].x, TEMP[2].xxxx
 14: MOV TEMP[4], TEMP[ADDR[0].x] (load last value written)
 15: UARL ADDR[0].x, TEMP[2].xxxx
 16: CMP TEMP[ADDR[0].x].x, TEMP[3].xxxx, IMM[0].yyyy, TEMP[4]
(conditional set)
(repeat for y, z and w)
 38: MOV OUT[2], TEMP[0]
 39: END

Oh, and it's horribly ugly compared to the 1 instruction it could be had
we proper support for arrays.

But, until that's resolved doing it like this will do ...
There's some work going on to make TGSI suitable for OpenCL which will
hopefully bring the necessary changes.

> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev




More information about the mesa-dev mailing list