From: Kenneth Graunke Date: Wed, 27 Apr 2022 08:15:00 +0000 (-0700) Subject: iris: don't create staging resources larger than half the aperture X-Git-Tag: upstream/22.3.5~3933 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a3dba0811566aba9f42e6e5b3a8e8691f972f4b5;p=platform%2Fupstream%2Fmesa.git iris: don't create staging resources larger than half the aperture This is a port of crocus's f1c1fcfd (crocus: don't create staging resources > half aperture). I chose to use the whole aperture here rather than 3/4 of it, mostly to avoid adding another legacy field for aperture stuff. It's close enough to work. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2104 Reviewed-by: Dave Airlie Tested-by: Mark Janes markjanes@swizzler.org Part-of: --- diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c index 0204b1d..82edd9a 100644 --- a/src/gallium/drivers/iris/iris_resource.c +++ b/src/gallium/drivers/iris/iris_resource.c @@ -1152,6 +1152,18 @@ iris_resource_create_with_modifiers(struct pipe_screen *pscreen, if (!isl_surf_created_successfully) goto fail; + /* Don't create staging surfaces that will use over half the aperture, + * since staging implies you are copying data to another resource that's + * at least as large, and then both wouldn't fit in the aperture. + * + * Skip this for discrete cards, as the destination buffer might be in + * device local memory while the staging buffer would be in system memory, + * so both would fit. + */ + if (templ->usage == PIPE_USAGE_STAGING && !devinfo->has_local_mem && + res->surf.size_B > devinfo->aperture_bytes / 2) + goto fail; + if (!iris_resource_configure_aux(screen, res, false)) goto fail;