D3d9 is very lax WRT map access to buffers and there isn't really much of a reason for us to restrict read access to non-DEFAULT resources.
On the other hand, we'd still really like to be able to ensure that DEFAULT, DYNAMIC | WRITEONLY buffers get allocated in the proper memory region and get efficient data uploads, so keep the restriction for DEFAULT resources.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46849 Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- Once we start using glBufferStorage() to create GL buffers (with MAP_WRITE_BIT / MAP_READ_BIT depending on resource access flags) we'll be depending on undefined behavior ("MAP_READ_BIT - "... "No GL error is generated if the pointer is used to query a mapping which excludes this flag, but the result is undefined and system errors (possibly including program termination) may occur.") for test_writeonly_resource() in device.c and possibly actual applications (not Vietcong though, it uses a WRITEONLY SYSTEMMEM buffer). The test works for me on both Nvidia and AMD but I realize it's not great...
dlls/d3d9/buffer.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/dlls/d3d9/buffer.c b/dlls/d3d9/buffer.c index 43321b3202b..46d11e7de09 100644 --- a/dlls/d3d9/buffer.c +++ b/dlls/d3d9/buffer.c @@ -316,6 +316,9 @@ HRESULT vertexbuffer_init(struct d3d9_vertexbuffer *buffer, struct d3d9_device * desc.usage = usage & WINED3DUSAGE_MASK; desc.bind_flags = 0; desc.access = wined3daccess_from_d3dpool(pool, usage) | map_access_from_usage(usage); + /* Buffers are always readable. */ + if (pool != D3DPOOL_DEFAULT) + desc.access |= WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.misc_flags = 0; desc.structure_byte_stride = 0;
@@ -639,6 +642,9 @@ HRESULT indexbuffer_init(struct d3d9_indexbuffer *buffer, struct d3d9_device *de desc.usage = (usage & WINED3DUSAGE_MASK) | WINED3DUSAGE_STATICDECL; desc.bind_flags = 0; desc.access = wined3daccess_from_d3dpool(pool, usage) | map_access_from_usage(usage); + /* Buffers are always readable. */ + if (pool != D3DPOOL_DEFAULT) + desc.access |= WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.misc_flags = 0; desc.structure_byte_stride = 0;