From d22828f716fba0c63522101bd18f9660db17b364 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 16 Jun 2009 21:30:59 +0100 Subject: wgl: Factor out some repetitive code into inline functions. --- .../state_trackers/wgl/shared/stw_context.c | 57 +++++++++++----------- 1 file changed, 28 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index 662b5fbcd2..1c217699ab 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -47,6 +47,23 @@ #include "stw_context.h" #include "stw_tls.h" + +static INLINE struct stw_context * +stw_context(GLcontext *glctx) +{ + if(!glctx) + return NULL; + assert(glctx->DriverCtx); + return (struct stw_context *)glctx->DriverCtx; +} + +static INLINE struct stw_context * +stw_current_context(void) +{ + GET_CURRENT_CONTEXT( glctx ); + return stw_context(glctx); +} + BOOL stw_copy_context( UINT_PTR hglrcSrc, @@ -194,11 +211,10 @@ stw_delete_context( pipe_mutex_unlock( stw_dev->mutex ); if (ctx) { - GLcontext *glctx = ctx->st->ctx; - GET_CURRENT_CONTEXT( glcurctx ); - + struct stw_context *curctx = stw_current_context(); + /* Unbind current if deleting current context. */ - if (glcurctx == glctx) + if (curctx == ctx) st_make_current( NULL, NULL, NULL ); st_destroy_context(ctx->st); @@ -230,13 +246,8 @@ stw_release_context( * current for this thread. We should check that and return False * if not the case. */ - { - GLcontext *glctx = ctx->st->ctx; - GET_CURRENT_CONTEXT( glcurctx ); - - if (glcurctx != glctx) - return FALSE; - } + if (ctx != stw_current_context()) + return FALSE; if (stw_make_current( NULL, 0 ) == FALSE) return FALSE; @@ -248,14 +259,9 @@ stw_release_context( UINT_PTR stw_get_current_context( void ) { - GET_CURRENT_CONTEXT( glcurctx ); struct stw_context *ctx; - if(!glcurctx) - return 0; - - ctx = (struct stw_context *)glcurctx->DriverCtx; - assert(ctx); + ctx = stw_current_context(); if(!ctx) return 0; @@ -265,14 +271,9 @@ stw_get_current_context( void ) HDC stw_get_current_dc( void ) { - GET_CURRENT_CONTEXT( glcurctx ); struct stw_context *ctx; - if(!glcurctx) - return NULL; - - ctx = (struct stw_context *)glcurctx->DriverCtx; - assert(ctx); + ctx = stw_current_context(); if(!ctx) return NULL; @@ -284,19 +285,17 @@ stw_make_current( HDC hdc, UINT_PTR hglrc ) { + struct stw_context *curctx; struct stw_context *ctx; - GET_CURRENT_CONTEXT( glcurctx ); struct stw_framebuffer *fb; if (!stw_dev) goto fail; - if (glcurctx != NULL) { - struct stw_context *curctx; - curctx = (struct stw_context *) glcurctx->DriverCtx; - + curctx = stw_current_context(); + if (curctx != NULL) { if (curctx->hglrc != hglrc) - st_flush(glcurctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + st_flush(curctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); /* Return if already current. */ if (curctx->hglrc == hglrc && curctx->hdc == hdc) -- cgit v1.2.3 From c53705ed7b89e5a2586b534508182de9c72452ea Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Jun 2009 07:58:35 -0600 Subject: GLX: attempt to fix glean makeCurrent test cases. Two parts to this: One we don't keep pointers to possibly freed memory anymore once we unbind the drawables from the context. Brian I need to figure out what the comment you made there, can we get a glean/piglit test so we can fix it properly? If the new gc is the same as the oldGC, we call the unbind even though we just bound it in that function. doh. (cherry picked from master, commit 77506dac8e81e9548a7e9680ce367175fe5747af) --- src/glx/x11/glxcurrent.c | 2 +- src/mesa/drivers/dri/common/dri_util.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/glx/x11/glxcurrent.c b/src/glx/x11/glxcurrent.c index 01f4233241..d44e0dd1fc 100644 --- a/src/glx/x11/glxcurrent.c +++ b/src/glx/x11/glxcurrent.c @@ -457,7 +457,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, &dummy_reply); } #ifdef GLX_DIRECT_RENDERING - else if (oldGC->driContext) { + else if (oldGC->driContext && oldGC != gc) { oldGC->driContext->unbindContext(oldGC->driContext); } #endif diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index e112720471..576494940f 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -119,6 +119,9 @@ static int driUnbindContext(__DRIcontext *pcp) pdp = pcp->driDrawablePriv; prp = pcp->driReadablePriv; + /* already unbound */ + if (!pdp && !prp) + return GL_TRUE; /* Let driver unbind drawable from context */ (*psp->DriverAPI.UnbindContext)(pcp); @@ -143,9 +146,10 @@ static int driUnbindContext(__DRIcontext *pcp) * window we can determine the last context bound to the window and * use that context's lock. (BrianP, 2-Dec-2000) */ + pcp->driDrawablePriv = pcp->driReadablePriv = NULL; + #if 0 /* Unbind the drawable */ - pcp->driDrawablePriv = NULL; pdp->driContextPriv = &psp->dummyContextPriv; #endif -- cgit v1.2.3 From 3705f48688d7d2c8d4ff5f108ff6b56e289d1967 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Jun 2009 08:33:39 -0600 Subject: st/glx: added null ptr check in Fake_glXCreatePixmap() Fixes segfault in progs/xdemos/glxgears_pixmap.c --- src/gallium/state_trackers/glx/xlib/fakeglx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/state_trackers/glx/xlib/fakeglx.c b/src/gallium/state_trackers/glx/xlib/fakeglx.c index 65e7048188..6df4c7d693 100644 --- a/src/gallium/state_trackers/glx/xlib/fakeglx.c +++ b/src/gallium/state_trackers/glx/xlib/fakeglx.c @@ -1817,7 +1817,7 @@ Fake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap, if (!dpy || !config || !pixmap) return 0; - for (attr = attribList; *attr; attr++) { + for (attr = attribList; attr && *attr; attr++) { switch (*attr) { case GLX_TEXTURE_FORMAT_EXT: attr++; -- cgit v1.2.3 From d18c57aaeac37cde0cb551191ecd3c3a56a0ffba Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Jun 2009 08:34:24 -0600 Subject: mesa: added null ptr check in Fake_glXCreatePixmap() Fixes segfault in progs/xdemos/glxgears_pixmap.c --- src/mesa/drivers/x11/fakeglx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c index 3b004a3ee2..34e0b8bc8d 100644 --- a/src/mesa/drivers/x11/fakeglx.c +++ b/src/mesa/drivers/x11/fakeglx.c @@ -2218,7 +2218,7 @@ Fake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap, if (!dpy || !config || !pixmap) return 0; - for (attr = attribList; *attr; attr++) { + for (attr = attribList; attr && *attr; attr++) { switch (*attr) { case GLX_TEXTURE_FORMAT_EXT: attr++; -- cgit v1.2.3 From 3f856c6b6b7fa95ef97a8712876de88d7d57932e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Jun 2009 08:35:55 -0600 Subject: mesa: rework viewport/scissor initialization code The first time a context is bound to a drawable, the viewport and scissor bounds are initialized to the buffer's size. This is actually a bit tricky. A new _mesa_check_init_viewport() function is called in several places to check if the viewport has been initialized. We also use a new ctx->ViewportInitialized flag instead of the overloaded ctx->FirstTimeCurrent flag. --- src/mesa/main/context.c | 41 +++++++++++++++++++++++---------- src/mesa/main/context.h | 3 +++ src/mesa/main/mtypes.h | 2 ++ src/mesa/state_tracker/st_context.c | 15 +++--------- src/mesa/state_tracker/st_framebuffer.c | 11 +-------- 5 files changed, 38 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index a947f69632..0a4c9acdfe 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1255,6 +1255,24 @@ initialize_framebuffer_size(GLcontext *ctx, GLframebuffer *fb) } +/** + * Check if the viewport/scissor size has not yet been initialized. + * Initialize the size if the given width and height are non-zero. + */ +void +_mesa_check_init_viewport(GLcontext *ctx, GLuint width, GLuint height) +{ + if (!ctx->ViewportInitialized && width > 0 && height > 0) { + /* Note: set flag here, before calling _mesa_set_viewport(), to prevent + * potential infinite recursion. + */ + ctx->ViewportInitialized = GL_TRUE; + _mesa_set_viewport(ctx, 0, 0, width, height); + _mesa_set_scissor(ctx, 0, 0, width, height); + } +} + + /** * Bind the given context to the given drawBuffer and readBuffer and * make it the current context for the calling thread. @@ -1372,25 +1390,24 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, ASSERT(drawBuffer->Height > 0); #endif - if (newCtx->FirstTimeCurrent) { - /* set initial viewport and scissor size now */ - _mesa_set_viewport(newCtx, 0, 0, - drawBuffer->Width, drawBuffer->Height); - _mesa_set_scissor(newCtx, 0, 0, - drawBuffer->Width, drawBuffer->Height ); - check_context_limits(newCtx); + if (drawBuffer) { + _mesa_check_init_viewport(newCtx, + drawBuffer->Width, drawBuffer->Height); } } - /* We can use this to help debug user's problems. Tell them to set - * the MESA_INFO env variable before running their app. Then the - * first time each context is made current we'll print some useful - * information. - */ if (newCtx->FirstTimeCurrent) { + check_context_limits(newCtx); + + /* We can use this to help debug user's problems. Tell them to set + * the MESA_INFO env variable before running their app. Then the + * first time each context is made current we'll print some useful + * information. + */ if (_mesa_getenv("MESA_INFO")) { _mesa_print_info(); } + newCtx->FirstTimeCurrent = GL_FALSE; } } diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index 6b3e1b2b97..0531ae8ee8 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -130,6 +130,9 @@ extern void _mesa_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask); +extern void +_mesa_check_init_viewport(GLcontext *ctx, GLuint width, GLuint height); + extern GLboolean _mesa_make_current( GLcontext *ctx, GLframebuffer *drawBuffer, GLframebuffer *readBuffer ); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 50dc2def87..8872c8963f 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2947,6 +2947,8 @@ struct __GLcontextRec GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */ GLbitfield NewState; /**< bitwise-or of _NEW_* flags */ + GLboolean ViewportInitialized; /**< has viewport size been initialized? */ + GLbitfield varying_vp_inputs; /**< mask of VERT_BIT_* flags */ /** \name Derived state */ diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 92ddffc014..8514b6b375 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -274,20 +274,11 @@ st_make_current(struct st_context *st, _glapi_check_multithread(); if (st) { - GLboolean firstTime = st->ctx->FirstTimeCurrent; - if(!_mesa_make_current(st->ctx, &draw->Base, &read->Base)) + if (!_mesa_make_current(st->ctx, &draw->Base, &read->Base)) return GL_FALSE; - /* Need to initialize viewport here since draw->Base->Width/Height - * will still be zero at this point. - * This could be improved, but would require rather extensive work - * elsewhere (allocate rb surface storage sooner) - */ - if (firstTime) { - GLuint w = draw->InitWidth, h = draw->InitHeight; - _mesa_set_viewport(st->ctx, 0, 0, w, h); - _mesa_set_scissor(st->ctx, 0, 0, w, h); - } + _mesa_check_init_viewport(st->ctx, draw->InitWidth, draw->InitHeight); + return GL_TRUE; } else { diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c index 331575660d..33a90ea7db 100644 --- a/src/mesa/state_tracker/st_framebuffer.c +++ b/src/mesa/state_tracker/st_framebuffer.c @@ -134,16 +134,7 @@ void st_resize_framebuffer( struct st_framebuffer *stfb, if (stfb->Base.Width != width || stfb->Base.Height != height) { GET_CURRENT_CONTEXT(ctx); if (ctx) { - if (stfb->InitWidth == 0 && stfb->InitHeight == 0) { - /* didn't have a valid size until now */ - stfb->InitWidth = width; - stfb->InitHeight = height; - if (ctx->Viewport.Width <= 1) { - /* set context's initial viewport/scissor size */ - _mesa_set_viewport(ctx, 0, 0, width, height); - _mesa_set_scissor(ctx, 0, 0, width, height); - } - } + _mesa_check_init_viewport(ctx, width, height); _mesa_resize_framebuffer(ctx, &stfb->Base, width, height); -- cgit v1.2.3 From 2770107d87ccfd558480c44cd90a75524bdea738 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 10 May 2009 09:45:43 -0700 Subject: intel: Map write-only buffer objects through the GTT when possible. This looks to be a win of a few percent in cairogears with new vbo code, thanks to not polluting caches. (cherry picked from commit aa422b262509bc0763a50f63a51a1730139ea52f) --- src/mesa/drivers/dri/intel/intel_buffer_objects.c | 16 ++++++++++++++-- src/mesa/drivers/dri/intel/intel_buffer_objects.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c b/src/mesa/drivers/dri/intel/intel_buffer_objects.c index c849e4869e..1b64c68157 100644 --- a/src/mesa/drivers/dri/intel/intel_buffer_objects.c +++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.c @@ -205,6 +205,7 @@ intel_bufferobj_map(GLcontext * ctx, struct intel_context *intel = intel_context(ctx); struct intel_buffer_object *intel_obj = intel_buffer_object(obj); GLboolean read_only = (access == GL_READ_ONLY_ARB); + GLboolean write_only = (access == GL_WRITE_ONLY_ARB); assert(intel_obj); @@ -216,7 +217,14 @@ intel_bufferobj_map(GLcontext * ctx, return NULL; } - dri_bo_map(intel_obj->buffer, !read_only); + if (write_only && intel->intelScreen->kernel_exec_fencing) { + drm_intel_gem_bo_map_gtt(intel_obj->buffer); + intel_obj->mapped_gtt = GL_TRUE; + } else { + drm_intel_bo_map(intel_obj->buffer, !read_only); + intel_obj->mapped_gtt = GL_FALSE; + } + obj->Pointer = intel_obj->buffer->virtual; return obj->Pointer; } @@ -234,7 +242,11 @@ intel_bufferobj_unmap(GLcontext * ctx, assert(intel_obj); if (intel_obj->buffer != NULL) { assert(obj->Pointer); - dri_bo_unmap(intel_obj->buffer); + if (intel_obj->mapped_gtt) { + drm_intel_gem_bo_unmap_gtt(intel_obj->buffer); + } else { + drm_intel_bo_unmap(intel_obj->buffer); + } obj->Pointer = NULL; } return GL_TRUE; diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.h b/src/mesa/drivers/dri/intel/intel_buffer_objects.h index bf6dbd58f2..7ef723833c 100644 --- a/src/mesa/drivers/dri/intel/intel_buffer_objects.h +++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.h @@ -46,6 +46,7 @@ struct intel_buffer_object struct intel_region *region; /* Is there a zero-copy texture associated with this (pixel) buffer object? */ + GLboolean mapped_gtt; }; -- cgit v1.2.3 From 61a2c9668fd59dc301c2b61d46b48c974d0f0109 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 10 May 2009 10:08:32 -0700 Subject: intel: Skip the DRI2 renderbuffer update when doing Viewport on an FBO. (cherry picked from commit d4a42b0ce6455d03be70aa56aacd779be193aca4) --- src/mesa/drivers/dri/intel/intel_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 5dc3df395d..bff0b05475 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -394,7 +394,7 @@ intel_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) if (!driContext->driScreenPriv->dri2.enabled) return; - if (!intel->internal_viewport_call) { + if (!intel->internal_viewport_call && ctx->DrawBuffer->Name == 0) { intel_update_renderbuffers(driContext, driContext->driDrawablePriv); if (driContext->driDrawablePriv != driContext->driReadablePriv) intel_update_renderbuffers(driContext, driContext->driReadablePriv); -- cgit v1.2.3 From d9e35d51fd9bb5d67865a451d16cf61c66f16a11 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 13 May 2009 18:18:29 -0700 Subject: intel: Use GL_FRONT_AND_BACK for stencil clearing. This comes from a radeon-rewrite fallback fix, but may also fix stencil clear failure when the polygon winding mode is flipped. (cherry picked from commit d866abeffc7e4a29736fa35fb8ac09c3a28a44d6) --- src/mesa/drivers/dri/intel/intel_clear.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/intel/intel_clear.c b/src/mesa/drivers/dri/intel/intel_clear.c index eb0d890f47..488db2cf45 100644 --- a/src/mesa/drivers/dri/intel/intel_clear.c +++ b/src/mesa/drivers/dri/intel/intel_clear.c @@ -256,7 +256,8 @@ intel_clear_tris(GLcontext *ctx, GLbitfield mask) if (this_mask & BUFFER_BIT_STENCIL) { _mesa_Enable(GL_STENCIL_TEST); _mesa_StencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); - _mesa_StencilFuncSeparate(GL_FRONT, GL_ALWAYS, ctx->Stencil.Clear, + _mesa_StencilFuncSeparate(GL_FRONT_AND_BACK, GL_ALWAYS, + ctx->Stencil.Clear, ctx->Stencil.WriteMask[0]); } else { _mesa_Disable(GL_STENCIL_TEST); -- cgit v1.2.3 From 320a303be0805b5746f357653cf09ad9d7f0e8bc Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 13 May 2009 19:08:17 -0700 Subject: intel: Use FRONT_AND_BACK for StencilOp as well. (cherry picked from commit 64980125c76b05501a6fe7fe20fe52438f459129) --- src/mesa/drivers/dri/intel/intel_clear.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/intel/intel_clear.c b/src/mesa/drivers/dri/intel/intel_clear.c index 488db2cf45..4dfaee8a4a 100644 --- a/src/mesa/drivers/dri/intel/intel_clear.c +++ b/src/mesa/drivers/dri/intel/intel_clear.c @@ -255,7 +255,8 @@ intel_clear_tris(GLcontext *ctx, GLbitfield mask) /* Control writing of the stencil clear value to stencil. */ if (this_mask & BUFFER_BIT_STENCIL) { _mesa_Enable(GL_STENCIL_TEST); - _mesa_StencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); + _mesa_StencilOpSeparate(GL_FRONT_AND_BACK, + GL_REPLACE, GL_REPLACE, GL_REPLACE); _mesa_StencilFuncSeparate(GL_FRONT_AND_BACK, GL_ALWAYS, ctx->Stencil.Clear, ctx->Stencil.WriteMask[0]); -- cgit v1.2.3 From 988b61be2743de6850c8042516db28d14ee3002f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 14 May 2009 09:49:45 -0700 Subject: i965: Fix register allocation of GLSL fp inputs. Before, if the VP output something that is in the attributes coming into the WM but which isn't used by the WM, then WM would end up reading subsequent varyings from the wrong places. This was visible with a GLSL demo using gl_PointSize in the VS and a varying in the WM, as point size is in the VUE but not used by the WM. There is now a regression test in piglit, glsl-unused-varying. (cherry picked from commit 0f5113deed91611ecdda6596542530b1849bb161) --- src/mesa/drivers/dri/i965/brw_wm.c | 5 ++++- src/mesa/drivers/dri/i965/brw_wm.h | 1 + src/mesa/drivers/dri/i965/brw_wm_glsl.c | 31 +++++++++++++++++++++---------- src/mesa/drivers/dri/i965/brw_wm_pass2.c | 3 +-- 4 files changed, 27 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index c0b07da63b..bd296aa2a7 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.c +++ b/src/mesa/drivers/dri/i965/brw_wm.c @@ -312,6 +312,9 @@ static void brw_wm_populate_key( struct brw_context *brw, key->drawable_height = brw->intel.driDrawable->h; } + /* CACHE_NEW_VS_PROG */ + key->vp_outputs_written = brw->vs.prog_data->outputs_written & DO_SETUP_BITS; + /* The unique fragment program ID */ key->program_string_id = fp->id; } @@ -350,7 +353,7 @@ const struct brw_tracked_state brw_wm_prog = { .brw = (BRW_NEW_FRAGMENT_PROGRAM | BRW_NEW_WM_INPUT_DIMENSIONS | BRW_NEW_REDUCED_PRIMITIVE), - .cache = 0 + .cache = CACHE_NEW_VS_PROG, }, .prepare = brw_prepare_wm_prog }; diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h index 0408034c38..295fed851b 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.h +++ b/src/mesa/drivers/dri/i965/brw_wm.h @@ -75,6 +75,7 @@ struct brw_wm_prog_key { GLuint program_string_id:32; GLuint origin_x, origin_y; GLuint drawable_height; + GLuint vp_outputs_written; }; diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c index 117460842a..875683e0aa 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c +++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c @@ -177,7 +177,7 @@ static void prealloc_reg(struct brw_wm_compile *c) { int i, j; struct brw_reg reg; - int nr_interp_regs = 0; + int urb_read_length = 0; GLuint inputs = FRAG_BIT_WPOS | c->fp_interp_emitted | c->fp_deriv_emitted; for (i = 0; i < 4; i++) { @@ -231,18 +231,29 @@ static void prealloc_reg(struct brw_wm_compile *c) } /* fragment shader inputs */ - for (i = 0; i < FRAG_ATTRIB_MAX; i++) { - if (inputs & (1<reg_index, 0); - for (j = 0; j < 4; j++) - set_reg(c, PROGRAM_PAYLOAD, i, j, reg); - c->reg_index += 2; - } + for (i = 0; i < VERT_RESULT_MAX; i++) { + int fp_input; + + if (i >= VERT_RESULT_VAR0) + fp_input = i - VERT_RESULT_VAR0 + FRAG_ATTRIB_VAR0; + else if (i <= VERT_RESULT_TEX7) + fp_input = i; + else + fp_input = -1; + + if (fp_input >= 0 && inputs & (1 << fp_input)) { + urb_read_length = c->reg_index; + reg = brw_vec8_grf(c->reg_index, 0); + for (j = 0; j < 4; j++) + set_reg(c, PROGRAM_PAYLOAD, fp_input, j, reg); + } + if (c->key.vp_outputs_written & (1 << i)) { + c->reg_index += 2; + } } c->prog_data.first_curbe_grf = c->key.nr_depth_regs * 2; - c->prog_data.urb_read_length = nr_interp_regs * 2; + c->prog_data.urb_read_length = urb_read_length; c->prog_data.curb_read_length = c->nr_creg; c->emit_mask_reg = brw_uw1_reg(BRW_GENERAL_REGISTER_FILE, c->reg_index, 0); c->reg_index++; diff --git a/src/mesa/drivers/dri/i965/brw_wm_pass2.c b/src/mesa/drivers/dri/i965/brw_wm_pass2.c index 780edbc42e..08cac730c2 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_pass2.c +++ b/src/mesa/drivers/dri/i965/brw_wm_pass2.c @@ -70,7 +70,6 @@ static void prealloc_reg(struct brw_wm_compile *c, static void init_registers( struct brw_wm_compile *c ) { struct brw_context *brw = c->func.brw; - GLuint inputs = (brw->vs.prog_data->outputs_written & DO_SETUP_BITS); GLuint nr_interp_regs = 0; GLuint i = 0; GLuint j; @@ -85,7 +84,7 @@ static void init_registers( struct brw_wm_compile *c ) prealloc_reg(c, &c->creg[j], i++); for (j = 0; j < FRAG_ATTRIB_MAX; j++) { - if (inputs & (1<key.vp_outputs_written & (1< Date: Thu, 14 May 2009 10:56:32 -0700 Subject: i965: Fix varying payload reg assignment for the non-GLSL-instructions path. I don't have a testcase for this, but it seems clearly wrong. (cherry picked from commit dc657f3929fbe03275b3fae4ef84f02e74b51114) --- src/mesa/drivers/dri/i965/brw_wm_pass2.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_wm_pass2.c b/src/mesa/drivers/dri/i965/brw_wm_pass2.c index 08cac730c2..6faea018fb 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_pass2.c +++ b/src/mesa/drivers/dri/i965/brw_wm_pass2.c @@ -69,7 +69,6 @@ static void prealloc_reg(struct brw_wm_compile *c, */ static void init_registers( struct brw_wm_compile *c ) { - struct brw_context *brw = c->func.brw; GLuint nr_interp_regs = 0; GLuint i = 0; GLuint j; @@ -85,15 +84,18 @@ static void init_registers( struct brw_wm_compile *c ) for (j = 0; j < FRAG_ATTRIB_MAX; j++) { if (c->key.vp_outputs_written & (1< FRAG_ATTRIB_VAR0) - index = j - (VERT_RESULT_VAR0 - FRAG_ATTRIB_VAR0); + int fp_index; + + if (j >= VERT_RESULT_VAR0) + fp_index = j - (VERT_RESULT_VAR0 - FRAG_ATTRIB_VAR0); + else if (j <= VERT_RESULT_TEX7) + fp_index = j; else - index = j; + fp_index = -1; + nr_interp_regs++; - prealloc_reg(c, &c->payload.input_interp[index], i++); + if (fp_index >= 0) + prealloc_reg(c, &c->payload.input_interp[fp_index], i++); } } -- cgit v1.2.3 From fbd554d07456cf393a20cb86d1c0e81c416843aa Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 15 May 2009 11:41:42 -0700 Subject: i915: Only use the new 945 cube layout for compressed textures. The docs actually explain this, but not in a terribly clear manner. This nearly fixes the piglit cubemap testcase, except that something's going wrong with the nearest filtering at 2x2 sizes in the testcase. Looks good by visual inspection, though. Bug #21692 (cherry picked from commit 5c5a46884899ea25cdf25545d6ab3d9a74eafa3a) --- src/mesa/drivers/dri/i915/i915_tex_layout.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915/i915_tex_layout.c b/src/mesa/drivers/dri/i915/i915_tex_layout.c index d44a2f47b3..7cc1c096e4 100644 --- a/src/mesa/drivers/dri/i915/i915_tex_layout.c +++ b/src/mesa/drivers/dri/i915/i915_tex_layout.c @@ -454,7 +454,10 @@ i945_miptree_layout(struct intel_context *intel, struct intel_mipmap_tree * mt) { switch (mt->target) { case GL_TEXTURE_CUBE_MAP: - i945_miptree_layout_cube(intel, mt); + if (mt->compressed) + i945_miptree_layout_cube(intel, mt); + else + i915_miptree_layout_cube(intel, mt); break; case GL_TEXTURE_3D: i945_miptree_layout_3d(intel, mt); -- cgit v1.2.3 From 66bfd025c84ca6d4fb73f394adcdd41418ab6b25 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 15 May 2009 12:32:51 -0700 Subject: i915: Use Stencil.Enabled instead of Stencil._Enabled in DrawBuffers. The _Enabled field isn't updated at the point that DrawBuffers is called, and the Driver.Enable() function does the testing for stencil buffer presence anyway. bug #21608 for Radeon (cherry picked from commit 4c6f82989983eecc0b3b724716cb3bcb675664c5) --- src/mesa/drivers/dri/intel/intel_buffers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/intel/intel_buffers.c b/src/mesa/drivers/dri/intel/intel_buffers.c index b86cafea24..d2fad9e4ea 100644 --- a/src/mesa/drivers/dri/intel/intel_buffers.c +++ b/src/mesa/drivers/dri/intel/intel_buffers.c @@ -276,7 +276,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) ctx->Driver.Enable(ctx, GL_DEPTH_TEST, (ctx->Depth.Test && fb->Visual.depthBits > 0)); ctx->Driver.Enable(ctx, GL_STENCIL_TEST, - (ctx->Stencil._Enabled && fb->Visual.stencilBits > 0)); + (ctx->Stencil.Enabled && fb->Visual.stencilBits > 0)); } else { /* Mesa's Stencil._Enabled field is updated when -- cgit v1.2.3 From 957f3c8c3d3b6a48bbcc24e9db2c110a7fde177b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 15 May 2009 16:24:59 -0700 Subject: mesa: Mark FBOs with compressed color attachments as FBO-incomplete. Both EXT_fbo and ARB_fbo agree on this. Fixes a segfault in the metaops mipmap generation in Intel for SGIS_generate_mipmap of S3TC textures in Regnum Online. Bug #21654. (cherry picked from commit 0307e609aa3e707eeb40051bd664d36f2340ba9b) --- src/mesa/main/fbobject.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index e8e8c2bf30..83301f1e62 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -368,6 +368,11 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format, att->Complete = GL_FALSE; return; } + if (texImage->TexFormat->TexelBytes == 0) { + att_incomplete("compressed internalformat"); + att->Complete = GL_FALSE; + return; + } } else if (format == GL_DEPTH) { if (texImage->TexFormat->BaseFormat == GL_DEPTH_COMPONENT) { -- cgit v1.2.3 From 97974b7e5198eb480c0e86474ee177821c462d45 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 15 May 2009 17:32:21 -0700 Subject: intel: Don't complain on falling back from PBO fastpaths. Instead, stash the debug info under the handy debug flag. Bug #20053 (cherry picked from commit 22690482e692cb5ed2f84d3e69545c09292e3484) --- src/mesa/drivers/dri/intel/intel_tex_image.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c index 1f192dafbe..66a3b4e492 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_image.c +++ b/src/mesa/drivers/dri/intel/intel_tex_image.c @@ -208,7 +208,7 @@ try_pbo_upload(struct intel_context *intel, if (!pbo || intel->ctx._ImageTransferState || unpack->SkipPixels || unpack->SkipRows) { - _mesa_printf("%s: failure 1\n", __FUNCTION__); + DBG("%s: failure 1\n", __FUNCTION__); return GL_FALSE; } @@ -264,7 +264,7 @@ try_pbo_zcopy(struct intel_context *intel, if (!pbo || intel->ctx._ImageTransferState || unpack->SkipPixels || unpack->SkipRows) { - _mesa_printf("%s: failure 1\n", __FUNCTION__); + DBG("%s: failure 1\n", __FUNCTION__); return GL_FALSE; } @@ -283,7 +283,7 @@ try_pbo_zcopy(struct intel_context *intel, dst_stride = intelImage->mt->pitch; if (src_stride != dst_stride || dst_offset != 0 || src_offset != 0) { - _mesa_printf("%s: failure 2\n", __FUNCTION__); + DBG("%s: failure 2\n", __FUNCTION__); return GL_FALSE; } -- cgit v1.2.3 From 7805c3b57b558dac7a92d97b6a2210e037aea792 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 20 May 2009 15:59:07 -0700 Subject: i956: Make state dependency of SF on drawbuffer bounds match Mesa's. Noticed while debugging a weird 1D FBO testcase that left its existing viewport and projection matrix in place when switching drawbuffers. Didn't fix the testcase, though. (cherry picked from commit 3a521d84ecc646fcc65fa3fe7c5f1fdbdebe8bc2) --- src/mesa/drivers/dri/i965/brw_sf_state.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c b/src/mesa/drivers/dri/i965/brw_sf_state.c index 68fa9820b6..c99918724b 100644 --- a/src/mesa/drivers/dri/i965/brw_sf_state.c +++ b/src/mesa/drivers/dri/i965/brw_sf_state.c @@ -66,7 +66,9 @@ static void upload_sf_vp(struct brw_context *brw) sfv.viewport.m31 = v[MAT_TY] * y_scale + y_bias; sfv.viewport.m32 = v[MAT_TZ] * depth_scale; - /* _NEW_SCISSOR */ + /* _NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT + * for DrawBuffer->_[XY]{min,max} + */ /* The scissor only needs to handle the intersection of drawable and * scissor rect. Clipping to the boundaries of static shared buffers @@ -97,7 +99,8 @@ static void upload_sf_vp(struct brw_context *brw) const struct brw_tracked_state brw_sf_vp = { .dirty = { .mesa = (_NEW_VIEWPORT | - _NEW_SCISSOR), + _NEW_SCISSOR | + _NEW_BUFFERS), .brw = 0, .cache = 0 }, -- cgit v1.2.3 From cee73ffdaf3a73f54593010dc1cbc77610ba3224 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 26 May 2009 19:48:08 -0700 Subject: i915: Restore the Viewport and DepthRange functions on 8xx. Fixes failed viewport updates on glxgears (and other apps) resize since e41780fedc2c1f22b43118da30a0103fa68b769f. Bug #20473. (cherry picked from commit 0e83e8f51af07a3066519f169f07d9afbf23252e) --- src/mesa/drivers/dri/i915/i830_state.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915/i830_state.c b/src/mesa/drivers/dri/i915/i830_state.c index d9cad0c4bf..8ef6c9144f 100644 --- a/src/mesa/drivers/dri/i915/i830_state.c +++ b/src/mesa/drivers/dri/i915/i830_state.c @@ -39,6 +39,7 @@ #include "intel_screen.h" #include "intel_batchbuffer.h" #include "intel_fbo.h" +#include "intel_buffers.h" #include "i830_context.h" #include "i830_reg.h" @@ -446,6 +447,24 @@ i830DepthMask(GLcontext * ctx, GLboolean flag) i830->state.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_DEPTH_WRITE; } +/** Called from ctx->Driver.Viewport() */ +static void +i830Viewport(GLcontext * ctx, + GLint x, GLint y, GLsizei width, GLsizei height) +{ + intelCalcViewport(ctx); + + intel_viewport(ctx, x, y, width, height); +} + + +/** Called from ctx->Driver.DepthRange() */ +static void +i830DepthRange(GLcontext * ctx, GLclampd nearval, GLclampd farval) +{ + intelCalcViewport(ctx); +} + /* ============================================================= * Polygon stipple * @@ -1064,6 +1083,8 @@ i830InitStateFuncs(struct dd_function_table *functions) functions->StencilFuncSeparate = i830StencilFuncSeparate; functions->StencilMaskSeparate = i830StencilMaskSeparate; functions->StencilOpSeparate = i830StencilOpSeparate; + functions->DepthRange = i830DepthRange; + functions->Viewport = i830Viewport; } void -- cgit v1.2.3 From 1b8e4dd2c8343af391a33be2aff7978366c450df Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 26 May 2009 20:45:29 -0700 Subject: i915: Fall back on NPOT textured metaops on 830-class. (cherry picked from commit 8ec6e036792decf5149a209e51cb5e93ccc5c754) --- src/mesa/drivers/dri/intel/intel_context.h | 6 ++++++ src/mesa/drivers/dri/intel/intel_pixel_bitmap.c | 8 ++++++++ src/mesa/drivers/dri/intel/intel_pixel_draw.c | 16 ++++++++++++++++ 3 files changed, 30 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h index f45e24ca3a..b5cf7e6648 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++ b/src/mesa/drivers/dri/intel/intel_context.h @@ -559,4 +559,10 @@ intel_context(GLcontext * ctx) return (struct intel_context *) ctx; } +static INLINE GLboolean +is_power_of_two(uint32_t value) +{ + return (value & (value - 1)) == 0; +} + #endif diff --git a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c index 1db7f5594e..69e619ac4a 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c @@ -401,6 +401,14 @@ intel_texture_bitmap(GLcontext * ctx, return GL_FALSE; } + if (!ctx->Extensions.ARB_texture_non_power_of_two && + (!is_power_of_two(width) || !is_power_of_two(height))) { + if (INTEL_DEBUG & DEBUG_FALLBACKS) + fprintf(stderr, + "glBitmap() fallback: NPOT texture\n"); + return GL_FALSE; + } + /* Check that we can load in a texture this big. */ if (width > (1 << (ctx->Const.MaxTextureLevels - 1)) || height > (1 << (ctx->Const.MaxTextureLevels - 1))) { diff --git a/src/mesa/drivers/dri/intel/intel_pixel_draw.c b/src/mesa/drivers/dri/intel/intel_pixel_draw.c index e8d5ac8569..2706ca327f 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_draw.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_draw.c @@ -120,6 +120,14 @@ intel_texture_drawpixels(GLcontext * ctx, return GL_FALSE; } + if (!ctx->Extensions.ARB_texture_non_power_of_two && + (!is_power_of_two(width) || !is_power_of_two(height))) { + if (INTEL_DEBUG & DEBUG_FALLBACKS) + fprintf(stderr, + "glDrawPixels() fallback: NPOT texture\n"); + return GL_FALSE; + } + _mesa_PushAttrib(GL_ENABLE_BIT | GL_TEXTURE_BIT | GL_CURRENT_BIT); _mesa_PushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT); @@ -273,6 +281,14 @@ intel_stencil_drawpixels(GLcontext * ctx, return GL_FALSE; } + if (!ctx->Extensions.ARB_texture_non_power_of_two && + (!is_power_of_two(width) || !is_power_of_two(height))) { + if (INTEL_DEBUG & DEBUG_FALLBACKS) + fprintf(stderr, + "glDrawPixels(GL_STENCIL_INDEX) fallback: NPOT texture\n"); + return GL_FALSE; + } + _mesa_PushAttrib(GL_ENABLE_BIT | GL_TEXTURE_BIT | GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); _mesa_PushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT); -- cgit v1.2.3 From ff3da0966fc91cd5bcfed994e5edadbf25903c47 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 2 Jun 2009 06:53:40 -0700 Subject: i915: Don't put VBOs in graphics memory unless required for an operation. This saves doing swtnl from uncached memory, which is painful. Improves clutter test-text performance by 10% since it started using VBOs. (cherry picked from commit a945e203d4fe254593bc0c5c5d6caca45e65f9f7) --- src/mesa/drivers/dri/intel/intel_buffer_objects.c | 39 ++++++++++++++++++++++- src/mesa/drivers/dri/intel/intel_buffer_objects.h | 2 ++ 2 files changed, 40 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c b/src/mesa/drivers/dri/intel/intel_buffer_objects.c index 1b64c68157..c31fe91ad6 100644 --- a/src/mesa/drivers/dri/intel/intel_buffer_objects.c +++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.c @@ -102,6 +102,7 @@ intel_bufferobj_free(GLcontext * ctx, struct gl_buffer_object *obj) assert(intel_obj); assert(!obj->Pointer); /* Mesa should have unmapped it */ + _mesa_free(intel_obj->sys_buffer); if (intel_obj->region) { intel_bufferobj_release_region(intel, intel_obj); } @@ -142,7 +143,23 @@ intel_bufferobj_data(GLcontext * ctx, dri_bo_unreference(intel_obj->buffer); intel_obj->buffer = NULL; } + _mesa_free(intel_obj->sys_buffer); + intel_obj->sys_buffer = NULL; + if (size != 0) { +#ifdef I915 + /* On pre-965, stick VBOs in system memory, as we're always doing swtnl + * with their contents anyway. + */ + if (target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER) { + intel_obj->sys_buffer = _mesa_malloc(size); + if (intel_obj->sys_buffer != NULL) { + if (data != NULL) + memcpy(intel_obj->sys_buffer, data, size); + return; + } + } +#endif intel_bufferobj_alloc_buffer(intel, intel_obj); if (data != NULL) @@ -172,7 +189,10 @@ intel_bufferobj_subdata(GLcontext * ctx, if (intel_obj->region) intel_bufferobj_cow(intel, intel_obj); - dri_bo_subdata(intel_obj->buffer, offset, size, data); + if (intel_obj->sys_buffer) + memcpy((char *)intel_obj->sys_buffer + offset, data, size); + else + dri_bo_subdata(intel_obj->buffer, offset, size, data); } @@ -209,6 +229,11 @@ intel_bufferobj_map(GLcontext * ctx, assert(intel_obj); + if (intel_obj->sys_buffer) { + obj->Pointer = intel_obj->sys_buffer; + return obj->Pointer; + } + if (intel_obj->region) intel_bufferobj_cow(intel, intel_obj); @@ -265,6 +290,18 @@ intel_bufferobj_buffer(struct intel_context *intel, } } + if (intel_obj->buffer == NULL) { + intel_bufferobj_alloc_buffer(intel, intel_obj); + intel_bufferobj_subdata(&intel->ctx, + GL_ARRAY_BUFFER_ARB, + 0, + intel_obj->Base.Size, + intel_obj->sys_buffer, + &intel_obj->Base); + _mesa_free(intel_obj->sys_buffer); + intel_obj->sys_buffer = NULL; + } + return intel_obj->buffer; } diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.h b/src/mesa/drivers/dri/intel/intel_buffer_objects.h index 7ef723833c..0431015631 100644 --- a/src/mesa/drivers/dri/intel/intel_buffer_objects.h +++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.h @@ -42,6 +42,8 @@ struct intel_buffer_object { struct gl_buffer_object Base; dri_bo *buffer; /* the low-level buffer manager's buffer handle */ + /** System memory buffer data, if not using a BO to store the data. */ + void *sys_buffer; struct intel_region *region; /* Is there a zero-copy texture associated with this (pixel) -- cgit v1.2.3 From a70c45bdabd8a172de6c50167b3e9d99649db1fa Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 3 Jun 2009 17:49:05 +0100 Subject: Fast path when rebinding the same texture in single context environment If there is no shared context, there is no purpose in rebinding the same texture. In some artificial tests this improves performance 10% - 30%. (cherry picked from commit 7f8000db8bd45bb95bda4a4f8535c49b8ef74254) --- src/mesa/main/texobj.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index b63f747fe8..9b8d3777fb 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -891,6 +891,7 @@ _mesa_BindTexture( GLenum target, GLuint texName ) struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; struct gl_texture_object *newTexObj = NULL, *defaultTexObj = NULL; GLint targetIndex; + GLboolean early_out = GL_FALSE; ASSERT_OUTSIDE_BEGIN_END(ctx); if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) @@ -944,6 +945,17 @@ _mesa_BindTexture( GLenum target, GLuint texName ) assert(valid_texture_object(newTexObj)); + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + if ((ctx->Shared->RefCount == 1) + && (newTexObj == texUnit->CurrentTex[targetIndex])) { + early_out = GL_TRUE; + } + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + + if (early_out) { + return; + } + /* flush before changing binding */ FLUSH_VERTICES(ctx, _NEW_TEXTURE); -- cgit v1.2.3 From e15aebe10e20aacce63175b68ec8daa5c1dc4e0c Mon Sep 17 00:00:00 2001 From: Robert Ellison Date: Fri, 8 May 2009 14:40:38 -0600 Subject: i965: fix segfault on low memory conditions When out of memory (in at least one case, triggered by a longrunning memory leak), this code will segfault and crash. By checking for the out-of-memory condition, the system can continue, and will report the out-of-memory error later, a much preferable outcome. (cherry picked from commit 44a4abfd4f8695809eaec07df8eeb191d6e017d7) --- src/mesa/drivers/dri/i965/brw_wm.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index bd296aa2a7..8a3b7df9c7 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.c +++ b/src/mesa/drivers/dri/i965/brw_wm.c @@ -146,6 +146,13 @@ static void do_wm_prog( struct brw_context *brw, if (c == NULL) { brw->wm.compile_data = calloc(1, sizeof(*brw->wm.compile_data)); c = brw->wm.compile_data; + if (c == NULL) { + /* Ouch - big out of memory problem. Can't continue + * without triggering a segfault, no way to signal, + * so just return. + */ + return; + } } else { memset(c, 0, sizeof(*brw->wm.compile_data)); } -- cgit v1.2.3 From 56235ae5049bee929c83f6932db077afaa5930f8 Mon Sep 17 00:00:00 2001 From: Robert Ellison Date: Wed, 13 May 2009 20:38:33 -0600 Subject: i965: send all warnings through _mesa_warning() One warning message: drm_i915_getparam: -22 was still being sent to fprintf(). This causes all Piglit tests to fail, even with MESA_DEBUG=0. Using _mesa_warning() to emit the message allows the general Mesa controls for messages like this to be applied. (cherry picked from commit bc3270e99f5c39544aaf831742db14796ab83a6a) --- src/mesa/drivers/dri/intel/intel_screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index 50cb13a482..0b48563776 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -236,7 +236,7 @@ intel_get_param(__DRIscreenPrivate *psp, int param, int *value) ret = drmCommandWriteRead(psp->fd, DRM_I915_GETPARAM, &gp, sizeof(gp)); if (ret) { - fprintf(stderr, "drm_i915_getparam: %d\n", ret); + _mesa_warning(NULL, "drm_i915_getparam: %d\n", ret); return GL_FALSE; } -- cgit v1.2.3 From d446d3acacdffa7c0f744764214b2bea5e191678 Mon Sep 17 00:00:00 2001 From: Robert Ellison Date: Wed, 13 May 2009 20:40:23 -0600 Subject: i965: fix 1D texture borders with GL_CLAMP_TO_BORDER With 1D textures, GL_TEXTURE_WRAP_T should be ignored (only GL_TEXTURE_WRAP_S should be respected). But the i965 hardware seems to follow the value of GL_TEXTURE_WRAP_T even when sampling 1D textures. This fix forces GL_TEXTURE_WRAP_T to be GL_REPEAT whenever 1D textures are used; this allows the texture to be sampled correctly, avoiding "imaginary" border elements in the T direction. This bug was demonstrated in the Piglit tex1d-2dborder test. With this fix, that test passes. (cherry picked from commit ab6c4fa582972e25f8800c77b5dd5b3a83afc996) --- src/mesa/drivers/dri/i965/brw_wm_sampler_state.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c index c604ef0162..3fc18ff1f3 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c @@ -178,6 +178,16 @@ static void brw_update_sampler_state(struct wm_sampler_entry *key, sampler->ss1.s_wrap_mode = BRW_TEXCOORDMODE_CUBE; sampler->ss1.t_wrap_mode = BRW_TEXCOORDMODE_CUBE; } + else if (key->tex_target == GL_TEXTURE_1D) { + /* There's a bug in 1D texture sampling - it actually pays + * attention to the wrap_t value, though it should not. + * Override the wrap_t value here to GL_REPEAT to keep + * any nonexistent border pixels from floating in. + */ + sampler->ss1.r_wrap_mode = translate_wrap_mode(key->wrap_r); + sampler->ss1.s_wrap_mode = translate_wrap_mode(key->wrap_s); + sampler->ss1.t_wrap_mode = BRW_TEXCOORDMODE_WRAP; + } else { sampler->ss1.r_wrap_mode = translate_wrap_mode(key->wrap_r); sampler->ss1.s_wrap_mode = translate_wrap_mode(key->wrap_s); -- cgit v1.2.3 From 39366ed995310c95d95e0c7a33fb0bec637a00b6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 8 Jun 2009 14:41:54 -0600 Subject: intel: remove extra \n from warning string (cherry picked from commit 42e9bde0fa2276b8f5bb434328eea7665794b127) --- src/mesa/drivers/dri/intel/intel_screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index 0b48563776..0f278b3acd 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -236,7 +236,7 @@ intel_get_param(__DRIscreenPrivate *psp, int param, int *value) ret = drmCommandWriteRead(psp->fd, DRM_I915_GETPARAM, &gp, sizeof(gp)); if (ret) { - _mesa_warning(NULL, "drm_i915_getparam: %d\n", ret); + _mesa_warning(NULL, "drm_i915_getparam: %d", ret); return GL_FALSE; } -- cgit v1.2.3 From 0491142152dcc61ebe0b46b05c94957e54c44bd9 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 11 Jun 2009 10:52:37 +0100 Subject: mesa: protect Elements against multiple definitions Mesa and gallium both have a definition of this macro --- src/mesa/main/compiler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h index 93103fe878..e79bbc2ac5 100644 --- a/src/mesa/main/compiler.h +++ b/src/mesa/main/compiler.h @@ -468,9 +468,9 @@ do { \ #endif - +#ifndef Elements #define Elements(x) (sizeof(x)/sizeof(*(x))) - +#endif -- cgit v1.2.3 From 1b05b5b4fecd9ac8ef34abdda6c085868016ad84 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 18 Jun 2009 10:13:55 +0100 Subject: glew: correct misspelling of glFramebufferTextureLayer This was misspelt as glFramebufferTexturLayer (missing e), causing conflicts with the correctly spelt version in glext.h and extfuncs.h. --- include/GL/glew.h | 6 +++--- src/glew/glew.c | 4 ++-- src/glew/glewinfo.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/include/GL/glew.h b/include/GL/glew.h index 2014092e87..7932a1ce19 100644 --- a/include/GL/glew.h +++ b/include/GL/glew.h @@ -2702,7 +2702,7 @@ typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint* framebuffers); typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint* renderbuffers); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURLAYERPROC) (GLenum target,GLenum attachment, GLuint texture,GLint level,GLint layer); +typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target,GLenum attachment, GLuint texture,GLint level,GLint layer); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer); @@ -2723,7 +2723,7 @@ typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum targ #define glDeleteFramebuffers GLEW_GET_FUN(__glewDeleteFramebuffers) #define glDeleteRenderbuffers GLEW_GET_FUN(__glewDeleteRenderbuffers) #define glFramebufferRenderbuffer GLEW_GET_FUN(__glewFramebufferRenderbuffer) -#define glFramebufferTexturLayer GLEW_GET_FUN(__glewFramebufferTexturLayer) +#define glFramebufferTextureLayer GLEW_GET_FUN(__glewFramebufferTextureLayer) #define glFramebufferTexture1D GLEW_GET_FUN(__glewFramebufferTexture1D) #define glFramebufferTexture2D GLEW_GET_FUN(__glewFramebufferTexture2D) #define glFramebufferTexture3D GLEW_GET_FUN(__glewFramebufferTexture3D) @@ -10563,7 +10563,7 @@ GLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSPROC __glewCheckFramebufferStatus; GLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSPROC __glewDeleteFramebuffers; GLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSPROC __glewDeleteRenderbuffers; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFERPROC __glewFramebufferRenderbuffer; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURLAYERPROC __glewFramebufferTexturLayer; +GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYERPROC __glewFramebufferTextureLayer; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DPROC __glewFramebufferTexture1D; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DPROC __glewFramebufferTexture2D; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DPROC __glewFramebufferTexture3D; diff --git a/src/glew/glew.c b/src/glew/glew.c index 24c6a726c3..aa2278f6c0 100644 --- a/src/glew/glew.c +++ b/src/glew/glew.c @@ -547,7 +547,7 @@ PFNGLCHECKFRAMEBUFFERSTATUSPROC __glewCheckFramebufferStatus = NULL; PFNGLDELETEFRAMEBUFFERSPROC __glewDeleteFramebuffers = NULL; PFNGLDELETERENDERBUFFERSPROC __glewDeleteRenderbuffers = NULL; PFNGLFRAMEBUFFERRENDERBUFFERPROC __glewFramebufferRenderbuffer = NULL; -PFNGLFRAMEBUFFERTEXTURLAYERPROC __glewFramebufferTexturLayer = NULL; +PFNGLFRAMEBUFFERTEXTURELAYERPROC __glewFramebufferTextureLayer = NULL; PFNGLFRAMEBUFFERTEXTURE1DPROC __glewFramebufferTexture1D = NULL; PFNGLFRAMEBUFFERTEXTURE2DPROC __glewFramebufferTexture2D = NULL; PFNGLFRAMEBUFFERTEXTURE3DPROC __glewFramebufferTexture3D = NULL; @@ -2739,7 +2739,7 @@ static GLboolean _glewInit_GL_ARB_framebuffer_object (GLEW_CONTEXT_ARG_DEF_INIT) r = ((glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glDeleteFramebuffers")) == NULL) || r; r = ((glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glDeleteRenderbuffers")) == NULL) || r; r = ((glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)glewGetProcAddress((const GLubyte*)"glFramebufferRenderbuffer")) == NULL) || r; - r = ((glFramebufferTexturLayer = (PFNGLFRAMEBUFFERTEXTURLAYERPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexturLayer")) == NULL) || r; + r = ((glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureLayer")) == NULL) || r; r = ((glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture1D")) == NULL) || r; r = ((glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture2D")) == NULL) || r; r = ((glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture3D")) == NULL) || r; diff --git a/src/glew/glewinfo.c b/src/glew/glewinfo.c index 13c6d05bd1..da2b241dea 100644 --- a/src/glew/glewinfo.c +++ b/src/glew/glewinfo.c @@ -708,7 +708,7 @@ static void _glewInfo_GL_ARB_framebuffer_object (void) glewInfoFunc("glDeleteFramebuffers", glDeleteFramebuffers == NULL); glewInfoFunc("glDeleteRenderbuffers", glDeleteRenderbuffers == NULL); glewInfoFunc("glFramebufferRenderbuffer", glFramebufferRenderbuffer == NULL); - glewInfoFunc("glFramebufferTexturLayer", glFramebufferTexturLayer == NULL); + glewInfoFunc("glFramebufferTextureLayer", glFramebufferTextureLayer == NULL); glewInfoFunc("glFramebufferTexture1D", glFramebufferTexture1D == NULL); glewInfoFunc("glFramebufferTexture2D", glFramebufferTexture2D == NULL); glewInfoFunc("glFramebufferTexture3D", glFramebufferTexture3D == NULL); -- cgit v1.2.3 From 4b4855c717e839a9ee6353604558543473c020c9 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 17 Jun 2009 19:24:51 +0100 Subject: wgl: Move all thread related code together. Not only for cosmetic reasons, but also because we need to set the SetWindowsHookEx hook for threads created before the DllMain is called (threads for each we don't get the DLL_THREAD_ATTACH notification). --- src/gallium/state_trackers/wgl/shared/stw_device.c | 9 +----- .../state_trackers/wgl/shared/stw_framebuffer.c | 37 +--------------------- .../state_trackers/wgl/shared/stw_framebuffer.h | 6 ---- src/gallium/state_trackers/wgl/shared/stw_tls.c | 33 ++++++++++++++----- src/gallium/state_trackers/wgl/shared/stw_tls.h | 6 ++++ 5 files changed, 33 insertions(+), 58 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/wgl/shared/stw_device.c b/src/gallium/state_trackers/wgl/shared/stw_device.c index 1a6b29807d..070ffcb3ca 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_device.c +++ b/src/gallium/state_trackers/wgl/shared/stw_device.c @@ -133,20 +133,13 @@ error1: boolean stw_init_thread(void) { - if (!stw_tls_init_thread()) - return FALSE; - - if (!stw_framebuffer_init_thread()) - return FALSE; - - return TRUE; + return stw_tls_init_thread(); } void stw_cleanup_thread(void) { - stw_framebuffer_cleanup_thread(); stw_tls_cleanup_thread(); } diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c index 58f1830319..88043859ce 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c @@ -84,7 +84,7 @@ stw_framebuffer_destroy_locked( * @sa http://msdn.microsoft.com/en-us/library/ms644975(VS.85).aspx * @sa http://msdn.microsoft.com/en-us/library/ms644960(VS.85).aspx */ -static LRESULT CALLBACK +LRESULT CALLBACK stw_call_window_proc( int nCode, WPARAM wParam, @@ -423,38 +423,3 @@ stw_swap_layer_buffers( return FALSE; } - - -boolean -stw_framebuffer_init_thread(void) -{ - struct stw_tls_data *tls_data; - - tls_data = stw_tls_get_data(); - if(!tls_data) - return FALSE; - - tls_data->hCallWndProcHook = SetWindowsHookEx(WH_CALLWNDPROC, - stw_call_window_proc, - NULL, - GetCurrentThreadId()); - if(tls_data->hCallWndProcHook == NULL) - return FALSE; - - return TRUE; -} - -void -stw_framebuffer_cleanup_thread(void) -{ - struct stw_tls_data *tls_data; - - tls_data = stw_tls_get_data(); - if(!tls_data) - return; - - if(tls_data->hCallWndProcHook) { - UnhookWindowsHookEx(tls_data->hCallWndProcHook); - tls_data->hCallWndProcHook = NULL; - } -} diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h index e7fa51c3a8..d6f5950ac3 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h +++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h @@ -79,10 +79,4 @@ struct stw_framebuffer * stw_framebuffer_from_hdc( HDC hdc ); -boolean -stw_framebuffer_init_thread(void); - -void -stw_framebuffer_cleanup_thread(void); - #endif /* STW_FRAMEBUFFER_H */ diff --git a/src/gallium/state_trackers/wgl/shared/stw_tls.c b/src/gallium/state_trackers/wgl/shared/stw_tls.c index 0c18a52352..4bd6a9289c 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_tls.c +++ b/src/gallium/state_trackers/wgl/shared/stw_tls.c @@ -51,9 +51,23 @@ stw_tls_data_create() data = CALLOC_STRUCT(stw_tls_data); if (!data) - return NULL; + goto no_data; + + data->hCallWndProcHook = SetWindowsHookEx(WH_CALLWNDPROC, + stw_call_window_proc, + NULL, + GetCurrentThreadId()); + if(data->hCallWndProcHook == NULL) + goto no_hook; + + TlsSetValue(tlsIndex, data); return data; + +no_hook: + FREE(data); +no_data: + return NULL; } boolean @@ -69,8 +83,6 @@ stw_tls_init_thread(void) if(!data) return FALSE; - TlsSetValue(tlsIndex, data); - return TRUE; } @@ -84,8 +96,16 @@ stw_tls_cleanup_thread(void) } data = (struct stw_tls_data *) TlsGetValue(tlsIndex); - TlsSetValue(tlsIndex, NULL); - FREE(data); + if(data) { + TlsSetValue(tlsIndex, NULL); + + if(data->hCallWndProcHook) { + UnhookWindowsHookEx(data->hCallWndProcHook); + data->hCallWndProcHook = NULL; + } + + FREE(data); + } } void @@ -110,12 +130,9 @@ stw_tls_get_data(void) if(!data) { /* DllMain is called with DLL_THREAD_ATTACH only by threads created after * the DLL is loaded by the process */ - data = stw_tls_data_create(); if(!data) return NULL; - - TlsSetValue(tlsIndex, data); } return data; diff --git a/src/gallium/state_trackers/wgl/shared/stw_tls.h b/src/gallium/state_trackers/wgl/shared/stw_tls.h index 6af8be70c9..fbf8b1cbee 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_tls.h +++ b/src/gallium/state_trackers/wgl/shared/stw_tls.h @@ -50,4 +50,10 @@ stw_tls_cleanup(void); struct stw_tls_data * stw_tls_get_data(void); +LRESULT CALLBACK +stw_call_window_proc( + int nCode, + WPARAM wParam, + LPARAM lParam ); + #endif /* STW_TLS_H */ -- cgit v1.2.3 From 42882897c67f6c74e67e120e946a95929e6c2065 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 17 Jun 2009 21:28:18 +0100 Subject: wgl: Fix window resizing in multithread applications. In multithreading stw_call_window_proc can be called by a thread other than the thread where the context is bound. --- .../state_trackers/wgl/shared/stw_context.c | 25 ++++- src/gallium/state_trackers/wgl/shared/stw_device.c | 24 +++++ .../state_trackers/wgl/shared/stw_framebuffer.c | 103 ++++++++++++--------- .../state_trackers/wgl/shared/stw_framebuffer.h | 7 +- 4 files changed, 112 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index 1c217699ab..9df1ab7652 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -116,6 +116,18 @@ stw_share_lists( return ret; } +static void +stw_viewport(GLcontext * glctx, GLint x, GLint y, + GLsizei width, GLsizei height) +{ + struct stw_context *ctx = (struct stw_context *)glctx->DriverCtx; + struct stw_framebuffer *fb; + + fb = stw_framebuffer_from_hdc( ctx->hdc ); + if(fb) + stw_framebuffer_update(fb); +} + UINT_PTR stw_create_layer_context( HDC hdc, @@ -175,6 +187,7 @@ stw_create_layer_context( goto no_st_ctx; ctx->st->ctx->DriverCtx = ctx; + ctx->st->ctx->Driver.Viewport = stw_viewport; pipe_mutex_lock( stw_dev->mutex ); ctx->hglrc = handle_table_add(stw_dev->ctx_table, ctx); @@ -298,8 +311,11 @@ stw_make_current( st_flush(curctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); /* Return if already current. */ - if (curctx->hglrc == hglrc && curctx->hdc == hdc) - return TRUE; + if (curctx->hglrc == hglrc && curctx->hdc == hdc) { + ctx = curctx; + fb = stw_framebuffer_from_hdc( hdc ); + goto success; + } } if (hdc == NULL || hglrc == 0) { @@ -343,7 +359,10 @@ stw_make_current( if(!st_make_current( ctx->st, fb->stfb, fb->stfb )) goto fail; - stw_framebuffer_resize(fb); +success: + assert(fb); + if(fb) + stw_framebuffer_update(fb); return TRUE; diff --git a/src/gallium/state_trackers/wgl/shared/stw_device.c b/src/gallium/state_trackers/wgl/shared/stw_device.c index 070ffcb3ca..1b4a2d5cdb 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_device.c +++ b/src/gallium/state_trackers/wgl/shared/stw_device.c @@ -30,6 +30,7 @@ #include "glapi/glthread.h" #include "util/u_debug.h" #include "pipe/p_screen.h" +#include "state_tracker/st_public.h" #ifdef DEBUG #include "trace/tr_screen.h" @@ -63,7 +64,26 @@ stw_flush_frontbuffer(struct pipe_screen *screen, { const struct stw_winsys *stw_winsys = stw_dev->stw_winsys; HDC hdc = (HDC)context_private; + struct stw_framebuffer *fb; + fb = stw_framebuffer_from_hdc( hdc ); + assert(fb); + if (fb == NULL) + return; + + pipe_mutex_lock( fb->mutex ); + +#if DEBUG + { + struct pipe_surface *surface2; + + if(!st_get_framebuffer_surface( fb->stfb, ST_SURFACE_FRONT_LEFT, &surface2 )) + assert(0); + else + assert(surface2 == surface); + } +#endif + #ifdef DEBUG if(stw_dev->trace_running) { screen = trace_screen(screen)->screen; @@ -72,6 +92,10 @@ stw_flush_frontbuffer(struct pipe_screen *screen, #endif stw_winsys->flush_frontbuffer(screen, surface, hdc); + + stw_framebuffer_update(fb); + + pipe_mutex_unlock( fb->mutex ); } diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c index 88043859ce..7d0e8f4648 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c @@ -111,15 +111,10 @@ stw_call_window_proc( unsigned width = LOWORD( pParams->lParam ); unsigned height = HIWORD( pParams->lParam ); - /* FIXME: The mesa statetracker makes the assumptions that only - * one context is using the framebuffer, and that that context is the - * current one. However neither holds true, as WGL allows more than - * one context to be bound to the same drawable, and this function can - * be called from any thread. - */ pipe_mutex_lock( fb->mutex ); - if (fb->stfb) - st_resize_framebuffer( fb->stfb, width, height ); + fb->must_resize = TRUE; + fb->width = width; + fb->height = height; pipe_mutex_unlock( fb->mutex ); } } @@ -140,6 +135,31 @@ stw_call_window_proc( } +static void +stw_framebuffer_get_size( struct stw_framebuffer *fb ) +{ + unsigned width, height; + RECT rect; + + assert(fb->hWnd); + + GetClientRect( fb->hWnd, &rect ); + width = rect.right - rect.left; + height = rect.bottom - rect.top; + + if(width < 1) + width = 1; + if(height < 1) + height = 1; + + if(width != fb->width || height != fb->height) { + fb->must_resize = TRUE; + fb->width = width; + fb->height = height; + } +} + + /** * Create a new framebuffer object which will correspond to the given HDC. */ @@ -169,6 +189,8 @@ stw_framebuffer_create_locked( stw_pixelformat_visual(&fb->visual, pfi); + stw_framebuffer_get_size(fb); + pipe_mutex_init( fb->mutex ); fb->next = stw_dev->fb_head; @@ -178,32 +200,6 @@ stw_framebuffer_create_locked( } -static void -stw_framebuffer_get_size( struct stw_framebuffer *fb, GLuint *pwidth, GLuint *pheight ) -{ - GLuint width, height; - - if (fb->hWnd) { - RECT rect; - GetClientRect( fb->hWnd, &rect ); - width = rect.right - rect.left; - height = rect.bottom - rect.top; - } - else { - width = GetDeviceCaps( fb->hDC, HORZRES ); - height = GetDeviceCaps( fb->hDC, VERTRES ); - } - - if(width < 1) - width = 1; - if(height < 1) - height = 1; - - *pwidth = width; - *pheight = height; -} - - BOOL stw_framebuffer_allocate( struct stw_framebuffer *fb) @@ -213,7 +209,6 @@ stw_framebuffer_allocate( if(!fb->stfb) { const struct stw_pixelformat_info *pfi = fb->pfi; enum pipe_format colorFormat, depthFormat, stencilFormat; - GLuint width, height; colorFormat = pfi->color_format; @@ -229,16 +224,21 @@ stw_framebuffer_allocate( else stencilFormat = PIPE_FORMAT_NONE; - stw_framebuffer_get_size(fb, &width, &height); - + assert(fb->must_resize); + assert(fb->width); + assert(fb->height); + fb->stfb = st_create_framebuffer( &fb->visual, colorFormat, depthFormat, stencilFormat, - width, - height, + fb->width, + fb->height, (void *) fb ); + + // to notify the context + fb->must_resize = TRUE; } pipe_mutex_unlock( fb->mutex ); @@ -247,14 +247,29 @@ stw_framebuffer_allocate( } +/** + * Update the framebuffer's size if necessary. + */ void -stw_framebuffer_resize( +stw_framebuffer_update( struct stw_framebuffer *fb) { - GLuint width, height; assert(fb->stfb); - stw_framebuffer_get_size(fb, &width, &height); - st_resize_framebuffer(fb->stfb, width, height); + assert(fb->height); + assert(fb->width); + + /* XXX: It would be nice to avoid checking the size again -- in theory + * stw_call_window_proc would have cought the resize and stored the right + * size already, but unfortunately threads created before the DllMain is + * called don't get a DLL_THREAD_ATTACH notification, and there is no way + * to know of their existing without using the not very portable PSAPI. + */ + stw_framebuffer_get_size(fb); + + if(fb->must_resize) { + st_resize_framebuffer(fb->stfb, fb->width, fb->height); + fb->must_resize = FALSE; + } } @@ -407,6 +422,8 @@ stw_swap_buffers( stw_dev->stw_winsys->flush_frontbuffer( screen, surface, hdc ); + stw_framebuffer_update(fb); + pipe_mutex_unlock( fb->mutex ); return TRUE; diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h index d6f5950ac3..759e06b891 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h +++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h @@ -51,6 +51,11 @@ struct stw_framebuffer pipe_mutex mutex; struct st_framebuffer *stfb; + /* FIXME: Make this work for multiple contexts bound to the same framebuffer */ + boolean must_resize; + unsigned width; + unsigned height; + /** This is protected by stw_device::mutex, not the mutex above */ struct stw_framebuffer *next; }; @@ -65,7 +70,7 @@ stw_framebuffer_allocate( struct stw_framebuffer *fb ); void -stw_framebuffer_resize( +stw_framebuffer_update( struct stw_framebuffer *fb); void -- cgit v1.2.3 From 2af0173e9e4eefe910c6011038e7346091a9b2a4 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 18 Jun 2009 12:51:00 +0100 Subject: pipebuffer: Use a type consistently for sizes/offsets. Avoids warnings on 64bit builds. Use regular unsigned since that's what gallium expects, but use a typedef to facilitate possible changes in the future. --- src/gallium/auxiliary/pipebuffer/pb_buffer.h | 14 ++++++--- .../auxiliary/pipebuffer/pb_buffer_fenced.c | 6 ++-- .../auxiliary/pipebuffer/pb_buffer_malloc.c | 6 ++-- src/gallium/auxiliary/pipebuffer/pb_bufmgr.h | 20 ++++++------ src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c | 2 +- src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c | 8 ++--- src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c | 30 +++++++++--------- .../auxiliary/pipebuffer/pb_bufmgr_fenced.c | 2 +- src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c | 24 +++++++-------- .../auxiliary/pipebuffer/pb_bufmgr_ondemand.c | 6 ++-- src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c | 20 ++++++------ src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c | 36 +++++++++++----------- 12 files changed, 90 insertions(+), 84 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer.h b/src/gallium/auxiliary/pipebuffer/pb_buffer.h index 92b6fd0056..2590546cb4 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer.h +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer.h @@ -71,6 +71,12 @@ struct pb_desc }; +/** + * Size. Regular (32bit) unsigned for now. + */ +typedef unsigned pb_size; + + /** * Base class for all pb_* buffers. */ @@ -126,7 +132,7 @@ struct pb_vtbl */ void (*get_base_buffer)( struct pb_buffer *buf, struct pb_buffer **base_buf, - unsigned *offset ); + pb_size *offset ); }; @@ -177,7 +183,7 @@ pb_unmap(struct pb_buffer *buf) static INLINE void pb_get_base_buffer( struct pb_buffer *buf, struct pb_buffer **base_buf, - unsigned *offset ) + pb_size *offset ) { assert(buf); if(!buf) { @@ -241,7 +247,7 @@ pb_reference(struct pb_buffer **dst, * the requested or not. */ static INLINE boolean -pb_check_alignment(size_t requested, size_t provided) +pb_check_alignment(pb_size requested, pb_size provided) { if(!requested) return TRUE; @@ -269,7 +275,7 @@ pb_check_usage(unsigned requested, unsigned provided) * hardware. */ struct pb_buffer * -pb_malloc_buffer_create(size_t size, +pb_malloc_buffer_create(pb_size size, const struct pb_desc *desc); diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c index 4698efa69c..109ac7c9d6 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c @@ -65,11 +65,11 @@ struct fenced_buffer_list struct pb_fence_ops *ops; - size_t numDelayed; + pb_size numDelayed; struct list_head delayed; #ifdef DEBUG - size_t numUnfenced; + pb_size numUnfenced; struct list_head unfenced; #endif }; @@ -433,7 +433,7 @@ fenced_buffer_fence(struct pb_buffer *buf, static void fenced_buffer_get_base_buffer(struct pb_buffer *buf, struct pb_buffer **base_buf, - unsigned *offset) + pb_size *offset) { struct fenced_buffer *fenced_buf = fenced_buffer(buf); pb_get_base_buffer(fenced_buf->buffer, base_buf, offset); diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c index 689fd74771..0760d60716 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c @@ -102,7 +102,7 @@ malloc_buffer_fence(struct pb_buffer *buf, static void malloc_buffer_get_base_buffer(struct pb_buffer *buf, struct pb_buffer **base_buf, - unsigned *offset) + pb_size *offset) { *base_buf = buf; *offset = 0; @@ -121,7 +121,7 @@ malloc_buffer_vtbl = { struct pb_buffer * -pb_malloc_buffer_create(size_t size, +pb_malloc_buffer_create(pb_size size, const struct pb_desc *desc) { struct malloc_buffer *buf; @@ -150,7 +150,7 @@ pb_malloc_buffer_create(size_t size, static struct pb_buffer * pb_malloc_bufmgr_create_buffer(struct pb_manager *mgr, - size_t size, + pb_size size, const struct pb_desc *desc) { return pb_malloc_buffer_create(size, desc); diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h index 74077f8277..39ab8e722c 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h @@ -73,7 +73,7 @@ struct pb_manager struct pb_buffer * (*create_buffer)( struct pb_manager *mgr, - size_t size, + pb_size size, const struct pb_desc *desc); /** @@ -106,7 +106,7 @@ pb_malloc_bufmgr_create(void); */ struct pb_manager * pool_bufmgr_create(struct pb_manager *provider, - size_t n, size_t size, + pb_size n, pb_size size, const struct pb_desc *desc); @@ -119,7 +119,7 @@ pool_bufmgr_create(struct pb_manager *provider, */ struct pb_manager * mm_bufmgr_create(struct pb_manager *provider, - size_t size, size_t align2); + pb_size size, pb_size align2); /** * Same as mm_bufmgr_create. @@ -128,7 +128,7 @@ mm_bufmgr_create(struct pb_manager *provider, */ struct pb_manager * mm_bufmgr_create_from_buffer(struct pb_buffer *buffer, - size_t size, size_t align2); + pb_size size, pb_size align2); /** @@ -136,8 +136,8 @@ mm_bufmgr_create_from_buffer(struct pb_buffer *buffer, */ struct pb_manager * pb_slab_manager_create(struct pb_manager *provider, - size_t bufSize, - size_t slabSize, + pb_size bufSize, + pb_size slabSize, const struct pb_desc *desc); /** @@ -146,9 +146,9 @@ pb_slab_manager_create(struct pb_manager *provider, */ struct pb_manager * pb_slab_range_manager_create(struct pb_manager *provider, - size_t minBufSize, - size_t maxBufSize, - size_t slabSize, + pb_size minBufSize, + pb_size maxBufSize, + pb_size slabSize, const struct pb_desc *desc); @@ -204,7 +204,7 @@ pb_ondemand_manager_create(struct pb_manager *provider); */ struct pb_manager * pb_debug_manager_create(struct pb_manager *provider, - size_t underflow_size, size_t overflow_size); + pb_size underflow_size, pb_size overflow_size); #ifdef __cplusplus diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c index db67d46c56..f60c836f18 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c @@ -60,7 +60,7 @@ pb_alt_manager(struct pb_manager *mgr) static struct pb_buffer * pb_alt_manager_create_buffer(struct pb_manager *_mgr, - size_t size, + pb_size size, const struct pb_desc *desc) { struct pb_alt_manager *mgr = pb_alt_manager(_mgr); diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c index 35358430b4..57d1ede45a 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c @@ -81,7 +81,7 @@ struct pb_cache_manager pipe_mutex mutex; struct list_head delayed; - size_t numDelayed; + pb_size numDelayed; }; @@ -204,7 +204,7 @@ pb_cache_buffer_fence(struct pb_buffer *_buf, static void pb_cache_buffer_get_base_buffer(struct pb_buffer *_buf, struct pb_buffer **base_buf, - unsigned *offset) + pb_size *offset) { struct pb_cache_buffer *buf = pb_cache_buffer(_buf); pb_get_base_buffer(buf->buffer, base_buf, offset); @@ -224,7 +224,7 @@ pb_cache_buffer_vtbl = { static INLINE boolean pb_cache_is_buffer_compat(struct pb_cache_buffer *buf, - size_t size, + pb_size size, const struct pb_desc *desc) { if(buf->base.base.size < size) @@ -246,7 +246,7 @@ pb_cache_is_buffer_compat(struct pb_cache_buffer *buf, static struct pb_buffer * pb_cache_manager_create_buffer(struct pb_manager *_mgr, - size_t size, + pb_size size, const struct pb_desc *desc) { struct pb_cache_manager *mgr = pb_cache_manager(_mgr); diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c index cedf745bda..1b4df28c70 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c @@ -72,8 +72,8 @@ struct pb_debug_buffer struct pb_buffer *buffer; struct pb_debug_manager *mgr; - size_t underflow_size; - size_t overflow_size; + pb_size underflow_size; + pb_size overflow_size; struct debug_stack_frame create_backtrace[PB_DEBUG_CREATE_BACKTRACE]; @@ -91,8 +91,8 @@ struct pb_debug_manager struct pb_manager *provider; - size_t underflow_size; - size_t overflow_size; + pb_size underflow_size; + pb_size overflow_size; pipe_mutex mutex; struct list_head list; @@ -124,9 +124,9 @@ static const uint8_t random_pattern[32] = { static INLINE void -fill_random_pattern(uint8_t *dst, size_t size) +fill_random_pattern(uint8_t *dst, pb_size size) { - size_t i = 0; + pb_size i = 0; while(size--) { *dst++ = random_pattern[i++]; i &= sizeof(random_pattern) - 1; @@ -135,11 +135,11 @@ fill_random_pattern(uint8_t *dst, size_t size) static INLINE boolean -check_random_pattern(const uint8_t *dst, size_t size, - size_t *min_ofs, size_t *max_ofs) +check_random_pattern(const uint8_t *dst, pb_size size, + pb_size *min_ofs, pb_size *max_ofs) { boolean result = TRUE; - size_t i; + pb_size i; *min_ofs = size; *max_ofs = 0; for(i = 0; i < size; ++i) { @@ -183,7 +183,7 @@ pb_debug_buffer_check(struct pb_debug_buffer *buf) assert(map); if(map) { boolean underflow, overflow; - size_t min_ofs, max_ofs; + pb_size min_ofs, max_ofs; underflow = !check_random_pattern(map, buf->underflow_size, &min_ofs, &max_ofs); @@ -287,7 +287,7 @@ pb_debug_buffer_unmap(struct pb_buffer *_buf) static void pb_debug_buffer_get_base_buffer(struct pb_buffer *_buf, struct pb_buffer **base_buf, - unsigned *offset) + pb_size *offset) { struct pb_debug_buffer *buf = pb_debug_buffer(_buf); pb_get_base_buffer(buf->buffer, base_buf, offset); @@ -363,13 +363,13 @@ pb_debug_manager_dump(struct pb_debug_manager *mgr) static struct pb_buffer * pb_debug_manager_create_buffer(struct pb_manager *_mgr, - size_t size, + pb_size size, const struct pb_desc *desc) { struct pb_debug_manager *mgr = pb_debug_manager(_mgr); struct pb_debug_buffer *buf; struct pb_desc real_desc; - size_t real_size; + pb_size real_size; buf = CALLOC_STRUCT(pb_debug_buffer); if(!buf) @@ -455,7 +455,7 @@ pb_debug_manager_destroy(struct pb_manager *_mgr) struct pb_manager * pb_debug_manager_create(struct pb_manager *provider, - size_t underflow_size, size_t overflow_size) + pb_size underflow_size, pb_size overflow_size) { struct pb_debug_manager *mgr; @@ -485,7 +485,7 @@ pb_debug_manager_create(struct pb_manager *provider, struct pb_manager * pb_debug_manager_create(struct pb_manager *provider, - size_t underflow_size, size_t overflow_size) + pb_size underflow_size, pb_size overflow_size) { return provider; } diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c index 144db5669b..97dd1427fd 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c @@ -62,7 +62,7 @@ fenced_pb_manager(struct pb_manager *mgr) static struct pb_buffer * fenced_bufmgr_create_buffer(struct pb_manager *mgr, - size_t size, + pb_size size, const struct pb_desc *desc) { struct fenced_pb_manager *fenced_mgr = fenced_pb_manager(mgr); diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c index d8decba49d..6400fc5b0a 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c @@ -55,10 +55,10 @@ struct mm_pb_manager pipe_mutex mutex; - size_t size; + pb_size size; struct mem_block *heap; - size_t align2; + pb_size align2; struct pb_buffer *buffer; void *map; @@ -148,7 +148,7 @@ mm_buffer_fence(struct pb_buffer *buf, static void mm_buffer_get_base_buffer(struct pb_buffer *buf, struct pb_buffer **base_buf, - unsigned *offset) + pb_size *offset) { struct mm_buffer *mm_buf = mm_buffer(buf); struct mm_pb_manager *mm = mm_buf->mgr; @@ -170,15 +170,15 @@ mm_buffer_vtbl = { static struct pb_buffer * mm_bufmgr_create_buffer(struct pb_manager *mgr, - size_t size, + pb_size size, const struct pb_desc *desc) { struct mm_pb_manager *mm = mm_pb_manager(mgr); struct mm_buffer *mm_buf; /* We don't handle alignments larger then the one initially setup */ - assert(pb_check_alignment(desc->alignment, 1 << mm->align2)); - if(!pb_check_alignment(desc->alignment, 1 << mm->align2)) + assert(pb_check_alignment(desc->alignment, (pb_size)1 << mm->align2)); + if(!pb_check_alignment(desc->alignment, (pb_size)1 << mm->align2)) return NULL; pipe_mutex_lock(mm->mutex); @@ -198,7 +198,7 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr, mm_buf->mgr = mm; - mm_buf->block = u_mmAllocMem(mm->heap, size, mm->align2, 0); + mm_buf->block = u_mmAllocMem(mm->heap, (int)size, (int)mm->align2, 0); if(!mm_buf->block) { #if 0 debug_printf("warning: heap full\n"); @@ -210,8 +210,8 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr, } /* Some sanity checks */ - assert(0 <= (unsigned)mm_buf->block->ofs && (unsigned)mm_buf->block->ofs < mm->size); - assert(size <= (unsigned)mm_buf->block->size && (unsigned)mm_buf->block->ofs + (unsigned)mm_buf->block->size <= mm->size); + assert(0 <= (pb_size)mm_buf->block->ofs && (pb_size)mm_buf->block->ofs < mm->size); + assert(size <= (pb_size)mm_buf->block->size && (pb_size)mm_buf->block->ofs + (pb_size)mm_buf->block->size <= mm->size); pipe_mutex_unlock(mm->mutex); return SUPER(mm_buf); @@ -245,7 +245,7 @@ mm_bufmgr_destroy(struct pb_manager *mgr) struct pb_manager * mm_bufmgr_create_from_buffer(struct pb_buffer *buffer, - size_t size, size_t align2) + pb_size size, pb_size align2) { struct mm_pb_manager *mm; @@ -273,7 +273,7 @@ mm_bufmgr_create_from_buffer(struct pb_buffer *buffer, if(!mm->map) goto failure; - mm->heap = u_mmInit(0, size); + mm->heap = u_mmInit(0, (int)size); if (!mm->heap) goto failure; @@ -292,7 +292,7 @@ if(mm->heap) struct pb_manager * mm_bufmgr_create(struct pb_manager *provider, - size_t size, size_t align2) + pb_size size, pb_size align2) { struct pb_buffer *buffer; struct pb_manager *mgr; diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c index 4f7e6b1c4d..bc3093f620 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c @@ -55,7 +55,7 @@ struct pb_ondemand_buffer /** Real buffer */ struct pb_buffer *buffer; - size_t size; + pb_size size; struct pb_desc desc; }; @@ -204,7 +204,7 @@ pb_ondemand_buffer_fence(struct pb_buffer *_buf, static void pb_ondemand_buffer_get_base_buffer(struct pb_buffer *_buf, struct pb_buffer **base_buf, - unsigned *offset) + pb_size *offset) { struct pb_ondemand_buffer *buf = pb_ondemand_buffer(_buf); @@ -232,7 +232,7 @@ pb_ondemand_buffer_vtbl = { static struct pb_buffer * pb_ondemand_manager_create_buffer(struct pb_manager *_mgr, - size_t size, + pb_size size, const struct pb_desc *desc) { struct pb_ondemand_manager *mgr = pb_ondemand_manager(_mgr); diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c index 07fd1a22d9..7fd65ed226 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c @@ -58,11 +58,11 @@ struct pool_pb_manager pipe_mutex mutex; - size_t bufSize; - size_t bufAlign; + pb_size bufSize; + pb_size bufAlign; - size_t numFree; - size_t numTot; + pb_size numFree; + pb_size numTot; struct list_head free; @@ -89,7 +89,7 @@ struct pool_buffer struct list_head head; - size_t start; + pb_size start; }; @@ -162,7 +162,7 @@ pool_buffer_fence(struct pb_buffer *buf, static void pool_buffer_get_base_buffer(struct pb_buffer *buf, struct pb_buffer **base_buf, - unsigned *offset) + pb_size *offset) { struct pool_buffer *pool_buf = pool_buffer(buf); struct pool_pb_manager *pool = pool_buf->mgr; @@ -184,7 +184,7 @@ pool_buffer_vtbl = { static struct pb_buffer * pool_bufmgr_create_buffer(struct pb_manager *mgr, - size_t size, + pb_size size, const struct pb_desc *desc) { struct pool_pb_manager *pool = pool_pb_manager(mgr); @@ -251,13 +251,13 @@ pool_bufmgr_destroy(struct pb_manager *mgr) struct pb_manager * pool_bufmgr_create(struct pb_manager *provider, - size_t numBufs, - size_t bufSize, + pb_size numBufs, + pb_size bufSize, const struct pb_desc *desc) { struct pool_pb_manager *pool; struct pool_buffer *pool_buf; - size_t i; + pb_size i; if(!provider) return NULL; diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c index 724aaadb43..e7352e90db 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c @@ -68,7 +68,7 @@ struct pb_slab_buffer unsigned mapCount; /** Offset relative to the start of the slab buffer. */ - size_t start; + pb_size start; /** Use when validating, to signal that all mappings are finished */ /* TODO: Actually validation does not reach this stage yet */ @@ -83,8 +83,8 @@ struct pb_slab { struct list_head head; struct list_head freeBuffers; - size_t numBuffers; - size_t numFree; + pb_size numBuffers; + pb_size numFree; struct pb_slab_buffer *buffers; struct pb_slab_manager *mgr; @@ -108,10 +108,10 @@ struct pb_slab_manager struct pb_manager *provider; /** Size of the buffers we hand on downstream */ - size_t bufSize; + pb_size bufSize; /** Size of the buffers we request upstream */ - size_t slabSize; + pb_size slabSize; /** * Alignment, usage to be used to allocate the slab buffers. @@ -150,14 +150,14 @@ struct pb_slab_range_manager struct pb_manager *provider; - size_t minBufSize; - size_t maxBufSize; + pb_size minBufSize; + pb_size maxBufSize; /** @sa pb_slab_manager::desc */ struct pb_desc desc; unsigned numBuckets; - size_t *bucketSizes; + pb_size *bucketSizes; /** Array of pb_slab_manager, one for each bucket size */ struct pb_manager **buckets; @@ -270,7 +270,7 @@ pb_slab_buffer_fence(struct pb_buffer *_buf, static void pb_slab_buffer_get_base_buffer(struct pb_buffer *_buf, struct pb_buffer **base_buf, - unsigned *offset) + pb_size *offset) { struct pb_slab_buffer *buf = pb_slab_buffer(_buf); pb_get_base_buffer(buf->slab->bo, base_buf, offset); @@ -369,7 +369,7 @@ out_err0: static struct pb_buffer * pb_slab_manager_create_buffer(struct pb_manager *_mgr, - size_t size, + pb_size size, const struct pb_desc *desc) { struct pb_slab_manager *mgr = pb_slab_manager(_mgr); @@ -450,8 +450,8 @@ pb_slab_manager_destroy(struct pb_manager *_mgr) struct pb_manager * pb_slab_manager_create(struct pb_manager *provider, - size_t bufSize, - size_t slabSize, + pb_size bufSize, + pb_size slabSize, const struct pb_desc *desc) { struct pb_slab_manager *mgr; @@ -479,11 +479,11 @@ pb_slab_manager_create(struct pb_manager *provider, static struct pb_buffer * pb_slab_range_manager_create_buffer(struct pb_manager *_mgr, - size_t size, + pb_size size, const struct pb_desc *desc) { struct pb_slab_range_manager *mgr = pb_slab_range_manager(_mgr); - size_t bufSize; + pb_size bufSize; unsigned i; bufSize = mgr->minBufSize; @@ -527,13 +527,13 @@ pb_slab_range_manager_destroy(struct pb_manager *_mgr) struct pb_manager * pb_slab_range_manager_create(struct pb_manager *provider, - size_t minBufSize, - size_t maxBufSize, - size_t slabSize, + pb_size minBufSize, + pb_size maxBufSize, + pb_size slabSize, const struct pb_desc *desc) { struct pb_slab_range_manager *mgr; - size_t bufSize; + pb_size bufSize; unsigned i; if(!provider) -- cgit v1.2.3 From d609df1daec552113a8385330b680b293ef862eb Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 18 Jun 2009 12:52:10 +0100 Subject: trace: Use size_t consistently. --- src/gallium/drivers/trace/tr_dump.c | 4 ++-- src/gallium/drivers/trace/tr_dump.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c index 3a1409e95a..643587ab42 100644 --- a/src/gallium/drivers/trace/tr_dump.c +++ b/src/gallium/drivers/trace/tr_dump.c @@ -451,11 +451,11 @@ void trace_dump_float(double value) } void trace_dump_bytes(const void *data, - long unsigned size) + size_t size) { static const char hex_table[16] = "0123456789ABCDEF"; const uint8_t *p = data; - long unsigned i; + size_t i; if (!dumping) return; diff --git a/src/gallium/drivers/trace/tr_dump.h b/src/gallium/drivers/trace/tr_dump.h index 31ac70802f..32592bab12 100644 --- a/src/gallium/drivers/trace/tr_dump.h +++ b/src/gallium/drivers/trace/tr_dump.h @@ -91,7 +91,7 @@ void trace_dump_bool(int value); void trace_dump_int(long long int value); void trace_dump_uint(long long unsigned value); void trace_dump_float(double value); -void trace_dump_bytes(const void *data, long unsigned size); +void trace_dump_bytes(const void *data, size_t size); void trace_dump_string(const char *str); void trace_dump_enum(const char *value); void trace_dump_array_begin(void); @@ -130,7 +130,7 @@ void trace_dump_transfer_ptr(struct pipe_transfer *_transfer); #define trace_dump_array(_type, _obj, _size) \ do { \ - unsigned long idx; \ + size_t idx; \ trace_dump_array_begin(); \ for(idx = 0; idx < (_size); ++idx) { \ trace_dump_elem_begin(); \ @@ -142,7 +142,7 @@ void trace_dump_transfer_ptr(struct pipe_transfer *_transfer); #define trace_dump_struct_array(_type, _obj, _size) \ do { \ - unsigned long idx; \ + size_t idx; \ trace_dump_array_begin(); \ for(idx = 0; idx < (_size); ++idx) { \ trace_dump_elem_begin(); \ -- cgit v1.2.3 From 21bfd0f4bdd4222346c7f2db956e7fc1645d2130 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 18 Jun 2009 14:46:45 +0100 Subject: draw: Replace pointer arithmetic with cast. Using uintptr_t as intermediate type for pointer -> integer conversions is easier to understand and does not cause any size mismatch warnings. uintptr_t is part of C99, and we already provide a suitable replacement definition for all platforms we care about. --- src/gallium/auxiliary/draw/draw_pt_elts.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/auxiliary/draw/draw_pt_elts.c b/src/gallium/auxiliary/draw/draw_pt_elts.c index b7780fb507..88f4d9f495 100644 --- a/src/gallium/auxiliary/draw/draw_pt_elts.c +++ b/src/gallium/auxiliary/draw/draw_pt_elts.c @@ -54,7 +54,8 @@ static unsigned elt_ubyte( const void *elts, unsigned idx ) static unsigned elt_vert( const void *elts, unsigned idx ) { - return (const ubyte *)elts - (const ubyte *)NULL + idx; + /* unsigned index is packed in the pointer */ + return (unsigned)(uintptr_t)elts + idx; } pt_elt_func draw_pt_elt_func( struct draw_context *draw ) -- cgit v1.2.3 From 8f382fd3f396e182255fe084bc32648b98ca1d94 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 18 Jun 2009 14:47:30 +0100 Subject: util: Add cast. It is expected to loose precision here. --- src/gallium/auxiliary/util/u_snprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_snprintf.c b/src/gallium/auxiliary/util/u_snprintf.c index 0d54299b28..65bdd0df2b 100644 --- a/src/gallium/auxiliary/util/u_snprintf.c +++ b/src/gallium/auxiliary/util/u_snprintf.c @@ -829,7 +829,7 @@ util_vsnprintf(char *str, size_t size, const char *format, va_list args) break; default: intptr = va_arg(args, int *); - *intptr = len; + *intptr = (int)len; break; } break; -- cgit v1.2.3 From 048765624598e6c60b9fe4dc82a72b7110f16715 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 19 Jun 2009 08:40:43 -0600 Subject: softpipe: return alpha=1 in shadow_compare() function The alpha value wasn't set at all before so we got unpredictable results. Note that we don't currently obey GL_DEPTH_TEXTURE_MODE in the state tracker. For now, we return the result in the default mode (r,r,r,1). --- src/gallium/drivers/softpipe/sp_tex_sample.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c index adbd0cb7f0..5de358dae9 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.c +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c @@ -744,7 +744,9 @@ shadow_compare(uint compare_func, break; } + /* XXX returning result for default GL_DEPTH_TEXTURE_MODE = GL_LUMINANCE */ rgba[0][j] = rgba[1][j] = rgba[2][j] = (float) k; + rgba[3][j] = 1.0F; } -- cgit v1.2.3 From a120778c72324bc56c63cd0f1873c6f2772228ea Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Fri, 19 Jun 2009 11:19:08 +0200 Subject: Always free image offsets memory when re-initializing texture image fields. Fixes leak running compiz with direct rendering. --- src/mesa/main/mipmap.c | 3 --- src/mesa/main/teximage.c | 2 ++ src/mesa/state_tracker/st_gen_mipmap.c | 3 --- 3 files changed, 2 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c index 7a719745fc..b306700484 100644 --- a/src/mesa/main/mipmap.c +++ b/src/mesa/main/mipmap.c @@ -1598,9 +1598,6 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target, return; } - if (dstImage->ImageOffsets) - _mesa_free(dstImage->ImageOffsets); - /* Free old image data */ if (dstImage->Data) ctx->Driver.FreeTexImageData(ctx, dstImage); diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 76b46d700b..6e21066537 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1250,6 +1250,8 @@ _mesa_init_teximage_fields(GLcontext *ctx, GLenum target, * We allocate the array for 1D/2D textures too in order to avoid special- * case code in the texstore routines. */ + if (img->ImageOffsets) + _mesa_free(img->ImageOffsets); img->ImageOffsets = (GLuint *) _mesa_malloc(depth * sizeof(GLuint)); for (i = 0; i < depth; i++) { img->ImageOffsets[i] = i * width * height; diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index dc6d77825f..58f6933652 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -198,9 +198,6 @@ st_generate_mipmap(GLcontext *ctx, GLenum target, return; } - if (dstImage->ImageOffsets) - _mesa_free(dstImage->ImageOffsets); - /* Free old image data */ if (dstImage->Data) ctx->Driver.FreeTexImageData(ctx, dstImage); -- cgit v1.2.3 From 9dfce365c7f35ddea6d81b7f595ddcd6d35382a5 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Fri, 19 Jun 2009 11:19:07 +0200 Subject: Also release direct rendering resources in glXDestroyGLXPixmap. Fixes leak running compiz with direct rendering. --- src/glx/x11/glxcmds.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c index ec3e69e4fe..77471b8599 100644 --- a/src/glx/x11/glxcmds.c +++ b/src/glx/x11/glxcmds.c @@ -869,6 +869,20 @@ PUBLIC void glXDestroyGLXPixmap(Display *dpy, GLXPixmap glxpixmap) req->glxpixmap = glxpixmap; UnlockDisplay(dpy); SyncHandle(); + +#ifdef GLX_DIRECT_RENDERING + { + int screen; + __GLXdisplayPrivate *const priv = __glXInitialize(dpy); + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, glxpixmap, &screen); + __GLXscreenConfigs *psc = &priv->screenConfigs[screen]; + + if (pdraw != NULL) { + (*pdraw->destroyDrawable) (pdraw); + __glxHashDelete(psc->drawHash, glxpixmap); + } + } +#endif } PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable) -- cgit v1.2.3 From 43bb78f2bb6c851d989903e7eb996e87113d878c Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Fri, 19 Jun 2009 20:00:55 +0200 Subject: radeons: use dp4 for position invariant vertex programs Fixes #22181. R200 requires this since DP4 is used in hw tnl mode. R300 prefers it (should be faster due to no instruction dependencies), but both methods should be correct (when sw tcl is used though, MUL/MAD might be faster). Probably doesn't make much difference for R100 since vertex progs are executed in software anyway, but let's just keep it the same there too. --- src/mesa/drivers/dri/r200/r200_context.c | 2 ++ src/mesa/drivers/dri/r300/r300_context.c | 2 ++ src/mesa/drivers/dri/radeon/radeon_context.c | 2 ++ 3 files changed, 6 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c index c06751516e..058296eab2 100644 --- a/src/mesa/drivers/dri/r200/r200_context.c +++ b/src/mesa/drivers/dri/r200/r200_context.c @@ -405,6 +405,8 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, ctx->Const.MaxDrawBuffers = 1; + _mesa_set_mvp_with_dp4( ctx, GL_TRUE ); + /* Initialize the software rasterizer and helper modules. */ _swrast_CreateContext( ctx ); diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c index 8f0effd83e..7d6705058f 100644 --- a/src/mesa/drivers/dri/r300/r300_context.c +++ b/src/mesa/drivers/dri/r300/r300_context.c @@ -327,6 +327,8 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual, ctx->Const.MaxDrawBuffers = 1; + _mesa_set_mvp_with_dp4( ctx, GL_TRUE ); + /* Initialize the software rasterizer and helper modules. */ _swrast_CreateContext(ctx); diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c index ea81a3250b..b67bda7d06 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.c +++ b/src/mesa/drivers/dri/radeon/radeon_context.c @@ -355,6 +355,8 @@ radeonCreateContext( const __GLcontextModes *glVisual, ctx->Const.MaxDrawBuffers = 1; + _mesa_set_mvp_with_dp4( ctx, GL_TRUE ); + /* Initialize the software rasterizer and helper modules. */ _swrast_CreateContext( ctx ); -- cgit v1.2.3 From daacac1c24ce5551e074c07f64e14f5c5057d188 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 19 Jun 2009 15:49:24 -0700 Subject: intel: Fix glClear behavior versus display lists. The CALL_DrawArrays was leaking the clear's primitives into the display list with GL_COMPILE_AND_EXECUTE. Use _mesa_DrawArrays instead, which doesn't appear to leak. Fixes piglit dlist-clear test. (cherry picked from commit 64edde1004f7a69e77877bba24d315a92bcd47c8) --- src/mesa/drivers/dri/intel/intel_clear.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/intel/intel_clear.c b/src/mesa/drivers/dri/intel/intel_clear.c index 4dfaee8a4a..19f47632ac 100644 --- a/src/mesa/drivers/dri/intel/intel_clear.c +++ b/src/mesa/drivers/dri/intel/intel_clear.c @@ -264,7 +264,7 @@ intel_clear_tris(GLcontext *ctx, GLbitfield mask) _mesa_Disable(GL_STENCIL_TEST); } - CALL_DrawArrays(ctx->Exec, (GL_TRIANGLE_FAN, 0, 4)); + _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); mask &= ~this_mask; } -- cgit v1.2.3 From abfd56c24c821e0dec233348ef01aef5b57f2763 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 19 Jun 2009 15:57:03 -0700 Subject: intel: Fix other metaops versus GL_COMPILE_AND_EXECUTE dlists. Fixes oglconform zbfunc.c and pxtrans-cidraw.c, at least. (cherry picked from commit 405300bb190f516e16b704050abe3389b366ed27) --- src/mesa/drivers/dri/intel/intel_pixel_bitmap.c | 2 +- src/mesa/drivers/dri/intel/intel_pixel_draw.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c index 69e619ac4a..a2ccae1b7d 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c @@ -507,7 +507,7 @@ intel_texture_bitmap(GLcontext * ctx, _mesa_TexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), &texcoords); _mesa_Enable(GL_VERTEX_ARRAY); _mesa_Enable(GL_TEXTURE_COORD_ARRAY); - CALL_DrawArrays(ctx->Exec, (GL_TRIANGLE_FAN, 0, 4)); + _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); intel_meta_restore_transform(intel); intel_meta_restore_fragment_program(intel); diff --git a/src/mesa/drivers/dri/intel/intel_pixel_draw.c b/src/mesa/drivers/dri/intel/intel_pixel_draw.c index 2706ca327f..225c5f48a5 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_draw.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_draw.c @@ -191,7 +191,7 @@ intel_texture_drawpixels(GLcontext * ctx, _mesa_TexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), &texcoords); _mesa_Enable(GL_VERTEX_ARRAY); _mesa_Enable(GL_TEXTURE_COORD_ARRAY); - CALL_DrawArrays(ctx->Exec, (GL_TRIANGLE_FAN, 0, 4)); + _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); intel_meta_restore_transform(intel); @@ -383,7 +383,7 @@ intel_stencil_drawpixels(GLcontext * ctx, _mesa_TexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), &texcoords); _mesa_Enable(GL_VERTEX_ARRAY); _mesa_Enable(GL_TEXTURE_COORD_ARRAY); - CALL_DrawArrays(ctx->Exec, (GL_TRIANGLE_FAN, 0, 4)); + _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); intel_meta_restore_transform(intel); -- cgit v1.2.3 From 00e203fe17cbf2127abc422c785cf9fad3232adb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 1 May 2009 09:30:32 -0600 Subject: mesa: create/use a fallback texture when bound texture is incomplete When a GLSL sampler reads from an incomplete texture it should return (0,0,0,1). Instead of jumping through hoops in all the drivers to make this happen, just create/install a fallback texture with those texel values. Fixes piglit/fp-incomplete-tex on i965 and more importantly, fixes some GPU lockups when trying to sample from missing surfaces. If a binding table entry is NULL, it seems that sampling sometimes works, but not always (lockup). Todo: create a fallback texture for each type of texture target? (cherry picked from commit 3f25219c7bf0f090502489928f0f018e62c4f6cf) --- src/mesa/main/mtypes.h | 3 +++ src/mesa/main/texobj.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ src/mesa/main/texobj.h | 3 +++ src/mesa/main/texstate.c | 9 ++++++-- 4 files changed, 66 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 8872c8963f..b9cb972e5f 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2053,6 +2053,9 @@ struct gl_shared_state /** Default texture objects (shared by all texture units) */ struct gl_texture_object *DefaultTex[NUM_TEXTURE_TARGETS]; + /** Fallback texture used when a bound texture is incomplete */ + struct gl_texture_object *FallbackTex; + /** * \name Thread safety and statechange notification for texture * objects. diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 9b8d3777fb..89ee69770e 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -662,6 +662,59 @@ _mesa_test_texobj_completeness( const GLcontext *ctx, } } + +/** + * Return pointer to a default/fallback texture. + * The texture is a 2D 8x8 RGBA texture with all texels = (0,0,0,1). + * That's the value a sampler should get when sampling from an + * incomplete texture. + */ +struct gl_texture_object * +_mesa_get_fallback_texture(GLcontext *ctx) +{ + if (!ctx->Shared->FallbackTex) { + /* create fallback texture now */ + static GLubyte texels[8 * 8][4]; + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GLuint i; + + for (i = 0; i < 8 * 8; i++) { + texels[i][0] = + texels[i][1] = + texels[i][2] = 0x0; + texels[i][3] = 0xff; + } + + /* create texture object */ + texObj = ctx->Driver.NewTextureObject(ctx, 0, GL_TEXTURE_2D); + assert(texObj->RefCount == 1); + texObj->MinFilter = GL_NEAREST; + texObj->MagFilter = GL_NEAREST; + + /* create level[0] texture image */ + texImage = _mesa_get_tex_image(ctx, texObj, GL_TEXTURE_2D, 0); + + /* init the image fields */ + _mesa_init_teximage_fields(ctx, GL_TEXTURE_2D, texImage, + 8, 8, 1, 0, GL_RGBA); + + /* set image data */ + ctx->Driver.TexImage2D(ctx, GL_TEXTURE_2D, 0, GL_RGBA, + 8, 8, 0, + GL_RGBA, GL_UNSIGNED_BYTE, texels, + &ctx->DefaultPacking, texObj, texImage); + + _mesa_test_texobj_completeness(ctx, texObj); + assert(texObj->_Complete); + + ctx->Shared->FallbackTex = texObj; + } + return ctx->Shared->FallbackTex; +} + + + /*@}*/ diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h index d5374c5d6c..2599c0816a 100644 --- a/src/mesa/main/texobj.h +++ b/src/mesa/main/texobj.h @@ -65,6 +65,9 @@ extern void _mesa_test_texobj_completeness( const GLcontext *ctx, struct gl_texture_object *obj ); +extern struct gl_texture_object * +_mesa_get_fallback_texture(GLcontext *ctx); + extern void _mesa_unlock_context_textures( GLcontext *ctx ); diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index cef58d7a49..89da4335a2 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -561,8 +561,13 @@ update_texture_state( GLcontext *ctx ) } if (!texUnit->_ReallyEnabled) { - _mesa_reference_texobj(&texUnit->_Current, NULL); - continue; + /* If we get here it means the shader (or fixed-function state) + * is expecting a texture object, but there isn't one (or it's + * incomplete). Use the fallback texture. + */ + struct gl_texture_object *texObj = _mesa_get_fallback_texture(ctx); + texUnit->_ReallyEnabled = 1 << TEXTURE_2D_INDEX; + _mesa_reference_texobj(&texUnit->_Current, texObj); } /* if we get here, we know this texture unit is enabled */ -- cgit v1.2.3 From ad0514b24df196e40d5ba7bb41f3bacce0b86a31 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 21 May 2009 09:52:33 -0600 Subject: vbo: return VP_NONE from get_program_mode() if running fixed-func vertex program If we're running a vertex program to emulated fixed-function, we still need to treat vertex arrays/attributes as if we're in fixed-function mode. This should probably be back-ported to Mesa 7.5 after a bit more testing. (cherry picked from commit dda82137d28aba846dda73da230871c115e30aaf) --- src/mesa/vbo/vbo_context.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/mesa/vbo/vbo_context.h b/src/mesa/vbo/vbo_context.h index bf405eb693..5c85161caa 100644 --- a/src/mesa/vbo/vbo_context.h +++ b/src/mesa/vbo/vbo_context.h @@ -102,6 +102,8 @@ static INLINE GLuint get_program_mode( GLcontext *ctx ) { if (!ctx->VertexProgram._Current) return VP_NONE; + else if (ctx->VertexProgram._Current == ctx->VertexProgram._TnlProgram) + return VP_NONE; else if (ctx->VertexProgram._Current->IsNVProgram) return VP_NV; else -- cgit v1.2.3 From 19ca5ee1db002db48fd3d2ff665670a9bc8d699b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 21 May 2009 10:05:04 -0600 Subject: mesa: fix some potential state-restore issues in pop_texture_group() Call the _mesa_set_enable() functions instead of driver functions, etc. Also, add missing code for 1D/2D texture arrays. (cherry picked from commit aac19609bfd7c950b2577489b06886c8a8097bb2) --- src/mesa/main/attrib.c | 90 +++++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index e43fa96dd3..a609199504 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 7.3 + * Version: 7.6 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * Copyright (C) 2009 VMware, Inc. All Rights Reserved. @@ -541,6 +541,7 @@ end: static void pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable) { + const GLuint curTexUnitSave = ctx->Texture.CurrentUnit; GLuint i; #define TEST_AND_UPDATE(VALUE, NEWVALUE, ENUM) \ @@ -685,59 +686,51 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable) /* texture unit enables */ for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { - if (ctx->Texture.Unit[i].Enabled != enable->Texture[i]) { - ctx->Texture.Unit[i].Enabled = enable->Texture[i]; - if (ctx->Driver.Enable) { - if (ctx->Driver.ActiveTexture) { - (*ctx->Driver.ActiveTexture)(ctx, i); - } - (*ctx->Driver.Enable)( ctx, GL_TEXTURE_1D, - (GLboolean) (enable->Texture[i] & TEXTURE_1D_BIT) ); - (*ctx->Driver.Enable)( ctx, GL_TEXTURE_2D, - (GLboolean) (enable->Texture[i] & TEXTURE_2D_BIT) ); - (*ctx->Driver.Enable)( ctx, GL_TEXTURE_3D, - (GLboolean) (enable->Texture[i] & TEXTURE_3D_BIT) ); - if (ctx->Extensions.ARB_texture_cube_map) - (*ctx->Driver.Enable)( ctx, GL_TEXTURE_CUBE_MAP_ARB, - (GLboolean) (enable->Texture[i] & TEXTURE_CUBE_BIT) ); - if (ctx->Extensions.NV_texture_rectangle) - (*ctx->Driver.Enable)( ctx, GL_TEXTURE_RECTANGLE_NV, - (GLboolean) (enable->Texture[i] & TEXTURE_RECT_BIT) ); + const GLbitfield enabled = enable->Texture[i]; + const GLbitfield genEnabled = enable->TexGen[i]; + + if (ctx->Texture.Unit[i].Enabled != enabled) { + _mesa_ActiveTextureARB(GL_TEXTURE0 + i); + + _mesa_set_enable(ctx, GL_TEXTURE_1D, + (enabled & TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_2D, + (enabled & TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_3D, + (enabled & TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE); + if (ctx->Extensions.NV_texture_rectangle) { + _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE_ARB, + (enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE); + } + if (ctx->Extensions.ARB_texture_cube_map) { + _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP, + (enabled & TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE); + } + if (ctx->Extensions.MESA_texture_array) { + _mesa_set_enable(ctx, GL_TEXTURE_1D_ARRAY_EXT, + (enabled & TEXTURE_1D_ARRAY_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_2D_ARRAY_EXT, + (enabled & TEXTURE_2D_ARRAY_BIT) ? GL_TRUE : GL_FALSE); } } - if (ctx->Texture.Unit[i].TexGenEnabled != enable->TexGen[i]) { - ctx->Texture.Unit[i].TexGenEnabled = enable->TexGen[i]; - if (ctx->Driver.Enable) { - if (ctx->Driver.ActiveTexture) { - (*ctx->Driver.ActiveTexture)(ctx, i); - } - if (enable->TexGen[i] & S_BIT) - (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_S, GL_TRUE); - else - (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_S, GL_FALSE); - if (enable->TexGen[i] & T_BIT) - (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_T, GL_TRUE); - else - (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_T, GL_FALSE); - if (enable->TexGen[i] & R_BIT) - (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_R, GL_TRUE); - else - (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_R, GL_FALSE); - if (enable->TexGen[i] & Q_BIT) - (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_Q, GL_TRUE); - else - (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_Q, GL_FALSE); - } + if (ctx->Texture.Unit[i].TexGenEnabled != genEnabled) { + _mesa_ActiveTextureARB(GL_TEXTURE0 + i); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, + (genEnabled & S_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, + (genEnabled & T_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, + (genEnabled & R_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, + (genEnabled & Q_BIT) ? GL_TRUE : GL_FALSE); } /* GL_SGI_texture_color_table */ ctx->Texture.Unit[i].ColorTableEnabled = enable->TextureColorTable[i]; } - if (ctx->Driver.ActiveTexture) { - (*ctx->Driver.ActiveTexture)(ctx, ctx->Texture.CurrentUnit); - } + _mesa_ActiveTextureARB(GL_TEXTURE0 + curTexUnitSave); } @@ -770,6 +763,13 @@ pop_texture_group(GLcontext *ctx, struct texture_state *texstate) _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE_NV, (unit->Enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE); } + if (ctx->Extensions.MESA_texture_array) { + _mesa_set_enable(ctx, GL_TEXTURE_1D_ARRAY_EXT, + (unit->Enabled & TEXTURE_1D_ARRAY_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_2D_ARRAY_EXT, + (unit->Enabled & TEXTURE_2D_ARRAY_BIT) ? GL_TRUE : GL_FALSE); + } + if (ctx->Extensions.SGI_texture_color_table) { _mesa_set_enable(ctx, GL_TEXTURE_COLOR_TABLE_SGI, unit->ColorTableEnabled); -- cgit v1.2.3 From 810df8317dfe30c573cfb8296e569f73d23b74a7 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 21 May 2009 17:03:21 -0600 Subject: mesa: s/MAX_VERTEX_PROGRAM_ATTRIBS/MAX_NV_VERTEX_PROGRAM_INPUTS (cherry picked from commit d2a74d76c96957cf0294dcf40d29526621ada95e) --- src/mesa/main/varray.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 0882e8f37a..8f6621ee45 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -538,7 +538,7 @@ _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); - if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) { + if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) { _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(index)"); return; } -- cgit v1.2.3 From 54f425b5cefd1e40f315a4f8747b9a3db29ab9d4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 May 2009 07:26:08 -0600 Subject: mesa: rename MAX_VERTEX_ATTRIBS to MAX_VERTEX_GENERIC_ATTRIBS Be clearer that this is the number of generic vertex program/shader attributes, not counting the legacy attributes (pos, normal, color, etc). (cherry picked from commit 4a95185c9f30c2de7a03bb1a0653f51b53b1111d) --- src/mesa/main/api_noop.c | 16 ++++++++-------- src/mesa/main/config.h | 2 +- src/mesa/main/dlist.c | 24 ++++++++++++------------ src/mesa/main/enums.c | 10 +++++----- src/mesa/shader/slang/slang_link.c | 8 ++++---- src/mesa/vbo/vbo_attrib_tmp.h | 16 ++++++++-------- src/mesa/vbo/vbo_exec_array.c | 4 ++-- 7 files changed, 40 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/mesa/main/api_noop.c b/src/mesa/main/api_noop.c index a1cc3a2a4b..66f9c4e6bd 100644 --- a/src/mesa/main/api_noop.c +++ b/src/mesa/main/api_noop.c @@ -477,7 +477,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib4fvNV( GLuint index, const GLfloat static void GLAPIENTRY _mesa_noop_VertexAttrib1fARB( GLuint index, GLfloat x ) { GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_ATTRIBS) { + if (index < MAX_VERTEX_GENERIC_ATTRIBS) { ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, 0, 0, 1); } else @@ -487,7 +487,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib1fARB( GLuint index, GLfloat x ) static void GLAPIENTRY _mesa_noop_VertexAttrib1fvARB( GLuint index, const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_ATTRIBS) { + if (index < MAX_VERTEX_GENERIC_ATTRIBS) { ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], 0, 0, 1); } else @@ -497,7 +497,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib1fvARB( GLuint index, const GLfloa static void GLAPIENTRY _mesa_noop_VertexAttrib2fARB( GLuint index, GLfloat x, GLfloat y ) { GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_ATTRIBS) { + if (index < MAX_VERTEX_GENERIC_ATTRIBS) { ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, 0, 1); } else @@ -507,7 +507,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib2fARB( GLuint index, GLfloat x, GL static void GLAPIENTRY _mesa_noop_VertexAttrib2fvARB( GLuint index, const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_ATTRIBS) { + if (index < MAX_VERTEX_GENERIC_ATTRIBS) { ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], 0, 1); } else @@ -518,7 +518,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib3fARB( GLuint index, GLfloat x, GLfloat y, GLfloat z ) { GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_ATTRIBS) { + if (index < MAX_VERTEX_GENERIC_ATTRIBS) { ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, z, 1); } else @@ -528,7 +528,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib3fARB( GLuint index, GLfloat x, static void GLAPIENTRY _mesa_noop_VertexAttrib3fvARB( GLuint index, const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_ATTRIBS) { + if (index < MAX_VERTEX_GENERIC_ATTRIBS) { ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], v[2], 1); } else @@ -539,7 +539,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib4fARB( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) { GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_ATTRIBS) { + if (index < MAX_VERTEX_GENERIC_ATTRIBS) { ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, z, w); } else @@ -549,7 +549,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib4fARB( GLuint index, GLfloat x, static void GLAPIENTRY _mesa_noop_VertexAttrib4fvARB( GLuint index, const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_ATTRIBS) { + if (index < MAX_VERTEX_GENERIC_ATTRIBS) { ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], v[2], v[3]); } else diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index bd66a4c231..aecea689af 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -215,7 +215,7 @@ /** For GL_ARB_vertex_shader */ /*@{*/ -#define MAX_VERTEX_ATTRIBS 16 +#define MAX_VERTEX_GENERIC_ATTRIBS 16 #define MAX_VERTEX_TEXTURE_IMAGE_UNITS MAX_TEXTURE_IMAGE_UNITS #define MAX_COMBINED_TEXTURE_IMAGE_UNITS MAX_TEXTURE_IMAGE_UNITS /*@}*/ diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 537ff5881f..0bd7c3d9a1 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -4974,7 +4974,7 @@ save_Attr1fARB(GLenum attr, GLfloat x) n[2].f = x; } - ASSERT(attr < MAX_VERTEX_ATTRIBS); + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 1; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1); @@ -4996,7 +4996,7 @@ save_Attr2fARB(GLenum attr, GLfloat x, GLfloat y) n[3].f = y; } - ASSERT(attr < MAX_VERTEX_ATTRIBS); + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 2; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1); @@ -5019,7 +5019,7 @@ save_Attr3fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z) n[4].f = z; } - ASSERT(attr < MAX_VERTEX_ATTRIBS); + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 3; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1); @@ -5043,7 +5043,7 @@ save_Attr4fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) n[5].f = w; } - ASSERT(attr < MAX_VERTEX_ATTRIBS); + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 4; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w); @@ -5582,7 +5582,7 @@ save_VertexAttrib4fvNV(GLuint index, const GLfloat * v) static void GLAPIENTRY save_VertexAttrib1fARB(GLuint index, GLfloat x) { - if (index < MAX_VERTEX_ATTRIBS) + if (index < MAX_VERTEX_GENERIC_ATTRIBS) save_Attr1fARB(index, x); else index_error(); @@ -5591,7 +5591,7 @@ save_VertexAttrib1fARB(GLuint index, GLfloat x) static void GLAPIENTRY save_VertexAttrib1fvARB(GLuint index, const GLfloat * v) { - if (index < MAX_VERTEX_ATTRIBS) + if (index < MAX_VERTEX_GENERIC_ATTRIBS) save_Attr1fARB(index, v[0]); else index_error(); @@ -5600,7 +5600,7 @@ save_VertexAttrib1fvARB(GLuint index, const GLfloat * v) static void GLAPIENTRY save_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y) { - if (index < MAX_VERTEX_ATTRIBS) + if (index < MAX_VERTEX_GENERIC_ATTRIBS) save_Attr2fARB(index, x, y); else index_error(); @@ -5609,7 +5609,7 @@ save_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y) static void GLAPIENTRY save_VertexAttrib2fvARB(GLuint index, const GLfloat * v) { - if (index < MAX_VERTEX_ATTRIBS) + if (index < MAX_VERTEX_GENERIC_ATTRIBS) save_Attr2fARB(index, v[0], v[1]); else index_error(); @@ -5618,7 +5618,7 @@ save_VertexAttrib2fvARB(GLuint index, const GLfloat * v) static void GLAPIENTRY save_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z) { - if (index < MAX_VERTEX_ATTRIBS) + if (index < MAX_VERTEX_GENERIC_ATTRIBS) save_Attr3fARB(index, x, y, z); else index_error(); @@ -5627,7 +5627,7 @@ save_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z) static void GLAPIENTRY save_VertexAttrib3fvARB(GLuint index, const GLfloat * v) { - if (index < MAX_VERTEX_ATTRIBS) + if (index < MAX_VERTEX_GENERIC_ATTRIBS) save_Attr3fARB(index, v[0], v[1], v[2]); else index_error(); @@ -5637,7 +5637,7 @@ static void GLAPIENTRY save_VertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { - if (index < MAX_VERTEX_ATTRIBS) + if (index < MAX_VERTEX_GENERIC_ATTRIBS) save_Attr4fARB(index, x, y, z, w); else index_error(); @@ -5646,7 +5646,7 @@ save_VertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z, static void GLAPIENTRY save_VertexAttrib4fvARB(GLuint index, const GLfloat * v) { - if (index < MAX_VERTEX_ATTRIBS) + if (index < MAX_VERTEX_GENERIC_ATTRIBS) save_Attr4fARB(index, v[0], v[1], v[2], v[3]); else index_error(); diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c index c077bc0a89..cf893fdac5 100644 --- a/src/mesa/main/enums.c +++ b/src/mesa/main/enums.c @@ -948,8 +948,8 @@ LONGSTRING static const char enum_string_table[] = "GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV\0" "GL_MAX_VARYING_FLOATS\0" "GL_MAX_VARYING_FLOATS_ARB\0" - "GL_MAX_VERTEX_ATTRIBS\0" - "GL_MAX_VERTEX_ATTRIBS_ARB\0" + "GL_MAX_VERTEX_GENERIC_ATTRIBS\0" + "GL_MAX_VERTEX_GENERIC_ATTRIBS_ARB\0" "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS\0" "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB\0" "GL_MAX_VERTEX_UNIFORM_COMPONENTS\0" @@ -2772,8 +2772,8 @@ static const enum_elt all_enums[1820] = { 19417, 0x0000862E }, /* GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */ { 19452, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS */ { 19474, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS_ARB */ - { 19500, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS */ - { 19522, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS_ARB */ + { 19500, 0x00008869 }, /* GL_MAX_VERTEX_GENERIC_ATTRIBS */ + { 19522, 0x00008869 }, /* GL_MAX_VERTEX_GENERIC_ATTRIBS_ARB */ { 19548, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */ { 19582, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ { 19620, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */ @@ -4733,7 +4733,7 @@ static const unsigned reduced_enums[1319] = 317, /* GL_CURRENT_QUERY */ 1259, /* GL_QUERY_RESULT */ 1261, /* GL_QUERY_RESULT_AVAILABLE */ - 912, /* GL_MAX_VERTEX_ATTRIBS */ + 912, /* GL_MAX_VERTEX_GENERIC_ATTRIBS */ 1778, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */ 368, /* GL_DEPTH_STENCIL_TO_RGBA_NV */ 367, /* GL_DEPTH_STENCIL_TO_BGRA_NV */ diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index 1fdf4db054..8c9fe1ea1f 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -319,7 +319,7 @@ _slang_resolve_attributes(struct gl_shader_program *shProg, const struct gl_program *origProg, struct gl_program *linkedProg) { - GLint attribMap[MAX_VERTEX_ATTRIBS]; + GLint attribMap[MAX_VERTEX_GENERIC_ATTRIBS]; GLuint i, j; GLbitfield usedAttributes; /* generics only, not legacy attributes */ @@ -355,7 +355,7 @@ _slang_resolve_attributes(struct gl_shader_program *shProg, } /* initialize the generic attribute map entries to -1 */ - for (i = 0; i < MAX_VERTEX_ATTRIBS; i++) { + for (i = 0; i < MAX_VERTEX_GENERIC_ATTRIBS; i++) { attribMap[i] = -1; } @@ -396,11 +396,11 @@ _slang_resolve_attributes(struct gl_shader_program *shProg, * Start at 1 since generic attribute 0 always aliases * glVertex/position. */ - for (attr = 0; attr < MAX_VERTEX_ATTRIBS; attr++) { + for (attr = 0; attr < MAX_VERTEX_GENERIC_ATTRIBS; attr++) { if (((1 << attr) & usedAttributes) == 0) break; } - if (attr == MAX_VERTEX_ATTRIBS) { + if (attr == MAX_VERTEX_GENERIC_ATTRIBS) { link_error(shProg, "Too many vertex attributes"); return GL_FALSE; } diff --git a/src/mesa/vbo/vbo_attrib_tmp.h b/src/mesa/vbo/vbo_attrib_tmp.h index ff11c7d59a..7a889b8e2f 100644 --- a/src/mesa/vbo/vbo_attrib_tmp.h +++ b/src/mesa/vbo/vbo_attrib_tmp.h @@ -265,7 +265,7 @@ static void GLAPIENTRY TAG(VertexAttrib1fARB)( GLuint index, GLfloat x ) GET_CURRENT_CONTEXT( ctx ); if (index == 0) ATTR1F(0, x); - else if (index < MAX_VERTEX_ATTRIBS) + else if (index < MAX_VERTEX_GENERIC_ATTRIBS) ATTR1F(VBO_ATTRIB_GENERIC0 + index, x); else ERROR(); @@ -277,7 +277,7 @@ static void GLAPIENTRY TAG(VertexAttrib1fvARB)( GLuint index, GET_CURRENT_CONTEXT( ctx ); if (index == 0) ATTR1FV(0, v); - else if (index < MAX_VERTEX_ATTRIBS) + else if (index < MAX_VERTEX_GENERIC_ATTRIBS) ATTR1FV(VBO_ATTRIB_GENERIC0 + index, v); else ERROR(); @@ -289,7 +289,7 @@ static void GLAPIENTRY TAG(VertexAttrib2fARB)( GLuint index, GLfloat x, GET_CURRENT_CONTEXT( ctx ); if (index == 0) ATTR2F(0, x, y); - else if (index < MAX_VERTEX_ATTRIBS) + else if (index < MAX_VERTEX_GENERIC_ATTRIBS) ATTR2F(VBO_ATTRIB_GENERIC0 + index, x, y); else ERROR(); @@ -301,7 +301,7 @@ static void GLAPIENTRY TAG(VertexAttrib2fvARB)( GLuint index, GET_CURRENT_CONTEXT( ctx ); if (index == 0) ATTR2FV(0, v); - else if (index < MAX_VERTEX_ATTRIBS) + else if (index < MAX_VERTEX_GENERIC_ATTRIBS) ATTR2FV(VBO_ATTRIB_GENERIC0 + index, v); else ERROR(); @@ -313,7 +313,7 @@ static void GLAPIENTRY TAG(VertexAttrib3fARB)( GLuint index, GLfloat x, GET_CURRENT_CONTEXT( ctx ); if (index == 0) ATTR3F(0, x, y, z); - else if (index < MAX_VERTEX_ATTRIBS) + else if (index < MAX_VERTEX_GENERIC_ATTRIBS) ATTR3F(VBO_ATTRIB_GENERIC0 + index, x, y, z); else ERROR(); @@ -325,7 +325,7 @@ static void GLAPIENTRY TAG(VertexAttrib3fvARB)( GLuint index, GET_CURRENT_CONTEXT( ctx ); if (index == 0) ATTR3FV(0, v); - else if (index < MAX_VERTEX_ATTRIBS) + else if (index < MAX_VERTEX_GENERIC_ATTRIBS) ATTR3FV(VBO_ATTRIB_GENERIC0 + index, v); else ERROR(); @@ -338,7 +338,7 @@ static void GLAPIENTRY TAG(VertexAttrib4fARB)( GLuint index, GLfloat x, GET_CURRENT_CONTEXT( ctx ); if (index == 0) ATTR4F(0, x, y, z, w); - else if (index < MAX_VERTEX_ATTRIBS) + else if (index < MAX_VERTEX_GENERIC_ATTRIBS) ATTR4F(VBO_ATTRIB_GENERIC0 + index, x, y, z, w); else ERROR(); @@ -350,7 +350,7 @@ static void GLAPIENTRY TAG(VertexAttrib4fvARB)( GLuint index, GET_CURRENT_CONTEXT( ctx ); if (index == 0) ATTR4FV(0, v); - else if (index < MAX_VERTEX_ATTRIBS) + else if (index < MAX_VERTEX_GENERIC_ATTRIBS) ATTR4FV(VBO_ATTRIB_GENERIC0 + index, v); else ERROR(); diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 65fe197a4d..de66cdd92f 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -118,7 +118,7 @@ static void bind_array_obj( GLcontext *ctx ) for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) exec->array.legacy_array[VERT_ATTRIB_TEX0 + i] = &arrayObj->TexCoord[i]; - for (i = 0; i < MAX_VERTEX_ATTRIBS; i++) { + for (i = 0; i < MAX_VERTEX_GENERIC_ATTRIBS; i++) { assert(i < Elements(arrayObj->VertexAttrib)); assert(i < Elements(exec->array.generic_array)); exec->array.generic_array[i] = &arrayObj->VertexAttrib[i]; @@ -219,7 +219,7 @@ static void recalculate_input_bindings( GLcontext *ctx ) } } - for (i = 0; i < MAX_VERTEX_ATTRIBS; i++) { + for (i = 0; i < MAX_VERTEX_GENERIC_ATTRIBS; i++) { if (exec->array.generic_array[i]->Enabled) inputs[VERT_ATTRIB_GENERIC0 + i] = exec->array.generic_array[i]; else { -- cgit v1.2.3 From a5b7e0c7d73949e24d4edb1ab09b0aff367132a5 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 May 2009 07:19:27 -0600 Subject: mesa: s/MAX_VERTEX_PROGRAM_ATTRIBS/MAX_NV_VERTEX_PROGRAM_INPUTS/ in NV funcs (cherry picked from commit 4dc426c01627a240bd5b148c1804c45b0d5ecd6c) --- src/mesa/main/dlist.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 0bd7c3d9a1..782f847904 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -5506,7 +5506,7 @@ index_error(void) static void GLAPIENTRY save_VertexAttrib1fNV(GLuint index, GLfloat x) { - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) save_Attr1fNV(index, x); else index_error(); @@ -5515,7 +5515,7 @@ save_VertexAttrib1fNV(GLuint index, GLfloat x) static void GLAPIENTRY save_VertexAttrib1fvNV(GLuint index, const GLfloat * v) { - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) save_Attr1fNV(index, v[0]); else index_error(); @@ -5524,7 +5524,7 @@ save_VertexAttrib1fvNV(GLuint index, const GLfloat * v) static void GLAPIENTRY save_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y) { - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) save_Attr2fNV(index, x, y); else index_error(); @@ -5533,7 +5533,7 @@ save_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y) static void GLAPIENTRY save_VertexAttrib2fvNV(GLuint index, const GLfloat * v) { - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) save_Attr2fNV(index, v[0], v[1]); else index_error(); @@ -5542,7 +5542,7 @@ save_VertexAttrib2fvNV(GLuint index, const GLfloat * v) static void GLAPIENTRY save_VertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z) { - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) save_Attr3fNV(index, x, y, z); else index_error(); @@ -5551,7 +5551,7 @@ save_VertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z) static void GLAPIENTRY save_VertexAttrib3fvNV(GLuint index, const GLfloat * v) { - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) save_Attr3fNV(index, v[0], v[1], v[2]); else index_error(); @@ -5561,7 +5561,7 @@ static void GLAPIENTRY save_VertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) save_Attr4fNV(index, x, y, z, w); else index_error(); @@ -5570,7 +5570,7 @@ save_VertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y, static void GLAPIENTRY save_VertexAttrib4fvNV(GLuint index, const GLfloat * v) { - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) save_Attr4fNV(index, v[0], v[1], v[2], v[3]); else index_error(); -- cgit v1.2.3 From 19218fe71269d03e1a2e9fcfd0c06a9adb5cb21d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 9 Jun 2009 15:07:39 -0600 Subject: i965: added intelFlush() call in intel_get_tex_image() Fixes the render-to-texture test in progs/tests/getteximage.c (cherry picked from commit a03b349153660e449daf4f56d750f1caef23b1a5) --- src/mesa/drivers/dri/intel/intel_tex_image.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c index 66a3b4e492..5e61e9e95e 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_image.c +++ b/src/mesa/drivers/dri/intel/intel_tex_image.c @@ -637,6 +637,12 @@ intel_get_tex_image(GLcontext * ctx, GLenum target, GLint level, struct intel_context *intel = intel_context(ctx); struct intel_texture_image *intelImage = intel_texture_image(texImage); + /* If we're reading from a texture that has been rendered to, need to + * make sure rendering is complete. + * We could probably predicate this on texObj->_RenderToTexture + */ + intelFlush(ctx); + /* Map */ if (intelImage->mt) { /* Image is stored in hardware format in a buffer managed by the -- cgit v1.2.3 From 0584b6e433753dd01101c6824f6f6336c40d0f1f Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Thu, 11 Jun 2009 12:09:10 +0200 Subject: intel: intel_texture_drawpixels() can't handle GL_DEPTH_STENCIL. Fixes glean depthStencil test. (cherry picked from commit 3885b708fdbb7bbd5dd3a247c41fb9a75ee7c057) --- src/mesa/drivers/dri/intel/intel_pixel_draw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/intel/intel_pixel_draw.c b/src/mesa/drivers/dri/intel/intel_pixel_draw.c index 225c5f48a5..d80069dd58 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_draw.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_draw.c @@ -97,7 +97,7 @@ intel_texture_drawpixels(GLcontext * ctx, /* We don't have a way to generate fragments with stencil values which * will set the resulting stencil value. */ - if (format == GL_STENCIL_INDEX) + if (format == GL_STENCIL_INDEX || format == GL_DEPTH_STENCIL) return GL_FALSE; /* Check that we can load in a texture this big. */ -- cgit v1.2.3 From 9d367d43b2fddb9a27d4be6302da172ab773ca91 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Sat, 6 Jun 2009 14:46:22 -0400 Subject: Disable SGI_swap_control extension for DRI2 We currently don't have support for SGI_swap_control for direct contexts with DRI2, so disable reporting the extension. Reporting the extension, and then having glXSwapIntervalSGI() "succeed" but do nothing can confuse applications. https://bugs.freedesktop.org/show_bug.cgi?id=22123 (cherry picked from commit 279143c6e808b37c333321b696d80df77f709a04) --- src/glx/x11/dri_common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/glx/x11/dri_common.c b/src/glx/x11/dri_common.c index 90c3d8c7d9..6de4111113 100644 --- a/src/glx/x11/dri_common.c +++ b/src/glx/x11/dri_common.c @@ -345,7 +345,9 @@ driBindExtensions(__GLXscreenConfigs *psc, int dri2) #endif #ifdef __DRI_SWAP_CONTROL - if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0) { + /* No DRI2 support for swap_control at the moment, since SwapBuffers + * is done by the X server */ + if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0 && !dri2) { psc->swapControl = (__DRIswapControlExtension *) extensions[i]; __glXEnableDirectExtension(psc, "GLX_SGI_swap_control"); __glXEnableDirectExtension(psc, "GLX_MESA_swap_control"); -- cgit v1.2.3 From 2f184d0d9f4600a20022887674b77f45ee6b728e Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 16 Jun 2009 21:38:58 +0200 Subject: i965: handle OPCODE_SWZ in the glsl path glsl compiler will not generate OPCODE_SWZ, and as a first step it would be translated away to a MOV anyway (why?), but later internally this opcode is generated (for EXT_texture_swizzling). (cherry picked from commit 4ef1f8e3b52a06fcf58f78c9c36738531b91dbac) --- src/mesa/drivers/dri/i965/brw_wm_glsl.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c index 875683e0aa..094c1af2fe 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c +++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c @@ -2681,6 +2681,7 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c) emit_trunc(c, inst); break; case OPCODE_MOV: + case OPCODE_SWZ: emit_mov(c, inst); break; case OPCODE_DP3: -- cgit v1.2.3 From c25534f30d326c15dff845775d9bd55ba6064049 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 24 Jun 2009 14:46:07 +0100 Subject: wgl: Handle flush after a window is destroyed. Fixes assertion failure with conform. --- src/gallium/state_trackers/wgl/shared/stw_device.c | 41 +++++++++++----------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/wgl/shared/stw_device.c b/src/gallium/state_trackers/wgl/shared/stw_device.c index 1b4a2d5cdb..ce46624146 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_device.c +++ b/src/gallium/state_trackers/wgl/shared/stw_device.c @@ -67,35 +67,36 @@ stw_flush_frontbuffer(struct pipe_screen *screen, struct stw_framebuffer *fb; fb = stw_framebuffer_from_hdc( hdc ); - assert(fb); - if (fb == NULL) - return; - - pipe_mutex_lock( fb->mutex ); + /* fb can be NULL if window was destroyed already */ + if (fb) { + pipe_mutex_lock( fb->mutex ); #if DEBUG - { - struct pipe_surface *surface2; - - if(!st_get_framebuffer_surface( fb->stfb, ST_SURFACE_FRONT_LEFT, &surface2 )) - assert(0); - else - assert(surface2 == surface); - } + { + struct pipe_surface *surface2; + + if(!st_get_framebuffer_surface( fb->stfb, ST_SURFACE_FRONT_LEFT, &surface2 )) + assert(0); + else + assert(surface2 == surface); + } #endif #ifdef DEBUG - if(stw_dev->trace_running) { - screen = trace_screen(screen)->screen; - surface = trace_surface(surface)->surface; - } + if(stw_dev->trace_running) { + screen = trace_screen(screen)->screen; + surface = trace_surface(surface)->surface; + } #endif + } stw_winsys->flush_frontbuffer(screen, surface, hdc); - stw_framebuffer_update(fb); - - pipe_mutex_unlock( fb->mutex ); + if(fb) { + stw_framebuffer_update(fb); + + pipe_mutex_unlock( fb->mutex ); + } } -- cgit v1.2.3