if (INTEL_DEBUG & DEBUG_PIXEL)
fprintf(stderr, "%s\n", __FUNCTION__);
- if (!intelTryDrawPixels( ctx, x, y, width, height, format, type,
- unpack, pixels )) {
- if (ctx->FragmentProgram._Current ==
- ctx->FragmentProgram._TexEnvProgram) {
- /* don't want the i915 texenv program to be applied to DrawPixels */
- struct gl_fragment_program *fpSave = ctx->FragmentProgram._Current;
- ctx->FragmentProgram._Current = NULL;
- _swrast_DrawPixels( ctx, x, y, width, height, format, type,
- unpack, pixels );
- ctx->FragmentProgram._Current = fpSave;
- }
- else {
- _swrast_DrawPixels( ctx, x, y, width, height, format, type,
- unpack, pixels );
- }
+ if (intelTryDrawPixels( ctx, x, y, width, height, format, type,
+ unpack, pixels ))
+ return;
+
+ if (ctx->FragmentProgram._Current == ctx->FragmentProgram._TexEnvProgram) {
+ /*
+ * We don't want the i915 texenv program to be applied to DrawPixels.
+ * This is really just a performance optimization (mesa will other-
+ * wise happily run the fragment program on each pixel in the image).
+ */
+ struct gl_fragment_program *fpSave = ctx->FragmentProgram._Current;
+ ctx->FragmentProgram._Current = NULL;
+ _swrast_DrawPixels( ctx, x, y, width, height, format, type,
+ unpack, pixels );
+ ctx->FragmentProgram._Current = fpSave;
+ }
+ else {
+ _swrast_DrawPixels( ctx, x, y, width, height, format, type,
+ unpack, pixels );
}
}
if (INTEL_DEBUG & DEBUG_PIXEL)
_mesa_printf("%s: fallback to swrast\n", __FUNCTION__);
- if (ctx->FragmentProgram._Current ==
- ctx->FragmentProgram._TexEnvProgram) {
- /* don't want the i915 texenv program to be applied to DrawPixels */
+ if (ctx->FragmentProgram._Current == ctx->FragmentProgram._TexEnvProgram) {
+ /*
+ * We don't want the i915 texenv program to be applied to DrawPixels.
+ * This is really just a performance optimization (mesa will other-
+ * wise happily run the fragment program on each pixel in the image).
+ */
struct gl_fragment_program *fpSave = ctx->FragmentProgram._Current;
ctx->FragmentProgram._Current = NULL;
_swrast_DrawPixels( ctx, x, y, width, height, format, type,
copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
GLint width, GLint height, GLint destx, GLint desty)
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const GLbitfield prevActiveAttribs = swrast->_ActiveAttribMask;
GLfloat *tmpImage, *p;
GLint sy, dy, stepy, row;
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
if (!ctx->ReadBuffer->_ColorReadBuffer) {
/* no readbuffer - OK */
- return;
+ goto end;
}
+ /* don't interpolate COL0 and overwrite the glDrawPixel colors! */
+ swrast->_ActiveAttribMask &= ~FRAG_BIT_COL0;
+
if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) {
copy_conv_rgba_pixels(ctx, srcx, srcy, width, height, destx, desty);
- return;
+ goto end;
}
else if (ctx->Pixel.Convolution1DEnabled) {
/* make sure we don't apply 1D convolution */
tmpImage = (GLfloat *) _mesa_malloc(width * height * sizeof(GLfloat) * 4);
if (!tmpImage) {
_mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" );
- return;
+ goto end;
}
/* read the source image as RGBA/float */
p = tmpImage;
if (overlapping)
_mesa_free(tmpImage);
+
+end:
+ swrast->_ActiveAttribMask = prevActiveAttribs;
}
const struct gl_pixelstore_attrib *unpack,
const GLvoid *pixels )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const GLbitfield prevActiveAttribs = swrast->_ActiveAttribMask;
const GLint imgX = x, imgY = y;
const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
GLfloat *convImage = NULL;
GLbitfield transferOps = ctx->_ImageTransferState;
SWspan span;
+ /* don't interpolate COL0 and overwrite the glDrawPixel colors! */
+ swrast->_ActiveAttribMask &= ~FRAG_BIT_COL0;
+
/* Try an optimized glDrawPixels first */
if (fast_draw_rgba_pixels(ctx, x, y, width, height, format, type,
- unpack, pixels))
- return;
+ unpack, pixels)) {
+ goto end;
+ }
INIT_SPAN(span, GL_BITMAP, 0, 0x0, SPAN_RGBA);
_swrast_span_default_attribs(ctx, &span);
tmpImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
if (!tmpImage) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels");
- return;
+ goto end;
}
convImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
if (!convImage) {
_mesa_free(tmpImage);
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels");
- return;
+ goto end;
}
/* Unpack the image and apply transfer ops up to convolution */
if (convImage) {
_mesa_free(convImage);
}
+
+end:
+ swrast->_ActiveAttribMask = prevActiveAttribs;
}
{
const SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ /* for glDraw/CopyPixels() we may have turned off some bits in
+ * the _ActiveAttribMask - be sure to obey that mask now.
+ */
+ attrMask &= swrast->_ActiveAttribMask;
+
ATTRIB_LOOP_BEGIN
if (attrMask & (1 << attr)) {
const GLfloat dwdx = span->attrStepX[FRAG_ATTRIB_WPOS][3];
if (ctx->FragmentProgram._Current ||
ctx->ATIFragmentShader._Enabled) {
/* programmable shading */
- if (span->primitive == GL_BITMAP) {
- if (span->array->ChanType != GL_FLOAT)
- convert_color_type(span, GL_FLOAT, 0);
- interpolate_active_attribs(ctx, span, ~FRAG_ATTRIB_COL0);
- }
- else {
- /* point, line, triangle */
- interpolate_active_attribs(ctx, span, ~0);
+ if (span->primitive == GL_BITMAP && span->array->ChanType != GL_FLOAT) {
+ convert_color_type(span, GL_FLOAT, 0);
}
+ interpolate_active_attribs(ctx, span, ~0);
span->array->ChanType = GL_FLOAT;
if (!(span->arrayMask & SPAN_Z))