mesa: Eliminate gl_config::rgbMode

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Adam Jackson
2019-09-06 12:30:19 -04:00
parent 78e0fa6bb2
commit 366b2e5c19
8 changed files with 31 additions and 68 deletions

View File

@@ -191,6 +191,9 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
GLint i; GLint i;
GLboolean comparePointers; GLboolean comparePointers;
if (!rgbFlag)
return NULL;
if (dbFlag) { if (dbFlag) {
/* Check if the MESA_BACK_BUFFER env var is set */ /* Check if the MESA_BACK_BUFFER env var is set */
char *backbuffer = getenv("MESA_BACK_BUFFER"); char *backbuffer = getenv("MESA_BACK_BUFFER");
@@ -234,7 +237,6 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
&& v->mesa_visual.numAuxBuffers == numAuxBuffers && v->mesa_visual.numAuxBuffers == numAuxBuffers
&& v->mesa_visual.samples == num_samples && v->mesa_visual.samples == num_samples
&& v->ximage_flag == ximageFlag && v->ximage_flag == ximageFlag
&& v->mesa_visual.rgbMode == rgbFlag
&& v->mesa_visual.doubleBufferMode == dbFlag && v->mesa_visual.doubleBufferMode == dbFlag
&& v->mesa_visual.stereoMode == stereoFlag && v->mesa_visual.stereoMode == stereoFlag
&& (v->mesa_visual.alphaBits > 0) == alphaFlag && (v->mesa_visual.alphaBits > 0) == alphaFlag
@@ -1522,12 +1524,7 @@ get_config( XMesaVisual xmvis, int attrib, int *value, GLboolean fbconfig )
case GLX_RGBA: case GLX_RGBA:
if (fbconfig) if (fbconfig)
return GLX_BAD_ATTRIBUTE; return GLX_BAD_ATTRIBUTE;
if (xmvis->mesa_visual.rgbMode) {
*value = True; *value = True;
}
else {
*value = False;
}
return 0; return 0;
case GLX_DOUBLEBUFFER: case GLX_DOUBLEBUFFER:
*value = (int) xmvis->mesa_visual.doubleBufferMode; *value = (int) xmvis->mesa_visual.doubleBufferMode;
@@ -1639,10 +1636,7 @@ get_config( XMesaVisual xmvis, int attrib, int *value, GLboolean fbconfig )
case GLX_RENDER_TYPE_SGIX: case GLX_RENDER_TYPE_SGIX:
if (!fbconfig) if (!fbconfig)
return GLX_BAD_ATTRIBUTE; return GLX_BAD_ATTRIBUTE;
if (xmvis->mesa_visual.rgbMode)
*value = GLX_RGBA_BIT; *value = GLX_RGBA_BIT;
else
*value = GLX_COLOR_INDEX_BIT;
break; break;
case GLX_X_RENDERABLE_SGIX: case GLX_X_RENDERABLE_SGIX:
if (!fbconfig) if (!fbconfig)
@@ -2222,10 +2216,7 @@ glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value )
*value = xmctx->xm_visual->visinfo->visualid; *value = xmctx->xm_visual->visinfo->visualid;
break; break;
case GLX_RENDER_TYPE: case GLX_RENDER_TYPE:
if (xmctx->xm_visual->mesa_visual.rgbMode)
*value = GLX_RGBA_TYPE; *value = GLX_RGBA_TYPE;
else
*value = GLX_COLOR_INDEX_TYPE;
break; break;
case GLX_SCREEN: case GLX_SCREEN:
*value = 0; *value = 0;

View File

@@ -636,15 +636,13 @@ xmesa_free_buffer(XMesaBuffer buffer)
* initializing the context's visual and buffer information. * initializing the context's visual and buffer information.
* \param v the XMesaVisual to initialize * \param v the XMesaVisual to initialize
* \param b the XMesaBuffer to initialize (may be NULL) * \param b the XMesaBuffer to initialize (may be NULL)
* \param rgb_flag TRUE = RGBA mode, FALSE = color index mode
* \param window the window/pixmap we're rendering into * \param window the window/pixmap we're rendering into
* \param cmap the colormap associated with the window/pixmap * \param cmap the colormap associated with the window/pixmap
* \return GL_TRUE=success, GL_FALSE=failure * \return GL_TRUE=success, GL_FALSE=failure
*/ */
static GLboolean static GLboolean
initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b, initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b,
GLboolean rgb_flag, Drawable window, Drawable window, Colormap cmap)
Colormap cmap)
{ {
assert(!b || b->xm_visual == v); assert(!b || b->xm_visual == v);
@@ -652,11 +650,6 @@ initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b,
v->BitsPerPixel = bits_per_pixel(v); v->BitsPerPixel = bits_per_pixel(v);
assert(v->BitsPerPixel > 0); assert(v->BitsPerPixel > 0);
if (rgb_flag == GL_FALSE) {
/* COLOR-INDEXED WINDOW: not supported*/
return GL_FALSE;
}
else {
/* RGB WINDOW: /* RGB WINDOW:
* We support RGB rendering into almost any kind of visual. * We support RGB rendering into almost any kind of visual.
*/ */
@@ -674,7 +667,6 @@ initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b,
*/ */
v->mesa_visual.alphaBits = 8; v->mesa_visual.alphaBits = 8;
} }
}
/* /*
* If MESA_INFO env var is set print out some debugging info * If MESA_INFO env var is set print out some debugging info
@@ -774,6 +766,9 @@ XMesaVisual XMesaCreateVisual( Display *display,
if (!xmdpy) if (!xmdpy)
return NULL; return NULL;
if (!rgb_flag)
return NULL;
/* For debugging only */ /* For debugging only */
if (getenv("MESA_XSYNC")) { if (getenv("MESA_XSYNC")) {
/* This makes debugging X easier. /* This makes debugging X easier.
@@ -820,7 +815,7 @@ XMesaVisual XMesaCreateVisual( Display *display,
if (alpha_flag) if (alpha_flag)
v->mesa_visual.alphaBits = 8; v->mesa_visual.alphaBits = 8;
(void) initialize_visual_and_buffer( v, NULL, rgb_flag, 0, 0 ); (void) initialize_visual_and_buffer( v, NULL, 0, 0 );
{ {
const int xclass = v->visualType; const int xclass = v->visualType;
@@ -848,7 +843,6 @@ XMesaVisual XMesaCreateVisual( Display *display,
{ {
struct gl_config *vis = &v->mesa_visual; struct gl_config *vis = &v->mesa_visual;
vis->rgbMode = GL_TRUE;
vis->doubleBufferMode = db_flag; vis->doubleBufferMode = db_flag;
vis->stereoMode = stereo_flag; vis->stereoMode = stereo_flag;
@@ -1109,8 +1103,7 @@ XMesaCreateWindowBuffer(XMesaVisual v, Window w)
if (!b) if (!b)
return NULL; return NULL;
if (!initialize_visual_and_buffer( v, b, v->mesa_visual.rgbMode, if (!initialize_visual_and_buffer( v, b, (Drawable) w, cmap )) {
(Drawable) w, cmap )) {
xmesa_free_buffer(b); xmesa_free_buffer(b);
return NULL; return NULL;
} }
@@ -1140,8 +1133,7 @@ XMesaCreatePixmapBuffer(XMesaVisual v, Pixmap p, Colormap cmap)
if (!b) if (!b)
return NULL; return NULL;
if (!initialize_visual_and_buffer(v, b, v->mesa_visual.rgbMode, if (!initialize_visual_and_buffer(v, b, (Drawable) p, cmap)) {
(Drawable) p, cmap)) {
xmesa_free_buffer(b); xmesa_free_buffer(b);
return NULL; return NULL;
} }
@@ -1199,8 +1191,7 @@ XMesaCreatePixmapTextureBuffer(XMesaVisual v, Pixmap p,
b->TextureFormat = format; b->TextureFormat = format;
b->TextureMipmap = mipmap; b->TextureMipmap = mipmap;
if (!initialize_visual_and_buffer(v, b, v->mesa_visual.rgbMode, if (!initialize_visual_and_buffer(v, b, (Drawable) p, cmap)) {
(Drawable) p, cmap)) {
xmesa_free_buffer(b); xmesa_free_buffer(b);
return NULL; return NULL;
} }
@@ -1229,8 +1220,7 @@ XMesaCreatePBuffer(XMesaVisual v, Colormap cmap,
if (!b) if (!b)
return NULL; return NULL;
if (!initialize_visual_and_buffer(v, b, v->mesa_visual.rgbMode, if (!initialize_visual_and_buffer(v, b, drawable, cmap)) {
drawable, cmap)) {
xmesa_free_buffer(b); xmesa_free_buffer(b);
return NULL; return NULL;
} }

View File

@@ -355,7 +355,6 @@ driCreateConfigs(mesa_format format,
modes->transparentBlue = GLX_DONT_CARE; modes->transparentBlue = GLX_DONT_CARE;
modes->transparentAlpha = GLX_DONT_CARE; modes->transparentAlpha = GLX_DONT_CARE;
modes->transparentIndex = GLX_DONT_CARE; modes->transparentIndex = GLX_DONT_CARE;
modes->rgbMode = GL_TRUE;
if (db_modes[i] == __DRI_ATTRIB_SWAP_NONE) { if (db_modes[i] == __DRI_ATTRIB_SWAP_NONE) {
modes->doubleBufferMode = GL_FALSE; modes->doubleBufferMode = GL_FALSE;

View File

@@ -1551,12 +1551,7 @@ get_config( XMesaVisual xmvis, int attrib, int *value, GLboolean fbconfig )
case GLX_RGBA: case GLX_RGBA:
if (fbconfig) if (fbconfig)
return GLX_BAD_ATTRIBUTE; return GLX_BAD_ATTRIBUTE;
if (xmvis->mesa_visual.rgbMode) {
*value = True; *value = True;
}
else {
*value = False;
}
return 0; return 0;
case GLX_DOUBLEBUFFER: case GLX_DOUBLEBUFFER:
*value = (int) xmvis->mesa_visual.doubleBufferMode; *value = (int) xmvis->mesa_visual.doubleBufferMode;
@@ -1618,13 +1613,8 @@ get_config( XMesaVisual xmvis, int attrib, int *value, GLboolean fbconfig )
} }
else if (xmvis->mesa_visual.level>0) { else if (xmvis->mesa_visual.level>0) {
/* overlay */ /* overlay */
if (xmvis->mesa_visual.rgbMode) {
*value = GLX_TRANSPARENT_RGB_EXT; *value = GLX_TRANSPARENT_RGB_EXT;
} }
else {
*value = GLX_TRANSPARENT_INDEX_EXT;
}
}
else if (xmvis->mesa_visual.level<0) { else if (xmvis->mesa_visual.level<0) {
/* underlay */ /* underlay */
*value = GLX_NONE_EXT; *value = GLX_NONE_EXT;
@@ -1691,10 +1681,8 @@ get_config( XMesaVisual xmvis, int attrib, int *value, GLboolean fbconfig )
return GLX_BAD_ATTRIBUTE; return GLX_BAD_ATTRIBUTE;
if (xmvis->mesa_visual.floatMode) if (xmvis->mesa_visual.floatMode)
*value = GLX_RGBA_FLOAT_BIT_ARB; *value = GLX_RGBA_FLOAT_BIT_ARB;
else if (xmvis->mesa_visual.rgbMode)
*value = GLX_RGBA_BIT;
else else
*value = GLX_COLOR_INDEX_BIT; *value = GLX_RGBA_BIT;
break; break;
case GLX_X_RENDERABLE_SGIX: case GLX_X_RENDERABLE_SGIX:
if (!fbconfig) if (!fbconfig)

View File

@@ -287,7 +287,6 @@ _mesa_initialize_visual( struct gl_config *vis,
assert(accumBlueBits >= 0); assert(accumBlueBits >= 0);
assert(accumAlphaBits >= 0); assert(accumAlphaBits >= 0);
vis->rgbMode = GL_TRUE;
vis->doubleBufferMode = dbFlag; vis->doubleBufferMode = dbFlag;
vis->stereoMode = stereoFlag; vis->stereoMode = stereoFlag;

View File

@@ -435,7 +435,6 @@ _mesa_update_framebuffer_visual(struct gl_context *ctx,
struct gl_framebuffer *fb) struct gl_framebuffer *fb)
{ {
memset(&fb->Visual, 0, sizeof(fb->Visual)); memset(&fb->Visual, 0, sizeof(fb->Visual));
fb->Visual.rgbMode = GL_TRUE; /* assume this */
/* find first RGB renderbuffer */ /* find first RGB renderbuffer */
for (unsigned i = 0; i < BUFFER_COUNT; i++) { for (unsigned i = 0; i < BUFFER_COUNT; i++) {

View File

@@ -159,7 +159,6 @@ _mesa_varying_slot_in_fs(gl_varying_slot slot)
*/ */
struct gl_config struct gl_config
{ {
GLboolean rgbMode;
GLboolean floatMode; GLboolean floatMode;
GLuint doubleBufferMode; GLuint doubleBufferMode;
GLuint stereoMode; GLuint stereoMode;

View File

@@ -380,8 +380,6 @@ st_visual_to_context_mode(const struct st_visual *visual,
mode->stereoMode = GL_TRUE; mode->stereoMode = GL_TRUE;
if (visual->color_format != PIPE_FORMAT_NONE) { if (visual->color_format != PIPE_FORMAT_NONE) {
mode->rgbMode = GL_TRUE;
mode->redBits = mode->redBits =
util_format_get_component_bits(visual->color_format, util_format_get_component_bits(visual->color_format,
UTIL_FORMAT_COLORSPACE_RGB, 0); UTIL_FORMAT_COLORSPACE_RGB, 0);