wined3d: Prefer mapping a BO if the buffer has WINED3D_BUFFER_USE_BO set.
commit6b96021a1cfa1680482a99123f594fe5b87a0c88
authorZebediah Figura <zfigura@codeweavers.com>
Fri, 28 Jan 2022 02:22:50 +0000 (27 20:22 -0600)
committerAlexandre Julliard <julliard@winehq.org>
Fri, 28 Jan 2022 20:10:21 +0000 (28 21:10 +0100)
tree979e92f60508853a047c3b420329fc4df8d138ee
parent287bfc775828762e4b8212157cabf05d38b3f237
wined3d: Prefer mapping a BO if the buffer has WINED3D_BUFFER_USE_BO set.

Instead of checking whether a BO already exists.

This will end up allocating a BO earlier in some cases. This is not particularly
impactful by itself, since we already would have sysmem available and thus could
use it without a performance penalty. However, we would like to avoid ever
allocating sysmem where not necessary, in particular by deferring allocation of
any location at all until the resource is written to.

This also has the side effect of fixing test_map_synchronization() on 64-bit
architectures, broken since 194b47b4fd92dda8ebf24e88ca7a14fc926c84ab. The test
creates a buffer, maps it once, then maps it again with NOOVERWRITE while the
GPU is still drawing, expecting the new data to be read by the GPU during the
draw. On 32-bit machines, and 64-bit machines before the offending commit, we do
the following:

First map: uses SYSMEM since the BO is not created yet
Draw: upload to VBO
Second map: map the existing VBO with GL_MAP_UNSYNCHRONIZED_BIT

After 194b47b4fd9, we don't use GL_MAP_UNSYNCHRONIZED_BIT since the buffer has
READ access, which means that the second map will be synchronized and wait for
the draw to complete.

After this patch, we do the following:

First map: create and map a VBO (not unsynchronized, but coherent and
persistently mapped)
Draw: use mapped VBO
Second map: write to existing (coherent) VBO, which is unsynchronized

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
dlls/wined3d/buffer.c