Fix some issues with glDrawBuffer(GL_NONE), bug 14198
Set _ColorDrawBuffers[0] = NULL if no renderbuffers enabled. Check that _ColorDrawBuffers[0] is non-null before dereferencing in a few places.
This commit is contained in:
@@ -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 );
|
||||
|
||||
|
@@ -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) {
|
||||
|
@@ -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;
|
||||
|
@@ -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 ||
|
||||
|
@@ -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; \
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user