From: Mike Blumenkrantz Date: Tue, 18 Oct 2022 16:25:17 +0000 (-0400) Subject: zink: enable tc cpu storage on some buffers X-Git-Tag: upstream/22.3.5~1533 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bf3edad94caa50887e83cc6c003086569f29d370;p=platform%2Fupstream%2Fmesa.git zink: enable tc cpu storage on some buffers matching freedreno usage Part-of: --- diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index 9824f78..3ec3691 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -1136,7 +1136,9 @@ resource_create(struct pipe_screen *pscreen, res->base.b = *templ; - threaded_resource_init(&res->base.b, false); + bool allow_cpu_storage = (templ->target == PIPE_BUFFER) && + (templ->width0 < 0x1000); + threaded_resource_init(&res->base.b, allow_cpu_storage); pipe_reference_init(&res->base.b.reference, 1); res->base.b.screen = pscreen; @@ -1425,6 +1427,8 @@ zink_resource_get_handle(struct pipe_screen *pscreen, struct winsys_handle *whandle, unsigned usage) { + if (tex->target == PIPE_BUFFER) + tc_buffer_disable_cpu_storage(tex); if (whandle->type == WINSYS_HANDLE_TYPE_FD || whandle->type == WINSYS_HANDLE_TYPE_KMS) { #ifdef ZINK_USE_DMABUF struct zink_resource *res = zink_resource(tex); @@ -1525,6 +1529,8 @@ zink_resource_from_handle(struct pipe_screen *pscreen, res->drm_format = whandle->format; if (pres->target != PIPE_BUFFER) res->valid = true; + else + tc_buffer_disable_cpu_storage(pres); } return pres; #else @@ -1588,8 +1594,12 @@ zink_resource_from_memobj(struct pipe_screen *pscreen, struct zink_memory_object *memobj = (struct zink_memory_object *)pmemobj; struct pipe_resource *pres = resource_create(pscreen, templ, &memobj->whandle, 0, NULL, 0, NULL); - if (pres && pres->target != PIPE_BUFFER) - zink_resource(pres)->valid = true; + if (pres) { + if (pres->target != PIPE_BUFFER) + zink_resource(pres)->valid = true; + else + tc_buffer_disable_cpu_storage(pres); + } return pres; }