dri: Fix hardware cursor for cards without modifier support

After the breaking commit, gbm_bo_create_with_modifiers({LINEAR}) returns
a BO with gbm_bo_get_modifier() = INVALID. This restores the functionality
and fixes most notably, hardware cursors for cards without modifiers.

Fixes #12039.

Fixes: 361f362258 ("dri: Unify createImage and createImageWithModifiers")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31725>
(cherry picked from commit 7d1a32fafd)
This commit is contained in:
Scott Moreau
2024-10-17 13:37:38 -06:00
committed by Dylan Baker
parent 108ab09453
commit dcb37073e9
2 changed files with 2 additions and 9 deletions

View File

@@ -1844,7 +1844,7 @@
"description": "dri: Fix hardware cursor for cards without modifier support", "description": "dri: Fix hardware cursor for cards without modifier support",
"nominated": true, "nominated": true,
"nomination_type": 2, "nomination_type": 2,
"resolution": 0, "resolution": 1,
"main_sha": null, "main_sha": null,
"because_sha": "361f3622587e5bc452a62dbd671969b713273b79", "because_sha": "361f3622587e5bc452a62dbd671969b713273b79",
"notes": null "notes": null

View File

@@ -1137,22 +1137,15 @@ dri_create_image(struct dri_screen *screen,
if (!pscreen->resource_create_with_modifiers && count > 0) { if (!pscreen->resource_create_with_modifiers && count > 0) {
bool invalid_ok = false; bool invalid_ok = false;
bool linear_ok = false;
for (unsigned i = 0; i < _count; i++) { for (unsigned i = 0; i < _count; i++) {
if (modifiers[i] == DRM_FORMAT_MOD_LINEAR) if (modifiers[i] == DRM_FORMAT_MOD_INVALID)
linear_ok = true;
else if (modifiers[i] == DRM_FORMAT_MOD_INVALID)
invalid_ok = true; invalid_ok = true;
} }
if (invalid_ok) { if (invalid_ok) {
count = 0; count = 0;
modifiers = NULL; modifiers = NULL;
} else if (linear_ok) {
count = 0;
modifiers = NULL;
use |= __DRI_IMAGE_USE_LINEAR;
} else { } else {
return NULL; return NULL;
} }