From: Conor McCarthy <cmccarthy@codeweavers.com> --- dlls/d3d8/device.c | 4 ++-- dlls/d3d8/tests/device.c | 3 --- dlls/d3d9/tests/device.c | 2 -- dlls/wined3d/device.c | 7 ++++++- dlls/wined3d/swapchain.c | 2 +- include/wine/wined3d.h | 1 + 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 036c60edc37..5c72eccb44a 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -957,7 +957,7 @@ static HRESULT WINAPI d3d8_device_Reset(IDirect3DDevice8 *iface, if (!wined3d_swapchain_desc_from_d3d8(&swapchain_desc, device->d3d_parent->wined3d_outputs[output_idx], present_parameters)) return D3DERR_INVALIDCALL; - swapchain_desc.flags |= WINED3D_SWAPCHAIN_IMPLICIT; + swapchain_desc.flags |= WINED3D_SWAPCHAIN_IMPLICIT | WINED3D_SWAPCHAIN_ALLOW_MS_LOCKABLE_BACKBUFFER; wined3d_mutex_lock(); @@ -3758,7 +3758,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine free(device->handle_table.entries); return D3DERR_INVALIDCALL; } - swapchain_desc.flags |= WINED3D_SWAPCHAIN_IMPLICIT; + swapchain_desc.flags |= WINED3D_SWAPCHAIN_IMPLICIT | WINED3D_SWAPCHAIN_ALLOW_MS_LOCKABLE_BACKBUFFER; if (FAILED(hr = d3d8_swapchain_create(device, &swapchain_desc, wined3dswapinterval_from_d3d(parameters->FullScreen_PresentationInterval), &d3d_swapchain))) diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 7e8fa3d5c26..e57f31dfef1 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -9564,10 +9564,7 @@ static void test_swapchain_multisample_reset(void) /* But locking is not allowed. */ hr = IDirect3DSurface8_LockRect(surface, &lr, NULL, 0); - todo_wine ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr); - if (SUCCEEDED(hr)) - IDirect3DSurface8_UnlockRect(surface); IDirect3DSurface8_Release(surface); diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index cb16b747f1f..421b5e67b1e 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -13272,10 +13272,8 @@ static void test_swapchain_multisample_reset(void) /* Lockable back buffer flag is not allowed. */ d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; hr = IDirect3DDevice9_Reset(device, &d3dpp); - todo_wine ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr); hr = IDirect3DDevice9_TestCooperativeLevel(device); - todo_wine ok(hr == D3DERR_DEVICENOTRESET, "TestCooperativeLevel returned hr %#lx.\n", hr); refcount = IDirect3DDevice9_Release(device); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index e754cc633b7..31e87a7df10 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -4987,7 +4987,7 @@ static void update_swapchain_flags(struct wined3d_texture *texture) { unsigned int flags = texture->swapchain->state.desc.flags; - if (flags & WINED3D_SWAPCHAIN_LOCKABLE_BACKBUFFER) + if (flags & WINED3D_SWAPCHAIN_LOCKABLE_BACKBUFFER && !texture->swapchain->state.desc.multisample_type) texture->resource.access |= WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; else texture->resource.access &= ~(WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W); @@ -5082,6 +5082,11 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, TRACE("refresh_rate %u\n", swapchain_desc->refresh_rate); TRACE("auto_restore_display_mode %#x\n", swapchain_desc->auto_restore_display_mode); + /* d3d8 allows the lockable flag even though the backbuffer is not lockable. */ + if (swapchain_desc->multisample_type && !(swapchain_desc->flags & WINED3D_SWAPCHAIN_ALLOW_MS_LOCKABLE_BACKBUFFER) + && (swapchain_desc->flags & WINED3D_SWAPCHAIN_LOCKABLE_BACKBUFFER)) + return WINED3DERR_INVALIDCALL; + if (swapchain_desc->backbuffer_bind_flags && swapchain_desc->backbuffer_bind_flags != WINED3D_BIND_RENDER_TARGET) FIXME("Got unexpected backbuffer bind flags %#x.\n", swapchain_desc->backbuffer_bind_flags); diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index 2bc544c1213..0fd3893c7de 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -1506,7 +1506,7 @@ static HRESULT swapchain_create_texture(struct wined3d_swapchain *swapchain, texture_desc.access = WINED3D_RESOURCE_ACCESS_CPU; else texture_desc.access = WINED3D_RESOURCE_ACCESS_GPU; - if (!depth && (swapchain_desc->flags & WINED3D_SWAPCHAIN_LOCKABLE_BACKBUFFER)) + if (!depth && (swapchain_desc->flags & WINED3D_SWAPCHAIN_LOCKABLE_BACKBUFFER) && !swapchain_desc->multisample_type) texture_desc.access |= WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; texture_desc.width = swapchain_desc->backbuffer_width; texture_desc.height = swapchain_desc->backbuffer_height; diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index cfb098adfb0..72674d03017 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -920,6 +920,7 @@ enum wined3d_memory_segment_group #define WINED3D_SWAPCHAIN_NO_WINDOW_CHANGES 0x00040000u #define WINED3D_SWAPCHAIN_RESTORE_WINDOW_STATE 0x00080000u #define WINED3D_SWAPCHAIN_REGISTER_TOPMOST_TIMER 0x00100000u +#define WINED3D_SWAPCHAIN_ALLOW_MS_LOCKABLE_BACKBUFFER 0x00200000u /* Allow the swapchain flag, but not actual locking */ #define WINED3DDP_MAXTEXCOORD 8 -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10874