diff options
author | Chad Versace <[email protected]> | 2011-11-15 18:20:39 -0800 |
---|---|---|
committer | Chad Versace <[email protected]> | 2011-11-22 10:50:50 -0800 |
commit | 3b0d295e122f8ca6e0ebe4593a1e0660308a18c3 (patch) | |
tree | 3057a2111d7eb5876910c380ac6bf3e5be831334 /src | |
parent | b95986729ef3522a65b7357aea99c6358f9d53c8 (diff) |
i965: Resolve buffers before drawing [v2]
Before emitting primitives in brw_try_draw_prims(), resolve the depth
buffer's HiZ buffer and resolve the depth buffer of each enabled depth
texture.
v2: [anholt] The driver no longer validates drm bo's, so update a comment
to reflect that.
Reviewed-by: Eric Anholt <[email protected]>
Signed-off-by: Chad Versace <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_draw.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index d2ae0877e8d..35196a7e1a0 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -44,6 +44,9 @@ #include "brw_state.h" #include "intel_batchbuffer.h" +#include "intel_fbo.h" +#include "intel_mipmap_tree.h" +#include "intel_regions.h" #define FILE_DEBUG_FLAG DEBUG_PRIMS @@ -287,6 +290,71 @@ static void brw_merge_inputs( struct brw_context *brw, brw->state.dirty.brw |= BRW_NEW_INPUT_DIMENSIONS; } +/* + * \brief Resolve buffers before drawing. + * + * Resolve the depth buffer's HiZ buffer and resolve the depth buffer of each + * enabled depth texture. + * + * (In the future, this will also perform MSAA resolves). + */ +static void +brw_predraw_resolve_buffers(struct brw_context *brw) +{ + struct gl_context *ctx = &brw->intel.ctx; + struct intel_context *intel = &brw->intel; + struct intel_renderbuffer *depth_irb; + struct intel_texture_object *tex_obj; + bool did_resolve = false; + + /* Avoid recursive HiZ op. */ + if (brw->hiz.op) { + return; + } + + /* Resolve the depth buffer's HiZ buffer. */ + depth_irb = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_DEPTH); + if (depth_irb && depth_irb->mt) { + did_resolve |= intel_renderbuffer_resolve_hiz(intel, depth_irb); + } + + /* Resolve depth buffer of each enabled depth texture. */ + for (int i = 0; i < BRW_MAX_TEX_UNIT; i++) { + if (!ctx->Texture.Unit[i]._ReallyEnabled) + continue; + tex_obj = intel_texture_object(ctx->Texture.Unit[i]._Current); + if (!tex_obj || !tex_obj->mt) + continue; + did_resolve |= intel_miptree_all_slices_resolve_depth(intel, tex_obj->mt); + } + + if (did_resolve) { + /* Call vbo_bind_array() to synchronize the vbo module's vertex + * attributes to the gl_context's. + * + * Details + * ------- + * The vbo module tracks vertex attributes separately from the + * gl_context. Specifically, the vbo module maintins vertex attributes + * in vbo_exec_context::array::inputs, which is synchronized with + * gl_context::Array::ArrayObj::VertexAttrib by vbo_bind_array(). + * vbo_draw_arrays() calls vbo_bind_array() to perform the + * synchronization before calling the real draw call, + * vbo_context::draw_arrays. + * + * At this point (after performing a resolve meta-op but before calling + * vbo_bind_array), the gl_context's vertex attributes have been + * restored to their original state (that is, their state before the + * meta-op began), but the vbo module's vertex attribute are those used + * in the last meta-op. Therefore we must manually synchronize the two with + * vbo_bind_array() before continuing with the original draw command. + */ + _mesa_update_state(ctx); + vbo_bind_arrays(ctx); + _mesa_update_state(ctx); + } +} + /* May fail if out of video memory for texture or vbo upload, or on * fallback conditions. */ @@ -316,6 +384,11 @@ static bool brw_try_draw_prims( struct gl_context *ctx, */ brw_validate_textures( brw ); + /* Resolves must occur after updating state and finalizing textures but + * before setting up any hardware state for this draw call. + */ + brw_predraw_resolve_buffers(brw); + /* Bind all inputs, derive varying and size information: */ brw_merge_inputs( brw, arrays ); |