diff options
-rw-r--r-- | src/mesa/drivers/x11/xm_dd.c | 27 | ||||
-rw-r--r-- | src/mesa/main/framebuffer.c | 3 | ||||
-rw-r--r-- | src/mesa/swrast/s_blit.c | 3 | ||||
-rw-r--r-- | src/mesa/swrast/s_drawpix.c | 7 | ||||
-rw-r--r-- | src/mesa/swrast/s_triangle.c | 10 |
5 files changed, 36 insertions, 14 deletions
diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index e7d4140..56c30ab 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -436,7 +436,12 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx, { const SWcontext *swrast = SWRAST_CONTEXT( ctx ); struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; - struct xmesa_renderbuffer *xrb = xmesa_renderbuffer(rb->Wrapped); + struct xmesa_renderbuffer *xrb; + + if (!rb) + return; + + xrb = xmesa_renderbuffer(rb->Wrapped); if (swrast->NewState) _swrast_validate_derived( ctx ); @@ -543,18 +548,22 @@ xmesa_DrawPixels_5R6G5B( GLcontext *ctx, const struct gl_pixelstore_attrib *unpack, const GLvoid *pixels ) { - struct xmesa_renderbuffer *xrb - = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]->Wrapped); const XMesaContext xmesa = XMESA_CONTEXT(ctx); const SWcontext *swrast = SWRAST_CONTEXT( ctx ); XMesaDisplay *dpy = xmesa->xm_visual->display; XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer); const XMesaGC gc = xmbuf->cleargc; /* effected by glColorMask */ + struct xmesa_renderbuffer *xrb; ASSERT(dpy); ASSERT(gc); ASSERT(xmesa->xm_visual->undithered_pf == PF_5R6G5B); + if (!ctx->DrawBuffer->_ColorDrawBuffers[0]) + return; + + xrb = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]->Wrapped); + if (swrast->NewState) _swrast_validate_derived( ctx ); @@ -651,14 +660,18 @@ xmesa_CopyPixels( GLcontext *ctx, XMesaDisplay *dpy = xmesa->xm_visual->display; XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer); const XMesaGC gc = xmbuf->cleargc; /* effected by glColorMask */ - struct xmesa_renderbuffer *srcXrb - = xmesa_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer->Wrapped); - struct xmesa_renderbuffer *dstXrb - = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]->Wrapped); + struct xmesa_renderbuffer *srcXrb, *dstXrb; + + if (!ctx->ReadBuffer->_ColorReadBuffer || + !ctx->DrawBuffer->_ColorDrawBuffers[0]) + return; ASSERT(dpy); ASSERT(gc); + srcXrb = xmesa_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer->Wrapped); + dstXrb = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]->Wrapped); + if (swrast->NewState) _swrast_validate_derived( ctx ); diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index 06a3457..d62af98 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -641,6 +641,9 @@ update_color_draw_buffers(GLcontext *ctx, struct gl_framebuffer *fb) { GLuint output; + /* set 0th buffer to NULL now in case _NumColorDrawBuffers is zero */ + fb->_ColorDrawBuffers[0] = NULL; + for (output = 0; output < fb->_NumColorDrawBuffers; output++) { GLint buf = fb->_ColorDrawBufferIndexes[output]; if (buf >= 0) { diff --git a/src/mesa/swrast/s_blit.c b/src/mesa/swrast/s_blit.c index a2c40bd..af43509 100644 --- a/src/mesa/swrast/s_blit.c +++ b/src/mesa/swrast/s_blit.c @@ -745,6 +745,9 @@ _swrast_BlitFramebuffer(GLcontext *ctx, }; GLint i; + if (!ctx->DrawBuffer->_NumColorDrawBuffers) + return; + if (!clip_blit(ctx, &srcX0, &srcY0, &srcX1, &srcY1, &dstX0, &dstY0, &dstX1, &dstY1)) { return; diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index 7bab14f..4733d10 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -54,7 +54,7 @@ fast_draw_rgba_pixels(GLcontext *ctx, GLint x, GLint y, { const GLint imgX = x, imgY = y; struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; - const GLenum rbType = rb->DataType; + GLenum rbType; SWcontext *swrast = SWRAST_CONTEXT(ctx); SWspan span; GLboolean simpleZoom; @@ -62,6 +62,11 @@ fast_draw_rgba_pixels(GLcontext *ctx, GLint x, GLint y, struct gl_pixelstore_attrib unpack; GLint destX, destY, drawWidth, drawHeight; /* post clipping */ + if (!rb) + return GL_TRUE; /* no-op */ + + rbType = rb->DataType; + if ((swrast->_RasterMask & ~CLIP_BIT) || ctx->Texture._EnabledCoordUnits || userUnpack->SwapBytes || diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c index 5036020..59e1564 100644 --- a/src/mesa/swrast/s_triangle.c +++ b/src/mesa/swrast/s_triangle.c @@ -130,7 +130,7 @@ _swrast_culltriangle( GLcontext *ctx, #define T_SCALE theight #define SETUP_CODE \ - struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];\ + struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; \ struct gl_texture_object *obj = ctx->Texture.Unit[0].Current2D; \ const GLint b = obj->BaseLevel; \ const GLfloat twidth = (GLfloat) obj->Image[0][b]->Width; \ @@ -139,8 +139,7 @@ _swrast_culltriangle( GLcontext *ctx, const GLchan *texture = (const GLchan *) obj->Image[0][b]->Data; \ const GLint smask = obj->Image[0][b]->Width - 1; \ const GLint tmask = obj->Image[0][b]->Height - 1; \ - if (!texture) { \ - /* this shouldn't happen */ \ + if (!rb || !texture) { \ return; \ } @@ -182,7 +181,7 @@ _swrast_culltriangle( GLcontext *ctx, #define T_SCALE theight #define SETUP_CODE \ - struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];\ + struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; \ struct gl_texture_object *obj = ctx->Texture.Unit[0].Current2D; \ const GLint b = obj->BaseLevel; \ const GLfloat twidth = (GLfloat) obj->Image[0][b]->Width; \ @@ -191,8 +190,7 @@ _swrast_culltriangle( GLcontext *ctx, const GLchan *texture = (const GLchan *) obj->Image[0][b]->Data; \ const GLint smask = obj->Image[0][b]->Width - 1; \ const GLint tmask = obj->Image[0][b]->Height - 1; \ - if (!texture) { \ - /* this shouldn't happen */ \ + if (!rb || !texture) { \ return; \ } |