diff --git a/src/panfrost/lib/pan_desc.c b/src/panfrost/lib/pan_desc.c index 090a47bc3f0..e9f43917bae 100644 --- a/src/panfrost/lib/pan_desc.c +++ b/src/panfrost/lib/pan_desc.c @@ -109,6 +109,8 @@ renderblock_fits_in_single_pass(const struct pan_image_view *view, int GENX(pan_select_crc_rt)(const struct pan_fb_info *fb, unsigned tile_size) { + int best_rt = -1; + /* Disable CRC when the tile size is smaller than 16x16. In the hardware, * CRC tiles are the same size as the tiles of the framebuffer. However, * our code only handles 16x16 tiles. Therefore under the current @@ -119,42 +121,40 @@ GENX(pan_select_crc_rt)(const struct pan_fb_info *fb, unsigned tile_size) * Restricting CRC to 16x16 should work in practice. */ if (tile_size < 16 * 16) - return -1; + return best_rt; #if PAN_ARCH <= 6 if (fb->rt_count == 1 && fb->rts[0].view && !fb->rts[0].discard && pan_image_view_has_crc(fb->rts[0].view) && - renderblock_fits_in_single_pass(fb->rts[0].view, tile_size) && - (*(fb->rts[0].crc_valid) || pan_fb_is_fully_covered(fb))) - return 0; - - return -1; + renderblock_fits_in_single_pass(fb->rts[0].view, tile_size)) + best_rt = 0; #else - bool best_rt_valid = false; - int best_rt = -1; - for (unsigned i = 0; i < fb->rt_count; i++) { + /* Skip unusable RT. */ if (!fb->rts[i].view || fb->rts[i].discard || !pan_image_view_has_crc(fb->rts[i].view) || !renderblock_fits_in_single_pass(fb->rts[i].view, tile_size)) continue; - bool valid = *(fb->rts[i].crc_valid); - bool full = pan_fb_is_fully_covered(fb); - if (!full && !valid) - continue; - - if (best_rt < 0 || (valid && !best_rt_valid)) { + /* Select the first RT with a valid CRC buffer. */ + if (*fb->rts[i].crc_valid) { best_rt = i; - best_rt_valid = valid; + break; } - if (valid) - break; + /* Store the first usable RT otherwise. */ + if (best_rt == -1) + best_rt = i; } +#endif + + /* The selected RT must be fully covered for now in order to correctly + * initialize the CRC buffer. */ + if (best_rt != -1 && !*fb->rts[best_rt].crc_valid && + !pan_fb_is_fully_covered(fb)) + best_rt = -1; return best_rt; -#endif } static enum mali_zs_format