}
+#define SWIZZLE_ZWWW MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W)
+
/**
* Return the VERT_ATTRIB_* or FRAG_ATTRIB_* value that corresponds to
* a vertex or fragment program input variable. Return -1 if the input
{ "gl_FragCoord", FRAG_ATTRIB_WPOS, SWIZZLE_NOOP },
{ "gl_Color", FRAG_ATTRIB_COL0, SWIZZLE_NOOP },
{ "gl_SecondaryColor", FRAG_ATTRIB_COL1, SWIZZLE_NOOP },
- { "gl_FogFragCoord", FRAG_ATTRIB_FOGC, SWIZZLE_XXXX },
{ "gl_TexCoord", FRAG_ATTRIB_TEX0, SWIZZLE_NOOP },
+ /* note: we're packing several quantities into the fogcoord vector */
+ { "gl_FogFragCoord", FRAG_ATTRIB_FOGC, SWIZZLE_XXXX },
{ "gl_FrontFacing", FRAG_ATTRIB_FOGC, SWIZZLE_YYYY }, /*XXX*/
+ { "gl_PointCoord", FRAG_ATTRIB_FOGC, SWIZZLE_ZWWW },
{ NULL, 0, SWIZZLE_NOOP }
};
GLuint i;
#include "library/slang_120_core_gc.h"
};
+static const byte slang_120_fragment_gc[] = {
+#include "library/slang_builtin_120_fragment_gc.h"
+};
+
static const byte slang_common_builtin_gc[] = {
#include "library/slang_common_builtin_gc.h"
};
SLANG_UNIT_FRAGMENT_BUILTIN, infolog, NULL,
&object->builtin[SLANG_BUILTIN_COMMON], NULL))
return GL_FALSE;
+#if FEATURE_ARB_shading_language_120
+ if (!compile_binary(slang_120_fragment_gc,
+ &object->builtin[SLANG_BUILTIN_TARGET],
+ SLANG_UNIT_FRAGMENT_BUILTIN, infolog, NULL,
+ &object->builtin[SLANG_BUILTIN_COMMON], NULL))
+ return GL_FALSE;
+#endif
}
else if (type == SLANG_UNIT_VERTEX_SHADER) {
if (!compile_binary(slang_vertex_builtin_gc,
SWcontext *swrast = SWRAST_CONTEXT(ctx);
SWspan span;
GLfloat size;
- GLuint tCoords[MAX_TEXTURE_COORD_UNITS];
+ GLuint tCoords[MAX_TEXTURE_COORD_UNITS + 1];
GLuint numTcoords = 0;
GLfloat t0, dtdy;
span.attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0F;
span.attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F;
- ATTRIB_LOOP_BEGIN
- if (attr >= FRAG_ATTRIB_TEX0 && attr < FRAG_ATTRIB_VAR0) {
- const GLuint u = attr - FRAG_ATTRIB_TEX0;
- /* a texcoord */
- if (ctx->Point.CoordReplace[u]) {
- GLfloat s, r, dsdx;
-
- s = 0.0;
- dsdx = 1.0 / size;
-
- if (ctx->Point.SpriteOrigin == GL_LOWER_LEFT) {
- t0 = 0.0;
- dtdy = 1.0 / size;
- }
- else {
- /* GL_UPPER_LEFT */
- t0 = 1.0;
- dtdy = -1.0 / size;
- }
- tCoords[numTcoords++] = attr;
-
- if (ctx->Point.SpriteRMode == GL_ZERO)
- r = 0.0F;
- else if (ctx->Point.SpriteRMode == GL_S)
- r = vert->attrib[attr][0];
- else /* GL_R */
- r = vert->attrib[attr][2];
-
- span.attrStart[attr][0] = s;
- span.attrStart[attr][1] = 0.0; /* overwritten below */
- span.attrStart[attr][2] = r;
- span.attrStart[attr][3] = 1.0;
-
- span.attrStepX[attr][0] = dsdx;
- span.attrStepX[attr][1] = 0.0;
- span.attrStepX[attr][2] = 0.0;
- span.attrStepX[attr][3] = 0.0;
-
- span.attrStepY[attr][0] = 0.0;
- span.attrStepY[attr][1] = dtdy;
- span.attrStepY[attr][2] = 0.0;
- span.attrStepY[attr][3] = 0.0;
+ {
+ GLfloat s, r, dsdx;
+
+ /* texcoord / pointcoord interpolants */
+ s = 0.0;
+ dsdx = 1.0 / size;
+ if (ctx->Point.SpriteOrigin == GL_LOWER_LEFT) {
+ t0 = 0.0;
+ dtdy = 1.0 / size;
+ }
+ else {
+ /* GL_UPPER_LEFT */
+ t0 = 1.0;
+ dtdy = -1.0 / size;
+ }
+ ATTRIB_LOOP_BEGIN
+ if (attr >= FRAG_ATTRIB_TEX0 && attr < FRAG_ATTRIB_VAR0) {
+ const GLuint u = attr - FRAG_ATTRIB_TEX0;
+ /* a texcoord */
+ if (ctx->Point.CoordReplace[u]) {
+ tCoords[numTcoords++] = attr;
+
+ if (ctx->Point.SpriteRMode == GL_ZERO)
+ r = 0.0F;
+ else if (ctx->Point.SpriteRMode == GL_S)
+ r = vert->attrib[attr][0];
+ else /* GL_R */
+ r = vert->attrib[attr][2];
+
+ span.attrStart[attr][0] = s;
+ span.attrStart[attr][1] = 0.0; /* overwritten below */
+ span.attrStart[attr][2] = r;
+ span.attrStart[attr][3] = 1.0;
+
+ span.attrStepX[attr][0] = dsdx;
+ span.attrStepX[attr][1] = 0.0;
+ span.attrStepX[attr][2] = 0.0;
+ span.attrStepX[attr][3] = 0.0;
+
+ span.attrStepY[attr][0] = 0.0;
+ span.attrStepY[attr][1] = dtdy;
+ span.attrStepY[attr][2] = 0.0;
+ span.attrStepY[attr][3] = 0.0;
+
+ continue;
+ }
+ }
+ else if (attr == FRAG_ATTRIB_FOGC) {
+ /* GLSL gl_PointCoord is stored in fog.zw */
+ span.attrStart[FRAG_ATTRIB_FOGC][2] = 0.0;
+ span.attrStart[FRAG_ATTRIB_FOGC][3] = 0.0; /* t0 set below */
+ span.attrStepX[FRAG_ATTRIB_FOGC][2] = dsdx;
+ span.attrStepX[FRAG_ATTRIB_FOGC][3] = 0.0;
+ span.attrStepY[FRAG_ATTRIB_FOGC][2] = 0.0;
+ span.attrStepY[FRAG_ATTRIB_FOGC][3] = dtdy;
+ tCoords[numTcoords++] = FRAG_ATTRIB_FOGC;
continue;
}
- }
- /* use vertex's texcoord/attrib */
- COPY_4V(span.attrStart[attr], vert->attrib[attr]);
- ASSIGN_4V(span.attrStepX[attr], 0, 0, 0, 0);
- ASSIGN_4V(span.attrStepY[attr], 0, 0, 0, 0);
- ATTRIB_LOOP_END
+ /* use vertex's texcoord/attrib */
+ COPY_4V(span.attrStart[attr], vert->attrib[attr]);
+ ASSIGN_4V(span.attrStepX[attr], 0, 0, 0, 0);
+ ASSIGN_4V(span.attrStepY[attr], 0, 0, 0, 0);
+ ATTRIB_LOOP_END;
+ }
/* compute pos, bounds and render */
{
GLuint i;
/* setup texcoord T for this row */
for (i = 0; i < numTcoords; i++) {
- span.attrStart[tCoords[i]][1] = tcoord;
+ if (tCoords[i] == FRAG_ATTRIB_FOGC)
+ span.attrStart[FRAG_ATTRIB_FOGC][3] = tcoord;
+ else
+ span.attrStart[tCoords[i]][1] = tcoord;
}
/* these might get changed by span clipping */