fdno/resource: Rewrite layout selection for allocation

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: <!12595>
59 jobs for !12595 with fdno-only-enforce-linear-if-only-modifier in 25 minutes and 18 seconds (queued for 26 seconds)
latest detached
Status Name Job ID Coverage
  Sanity
passed sanity #13791278

00:00:08

 
  Container
passed debian/android_build #13791287

00:00:20

passed debian/arm_build #13791294
aarch64

00:00:28

passed debian/arm_test #13791303

00:00:52

passed debian/i386_build #13791283

00:00:21

passed debian/ppc64el_build #13791284

00:00:23

passed debian/s390x_build #13791286

00:00:24

passed debian/x86_build #13791281

00:00:21

passed debian/x86_build-base #13791279

00:00:27

passed debian/x86_test-base #13791289

00:00:22

passed debian/x86_test-gl #13791291

00:00:24

passed debian/x86_test-vk #13791292

00:00:23

passed fedora/x86_build #13791296

00:00:25

passed kernel+rootfs_amd64 #13791297

00:00:12

passed kernel+rootfs_arm64 #13791299
aarch64

00:01:07

passed kernel+rootfs_armhf #13791301
aarch64

00:00:12

passed windows_build_vs2019 #13791305
windows shell 1809 mesa

00:00:12

 
  Build X86 64
passed debian-clang #13791317

00:07:38

passed debian-clover #13791319

00:01:25

passed debian-clover-testing #13791310

00:01:05

passed debian-gallium #13791312

00:02:59

passed debian-release #13791314

00:02:42

passed debian-testing #13791307

00:01:46

passed debian-testing-asan #13791309

00:01:53

passed debian-vulkan #13791320

00:01:29

passed fedora-release #13791315

00:01:09

 
  Build Misc
passed debian-android #13791322

00:01:10

passed debian-arm64 #13791326
aarch64

00:01:37

passed debian-arm64-asan #13791328
aarch64

00:03:09

passed debian-arm64-build-test #13791330
aarch64

00:01:32

passed debian-armhf #13791324
aarch64

00:01:37

passed debian-i386 #13791332

00:01:26

passed debian-mingw32-x86_64 #13791333

00:02:52

 
  Freedreno
passed a306_gl 1/5 #13791335
google-freedreno-db410c

00:10:08

passed a306_gl 2/5 #13791337
google-freedreno-db410c

00:10:22

passed a306_gl 3/5 #13791339
google-freedreno-db410c

00:10:11

passed a306_gl 4/5 #13791341
google-freedreno-db410c

00:09:50

passed a306_gl 5/5 #13791343
google-freedreno-db410c

00:09:46

passed a306-traces #13791345
google-freedreno-db410c

00:03:33

passed a530_gl 1/5 #13791347
google-freedreno-db820c

00:10:43

passed a530_gl 2/5 #13791349
google-freedreno-db820c

00:11:51

passed a530_gl 3/5 #13791351
google-freedreno-db820c

00:09:53

passed a530_gl 4/5 #13791353
google-freedreno-db820c

00:10:24

passed a530_gl 5/5 #13791355
google-freedreno-db820c

00:11:35

passed a530_piglit_shader 1/2 #13791357
google-freedreno-db820c

00:09:11

passed a530_piglit_shader 2/2 #13791359
google-freedreno-db820c

00:09:25

passed a530-traces #13791361
google-freedreno-db820c

00:08:34

passed a630_egl #13791371
google-freedreno-cheza

00:02:34

passed a630_gl 1/4 #13791363
google-freedreno-cheza

00:06:46

passed a630_gl 2/4 #13791365
google-freedreno-cheza

00:07:23

passed a630_gl 3/4 #13791367
google-freedreno-cheza

00:06:10

passed a630_gl 4/4 #13791369
google-freedreno-cheza

00:06:57

passed a630_piglit #13791379
google-freedreno-cheza

00:08:44

passed a630-traces #13791381
google-freedreno-cheza

00:03:59

passed a630-traces-performance #13791385
google-freedreno-cheza manual

00:04:37

failed a630-traces-restricted #13791383
google-freedreno-cheza allowed to fail

00:03:37

passed a630_vk 1/3 #13791373
google-freedreno-cheza

00:08:22

passed a630_vk 2/3 #13791375
google-freedreno-cheza

00:09:46

passed a630_vk 3/3 #13791377
google-freedreno-cheza

00:09:44

 
Name Stage Failure
failed
a630-traces-restricted Freedreno
Uploading artifacts...
results/: found 33 matching files and directories

WARNING: serial*.txt: no matching files
Uploading artifacts as "archive" to coordinator... ok
id=13791383 responseStatus=201 Created token=QotpCJrQ
Uploading artifacts...
results/junit.xml: found 1 matching files and directories

Uploading artifacts as "junit" to coordinator... ok
id=13791383 responseStatus=201 Created token=QotpCJrQ
Cleaning up file based variables
ERROR: Job failed: exit code 1