From 10ace5de3afa213b654a9a8bc1b06281896dd5f5 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 27 Oct 2022 11:23:53 -0400 Subject: [PATCH] panfrost,asahi: Support ARB_buffer_storage After a great deal of spec lawyering in #dri-devel, I am convinced this is probably okay for the same reasons as v3d and freedreno. The batch reordering and flush deferral optimizations are seemingly still ok. The requirement that writes are visible "immediately" in the spec actually means "in the subsequent [OpenGL] command" for the CPU -> GPU direction, which avoids pitfalls where PERSISTENT|COHERENT could be used as a "doorbell". With that understanding, the extension doesn't actually require anything special for tilers other than coherency at GPU submit boundaries, which is true for any driver that does not use a sync ioctl. After this commit, the remaining drivers that don't set the CAP are d3d12, softpipe, etnaviv, and i915g. I am unsure about d3d12, but the latter 3 could probbaly enable it trivially for the same reason. v2: Don't use copy_resource path for persistent mappings (Emma). Emma explained on GitLab: I don't think you should have the copy_resource path taken for PIPE_RESOURCE_FLAG_MAP_PERSISTENT BOs. Imagine the user has a general-purpose BO they're streaming stuff into and doing draws that they keep persistently mapped until wrapping. They call some GL function on the same buffer that does a fallback write map on the BO (u_default_buffer_subdata, util_resource_copy_region, whatever) -- the buffer is in use, copy triggers, allocates a new BO. Whoops, the user's pointer for streaming writes is now freed. Closes: #7570 Signed-off-by: Alyssa Rosenzweig Reviewed-by: Emma Anholt Part-of: --- docs/features.txt | 2 +- src/gallium/drivers/asahi/agx_pipe.c | 1 + src/gallium/drivers/panfrost/pan_resource.c | 1 + src/gallium/drivers/panfrost/pan_screen.c | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/features.txt b/docs/features.txt index b945acb9ce6..554c488ebbf 100644 --- a/docs/features.txt +++ b/docs/features.txt @@ -195,7 +195,7 @@ GL 4.3, GLSL 4.30 -- all DONE: i965/gen8+, nvc0, r600, radeonsi, llvmpipe, virgl GL 4.4, GLSL 4.40 -- all DONE: i965/gen8+, nvc0, r600, radeonsi, llvmpipe, zink GL_MAX_VERTEX_ATTRIB_STRIDE DONE (all drivers) - GL_ARB_buffer_storage DONE (freedreno, i965, nv50, v3d, vc4, lima) + GL_ARB_buffer_storage DONE (freedreno, i965, nv50, v3d, vc4, lima, panfrost, asahi) GL_ARB_clear_texture DONE (i965, nv50, softpipe, virgl) GL_ARB_enhanced_layouts DONE (freedreno/a3xx+, i965, nv50, softpipe, virgl) - compile-time constant expressions DONE diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c index 6c5b529c170..149597903c2 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -731,6 +731,7 @@ agx_get_param(struct pipe_screen* pscreen, enum pipe_cap param) case PIPE_CAP_MIXED_COLOR_DEPTH_BITS: case PIPE_CAP_FRAGMENT_SHADER_TEXTURE_LOD: case PIPE_CAP_VERTEX_COLOR_UNCLAMPED: + case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT: case PIPE_CAP_DEPTH_CLIP_DISABLE: case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES: case PIPE_CAP_FRAGMENT_SHADER_DERIVATIVES: diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 2fce5bbb77e..02651ecf8cd 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -1010,6 +1010,7 @@ panfrost_ptr_map(struct pipe_context *pctx, if (!create_new_bo && !(usage & PIPE_MAP_UNSYNCHRONIZED) && + !(resource->flags & PIPE_RESOURCE_FLAG_MAP_PERSISTENT) && (usage & PIPE_MAP_WRITE) && !(resource->target == PIPE_BUFFER && !util_ranges_intersect(&rsrc->valid_buffer_range, box->x, box->x + box->width)) && diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c index 7cba67a8d3e..2f2b291be0c 100644 --- a/src/gallium/drivers/panfrost/pan_screen.c +++ b/src/gallium/drivers/panfrost/pan_screen.c @@ -113,6 +113,7 @@ panfrost_get_param(struct pipe_screen *screen, enum pipe_cap param) case PIPE_CAP_MIXED_COLOR_DEPTH_BITS: case PIPE_CAP_FRAGMENT_SHADER_TEXTURE_LOD: case PIPE_CAP_VERTEX_COLOR_UNCLAMPED: + case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT: case PIPE_CAP_DEPTH_CLIP_DISABLE: case PIPE_CAP_DEPTH_CLIP_DISABLE_SEPARATE: case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES: