zink: enable single-plane modifiers for generic 2D exports
this should be fine; multi-plane ones won't work because not all callers expect to get multiple fds back Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33675>
This commit is contained in:
committed by
Marge Bot
parent
237d8799be
commit
df1ff3c711
@@ -1727,16 +1727,27 @@ add_resource_bind(struct zink_context *ctx, struct zink_resource *res, unsigned
|
|||||||
assert((res->base.b.bind & bind) == 0);
|
assert((res->base.b.bind & bind) == 0);
|
||||||
res->base.b.bind |= bind;
|
res->base.b.bind |= bind;
|
||||||
struct zink_resource_object *old_obj = res->obj;
|
struct zink_resource_object *old_obj = res->obj;
|
||||||
ASSERTED uint64_t mod = DRM_FORMAT_MOD_INVALID;
|
ASSERTED uint64_t check_mod = false;
|
||||||
if (bind & ZINK_BIND_DMABUF && !res->modifiers_count && !res->obj->is_buffer && screen->info.have_EXT_image_drm_format_modifier) {
|
if (bind & ZINK_BIND_DMABUF && !res->modifiers_count && !res->obj->is_buffer && screen->info.have_EXT_image_drm_format_modifier) {
|
||||||
res->modifiers_count = 1;
|
/* 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 = malloc(res->modifiers_count * sizeof(uint64_t));
|
res->modifiers = malloc(res->modifiers_count * sizeof(uint64_t));
|
||||||
if (!res->modifiers) {
|
if (!res->modifiers) {
|
||||||
mesa_loge("ZINK: failed to allocate res->modifiers!");
|
mesa_loge("ZINK: failed to allocate res->modifiers!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (use_modifiers) {
|
||||||
mod = res->modifiers[0] = DRM_FORMAT_MOD_LINEAR;
|
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;
|
||||||
}
|
}
|
||||||
struct zink_resource_object *new_obj = resource_object_create(screen, &res->base.b, NULL, &res->linear, res->modifiers, res->modifiers_count, NULL, NULL);
|
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) {
|
if (!new_obj) {
|
||||||
@@ -1744,7 +1755,7 @@ add_resource_bind(struct zink_context *ctx, struct zink_resource *res, unsigned
|
|||||||
res->base.b.bind &= ~bind;
|
res->base.b.bind &= ~bind;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
assert(mod == DRM_FORMAT_MOD_INVALID || new_obj->modifier == DRM_FORMAT_MOD_LINEAR);
|
assert(!check_mod || new_obj->modifier != DRM_FORMAT_MOD_INVALID);
|
||||||
struct zink_resource staging = *res;
|
struct zink_resource staging = *res;
|
||||||
staging.obj = old_obj;
|
staging.obj = old_obj;
|
||||||
staging.all_binds = 0;
|
staging.all_binds = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user