Home | History | Annotate | Download | only in swrast

Lines Matching refs:span

29  * \brief Span processing functions used by all rasterization functions.
60 * Set default fragment attributes for the span using the
65 _swrast_span_default_attribs(struct gl_context *ctx, SWspan *span)
72 span->z = FloatToFixed(ctx->Current.RasterPos[2] * depthMax + 0.5F);
76 span->z = (GLint)tmpf;
78 span->zStep = 0;
79 span->interpMask |= SPAN_Z;
83 span->attrStart[VARYING_SLOT_POS][3] = 1.0;
84 span->attrStepX[VARYING_SLOT_POS][3] = 0.0;
85 span->attrStepY[VARYING_SLOT_POS][3] = 0.0;
93 span->red = r;
94 span->green = g;
95 span->blue = b;
96 span->alpha = a;
98 span->red = IntToFixed(r);
99 span->green = IntToFixed(g);
100 span->blue = IntToFixed(b);
101 span->alpha = IntToFixed(a);
103 span->redStep = 0;
104 span->greenStep = 0;
105 span->blueStep = 0;
106 span->alphaStep = 0;
107 span->interpMask |= SPAN_RGBA;
109 COPY_4V(span->attrStart[VARYING_SLOT_COL0], ctx->Current.RasterColor);
110 ASSIGN_4V(span->attrStepX[VARYING_SLOT_COL0], 0.0, 0.0, 0.0, 0.0);
111 ASSIGN_4V(span->attrStepY[VARYING_SLOT_COL0], 0.0, 0.0, 0.0, 0.0);
116 COPY_4V(span->attrStart[VARYING_SLOT_COL1], ctx->Current.RasterSecondaryColor);
117 ASSIGN_4V(span->attrStepX[VARYING_SLOT_COL1], 0.0, 0.0, 0.0, 0.0);
118 ASSIGN_4V(span->attrStepY[VARYING_SLOT_COL1], 0.0, 0.0, 0.0, 0.0);
133 span->attrStart[VARYING_SLOT_FOGC][0] = fogVal;
134 span->attrStepX[VARYING_SLOT_FOGC][0] = 0.0;
135 span->attrStepY[VARYING_SLOT_FOGC][0] = 0.0;
146 COPY_4V(span->attrStart[attr], tc);
150 span->attrStart[attr][0] = tc[0] / tc[3];
151 span->attrStart[attr][1] = tc[1] / tc[3];
152 span->attrStart[attr][2] = tc[2] / tc[3];
153 span->attrStart[attr][3] = 1.0;
156 ASSIGN_4V(span->attrStart[attr], 0.0F, 0.0F, 0.0F, 1.0F);
158 ASSIGN_4V(span->attrStepX[attr], 0.0F, 0.0F, 0.0F, 0.0F);
159 ASSIGN_4V(span->attrStepY[attr], 0.0F, 0.0F, 0.0F, 0.0F);
167 * fill in span->array->attribs[].
172 interpolate_active_attribs(struct gl_context *ctx, SWspan *span,
181 attrMask &= ~span->arrayAttribs;
185 const GLfloat dwdx = span->attrStepX[VARYING_SLOT_POS][3];
186 GLfloat w = span->attrStart[VARYING_SLOT_POS][3];
187 const GLfloat dv0dx = span->attrStepX[attr][0];
188 const GLfloat dv1dx = span->attrStepX[attr][1];
189 const GLfloat dv2dx = span->attrStepX[attr][2];
190 const GLfloat dv3dx = span->attrStepX[attr][3];
191 GLfloat v0 = span->attrStart[attr][0] + span->leftClip * dv0dx;
192 GLfloat v1 = span->attrStart[attr][1] + span->leftClip * dv1dx;
193 GLfloat v2 = span->attrStart[attr][2] + span->leftClip * dv2dx;
194 GLfloat v3 = span->attrStart[attr][3] + span->leftClip * dv3dx;
196 for (k = 0; k < span->end; k++) {
198 span->array->attribs[attr][k][0] = v0 * invW;
199 span->array->attribs[attr][k][1] = v1 * invW;
200 span->array->attribs[attr][k][2] = v2 * invW;
201 span->array->attribs[attr][k][3] = v3 * invW;
208 assert((span->arrayAttribs & BITFIELD64_BIT(attr)) == 0);
209 span->arrayAttribs |= BITFIELD64_BIT(attr);
216 * Interpolate primary colors to fill in the span->array->rgba8 (or rgb16)
220 interpolate_int_colors(struct gl_context *ctx, SWspan *span)
223 const GLuint n = span->end;
226 assert(!(span->arrayMask & SPAN_RGBA));
229 switch (span->array->ChanType) {
233 GLubyte (*rgba)[4] = span->array->rgba8;
234 if (span->interpMask & SPAN_FLAT) {
236 color[RCOMP] = FixedToInt(span->red);
237 color[GCOMP] = FixedToInt(span->green);
238 color[BCOMP] = FixedToInt(span->blue);
239 color[ACOMP] = FixedToInt(span->alpha);
245 GLfixed r = span->red;
246 GLfixed g = span->green;
247 GLfixed b = span->blue;
248 GLfixed a = span->alpha;
249 GLint dr = span->redStep;
250 GLint dg = span->greenStep;
251 GLint db = span->blueStep;
252 GLint da = span->alphaStep;
268 GLushort (*rgba)[4] = span->array->rgba16;
269 if (span->interpMask & SPAN_FLAT) {
271 color[RCOMP] = FixedToInt(span->red);
272 color[GCOMP] = FixedToInt(span->green);
273 color[BCOMP] = FixedToInt(span->blue);
274 color[ACOMP] = FixedToInt(span->alpha);
280 GLushort (*rgba)[4] = span->array->rgba16;
283 r = span->red;
284 g = span->green;
285 b = span->blue;
286 a = span->alpha;
287 dr = span->redStep;
288 dg = span->greenStep;
289 db = span->blueStep;
290 da = span->alphaStep;
306 interpolate_active_attribs(ctx, span, VARYING_BIT_COL0);
310 span->array->ChanType);
312 span->arrayMask |= SPAN_RGBA;
320 interpolate_float_colors(SWspan *span)
322 GLfloat (*col0)[4] = span->array->attribs[VARYING_SLOT_COL0];
323 const GLuint n = span->end;
326 assert(!(span->arrayAttribs & VARYING_BIT_COL0));
328 if (span->arrayMask & SPAN_RGBA) {
331 col0[i][0] = UBYTE_TO_FLOAT(span->array->rgba8[i][0]);
332 col0[i][1] = UBYTE_TO_FLOAT(span->array->rgba8[i][1]);
333 col0[i][2] = UBYTE_TO_FLOAT(span->array->rgba8[i][2]);
334 col0[i][3] = UBYTE_TO_FLOAT(span->array->rgba8[i][3]);
339 assert(span->interpMask & SPAN_RGBA);
340 if (span->interpMask & SPAN_FLAT) {
341 GLfloat r = FixedToFloat(span->red);
342 GLfloat g = FixedToFloat(span->green);
343 GLfloat b = FixedToFloat(span->blue);
344 GLfloat a = FixedToFloat(span->alpha);
350 GLfloat r = FixedToFloat(span->red);
351 GLfloat g = FixedToFloat(span->green);
352 GLfloat b = FixedToFloat(span->blue);
353 GLfloat a = FixedToFloat(span->alpha);
354 GLfloat dr = FixedToFloat(span->redStep);
355 GLfloat dg = FixedToFloat(span->greenStep);
356 GLfloat db = FixedToFloat(span->blueStep);
357 GLfloat da = FixedToFloat(span->alphaStep);
371 span->arrayAttribs |= VARYING_BIT_COL0;
372 span->array->ChanType = GL_FLOAT;
378 * Fill in the span.zArray array from the span->z, zStep values.
381 _swrast_span_interpolate_z( const struct gl_context *ctx, SWspan *span )
383 const GLuint n = span->end;
386 assert(!(span->arrayMask & SPAN_Z));
389 GLfixed zval = span->z;
390 GLuint *z = span->array->z;
393 zval += span->zStep;
398 GLuint zval = span->z;
399 GLuint *z = span->array->z;
402 zval += span->zStep;
405 span->interpMask &= ~SPAN_Z;
406 span->arrayMask |= SPAN_Z;
460 * Fill in the span.array->attrib[VARYING_SLOT_TEXn] arrays from the
471 interpolate_texcoords(struct gl_context *ctx, SWspan *span)
484 GLfloat (*texcoord)[4] = span->array->attribs[attr];
485 GLfloat *lambda = span->array->lambda[u];
486 const GLfloat dsdx = span->attrStepX[attr][0];
487 const GLfloat dsdy = span->attrStepY[attr][0];
488 const GLfloat dtdx = span->attrStepX[attr][1];
489 const GLfloat dtdy = span->attrStepY[attr][1];
490 const GLfloat drdx = span->attrStepX[attr][2];
491 const GLfloat dqdx = span->attrStepX[attr][3];
492 const GLfloat dqdy = span->attrStepY[attr][3];
493 GLfloat s = span->attrStart[attr][0] + span->leftClip * dsdx;
494 GLfloat t = span->attrStart[attr][1] + span->leftClip * dtdx;
495 GLfloat r = span->attrStart[attr][2] + span->leftClip * drdx;
496 span->attrStart[attr][3] + span->leftClip * dqdx;
528 const GLfloat dwdx = span->attrStepX[VARYING_SLOT_POS][3];
529 GLfloat w = span->attrStart[VARYING_SLOT_POS][3] + span->leftClip * dwdx;
530 for (i = 0; i < span->end; i++) {
547 for (i = 0; i < span->end; i++) {
562 span->arrayMask |= SPAN_LAMBDA;
569 const GLfloat dwdx = span->attrStepX[VARYING_SLOT_POS][3];
570 GLfloat w = span->attrStart[VARYING_SLOT_POS][3] + span->leftClip * dwdx;
571 for (i = 0; i < span->end; i++) {
588 for (i = 0; i < span->end; i++) {
600 for (i = 0; i < span->end; i++) {
623 interpolate_wpos(struct gl_context *ctx, SWspan *span)
625 GLfloat (*wpos)[4] = span->array->attribs[VARYING_SLOT_POS];
630 if (span->arrayMask & SPAN_XY) {
631 for (i = 0; i < span->end; i++) {
632 wpos[i][0] = (GLfloat) span->array->x[i];
633 wpos[i][1] = (GLfloat) span->array->y[i];
637 for (i = 0; i < span->end; i++) {
638 wpos[i][0] = (GLfloat) span->x + i;
639 wpos[i][1] = (GLfloat) span->y;
643 dw = span->attrStepX[VARYING_SLOT_POS][3];
644 w = span->attrStart[VARYING_SLOT_POS][3] + span->leftClip * dw;
645 for (i = 0; i < span->end; i++) {
646 wpos[i][2] = (GLfloat) span->array->z[i] * zScale;
654 * Apply the current polygon stipple pattern to a span of pixels.
657 stipple_polygon_span(struct gl_context *ctx, SWspan *span)
659 GLubyte *mask = span->array->mask;
663 if (span->arrayMask & SPAN_XY) {
666 for (i = 0; i < span->end; i++) {
667 const GLint col = span->array->x[i] % 32;
668 const GLint row = span->array->y[i] % 32;
676 /* horizontal span of pixels */
678 const GLuint stipple = ctx->PolygonStipple[span->y % 32];
679 GLuint i, m = highBit >> (GLuint) (span->x % 32);
680 for (i = 0; i < span->end; i++) {
690 span->writeAll = GL_FALSE;
695 * Clip a pixel span to the current buffer/window boundaries:
702 clip_span( struct gl_context *ctx, SWspan *span )
709 span->leftClip = 0;
711 if (span->arrayMask & SPAN_XY) {
713 const GLint *x = span->array->x;
714 const GLint *y = span->array->y;
715 const GLint n = span->end;
716 GLubyte *mask = span->array->mask;
719 if (span->arrayMask & SPAN_MASK) {
738 /* horizontal span of pixels */
739 const GLint x = span->x;
740 const GLint y = span->y;
741 GLint n = span->end;
745 span->end = 0;
752 n = span->end = xmax - x;
764 * The span->leftClip field will be applied when we interpolate
769 if (span->interpMask & (1 << i)) {
772 span->attrStart[i][j] += leftClip * span->attrStepX[i][j];
777 span->red += leftClip * span->redStep;
778 span->green += leftClip * span->greenStep;
779 span->blue += leftClip * span->blueStep;
780 span->alpha += leftClip * span->alphaStep;
781 span->index += leftClip * span->indexStep;
782 span->z += leftClip * span->zStep;
783 span->intTex[0] += leftClip * span->intTexStep[0];
784 span->intTex[1] += leftClip * span->intTexStep[1];
790 if (span->arrayAttribs & BITFIELD64_BIT(i)) {
792 SHIFT_ARRAY(span->array->attribs[i], leftClip, n - leftClip);
796 SHIFT_ARRAY(span->array->mask, leftClip, n - leftClip);
797 SHIFT_ARRAY(span->array->rgba8, leftClip, n - leftClip);
798 SHIFT_ARRAY(span->array->rgba16, leftClip, n - leftClip);
799 SHIFT_ARRAY(span->array->x, leftClip, n - leftClip);
800 SHIFT_ARRAY(span->array->y, leftClip, n - leftClip);
801 SHIFT_ARRAY(span->array->z, leftClip, n - leftClip);
802 SHIFT_ARRAY(span->array->index, leftClip, n - leftClip);
804 SHIFT_ARRAY(span->array->lambda[i], leftClip, n - leftClip);
806 SHIFT_ARRAY(span->array->coverage, leftClip, n - leftClip);
810 span->leftClip = leftClip;
811 span->x = xmin;
812 span->end -= leftClip;
813 span->writeAll = GL_FALSE;
816 assert(span->x >= xmin);
817 assert(span->x + span->end <= xmax);
818 assert(span->y >= ymin);
819 assert(span->y < ymax);
832 add_specular(struct gl_context *ctx, SWspan *span)
835 const GLubyte *mask = span->array->mask;
836 GLfloat (*col0)[4] = span->array->attribs[VARYING_SLOT_COL0];
837 GLfloat (*col1)[4] = span->array->attribs[VARYING_SLOT_COL1];
841 assert(span->arrayMask & SPAN_RGBA);
845 if (span->array->ChanType == GL_FLOAT) {
846 if ((span->arrayAttribs & VARYING_BIT_COL0) == 0) {
847 interpolate_active_attribs(ctx, span, VARYING_BIT_COL0);
852 if ((span->arrayAttribs & VARYING_BIT_COL0) == 0) {
853 interpolate_float_colors(span);
857 if ((span->arrayAttribs & VARYING_BIT_COL1) == 0) {
859 interpolate_active_attribs(ctx, span, VARYING_BIT_COL1);
862 assert(span->arrayAttribs & VARYING_BIT_COL0);
863 assert(span->arrayAttribs & VARYING_BIT_COL1);
865 for (i = 0; i < span->end; i++) {
873 span->array->ChanType = GL_FLOAT;
881 apply_aa_coverage(SWspan *span)
883 const GLfloat *coverage = span->array->coverage;
885 if (span->array->ChanType == GL_UNSIGNED_BYTE) {
886 GLubyte (*rgba)[4] = span->array->rgba8;
887 for (i = 0; i < span->end; i++) {
894 else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
895 GLushort (*rgba)[4] = span->array->rgba16;
896 for (i = 0; i < span->end; i++) {
902 GLfloat (*rgba)[4] = span->array->attribs[VARYING_SLOT_COL0];
903 for (i = 0; i < span->end; i++) {
912 * Clamp span's float colors to [0,1]
915 clamp_colors(SWspan *span)
917 GLfloat (*rgba)[4] = span->array->attribs[VARYING_SLOT_COL0];
919 assert(span->array->ChanType == GL_FLOAT);
920 for (i = 0; i < span->end; i++) {
930 * Convert the span's color arrays to the given type.
936 convert_color_type(SWspan *span, GLenum srcType, GLenum newType, GLuint output)
941 src = span->array->attribs[VARYING_SLOT_COL0 + output];
942 span->array->ChanType = GL_FLOAT;
945 src = span->array->rgba8;
949 src = span->array->rgba16;
953 dst = span->array->rgba8;
956 dst = span->array->rgba16;
959 dst = span->array->attribs[VARYING_SLOT_COL0];
962 _mesa_convert_colors(span->array->ChanType, src,
964 span->end, span->array->mask);
966 span->array->ChanType = newType;
967 span->array->rgba = dst;
973 * Apply fragment shader, fragment program or normal texturing to span.
976 shade_texture_span(struct gl_context *ctx, SWspan *span)
981 if (span->primitive == GL_BITMAP && span->array->ChanType != GL_FLOAT) {
982 convert_color_type(span, span->array->ChanType, GL_FLOAT, 0);
985 span->array->rgba = (void *) span->array->attribs[VARYING_SLOT_COL0];
988 if (span->primitive != GL_POINT ||
989 (span->interpMask & SPAN_RGBA) ||
992 interpolate_active_attribs(ctx, span, ~0);
994 span->array->ChanType = GL_FLOAT;
996 if (!(span->arrayMask & SPAN_Z))
997 _swrast_span_interpolate_z (ctx, span);
1004 interpolate_wpos(ctx, span);
1008 _swrast_exec_fragment_program(ctx, span);
1012 _swrast_exec_fragment_shader(ctx, span);
1019 if ((span->arrayAttribs & VARYING_BIT_COL0) == 0) {
1020 interpolate_int_colors(ctx, span);
1023 if (!(span->arrayMask & SPAN_RGBA))
1024 interpolate_int_colors(ctx, span);
1026 if ((span->arrayAttribs & VARYING_BITS_TEX_ANY) == 0x0)
1027 interpolate_texcoords(ctx, span);
1029 _swrast_texture_span(ctx, span);
1124 * Apply all the per-fragment operations to a span.
1126 * This function may modify any of the array values in the span.
1127 * span->interpMask and span->arrayMask may be changed but will be restored
1131 _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span)
1135 const GLbitfield origInterpMask = span->interpMask;
1136 const GLbitfield origArrayMask = span->arrayMask;
1137 const GLbitfield64 origArrayAttribs = span->arrayAttribs;
1138 const GLenum origChanType = span->array->ChanType;
1139 void * const origRgba = span->array->rgba;
1147 span->interpMask, span->arrayMask);
1150 assert(span->primitive == GL_POINT ||
1151 span->primitive == GL_LINE ||
1152 span->primitive == GL_POLYGON ||
1153 span->primitive == GL_BITMAP);
1156 if (span->arrayMask & SPAN_MASK) {
1158 span->writeAll = GL_FALSE;
1161 memset(span->array->mask, 1, span->end);
1162 span->writeAll = GL_TRUE;
1166 if (!clip_span(ctx, span)) {
1170 assert(span->end <= SWRAST_MAX_WIDTH);
1174 if (!_swrast_depth_bounds_test(ctx, span)) {
1181 if (span->arrayMask & SPAN_XY) {
1184 for (i = 0; i < span->end; i++) {
1185 if (span->array->mask[i]) {
1186 assert(span->array->x[i] >= fb->_Xmin);
1187 assert(span->array->x[i] < fb->_Xmax);
1188 assert(span->array->y[i] >= fb->_Ymin);
1189 assert(span->array->y[i] < fb->_Ymax);
1196 if (ctx->Polygon.StippleFlag && span->primitive == GL_POLYGON) {
1197 stipple_polygon_span(ctx, span);
1204 shade_texture_span(ctx, span);
1209 if (!_swrast_alpha_test(ctx, span)) {
1217 if (!(span->arrayMask & SPAN_Z))
1218 _swrast_span_interpolate_z(ctx, span);
1221 _swrast_depth_clamp_span(ctx, span);
1225 if (!_swrast_stencil_and_ztest_span(ctx, span)) {
1233 assert(span->arrayMask & SPAN_Z);
1234 if (!_swrast_depth_test_span(ctx, span)) {
1245 for (i = 0; i < span->end; i++)
1246 q->Result += span->array->mask[i];
1262 shade_texture_span(ctx, span);
1266 if ((span->arrayAttribs & VARYING_BIT_COL0) == 0) {
1267 interpolate_active_attribs(ctx, span, VARYING_BIT_COL0);
1270 if ((span->arrayMask & SPAN_RGBA) == 0) {
1271 interpolate_int_colors(ctx, span);
1275 assert(span->arrayMask & SPAN_RGBA);
1277 if (span->primitive == GL_BITMAP || !swrast->SpecularVertexAdd) {
1283 add_specular(ctx, span);
1290 _swrast_fog_rgba_span(ctx, span);
1294 if (span->arrayMask & SPAN_COVERAGE) {
1295 apply_aa_coverage(span);
1300 span->array->ChanType == GL_FLOAT) {
1301 clamp_colors(span);
1318 const GLenum srcColorType = span->array->ChanType;
1328 GLchan (*rgbaSave)[4] = (GLchan (*)[4]) span->array->attribs[0];
1335 /* set span->array->rgba to colors for renderbuffer's datatype */
1337 convert_color_type(span, srcColorType, dstColorType,
1342 span->array->rgba = span->array->rgba8;
1345 span->array->rgba = (void *)
1346 span->array->attribs[VARYING_SLOT_COL0];
1352 memcpy(rgbaSave, span->array->rgba,
1353 4 * span->end * sizeof(GLchan));
1363 _swrast_logicop_rgba_span(ctx, rb, span);
1366 _swrast_blend_span(ctx, rb, span);
1370 _swrast_mask_rgba_span(ctx, rb, span, buf);
1373 if (span->arrayMask & SPAN_XY) {
1376 span->array->ChanType, span->end,
1377 span->array->x, span->array->y,
1378 span->array->rgba, span->array->mask);
1383 span->array->ChanType,
1384 span->end, span->x, span->y,
1385 span->array->rgba,
1386 span->writeAll ? NULL: span->array->mask);
1390 /* restore original span values */
1391 memcpy(span->array->rgba, rgbaSave,
1392 4 * span->end * sizeof(GLchan));
1401 span->interpMask = origInterpMask;
1402 span->arrayMask = origArrayMask;
1403 span->arrayAttribs = origArrayAttribs;
1404 span->array->ChanType = origChanType;
1405 span->array->rgba = origRgba;
1577 SWspan *span)
1582 rbPixels = span->array->attribs[VARYING_SLOT_MAX - 1];
1585 if (span->arrayMask & SPAN_XY) {
1586 get_values(ctx, rb, span->end, span->array->x, span->array->y,
1587 rbPixels, span->array->ChanType);
1590 get_row(ctx, rb, span->end, span->x, span->y,
1591 rbPixels, span->array->ChanType);