Module: Mesa Branch: main Commit: 465eb092ede759f873bb34e54b11721296be4c5a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=465eb092ede759f873bb34e54b11721296be4c5a
Author: Kenneth Graunke <[email protected]> Date: Thu Sep 29 16:12:07 2022 -0700 iris: Use persistent mappings for pinned memory (userptr) This is a port of Nicolai's b52721e3b693e113aa537d163c8a855169e7b75d from radeonsi. Because GL_AMD_pinned_memory guarantees that mappings will refer to the same underlying page, we need to avoid using staging maps. Using a persistent map is a reasonable way to accomplish this. Reviewed-by: Ian Romanick <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19209> --- src/gallium/drivers/iris/iris_resource.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c index d33a8e7898b..5546edf8d93 100644 --- a/src/gallium/drivers/iris/iris_resource.c +++ b/src/gallium/drivers/iris/iris_resource.c @@ -2369,6 +2369,20 @@ iris_transfer_map(struct pipe_context *ctx, struct iris_resource *res = (struct iris_resource *)resource; struct isl_surf *surf = &res->surf; + /* From GL_AMD_pinned_memory issues: + * + * 4) Is glMapBuffer on a shared buffer guaranteed to return the + * same system address which was specified at creation time? + * + * RESOLVED: NO. The GL implementation might return a different + * virtual mapping of that memory, although the same physical + * page will be used. + * + * So don't ever use staging buffers. + */ + if (res->base.is_user_ptr) + usage |= PIPE_MAP_PERSISTENT; + if (usage & PIPE_MAP_DISCARD_WHOLE_RESOURCE) { /* Replace the backing storage with a fresh buffer for non-async maps */ if (!(usage & (PIPE_MAP_UNSYNCHRONIZED |
