--- src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c index 801d830..ebc414c 100644 --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c @@ -2760,6 +2760,23 @@ intel_miptree_texture_aux_usage(struct brw_context *brw, return ISL_AUX_USAGE_NONE; } +static bool +isl_formats_are_fast_clear_compatible(enum isl_format a, enum isl_format b) +{ + /* On gen8 and earlier, the hardware was only capable of handling 0/1 clear + * values so sRGB curve application was a no-op for all fast-clearable + * formats. + * + * On gen9+, the hardware supports arbitrary clear values. For sRGB clear + * values, the hardware interprets the floats, not as what would be + * returned from the sampler (or written by the shader), but as being + * between format conversion and sRGB curve application. This means that + * we can switch between sRGB and UNORM without having to whack the clear + * color. + */ + return isl_format_srgb_to_linear(a) == isl_format_srgb_to_linear(b); +} + static void intel_miptree_prepare_texture_slices(struct brw_context *brw, struct intel_mipmap_tree *mt, @@ -2776,7 +2793,8 @@ intel_miptree_prepare_texture_slices(struct brw_context *brw, * the sampler. If we have a texture view, we would have to perform the * clear color conversion manually. Just disable clear color. */ - if (mt->format != view_format) + enum isl_format isl_mt_format = translate_tex_format(brw, mt->format, false); + if (!isl_formats_are_fast_clear_compatible(isl_mt_format, view_format)) clear_supported = false; intel_miptree_prepare_access(brw, mt, start_level, num_levels, -- 2.5.0.400.gff86faf _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev