A common problem with using HiZ and multisampling is that surfaces need to resolved prior to use. Currently i965 does this inside its state update hook, but that is a comparatively heavyweight operation that need not be performed so frequently. The obvious solution (and therefore fraught with dragons) is to move the HiZ/color resolves into the brw_draw_prims() - however, the resolves are performed using meta and end up re-entering brw_draw_prims() corrupting the context state of the original call. To avoid the meta recursion, we can add a new callback (vbo->resolve()) into the vbo pipeline that is called just before vbo->draw().
Signed-off-by: Chris Wilson <ch...@chris-wilson.co.uk> Cc: Brian Paul <bri...@vmware.com> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Jason Ekstrand <jason.ekstr...@intel.com> Cc: Kenneth Graunke <kenn...@whitecape.org> Cc: Francisco Jerez <curroje...@riseup.net> --- src/mesa/vbo/vbo.h | 1 + src/mesa/vbo/vbo_context.c | 19 +++++++++++++++++++ src/mesa/vbo/vbo_context.h | 1 + src/mesa/vbo/vbo_exec_array.c | 1 + src/mesa/vbo/vbo_exec_draw.c | 5 ++++- src/mesa/vbo/vbo_save_draw.c | 2 ++ 6 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h index 2aaff5d..b64c468 100644 --- a/src/mesa/vbo/vbo.h +++ b/src/mesa/vbo/vbo.h @@ -89,6 +89,7 @@ vbo_initialize_save_dispatch(const struct gl_context *ctx, struct _glapi_table *exec); +typedef void (*vbo_resolve_func)( struct gl_context *ctx); typedef void (*vbo_draw_func)( struct gl_context *ctx, const struct _mesa_prim *prims, GLuint nr_prims, diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c index e3eb286..1f0b46a 100644 --- a/src/mesa/vbo/vbo_context.c +++ b/src/mesa/vbo/vbo_context.c @@ -148,11 +148,30 @@ static void init_mat_currval(struct gl_context *ctx) } +static void nop_resolve(struct gl_context *ctx) +{ +} + +static void nop_draw(struct gl_context *ctx, + const struct _mesa_prim *prims, + GLuint nr_prims, + const struct _mesa_index_buffer *ib, + GLboolean index_bounds_valid, + GLuint min_index, + GLuint max_index, + struct gl_transform_feedback_object *tfb_vertcount, + unsigned stream, + struct gl_buffer_object *indirect) +{ +} + GLboolean _vbo_CreateContext( struct gl_context *ctx ) { struct vbo_context *vbo = CALLOC_STRUCT(vbo_context); ctx->vbo_context = vbo; + vbo->draw_prims = nop_draw; + vbo->resolve = nop_resolve; /* Initialize the arrayelt helper */ diff --git a/src/mesa/vbo/vbo_context.h b/src/mesa/vbo/vbo_context.h index a376efe..c4033ee4 100644 --- a/src/mesa/vbo/vbo_context.h +++ b/src/mesa/vbo/vbo_context.h @@ -75,6 +75,7 @@ struct vbo_context { /* Callback into the driver. This must always succeed, the driver * is responsible for initiating any fallback actions required: */ + vbo_resolve_func resolve; vbo_draw_func draw_prims; }; diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 34d2c1d..d592ae4 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -549,6 +549,7 @@ vbo_bind_arrays(struct gl_context *ctx) struct vbo_context *vbo = vbo_context(ctx); struct vbo_exec_context *exec = &vbo->exec; + vbo->resolve(ctx); vbo_draw_method(vbo, DRAW_ARRAYS); if (exec->array.recalculate_inputs) { diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index 2bfb0c3..fa5b06b 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -388,11 +388,14 @@ vbo_exec_vtx_flush(struct vbo_exec_context *exec, GLboolean keepUnmapped) if (exec->vtx.copied.nr != exec->vtx.vert_count) { struct gl_context *ctx = exec->ctx; + + vbo_context(ctx)->resolve( ctx ); /* Before the update_state() as this may raise _NEW_VARYING_VP_INPUTS * from _mesa_set_varying_vp_inputs(). */ - vbo_exec_bind_arrays( ctx ); + vbo_draw_method( vbo_context(ctx), DRAW_BEGIN_END); + vbo_exec_bind_arrays( ctx ); if (ctx->NewState) _mesa_update_state( ctx ); diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index b1fd689..2103b8e 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -297,6 +297,8 @@ vbo_save_playback_vertex_list(struct gl_context *ctx, void *data) return; } + vbo_context(ctx)->resolve(ctx); + vbo_bind_vertex_list( ctx, node ); vbo_draw_method(vbo_context(ctx), DRAW_DISPLAY_LIST); -- 2.5.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev