virgl: fix sync issue regarding discard/unsync transfers
authorChia-I Wu <olvaffe@gmail.com>
Mon, 17 Jun 2019 16:53:48 +0000 (09:53 -0700)
committerChia-I Wu <olvaffe@gmail.com>
Tue, 18 Jun 2019 17:38:21 +0000 (10:38 -0700)
commit98eda99ab88b8a5bcf5da5daa7ca4edbf34592fd
treee4aaf0bd2bc553a4b87cc39fc240a1ee40ca33c6
parent2a717f300bb6fdb610f20ec8c693af4896e4fc5a
virgl: fix sync issue regarding discard/unsync transfers

GL_MAP_INVALIDATE_BUFFER_BIT cannot be treated as
GL_MAP_INVALIDATE_RANGE_BIT naively.  When we run into

  ptr = glMapBufferRange(buf, 0, size,
          GL_WRITE_BIT|GL_MAP_INVALIDATE_BUFFER_BIT);
  memcpy(ptr, data1, size);
  glUnmapBuffer(buf);
  ptr = glMapBufferRange(buf, size, size,
          GL_WRITE_BIT|GL_MAP_UNSYNCHRONIZED_BIT);
  memcpy(ptr, data2, size);
  glUnmapBuffer(buf);

we never want data1 to be copy_transfer'ed.  Because that would mean
that data2 might overwrite valid data.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Alexandros Frantzis alexandros.frantzis@collabora.com
Fixes: a22c5df0794 ("virgl: Use buffer copy transfers to avoid waiting when mapping")
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
src/gallium/drivers/virgl/virgl_resource.c