0e15d5af81
The previous code had a number of errors, the most glaring of which was forcing linear when it was one of the possible layouts requested. When modifiers are being used, a list of _acceptable_ modifiers is supplied; it's up to the driver to then make a decision as to which it thinks is most optimal. Normally we would select between linear/tiled/UBWC in ascending order of preference according to what's possible, however we can't use a tiled layout with explicit modifiers as there is no modifier token defined for it. Rewrite the layout-selection mechanism to always try to do the most optimal thing. If the use flags force us to, or we have a shared resource without explicit modifiers, we use linear. Failing that, we use UBWC wherever possible; if this is not possible, we use tiled for internal resources only or linear for shared resources. v2 (Rob): respect FD_FORMAT_MOD_QCOM_TILED; do not print perf warning on user choice of disabling UBWC; v3: fix several issues breaking CI tests: revert removal of using MOD_INVALID in various places, and assume implicit modifiers if present; do not attempt to set UBWC flags when screen->tile_mode(prsc) falls back to LINEAR (e.g. for small mip-maps levels); use TILED for implicit modifier case with non-shared resources v4: fix unintended demotion of UBWC, i.e. only check QCOM_COMPRESSED modifier and demote UBWC to less optimal format when using explicit modifiers Signed-off-by: Daniel Stone <daniels@collabora.com> Tested-by: Heinrich Fink <hfink@snap.com> Signed-off-by: Heinrich Fink <hfink@snap.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12595>