crocus: Avoid fast-clear with incompatible view

Port of code from iris.
Original author: Nanley Chery

Helps with fast_color_clear@fcc-write-after-clear

Cc: mesa-stable

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24135>
This commit is contained in:
Filip Gawin
2023-07-02 13:40:30 +02:00
committed by Marge Bot
parent 4fa02c5c8e
commit 6e87b277bd
4 changed files with 37 additions and 4 deletions

View File

@@ -2,8 +2,6 @@ spec@!opengl 1.0@depth-clear-precision-check,Fail
spec@!opengl 1.0@depth-clear-precision-check@depth16,Fail
spec@!opengl 1.0@depth-clear-precision-check@depth32,Fail
fast_color_clear@fcc-write-after-clear,Fail
spec@!opengl 1.0@gl-1.0-swapbuffers-behavior,Fail
# Compat mode failure

View File

@@ -101,8 +101,8 @@ can_fast_clear_color(struct crocus_context *ice,
* during resolves because the resolve operations only know about the
* resource and not the renderbuffer.
*/
if (isl_format_srgb_to_linear(render_format) !=
isl_format_srgb_to_linear(format)) {
if (!crocus_render_formats_color_compatible(render_format, res->surf.format,
color)) {
return false;
}

View File

@@ -981,6 +981,22 @@ crocus_resource_prepare_texture(struct crocus_context *ice,
aux_usage, clear_supported);
}
bool
crocus_render_formats_color_compatible(enum isl_format a, enum isl_format b,
union isl_color_value color)
{
if (a == b)
return true;
/* A difference in color space doesn't matter for 0/1 values. */
if (isl_format_srgb_to_linear(a) == isl_format_srgb_to_linear(b) &&
isl_color_value_is_zero_one(color, a)) {
return true;
}
return false;
}
enum isl_aux_usage
crocus_resource_render_aux_usage(struct crocus_context *ice,
struct crocus_resource *res,
@@ -999,6 +1015,22 @@ crocus_resource_render_aux_usage(struct crocus_context *ice,
return res->aux.usage;
case ISL_AUX_USAGE_CCS_D:
/* Disable CCS for some cases of texture-view rendering. On gfx12, HW
* may convert some subregions of shader output to fast-cleared blocks
* if CCS is enabled and the shader output matches the clear color.
* Existing fast-cleared blocks are correctly interpreted by the clear
* color and the resource format (see can_fast_clear_color). To avoid
* gaining new fast-cleared blocks that can't be interpreted by the
* resource format (and to avoid misinterpreting existing ones), shut
* off CCS when the interpretation of the clear color differs between
* the render_format and the resource format.
*/
if (!crocus_render_formats_color_compatible(render_format,
res->surf.format,
res->aux.clear_color)) {
return ISL_AUX_USAGE_NONE;
}
/* Otherwise, we try to fall back to CCS_D */
if (isl_format_supports_ccs_d(devinfo, render_format))
return ISL_AUX_USAGE_CCS_D;

View File

@@ -526,6 +526,9 @@ bool crocus_has_color_unresolved(const struct crocus_resource *res,
unsigned start_level, unsigned num_levels,
unsigned start_layer, unsigned num_layers);
bool crocus_render_formats_color_compatible(enum isl_format a,
enum isl_format b,
union isl_color_value color);
enum isl_aux_usage crocus_resource_render_aux_usage(struct crocus_context *ice,
struct crocus_resource *res,
uint32_t level,