radeonsi: Check if modifier supports the image extent

DCN only supports an extent < 4K on !64B && 128B.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13056>
This commit is contained in:
Joshua Ashton 2021-09-26 20:14:34 +01:00 committed by Marge Bot
parent 9cffe1b9ea
commit baff748cb0

View file

@ -1384,6 +1384,18 @@ si_get_dmabuf_modifier_planes(struct pipe_screen *pscreen, uint64_t modifier,
return planes; return planes;
} }
static bool
si_modifier_supports_resource(struct pipe_screen *screen,
uint64_t modifier,
const struct pipe_resource *templ)
{
struct si_screen *sscreen = (struct si_screen *)screen;
uint32_t max_width, max_height;
ac_modifier_max_extent(&sscreen->info, modifier, &max_width, &max_height);
return templ->width0 <= max_width && templ->height0 <= max_height;
}
static struct pipe_resource * static struct pipe_resource *
si_texture_create_with_modifiers(struct pipe_screen *screen, si_texture_create_with_modifiers(struct pipe_screen *screen,
const struct pipe_resource *templ, const struct pipe_resource *templ,
@ -1413,7 +1425,7 @@ si_texture_create_with_modifiers(struct pipe_screen *screen,
for (int i = 0; i < allowed_mod_count; ++i) { for (int i = 0; i < allowed_mod_count; ++i) {
bool found = false; bool found = false;
for (int j = 0; j < modifier_count && !found; ++j) for (int j = 0; j < modifier_count && !found; ++j)
if (modifiers[j] == allowed_modifiers[i]) if (modifiers[j] == allowed_modifiers[i] && si_modifier_supports_resource(screen, modifiers[j], templ))
found = true; found = true;
if (found) { if (found) {