virgl: Clear the valid buffer range when possible
authorAlexandros Frantzis <alexandros.frantzis@collabora.com>
Fri, 21 Jun 2019 22:18:27 +0000 (01:18 +0300)
committerChia-I Wu <olvaffe@gmail.com>
Wed, 3 Jul 2019 16:59:55 +0000 (09:59 -0700)
commite5be4351c2f5cc7a639dc2727e0b38f56b4a2263
tree4560150f342c23c0514bc1365c0f649e8ad694f5
parent243db4980c77e9d55b016ea79c4ddf075101bde0
virgl: Clear the valid buffer range when possible

If we are discarding the whole resource, we don't care about previous contents,
and the resource storage is now unused, either because we have created new
resource storage, or because we have waited for the existing resource storage
to become unused, or because the transfer is unsynchronized.

In the last two cases this commit marks the storage as uninitialized, but only
if the resource is not host writable (in which case we can't clear the valid
range, since that would result in missed readbacks in future transfers).

In the first case, when the whole resource discard involves a reallocation, the
reallocation and subsequent rebinding already update the valid buffer range
appropriately.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
src/gallium/drivers/virgl/virgl_buffer.c
src/gallium/drivers/virgl/virgl_resource.c