Module: Mesa Branch: master Commit: 67cd0f97030a358777c01ee6ad79926717dfdf42 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=67cd0f97030a358777c01ee6ad79926717dfdf42
Author: Paul Berry <stereotype...@gmail.com> Date: Tue May 7 14:55:42 2013 -0700 i965/gen7+: Resolve color buffers when necessary. Resolve color buffers that have been fast-color cleared: 1. before texturing from the buffer (brw_predraw_resolve_buffers()) 2. before using the buffer as the source in a blorp blit (brw_blorp_blit_miptrees()) 3. before mapping the buffer's miptree (intel_miptree_map_raw(), intel_texsubimage_tiled_memcpy()) 4. before accessing the buffer using the hardware blitter (intel_miptree_blit(), do_blit_bitmap()) v2: Rework based on the fact that we have decided not to use an accessor function to protect access to the region. Reviewed-by: Eric Anholt <e...@anholt.net> --- src/mesa/drivers/dri/i965/brw_blorp_blit.cpp | 7 +++++++ src/mesa/drivers/dri/i965/brw_blorp_clear.cpp | 1 + src/mesa/drivers/dri/i965/brw_draw.c | 6 +++++- src/mesa/drivers/dri/intel/intel_blit.c | 11 +++++++++-- src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 5 +++++ src/mesa/drivers/dri/intel/intel_pixel_bitmap.c | 5 +++++ src/mesa/drivers/dri/intel/intel_tex_subimage.c | 5 +++++ 7 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp index a6b2bbf..7b063ff 100644 --- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp +++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp @@ -134,6 +134,13 @@ brw_blorp_blit_miptrees(struct intel_context *intel, float dst_x1, float dst_y1, bool mirror_x, bool mirror_y) { + /* Get ready to blit. This includes depth resolving the src and dst + * buffers if necessary. Note: it's not necessary to do a color resolve on + * the destination buffer because we use the standard render path to render + * to destination color buffers, and the standard render path is + * fast-color-aware. + */ + intel_miptree_resolve_color(intel, src_mt); intel_miptree_slice_resolve_depth(intel, src_mt, src_level, src_layer); intel_miptree_slice_resolve_depth(intel, dst_mt, dst_level, dst_layer); diff --git a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp index 1e2205e..85449bd 100644 --- a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp +++ b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp @@ -507,6 +507,7 @@ void brw_blorp_resolve_color(struct intel_context *intel, struct intel_mipmap_tree *mt) { struct brw_context *brw = brw_context(&intel->ctx); + brw_blorp_rt_resolve_params params(brw, mt); brw_blorp_exec(intel, ¶ms); mt->mcs_state = INTEL_MCS_STATE_RESOLVED; diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index 657d6ee..5730eed 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -41,6 +41,7 @@ #include "swrast_setup/swrast_setup.h" #include "drivers/common/meta.h" +#include "brw_blorp.h" #include "brw_draw.h" #include "brw_defines.h" #include "brw_context.h" @@ -310,7 +311,9 @@ brw_predraw_resolve_buffers(struct brw_context *brw) if (depth_irb) intel_renderbuffer_resolve_hiz(intel, depth_irb); - /* Resolve depth buffer of each enabled depth texture. */ + /* Resolve depth buffer of each enabled depth texture, and color buffer of + * each fast-clear-enabled color texture. + */ for (int i = 0; i < BRW_MAX_TEX_UNIT; i++) { if (!ctx->Texture.Unit[i]._ReallyEnabled) continue; @@ -318,6 +321,7 @@ brw_predraw_resolve_buffers(struct brw_context *brw) if (!tex_obj || !tex_obj->mt) continue; intel_miptree_all_slices_resolve_depth(intel, tex_obj->mt); + intel_miptree_resolve_color(intel, tex_obj->mt); } } diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c index 1f6ad09..fffbef4 100644 --- a/src/mesa/drivers/dri/intel/intel_blit.c +++ b/src/mesa/drivers/dri/intel/intel_blit.c @@ -140,11 +140,13 @@ intel_miptree_blit(struct intel_context *intel, return false; } - /* The blitter has no idea about HiZ, so we need to get the real depth - * data into the two miptrees before we do anything. + /* The blitter has no idea about HiZ or fast color clears, so we need to + * resolve the miptrees before we do anything. */ intel_miptree_slice_resolve_depth(intel, src_mt, src_level, src_slice); intel_miptree_slice_resolve_depth(intel, dst_mt, dst_level, dst_slice); + intel_miptree_resolve_color(intel, src_mt); + intel_miptree_resolve_color(intel, dst_mt); if (src_flip) src_y = src_mt->level[src_level].height - src_y - height; @@ -368,6 +370,11 @@ intelClearWithBlit(struct gl_context *ctx, GLbitfield mask) GLbitfield fail_mask = 0; BATCH_LOCALS; + /* Note: we don't use this function on Gen7+ hardware, so we can safely + * ignore fast color clear issues. + */ + assert(intel->gen < 7); + /* * Compute values for clearing the buffers. */ diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index bf2c417..4c98e90 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -1616,6 +1616,11 @@ intel_miptree_upsample(struct intel_context *intel, void * intel_miptree_map_raw(struct intel_context *intel, struct intel_mipmap_tree *mt) { + /* CPU accesses to color buffers don't understand fast color clears, so + * resolve any pending fast color clears before we map. + */ + intel_miptree_resolve_color(intel, mt); + drm_intel_bo *bo = mt->region->bo; if (unlikely(INTEL_DEBUG & DEBUG_PERF)) { diff --git a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c index c82253a..8c0edf2 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c @@ -255,6 +255,11 @@ do_blit_bitmap( struct gl_context *ctx, #define DY 32 #define DX 32 + /* The blitter has no idea about fast color clears, so we need to resolve + * the miptree before we do anything. + */ + intel_miptree_resolve_color(intel, irb->mt); + /* Chop it all into chunks that can be digested by hardware: */ for (py = 0; py < height; py += DY) { for (px = 0; px < width; px += DX) { diff --git a/src/mesa/drivers/dri/intel/intel_tex_subimage.c b/src/mesa/drivers/dri/intel/intel_tex_subimage.c index bd178bb..f936e9b 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_subimage.c +++ b/src/mesa/drivers/dri/intel/intel_tex_subimage.c @@ -206,6 +206,11 @@ intel_texsubimage_tiled_memcpy(struct gl_context * ctx, return false; } + /* Since we are going to write raw data to the miptree, we need to resolve + * any pending fast color clears before we start. + */ + intel_miptree_resolve_color(intel, image->mt); + bo = image->mt->region->bo; if (drm_intel_bo_references(intel->batch.bo, bo)) { _______________________________________________ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit