/*
* Mesa 3-D graphics library
- * Version: 7.5
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
*/
* \author Brian Paul
*/
+#include "c99_math.h"
#include "main/glheader.h"
-#include "main/colormac.h"
#include "main/format_pack.h"
#include "main/format_unpack.h"
#include "main/macros.h"
#include "main/imports.h"
#include "main/image.h"
+#include "main/samplerobj.h"
+#include "main/teximage.h"
#include "s_atifragshader.h"
#include "s_alpha.h"
}
/* W (for perspective correction) */
- span->attrStart[FRAG_ATTRIB_WPOS][3] = 1.0;
- span->attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0;
- span->attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0;
+ span->attrStart[VARYING_SLOT_POS][3] = 1.0;
+ span->attrStepX[VARYING_SLOT_POS][3] = 0.0;
+ span->attrStepY[VARYING_SLOT_POS][3] = 0.0;
/* primary color, or color index */
UNCLAMPED_FLOAT_TO_CHAN(r, ctx->Current.RasterColor[0]);
span->alphaStep = 0;
span->interpMask |= SPAN_RGBA;
- COPY_4V(span->attrStart[FRAG_ATTRIB_COL0], ctx->Current.RasterColor);
- ASSIGN_4V(span->attrStepX[FRAG_ATTRIB_COL0], 0.0, 0.0, 0.0, 0.0);
- ASSIGN_4V(span->attrStepY[FRAG_ATTRIB_COL0], 0.0, 0.0, 0.0, 0.0);
+ COPY_4V(span->attrStart[VARYING_SLOT_COL0], ctx->Current.RasterColor);
+ ASSIGN_4V(span->attrStepX[VARYING_SLOT_COL0], 0.0, 0.0, 0.0, 0.0);
+ ASSIGN_4V(span->attrStepY[VARYING_SLOT_COL0], 0.0, 0.0, 0.0, 0.0);
/* Secondary color */
if (ctx->Light.Enabled || ctx->Fog.ColorSumEnabled)
{
- COPY_4V(span->attrStart[FRAG_ATTRIB_COL1], ctx->Current.RasterSecondaryColor);
- ASSIGN_4V(span->attrStepX[FRAG_ATTRIB_COL1], 0.0, 0.0, 0.0, 0.0);
- ASSIGN_4V(span->attrStepY[FRAG_ATTRIB_COL1], 0.0, 0.0, 0.0, 0.0);
+ COPY_4V(span->attrStart[VARYING_SLOT_COL1], ctx->Current.RasterSecondaryColor);
+ ASSIGN_4V(span->attrStepX[VARYING_SLOT_COL1], 0.0, 0.0, 0.0, 0.0);
+ ASSIGN_4V(span->attrStepY[VARYING_SLOT_COL1], 0.0, 0.0, 0.0, 0.0);
}
/* fog */
/* fog blend factor should be computed from fogcoord now */
fogVal = _swrast_z_to_fogfactor(ctx, ctx->Current.RasterDistance);
}
- span->attrStart[FRAG_ATTRIB_FOGC][0] = fogVal;
- span->attrStepX[FRAG_ATTRIB_FOGC][0] = 0.0;
- span->attrStepY[FRAG_ATTRIB_FOGC][0] = 0.0;
+ span->attrStart[VARYING_SLOT_FOGC][0] = fogVal;
+ span->attrStepX[VARYING_SLOT_FOGC][0] = 0.0;
+ span->attrStepY[VARYING_SLOT_FOGC][0] = 0.0;
}
/* texcoords */
{
GLuint i;
for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
- const GLuint attr = FRAG_ATTRIB_TEX0 + i;
+ const GLuint attr = VARYING_SLOT_TEX0 + i;
const GLfloat *tc = ctx->Current.RasterTexCoords[i];
if (_swrast_use_fragment_program(ctx) ||
ctx->ATIFragmentShader._Enabled) {
* Interpolate the active attributes (and'd with attrMask) to
* fill in span->array->attribs[].
* Perspective correction will be done. The point/line/triangle function
- * should have computed attrStart/Step values for FRAG_ATTRIB_WPOS[3]!
+ * should have computed attrStart/Step values for VARYING_SLOT_POS[3]!
*/
static inline void
interpolate_active_attribs(struct gl_context *ctx, SWspan *span,
ATTRIB_LOOP_BEGIN
if (attrMask & BITFIELD64_BIT(attr)) {
- const GLfloat dwdx = span->attrStepX[FRAG_ATTRIB_WPOS][3];
- GLfloat w = span->attrStart[FRAG_ATTRIB_WPOS][3];
+ const GLfloat dwdx = span->attrStepX[VARYING_SLOT_POS][3];
+ GLfloat w = span->attrStart[VARYING_SLOT_POS][3];
const GLfloat dv0dx = span->attrStepX[attr][0];
const GLfloat dv1dx = span->attrStepX[attr][1];
const GLfloat dv2dx = span->attrStepX[attr][2];
v3 += dv3dx;
w += dwdx;
}
- ASSERT((span->arrayAttribs & BITFIELD64_BIT(attr)) == 0);
+ assert((span->arrayAttribs & BITFIELD64_BIT(attr)) == 0);
span->arrayAttribs |= BITFIELD64_BIT(attr);
}
ATTRIB_LOOP_END
const GLuint n = span->end;
GLuint i;
- ASSERT(!(span->arrayMask & SPAN_RGBA));
+ assert(!(span->arrayMask & SPAN_RGBA));
#endif
switch (span->array->ChanType) {
break;
#endif
case GL_FLOAT:
- interpolate_active_attribs(ctx, span, FRAG_BIT_COL0);
+ interpolate_active_attribs(ctx, span, VARYING_BIT_COL0);
break;
default:
_mesa_problem(ctx, "bad datatype 0x%x in interpolate_int_colors",
/**
- * Populate the FRAG_ATTRIB_COL0 array.
+ * Populate the VARYING_SLOT_COL0 array.
*/
static inline void
interpolate_float_colors(SWspan *span)
{
- GLfloat (*col0)[4] = span->array->attribs[FRAG_ATTRIB_COL0];
+ GLfloat (*col0)[4] = span->array->attribs[VARYING_SLOT_COL0];
const GLuint n = span->end;
GLuint i;
- assert(!(span->arrayAttribs & FRAG_BIT_COL0));
+ assert(!(span->arrayAttribs & VARYING_BIT_COL0));
if (span->arrayMask & SPAN_RGBA) {
/* convert array of int colors */
}
else {
/* interpolate red/green/blue/alpha to get float colors */
- ASSERT(span->interpMask & SPAN_RGBA);
+ assert(span->interpMask & SPAN_RGBA);
if (span->interpMask & SPAN_FLAT) {
GLfloat r = FixedToFloat(span->red);
GLfloat g = FixedToFloat(span->green);
}
}
- span->arrayAttribs |= FRAG_BIT_COL0;
+ span->arrayAttribs |= VARYING_BIT_COL0;
span->array->ChanType = GL_FLOAT;
}
const GLuint n = span->end;
GLuint i;
- ASSERT(!(span->arrayMask & SPAN_Z));
+ assert(!(span->arrayMask & SPAN_Z));
if (ctx->DrawBuffer->Visual.depthBits <= 16) {
GLfixed zval = span->z;
GLfloat dvdx = texH * ((t + dtdx) / (q + dqdx) - t * invQ);
GLfloat dudy = texW * ((s + dsdy) / (q + dqdy) - s * invQ);
GLfloat dvdy = texH * ((t + dtdy) / (q + dqdy) - t * invQ);
- GLfloat x = SQRTF(dudx * dudx + dvdx * dvdx);
- GLfloat y = SQRTF(dudy * dudy + dvdy * dvdy);
+ GLfloat x = sqrtf(dudx * dudx + dvdx * dvdx);
+ GLfloat y = sqrtf(dudy * dudy + dvdy * dvdy);
GLfloat rho = MAX2(x, y);
GLfloat lambda = LOG2(rho);
return lambda;
GLfloat dsdy2 = (s + dsdy) / (q + dqdy) - s * invQ;
GLfloat dtdy2 = (t + dtdy) / (q + dqdy) - t * invQ;
GLfloat maxU, maxV, rho, lambda;
- dsdx2 = FABSF(dsdx2);
- dsdy2 = FABSF(dsdy2);
- dtdx2 = FABSF(dtdx2);
- dtdy2 = FABSF(dtdy2);
+ dsdx2 = fabsf(dsdx2);
+ dsdy2 = fabsf(dsdy2);
+ dtdx2 = fabsf(dtdx2);
+ dtdy2 = fabsf(dtdy2);
maxU = MAX2(dsdx2, dsdy2) * texW;
maxV = MAX2(dtdx2, dtdy2) * texH;
rho = MAX2(maxU, maxV);
/**
- * Fill in the span.array->attrib[FRAG_ATTRIB_TEXn] arrays from the
+ * Fill in the span.array->attrib[VARYING_SLOT_TEXn] arrays from the
* using the attrStart/Step values.
*
* This function only used during fixed-function fragment processing.
/* XXX CoordUnits vs. ImageUnits */
for (u = 0; u < maxUnit; u++) {
if (ctx->Texture._EnabledCoordUnits & (1 << u)) {
- const GLuint attr = FRAG_ATTRIB_TEX0 + u;
+ const GLuint attr = VARYING_SLOT_TEX0 + u;
const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current;
GLfloat texW, texH;
GLboolean needLambda;
GLfloat q = span->attrStart[attr][3] + span->leftClip * dqdx;
if (obj) {
- const struct gl_texture_image *img = obj->Image[0][obj->BaseLevel];
+ const struct gl_texture_image *img = _mesa_base_tex_image(obj);
const struct swrast_texture_image *swImg =
swrast_texture_image_const(img);
+ const struct gl_sampler_object *samp = _mesa_get_samplerobj(ctx, u);
- needLambda = (obj->Sampler.MinFilter != obj->Sampler.MagFilter)
+ needLambda = (samp->MinFilter != samp->MagFilter)
|| _swrast_use_fragment_program(ctx);
/* LOD is calculated directly in the ansiotropic filter, we can
* skip the normal lambda function as the result is ignored.
*/
- if (obj->Sampler.MaxAnisotropy > 1.0 &&
- obj->Sampler.MinFilter == GL_LINEAR_MIPMAP_LINEAR) {
+ if (samp->MaxAnisotropy > 1.0 &&
+ samp->MinFilter == GL_LINEAR_MIPMAP_LINEAR) {
needLambda = GL_FALSE;
}
texW = swImg->WidthScale;
if (_swrast_use_fragment_program(ctx)
|| ctx->ATIFragmentShader._Enabled) {
/* do perspective correction but don't divide s, t, r by q */
- const GLfloat dwdx = span->attrStepX[FRAG_ATTRIB_WPOS][3];
- GLfloat w = span->attrStart[FRAG_ATTRIB_WPOS][3] + span->leftClip * dwdx;
+ const GLfloat dwdx = span->attrStepX[VARYING_SLOT_POS][3];
+ GLfloat w = span->attrStart[VARYING_SLOT_POS][3] + span->leftClip * dwdx;
for (i = 0; i < span->end; i++) {
const GLfloat invW = 1.0F / w;
texcoord[i][0] = s * invW;
if (_swrast_use_fragment_program(ctx) ||
ctx->ATIFragmentShader._Enabled) {
/* do perspective correction but don't divide s, t, r by q */
- const GLfloat dwdx = span->attrStepX[FRAG_ATTRIB_WPOS][3];
- GLfloat w = span->attrStart[FRAG_ATTRIB_WPOS][3] + span->leftClip * dwdx;
+ const GLfloat dwdx = span->attrStepX[VARYING_SLOT_POS][3];
+ GLfloat w = span->attrStart[VARYING_SLOT_POS][3] + span->leftClip * dwdx;
for (i = 0; i < span->end; i++) {
const GLfloat invW = 1.0F / w;
texcoord[i][0] = s * invW;
/**
- * Fill in the arrays->attribs[FRAG_ATTRIB_WPOS] array.
+ * Fill in the arrays->attribs[VARYING_SLOT_POS] array.
*/
static inline void
interpolate_wpos(struct gl_context *ctx, SWspan *span)
{
- GLfloat (*wpos)[4] = span->array->attribs[FRAG_ATTRIB_WPOS];
+ GLfloat (*wpos)[4] = span->array->attribs[VARYING_SLOT_POS];
GLuint i;
const GLfloat zScale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
GLfloat w, dw;
}
}
- dw = span->attrStepX[FRAG_ATTRIB_WPOS][3];
- w = span->attrStart[FRAG_ATTRIB_WPOS][3] + span->leftClip * dw;
+ dw = span->attrStepX[VARYING_SLOT_POS][3];
+ w = span->attrStart[VARYING_SLOT_POS][3] + span->leftClip * dw;
for (i = 0; i < span->end; i++) {
wpos[i][2] = (GLfloat) span->array->z[i] * zScale;
wpos[i][3] = w;
{
GLubyte *mask = span->array->mask;
- ASSERT(ctx->Polygon.StippleFlag);
+ assert(ctx->Polygon.StippleFlag);
if (span->arrayMask & SPAN_XY) {
/* arrays of x/y pixel coords */
/* Clip to right */
if (x + n > xmax) {
- ASSERT(x < xmax);
+ assert(x < xmax);
n = span->end = xmax - x;
}
const GLint leftClip = xmin - x;
GLuint i;
- ASSERT(leftClip > 0);
- ASSERT(x + n > xmin);
+ assert(leftClip > 0);
+ assert(x + n > xmin);
/* Clip 'leftClip' pixels from the left side.
* The span->leftClip field will be applied when we interpolate
* fragment attributes.
* For arrays of values, shift them left.
*/
- for (i = 0; i < FRAG_ATTRIB_MAX; i++) {
+ for (i = 0; i < VARYING_SLOT_MAX; i++) {
if (span->interpMask & (1 << i)) {
GLuint j;
for (j = 0; j < 4; j++) {
#define SHIFT_ARRAY(ARRAY, SHIFT, LEN) \
memmove(ARRAY, ARRAY + (SHIFT), (LEN) * sizeof(ARRAY[0]))
- for (i = 0; i < FRAG_ATTRIB_MAX; i++) {
- if (span->arrayAttribs & (1 << i)) {
+ for (i = 0; i < VARYING_SLOT_MAX; i++) {
+ if (span->arrayAttribs & BITFIELD64_BIT(i)) {
/* shift array elements left by 'leftClip' */
SHIFT_ARRAY(span->array->attribs[i], leftClip, n - leftClip);
}
span->writeAll = GL_FALSE;
}
- ASSERT(span->x >= xmin);
- ASSERT(span->x + span->end <= xmax);
- ASSERT(span->y >= ymin);
- ASSERT(span->y < ymax);
+ assert(span->x >= xmin);
+ assert(span->x + span->end <= xmax);
+ assert(span->y >= ymin);
+ assert(span->y < ymax);
return GL_TRUE; /* some pixels visible */
}
/**
* Add specular colors to primary colors.
* Only called during fixed-function operation.
- * Result is float color array (FRAG_ATTRIB_COL0).
+ * Result is float color array (VARYING_SLOT_COL0).
*/
static inline void
add_specular(struct gl_context *ctx, SWspan *span)
{
const SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLubyte *mask = span->array->mask;
- GLfloat (*col0)[4] = span->array->attribs[FRAG_ATTRIB_COL0];
- GLfloat (*col1)[4] = span->array->attribs[FRAG_ATTRIB_COL1];
+ GLfloat (*col0)[4] = span->array->attribs[VARYING_SLOT_COL0];
+ GLfloat (*col1)[4] = span->array->attribs[VARYING_SLOT_COL1];
GLuint i;
- ASSERT(!_swrast_use_fragment_program(ctx));
- ASSERT(span->arrayMask & SPAN_RGBA);
- ASSERT(swrast->_ActiveAttribMask & FRAG_BIT_COL1);
+ assert(!_swrast_use_fragment_program(ctx));
+ assert(span->arrayMask & SPAN_RGBA);
+ assert(swrast->_ActiveAttribMask & VARYING_BIT_COL1);
(void) swrast; /* silence warning */
if (span->array->ChanType == GL_FLOAT) {
- if ((span->arrayAttribs & FRAG_BIT_COL0) == 0) {
- interpolate_active_attribs(ctx, span, FRAG_BIT_COL0);
+ if ((span->arrayAttribs & VARYING_BIT_COL0) == 0) {
+ interpolate_active_attribs(ctx, span, VARYING_BIT_COL0);
}
}
else {
/* need float colors */
- if ((span->arrayAttribs & FRAG_BIT_COL0) == 0) {
+ if ((span->arrayAttribs & VARYING_BIT_COL0) == 0) {
interpolate_float_colors(span);
}
}
- if ((span->arrayAttribs & FRAG_BIT_COL1) == 0) {
+ if ((span->arrayAttribs & VARYING_BIT_COL1) == 0) {
/* XXX could avoid this and interpolate COL1 in the loop below */
- interpolate_active_attribs(ctx, span, FRAG_BIT_COL1);
+ interpolate_active_attribs(ctx, span, VARYING_BIT_COL1);
}
- ASSERT(span->arrayAttribs & FRAG_BIT_COL0);
- ASSERT(span->arrayAttribs & FRAG_BIT_COL1);
+ assert(span->arrayAttribs & VARYING_BIT_COL0);
+ assert(span->arrayAttribs & VARYING_BIT_COL1);
for (i = 0; i < span->end; i++) {
if (mask[i]) {
for (i = 0; i < span->end; i++) {
const GLfloat a = rgba[i][ACOMP] * coverage[i];
rgba[i][ACOMP] = (GLubyte) CLAMP(a, 0.0, 255.0);
- ASSERT(coverage[i] >= 0.0);
- ASSERT(coverage[i] <= 1.0);
+ assert(coverage[i] >= 0.0);
+ assert(coverage[i] <= 1.0);
}
}
else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
}
}
else {
- GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL0];
+ GLfloat (*rgba)[4] = span->array->attribs[VARYING_SLOT_COL0];
for (i = 0; i < span->end; i++) {
rgba[i][ACOMP] = rgba[i][ACOMP] * coverage[i];
/* clamp later */
static inline void
clamp_colors(SWspan *span)
{
- GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL0];
+ GLfloat (*rgba)[4] = span->array->attribs[VARYING_SLOT_COL0];
GLuint i;
- ASSERT(span->array->ChanType == GL_FLOAT);
+ assert(span->array->ChanType == GL_FLOAT);
for (i = 0; i < span->end; i++) {
rgba[i][RCOMP] = CLAMP(rgba[i][RCOMP], 0.0F, 1.0F);
rgba[i][GCOMP] = CLAMP(rgba[i][GCOMP], 0.0F, 1.0F);
* \param output which fragment program color output is being processed
*/
static inline void
-convert_color_type(SWspan *span, GLenum newType, GLuint output)
+convert_color_type(SWspan *span, GLenum srcType, GLenum newType, GLuint output)
{
GLvoid *src, *dst;
- if (output > 0 || span->array->ChanType == GL_FLOAT) {
- src = span->array->attribs[FRAG_ATTRIB_COL0 + output];
+ if (output > 0 || srcType == GL_FLOAT) {
+ src = span->array->attribs[VARYING_SLOT_COL0 + output];
span->array->ChanType = GL_FLOAT;
}
- else if (span->array->ChanType == GL_UNSIGNED_BYTE) {
+ else if (srcType == GL_UNSIGNED_BYTE) {
src = span->array->rgba8;
}
else {
- ASSERT(span->array->ChanType == GL_UNSIGNED_SHORT);
+ assert(srcType == GL_UNSIGNED_SHORT);
src = span->array->rgba16;
}
dst = span->array->rgba16;
}
else {
- dst = span->array->attribs[FRAG_ATTRIB_COL0];
+ dst = span->array->attribs[VARYING_SLOT_COL0];
}
_mesa_convert_colors(span->array->ChanType, src,
ctx->ATIFragmentShader._Enabled) {
/* programmable shading */
if (span->primitive == GL_BITMAP && span->array->ChanType != GL_FLOAT) {
- convert_color_type(span, GL_FLOAT, 0);
+ convert_color_type(span, span->array->ChanType, GL_FLOAT, 0);
}
else {
- span->array->rgba = (void *) span->array->attribs[FRAG_ATTRIB_COL0];
+ span->array->rgba = (void *) span->array->attribs[VARYING_SLOT_COL0];
}
if (span->primitive != GL_POINT ||
_swrast_span_interpolate_z (ctx, span);
#if 0
- if (inputsRead & FRAG_BIT_WPOS)
+ if (inputsRead & VARYING_BIT_POS)
#else
/* XXX always interpolate wpos so that DDX/DDY work */
#endif
_swrast_exec_fragment_program(ctx, span);
}
else {
- ASSERT(ctx->ATIFragmentShader._Enabled);
+ assert(ctx->ATIFragmentShader._Enabled);
_swrast_exec_fragment_shader(ctx, span);
}
}
/* conventional texturing */
#if CHAN_BITS == 32
- if ((span->arrayAttribs & FRAG_BIT_COL0) == 0) {
+ if ((span->arrayAttribs & VARYING_BIT_COL0) == 0) {
interpolate_int_colors(ctx, span);
}
#else
if (!(span->arrayMask & SPAN_RGBA))
interpolate_int_colors(ctx, span);
#endif
- if ((span->arrayAttribs & FRAG_BITS_TEX_ANY) == 0x0)
+ if ((span->arrayAttribs & VARYING_BITS_TEX_ANY) == 0x0)
interpolate_texcoords(ctx, span);
_swrast_texture_span(ctx, span);
struct gl_framebuffer *fb = ctx->DrawBuffer;
/*
- printf("%s() interp 0x%x array 0x%x\n", __FUNCTION__,
+ printf("%s() interp 0x%x array 0x%x\n", __func__,
span->interpMask, span->arrayMask);
*/
- ASSERT(span->primitive == GL_POINT ||
+ assert(span->primitive == GL_POINT ||
span->primitive == GL_LINE ||
span->primitive == GL_POLYGON ||
span->primitive == GL_BITMAP);
return;
}
- ASSERT(span->end <= MAX_WIDTH);
+ assert(span->end <= SWRAST_MAX_WIDTH);
/* Depth bounds test */
if (ctx->Depth.BoundsTest && fb->Visual.depthBits > 0) {
}
else if (fb->Visual.depthBits > 0) {
/* Just regular depth testing */
- ASSERT(ctx->Depth.Test);
- ASSERT(span->arrayMask & SPAN_Z);
+ assert(ctx->Depth.Test);
+ assert(span->arrayMask & SPAN_Z);
if (!_swrast_depth_test_span(ctx, span)) {
/* all fragments failed test */
goto end;
}
#if CHAN_BITS == 32
- if ((span->arrayAttribs & FRAG_BIT_COL0) == 0) {
- interpolate_active_attribs(ctx, span, FRAG_BIT_COL0);
+ if ((span->arrayAttribs & VARYING_BIT_COL0) == 0) {
+ interpolate_active_attribs(ctx, span, VARYING_BIT_COL0);
}
#else
if ((span->arrayMask & SPAN_RGBA) == 0) {
}
#endif
- ASSERT(span->arrayMask & SPAN_RGBA);
+ assert(span->arrayMask & SPAN_RGBA);
if (span->primitive == GL_BITMAP || !swrast->SpecularVertexAdd) {
/* Add primary and specular (diffuse + specular) colors */
const GLboolean multiFragOutputs =
_swrast_use_fragment_program(ctx)
&& fp->Base.OutputsWritten >= (1 << FRAG_RESULT_DATA0);
+ /* Save srcColorType because convert_color_type() can change it */
+ const GLenum srcColorType = span->array->ChanType;
GLuint buf;
for (buf = 0; buf < numBuffers; buf++) {
/* color[fragOutput] will be written to buffer[buf] */
if (rb) {
- GLchan rgbaSave[MAX_WIDTH][4];
-
- if (span->array->ChanType == GL_UNSIGNED_BYTE) {
- span->array->rgba = span->array->rgba8;
+ /* re-use one of the attribute array buffers for rgbaSave */
+ GLchan (*rgbaSave)[4] = (GLchan (*)[4]) span->array->attribs[0];
+ struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
+ const GLenum dstColorType = srb->ColorType;
+
+ assert(dstColorType == GL_UNSIGNED_BYTE ||
+ dstColorType == GL_FLOAT);
+
+ /* set span->array->rgba to colors for renderbuffer's datatype */
+ if (srcColorType != dstColorType) {
+ convert_color_type(span, srcColorType, dstColorType,
+ multiFragOutputs ? buf : 0);
}
else {
- span->array->rgba = (void *)
- span->array->attribs[FRAG_ATTRIB_COL0];
+ if (srcColorType == GL_UNSIGNED_BYTE) {
+ span->array->rgba = span->array->rgba8;
+ }
+ else {
+ span->array->rgba = (void *)
+ span->array->attribs[VARYING_SLOT_COL0];
+ }
}
if (!multiFragOutputs && numBuffers > 1) {
4 * span->end * sizeof(GLchan));
}
- ASSERT(rb->_BaseFormat == GL_RGBA ||
+ assert(rb->_BaseFormat == GL_RGBA ||
rb->_BaseFormat == GL_RGB ||
rb->_BaseFormat == GL_RED ||
rb->_BaseFormat == GL_RG ||
length = (GLint) n;
}
- ASSERT(rb);
- ASSERT(rb->_BaseFormat == GL_RGBA ||
+ assert(rb);
+ assert(rb->_BaseFormat == GL_RGBA ||
rb->_BaseFormat == GL_RGB ||
rb->_BaseFormat == GL_RG ||
rb->_BaseFormat == GL_RED ||
rb->_BaseFormat == GL_ALPHA);
assert(srb->Map);
+ (void) srb; /* silence unused var warning */
src = _swrast_pixel_address(rb, x + skip, y);
void *rbPixels;
/* Point rbPixels to a temporary space */
- rbPixels = span->array->attribs[FRAG_ATTRIB_MAX - 1];
+ rbPixels = span->array->attribs[VARYING_SLOT_MAX - 1];
/* Get destination values from renderbuffer */
if (span->arrayMask & SPAN_XY) {