Signed-off-by: Topi Pohjolainen <topi.pohjolai...@intel.com> --- src/mesa/drivers/dri/i965/brw_context.c | 101 ++++++++++++++++---------------- 1 file changed, 51 insertions(+), 50 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index f4ebaf2..746d754 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -322,6 +322,55 @@ brw_prepare_image_surfaces(struct gl_context *ctx) return flush; } +static enum intel_write_cache_flush_type +brw_prepare_framebuffer(struct gl_context *ctx) +{ + struct brw_context *brw = brw_context(ctx); + enum intel_write_cache_flush_type flush = INTEL_WRITE_CACHE_NO_FLUSH; + + /* Resolve color buffers for non-coherent framebuffer fetch. */ + const bool non_coherent_fb_fetch = + !ctx->Extensions.MESA_shader_framebuffer_fetch && + ctx->FragmentProgram._Current && + ctx->FragmentProgram._Current->info.outputs_read; + + /* If FRAMEBUFFER_SRGB is used on Gen9+ then we need to resolve any of the + * single-sampled color renderbuffers because the CCS buffer isn't + * supported for SRGB formats. This only matters if FRAMEBUFFER_SRGB is + * enabled because otherwise the surface state will be programmed with the + * linear equivalent format anyway. + */ + const bool srgb_fb = brw->gen >= 9 && ctx->Color.sRGBEnabled; + + const struct gl_framebuffer *fb = ctx->DrawBuffer; + for (unsigned i = 0; i < fb->_NumColorDrawBuffers; i++) { + const struct intel_renderbuffer *irb = + intel_renderbuffer(fb->_ColorDrawBuffers[i]); + + if (!irb) + continue; + + if (non_coherent_fb_fetch && + intel_miptree_resolve_color( + brw, irb->mt, irb->mt_level, irb->mt_layer, irb->layer_count, + INTEL_MIPTREE_IGNORE_CCS_E)) { + flush |= INTEL_WRITE_CACHE_SYNC; + } + + if (srgb_fb && irb->mt && irb->mt->num_samples <= 1 && + _mesa_get_srgb_format_linear(irb->mt->format) != irb->mt->format) { + /* Lossless compression is not supported for SRGB formats, it + * should be impossible to get here with such surfaces. + */ + assert(!intel_miptree_is_lossless_compressed(brw, irb->mt)); + if (intel_miptree_all_slices_resolve_color(brw, irb->mt, 0)) + flush |= INTEL_WRITE_CACHE_SYNC; + } + } + + return flush; +} + static bool intel_resolve_and_sync_surfaces(struct gl_context *ctx) { @@ -333,7 +382,8 @@ intel_resolve_and_sync_surfaces(struct gl_context *ctx) const enum intel_write_cache_flush_type flush = brw_prepare_textures(ctx) | - brw_prepare_image_surfaces(ctx); + brw_prepare_image_surfaces(ctx) | + brw_prepare_framebuffer(ctx); if (flush == INTEL_WRITE_CACHE_NO_FLUSH) return false; @@ -402,55 +452,6 @@ intel_update_state(struct gl_context * ctx, GLuint new_state) } } - /* Resolve color buffers for non-coherent framebuffer fetch. */ - if (!ctx->Extensions.MESA_shader_framebuffer_fetch && - ctx->FragmentProgram._Current && - ctx->FragmentProgram._Current->info.outputs_read) { - const struct gl_framebuffer *fb = ctx->DrawBuffer; - - for (unsigned i = 0; i < fb->_NumColorDrawBuffers; i++) { - const struct intel_renderbuffer *irb = - intel_renderbuffer(fb->_ColorDrawBuffers[i]); - - if (irb && - intel_miptree_resolve_color( - brw, irb->mt, irb->mt_level, irb->mt_layer, irb->layer_count, - INTEL_MIPTREE_IGNORE_CCS_E)) - brw_render_cache_set_check_flush(brw, irb->mt->bo); - } - } - - /* If FRAMEBUFFER_SRGB is used on Gen9+ then we need to resolve any of the - * single-sampled color renderbuffers because the CCS buffer isn't - * supported for SRGB formats. This only matters if FRAMEBUFFER_SRGB is - * enabled because otherwise the surface state will be programmed with the - * linear equivalent format anyway. - */ - if (brw->gen >= 9 && ctx->Color.sRGBEnabled) { - struct gl_framebuffer *fb = ctx->DrawBuffer; - for (int i = 0; i < fb->_NumColorDrawBuffers; i++) { - struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[i]; - - if (rb == NULL) - continue; - - struct intel_renderbuffer *irb = intel_renderbuffer(rb); - struct intel_mipmap_tree *mt = irb->mt; - - if (mt == NULL || - mt->num_samples > 1 || - _mesa_get_srgb_format_linear(mt->format) == mt->format) - continue; - - /* Lossless compression is not supported for SRGB formats, it - * should be impossible to get here with such surfaces. - */ - assert(!intel_miptree_is_lossless_compressed(brw, mt)); - intel_miptree_all_slices_resolve_color(brw, mt, 0); - brw_render_cache_set_check_flush(brw, mt->bo); - } - } - _mesa_lock_context_textures(ctx); if (new_state & _NEW_BUFFERS) { -- 2.5.5 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev