From 24350064ca2f2fdb097871f60228b7d20eec6f87 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 8 May 2023 15:06:55 -0400 Subject: [PATCH] zink: fix uncached memory readback the inner conditional here didn't include uncached readback, meaning that many (most?) buffers allocated with uncached memory (i.e., BAR) were being read back directly instead of using staging resources to be faster at some point this inner conditional should be reevaluated to determine whether it still does anything, but this is not that time fixes, among other things, loading in DOOM2016 on some GPUs Fixes: 52f27cda05b ("zink: allow direct memory mapping for any COHERENT+CACHED buffer") Part-of: --- src/gallium/drivers/zink/ci/zink-anv-tgl-fails.txt | 7 ------- src/gallium/drivers/zink/zink_resource.c | 4 +++- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/zink/ci/zink-anv-tgl-fails.txt b/src/gallium/drivers/zink/ci/zink-anv-tgl-fails.txt index e2c3b768816..3731898edaf 100644 --- a/src/gallium/drivers/zink/ci/zink-anv-tgl-fails.txt +++ b/src/gallium/drivers/zink/ci/zink-anv-tgl-fails.txt @@ -206,13 +206,6 @@ spec@arb_gpu_shader_fp64@uniform_buffers@fs-ubo-load.indirect.3,Fail spec@arb_program_interface_query@arb_program_interface_query-getprogramresourceindex,Fail spec@arb_program_interface_query@arb_program_interface_query-getprogramresourceindex@'vs_input2[1][0]' on GL_PROGRAM_INPUT,Fail -# failing since at least e82369d0 (2023-02-03) -spec@arb_query_buffer_object@qbo,Fail -spec@arb_query_buffer_object@qbo@query-GL_CLIPPING_INPUT_PRIMITIVES-ASYNC_CPU_READ_BEFORE-GL_UNSIGNED_INT64_ARB,Fail -spec@arb_query_buffer_object@qbo@query-GL_PRIMITIVES_SUBMITTED-ASYNC_CPU_READ_BEFORE-GL_UNSIGNED_INT64_ARB,Fail -spec@arb_query_buffer_object@qbo@query-GL_GEOMETRY_SHADER_INVOCATIONS-ASYNC_CPU_READ_BEFORE-GL_UNSIGNED_INT64_ARB,Fail -spec@arb_query_buffer_object@qbo@query-GL_SAMPLES_PASSED-ASYNC_CPU_READ_BEFORE-GL_UNSIGNED_INT64_ARB,Fail - spec@arb_sample_locations@test,Fail spec@arb_sample_locations@test@MSAA: 1- X: 0- Y: 0- Grid: false,Fail spec@arb_sample_locations@test@MSAA: 1- X: 0- Y: 0- Grid: true,Fail diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index 7dfcc168374..f265a52b9a8 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -1946,8 +1946,10 @@ zink_buffer_map(struct pipe_context *pctx, (((usage & PIPE_MAP_READ) && !(usage & PIPE_MAP_PERSISTENT) && ((res->obj->bo->base.placement & VK_STAGING_RAM) != VK_STAGING_RAM)) || !res->obj->host_visible)) { + /* the above conditional catches uncached reads and non-HV writes */ assert(!(usage & (TC_TRANSFER_MAP_THREADED_UNSYNC))); - if (!res->obj->host_visible || res->base.b.flags & PIPE_RESOURCE_FLAG_DONT_MAP_DIRECTLY) { + /* any read, non-HV write, or unmappable that reaches this point needs staging */ + if ((usage & PIPE_MAP_READ) || !res->obj->host_visible || res->base.b.flags & PIPE_RESOURCE_FLAG_DONT_MAP_DIRECTLY) { overwrite: trans->offset = box->x % screen->info.props.limits.minMemoryMapAlignment; trans->staging_res = pipe_buffer_create(&screen->base, PIPE_BIND_LINEAR, PIPE_USAGE_STAGING, box->width + trans->offset);