diff options
author | Jason Ekstrand <[email protected]> | 2017-05-25 11:47:13 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2017-06-07 22:18:53 -0700 |
commit | c89b795db45b2adc7f32d6a37b1cc4ebf6b8a6af (patch) | |
tree | 771aa817f95d453bf5d63616fa76dde7bfbec1a4 | |
parent | 0607ca42da5fdb79b64445e34c642925e94354de (diff) |
i965: Combine render target resolve code
We have two different bits of resolve code for render targets: one in
brw_draw where it's always been and one in brw_context to deal with sRGB
on gen9. Let's pull them together.
Reviewed-by: Topi Pohjolainen <[email protected]>
Reviewed-by: Chad Versace <[email protected]>
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_context.c | 47 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_draw.c | 34 |
2 files changed, 29 insertions, 52 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index fe9124cfc6e..bf7200bd00e 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -329,27 +329,24 @@ intel_update_state(struct gl_context * ctx, GLuint new_state) } } - /* 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]; + struct gl_framebuffer *fb = ctx->DrawBuffer; + for (int i = 0; i < fb->_NumColorDrawBuffers; i++) { + struct intel_renderbuffer *irb = + intel_renderbuffer(fb->_ColorDrawBuffers[i]); - if (rb == NULL) - continue; + if (irb == NULL || irb->mt == NULL) + continue; - struct intel_renderbuffer *irb = intel_renderbuffer(rb); - struct intel_mipmap_tree *mt = irb->mt; + struct intel_mipmap_tree *mt = irb->mt; - if (mt == NULL || - mt->num_samples > 1 || - _mesa_get_srgb_format_linear(mt->format) == mt->format) - continue; + /* 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 && mt->num_samples <= 1 && + _mesa_get_srgb_format_linear(mt->format) != mt->format) { /* Lossless compression is not supported for SRGB formats, it * should be impossible to get here with such surfaces. @@ -358,6 +355,20 @@ intel_update_state(struct gl_context * ctx, GLuint new_state) intel_miptree_all_slices_resolve_color(brw, mt, 0); brw_render_cache_set_check_flush(brw, mt->bo); } + + /* For layered rendering non-compressed fast cleared buffers need to be + * resolved. Surface state can carry only one fast color clear value + * while each layer may have its own fast clear color value. For + * compressed buffers color value is available in the color buffer. + */ + if (irb->layer_count > 1 && + !(irb->mt->aux_disable & INTEL_AUX_DISABLE_CCS) && + !intel_miptree_is_lossless_compressed(brw, mt)) { + assert(brw->gen >= 8); + + intel_miptree_resolve_color(brw, mt, irb->mt_level, 1, + irb->mt_layer, irb->layer_count, 0); + } } _mesa_lock_context_textures(ctx); diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index f7287318a5a..3a1bb5023e4 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -405,39 +405,6 @@ brw_postdraw_set_buffers_need_resolve(struct brw_context *brw) } } -static void -brw_predraw_set_aux_buffers(struct brw_context *brw) -{ - if (brw->gen < 9) - return; - - struct gl_context *ctx = &brw->ctx; - struct gl_framebuffer *fb = ctx->DrawBuffer; - - for (unsigned i = 0; i < fb->_NumColorDrawBuffers; i++) { - struct intel_renderbuffer *irb = - intel_renderbuffer(fb->_ColorDrawBuffers[i]); - - if (!irb) { - continue; - } - - /* For layered rendering non-compressed fast cleared buffers need to be - * resolved. Surface state can carry only one fast color clear value - * while each layer may have its own fast clear color value. For - * compressed buffers color value is available in the color buffer. - */ - if (irb->layer_count > 1 && - !(irb->mt->aux_disable & INTEL_AUX_DISABLE_CCS) && - !intel_miptree_is_lossless_compressed(brw, irb->mt)) { - assert(brw->gen >= 8); - - intel_miptree_resolve_color(brw, irb->mt, irb->mt_level, 1, - irb->mt_layer, irb->layer_count, 0); - } - } -} - /* May fail if out of video memory for texture or vbo upload, or on * fallback conditions. */ @@ -486,7 +453,6 @@ brw_try_draw_prims(struct gl_context *ctx, util_last_bit(ctx->VertexProgram._Current->SamplersUsed); intel_prepare_render(brw); - brw_predraw_set_aux_buffers(brw); /* This workaround has to happen outside of brw_upload_render_state() * because it may flush the batchbuffer for a blit, affecting the state |