From 2f7abf5c042a1bcf97d77d6dad4a17bda37e0567 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Oct 2009 16:26:54 -0600 Subject: i965: remove unused BRW_FALLBACK_TEXTURE bit The value was probably wrong too. It was the same as INTEL_FALLBACK_DRAW_BUFFER. --- src/mesa/drivers/dri/i965/brw_context.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index a5209ac41b..b7d6c7ce7e 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -115,7 +115,7 @@ * Handles blending and (presumably) depth and stencil testing. */ -#define BRW_FALLBACK_TEXTURE 0x1 + #define BRW_MAX_CURBE (32*16) struct brw_context; -- cgit v1.2.3 From f9bbbe5803a72eceb8ed6ddc73bb48c8bcdc0179 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Oct 2009 16:32:08 -0600 Subject: i965: remove unused brw_context::tmp_fallback field --- src/mesa/drivers/dri/i965/brw_context.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index b7d6c7ce7e..da0e091bfd 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -454,7 +454,6 @@ struct brw_context GLuint primitive; GLboolean emit_state_always; - GLboolean tmp_fallback; GLboolean no_batch_wrap; struct { -- cgit v1.2.3 From ea659f891740fab1943eca219ffbdd5ed3d1906c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Oct 2009 16:33:36 -0600 Subject: intel: Fallback field is a bitmask, use GLbitfield --- src/mesa/drivers/dri/i915/intel_tris.c | 8 ++++++-- src/mesa/drivers/dri/intel/intel_context.c | 2 +- src/mesa/drivers/dri/intel/intel_context.h | 9 +++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/i915/intel_tris.c b/src/mesa/drivers/dri/i915/intel_tris.c index a905455342..bc6b29281a 100644 --- a/src/mesa/drivers/dri/i915/intel_tris.c +++ b/src/mesa/drivers/dri/i915/intel_tris.c @@ -1194,12 +1194,16 @@ getFallbackString(GLuint bit) +/** + * Enable/disable a fallback flag. + * \param bit one of INTEL_FALLBACK_x flags. + */ void -intelFallback(struct intel_context *intel, GLuint bit, GLboolean mode) +intelFallback(struct intel_context *intel, GLbitfield bit, GLboolean mode) { GLcontext *ctx = &intel->ctx; TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint oldfallback = intel->Fallback; + const GLbitfield oldfallback = intel->Fallback; if (mode) { intel->Fallback |= bit; diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index c49f06e44a..d24af46f59 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -839,7 +839,7 @@ intelDestroyContext(__DRIcontextPrivate * driContextPriv) _vbo_DestroyContext(&intel->ctx); _swrast_DestroyContext(&intel->ctx); - intel->Fallback = 0; /* don't call _swrast_Flush later */ + intel->Fallback = 0x0; /* don't call _swrast_Flush later */ intel_batchbuffer_free(intel->batch); intel->batch = NULL; diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h index 03e7cf39d6..a9db8f6a2b 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++ b/src/mesa/drivers/dri/intel/intel_context.h @@ -61,6 +61,10 @@ typedef void (*intel_line_func) (struct intel_context *, intelVertex *, intelVertex *); typedef void (*intel_point_func) (struct intel_context *, intelVertex *); +/** + * Bits for intel->Fallback field + */ +/*@{*/ #define INTEL_FALLBACK_DRAW_BUFFER 0x1 #define INTEL_FALLBACK_READ_BUFFER 0x2 #define INTEL_FALLBACK_DEPTH_BUFFER 0x4 @@ -68,8 +72,9 @@ typedef void (*intel_point_func) (struct intel_context *, intelVertex *); #define INTEL_FALLBACK_USER 0x10 #define INTEL_FALLBACK_RENDERMODE 0x20 #define INTEL_FALLBACK_TEXTURE 0x40 +/*@}*/ -extern void intelFallback(struct intel_context *intel, GLuint bit, +extern void intelFallback(struct intel_context *intel, GLbitfield bit, GLboolean mode); #define FALLBACK( intel, bit, mode ) intelFallback( intel, bit, mode ) @@ -171,7 +176,7 @@ struct intel_context struct dri_metaops meta; GLint refcount; - GLuint Fallback; + GLbitfield Fallback; /**< mask of INTEL_FALLBACK_x bits */ GLuint NewGLState; dri_bufmgr *bufmgr; -- cgit v1.2.3 From c24466c34e7aeb8aeda2455f6a688b99c44b10e2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Oct 2009 16:45:03 -0600 Subject: intel: define INTEL_FALLBACK_DRIVER for drivers --- src/mesa/drivers/dri/intel/intel_context.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h index a9db8f6a2b..d3acf6e4b3 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++ b/src/mesa/drivers/dri/intel/intel_context.h @@ -72,6 +72,7 @@ typedef void (*intel_point_func) (struct intel_context *, intelVertex *); #define INTEL_FALLBACK_USER 0x10 #define INTEL_FALLBACK_RENDERMODE 0x20 #define INTEL_FALLBACK_TEXTURE 0x40 +#define INTEL_FALLBACK_DRIVER 0x1000 /**< first for drivers */ /*@}*/ extern void intelFallback(struct intel_context *intel, GLbitfield bit, -- cgit v1.2.3 From 8810b8f67135185d1044746bb861fe2ff997626c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Oct 2009 16:45:50 -0600 Subject: i965: fix hacked Fallback usage in brw_prepare_vertices() Setting intel->Fallback = 1 clobbered any fallback state that was already set. Not sure where this hack originated (the git history is a little convoluted). Define and use a new BRW_FALLBACK_DRAW bit instead. This shouldn't break anything and could potentially fix some bugs (but no specific ones are known). --- src/mesa/drivers/dri/i965/brw_context.h | 2 ++ src/mesa/drivers/dri/i965/brw_draw_upload.c | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index da0e091bfd..b1e7ec8465 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -116,6 +116,8 @@ */ +#define BRW_FALLBACK_DRAW (INTEL_FALLBACK_DRIVER << 0) + #define BRW_MAX_CURBE (32*16) struct brw_context; diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index 9d089e113e..4f8ceb37bd 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -375,9 +375,10 @@ static void brw_prepare_vertices(struct brw_context *brw) * isn't an issue at this point. */ if (brw->vb.nr_enabled >= BRW_VEP_MAX) { - intel->Fallback = 1; + FALLBACK(intel, BRW_FALLBACK_DRAW, GL_TRUE); return; } + FALLBACK(intel, BRW_FALLBACK_DRAW, GL_FALSE); for (i = 0; i < brw->vb.nr_enabled; i++) { struct brw_vertex_element *input = brw->vb.enabled[i]; @@ -427,9 +428,10 @@ static void brw_prepare_vertices(struct brw_context *brw) /* Position array not properly enabled: */ if (input->glarray->StrideB == 0) { - intel->Fallback = 1; + FALLBACK(intel, BRW_FALLBACK_DRAW, GL_TRUE); return; } + FALLBACK(intel, BRW_FALLBACK_DRAW, GL_FALSE); interleave = input->glarray->StrideB; ptr = input->glarray->Ptr; -- cgit v1.2.3 From 61a96a2ac72b3f071151de436a48c6ec985e3653 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Oct 2009 17:11:59 -0600 Subject: progs/xdemos: fix command line flag typo --- progs/xdemos/glsync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/progs/xdemos/glsync.c b/progs/xdemos/glsync.c index 34167d339f..da87306cf2 100644 --- a/progs/xdemos/glsync.c +++ b/progs/xdemos/glsync.c @@ -95,7 +95,7 @@ enum sync_type { static void usage(char *name) { printf("usage: %s [-w ] [-h ] [-s] " - "[-vc]\n", name); + "[-v]\n", name); printf("\t-s:\n"); printf("\t\tn: none\n"); printf("\t\ts: SGI video sync extension\n"); -- cgit v1.2.3 From 4837e01bcd3d011a38d75cc9f1eff629c3de6fd6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Oct 2009 18:16:10 -0600 Subject: mesa: code refactoring- new _mesa_finish(), _mesa_flush() --- src/mesa/main/context.c | 37 +++++++++++++++++++++++++++++-------- src/mesa/main/context.h | 8 ++++++++ 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index ac6540f4a0..e844a7432d 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1543,6 +1543,33 @@ _mesa_record_error(GLcontext *ctx, GLenum error) } +/** + * Flush commands and wait for completion. + */ +void +_mesa_finish(GLcontext *ctx) +{ + FLUSH_CURRENT( ctx, 0 ); + if (ctx->Driver.Finish) { + ctx->Driver.Finish(ctx); + } +} + + +/** + * Flush commands. + */ +void +_mesa_flush(GLcontext *ctx) +{ + FLUSH_CURRENT( ctx, 0 ); + if (ctx->Driver.Flush) { + ctx->Driver.Flush(ctx); + } +} + + + /** * Execute glFinish(). * @@ -1554,10 +1581,7 @@ _mesa_Finish(void) { GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - FLUSH_CURRENT( ctx, 0 ); - if (ctx->Driver.Finish) { - ctx->Driver.Finish(ctx); - } + _mesa_finish(ctx); } @@ -1572,10 +1596,7 @@ _mesa_Flush(void) { GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - FLUSH_CURRENT( ctx, 0 ); - if (ctx->Driver.Flush) { - ctx->Driver.Flush(ctx); - } + _mesa_flush(ctx); } diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index 5587695fa0..c3be1063f8 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -170,6 +170,14 @@ _mesa_valid_to_render(GLcontext *ctx, const char *where); extern void _mesa_record_error( GLcontext *ctx, GLenum error ); + +extern void +_mesa_finish(GLcontext *ctx); + +extern void +_mesa_flush(GLcontext *ctx); + + extern void GLAPIENTRY _mesa_Finish( void ); -- cgit v1.2.3 From 5e6a6a2719c695996490bde491dac267e52f78af Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Oct 2009 18:19:01 -0600 Subject: glx: don't destroy context immediately if it's currently bound According to the GLXDestroyContext() man page, the context should not immediately be destroyed if it's bound to some thread. Wait until it's unbound to really delete it. The code for doing the later part is already present in MakeContextCurrent() so no change was needed there. --- src/glx/x11/glxcmds.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c index cd4aede74e..c63116bab7 100644 --- a/src/glx/x11/glxcmds.c +++ b/src/glx/x11/glxcmds.c @@ -540,6 +540,16 @@ DestroyContext(Display * dpy, GLXContext gc) imported = gc->imported; gc->xid = None; + if (gc->currentDpy) { + /* This context is bound to some thread. According to the man page, + * we should not actually delete the context until it's unbound. + * Note that we set gc->xid = None above. In MakeContextCurrent() + * we check for that and delete the context there. + */ + __glXUnlock(); + return; + } + #ifdef GLX_DIRECT_RENDERING /* Destroy the direct rendering context */ if (gc->driContext) { -- cgit v1.2.3 From 55058652b886b95bfc24109a9edb04d274c01c1a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Oct 2009 18:32:48 -0600 Subject: intel: flush old context before binding new context Per the GLX spec, when changing rendering contexts, the old context should first be flushed. --- src/mesa/drivers/dri/intel/intel_context.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index d24af46f59..ddb0550f77 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -944,10 +944,23 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv, __DRIdrawablePrivate * driReadPriv) { __DRIscreenPrivate *psp = driDrawPriv->driScreenPriv; + struct intel_context *intel; + GET_CURRENT_CONTEXT(curCtx); + + if (driContextPriv) + intel = (struct intel_context *) driContextPriv->driverPrivate; + else + intel = NULL; + + /* According to the glXMakeCurrent() man page: "Pending commands to + * the previous context, if any, are flushed before it is released." + * But only flush if we're actually changing contexts. + */ + if (intel_context(curCtx) && intel_context(curCtx) != intel) { + _mesa_flush(curCtx); + } if (driContextPriv) { - struct intel_context *intel = - (struct intel_context *) driContextPriv->driverPrivate; struct intel_framebuffer *intel_fb = (struct intel_framebuffer *) driDrawPriv->driverPrivate; GLframebuffer *readFb = (GLframebuffer *) driReadPriv->driverPrivate; -- cgit v1.2.3