From: Jonathan Marek Date: Sat, 11 Jul 2020 17:49:51 +0000 (-0400) Subject: freedreno: fix layout pitchalign field not being set for imported buffers X-Git-Tag: upstream/21.0.0~7735 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=248fbe15675c39de4faa7c083b6f5190cc5560fe;p=platform%2Fupstream%2Fmesa.git freedreno: fix layout pitchalign field not being set for imported buffers The pitchalign value was being left to 0 and then wrapping around when the base offset was subtracted in texture state. Fixes: 979e7e3680792 ("freedreno/layout: layout simplifications and pitch from level 0 pitch") Signed-off-by: Jonathan Marek Part-of: --- diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index fb5bb53..07baa7d 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -1027,16 +1027,23 @@ fd_resource_from_handle(struct pipe_screen *pscreen, slice->offset = handle->offset; slice->size0 = handle->stride * prsc->height0; - uint32_t pitchalign = fd_screen(pscreen)->gmem_alignw * rsc->layout.cpp; - - /* pitchalign is 64-bytes for linear formats on a6xx - * layout_resource_for_modifier will validate tiled pitch + /* use a pitchalign of gmem_alignw pixels, because GMEM resolve for + * lower alignments is not implemented (but possible for a6xx at least) + * + * for UBWC-enabled resources, layout_resource_for_modifier will further + * validate the pitch and set the right pitchalign */ - if (is_a6xx(screen)) - pitchalign = 64; + rsc->layout.pitchalign = + fdl_cpp_shift(&rsc->layout) + util_logbase2(screen->gmem_alignw); + + /* apply the minimum pitchalign (note: actually 4 for a3xx but doesn't matter) */ + if (is_a6xx(screen) || is_a5xx(screen)) + rsc->layout.pitchalign = MAX2(rsc->layout.pitchalign, 6); + else + rsc->layout.pitchalign = MAX2(rsc->layout.pitchalign, 5); - if ((rsc->layout.pitch0 < align(prsc->width0 * rsc->layout.cpp, pitchalign)) || - (rsc->layout.pitch0 & (pitchalign - 1))) + if (rsc->layout.pitch0 < (prsc->width0 * rsc->layout.cpp) || + fd_resource_pitch(rsc, 0) != rsc->layout.pitch0) goto fail; assert(rsc->layout.cpp);