d3d8: Only one fullscreen swapchain is allowed.
This commit is contained in:
parent
8b6a7a9c02
commit
dd8bf9c87d
|
@ -557,11 +557,36 @@ static HRESULT WINAPI d3d8_device_CreateAdditionalSwapChain(IDirect3DDevice8 *if
|
|||
struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
|
||||
struct wined3d_swapchain_desc desc;
|
||||
struct d3d8_swapchain *object;
|
||||
UINT i, count;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, present_parameters %p, swapchain %p.\n",
|
||||
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);
|
||||
if (SUCCEEDED(hr = d3d8_swapchain_create(device, &desc, &object)))
|
||||
*swapchain = &object->IDirect3DSwapChain8_iface;
|
||||
|
|
|
@ -262,12 +262,16 @@ static void test_swapchain(void)
|
|||
IDirect3DDevice8 *device;
|
||||
IDirect3D8 *d3d;
|
||||
ULONG refcount;
|
||||
HWND window;
|
||||
HWND window, window2;
|
||||
HRESULT hr;
|
||||
struct device_desc device_desc;
|
||||
|
||||
window = CreateWindowA("d3d8_test_wc", "d3d8_test", WS_OVERLAPPEDWINDOW,
|
||||
0, 0, 640, 480, NULL, NULL, NULL, NULL);
|
||||
ok(!!window, "Failed to create a window.\n");
|
||||
window2 = CreateWindowA("d3d8_test_wc", "d3d8_test", WS_OVERLAPPEDWINDOW,
|
||||
0, 0, 640, 480, NULL, NULL, NULL, NULL);
|
||||
ok(!!window2, "Failed to create a window.\n");
|
||||
d3d = Direct3DCreate8(D3D_SDK_VERSION);
|
||||
ok(!!d3d, "Failed to create a D3D object.\n");
|
||||
if (!(device = create_device(d3d, window, NULL)))
|
||||
|
@ -356,10 +360,42 @@ static void test_swapchain(void)
|
|||
IDirect3DSwapChain8_Release(swapchain3);
|
||||
IDirect3DSwapChain8_Release(swapchain2);
|
||||
IDirect3DSwapChain8_Release(swapchain1);
|
||||
|
||||
d3dpp.Windowed = FALSE;
|
||||
d3dpp.hDeviceWindow = window;
|
||||
d3dpp.BackBufferCount = 1;
|
||||
hr = IDirect3DDevice8_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
|
||||
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
|
||||
d3dpp.hDeviceWindow = window2;
|
||||
hr = IDirect3DDevice8_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 = IDirect3DDevice8_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
|
||||
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
|
||||
d3dpp.hDeviceWindow = window2;
|
||||
hr = IDirect3DDevice8_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
|
||||
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
|
||||
d3dpp.Windowed = TRUE;
|
||||
d3dpp.hDeviceWindow = window;
|
||||
hr = IDirect3DDevice8_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
|
||||
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
|
||||
d3dpp.hDeviceWindow = window2;
|
||||
hr = IDirect3DDevice8_CreateAdditionalSwapChain(device, &d3dpp, &swapchain1);
|
||||
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x\n", hr);
|
||||
|
||||
refcount = IDirect3DDevice8_Release(device);
|
||||
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||
cleanup:
|
||||
IDirect3D8_Release(d3d);
|
||||
DestroyWindow(window2);
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue