summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/dri/dri_drawable.c10
-rw-r--r--src/gallium/state_trackers/glx/xlib/glx_api.c54
-rw-r--r--src/gallium/state_trackers/glx/xlib/xm_api.c2
-rw-r--r--src/gallium/state_trackers/glx/xlib/xm_api.h7
4 files changed, 50 insertions, 23 deletions
diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c
index 5cec9e329d..c67cc8dacb 100644
--- a/src/gallium/state_trackers/dri/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/dri_drawable.c
@@ -179,7 +179,6 @@ dri_get_buffers(__DRIdrawablePrivate * dPriv)
switch (buffers[i].attachment) {
case __DRI_BUFFER_FRONT_LEFT:
- continue;
case __DRI_BUFFER_FAKE_FRONT_LEFT:
index = ST_SURFACE_FRONT_LEFT;
format = drawable->color_format;
@@ -214,6 +213,7 @@ dri_get_buffers(__DRIdrawablePrivate * dPriv)
dri_drawable->h, buffers[i].pitch);
switch (buffers[i].attachment) {
+ case __DRI_BUFFER_FRONT_LEFT:
case __DRI_BUFFER_FAKE_FRONT_LEFT:
case __DRI_BUFFER_BACK_LEFT:
drawable->color_format = surface->format;
@@ -223,6 +223,9 @@ dri_get_buffers(__DRIdrawablePrivate * dPriv)
case __DRI_BUFFER_STENCIL:
drawable->depth_stencil_format = surface->format;
break;
+ case __DRI_BUFFER_ACCUM:
+ default:
+ assert(0);
}
st_set_framebuffer_surface(drawable->stfb, index, surface);
@@ -250,6 +253,9 @@ void dri2_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target,
dri_get_buffers(drawable->dPriv);
st_get_framebuffer_surface(drawable->stfb, ST_SURFACE_FRONT_LEFT, &ps);
+ if (!ps)
+ return;
+
st_bind_texture_surface(ps, target == GL_TEXTURE_2D ? ST_TEXTURE_2D :
ST_TEXTURE_RECT, 0, drawable->color_format);
}
@@ -360,8 +366,6 @@ dri_create_buffer(__DRIscreenPrivate * sPriv,
if (visual->doubleBufferMode)
drawable->attachments[i++] = __DRI_BUFFER_BACK_LEFT;
- else
- drawable->attachments[i++] = __DRI_BUFFER_FAKE_FRONT_LEFT;
if (visual->depthBits && visual->stencilBits)
drawable->attachments[i++] = __DRI_BUFFER_DEPTH_STENCIL;
else if (visual->depthBits)
diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c
index 65012e9253..556eefb1b1 100644
--- a/src/gallium/state_trackers/glx/xlib/glx_api.c
+++ b/src/gallium/state_trackers/glx/xlib/glx_api.c
@@ -850,10 +850,10 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig )
if (!fbConfig)
return NULL;
parselist++;
- if (*parselist == GLX_RGBA_BIT) {
+ if (*parselist & GLX_RGBA_BIT) {
rgb_flag = GL_TRUE;
}
- else if (*parselist == GLX_COLOR_INDEX_BIT) {
+ else if (*parselist & GLX_COLOR_INDEX_BIT) {
rgb_flag = GL_FALSE;
}
else if (*parselist == 0) {
@@ -1309,12 +1309,14 @@ glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
Bool
-glXQueryExtension( Display *dpy, int *errorb, int *event )
+glXQueryExtension( Display *dpy, int *errorBase, int *eventBase )
{
/* Mesa's GLX isn't really an X extension but we try to act like one. */
(void) dpy;
- (void) errorb;
- (void) event;
+ if (errorBase)
+ *errorBase = 0;
+ if (eventBase)
+ *eventBase = 0;
return True;
}
@@ -1538,9 +1540,9 @@ get_config( XMesaVisual xmvis, int attrib, int *value, GLboolean fbconfig )
if (!fbconfig)
return GLX_BAD_ATTRIBUTE;
if (xmvis->mesa_visual.rgbMode)
- *value = GLX_RGBA_TYPE;
+ *value = GLX_RGBA_BIT;
else
- *value = GLX_COLOR_INDEX_TYPE;
+ *value = GLX_COLOR_INDEX_BIT;
break;
case GLX_X_RENDERABLE_SGIX:
if (!fbconfig)
@@ -1990,32 +1992,42 @@ glXCreatePbuffer( Display *dpy, GLXFBConfig config,
break;
case GLX_PRESERVED_CONTENTS:
attrib++;
- preserveContents = *attrib; /* ignored */
+ preserveContents = *attrib;
break;
case GLX_LARGEST_PBUFFER:
attrib++;
- useLargest = *attrib; /* ignored */
+ useLargest = *attrib;
break;
default:
return 0;
}
}
- /* not used at this time */
- (void) useLargest;
- (void) preserveContents;
-
if (width == 0 || height == 0)
return 0;
+ if (width > MAX_WIDTH || height > MAX_HEIGHT) {
+ /* If allocation would have failed and GLX_LARGEST_PBUFFER is set,
+ * allocate the largest possible buffer.
+ */
+ if (useLargest) {
+ width = MAX_WIDTH;
+ height = MAX_HEIGHT;
+ }
+ }
+
xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height);
/* A GLXPbuffer handle must be an X Drawable because that's what
* glXMakeCurrent takes.
*/
- if (xmbuf)
+ if (xmbuf) {
+ xmbuf->largestPbuffer = useLargest;
+ xmbuf->preservedContents = preserveContents;
return (GLXPbuffer) xmbuf->drawable;
- else
+ }
+ else {
return 0;
+ }
}
@@ -2033,22 +2045,26 @@ void
glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
unsigned int *value )
{
+ GLuint width, height;
XMesaBuffer xmbuf = XMesaFindBuffer(dpy, draw);
if (!xmbuf)
return;
+ /* make sure buffer's dimensions are up to date */
+ xmesa_get_window_size(dpy, xmbuf, &width, &height);
+
switch (attribute) {
case GLX_WIDTH:
- *value = xmesa_buffer_width(xmbuf);
+ *value = width;
break;
case GLX_HEIGHT:
- *value = xmesa_buffer_width(xmbuf);
+ *value = height;
break;
case GLX_PRESERVED_CONTENTS:
- *value = True;
+ *value = xmbuf->preservedContents;
break;
case GLX_LARGEST_PBUFFER:
- *value = xmesa_buffer_width(xmbuf) * xmesa_buffer_height(xmbuf);
+ *value = xmbuf->largestPbuffer;
break;
case GLX_FBCONFIG_ID:
*value = xmbuf->xm_visual->visinfo->visualid;
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c
index 957002ddd5..c76dfb31d2 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -228,7 +228,7 @@ get_drawable_size( Display *dpy, Drawable d, uint *width, uint *height )
* \param width returns width in pixels
* \param height returns height in pixels
*/
-static void
+void
xmesa_get_window_size(Display *dpy, XMesaBuffer b,
GLuint *width, GLuint *height)
{
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.h b/src/gallium/state_trackers/glx/xlib/xm_api.h
index ce97a3ec76..d24971ca1c 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.h
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.h
@@ -323,6 +323,9 @@ struct xmesa_buffer {
Colormap cmap; /* the X colormap */
BufferType type; /* window, pixmap, pbuffer or glxwindow */
+ GLboolean largestPbuffer; /**< for pbuffers */
+ GLboolean preservedContents; /**< for pbuffers */
+
XImage *tempImage;
unsigned long selectedEvents;/* for pbuffers only */
@@ -370,6 +373,10 @@ extern XMesaBuffer
xmesa_find_buffer(Display *dpy, Colormap cmap, XMesaBuffer notThis);
extern void
+xmesa_get_window_size(Display *dpy, XMesaBuffer b,
+ GLuint *width, GLuint *height);
+
+extern void
xmesa_check_and_update_buffer_size(XMesaContext xmctx, XMesaBuffer drawBuffer);
extern void