From f9904edf53e1f8be22991c80b4f9a5cb510674df Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 7 Oct 2009 07:43:12 -0600 Subject: gallium/xlib: return 0 for errorBase, eventBase in glXQueryExtension() A little better than leaving the values undefined, I think. See bug 24321. --- src/gallium/state_trackers/glx/xlib/glx_api.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index 6cd7ede31c..3277ff58a6 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -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; } -- cgit v1.2.3 From e3fff3daf031a997a1d4316e1a0e5c831573221d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 7 Oct 2009 07:45:15 -0600 Subject: mesa/xlib: return 0 for errorBase, eventBase in glXQueryExtension() A little better than leaving the values undefined, I think. See bug 24321. --- src/mesa/drivers/x11/fakeglx.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c index 6449dc88b0..2bda9db87c 100644 --- a/src/mesa/drivers/x11/fakeglx.c +++ b/src/mesa/drivers/x11/fakeglx.c @@ -1637,12 +1637,14 @@ Fake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst, static Bool -Fake_glXQueryExtension( Display *dpy, int *errorb, int *event ) +Fake_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; } -- cgit v1.2.3 From 4b3cbecb3a87374a292a7e454cd959e8c1eac322 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Wed, 7 Oct 2009 07:54:31 -0600 Subject: progs/test: Fix MSVC build. --- progs/tests/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/progs/tests/random.c b/progs/tests/random.c index 4023674c05..604b4d4088 100644 --- a/progs/tests/random.c +++ b/progs/tests/random.c @@ -257,11 +257,11 @@ RandomPrimitive(void) Vcount++; for (i = 0; i < len; i++) { + int k = RandomInt(9); Vbuffer[Vcount].v[0] = RandomFloat(-3, 3); Vbuffer[Vcount].v[1] = RandomFloat(-3, 3); Vbuffer[Vcount].v[2] = RandomFloat(-3, 3); Vbuffer[Vcount].v[3] = RandomFloat(-3, 3); - int k = RandomInt(9); switch (k) { case 0: glVertex2fv(Vbuffer[Vcount].v); -- cgit v1.2.3 From 14f21c785087f86d291243400e59ebfc8721c4f6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 6 Oct 2009 19:05:23 -0600 Subject: swrast: add missing returns --- src/mesa/swrast/s_depth.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c index 26e23f02d5..a9d678d180 100644 --- a/src/mesa/swrast/s_depth.c +++ b/src/mesa/swrast/s_depth.c @@ -1211,6 +1211,7 @@ _swrast_read_depth_span_float( GLcontext *ctx, struct gl_renderbuffer *rb, if (!rb) { /* really only doing this to prevent FP exceptions later */ _mesa_bzero(depth, n * sizeof(GLfloat)); + return; } ASSERT(rb->_BaseFormat == GL_DEPTH_COMPONENT); @@ -1274,6 +1275,7 @@ _swrast_read_depth_span_uint( GLcontext *ctx, struct gl_renderbuffer *rb, if (!rb) { /* really only doing this to prevent FP exceptions later */ _mesa_bzero(depth, n * sizeof(GLfloat)); + return; } ASSERT(rb->_BaseFormat == GL_DEPTH_COMPONENT); -- cgit v1.2.3 From edbaa717b49f679572805d535ed7c77518257781 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 7 Oct 2009 08:07:53 -0600 Subject: swrast: s/GLfloat/GLuint/ in bzero() --- src/mesa/swrast/s_depth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c index a9d678d180..7086cae0c8 100644 --- a/src/mesa/swrast/s_depth.c +++ b/src/mesa/swrast/s_depth.c @@ -1274,7 +1274,7 @@ _swrast_read_depth_span_uint( GLcontext *ctx, struct gl_renderbuffer *rb, { if (!rb) { /* really only doing this to prevent FP exceptions later */ - _mesa_bzero(depth, n * sizeof(GLfloat)); + _mesa_bzero(depth, n * sizeof(GLuint)); return; } -- cgit v1.2.3 From 846a6b069589d5f7b7a8a65f99a0f43cb8fed20b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 7 Oct 2009 09:10:48 -0600 Subject: progs/xdemos: fix swapped parameters to CreatePbuffer() --- progs/xdemos/pbdemo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/progs/xdemos/pbdemo.c b/progs/xdemos/pbdemo.c index 7db0017b33..425b3bbe9f 100644 --- a/progs/xdemos/pbdemo.c +++ b/progs/xdemos/pbdemo.c @@ -143,7 +143,7 @@ MakePbuffer( Display *dpy, int screen, int width, int height ) /* Create the pbuffer using first fbConfig in the list that works. */ for (i=0;i Date: Wed, 7 Oct 2009 09:11:23 -0600 Subject: progs/xdemos: test glXQueryDrawable() --- progs/xdemos/pbdemo.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/progs/xdemos/pbdemo.c b/progs/xdemos/pbdemo.c index 425b3bbe9f..2573209336 100644 --- a/progs/xdemos/pbdemo.c +++ b/progs/xdemos/pbdemo.c @@ -210,6 +210,21 @@ Setup(int width, int height) return 0; } + /* Test drawable queries */ + { + unsigned int v; + glXQueryDrawable( gDpy, gPBuffer, GLX_WIDTH, &v); + printf("GLX_WIDTH = %u\n", v); + glXQueryDrawable( gDpy, gPBuffer, GLX_HEIGHT, &v); + printf("GLX_HEIGHT = %u\n", v); + glXQueryDrawable( gDpy, gPBuffer, GLX_PRESERVED_CONTENTS, &v); + printf("GLX_PRESERVED_CONTENTS = %u\n", v); + glXQueryDrawable( gDpy, gPBuffer, GLX_LARGEST_PBUFFER, &v); + printf("GLX_LARGEST_PBUFFER = %u\n", v); + glXQueryDrawable( gDpy, gPBuffer, GLX_FBCONFIG_ID, &v); + printf("GLX_FBCONFIG_ID = %u\n", v); + } + /* Get corresponding XVisualInfo */ visInfo = GetVisualFromFBConfig(gDpy, gScreen, gFBconfig); if (!visInfo) { -- cgit v1.2.3 From 0526100a5cbd928fa28d38abdafd6beb024b0828 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 7 Oct 2009 09:40:04 -0600 Subject: gallium/xlib: fix glXQueryDrawable() bugs, see bug 24320 --- src/gallium/state_trackers/glx/xlib/glx_api.c | 38 ++++++++++++++++++--------- src/gallium/state_trackers/glx/xlib/xm_api.c | 2 +- src/gallium/state_trackers/glx/xlib/xm_api.h | 7 +++++ 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index 3277ff58a6..556eefb1b1 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -1992,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; + } } @@ -2035,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 */ @@ -369,6 +372,10 @@ xmesa_delete_framebuffer(struct gl_framebuffer *fb); 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); -- cgit v1.2.3 From c3eef6021a06d728aa4c8b882264f554f2d4b801 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 7 Oct 2009 09:40:22 -0600 Subject: mesa/xlib: fix glXQueryDrawable() bugs, see bug 24320 --- src/mesa/drivers/x11/fakeglx.c | 37 +++++++++++++++++++++++++------------ src/mesa/drivers/x11/xmesaP.h | 3 +++ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c index 2bda9db87c..525db3b7cb 100644 --- a/src/mesa/drivers/x11/fakeglx.c +++ b/src/mesa/drivers/x11/fakeglx.c @@ -2351,32 +2351,42 @@ Fake_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->frontxrb->pixmap; - else + } + else { return 0; + } } @@ -2398,6 +2408,9 @@ Fake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute, if (!xmbuf) return; + /* make sure buffer's dimensions are up to date */ + xmesa_check_and_update_buffer_size(NULL, xmbuf); + switch (attribute) { case GLX_WIDTH: *value = xmbuf->mesa_buffer.Width; @@ -2406,10 +2419,10 @@ Fake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute, *value = xmbuf->mesa_buffer.Height; break; case GLX_PRESERVED_CONTENTS: - *value = True; + *value = xmbuf->preservedContents; break; case GLX_LARGEST_PBUFFER: - *value = xmbuf->mesa_buffer.Width * xmbuf->mesa_buffer.Height; + *value = xmbuf->largestPbuffer; break; case GLX_FBCONFIG_ID: *value = xmbuf->xm_visual->visinfo->visualid; @@ -2766,10 +2779,10 @@ Fake_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, un switch (attribute) { case GLX_PRESERVED_CONTENTS_SGIX: - *value = True; + *value = xmbuf->preservedContents; break; case GLX_LARGEST_PBUFFER_SGIX: - *value = xmbuf->mesa_buffer.Width * xmbuf->mesa_buffer.Height; + *value = xmbuf->largestPbuffer; break; case GLX_WIDTH_SGIX: *value = xmbuf->mesa_buffer.Width; diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index 25db55862e..3ffd7661e3 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -212,6 +212,9 @@ struct xmesa_buffer { XMesaDisplay *display; BufferType type; /* window, pixmap, pbuffer or glxwindow */ + GLboolean largestPbuffer; /**< for pbuffers */ + GLboolean preservedContents; /**< for pbuffers */ + struct xmesa_renderbuffer *frontxrb; /* front color renderbuffer */ struct xmesa_renderbuffer *backxrb; /* back color renderbuffer */ -- cgit v1.2.3 From cdcd9da48077f4d4de810cc4c9e5c2bdf3d429d3 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 7 Oct 2009 09:41:00 -0600 Subject: docs: fix glXQueryDrawable() bugs --- docs/relnotes-7.6.1.html | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/relnotes-7.6.1.html b/docs/relnotes-7.6.1.html index d69af7aec2..52a4728133 100644 --- a/docs/relnotes-7.6.1.html +++ b/docs/relnotes-7.6.1.html @@ -42,6 +42,7 @@ tbd
  • GLSL sqrt(0) returned unpredictable results
  • Fixed default texture binding bug when a bound texture was deleted.
  • r300: Work around an issue with very large fragment programs on R500. +
  • Fake glXQueryDrawable() didn't return good values (bug 24320) -- cgit v1.2.3 From ae351599f144b9e0cb1691870dd4c305fbaab97c Mon Sep 17 00:00:00 2001 From: Nicolai Hähnle Date: Sat, 3 Oct 2009 16:18:57 +0200 Subject: prog_parameter: Document the fact that Size may be > 4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nicolai Hähnle --- src/mesa/shader/prog_parameter.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mesa/shader/prog_parameter.h b/src/mesa/shader/prog_parameter.h index d1fcf47e61..699cb0c735 100644 --- a/src/mesa/shader/prog_parameter.h +++ b/src/mesa/shader/prog_parameter.h @@ -56,7 +56,13 @@ struct gl_program_parameter const char *Name; /**< Null-terminated string */ gl_register_file Type; /**< PROGRAM_NAMED_PARAM, CONSTANT or STATE_VAR */ GLenum DataType; /**< GL_FLOAT, GL_FLOAT_VEC2, etc */ - GLuint Size; /**< Number of components (1..4) */ + /** + * Number of components (1..4), or more. + * If the number of components is greater than 4, + * this parameter is part of a larger uniform like a GLSL matrix or array. + * The next program parameter's Size will be Size-4 of this parameter. + */ + GLuint Size; GLboolean Used; /**< Helper flag for GLSL uniform tracking */ GLboolean Initialized; /**< Has the ParameterValue[] been set? */ GLbitfield Flags; /**< Bitmask of PROG_PARAM_*_BIT */ -- cgit v1.2.3 From 9fde81bb20bbfd2f8da80749cb84d890843a7bc2 Mon Sep 17 00:00:00 2001 From: Nicolai Hähnle Date: Sat, 3 Oct 2009 16:30:16 +0200 Subject: shader_api: Fix bounds checking of glUniform and glUniformMatrix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nicolai Hähnle Reviewed-by: Ian Romanick --- src/mesa/shader/shader_api.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 178b7d0dba..b282d7af60 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -1702,8 +1702,8 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program, /* we'll ignore extra data below */ } else { - /* non-array: count must be one */ - if (count != 1) { + /* non-array: count must be at most one; count == 0 is handled by the loop below */ + if (count > 1) { _mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(uniform is not an array)"); return; @@ -1880,20 +1880,27 @@ set_program_uniform_matrix(GLcontext *ctx, struct gl_program *program, GLboolean transpose, const GLfloat *values) { GLuint mat, row, col; - GLuint dst = index + offset, src = 0; + GLuint src = 0; + const struct gl_program_parameter * param = &program->Parameters->Parameters[index]; + const GLint slots = (param->Size + 3) / 4; + const GLint typeSize = sizeof_glsl_type(param->DataType); GLint nr, nc; /* check that the number of rows, columns is correct */ - get_matrix_dims(program->Parameters->Parameters[index].DataType, &nr, &nc); + get_matrix_dims(param->DataType, &nr, &nc); if (rows != nr || cols != nc) { _mesa_error(ctx, GL_INVALID_OPERATION, "glUniformMatrix(matrix size mismatch)"); return; } - if (index + offset > program->Parameters->Size) { - /* out of bounds! */ - return; + if (param->Size <= typeSize) { + /* non-array: count must be at most one; count == 0 is handled by the loop below */ + if (count > 1) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUniformMatrix(uniform is not an array)"); + return; + } } /* @@ -1907,7 +1914,12 @@ set_program_uniform_matrix(GLcontext *ctx, struct gl_program *program, /* each matrix: */ for (col = 0; col < cols; col++) { - GLfloat *v = program->Parameters->ParameterValues[dst]; + GLfloat *v; + if (offset >= slots) { + /* Ignore writes beyond the end of (the used part of) an array */ + return; + } + v = program->Parameters->ParameterValues[index + offset]; for (row = 0; row < rows; row++) { if (transpose) { v[row] = values[src + row * cols + col]; @@ -1916,7 +1928,8 @@ set_program_uniform_matrix(GLcontext *ctx, struct gl_program *program, v[row] = values[src + col * rows + row]; } } - dst++; + + offset++; } src += rows * cols; /* next matrix */ -- cgit v1.2.3