From e1b4b399ce07266a2b04fe5c7c1df9e1c9649642 Mon Sep 17 00:00:00 2001 From: Juston Li Date: Mon, 20 May 2024 13:32:34 -0700 Subject: [PATCH] zink: disable cpu_storage for PIPE_USAGE_STREAM See 8af8dc97bc3e ("tc: do a GPU->CPU copy to initialize cpu_storage") On zink, initializing cpu_storage that requires a GPU->CPU copy is particularly expensive; in addition to a sync, the buffer_map call to copy the GPU data submits a batch and has to wait for that batch. Take the PIPE_USAGE_STREAM hint and disable using cpu_storage on resources that "will be modified once and used at most a few times" where the benefit of cpu_storage is outweighed by the heavy init time. Signed-off-by: Juston Li Part-of: --- src/gallium/drivers/zink/zink_resource.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index 155805d5cd1..55bc85cdc85 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -1584,6 +1584,7 @@ resource_create(struct pipe_screen *pscreen, res->base.b = *templ; bool allow_cpu_storage = (templ->target == PIPE_BUFFER) && + (templ->usage != PIPE_USAGE_STREAM) && (templ->width0 < 0x1000); threaded_resource_init(&res->base.b, allow_cpu_storage); pipe_reference_init(&res->base.b.reference, 1);