From f42eb33ad2feafecb0d4fbf01949ab5ff52307b4 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 8 Oct 2020 18:51:43 -0400 Subject: [PATCH] panfrost: Fix faults on block-based formats on Bifrost Fixes dEQP-GLES2.functional.texture.filtering.2d.nearest_nearest_clamp_etc1 Signed-off-by: Alyssa Rosenzweig Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/lib/pan_texture.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/panfrost/lib/pan_texture.c b/src/panfrost/lib/pan_texture.c index ecb7a69..6de8223 100644 --- a/src/panfrost/lib/pan_texture.c +++ b/src/panfrost/lib/pan_texture.c @@ -231,14 +231,20 @@ panfrost_block_dim(uint64_t modifier, bool width, unsigned plane) static unsigned panfrost_nonlinear_stride(uint64_t modifier, - unsigned bytes_per_pixel, + unsigned bytes_per_block, + unsigned pixels_per_block, unsigned width, unsigned height, bool plane) { unsigned block_w = panfrost_block_dim(modifier, true, plane); unsigned block_h = panfrost_block_dim(modifier, false, plane); - unsigned block_size = block_w * block_h * bytes_per_pixel; + + /* Calculate block size. Ensure the division happens only at the end to + * avoid rounding errors if bytes per block < pixels per block */ + + unsigned block_size = (block_w * block_h * bytes_per_block) + / pixels_per_block; if (height <= block_h) return 0; @@ -291,6 +297,7 @@ panfrost_emit_texture_payload( slices[l].stride : panfrost_nonlinear_stride(modifier, MAX2(desc->block.bits / 8, 1), + desc->block.width * desc->block.height, u_minify(width, l), u_minify(height, l), false); } -- 2.7.4