diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c index f14b2e5b944..1580701fce8 100644 --- a/src/gallium/drivers/iris/iris_resource.c +++ b/src/gallium/drivers/iris/iris_resource.c @@ -1434,6 +1434,19 @@ mod_plane_is_clear_color(uint64_t modifier, uint32_t plane) } } +static struct iris_resource * +get_resource_for_plane(struct pipe_resource *resource, + unsigned plane) +{ + unsigned count = 0; + for (struct pipe_resource *cur = resource; cur; cur = cur->next) { + if (count++ == plane) + return (struct iris_resource *)cur; + } + + return NULL; +} + static unsigned get_num_planes(const struct pipe_resource *resource) { @@ -1444,6 +1457,27 @@ get_num_planes(const struct pipe_resource *resource) return count; } +static unsigned +get_main_plane_for_plane(enum pipe_format format, + const struct isl_drm_modifier_info *mod_info, + unsigned plane) +{ + unsigned int n_planes = util_format_get_num_planes(format); + + if (n_planes == 1) + return 0; + + if (!mod_info) + return plane; + + if (mod_info->supports_media_compression) { + return plane % n_planes; + } else { + assert(!mod_info->supports_render_compression); + return plane; + } +} + static struct pipe_resource * iris_resource_from_handle(struct pipe_screen *pscreen, const struct pipe_resource *templ, @@ -1791,10 +1825,15 @@ iris_resource_get_param(struct pipe_screen *pscreen, uint64_t *value) { struct iris_screen *screen = (struct iris_screen *)pscreen; - struct iris_resource *res = (struct iris_resource *)resource; + struct iris_resource *base_res = (struct iris_resource *)resource; + unsigned main_plane = get_main_plane_for_plane(base_res->external_format, + base_res->mod_info, plane); + struct iris_resource *res = get_resource_for_plane(resource, main_plane); + assert(res); + bool mod_with_aux = res->mod_info && isl_drm_modifier_has_aux(res->mod_info->modifier); - bool wants_aux = mod_with_aux && plane > 0; + bool wants_aux = mod_with_aux && plane != main_plane; bool wants_cc = mod_with_aux && mod_plane_is_clear_color(res->mod_info->modifier, plane); bool result; @@ -1835,7 +1874,7 @@ iris_resource_get_param(struct pipe_screen *pscreen, return true; case PIPE_RESOURCE_PARAM_OFFSET: *value = wants_cc ? res->aux.clear_color_offset : - wants_aux ? res->aux.offset : 0; + wants_aux ? res->aux.offset : res->offset; return true; case PIPE_RESOURCE_PARAM_MODIFIER: *value = res->mod_info ? res->mod_info->modifier :