zink: Revert "zink: enable single-plane modifiers for generic 2D exports"

This reverts commit df1ff3c711.  When
clients allocate BOs via GBM's gbm_bo_create(), they expect those BOs to
work with KMS without modifiers.  Assigning them a modifier and hoping
that they then query that modifier even though they used the legacy API
to create the BO is pretty mean.  In particular, this breaks KWin which
doesn't use modifiers if the KMS device doesn't support atomic.

Fixes: df1ff3c711 ("zink: enable single-plane modifiers for generic 2D exports")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33887>
This commit is contained in:
Faith Ekstrand 2025-03-04 17:30:18 -06:00 committed by Marge Bot
parent bcff33ff93
commit 78a80b9bf1

View file

@ -1727,27 +1727,16 @@ add_resource_bind(struct zink_context *ctx, struct zink_resource *res, unsigned
assert((res->base.b.bind & bind) == 0);
res->base.b.bind |= bind;
struct zink_resource_object *old_obj = res->obj;
ASSERTED uint64_t check_mod = false;
ASSERTED uint64_t mod = DRM_FORMAT_MOD_INVALID;
if (bind & ZINK_BIND_DMABUF && !res->modifiers_count && !res->obj->is_buffer && screen->info.have_EXT_image_drm_format_modifier) {
/* it's improbable that drivers support non-linear modifiers for anything but 2D */
bool use_modifiers = res->base.b.target == PIPE_TEXTURE_2D;
res->modifiers_count = use_modifiers ? screen->modifier_props[res->base.b.format].drmFormatModifierCount : 1;
res->modifiers_count = 1;
res->modifiers = malloc(res->modifiers_count * sizeof(uint64_t));
if (!res->modifiers) {
mesa_loge("ZINK: failed to allocate res->modifiers!");
return false;
}
if (use_modifiers) {
int idx = 0;
for (unsigned i = 0; i < screen->modifier_props[res->base.b.format].drmFormatModifierCount; i++) {
if (screen->modifier_props[res->base.b.format].pDrmFormatModifierProperties[i].drmFormatModifierPlaneCount == 1)
res->modifiers[idx++] = screen->modifier_props[res->base.b.format].pDrmFormatModifierProperties[i].drmFormatModifier;
}
res->modifiers_count = idx;
} else {
res->modifiers[0] = DRM_FORMAT_MOD_LINEAR;
}
check_mod = true;
mod = res->modifiers[0] = DRM_FORMAT_MOD_LINEAR;
}
struct zink_resource_object *new_obj = resource_object_create(screen, &res->base.b, NULL, &res->linear, res->modifiers, res->modifiers_count, NULL, NULL);
if (!new_obj) {
@ -1755,7 +1744,7 @@ add_resource_bind(struct zink_context *ctx, struct zink_resource *res, unsigned
res->base.b.bind &= ~bind;
return false;
}
assert(!check_mod || new_obj->modifier != DRM_FORMAT_MOD_INVALID);
assert(mod == DRM_FORMAT_MOD_INVALID || new_obj->modifier == DRM_FORMAT_MOD_LINEAR);
struct zink_resource staging = *res;
staging.obj = old_obj;
staging.all_binds = 0;