From c5e473fbe25b20cb27aac44ff6e269701abd33a8 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Mon, 16 Apr 2012 04:56:12 +0200 Subject: mesa: add gl_context::NewDriverState and use it for vertex arrays The vbo module recomputes its states if _NEW_ARRAY is set, so it shouldn't use the same flag to notify the driver. Since we've run out of bits in NewState and NewState is for core Mesa anyway, we need to find another way. This patch is the first to start decoupling the state flags meant only for core Mesa and those only for drivers. The idea is to have two flag sets: - gl_context::NewState - used by core Mesa only - gl_context::NewDriverState - used by drivers only (the flags are defined by the driver and opaque to core Mesa) It makes perfect sense to use NewState|=_NEW_ARRAY to notify the vbo module that the user changed vertex arrays, and the vbo module in turn sets a driver-specific flag to notify the driver that it should update its vertex array bindings. The driver decides which bits of NewDriverState should be set and stores them in gl_context::DriverFlags. Then, Core Mesa can do this: ctx->NewDriverState |= ctx->DriverFlags.NewArray; This patch implements this behavior and adapts st/mesa. DriverFlags.NewArray is set to ST_NEW_VERTEX_ARRAYS. Core Mesa only sets NewDriverState. It's the driver's responsibility to read it whenever it wants and reset it to 0. Reviewed-by: Brian Paul --- src/mesa/state_tracker/st_draw.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 01ba09d6567..42dc3757615 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -981,13 +981,19 @@ st_draw_vbo(struct gl_context *ctx, const struct gl_client_array **arrays = ctx->Array._DrawArrays; unsigned i, num_instances = 1; unsigned max_index_plus_base; - GLboolean new_array = - st->dirty.st && - (st->dirty.mesa & (_NEW_ARRAY | _NEW_PROGRAM | _NEW_BUFFER_OBJECT)) != 0; + GLboolean new_array; /* Mesa core state should have been validated already */ assert(ctx->NewState == 0x0); + /* Get Mesa driver state. */ + st->dirty.st |= ctx->NewDriverState; + ctx->NewDriverState = 0; + + new_array = + (st->dirty.st & (ST_NEW_VERTEX_ARRAYS | ST_NEW_VERTEX_PROGRAM)) || + (st->dirty.mesa & (_NEW_PROGRAM | _NEW_BUFFER_OBJECT)) != 0; + if (ib) { int max_base_vertex = 0; -- cgit v1.2.3