[Mesa-dev] [PATCH 4/7] mesa: remove check_compatible() in make_current

Miklós Máté mtmkls at gmail.com
Fri Feb 5 21:11:16 UTC 2016


this was marked for removal since 2007
ctx::Visual is also removed, since this was its only legit user
---
 .../drivers/dri/radeon/radeon_common_context.c     |  2 +-
 src/mesa/main/blend.c                              |  4 +-
 src/mesa/main/blend.h                              |  4 +-
 src/mesa/main/context.c                            | 89 ++--------------------
 src/mesa/main/mtypes.h                             |  7 --
 src/mesa/main/pixel.c                              |  4 +-
 src/mesa/main/pixel.h                              |  4 +-
 7 files changed, 15 insertions(+), 99 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.c b/src/mesa/drivers/dri/radeon/radeon_common_context.c
index 4660d98..2989f63 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_common_context.c
@@ -604,7 +604,7 @@ GLboolean radeonMakeCurrent(__DRIcontext * driContextPriv,
 	}
 
 	if(driDrawPriv == NULL && driReadPriv == NULL) {
-		drfb = _mesa_create_framebuffer(&radeon->glCtx.Visual);
+		drfb = _mesa_get_incomplete_framebuffer();
 		readfb = drfb;
 	}
 	else {
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index 2ae22e9..28e2dbf 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -921,7 +921,7 @@ _mesa_get_render_format(const struct gl_context *ctx, mesa_format format)
  * Initializes the related fields in the context color attribute group,
  * __struct gl_contextRec::Color.
  */
-void _mesa_init_color( struct gl_context * ctx )
+void _mesa_init_color( struct gl_context * ctx, GLuint doubleBufferMode )
 {
    GLuint i;
 
@@ -951,7 +951,7 @@ void _mesa_init_color( struct gl_context * ctx )
 
    /* GL_FRONT is not possible on GLES. Instead GL_BACK will render to either
     * the front or the back buffer depending on the config */
-   if (ctx->Visual.doubleBufferMode || _mesa_is_gles(ctx)) {
+   if (doubleBufferMode || _mesa_is_gles(ctx)) {
       ctx->Color.DrawBuffer[0] = GL_BACK;
    }
    else {
diff --git a/src/mesa/main/blend.h b/src/mesa/main/blend.h
index 8ab9e02..f4854a6 100644
--- a/src/mesa/main/blend.h
+++ b/src/mesa/main/blend.h
@@ -124,7 +124,7 @@ _mesa_update_clamp_vertex_color(struct gl_context *ctx,
 extern mesa_format
 _mesa_get_render_format(const struct gl_context *ctx, mesa_format format);
 
-extern void  
-_mesa_init_color( struct gl_context * ctx );
+extern void
+_mesa_init_color( struct gl_context * ctx, GLuint doubleBufferMode );
 
 #endif
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 8b415ed..2a512c6 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -796,7 +796,7 @@ check_context_limits(struct gl_context *ctx)
  * functions for the more complex data structures.
  */
 static GLboolean
-init_attrib_groups(struct gl_context *ctx)
+init_attrib_groups(struct gl_context *ctx, GLuint doubleBufferMode)
 {
    assert(ctx);
 
@@ -810,7 +810,7 @@ init_attrib_groups(struct gl_context *ctx)
    _mesa_init_accum( ctx );
    _mesa_init_attrib( ctx );
    _mesa_init_buffer_objects( ctx );
-   _mesa_init_color( ctx );
+   _mesa_init_color( ctx, doubleBufferMode );
    _mesa_init_current( ctx );
    _mesa_init_depth( ctx );
    _mesa_init_debug( ctx );
@@ -828,7 +828,7 @@ init_attrib_groups(struct gl_context *ctx)
    _mesa_init_multisample( ctx );
    _mesa_init_performance_monitors( ctx );
    _mesa_init_pipeline( ctx );
-   _mesa_init_pixel( ctx );
+   _mesa_init_pixel( ctx, doubleBufferMode );
    _mesa_init_pixelstore( ctx );
    _mesa_init_point( ctx );
    _mesa_init_polygon( ctx );
@@ -1159,15 +1159,6 @@ _mesa_initialize_context(struct gl_context *ctx,
    ctx->WinSysDrawBuffer = NULL;
    ctx->WinSysReadBuffer = NULL;
 
-   if (visual) {
-      ctx->Visual = *visual;
-      ctx->HasConfig = GL_TRUE;
-   }
-   else {
-      memset(&ctx->Visual, 0, sizeof ctx->Visual);
-      ctx->HasConfig = GL_FALSE;
-   }
-
    _mesa_override_gl_version(ctx);
 
    /* misc one-time initializations */
@@ -1193,7 +1184,7 @@ _mesa_initialize_context(struct gl_context *ctx,
 
    _mesa_reference_shared_state(ctx, &ctx->Shared, shared);
 
-   if (!init_attrib_groups( ctx ))
+   if (!init_attrib_groups( ctx, visual->doubleBufferMode ))
       goto fail;
 
    /* setup the API dispatch tables with all nop functions */
@@ -1521,57 +1512,6 @@ _mesa_copy_context( const struct gl_context *src, struct gl_context *dst,
 
 
 /**
- * Check if the given context can render into the given framebuffer
- * by checking visual attributes.
- *
- * Most of these tests could go away because Mesa is now pretty flexible
- * in terms of mixing rendering contexts with framebuffers.  As long
- * as RGB vs. CI mode agree, we're probably good.
- *
- * \return GL_TRUE if compatible, GL_FALSE otherwise.
- */
-static GLboolean 
-check_compatible(const struct gl_context *ctx,
-                 const struct gl_framebuffer *buffer)
-{
-   const struct gl_config *ctxvis = &ctx->Visual;
-   const struct gl_config *bufvis = &buffer->Visual;
-
-   if (buffer == _mesa_get_incomplete_framebuffer())
-      return GL_TRUE;
-
-#if 0
-   /* disabling this fixes the fgl_glxgears pbuffer demo */
-   if (ctxvis->doubleBufferMode && !bufvis->doubleBufferMode)
-      return GL_FALSE;
-#endif
-   if (ctxvis->stereoMode && !bufvis->stereoMode)
-      return GL_FALSE;
-   if (ctxvis->haveAccumBuffer && !bufvis->haveAccumBuffer)
-      return GL_FALSE;
-   if (ctxvis->haveDepthBuffer && !bufvis->haveDepthBuffer)
-      return GL_FALSE;
-   if (ctxvis->haveStencilBuffer && !bufvis->haveStencilBuffer)
-      return GL_FALSE;
-   if (ctxvis->redMask && ctxvis->redMask != bufvis->redMask)
-      return GL_FALSE;
-   if (ctxvis->greenMask && ctxvis->greenMask != bufvis->greenMask)
-      return GL_FALSE;
-   if (ctxvis->blueMask && ctxvis->blueMask != bufvis->blueMask)
-      return GL_FALSE;
-#if 0
-   /* disabled (see bug 11161) */
-   if (ctxvis->depthBits && ctxvis->depthBits != bufvis->depthBits)
-      return GL_FALSE;
-#endif
-   if (ctxvis->stencilBits && ctxvis->stencilBits != bufvis->stencilBits)
-      return GL_FALSE;
-
-   return GL_TRUE;
-}
-
-
-/**
  * Check if the viewport/scissor size has not yet been initialized.
  * Initialize the size if the given width and height are non-zero.
  */
@@ -1614,7 +1554,7 @@ handle_first_current(struct gl_context *ctx)
    /* According to GL_MESA_configless_context the default value of
     * glDrawBuffers depends on the config of the first surface it is bound to.
     * For GLES it is always GL_BACK which has a magic interpretation */
-   if (!ctx->HasConfig && _mesa_is_desktop_gl(ctx)) {
+   if (_mesa_is_desktop_gl(ctx)) {
       if (ctx->DrawBuffer != _mesa_get_incomplete_framebuffer()) {
          if (ctx->DrawBuffer->Visual.doubleBufferMode)
             buffer = GL_BACK;
@@ -1673,24 +1613,7 @@ _mesa_make_current( struct gl_context *newCtx,
    if (MESA_VERBOSE & VERBOSE_API)
       _mesa_debug(newCtx, "_mesa_make_current()\n");
 
-   /* Check that the context's and framebuffer's visuals are compatible.
-    */
-   if (newCtx && drawBuffer && newCtx->WinSysDrawBuffer != drawBuffer) {
-      if (!check_compatible(newCtx, drawBuffer)) {
-         _mesa_warning(newCtx,
-              "MakeCurrent: incompatible visuals for context and drawbuffer");
-         return GL_FALSE;
-      }
-   }
-   if (newCtx && readBuffer && newCtx->WinSysReadBuffer != readBuffer) {
-      if (!check_compatible(newCtx, readBuffer)) {
-         _mesa_warning(newCtx,
-              "MakeCurrent: incompatible visuals for context and readbuffer");
-         return GL_FALSE;
-      }
-   }
-
-   if (curCtx && 
+   if (curCtx &&
        (curCtx->WinSysDrawBuffer || curCtx->WinSysReadBuffer) &&
        /* make sure this context is valid for flushing */
        curCtx != newCtx &&
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 4d29d6a..5c4ce89 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4309,7 +4309,6 @@ struct gl_context
    struct _glapi_table *CurrentDispatch;
    /*@}*/
 
-   struct gl_config Visual;
    struct gl_framebuffer *DrawBuffer;	/**< buffer for writing */
    struct gl_framebuffer *ReadBuffer;	/**< buffer for reading */
    struct gl_framebuffer *WinSysDrawBuffer;  /**< set with MakeCurrent */
@@ -4548,12 +4547,6 @@ struct gl_context
    GLboolean FirstTimeCurrent;
    /*@}*/
 
-   /**
-    * False if this context was created without a config. This is needed
-    * because the initial state of glDrawBuffers depends on this
-    */
-   GLboolean HasConfig;
-
    /** software compression/decompression supported or not */
    GLboolean Mesa_DXTn;
 
diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c
index 608a545..ffdb31b 100644
--- a/src/mesa/main/pixel.c
+++ b/src/mesa/main/pixel.c
@@ -649,7 +649,7 @@ init_pixelmap(struct gl_pixelmap *map)
  * Initialize the context's PIXEL attribute group.
  */
 void
-_mesa_init_pixel( struct gl_context *ctx )
+_mesa_init_pixel( struct gl_context *ctx, GLuint doubleBufferMode )
 {
    /* Pixel group */
    ctx->Pixel.RedBias = 0.0;
@@ -679,7 +679,7 @@ _mesa_init_pixel( struct gl_context *ctx )
    init_pixelmap(&ctx->PixelMaps.BtoB);
    init_pixelmap(&ctx->PixelMaps.AtoA);
 
-   if (ctx->Visual.doubleBufferMode) {
+   if (doubleBufferMode) {
       ctx->Pixel.ReadBuffer = GL_BACK;
    }
    else {
diff --git a/src/mesa/main/pixel.h b/src/mesa/main/pixel.h
index fd1782e..51e4b51 100644
--- a/src/mesa/main/pixel.h
+++ b/src/mesa/main/pixel.h
@@ -66,8 +66,8 @@ _mesa_PixelTransferi( GLenum pname, GLint param );
 extern void 
 _mesa_update_pixel( struct gl_context *ctx, GLuint newstate );
 
-extern void 
-_mesa_init_pixel( struct gl_context * ctx );
+extern void
+_mesa_init_pixel( struct gl_context * ctx, GLuint doubleBufferMode );
 
 /*@}*/
 
-- 
2.7.0



More information about the mesa-dev mailing list