Skip to content
Snippets Groups Projects
Commit 46396e97 authored by Dmitry Osipenko's avatar Dmitry Osipenko Committed by Marge Bot
Browse files

virgl: Fix unmapping of blob resources


OpenGL API calls like glClearBufferData() result in mapping/unmapping
of a given buffer by Mesa and unmapping of a host blob fails in
virglrenderer because VirGL driver uses command that is intended for
unmapping of a guest buffer. In particular this causes problem for the
"Total War: Warhammer" game that gets GL_OUT_OF_MEMORY error due to the
failed unmapping command. Fix this by setting the mapping usage flag in
accordance to the resource flags, allowing virgl_buffer_transfer_unmap()
to differentiate host buffer from guest.

Fixes: 3b54e583 ("virgl: support PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT")
Signed-off-by: default avatarDmitry Osipenko <dmitry.osipenko@collabora.com>
Part-of: <mesa/mesa!17914>
parent b731be2e
No related branches found
No related tags found
Loading
......@@ -493,6 +493,18 @@ virgl_resource_transfer_map(struct pipe_context *ctx,
/* Multisampled resources require resolve before mapping. */
assert(resource->nr_samples <= 1);
/* If virgl resource was created using persistence and coherency flags,
* then its memory mapping can be only made in accordance to these
* flags. We record the "usage" flags in struct virgl_transfer and
* then virgl_buffer_transfer_unmap() uses them to differentiate
* unmapping of a host blob resource from guest.
*/
if (resource->flags & PIPE_RESOURCE_FLAG_MAP_PERSISTENT)
usage |= PIPE_MAP_PERSISTENT;
if (resource->flags & PIPE_RESOURCE_FLAG_MAP_COHERENT)
usage |= PIPE_MAP_COHERENT;
trans = virgl_resource_create_transfer(vctx, resource,
&vres->metadata, level, usage, box);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment