virgl: don't a use staging when a resources created with the shared flag
authorGert Wollny <gert.wollny@collabora.com>
Thu, 10 Nov 2022 17:48:29 +0000 (18:48 +0100)
committerEric Engestrom <eric@engestrom.ch>
Wed, 23 Nov 2022 19:11:59 +0000 (19:11 +0000)
commit3b282d2c3ddc4409fb61b6ed7b0a0fd86029c84f
tree3699ac9914b2c8fbe2f454d40d93f8e2878ab3aa
parentd567ac1dc8df300b4bd6b7923dce102df4b05052
virgl: don't a use staging when a resources created with the shared flag

There seems to be a problem with running firefox by using Xwayland that
results in a shared resources being not always tagged as using staging.

As a result one process tries to map the resource that was allocated as
one that uses staging without actually using the staging resource, and
hence the mapped range only accounts for the small region that we have
to allocated because a zero-allocation doesn't work, but the application
mapping the resource assumes that a properly sized range is mapped, and
consequently this results in invalid memory access.

To work around this issue disable creating staging for resources that
are created by using shared binding. It is not clear to me whether this
is the best fix, but it seems to quell the issue.

Fixes: c9d99b7eec7ec14d6d71d381a424b6280d75a882
    virgl: Fix texture transfers by using a staging resource

Related: https://gitlab.freedesktop.org/virgl/virglrenderer/-/issues/291
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19655>
(cherry picked from commit e496d24cb2d5339566c08c79a8aa7809c240613c)
.pick_status.json
src/gallium/drivers/virgl/virgl_resource.c