summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2009-08-24 16:39:25 -0400
committerZack Rusin <[email protected]>2009-08-24 16:39:25 -0400
commitcd5c7bfd93bf207d28610a484b732b8d3eca6059 (patch)
tree61725df97ac4015709bc7c869e01401fcb0d3d93 /src/mesa
parent534c13302291c07a44afd528f4c758ced4296db5 (diff)
parent4bccd693a72a0b42dffc849034263a68e779ca91 (diff)
Merge branch 'master' of ssh://[email protected]/git/mesa/mesa
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/r600/r600_context.c8
-rw-r--r--src/mesa/drivers/dri/r600/r700_chip.c74
-rw-r--r--src/mesa/drivers/dri/r600/r700_render.c7
-rw-r--r--src/mesa/glapi/glapi.c111
-rw-r--r--src/mesa/glapi/glapi.h5
-rw-r--r--src/mesa/glapi/glthread.h2
-rw-r--r--src/mesa/shader/arbprogram.c3
-rw-r--r--src/mesa/shader/prog_parameter_layout.c12
-rw-r--r--src/mesa/shader/prog_parameter_layout.h3
-rw-r--r--src/mesa/shader/program_parse.tab.c12
-rw-r--r--src/mesa/shader/program_parse.y12
-rw-r--r--src/mesa/shader/slang/slang_builtin.c2
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c16
-rw-r--r--src/mesa/vbo/vbo_exec_draw.c2
14 files changed, 179 insertions, 90 deletions
diff --git a/src/mesa/drivers/dri/r600/r600_context.c b/src/mesa/drivers/dri/r600/r600_context.c
index 0b0c4f5049b..6a066f35105 100644
--- a/src/mesa/drivers/dri/r600/r600_context.c
+++ b/src/mesa/drivers/dri/r600/r600_context.c
@@ -185,13 +185,7 @@ static void r600_vtbl_emit_cs_header(struct radeon_cs *cs, radeonContextPtr rmes
static void r600_vtbl_pre_emit_atoms(radeonContextPtr radeon)
{
- context_t *context = (context_t *)radeon;
-
- /* always emit CB base to prevent
- * lock ups on some chips.
- */
- R600_STATECHANGE(context, cb_target);
- r700Start3D(context);
+ r700Start3D((context_t *)radeon);
}
static void r600_fallback(GLcontext *ctx, GLuint bit, GLboolean mode)
diff --git a/src/mesa/drivers/dri/r600/r700_chip.c b/src/mesa/drivers/dri/r600/r700_chip.c
index 3f11cf2c981..16f1a3df366 100644
--- a/src/mesa/drivers/dri/r600/r700_chip.c
+++ b/src/mesa/drivers/dri/r600/r700_chip.c
@@ -230,6 +230,9 @@ static void r700SendVTXState(GLcontext *ctx, struct radeon_state_atom *atom)
unsigned int i, j = 0;
BATCH_LOCALS(&context->radeon);
+ if (context->radeon.tcl.aos_count == 0)
+ return;
+
BEGIN_BATCH_NO_AUTOSTATE(6);
R600_OUT_BATCH(CP_PACKET3(R600_IT_SET_CTL_CONST, 1));
R600_OUT_BATCH(mmSQ_VTX_BASE_VTX_LOC - ASIC_CTL_CONST_BASE_INDEX);
@@ -989,11 +992,60 @@ static int check_always(GLcontext *ctx, struct radeon_state_atom *atom)
return atom->cmd_size;
}
+static int check_cb(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+ context_t *context = R700_CONTEXT(ctx);
+ int count = 7;
+
+ if (context->radeon.radeonScreen->chip_family < CHIP_FAMILY_RV770)
+ count += 11;
+
+ return count;
+}
+
+static int check_blnd(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+ context_t *context = R700_CONTEXT(ctx);
+ R700_CHIP_CONTEXT *r700 = (R700_CHIP_CONTEXT*)(&context->hw);
+ unsigned int ui;
+ int count = 3;
+
+ if (context->radeon.radeonScreen->chip_family < CHIP_FAMILY_RV770)
+ count += 3;
+
+ if (context->radeon.radeonScreen->chip_family > CHIP_FAMILY_R600) {
+ for (ui = 0; ui < R700_MAX_RENDER_TARGETS; ui++) {
+ if (r700->render_target[ui].enabled)
+ count += 3;
+ }
+ }
+
+ return count;
+}
+
+static int check_ucp(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+ context_t *context = R700_CONTEXT(ctx);
+ R700_CHIP_CONTEXT *r700 = (R700_CHIP_CONTEXT*)(&context->hw);
+ int i;
+ int count = 0;
+
+ for (i = 0; i < R700_MAX_UCP; i++) {
+ if (r700->ucp[i].enabled)
+ count += 6;
+ }
+ return count;
+}
+
static int check_vtx(GLcontext *ctx, struct radeon_state_atom *atom)
{
context_t *context = R700_CONTEXT(ctx);
+ int count = context->radeon.tcl.aos_count * 18;
+
+ if (count)
+ count += 6;
- return context->radeon.tcl.aos_count * 18;
+ return count;
}
static int check_tx(GLcontext *ctx, struct radeon_state_atom *atom)
@@ -1014,16 +1066,24 @@ static int check_ps_consts(GLcontext *ctx, struct radeon_state_atom *atom)
{
context_t *context = R700_CONTEXT(ctx);
R700_CHIP_CONTEXT *r700 = (R700_CHIP_CONTEXT*)(&context->hw);
+ int count = r700->ps.num_consts * 4;
- return 2 + (r700->ps.num_consts * 4);
+ if (count)
+ count += 2;
+
+ return count;
}
static int check_vs_consts(GLcontext *ctx, struct radeon_state_atom *atom)
{
context_t *context = R700_CONTEXT(ctx);
R700_CHIP_CONTEXT *r700 = (R700_CHIP_CONTEXT*)(&context->hw);
+ int count = r700->vs.num_consts * 4;
+
+ if (count)
+ count += 2;
- return 2 + (r700->vs.num_consts * 4);
+ return count;
}
#define ALLOC_STATE( ATOM, CHK, SZ, EMIT ) \
@@ -1056,12 +1116,12 @@ void r600InitAtoms(context_t *context)
ALLOC_STATE(aa, always, 12, r700SendAAState);
ALLOC_STATE(cl, always, 12, r700SendCLState);
ALLOC_STATE(gb, always, 6, r700SendGBState);
- ALLOC_STATE(ucp, always, 36, r700SendUCPState);
+ ALLOC_STATE(ucp, ucp, (R700_MAX_UCP * 6), r700SendUCPState);
ALLOC_STATE(su, always, 9, r700SendSUState);
ALLOC_STATE(poly, always, 10, r700SendPolyState);
- ALLOC_STATE(cb, always, 18, r700SendCBState);
+ ALLOC_STATE(cb, cb, 18, r700SendCBState);
ALLOC_STATE(clrcmp, always, 6, r700SendCBCLRCMPState);
- ALLOC_STATE(blnd, always, 30, r700SendCBBlendState);
+ ALLOC_STATE(blnd, blnd, (6 + (R700_MAX_RENDER_TARGETS * 3)), r700SendCBBlendState);
ALLOC_STATE(blnd_clr, always, 6, r700SendCBBlendColorState);
ALLOC_STATE(cb_target, always, 25, r700SendRenderTargetState);
ALLOC_STATE(sx, always, 9, r700SendSXState);
@@ -1073,7 +1133,7 @@ void r600InitAtoms(context_t *context)
ALLOC_STATE(ps, always, 21, r700SendPSState);
ALLOC_STATE(vs_consts, vs_consts, (2 + (R700_MAX_DX9_CONSTS * 4)), r700SendVSConsts);
ALLOC_STATE(ps_consts, ps_consts, (2 + (R700_MAX_DX9_CONSTS * 4)), r700SendPSConsts);
- ALLOC_STATE(vtx, vtx, (VERT_ATTRIB_MAX * 18), r700SendVTXState);
+ ALLOC_STATE(vtx, vtx, (6 + (VERT_ATTRIB_MAX * 18)), r700SendVTXState);
ALLOC_STATE(tx, tx, (R700_TEXTURE_NUMBERUNITS * 20), r700SendTexState);
ALLOC_STATE(tx_smplr, tx, (R700_TEXTURE_NUMBERUNITS * 5), r700SendTexSamplerState);
ALLOC_STATE(tx_brdr_clr, tx, (R700_TEXTURE_NUMBERUNITS * 6), r700SendTexBorderColorState);
diff --git a/src/mesa/drivers/dri/r600/r700_render.c b/src/mesa/drivers/dri/r600/r700_render.c
index 9c4be37aaca..cdf3220a7f3 100644
--- a/src/mesa/drivers/dri/r600/r700_render.c
+++ b/src/mesa/drivers/dri/r600/r700_render.c
@@ -315,6 +315,13 @@ static GLboolean r700RunRender(GLcontext * ctx,
rcommonEnsureCmdBufSpace(&context->radeon,
radeon->hw.max_state_size + ind_count, __FUNCTION__);
+ /* always emit CB base to prevent
+ * lock ups on some chips.
+ */
+ R600_STATECHANGE(context, cb_target);
+ /* mark vtx as dirty since it changes per-draw */
+ R600_STATECHANGE(context, vtx);
+
r700UpdateShaders(ctx);
r700SetScissor(context);
r700SetupVertexProgram(ctx);
diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c
index 2b105d0f17d..4bb10df1d84 100644
--- a/src/mesa/glapi/glapi.c
+++ b/src/mesa/glapi/glapi.c
@@ -160,26 +160,20 @@ static GLint NoOpUnused(void)
* the variables \c _glapi_Dispatch and \c _glapi_Context are used for this
* purpose.
*
- * In the "normal" threaded case, the variables \c _glapi_Dispatch and
- * \c _glapi_Context will be \c NULL if an application is detected as being
- * multithreaded. Single-threaded applications will use \c _glapi_Dispatch
- * and \c _glapi_Context just like the case without any threading support.
- * When \c _glapi_Dispatch and \c _glapi_Context are \c NULL, the thread state
- * data \c _gl_DispatchTSD and \c ContextTSD are used. Drivers and the
- * static dispatch functions access these variables via \c _glapi_get_dispatch
- * and \c _glapi_get_context.
+ * In the "normal" threaded case, the variable \c _glapi_SingleThreaded will be
+ * \c GL_FALSE if an application is detected as being multithreaded.
+ * Single-threaded applications will use \c _glapi_Dispatch and \c
+ * _glapi_Context just like the case without any threading support. When \c
+ * _glapi_SingleThreaded is \c GL_FALSE, the thread state data \c
+ * _gl_DispatchTSD and \c ContextTSD are used. Drivers and the static dispatch
+ * functions access these variables via \c _glapi_get_dispatch and \c
+ * _glapi_get_context.
*
- * There is a race condition in setting \c _glapi_Dispatch to \c NULL. It is
- * possible for the original thread to be setting it at the same instant a new
- * thread, perhaps running on a different processor, is clearing it. Because
- * of that, \c ThreadSafe, which can only ever be changed to \c GL_TRUE, is
- * used to determine whether or not the application is multithreaded.
- *
* In the TLS case, the variables \c _glapi_Dispatch and \c _glapi_Context are
* hardcoded to \c NULL. Instead the TLS variables \c _glapi_tls_Dispatch and
- * \c _glapi_tls_Context are used. Having \c _glapi_Dispatch and
- * \c _glapi_Context be hardcoded to \c NULL maintains binary compatability
- * between TLS enabled loaders and non-TLS DRI drivers.
+ * \c _glapi_tls_Context are used. The variable \c _glapi_SingleThreaded,
+ * though not used, is defined and hardcoded to \c GL_FALSE to maintain binary
+ * compatability between TLS enabled loaders and non-TLS DRI drivers.
*/
/*@{*/
#if defined(GLX_USE_TLS)
@@ -194,13 +188,26 @@ PUBLIC __thread void * _glapi_tls_Context
PUBLIC const struct _glapi_table *_glapi_Dispatch = NULL;
PUBLIC const void *_glapi_Context = NULL;
+/* Unused, but maintain binary compatability with non-TLS DRI drivers */
+GLboolean _glapi_SingleThreaded = GL_FALSE;
+
#else
#if defined(THREADS)
-static GLboolean ThreadSafe = GL_FALSE; /**< In thread-safe mode? */
-_glthread_TSD _gl_DispatchTSD; /**< Per-thread dispatch pointer */
-static _glthread_TSD ContextTSD; /**< Per-thread context pointer */
+#ifdef WIN32_THREADS
+/* _glthread_DECLARE_STATIC_MUTEX is broken on windows. There will be race! */
+#define CHECK_MULTITHREAD_LOCK()
+#define CHECK_MULTITHREAD_UNLOCK()
+#else
+_glthread_DECLARE_STATIC_MUTEX(ThreadCheckMutex);
+#define CHECK_MULTITHREAD_LOCK() _glthread_LOCK_MUTEX(ThreadCheckMutex)
+#define CHECK_MULTITHREAD_UNLOCK() _glthread_UNLOCK_MUTEX(ThreadCheckMutex)
+#endif
+
+GLboolean _glapi_SingleThreaded = GL_TRUE; /**< In single-thread mode? */
+_glthread_TSD _gl_DispatchTSD; /**< Per-thread dispatch pointer */
+static _glthread_TSD ContextTSD; /**< Per-thread context pointer */
#if defined(WIN32_THREADS)
void FreeTSD(_glthread_TSD *p);
@@ -231,23 +238,30 @@ void
_glapi_check_multithread(void)
{
#if defined(THREADS) && !defined(GLX_USE_TLS)
- if (!ThreadSafe) {
- static unsigned long knownID;
- static GLboolean firstCall = GL_TRUE;
- if (firstCall) {
- knownID = _glthread_GetID();
- firstCall = GL_FALSE;
- }
- else if (knownID != _glthread_GetID()) {
- ThreadSafe = GL_TRUE;
- _glapi_set_dispatch(NULL);
- _glapi_set_context(NULL);
- }
+ static unsigned long knownID;
+ static GLboolean firstCall = GL_TRUE;
+
+ if (!_glapi_SingleThreaded)
+ return;
+
+ CHECK_MULTITHREAD_LOCK();
+ if (firstCall) {
+ /* initialize TSDs */
+ (void) _glthread_GetTSD(&ContextTSD);
+ (void) _glthread_GetTSD(&_gl_DispatchTSD);
+
+ knownID = _glthread_GetID();
+ firstCall = GL_FALSE;
}
- else if (!_glapi_get_dispatch()) {
- /* make sure that this thread's dispatch pointer isn't null */
- _glapi_set_dispatch(NULL);
+ else if (knownID != _glthread_GetID()) {
+ /*
+ * switch to thread-safe mode. _glapi_Context and _glapi_Dispatch are no
+ * longer accessed after this point, except for raced by the first
+ * thread. Because of the race, they cannot be reset to NULL.
+ */
+ _glapi_SingleThreaded = GL_FALSE;
}
+ CHECK_MULTITHREAD_UNLOCK();
#endif
}
@@ -265,8 +279,10 @@ _glapi_set_context(void *context)
#if defined(GLX_USE_TLS)
_glapi_tls_Context = context;
#elif defined(THREADS)
+ if (_glapi_SingleThreaded)
+ _glapi_Context = context;
+ /* always update TSD because we might switch to it at any time */
_glthread_SetTSD(&ContextTSD, context);
- _glapi_Context = (ThreadSafe) ? NULL : context;
#else
_glapi_Context = context;
#endif
@@ -285,12 +301,8 @@ _glapi_get_context(void)
#if defined(GLX_USE_TLS)
return _glapi_tls_Context;
#elif defined(THREADS)
- if (ThreadSafe) {
- return _glthread_GetTSD(&ContextTSD);
- }
- else {
- return _glapi_Context;
- }
+ return (_glapi_SingleThreaded)
+ ? _glapi_Context : _glthread_GetTSD(&ContextTSD);
#else
return _glapi_Context;
#endif
@@ -505,8 +517,9 @@ _glapi_set_dispatch(struct _glapi_table *dispatch)
#if defined(GLX_USE_TLS)
_glapi_tls_Dispatch = dispatch;
#elif defined(THREADS)
+ if (_glapi_SingleThreaded)
+ _glapi_Dispatch = dispatch;
_glthread_SetTSD(&_gl_DispatchTSD, (void *) dispatch);
- _glapi_Dispatch = (ThreadSafe) ? NULL : dispatch;
#else /*THREADS*/
_glapi_Dispatch = dispatch;
#endif /*THREADS*/
@@ -520,17 +533,15 @@ _glapi_set_dispatch(struct _glapi_table *dispatch)
PUBLIC struct _glapi_table *
_glapi_get_dispatch(void)
{
- struct _glapi_table * api;
#if defined(GLX_USE_TLS)
- api = _glapi_tls_Dispatch;
+ return _glapi_tls_Dispatch;
#elif defined(THREADS)
- api = (ThreadSafe)
- ? (struct _glapi_table *) _glthread_GetTSD(&_gl_DispatchTSD)
- : _glapi_Dispatch;
+ return (_glapi_SingleThreaded)
+ ? _glapi_Dispatch
+ : (struct _glapi_table *) _glthread_GetTSD(&_gl_DispatchTSD);
#else
- api = _glapi_Dispatch;
+ return _glapi_Dispatch;
#endif
- return api;
}
diff --git a/src/mesa/glapi/glapi.h b/src/mesa/glapi/glapi.h
index 8f2cf662183..b2a1fe6ee93 100644
--- a/src/mesa/glapi/glapi.h
+++ b/src/mesa/glapi/glapi.h
@@ -94,7 +94,10 @@ extern void *_glapi_Context;
extern struct _glapi_table *_glapi_Dispatch;
# ifdef THREADS
-# define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context())
+/* this variable is here only for quick access to current context/dispatch */
+extern GLboolean _glapi_SingleThreaded;
+# define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) \
+ ((_glapi_SingleThreaded) ? _glapi_Context : _glapi_get_context())
# else
# define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_Context
# endif
diff --git a/src/mesa/glapi/glthread.h b/src/mesa/glapi/glthread.h
index 8ec933a8514..a36bea71762 100644
--- a/src/mesa/glapi/glthread.h
+++ b/src/mesa/glapi/glthread.h
@@ -322,7 +322,7 @@ extern __thread struct _glapi_table * _glapi_tls_Dispatch
#elif !defined(GL_CALL)
# if defined(THREADS)
# define GET_DISPATCH() \
- ((__builtin_expect( _glapi_Dispatch != NULL, 1 )) \
+ ((__builtin_expect(_glapi_SingleThreaded, 1)) \
? _glapi_Dispatch : _glapi_get_dispatch())
# else
# define GET_DISPATCH() _glapi_Dispatch
diff --git a/src/mesa/shader/arbprogram.c b/src/mesa/shader/arbprogram.c
index 39136efadac..4d8cff07001 100644
--- a/src/mesa/shader/arbprogram.c
+++ b/src/mesa/shader/arbprogram.c
@@ -1001,6 +1001,9 @@ _mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params)
_mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(pname)");
return;
}
+ } else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(pname)");
+ return;
}
}
diff --git a/src/mesa/shader/prog_parameter_layout.c b/src/mesa/shader/prog_parameter_layout.c
index 8f2b3062203..1c37b3a7a5a 100644
--- a/src/mesa/shader/prog_parameter_layout.c
+++ b/src/mesa/shader/prog_parameter_layout.c
@@ -106,7 +106,11 @@ copy_indirect_accessed_array(struct gl_program_parameter_list *src,
}
-int
+/**
+ * XXX description???
+ * \return GL_TRUE for success, GL_FALSE for failure
+ */
+GLboolean
_mesa_layout_parameters(struct asm_parser_state *state)
{
struct gl_program_parameter_list *layout;
@@ -128,12 +132,12 @@ _mesa_layout_parameters(struct asm_parser_state *state)
*/
if (!inst->SrcReg[i].Symbol->pass1_done) {
const int new_begin =
- copy_indirect_accessed_array(state->prog->Parameters, layout,
+ copy_indirect_accessed_array(state->prog->Parameters, layout,
inst->SrcReg[i].Symbol->param_binding_begin,
inst->SrcReg[i].Symbol->param_binding_length);
if (new_begin < 0) {
- return 0;
+ return GL_FALSE;
}
inst->SrcReg[i].Symbol->param_binding_begin = new_begin;
@@ -209,5 +213,5 @@ _mesa_layout_parameters(struct asm_parser_state *state)
_mesa_free_parameter_list(state->prog->Parameters);
state->prog->Parameters = layout;
- return 1;
+ return GL_TRUE;
}
diff --git a/src/mesa/shader/prog_parameter_layout.h b/src/mesa/shader/prog_parameter_layout.h
index 1686170bab5..99a7b6c7266 100644
--- a/src/mesa/shader/prog_parameter_layout.h
+++ b/src/mesa/shader/prog_parameter_layout.h
@@ -36,6 +36,7 @@
extern unsigned _mesa_combine_swizzles(unsigned base, unsigned applied);
struct asm_parser_state;
-extern int _mesa_layout_parameters(struct asm_parser_state *state);
+
+extern GLboolean _mesa_layout_parameters(struct asm_parser_state *state);
#endif /* PROG_PARAMETER_LAYOUT_H */
diff --git a/src/mesa/shader/program_parse.tab.c b/src/mesa/shader/program_parse.tab.c
index dbed448113e..5c604c2fd1f 100644
--- a/src/mesa/shader/program_parse.tab.c
+++ b/src/mesa/shader/program_parse.tab.c
@@ -5156,12 +5156,12 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, const GLubyte *str,
? & ctx->Const.VertexProgram
: & ctx->Const.FragmentProgram;
- state->MaxTextureImageUnits = 16;
- state->MaxTextureCoordUnits = 8;
- state->MaxTextureUnits = 8;
- state->MaxClipPlanes = 6;
- state->MaxLights = 8;
- state->MaxProgramMatrices = 8;
+ state->MaxTextureImageUnits = ctx->Const.MaxTextureImageUnits;
+ state->MaxTextureCoordUnits = ctx->Const.MaxTextureCoordUnits;
+ state->MaxTextureUnits = ctx->Const.MaxTextureUnits;
+ state->MaxClipPlanes = ctx->Const.MaxClipPlanes;
+ state->MaxLights = ctx->Const.MaxLights;
+ state->MaxProgramMatrices = ctx->Const.MaxProgramMatrices;
state->state_param_enum = (target == GL_VERTEX_PROGRAM_ARB)
? STATE_VERTEX_PROGRAM : STATE_FRAGMENT_PROGRAM;
diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y
index 89e88502121..e2e83e484f5 100644
--- a/src/mesa/shader/program_parse.y
+++ b/src/mesa/shader/program_parse.y
@@ -2287,12 +2287,12 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, const GLubyte *str,
? & ctx->Const.VertexProgram
: & ctx->Const.FragmentProgram;
- state->MaxTextureImageUnits = 16;
- state->MaxTextureCoordUnits = 8;
- state->MaxTextureUnits = 8;
- state->MaxClipPlanes = 6;
- state->MaxLights = 8;
- state->MaxProgramMatrices = 8;
+ state->MaxTextureImageUnits = ctx->Const.MaxTextureImageUnits;
+ state->MaxTextureCoordUnits = ctx->Const.MaxTextureCoordUnits;
+ state->MaxTextureUnits = ctx->Const.MaxTextureUnits;
+ state->MaxClipPlanes = ctx->Const.MaxClipPlanes;
+ state->MaxLights = ctx->Const.MaxLights;
+ state->MaxProgramMatrices = ctx->Const.MaxProgramMatrices;
state->state_param_enum = (target == GL_VERTEX_PROGRAM_ARB)
? STATE_VERTEX_PROGRAM : STATE_FRAGMENT_PROGRAM;
diff --git a/src/mesa/shader/slang/slang_builtin.c b/src/mesa/shader/slang/slang_builtin.c
index ad2e306c19e..bef0f856534 100644
--- a/src/mesa/shader/slang/slang_builtin.c
+++ b/src/mesa/shader/slang/slang_builtin.c
@@ -436,7 +436,7 @@ emit_statevars(const char *name, int array_len,
struct gl_program_parameter_list *paramList)
{
if (type->type == SLANG_SPEC_ARRAY) {
- GLint i, pos;
+ GLint i, pos = -1;
assert(array_len > 0);
if (strcmp(name, "gl_ClipPlane") == 0) {
tokens[0] = STATE_CLIPPLANE;
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index 8709633557c..ccf972f8055 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -94,6 +94,9 @@ struct bitmap_cache
GLfloat color[4];
+ /** Bitmap's Z position */
+ GLfloat zpos;
+
struct pipe_texture *texture;
struct pipe_transfer *trans;
@@ -104,6 +107,8 @@ struct bitmap_cache
};
+/** Epsilon for Z comparisons */
+#define Z_EPSILON 1e-06
/**
@@ -538,9 +543,7 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
}
/* draw textured quad */
- offset = setup_bitmap_vertex_data(st, x, y, width, height,
- ctx->Current.RasterPos[2],
- color);
+ offset = setup_bitmap_vertex_data(st, x, y, width, height, z, color);
util_draw_vertex_buffer(pipe, st->bitmap.vbuf, offset,
PIPE_PRIM_TRIANGLE_FAN,
@@ -647,7 +650,7 @@ st_flush_bitmap_cache(struct st_context *st)
draw_bitmap_quad(st->ctx,
cache->xpos,
cache->ypos,
- st->ctx->Current.RasterPos[2],
+ cache->zpos,
BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT,
cache->texture,
cache->color);
@@ -687,6 +690,7 @@ accum_bitmap(struct st_context *st,
{
struct bitmap_cache *cache = st->bitmap.cache;
int px = -999, py;
+ const GLfloat z = st->ctx->Current.RasterPos[2];
if (width > BITMAP_CACHE_WIDTH ||
height > BITMAP_CACHE_HEIGHT)
@@ -697,7 +701,8 @@ accum_bitmap(struct st_context *st,
py = y - cache->ypos;
if (px < 0 || px + width > BITMAP_CACHE_WIDTH ||
py < 0 || py + height > BITMAP_CACHE_HEIGHT ||
- !TEST_EQ_4V(st->ctx->Current.RasterColor, cache->color)) {
+ !TEST_EQ_4V(st->ctx->Current.RasterColor, cache->color) ||
+ ((fabs(z - cache->zpos) > Z_EPSILON))) {
/* This bitmap would extend beyond cache bounds, or the bitmap
* color is changing
* so flush and continue.
@@ -712,6 +717,7 @@ accum_bitmap(struct st_context *st,
py = (BITMAP_CACHE_HEIGHT - height) / 2;
cache->xpos = x;
cache->ypos = y - py;
+ cache->zpos = z;
cache->empty = GL_FALSE;
COPY_4FV(cache->color, st->ctx->Current.RasterColor);
}
diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index d76c45f3560..625452ac09a 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -398,7 +398,7 @@ vbo_exec_vtx_flush( struct vbo_exec_context *exec, GLboolean unmap )
vbo_exec_vtx_unmap( exec );
}
- if (unmap)
+ if (unmap || exec->vtx.vertex_size == 0)
exec->vtx.max_vert = 0;
else
exec->vtx.max_vert = ((VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used) /