d3d9: Only one fullscreen swapchain is allowed.

This commit is contained in:
Stefan Dösinger 2014-11-25 10:16:54 +01:00 committed by Alexandre Julliard
parent 2f0a4a4425
commit 8b6a7a9c02
2 changed files with 62 additions and 1 deletions

View File

@ -503,11 +503,36 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_CreateAdditionalSwapChain(ID
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
struct wined3d_swapchain_desc desc; struct wined3d_swapchain_desc desc;
struct d3d9_swapchain *object; struct d3d9_swapchain *object;
UINT i, count;
HRESULT hr; HRESULT hr;
TRACE("iface %p, present_parameters %p, swapchain %p.\n", TRACE("iface %p, present_parameters %p, swapchain %p.\n",
iface, present_parameters, swapchain); iface, present_parameters, swapchain);
if (!present_parameters->Windowed)
{
WARN("Trying to create an additional fullscreen swapchain, returning D3DERR_INVALIDCALL.\n");
return D3DERR_INVALIDCALL;
}
wined3d_mutex_lock();
count = wined3d_device_get_swapchain_count(device->wined3d_device);
for (i = 0; i < count; ++i)
{
struct wined3d_swapchain *wined3d_swapchain;
wined3d_swapchain = wined3d_device_get_swapchain(device->wined3d_device, i);
wined3d_swapchain_get_desc(wined3d_swapchain, &desc);
if (!desc.windowed)
{
wined3d_mutex_unlock();
WARN("Trying to create an additional swapchain in fullscreen mode, returning D3DERR_INVALIDCALL.\n");
return D3DERR_INVALIDCALL;
}
}
wined3d_mutex_unlock();
wined3d_swapchain_desc_from_present_parameters(&desc, present_parameters); wined3d_swapchain_desc_from_present_parameters(&desc, present_parameters);
if (SUCCEEDED(hr = d3d9_swapchain_create(device, &desc, &object))) if (SUCCEEDED(hr = d3d9_swapchain_create(device, &desc, &object)))
*swapchain = (IDirect3DSwapChain9 *)&object->IDirect3DSwapChain9Ex_iface; *swapchain = (IDirect3DSwapChain9 *)&object->IDirect3DSwapChain9Ex_iface;

View File

@ -1058,12 +1058,16 @@ static void test_swapchain(void)
IDirect3DDevice9 *device; IDirect3DDevice9 *device;
IDirect3D9 *d3d; IDirect3D9 *d3d;
ULONG refcount; ULONG refcount;
HWND window; HWND window, window2;
HRESULT hr; HRESULT hr;
struct device_desc device_desc;
window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW, window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, NULL, NULL, NULL, NULL); 0, 0, 640, 480, NULL, NULL, NULL, NULL);
ok(!!window, "Failed to create a window.\n"); ok(!!window, "Failed to create a window.\n");
window2 = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, NULL, NULL, NULL, NULL);
ok(!!window2, "Failed to create a window.\n");
d3d = Direct3DCreate9(D3D_SDK_VERSION); d3d = Direct3DCreate9(D3D_SDK_VERSION);
ok(!!d3d, "Failed to create a D3D object.\n"); ok(!!d3d, "Failed to create a D3D object.\n");
if (!(device = create_device(d3d, window, NULL))) if (!(device = create_device(d3d, window, NULL)))
@ -1176,10 +1180,42 @@ static void test_swapchain(void)
IDirect3DSwapChain9_Release(swapchain3); IDirect3DSwapChain9_Release(swapchain3);
IDirect3DSwapChain9_Release(swapchain2); IDirect3DSwapChain9_Release(swapchain2);
IDirect3DSwapChain9_Release(swapchain1); IDirect3DSwapChain9_Release(swapchain1);
d3dpp.Windowed = FALSE;
d3dpp.hDeviceWindow = window;
d3dpp.BackBufferCount = 1;
hr = IDirect3DDevice9_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
d3dpp.hDeviceWindow = window2;
hr = IDirect3DDevice9_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
device_desc.width = registry_mode.dmPelsWidth;
device_desc.height = registry_mode.dmPelsHeight;
device_desc.device_window = window;
device_desc.flags = CREATE_DEVICE_FULLSCREEN;
hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
d3dpp.hDeviceWindow = window;
hr = IDirect3DDevice9_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
d3dpp.hDeviceWindow = window2;
hr = IDirect3DDevice9_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
d3dpp.Windowed = TRUE;
d3dpp.hDeviceWindow = window;
hr = IDirect3DDevice9_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
d3dpp.hDeviceWindow = window2;
hr = IDirect3DDevice9_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
refcount = IDirect3DDevice9_Release(device); refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount); ok(!refcount, "Device has %u references left.\n", refcount);
cleanup: cleanup:
IDirect3D9_Release(d3d); IDirect3D9_Release(d3d);
DestroyWindow(window2);
DestroyWindow(window); DestroyWindow(window);
} }