diff options
author | Topi Pohjolainen <topi.pohjolainen@intel.com> | 2016-05-31 10:36:12 +0300 |
---|---|---|
committer | Topi Pohjolainen <topi.pohjolainen@intel.com> | 2016-06-01 09:16:36 +0300 |
commit | 30e9e6bd071097fd602a15f488b7eead45460885 (patch) | |
tree | e2566d4447c54a53a0d1852c6a424b40647f21f2 /src/mesa/drivers/dri/i965/brw_context.c | |
parent | a3dc99f3d48df3da1e997d95961747daed0ba6b9 (diff) | |
download | external_mesa3d-30e9e6bd071097fd602a15f488b7eead45460885.zip external_mesa3d-30e9e6bd071097fd602a15f488b7eead45460885.tar.gz external_mesa3d-30e9e6bd071097fd602a15f488b7eead45460885.tar.bz2 |
i965/gen9: Configure rbc buffers as plain for non-rbc tex views
Fixes rendering in Shadow of Mordor with rbc. Application writes
RGBA_UNORM texture filling it with values the application wants to
later on treat as SRGB_ALPHA.
Intel driver enables lossless compression for the buffer by the time
of writing. However, the driver fails to make sure the buffer can be
sampled as something else later on and unfortunately there is
restriction in the hardware for using lossless compression for srgb
formats which looks to extend itself to the sampling engine also.
Requesting srgb to linear conversion on top of compressed buffer
results the color values to be pretty much garbage.
Fortunately none of tracked benchmarks showed a regression with
this.
v2 (Matt): Add missing space
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_context.c')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_context.c | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 2504dce..97dc226 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -70,6 +70,7 @@ #include "tnl/t_pipeline.h" #include "util/ralloc.h" #include "util/debug.h" +#include "isl/isl.h" /*************************************** * Mesa's Driver Functions @@ -166,6 +167,38 @@ intel_update_framebuffer(struct gl_context *ctx, fb->DefaultGeometry.NumSamples); } +/* On Gen9 color buffers may be compressed by the hardware (lossless + * compression). There are, however, format restrictions and care needs to be + * taken that the sampler engine is capable for re-interpreting a buffer with + * format different the buffer was originally written with. + * + * For example, SRGB formats are not compressible and the sampler engine isn't + * capable of treating RGBA_UNORM as SRGB_ALPHA. In such a case the underlying + * color buffer needs to be resolved so that the sampling surface can be + * sampled as non-compressed (i.e., without the auxiliary MCS buffer being + * set). + */ +static bool +intel_texture_view_requires_resolve(struct brw_context *brw, + struct intel_texture_object *intel_tex) +{ + if (brw->gen < 9 || + !intel_miptree_is_lossless_compressed(brw, intel_tex->mt)) + return false; + + const uint32_t brw_format = brw_format_for_mesa_format(intel_tex->_Format); + + if (isl_format_supports_lossless_compression(brw->intelScreen->devinfo, + brw_format)) + return false; + + perf_debug("Incompatible sampling format (%s) for rbc (%s)\n", + _mesa_get_format_name(intel_tex->_Format), + _mesa_get_format_name(intel_tex->mt->format)); + + return true; +} + static void intel_update_state(struct gl_context * ctx, GLuint new_state) { @@ -198,8 +231,9 @@ intel_update_state(struct gl_context * ctx, GLuint new_state) /* Sampling engine understands lossless compression and resolving * those surfaces should be skipped for performance reasons. */ - intel_miptree_resolve_color(brw, tex_obj->mt, - INTEL_MIPTREE_IGNORE_CCS_E); + const int flags = intel_texture_view_requires_resolve(brw, tex_obj) ? + 0 : INTEL_MIPTREE_IGNORE_CCS_E; + intel_miptree_resolve_color(brw, tex_obj->mt, flags); brw_render_cache_set_check_flush(brw, tex_obj->mt->bo); } |