2 * Copyright 2008 Henri Verbeet for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/test.h"
24 static HRESULT (WINAPI
*pCreateDXGIFactory1
)(REFIID iid
, void **factory
);
26 static ULONG
get_refcount(IUnknown
*iface
)
28 IUnknown_AddRef(iface
);
29 return IUnknown_Release(iface
);
32 static IDXGIDevice
*create_device(void)
34 IDXGIDevice
*dxgi_device
;
38 if (SUCCEEDED(D3D10CreateDevice(NULL
, D3D10_DRIVER_TYPE_HARDWARE
, NULL
, 0, D3D10_SDK_VERSION
, &device
)))
40 if (SUCCEEDED(D3D10CreateDevice(NULL
, D3D10_DRIVER_TYPE_WARP
, NULL
, 0, D3D10_SDK_VERSION
, &device
)))
42 if (SUCCEEDED(D3D10CreateDevice(NULL
, D3D10_DRIVER_TYPE_REFERENCE
, NULL
, 0, D3D10_SDK_VERSION
, &device
)))
48 hr
= ID3D10Device_QueryInterface(device
, &IID_IDXGIDevice
, (void **)&dxgi_device
);
49 ok(SUCCEEDED(hr
), "Created device does not implement IDXGIDevice\n");
50 ID3D10Device_Release(device
);
55 static void test_device_interfaces(void)
62 if (!(device
= create_device()))
64 skip("Failed to create device, skipping tests.\n");
68 hr
= IDXGIDevice_QueryInterface(device
, &IID_IUnknown
, (void **)&iface
);
69 ok(SUCCEEDED(hr
), "Failed to query IUnknown interface, hr %#x.\n", hr
);
70 IUnknown_Release(iface
);
72 hr
= IDXGIDevice_QueryInterface(device
, &IID_IDXGIObject
, (void **)&iface
);
73 ok(SUCCEEDED(hr
), "Failed to query IDXGIObject interface, hr %#x.\n", hr
);
74 IUnknown_Release(iface
);
76 hr
= IDXGIDevice_QueryInterface(device
, &IID_IDXGIDevice
, (void **)&iface
);
77 ok(SUCCEEDED(hr
), "Failed to query IDXGIDevice interface, hr %#x.\n", hr
);
78 IUnknown_Release(iface
);
80 hr
= IDXGIDevice_QueryInterface(device
, &IID_ID3D10Device
, (void **)&iface
);
81 ok(SUCCEEDED(hr
), "Failed to query ID3D10Device interface, hr %#x.\n", hr
);
82 IUnknown_Release(iface
);
84 hr
= IDXGIDevice_QueryInterface(device
, &IID_ID3D10Multithread
, (void **)&iface
);
85 ok(SUCCEEDED(hr
), "Failed to query ID3D10Multithread interface, hr %#x.\n", hr
);
86 IUnknown_Release(iface
);
88 if (SUCCEEDED(hr
= IDXGIDevice_QueryInterface(device
, &IID_ID3D10Device1
, (void **)&iface
)))
89 IUnknown_Release(iface
);
90 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
91 "Failed to query ID3D10Device1 interface, hr %#x.\n", hr
);
93 if (SUCCEEDED(hr
= IDXGIDevice_QueryInterface(device
, &IID_ID3D11Device
, (void **)&iface
)))
94 IUnknown_Release(iface
);
95 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
96 "Failed to query ID3D11Device interface, hr %#x.\n", hr
);
98 refcount
= IDXGIDevice_Release(device
);
99 ok(!refcount
, "Device has %u references left.\n", refcount
);
102 static void test_adapter_desc(void)
104 DXGI_ADAPTER_DESC1 desc1
;
105 IDXGIAdapter1
*adapter1
;
106 DXGI_ADAPTER_DESC desc
;
107 IDXGIAdapter
*adapter
;
112 if (!(device
= create_device()))
114 skip("Failed to create device, skipping tests.\n");
118 hr
= IDXGIDevice_GetAdapter(device
, &adapter
);
119 ok(SUCCEEDED(hr
), "GetAdapter failed, hr %#x.\n", hr
);
121 hr
= IDXGIAdapter_GetDesc(adapter
, NULL
);
122 ok(hr
== E_INVALIDARG
, "GetDesc returned %#x, expected %#x.\n",
125 hr
= IDXGIAdapter_GetDesc(adapter
, &desc
);
126 ok(SUCCEEDED(hr
), "GetDesc failed, hr %#x.\n", hr
);
128 trace("%s.\n", wine_dbgstr_w(desc
.Description
));
129 trace("%04x: %04x:%04x (rev %02x).\n",
130 desc
.SubSysId
, desc
.VendorId
, desc
.DeviceId
, desc
.Revision
);
131 trace("Dedicated video memory: %lu (%lu MB).\n",
132 desc
.DedicatedVideoMemory
, desc
.DedicatedVideoMemory
/ (1024 * 1024));
133 trace("Dedicated system memory: %lu (%lu MB).\n",
134 desc
.DedicatedSystemMemory
, desc
.DedicatedSystemMemory
/ (1024 * 1024));
135 trace("Shared system memory: %lu (%lu MB).\n",
136 desc
.SharedSystemMemory
, desc
.SharedSystemMemory
/ (1024 * 1024));
137 trace("LUID: %08x:%08x.\n", desc
.AdapterLuid
.HighPart
, desc
.AdapterLuid
.LowPart
);
139 hr
= IDXGIAdapter_QueryInterface(adapter
, &IID_IDXGIAdapter1
, (void **)&adapter1
);
140 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
), "Got unexpected hr %#x.\n", hr
);
141 if (hr
== E_NOINTERFACE
)
144 hr
= IDXGIAdapter1_GetDesc1(adapter1
, &desc1
);
145 ok(SUCCEEDED(hr
), "GetDesc1 failed, hr %#x.\n", hr
);
147 ok(!lstrcmpW(desc
.Description
, desc1
.Description
),
148 "Got unexpected description %s.\n", wine_dbgstr_w(desc1
.Description
));
149 ok(desc1
.VendorId
== desc
.VendorId
, "Got unexpected vendor ID %04x.\n", desc1
.VendorId
);
150 ok(desc1
.DeviceId
== desc
.DeviceId
, "Got unexpected device ID %04x.\n", desc1
.DeviceId
);
151 ok(desc1
.SubSysId
== desc
.SubSysId
, "Got unexpected sub system ID %04x.\n", desc1
.SubSysId
);
152 ok(desc1
.Revision
== desc
.Revision
, "Got unexpected revision %02x.\n", desc1
.Revision
);
153 ok(desc1
.DedicatedVideoMemory
== desc
.DedicatedVideoMemory
,
154 "Got unexpected dedicated video memory %lu.\n", desc1
.DedicatedVideoMemory
);
155 ok(desc1
.DedicatedSystemMemory
== desc
.DedicatedSystemMemory
,
156 "Got unexpected dedicated system memory %lu.\n", desc1
.DedicatedSystemMemory
);
157 ok(desc1
.SharedSystemMemory
== desc
.SharedSystemMemory
,
158 "Got unexpected shared system memory %lu.\n", desc1
.SharedSystemMemory
);
159 ok(!memcmp(&desc
.AdapterLuid
, &desc1
.AdapterLuid
, sizeof(desc
.AdapterLuid
)),
160 "Got unexpected adapter LUID %08x:%08x.\n", desc1
.AdapterLuid
.HighPart
, desc1
.AdapterLuid
.LowPart
);
161 trace("Flags: %08x.\n", desc1
.Flags
);
163 IDXGIAdapter1_Release(adapter1
);
166 IDXGIAdapter_Release(adapter
);
167 refcount
= IDXGIDevice_Release(device
);
168 ok(!refcount
, "Device has %u references left.\n", refcount
);
171 static void test_create_surface(void)
173 ID3D10Texture2D
*texture
;
174 IDXGISurface
*surface
;
175 DXGI_SURFACE_DESC desc
;
180 if (!(device
= create_device()))
182 skip("Failed to create device, skipping tests.\n");
188 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
189 desc
.SampleDesc
.Count
= 1;
190 desc
.SampleDesc
.Quality
= 0;
192 hr
= IDXGIDevice_CreateSurface(device
, &desc
, 1, DXGI_USAGE_RENDER_TARGET_OUTPUT
, NULL
, &surface
);
193 ok(SUCCEEDED(hr
), "Failed to create a dxgi surface, hr %#x\n", hr
);
195 hr
= IDXGISurface_QueryInterface(surface
, &IID_ID3D10Texture2D
, (void **)&texture
);
196 ok(SUCCEEDED(hr
), "Surface should implement ID3D10Texture2D\n");
197 if (SUCCEEDED(hr
)) ID3D10Texture2D_Release(texture
);
199 IDXGISurface_Release(surface
);
200 refcount
= IDXGIDevice_Release(device
);
201 ok(!refcount
, "Device has %u references left.\n", refcount
);
204 static void test_parents(void)
206 DXGI_SURFACE_DESC surface_desc
;
207 IDXGISurface
*surface
;
208 IDXGIFactory
*factory
;
209 IDXGIAdapter
*adapter
;
216 if (!(device
= create_device()))
218 skip("Failed to create device, skipping tests.\n");
222 surface_desc
.Width
= 512;
223 surface_desc
.Height
= 512;
224 surface_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
225 surface_desc
.SampleDesc
.Count
= 1;
226 surface_desc
.SampleDesc
.Quality
= 0;
228 hr
= IDXGIDevice_CreateSurface(device
, &surface_desc
, 1, DXGI_USAGE_RENDER_TARGET_OUTPUT
, NULL
, &surface
);
229 ok(SUCCEEDED(hr
), "Failed to create a dxgi surface, hr %#x\n", hr
);
231 hr
= IDXGISurface_GetParent(surface
, &IID_IDXGIDevice
, (void **)&parent
);
232 IDXGISurface_Release(surface
);
233 ok(SUCCEEDED(hr
), "GetParent failed, hr %#x.\n", hr
);
234 ok(parent
== (IUnknown
*)device
, "Got parent %p, expected %p.\n", parent
, device
);
235 IUnknown_Release(parent
);
237 hr
= IDXGIDevice_GetAdapter(device
, &adapter
);
238 ok(SUCCEEDED(hr
), "GetAdapter failed, hr %#x.\n", hr
);
240 hr
= IDXGIAdapter_EnumOutputs(adapter
, 0, &output
);
241 if (hr
== DXGI_ERROR_NOT_FOUND
)
243 skip("Adapter has not outputs, skipping output tests.\n");
247 ok(SUCCEEDED(hr
), "EnumOutputs failed, hr %#x.\n", hr
);
249 hr
= IDXGIOutput_GetParent(output
, &IID_IDXGIAdapter
, (void **)&parent
);
250 IDXGIOutput_Release(output
);
251 ok(SUCCEEDED(hr
), "GetParent failed, hr %#x.\n", hr
);
252 ok(parent
== (IUnknown
*)adapter
, "Got parent %p, expected %p.\n", parent
, adapter
);
253 IUnknown_Release(parent
);
256 hr
= IDXGIAdapter_GetParent(adapter
, &IID_IDXGIFactory
, (void **)&factory
);
257 ok(SUCCEEDED(hr
), "GetParent failed, hr %#x.\n", hr
);
259 hr
= IDXGIFactory_GetParent(factory
, &IID_IUnknown
, (void **)&parent
);
260 ok(hr
== E_NOINTERFACE
, "GetParent returned %#x, expected %#x.\n", hr
, E_NOINTERFACE
);
261 ok(parent
== NULL
, "Got parent %p, expected %p.\n", parent
, NULL
);
262 IDXGIFactory_Release(factory
);
264 hr
= IDXGIDevice_GetParent(device
, &IID_IDXGIAdapter
, (void **)&parent
);
265 ok(SUCCEEDED(hr
), "GetParent failed, hr %#x.\n", hr
);
266 ok(parent
== (IUnknown
*)adapter
, "Got parent %p, expected %p.\n", parent
, adapter
);
267 IUnknown_Release(parent
);
269 IDXGIAdapter_Release(adapter
);
270 refcount
= IDXGIDevice_Release(device
);
271 ok(!refcount
, "Device has %u references left.\n", refcount
);
274 static void test_output(void)
276 IDXGIAdapter
*adapter
;
281 UINT mode_count
, mode_count_comp
, i
;
282 DXGI_MODE_DESC
*modes
;
284 if (!(device
= create_device()))
286 skip("Failed to create device, skipping tests.\n");
290 hr
= IDXGIDevice_GetAdapter(device
, &adapter
);
291 ok(SUCCEEDED(hr
), "GetAdapter failed, hr %#x.\n", hr
);
293 hr
= IDXGIAdapter_EnumOutputs(adapter
, 0, &output
);
294 if (hr
== DXGI_ERROR_NOT_FOUND
)
296 skip("Adapter doesn't have any outputs, skipping tests.\n");
297 IDXGIAdapter_Release(adapter
);
298 IDXGIDevice_Release(device
);
301 ok(SUCCEEDED(hr
), "EnumOutputs failed, hr %#x.\n", hr
);
303 hr
= IDXGIOutput_GetDisplayModeList(output
, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, NULL
, NULL
);
304 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
306 hr
= IDXGIOutput_GetDisplayModeList(output
, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, &mode_count
, NULL
);
308 || broken(hr
== DXGI_ERROR_NOT_CURRENTLY_AVAILABLE
), /* Remote Desktop Services / Win 7 testbot */
309 "Failed to list modes, hr %#x.\n", hr
);
310 if (hr
== DXGI_ERROR_NOT_CURRENTLY_AVAILABLE
)
312 skip("GetDisplayModeList() not supported, skipping tests.\n");
313 IDXGIOutput_Release(output
);
314 IDXGIAdapter_Release(adapter
);
315 IDXGIDevice_Release(device
);
318 mode_count_comp
= mode_count
;
320 hr
= IDXGIOutput_GetDisplayModeList(output
, 0, 0, &mode_count
, NULL
);
321 ok(SUCCEEDED(hr
), "Failed to list modes, hr %#x.\n", hr
);
322 ok(!mode_count
, "Got unexpected mode_count %u.\n", mode_count
);
324 hr
= IDXGIOutput_GetDisplayModeList(output
, DXGI_FORMAT_R8G8B8A8_UNORM
,
325 DXGI_ENUM_MODES_SCALING
, &mode_count
, NULL
);
326 ok(SUCCEEDED(hr
), "Failed to list modes, hr %#x.\n", hr
);
327 ok(mode_count
>= mode_count_comp
, "Got unexpected mode_count %u, expected >= %u.\n", mode_count
, mode_count_comp
);
328 mode_count_comp
= mode_count
;
330 modes
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*modes
) * (mode_count
+ 10));
332 hr
= IDXGIOutput_GetDisplayModeList(output
, DXGI_FORMAT_R8G8B8A8_UNORM
,
333 DXGI_ENUM_MODES_SCALING
, NULL
, modes
);
334 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
335 ok(!modes
[0].Height
, "No output was expected.\n");
338 hr
= IDXGIOutput_GetDisplayModeList(output
, DXGI_FORMAT_R8G8B8A8_UNORM
,
339 DXGI_ENUM_MODES_SCALING
, &mode_count
, modes
);
340 ok(hr
== DXGI_ERROR_MORE_DATA
, "Got unexpected hr %#x.\n", hr
);
341 ok(!modes
[0].Height
, "No output was expected.\n");
343 mode_count
= mode_count_comp
;
344 hr
= IDXGIOutput_GetDisplayModeList(output
, DXGI_FORMAT_R8G8B8A8_UNORM
,
345 DXGI_ENUM_MODES_SCALING
, &mode_count
, modes
);
346 ok(SUCCEEDED(hr
), "Failed to list modes, hr %#x.\n", hr
);
347 ok(mode_count
== mode_count_comp
, "Got unexpected mode_count %u, expected %u.\n", mode_count
, mode_count_comp
);
349 for (i
= 0; i
< mode_count
; i
++)
351 ok(modes
[i
].Height
&& modes
[i
].Width
, "Proper mode was expected\n");
355 hr
= IDXGIOutput_GetDisplayModeList(output
, DXGI_FORMAT_R8G8B8A8_UNORM
,
356 DXGI_ENUM_MODES_SCALING
, &mode_count
, modes
);
357 ok(SUCCEEDED(hr
), "Failed to list modes, hr %#x.\n", hr
);
358 ok(mode_count
== mode_count_comp
, "Got unexpected mode_count %u, expected %u.\n", mode_count
, mode_count_comp
);
362 mode_count
= mode_count_comp
- 1;
363 hr
= IDXGIOutput_GetDisplayModeList(output
, DXGI_FORMAT_R8G8B8A8_UNORM
,
364 DXGI_ENUM_MODES_SCALING
, &mode_count
, modes
);
365 ok(hr
== DXGI_ERROR_MORE_DATA
, "Got unexpected hr %#x.\n", hr
);
366 ok(mode_count
== mode_count_comp
- 1, "Got unexpected mode_count %u, expected %u.\n",
367 mode_count
, mode_count_comp
- 1);
371 skip("Not enough modes for test, skipping.\n");
374 HeapFree(GetProcessHeap(), 0, modes
);
375 IDXGIOutput_Release(output
);
376 IDXGIAdapter_Release(adapter
);
377 refcount
= IDXGIDevice_Release(device
);
378 ok(!refcount
, "Device has %u references left.\n", refcount
);
385 BOOL numerator_should_pass
;
386 BOOL denominator_should_pass
;
389 static void test_createswapchain(void)
392 IDXGIAdapter
*adapter
;
393 IDXGIFactory
*factory
;
396 IDXGISwapChain
*swapchain
;
397 DXGI_SWAP_CHAIN_DESC creation_desc
, result_desc
;
401 const struct refresh_rates refresh_list
[] =
403 {60, 60, FALSE
, FALSE
},
404 {60, 0, TRUE
, FALSE
},
406 { 0, 60, TRUE
, FALSE
},
407 { 0, 0, TRUE
, FALSE
},
410 if (!(device
= create_device()))
412 skip("Failed to create device, skipping tests.\n");
416 creation_desc
.OutputWindow
= 0;
417 creation_desc
.BufferDesc
.Width
= 800;
418 creation_desc
.BufferDesc
.Height
= 600;
419 creation_desc
.BufferDesc
.RefreshRate
.Numerator
= 60;
420 creation_desc
.BufferDesc
.RefreshRate
.Denominator
= 60;
421 creation_desc
.BufferDesc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
422 creation_desc
.BufferDesc
.ScanlineOrdering
= DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED
;
423 creation_desc
.BufferDesc
.Scaling
= DXGI_MODE_SCALING_UNSPECIFIED
;
424 creation_desc
.SampleDesc
.Count
= 1;
425 creation_desc
.SampleDesc
.Quality
= 0;
426 creation_desc
.BufferUsage
= DXGI_USAGE_RENDER_TARGET_OUTPUT
;
427 creation_desc
.BufferCount
= 1;
428 creation_desc
.OutputWindow
= CreateWindowA("static", "dxgi_test", 0, 0, 0, 0, 0, 0, 0, 0, 0);
429 creation_desc
.Windowed
= TRUE
;
430 creation_desc
.SwapEffect
= DXGI_SWAP_EFFECT_DISCARD
;
431 creation_desc
.Flags
= 0;
433 hr
= IDXGIDevice_QueryInterface(device
, &IID_IUnknown
, (void **)&obj
);
434 ok(SUCCEEDED(hr
), "IDXGIDevice does not implement IUnknown\n");
436 hr
= IDXGIDevice_GetAdapter(device
, &adapter
);
437 ok(SUCCEEDED(hr
), "GetAdapter failed, hr %#x.\n", hr
);
439 hr
= IDXGIAdapter_GetParent(adapter
, &IID_IDXGIFactory
, (void **)&factory
);
440 ok(SUCCEEDED(hr
), "GetParent failed, hr %#x.\n", hr
);
442 hr
= IDXGIFactory_CreateSwapChain(factory
, obj
, &creation_desc
, &swapchain
);
443 ok(SUCCEEDED(hr
), "CreateSwapChain failed, hr %#x.\n", hr
);
445 hr
= IDXGISwapChain_GetDesc(swapchain
, NULL
);
446 ok(hr
== E_INVALIDARG
, "GetDesc unexpectedly returned %#x.\n", hr
);
448 IDXGISwapChain_Release(swapchain
);
450 for (i
= 0; i
< sizeof(refresh_list
)/sizeof(refresh_list
[0]); i
++)
452 creation_desc
.BufferDesc
.RefreshRate
.Numerator
= refresh_list
[i
].numerator
;
453 creation_desc
.BufferDesc
.RefreshRate
.Denominator
= refresh_list
[i
].denominator
;
455 hr
= IDXGIFactory_CreateSwapChain(factory
, obj
, &creation_desc
, &swapchain
);
456 ok(SUCCEEDED(hr
), "CreateSwapChain failed, hr %#x.\n", hr
);
458 hr
= IDXGISwapChain_GetDesc(swapchain
, &result_desc
);
459 ok(SUCCEEDED(hr
), "GetDesc failed, hr %#x.\n", hr
);
461 if (refresh_list
[i
].numerator_should_pass
)
462 ok(result_desc
.BufferDesc
.RefreshRate
.Numerator
== refresh_list
[i
].numerator
,
463 "Numerator %u is %u.\n", i
, result_desc
.BufferDesc
.RefreshRate
.Numerator
);
465 todo_wine
ok(result_desc
.BufferDesc
.RefreshRate
.Numerator
== refresh_list
[i
].numerator
,
466 "Numerator %u is %u.\n", i
, result_desc
.BufferDesc
.RefreshRate
.Numerator
);
468 if (refresh_list
[i
].denominator_should_pass
)
469 ok(result_desc
.BufferDesc
.RefreshRate
.Denominator
== refresh_list
[i
].denominator
,
470 "Denominator %u is %u.\n", i
,result_desc
.BufferDesc
.RefreshRate
.Denominator
);
472 todo_wine
ok(result_desc
.BufferDesc
.RefreshRate
.Denominator
== refresh_list
[i
].denominator
,
473 "Denominator %u is %u.\n", i
, result_desc
.BufferDesc
.RefreshRate
.Denominator
);
475 IDXGISwapChain_Release(swapchain
);
478 creation_desc
.Windowed
= FALSE
;
480 for (i
= 0; i
< sizeof(refresh_list
)/sizeof(refresh_list
[0]); i
++)
482 creation_desc
.BufferDesc
.RefreshRate
.Numerator
= refresh_list
[i
].numerator
;
483 creation_desc
.BufferDesc
.RefreshRate
.Denominator
= refresh_list
[i
].denominator
;
485 hr
= IDXGIFactory_CreateSwapChain(factory
, obj
, &creation_desc
, &swapchain
);
486 ok(SUCCEEDED(hr
), "CreateSwapChain failed, hr %#x.\n", hr
);
488 hr
= IDXGISwapChain_GetDesc(swapchain
, &result_desc
);
489 ok(SUCCEEDED(hr
), "GetDesc failed, hr %#x.\n", hr
);
491 if (refresh_list
[i
].numerator_should_pass
)
492 ok(result_desc
.BufferDesc
.RefreshRate
.Numerator
== refresh_list
[i
].numerator
,
493 "Numerator %u is %u.\n", i
, result_desc
.BufferDesc
.RefreshRate
.Numerator
);
495 todo_wine
ok(result_desc
.BufferDesc
.RefreshRate
.Numerator
== refresh_list
[i
].numerator
,
496 "Numerator %u is %u.\n", i
, result_desc
.BufferDesc
.RefreshRate
.Numerator
);
498 if (refresh_list
[i
].denominator_should_pass
)
499 ok(result_desc
.BufferDesc
.RefreshRate
.Denominator
== refresh_list
[i
].denominator
,
500 "Denominator %u is %u.\n", i
,result_desc
.BufferDesc
.RefreshRate
.Denominator
);
502 todo_wine
ok(result_desc
.BufferDesc
.RefreshRate
.Denominator
== refresh_list
[i
].denominator
,
503 "Denominator %u is %u.\n", i
, result_desc
.BufferDesc
.RefreshRate
.Denominator
);
505 hr
= IDXGISwapChain_SetFullscreenState(swapchain
, FALSE
, NULL
);
506 todo_wine
ok(SUCCEEDED(hr
), "SetFullscreenState failed, hr %#x.\n", hr
);
508 IDXGISwapChain_Release(swapchain
);
511 IDXGIFactory_Release(factory
);
512 IDXGIAdapter_Release(adapter
);
513 IUnknown_Release(obj
);
514 refcount
= IDXGIDevice_Release(device
);
515 ok(!refcount
, "Device has %u references left.\n", refcount
);
518 static void test_create_factory(void)
520 IDXGIFactory1
*factory
;
524 iface
= (void *)0xdeadbeef;
525 hr
= CreateDXGIFactory(&IID_IDXGIDevice
, (void **)&iface
);
526 ok(hr
== E_NOINTERFACE
, "Got unexpected hr %#x.\n", hr
);
527 ok(!iface
, "Got unexpected iface %p.\n", iface
);
529 hr
= CreateDXGIFactory(&IID_IUnknown
, (void **)&iface
);
530 ok(SUCCEEDED(hr
), "Failed to create factory with IID_IUnknown, hr %#x.\n", hr
);
531 IUnknown_Release(iface
);
533 hr
= CreateDXGIFactory(&IID_IDXGIObject
, (void **)&iface
);
534 ok(SUCCEEDED(hr
), "Failed to create factory with IID_IDXGIObject, hr %#x.\n", hr
);
535 IUnknown_Release(iface
);
537 factory
= (void *)0xdeadbeef;
538 hr
= CreateDXGIFactory(&IID_IDXGIFactory
, (void **)&iface
);
539 ok(SUCCEEDED(hr
), "Failed to create factory with IID_IDXGIFactory, hr %#x.\n", hr
);
540 hr
= IUnknown_QueryInterface(iface
, &IID_IDXGIFactory1
, (void **)&factory
);
541 ok(hr
== E_NOINTERFACE
, "Got unexpected hr %#x.\n", hr
);
542 ok(!factory
, "Got unexpected factory %p.\n", factory
);
543 IUnknown_Release(iface
);
545 iface
= (void *)0xdeadbeef;
546 hr
= CreateDXGIFactory(&IID_IDXGIFactory1
, (void **)&iface
);
547 ok(hr
== E_NOINTERFACE
, "Got unexpected hr %#x.\n", hr
);
548 ok(!iface
, "Got unexpected iface %p.\n", iface
);
550 if (!pCreateDXGIFactory1
)
552 win_skip("CreateDXGIFactory1 not available, skipping tests.\n");
556 iface
= (void *)0xdeadbeef;
557 hr
= pCreateDXGIFactory1(&IID_IDXGIDevice
, (void **)&iface
);
558 ok(hr
== E_NOINTERFACE
, "Got unexpected hr %#x.\n", hr
);
559 ok(!iface
, "Got unexpected iface %p.\n", iface
);
561 hr
= pCreateDXGIFactory1(&IID_IUnknown
, (void **)&iface
);
562 ok(SUCCEEDED(hr
), "Failed to create factory with IID_IUnknown, hr %#x.\n", hr
);
563 IUnknown_Release(iface
);
565 hr
= pCreateDXGIFactory1(&IID_IDXGIObject
, (void **)&iface
);
566 ok(SUCCEEDED(hr
), "Failed to create factory with IID_IDXGIObject, hr %#x.\n", hr
);
567 IUnknown_Release(iface
);
569 hr
= pCreateDXGIFactory1(&IID_IDXGIFactory
, (void **)&iface
);
570 ok(SUCCEEDED(hr
), "Failed to create factory with IID_IDXGIFactory, hr %#x.\n", hr
);
571 hr
= IUnknown_QueryInterface(iface
, &IID_IDXGIFactory1
, (void **)&factory
);
572 ok(SUCCEEDED(hr
), "Failed to query IDXGIFactory1 interface, hr %#x.\n", hr
);
573 IDXGIFactory1_Release(factory
);
574 IUnknown_Release(iface
);
576 hr
= pCreateDXGIFactory1(&IID_IDXGIFactory1
, (void **)&iface
);
577 ok(SUCCEEDED(hr
), "Failed to create factory with IID_IDXGIFactory1, hr %#x.\n", hr
);
578 IUnknown_Release(iface
);
581 static void test_private_data(void)
583 ULONG refcount
, expected_refcount
;
586 IDXGIDevice
*test_object
;
588 static const DWORD data
[] = {1, 2, 3, 4};
590 static const GUID dxgi_private_data_test_guid
=
595 {0xa3, 0x7f, 0x9b, 0x1d, 0xf4, 0x88, 0xc5, 0xfc}
597 static const GUID dxgi_private_data_test_guid2
=
602 {0x9b, 0x4b, 0x89, 0xd7, 0xd1, 0x12, 0xe7, 0x2b}
605 if (!(device
= create_device()))
607 skip("Failed to create device, skipping tests.\n");
611 test_object
= create_device();
613 /* SetPrivateData with a pointer of NULL has the purpose of FreePrivateData in previous
614 * d3d versions. A successful clear returns S_OK. A redundant clear S_FALSE. Setting a
615 * NULL interface is not considered a clear but as setting an interface pointer that
616 * happens to be NULL. */
617 hr
= IDXGIDevice_SetPrivateData(device
, &dxgi_private_data_test_guid
, 0, NULL
);
618 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
619 hr
= IDXGIDevice_SetPrivateDataInterface(device
, &dxgi_private_data_test_guid
, NULL
);
620 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
621 hr
= IDXGIDevice_SetPrivateData(device
, &dxgi_private_data_test_guid
, ~0U, NULL
);
622 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
623 hr
= IDXGIDevice_SetPrivateData(device
, &dxgi_private_data_test_guid
, ~0U, NULL
);
624 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
626 hr
= IDXGIDevice_SetPrivateDataInterface(device
, &dxgi_private_data_test_guid
, NULL
);
627 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
628 size
= sizeof(ptr
) * 2;
629 ptr
= (IUnknown
*)0xdeadbeef;
630 hr
= IDXGIDevice_GetPrivateData(device
, &dxgi_private_data_test_guid
, &size
, &ptr
);
631 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
632 ok(!ptr
, "Got unexpected pointer %p.\n", ptr
);
633 ok(size
== sizeof(IUnknown
*), "Got unexpected size %u.\n", size
);
635 refcount
= get_refcount((IUnknown
*)test_object
);
636 hr
= IDXGIDevice_SetPrivateDataInterface(device
, &dxgi_private_data_test_guid
,
637 (IUnknown
*)test_object
);
638 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
639 expected_refcount
= refcount
+ 1;
640 refcount
= get_refcount((IUnknown
*)test_object
);
641 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
642 hr
= IDXGIDevice_SetPrivateDataInterface(device
, &dxgi_private_data_test_guid
,
643 (IUnknown
*)test_object
);
644 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
645 refcount
= get_refcount((IUnknown
*)test_object
);
646 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
648 hr
= IDXGIDevice_SetPrivateDataInterface(device
, &dxgi_private_data_test_guid
, NULL
);
649 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
651 refcount
= get_refcount((IUnknown
*)test_object
);
652 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
654 hr
= IDXGIDevice_SetPrivateDataInterface(device
, &dxgi_private_data_test_guid
,
655 (IUnknown
*)test_object
);
656 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
658 hr
= IDXGIDevice_SetPrivateData(device
, &dxgi_private_data_test_guid
, size
, data
);
659 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
660 refcount
= get_refcount((IUnknown
*)test_object
);
661 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
662 hr
= IDXGIDevice_SetPrivateData(device
, &dxgi_private_data_test_guid
, 42, NULL
);
663 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
664 hr
= IDXGIDevice_SetPrivateData(device
, &dxgi_private_data_test_guid
, 42, NULL
);
665 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
667 hr
= IDXGIDevice_SetPrivateDataInterface(device
, &dxgi_private_data_test_guid
,
668 (IUnknown
*)test_object
);
669 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
671 size
= 2 * sizeof(ptr
);
673 hr
= IDXGIDevice_GetPrivateData(device
, &dxgi_private_data_test_guid
, &size
, &ptr
);
674 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
675 ok(size
== sizeof(test_object
), "Got unexpected size %u.\n", size
);
677 refcount
= get_refcount((IUnknown
*)test_object
);
678 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
680 IUnknown_Release(ptr
);
683 ptr
= (IUnknown
*)0xdeadbeef;
685 hr
= IDXGIDevice_GetPrivateData(device
, &dxgi_private_data_test_guid
, &size
, NULL
);
686 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
687 ok(size
== sizeof(device
), "Got unexpected size %u.\n", size
);
688 size
= 2 * sizeof(ptr
);
689 hr
= IDXGIDevice_GetPrivateData(device
, &dxgi_private_data_test_guid
, &size
, NULL
);
690 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
691 ok(size
== sizeof(device
), "Got unexpected size %u.\n", size
);
692 refcount
= get_refcount((IUnknown
*)test_object
);
693 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
696 hr
= IDXGIDevice_GetPrivateData(device
, &dxgi_private_data_test_guid
, &size
, &ptr
);
697 ok(hr
== DXGI_ERROR_MORE_DATA
, "Got unexpected hr %#x.\n", hr
);
698 ok(size
== sizeof(device
), "Got unexpected size %u.\n", size
);
699 ok(ptr
== (IUnknown
*)0xdeadbeef, "Got unexpected pointer %p.\n", ptr
);
700 hr
= IDXGIDevice_GetPrivateData(device
, &dxgi_private_data_test_guid2
, NULL
, NULL
);
701 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
703 hr
= IDXGIDevice_GetPrivateData(device
, &dxgi_private_data_test_guid2
, &size
, &ptr
);
704 ok(hr
== DXGI_ERROR_NOT_FOUND
, "Got unexpected hr %#x.\n", hr
);
705 ok(size
== 0, "Got unexpected size %u.\n", size
);
706 ok(ptr
== (IUnknown
*)0xdeadbeef, "Got unexpected pointer %p.\n", ptr
);
707 hr
= IDXGIDevice_GetPrivateData(device
, &dxgi_private_data_test_guid
, NULL
, &ptr
);
708 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
709 ok(ptr
== (IUnknown
*)0xdeadbeef, "Got unexpected pointer %p.\n", ptr
);
711 refcount
= IDXGIDevice_Release(device
);
712 ok(!refcount
, "Device has %u references left.\n", refcount
);
713 refcount
= IDXGIDevice_Release(test_object
);
714 ok(!refcount
, "Test object has %u references left.\n", refcount
);
717 static void test_swapchain_resize(void)
719 DXGI_SWAP_CHAIN_DESC swapchain_desc
;
720 D3D10_TEXTURE2D_DESC texture_desc
;
721 DXGI_SURFACE_DESC surface_desc
;
722 IDXGISwapChain
*swapchain
;
723 ID3D10Texture2D
*texture
;
724 IDXGISurface
*surface
;
725 IDXGIAdapter
*adapter
;
726 IDXGIFactory
*factory
;
734 if (!(device
= create_device()))
736 skip("Failed to create device, skipping tests.\n");
739 window
= CreateWindowA("static", "dxgi_test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
740 0, 0, 640, 480, NULL
, NULL
, NULL
, NULL
);
741 ret
= GetClientRect(window
, &client_rect
);
742 ok(ret
, "Failed to get client rect.\n");
744 hr
= IDXGIDevice_GetAdapter(device
, &adapter
);
745 ok(SUCCEEDED(hr
), "Failed to get adapter, hr %#x.\n", hr
);
746 hr
= IDXGIAdapter_GetParent(adapter
, &IID_IDXGIFactory
, (void **)&factory
);
747 ok(SUCCEEDED(hr
), "Failed to get factory, hr %#x.\n", hr
);
748 IDXGIAdapter_Release(adapter
);
750 swapchain_desc
.BufferDesc
.Width
= 640;
751 swapchain_desc
.BufferDesc
.Height
= 480;
752 swapchain_desc
.BufferDesc
.RefreshRate
.Numerator
= 60;
753 swapchain_desc
.BufferDesc
.RefreshRate
.Denominator
= 1;
754 swapchain_desc
.BufferDesc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
755 swapchain_desc
.BufferDesc
.ScanlineOrdering
= DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED
;
756 swapchain_desc
.BufferDesc
.Scaling
= DXGI_MODE_SCALING_UNSPECIFIED
;
757 swapchain_desc
.SampleDesc
.Count
= 1;
758 swapchain_desc
.SampleDesc
.Quality
= 0;
759 swapchain_desc
.BufferUsage
= DXGI_USAGE_RENDER_TARGET_OUTPUT
;
760 swapchain_desc
.BufferCount
= 1;
761 swapchain_desc
.OutputWindow
= window
;
762 swapchain_desc
.Windowed
= TRUE
;
763 swapchain_desc
.SwapEffect
= DXGI_SWAP_EFFECT_DISCARD
;
764 swapchain_desc
.Flags
= 0;
766 hr
= IDXGIFactory_CreateSwapChain(factory
, (IUnknown
*)device
, &swapchain_desc
, &swapchain
);
767 ok(SUCCEEDED(hr
), "Failed to create swapchain, hr %#x.\n", hr
);
768 IDXGIFactory_Release(factory
);
769 hr
= IDXGISwapChain_GetBuffer(swapchain
, 0, &IID_IDXGISurface
, (void **)&surface
);
770 ok(SUCCEEDED(hr
), "Failed to get buffer, hr %#x.\n", hr
);
771 hr
= IDXGISwapChain_GetBuffer(swapchain
, 0, &IID_ID3D10Texture2D
, (void **)&texture
);
772 ok(SUCCEEDED(hr
), "Failed to get buffer, hr %#x.\n", hr
);
774 ret
= GetClientRect(window
, &r
);
775 ok(ret
, "Failed to get client rect.\n");
776 ok(EqualRect(&r
, &client_rect
), "Got unexpected rect {%d, %d, %d, %d}, expected {%d, %d, %d, %d}.\n",
777 r
.left
, r
.top
, r
.right
, r
.bottom
,
778 client_rect
.left
, client_rect
.top
, client_rect
.right
, client_rect
.bottom
);
780 hr
= IDXGISwapChain_GetDesc(swapchain
, &swapchain_desc
);
781 ok(SUCCEEDED(hr
), "Failed to get swapchain desc, hr %#x.\n", hr
);
782 ok(swapchain_desc
.BufferDesc
.Width
== 640,
783 "Got unexpected BufferDesc.Width %u.\n", swapchain_desc
.BufferDesc
.Width
);
784 ok(swapchain_desc
.BufferDesc
.Height
== 480,
785 "Got unexpected bufferDesc.Height %u.\n", swapchain_desc
.BufferDesc
.Height
);
786 ok(swapchain_desc
.BufferDesc
.RefreshRate
.Numerator
== 60,
787 "Got unexpected BufferDesc.RefreshRate.Numerator %u.\n",
788 swapchain_desc
.BufferDesc
.RefreshRate
.Numerator
);
789 ok(swapchain_desc
.BufferDesc
.RefreshRate
.Denominator
== 1,
790 "Got unexpected BufferDesc.RefreshRate.Denominator %u.\n",
791 swapchain_desc
.BufferDesc
.RefreshRate
.Denominator
);
792 ok(swapchain_desc
.BufferDesc
.Format
== DXGI_FORMAT_R8G8B8A8_UNORM
,
793 "Got unexpected BufferDesc.Format %#x.\n", swapchain_desc
.BufferDesc
.Format
);
794 ok(swapchain_desc
.BufferDesc
.ScanlineOrdering
== DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED
,
795 "Got unexpected BufferDesc.ScanlineOrdering %#x.\n", swapchain_desc
.BufferDesc
.ScanlineOrdering
);
796 ok(swapchain_desc
.BufferDesc
.Scaling
== DXGI_MODE_SCALING_UNSPECIFIED
,
797 "Got unexpected BufferDesc.Scaling %#x.\n", swapchain_desc
.BufferDesc
.Scaling
);
798 ok(swapchain_desc
.SampleDesc
.Count
== 1,
799 "Got unexpected SampleDesc.Count %u.\n", swapchain_desc
.SampleDesc
.Count
);
800 ok(!swapchain_desc
.SampleDesc
.Quality
,
801 "Got unexpected SampleDesc.Quality %u.\n", swapchain_desc
.SampleDesc
.Quality
);
802 ok(swapchain_desc
.BufferUsage
== DXGI_USAGE_RENDER_TARGET_OUTPUT
,
803 "Got unexpected BufferUsage %#x.\n", swapchain_desc
.BufferUsage
);
804 ok(swapchain_desc
.BufferCount
== 1,
805 "Got unexpected BufferCount %u.\n", swapchain_desc
.BufferCount
);
806 ok(swapchain_desc
.OutputWindow
== window
,
807 "Got unexpected OutputWindow %p, expected %p.\n", swapchain_desc
.OutputWindow
, window
);
808 ok(swapchain_desc
.Windowed
,
809 "Got unexpected Windowed %#x.\n", swapchain_desc
.Windowed
);
810 ok(swapchain_desc
.SwapEffect
== DXGI_SWAP_EFFECT_DISCARD
,
811 "Got unexpected SwapEffect %#x.\n", swapchain_desc
.SwapEffect
);
812 ok(!swapchain_desc
.Flags
,
813 "Got unexpected Flags %#x.\n", swapchain_desc
.Flags
);
815 hr
= IDXGISurface_GetDesc(surface
, &surface_desc
);
816 ok(SUCCEEDED(hr
), "Failed to get surface desc, hr %#x.\n", hr
);
817 ok(surface_desc
.Width
== 640, "Got unexpected Width %u.\n", surface_desc
.Width
);
818 ok(surface_desc
.Height
== 480, "Got unexpected Height %u.\n", surface_desc
.Height
);
819 ok(surface_desc
.Format
== DXGI_FORMAT_R8G8B8A8_UNORM
, "Got unexpected Format %#x.\n", surface_desc
.Format
);
820 ok(surface_desc
.SampleDesc
.Count
== 1, "Got unexpected SampleDesc.Count %u.\n", surface_desc
.SampleDesc
.Count
);
821 ok(!surface_desc
.SampleDesc
.Quality
, "Got unexpected SampleDesc.Quality %u.\n", surface_desc
.SampleDesc
.Quality
);
823 ID3D10Texture2D_GetDesc(texture
, &texture_desc
);
824 ok(texture_desc
.Width
== 640, "Got unexpected Width %u.\n", texture_desc
.Width
);
825 ok(texture_desc
.Height
== 480, "Got unexpected Height %u.\n", texture_desc
.Height
);
826 ok(texture_desc
.MipLevels
== 1, "Got unexpected MipLevels %u.\n", texture_desc
.MipLevels
);
827 ok(texture_desc
.ArraySize
== 1, "Got unexpected ArraySize %u.\n", texture_desc
.ArraySize
);
828 ok(texture_desc
.Format
== DXGI_FORMAT_R8G8B8A8_UNORM
, "Got unexpected Format %#x.\n", texture_desc
.Format
);
829 ok(texture_desc
.SampleDesc
.Count
== 1, "Got unexpected SampleDesc.Count %u.\n", texture_desc
.SampleDesc
.Count
);
830 ok(!texture_desc
.SampleDesc
.Quality
, "Got unexpected SampleDesc.Quality %u.\n", texture_desc
.SampleDesc
.Quality
);
831 ok(texture_desc
.Usage
== D3D10_USAGE_DEFAULT
, "Got unexpected Usage %#x.\n", texture_desc
.Usage
);
832 ok(texture_desc
.BindFlags
== D3D10_BIND_RENDER_TARGET
, "Got unexpected BindFlags %#x.\n", texture_desc
.BindFlags
);
833 ok(!texture_desc
.CPUAccessFlags
, "Got unexpected CPUAccessFlags %#x.\n", texture_desc
.CPUAccessFlags
);
834 ok(!texture_desc
.MiscFlags
, "Got unexpected MiscFlags %#x.\n", texture_desc
.MiscFlags
);
836 hr
= IDXGISwapChain_ResizeBuffers(swapchain
, 1, 320, 240, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
, 0);
837 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
839 ret
= GetClientRect(window
, &r
);
840 ok(ret
, "Failed to get client rect.\n");
841 ok(EqualRect(&r
, &client_rect
), "Got unexpected rect {%d, %d, %d, %d}, expected {%d, %d, %d, %d}.\n",
842 r
.left
, r
.top
, r
.right
, r
.bottom
,
843 client_rect
.left
, client_rect
.top
, client_rect
.right
, client_rect
.bottom
);
845 hr
= IDXGISwapChain_GetDesc(swapchain
, &swapchain_desc
);
846 ok(SUCCEEDED(hr
), "Failed to get swapchain desc, hr %#x.\n", hr
);
847 ok(swapchain_desc
.BufferDesc
.Width
== 640,
848 "Got unexpected BufferDesc.Width %u.\n", swapchain_desc
.BufferDesc
.Width
);
849 ok(swapchain_desc
.BufferDesc
.Height
== 480,
850 "Got unexpected bufferDesc.Height %u.\n", swapchain_desc
.BufferDesc
.Height
);
851 ok(swapchain_desc
.BufferDesc
.RefreshRate
.Numerator
== 60,
852 "Got unexpected BufferDesc.RefreshRate.Numerator %u.\n",
853 swapchain_desc
.BufferDesc
.RefreshRate
.Numerator
);
854 ok(swapchain_desc
.BufferDesc
.RefreshRate
.Denominator
== 1,
855 "Got unexpected BufferDesc.RefreshRate.Denominator %u.\n",
856 swapchain_desc
.BufferDesc
.RefreshRate
.Denominator
);
857 ok(swapchain_desc
.BufferDesc
.Format
== DXGI_FORMAT_R8G8B8A8_UNORM
,
858 "Got unexpected BufferDesc.Format %#x.\n", swapchain_desc
.BufferDesc
.Format
);
859 ok(swapchain_desc
.BufferDesc
.ScanlineOrdering
== DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED
,
860 "Got unexpected BufferDesc.ScanlineOrdering %#x.\n", swapchain_desc
.BufferDesc
.ScanlineOrdering
);
861 ok(swapchain_desc
.BufferDesc
.Scaling
== DXGI_MODE_SCALING_UNSPECIFIED
,
862 "Got unexpected BufferDesc.Scaling %#x.\n", swapchain_desc
.BufferDesc
.Scaling
);
863 ok(swapchain_desc
.SampleDesc
.Count
== 1,
864 "Got unexpected SampleDesc.Count %u.\n", swapchain_desc
.SampleDesc
.Count
);
865 ok(!swapchain_desc
.SampleDesc
.Quality
,
866 "Got unexpected SampleDesc.Quality %u.\n", swapchain_desc
.SampleDesc
.Quality
);
867 ok(swapchain_desc
.BufferUsage
== DXGI_USAGE_RENDER_TARGET_OUTPUT
,
868 "Got unexpected BufferUsage %#x.\n", swapchain_desc
.BufferUsage
);
869 ok(swapchain_desc
.BufferCount
== 1,
870 "Got unexpected BufferCount %u.\n", swapchain_desc
.BufferCount
);
871 ok(swapchain_desc
.OutputWindow
== window
,
872 "Got unexpected OutputWindow %p, expected %p.\n", swapchain_desc
.OutputWindow
, window
);
873 ok(swapchain_desc
.Windowed
,
874 "Got unexpected Windowed %#x.\n", swapchain_desc
.Windowed
);
875 ok(swapchain_desc
.SwapEffect
== DXGI_SWAP_EFFECT_DISCARD
,
876 "Got unexpected SwapEffect %#x.\n", swapchain_desc
.SwapEffect
);
877 ok(!swapchain_desc
.Flags
,
878 "Got unexpected Flags %#x.\n", swapchain_desc
.Flags
);
880 hr
= IDXGISurface_GetDesc(surface
, &surface_desc
);
881 ok(SUCCEEDED(hr
), "Failed to get surface desc, hr %#x.\n", hr
);
882 ok(surface_desc
.Width
== 640, "Got unexpected Width %u.\n", surface_desc
.Width
);
883 ok(surface_desc
.Height
== 480, "Got unexpected Height %u.\n", surface_desc
.Height
);
884 ok(surface_desc
.Format
== DXGI_FORMAT_R8G8B8A8_UNORM
, "Got unexpected Format %#x.\n", surface_desc
.Format
);
885 ok(surface_desc
.SampleDesc
.Count
== 1, "Got unexpected SampleDesc.Count %u.\n", surface_desc
.SampleDesc
.Count
);
886 ok(!surface_desc
.SampleDesc
.Quality
, "Got unexpected SampleDesc.Quality %u.\n", surface_desc
.SampleDesc
.Quality
);
888 ID3D10Texture2D_GetDesc(texture
, &texture_desc
);
889 ok(texture_desc
.Width
== 640, "Got unexpected Width %u.\n", texture_desc
.Width
);
890 ok(texture_desc
.Height
== 480, "Got unexpected Height %u.\n", texture_desc
.Height
);
891 ok(texture_desc
.MipLevels
== 1, "Got unexpected MipLevels %u.\n", texture_desc
.MipLevels
);
892 ok(texture_desc
.ArraySize
== 1, "Got unexpected ArraySize %u.\n", texture_desc
.ArraySize
);
893 ok(texture_desc
.Format
== DXGI_FORMAT_R8G8B8A8_UNORM
, "Got unexpected Format %#x.\n", texture_desc
.Format
);
894 ok(texture_desc
.SampleDesc
.Count
== 1, "Got unexpected SampleDesc.Count %u.\n", texture_desc
.SampleDesc
.Count
);
895 ok(!texture_desc
.SampleDesc
.Quality
, "Got unexpected SampleDesc.Quality %u.\n", texture_desc
.SampleDesc
.Quality
);
896 ok(texture_desc
.Usage
== D3D10_USAGE_DEFAULT
, "Got unexpected Usage %#x.\n", texture_desc
.Usage
);
897 ok(texture_desc
.BindFlags
== D3D10_BIND_RENDER_TARGET
, "Got unexpected BindFlags %#x.\n", texture_desc
.BindFlags
);
898 ok(!texture_desc
.CPUAccessFlags
, "Got unexpected CPUAccessFlags %#x.\n", texture_desc
.CPUAccessFlags
);
899 ok(!texture_desc
.MiscFlags
, "Got unexpected MiscFlags %#x.\n", texture_desc
.MiscFlags
);
901 ID3D10Texture2D_Release(texture
);
902 IDXGISurface_Release(surface
);
903 hr
= IDXGISwapChain_ResizeBuffers(swapchain
, 1, 320, 240, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
, 0);
904 ok(SUCCEEDED(hr
), "Failed to resize buffers, hr %#x.\n", hr
);
905 hr
= IDXGISwapChain_GetBuffer(swapchain
, 0, &IID_IDXGISurface
, (void **)&surface
);
906 ok(SUCCEEDED(hr
), "Failed to get buffer, hr %#x.\n", hr
);
907 hr
= IDXGISwapChain_GetBuffer(swapchain
, 0, &IID_ID3D10Texture2D
, (void **)&texture
);
908 ok(SUCCEEDED(hr
), "Failed to get buffer, hr %#x.\n", hr
);
910 ret
= GetClientRect(window
, &r
);
911 ok(ret
, "Failed to get client rect.\n");
912 ok(EqualRect(&r
, &client_rect
), "Got unexpected rect {%d, %d, %d, %d}, expected {%d, %d, %d, %d}.\n",
913 r
.left
, r
.top
, r
.right
, r
.bottom
,
914 client_rect
.left
, client_rect
.top
, client_rect
.right
, client_rect
.bottom
);
916 hr
= IDXGISwapChain_GetDesc(swapchain
, &swapchain_desc
);
917 ok(SUCCEEDED(hr
), "Failed to get swapchain desc, hr %#x.\n", hr
);
918 ok(swapchain_desc
.BufferDesc
.Width
== 320,
919 "Got unexpected BufferDesc.Width %u.\n", swapchain_desc
.BufferDesc
.Width
);
920 ok(swapchain_desc
.BufferDesc
.Height
== 240,
921 "Got unexpected bufferDesc.Height %u.\n", swapchain_desc
.BufferDesc
.Height
);
922 ok(swapchain_desc
.BufferDesc
.RefreshRate
.Numerator
== 60,
923 "Got unexpected BufferDesc.RefreshRate.Numerator %u.\n",
924 swapchain_desc
.BufferDesc
.RefreshRate
.Numerator
);
925 ok(swapchain_desc
.BufferDesc
.RefreshRate
.Denominator
== 1,
926 "Got unexpected BufferDesc.RefreshRate.Denominator %u.\n",
927 swapchain_desc
.BufferDesc
.RefreshRate
.Denominator
);
928 ok(swapchain_desc
.BufferDesc
.Format
== DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
929 "Got unexpected BufferDesc.Format %#x.\n", swapchain_desc
.BufferDesc
.Format
);
930 ok(swapchain_desc
.BufferDesc
.ScanlineOrdering
== DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED
,
931 "Got unexpected BufferDesc.ScanlineOrdering %#x.\n", swapchain_desc
.BufferDesc
.ScanlineOrdering
);
932 ok(swapchain_desc
.BufferDesc
.Scaling
== DXGI_MODE_SCALING_UNSPECIFIED
,
933 "Got unexpected BufferDesc.Scaling %#x.\n", swapchain_desc
.BufferDesc
.Scaling
);
934 ok(swapchain_desc
.SampleDesc
.Count
== 1,
935 "Got unexpected SampleDesc.Count %u.\n", swapchain_desc
.SampleDesc
.Count
);
936 ok(!swapchain_desc
.SampleDesc
.Quality
,
937 "Got unexpected SampleDesc.Quality %u.\n", swapchain_desc
.SampleDesc
.Quality
);
938 ok(swapchain_desc
.BufferUsage
== DXGI_USAGE_RENDER_TARGET_OUTPUT
,
939 "Got unexpected BufferUsage %#x.\n", swapchain_desc
.BufferUsage
);
940 ok(swapchain_desc
.BufferCount
== 1,
941 "Got unexpected BufferCount %u.\n", swapchain_desc
.BufferCount
);
942 ok(swapchain_desc
.OutputWindow
== window
,
943 "Got unexpected OutputWindow %p, expected %p.\n", swapchain_desc
.OutputWindow
, window
);
944 ok(swapchain_desc
.Windowed
,
945 "Got unexpected Windowed %#x.\n", swapchain_desc
.Windowed
);
946 ok(swapchain_desc
.SwapEffect
== DXGI_SWAP_EFFECT_DISCARD
,
947 "Got unexpected SwapEffect %#x.\n", swapchain_desc
.SwapEffect
);
948 ok(!swapchain_desc
.Flags
,
949 "Got unexpected Flags %#x.\n", swapchain_desc
.Flags
);
951 hr
= IDXGISurface_GetDesc(surface
, &surface_desc
);
952 ok(SUCCEEDED(hr
), "Failed to get surface desc, hr %#x.\n", hr
);
953 ok(surface_desc
.Width
== 320, "Got unexpected Width %u.\n", surface_desc
.Width
);
954 ok(surface_desc
.Height
== 240, "Got unexpected Height %u.\n", surface_desc
.Height
);
955 ok(surface_desc
.Format
== DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
, "Got unexpected Format %#x.\n", surface_desc
.Format
);
956 ok(surface_desc
.SampleDesc
.Count
== 1, "Got unexpected SampleDesc.Count %u.\n", surface_desc
.SampleDesc
.Count
);
957 ok(!surface_desc
.SampleDesc
.Quality
, "Got unexpected SampleDesc.Quality %u.\n", surface_desc
.SampleDesc
.Quality
);
959 ID3D10Texture2D_GetDesc(texture
, &texture_desc
);
960 ok(texture_desc
.Width
== 320, "Got unexpected Width %u.\n", texture_desc
.Width
);
961 ok(texture_desc
.Height
== 240, "Got unexpected Height %u.\n", texture_desc
.Height
);
962 ok(texture_desc
.MipLevels
== 1, "Got unexpected MipLevels %u.\n", texture_desc
.MipLevels
);
963 ok(texture_desc
.ArraySize
== 1, "Got unexpected ArraySize %u.\n", texture_desc
.ArraySize
);
964 ok(texture_desc
.Format
== DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
, "Got unexpected Format %#x.\n", texture_desc
.Format
);
965 ok(texture_desc
.SampleDesc
.Count
== 1, "Got unexpected SampleDesc.Count %u.\n", texture_desc
.SampleDesc
.Count
);
966 ok(!texture_desc
.SampleDesc
.Quality
, "Got unexpected SampleDesc.Quality %u.\n", texture_desc
.SampleDesc
.Quality
);
967 ok(texture_desc
.Usage
== D3D10_USAGE_DEFAULT
, "Got unexpected Usage %#x.\n", texture_desc
.Usage
);
968 ok(texture_desc
.BindFlags
== D3D10_BIND_RENDER_TARGET
, "Got unexpected BindFlags %#x.\n", texture_desc
.BindFlags
);
969 ok(!texture_desc
.CPUAccessFlags
, "Got unexpected CPUAccessFlags %#x.\n", texture_desc
.CPUAccessFlags
);
970 ok(!texture_desc
.MiscFlags
, "Got unexpected MiscFlags %#x.\n", texture_desc
.MiscFlags
);
972 ID3D10Texture2D_Release(texture
);
973 IDXGISurface_Release(surface
);
975 hr
= IDXGISwapChain_ResizeBuffers(swapchain
, 0, 0, 0, DXGI_FORMAT_UNKNOWN
, 0);
976 ok(SUCCEEDED(hr
), "Failed to resize buffers, hr %#x.\n", hr
);
978 hr
= IDXGISwapChain_GetDesc(swapchain
, &swapchain_desc
);
979 ok(SUCCEEDED(hr
), "Failed to get swapchain desc, hr %#x.\n", hr
);
980 ok(swapchain_desc
.BufferDesc
.Width
== client_rect
.right
- client_rect
.left
,
981 "Got unexpected BufferDesc.Width %u, expected %u.\n",
982 swapchain_desc
.BufferDesc
.Width
, client_rect
.right
- client_rect
.left
);
983 ok(swapchain_desc
.BufferDesc
.Height
== client_rect
.bottom
- client_rect
.top
,
984 "Got unexpected bufferDesc.Height %u, expected %u.\n",
985 swapchain_desc
.BufferDesc
.Height
, client_rect
.bottom
- client_rect
.top
);
986 ok(swapchain_desc
.BufferDesc
.RefreshRate
.Numerator
== 60,
987 "Got unexpected BufferDesc.RefreshRate.Numerator %u.\n",
988 swapchain_desc
.BufferDesc
.RefreshRate
.Numerator
);
989 ok(swapchain_desc
.BufferDesc
.RefreshRate
.Denominator
== 1,
990 "Got unexpected BufferDesc.RefreshRate.Denominator %u.\n",
991 swapchain_desc
.BufferDesc
.RefreshRate
.Denominator
);
992 ok(swapchain_desc
.BufferDesc
.Format
== DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
993 "Got unexpected BufferDesc.Format %#x.\n", swapchain_desc
.BufferDesc
.Format
);
994 ok(swapchain_desc
.BufferDesc
.ScanlineOrdering
== DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED
,
995 "Got unexpected BufferDesc.ScanlineOrdering %#x.\n", swapchain_desc
.BufferDesc
.ScanlineOrdering
);
996 ok(swapchain_desc
.BufferDesc
.Scaling
== DXGI_MODE_SCALING_UNSPECIFIED
,
997 "Got unexpected BufferDesc.Scaling %#x.\n", swapchain_desc
.BufferDesc
.Scaling
);
998 ok(swapchain_desc
.SampleDesc
.Count
== 1,
999 "Got unexpected SampleDesc.Count %u.\n", swapchain_desc
.SampleDesc
.Count
);
1000 ok(!swapchain_desc
.SampleDesc
.Quality
,
1001 "Got unexpected SampleDesc.Quality %u.\n", swapchain_desc
.SampleDesc
.Quality
);
1002 ok(swapchain_desc
.BufferUsage
== DXGI_USAGE_RENDER_TARGET_OUTPUT
,
1003 "Got unexpected BufferUsage %#x.\n", swapchain_desc
.BufferUsage
);
1004 ok(swapchain_desc
.BufferCount
== 1,
1005 "Got unexpected BufferCount %u.\n", swapchain_desc
.BufferCount
);
1006 ok(swapchain_desc
.OutputWindow
== window
,
1007 "Got unexpected OutputWindow %p, expected %p.\n", swapchain_desc
.OutputWindow
, window
);
1008 ok(swapchain_desc
.Windowed
,
1009 "Got unexpected Windowed %#x.\n", swapchain_desc
.Windowed
);
1010 ok(swapchain_desc
.SwapEffect
== DXGI_SWAP_EFFECT_DISCARD
,
1011 "Got unexpected SwapEffect %#x.\n", swapchain_desc
.SwapEffect
);
1012 ok(!swapchain_desc
.Flags
,
1013 "Got unexpected Flags %#x.\n", swapchain_desc
.Flags
);
1015 IDXGISwapChain_Release(swapchain
);
1016 refcount
= IDXGIDevice_Release(device
);
1017 ok(!refcount
, "Device has %u references left.\n", refcount
);
1018 DestroyWindow(window
);
1023 pCreateDXGIFactory1
= (void *)GetProcAddress(GetModuleHandleA("dxgi.dll"), "CreateDXGIFactory1");
1025 test_adapter_desc();
1026 test_device_interfaces();
1027 test_create_surface();
1030 test_createswapchain();
1031 test_create_factory();
1032 test_private_data();
1033 test_swapchain_resize();