d3d11/tests: Port test_create_blend_state() from d3d10core.
[wine/multimedia.git] / dlls / d3d11 / tests / d3d11.c
blob595ae7c7b0c2e2231ca9cfbf5c0aca13eec5ce70
1 /*
2 * Copyright 2008 Henri Verbeet for CodeWeavers
3 * Copyright 2015 Józef Kucia for CodeWeavers
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #define COBJMACROS
21 #include "initguid.h"
22 #include "d3d11.h"
23 #include "wine/test.h"
25 static const D3D_FEATURE_LEVEL d3d11_feature_levels[] =
27 D3D_FEATURE_LEVEL_11_1,
28 D3D_FEATURE_LEVEL_11_0,
29 D3D_FEATURE_LEVEL_10_1,
30 D3D_FEATURE_LEVEL_10_0,
31 D3D_FEATURE_LEVEL_9_3,
32 D3D_FEATURE_LEVEL_9_2,
33 D3D_FEATURE_LEVEL_9_1
36 static ULONG get_refcount(IUnknown *iface)
38 IUnknown_AddRef(iface);
39 return IUnknown_Release(iface);
42 static ID3D11Device *create_device(const D3D_FEATURE_LEVEL *feature_level)
44 ID3D11Device *device;
45 UINT feature_level_count = feature_level ? 1 : 0;
47 if (SUCCEEDED(D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, feature_level, feature_level_count,
48 D3D11_SDK_VERSION, &device, NULL, NULL)))
49 return device;
50 if (SUCCEEDED(D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_WARP, NULL, 0, feature_level, feature_level_count,
51 D3D11_SDK_VERSION, &device, NULL, NULL)))
52 return device;
53 if (SUCCEEDED(D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_REFERENCE, NULL, 0, feature_level, feature_level_count,
54 D3D11_SDK_VERSION, &device, NULL, NULL)))
55 return device;
57 return NULL;
60 static void test_create_device(void)
62 D3D_FEATURE_LEVEL feature_level, supported_feature_level;
63 DXGI_SWAP_CHAIN_DESC swapchain_desc, obtained_desc;
64 ID3D11DeviceContext *immediate_context = NULL;
65 IDXGISwapChain *swapchain;
66 ID3D11Device *device;
67 ULONG refcount;
68 HWND window;
69 HRESULT hr;
71 hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION, &device,
72 NULL, NULL);
73 if (FAILED(hr))
75 skip("Failed to create HAL device, skipping tests.\n");
76 return;
79 supported_feature_level = ID3D11Device_GetFeatureLevel(device);
80 ID3D11Device_Release(device);
82 hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION, NULL, NULL, NULL);
83 ok(SUCCEEDED(hr), "D3D11CreateDevice failed %#x.\n", hr);
85 hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION, NULL,
86 &feature_level, NULL);
87 ok(SUCCEEDED(hr), "D3D11CreateDevice failed %#x.\n", hr);
88 ok(feature_level == supported_feature_level, "Got feature level %#x, expected %#x.\n",
89 feature_level, supported_feature_level);
91 hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION, NULL, NULL,
92 &immediate_context);
93 ok(SUCCEEDED(hr), "D3D11CreateDevice failed %#x.\n", hr);
95 todo_wine ok(!!immediate_context, "Immediate context is NULL.\n");
96 if (immediate_context)
98 refcount = get_refcount((IUnknown *)immediate_context);
99 ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
101 ID3D11DeviceContext_GetDevice(immediate_context, &device);
102 refcount = ID3D11Device_Release(device);
103 ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
105 refcount = ID3D11DeviceContext_Release(immediate_context);
106 ok(!refcount, "ID3D11DeviceContext has %u references left.\n", refcount);
109 device = (ID3D11Device *)0xdeadbeef;
110 feature_level = 0xdeadbeef;
111 immediate_context = (ID3D11DeviceContext *)0xdeadbeef;
112 hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_UNKNOWN, NULL, 0, NULL, 0, D3D11_SDK_VERSION,
113 &device, &feature_level, &immediate_context);
114 todo_wine ok(hr == E_INVALIDARG, "D3D11CreateDevice returned %#x.\n", hr);
115 ok(!device, "Got unexpected device pointer %p.\n", device);
116 ok(!feature_level, "Got unexpected feature level %#x.\n", feature_level);
117 ok(!immediate_context, "Got unexpected immediate_context pointer %p.\n", immediate_context);
119 window = CreateWindowA("static", "d3d11_test", 0, 0, 0, 0, 0, 0, 0, 0, 0);
121 swapchain_desc.BufferDesc.Width = 800;
122 swapchain_desc.BufferDesc.Height = 600;
123 swapchain_desc.BufferDesc.RefreshRate.Numerator = 60;
124 swapchain_desc.BufferDesc.RefreshRate.Denominator = 60;
125 swapchain_desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
126 swapchain_desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
127 swapchain_desc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
128 swapchain_desc.SampleDesc.Count = 1;
129 swapchain_desc.SampleDesc.Quality = 0;
130 swapchain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
131 swapchain_desc.BufferCount = 1;
132 swapchain_desc.OutputWindow = window;
133 swapchain_desc.Windowed = TRUE;
134 swapchain_desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
135 swapchain_desc.Flags = 0;
137 hr = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION,
138 &swapchain_desc, NULL, NULL, NULL, NULL);
139 ok(SUCCEEDED(hr), "D3D11CreateDeviceAndSwapChain failed %#x.\n", hr);
141 hr = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION,
142 &swapchain_desc, NULL, NULL, &feature_level, NULL);
143 ok(SUCCEEDED(hr), "D3D11CreateDeviceAndSwapChain failed %#x.\n", hr);
144 ok(feature_level == supported_feature_level, "Got feature level %#x, expected %#x.\n",
145 feature_level, supported_feature_level);
147 hr = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION,
148 &swapchain_desc, &swapchain, &device, NULL, NULL);
149 ok(SUCCEEDED(hr), "D3D11CreateDeviceAndSwapChain failed %#x.\n", hr);
151 memset(&obtained_desc, 0, sizeof(obtained_desc));
152 hr = IDXGISwapChain_GetDesc(swapchain, &obtained_desc);
153 ok(SUCCEEDED(hr), "GetDesc failed %#x.\n", hr);
154 ok(obtained_desc.BufferDesc.Width == swapchain_desc.BufferDesc.Width,
155 "Got unexpected BufferDesc.Width %u.\n", obtained_desc.BufferDesc.Width);
156 ok(obtained_desc.BufferDesc.Height == swapchain_desc.BufferDesc.Height,
157 "Got unexpected BufferDesc.Height %u.\n", obtained_desc.BufferDesc.Height);
158 todo_wine ok(obtained_desc.BufferDesc.RefreshRate.Numerator == swapchain_desc.BufferDesc.RefreshRate.Numerator,
159 "Got unexpected BufferDesc.RefreshRate.Numerator %u.\n",
160 obtained_desc.BufferDesc.RefreshRate.Numerator);
161 todo_wine ok(obtained_desc.BufferDesc.RefreshRate.Denominator == swapchain_desc.BufferDesc.RefreshRate.Denominator,
162 "Got unexpected BufferDesc.RefreshRate.Denominator %u.\n",
163 obtained_desc.BufferDesc.RefreshRate.Denominator);
164 ok(obtained_desc.BufferDesc.Format == swapchain_desc.BufferDesc.Format,
165 "Got unexpected BufferDesc.Format %#x.\n", obtained_desc.BufferDesc.Format);
166 ok(obtained_desc.BufferDesc.ScanlineOrdering == swapchain_desc.BufferDesc.ScanlineOrdering,
167 "Got unexpected BufferDesc.ScanlineOrdering %#x.\n", obtained_desc.BufferDesc.ScanlineOrdering);
168 ok(obtained_desc.BufferDesc.Scaling == swapchain_desc.BufferDesc.Scaling,
169 "Got unexpected BufferDesc.Scaling %#x.\n", obtained_desc.BufferDesc.Scaling);
170 ok(obtained_desc.SampleDesc.Count == swapchain_desc.SampleDesc.Count,
171 "Got unexpected SampleDesc.Count %u.\n", obtained_desc.SampleDesc.Count);
172 ok(obtained_desc.SampleDesc.Quality == swapchain_desc.SampleDesc.Quality,
173 "Got unexpected SampleDesc.Quality %u.\n", obtained_desc.SampleDesc.Quality);
174 todo_wine ok(obtained_desc.BufferUsage == swapchain_desc.BufferUsage,
175 "Got unexpected BufferUsage %#x.\n", obtained_desc.BufferUsage);
176 ok(obtained_desc.BufferCount == swapchain_desc.BufferCount,
177 "Got unexpected BufferCount %u.\n", obtained_desc.BufferCount);
178 ok(obtained_desc.OutputWindow == swapchain_desc.OutputWindow,
179 "Got unexpected OutputWindow %p.\n", obtained_desc.OutputWindow);
180 ok(obtained_desc.Windowed == swapchain_desc.Windowed,
181 "Got unexpected Windowed %#x.\n", obtained_desc.Windowed);
182 ok(obtained_desc.SwapEffect == swapchain_desc.SwapEffect,
183 "Got unexpected SwapEffect %#x.\n", obtained_desc.SwapEffect);
184 ok(obtained_desc.Flags == swapchain_desc.Flags,
185 "Got unexpected Flags %#x.\n", obtained_desc.Flags);
187 refcount = IDXGISwapChain_Release(swapchain);
188 ok(!refcount, "Swapchain has %u references left.\n", refcount);
190 feature_level = ID3D11Device_GetFeatureLevel(device);
191 ok(feature_level == supported_feature_level, "Got feature level %#x, expected %#x.\n",
192 feature_level, supported_feature_level);
194 refcount = ID3D11Device_Release(device);
195 ok(!refcount, "Device has %u references left.\n", refcount);
197 hr = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION,
198 NULL, NULL, &device, NULL, NULL);
199 ok(SUCCEEDED(hr), "D3D11CreateDeviceAndSwapChain failed %#x.\n", hr);
200 ID3D11Device_Release(device);
202 hr = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION,
203 NULL, NULL, NULL, NULL, NULL);
204 ok(SUCCEEDED(hr), "D3D11CreateDeviceAndSwapChain failed %#x.\n", hr);
206 hr = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION,
207 NULL, NULL, NULL, &feature_level, NULL);
208 ok(SUCCEEDED(hr), "D3D11CreateDeviceAndSwapChain failed %#x.\n", hr);
209 ok(feature_level == supported_feature_level, "Got feature level %#x, expected %#x.\n",
210 feature_level, supported_feature_level);
212 hr = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION,
213 &swapchain_desc, NULL, NULL, NULL, NULL);
214 ok(SUCCEEDED(hr), "D3D11CreateDeviceAndSwapChain failed %#x.\n", hr);
216 swapchain_desc.OutputWindow = NULL;
217 hr = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION,
218 &swapchain_desc, NULL, &device, NULL, NULL);
219 ok(SUCCEEDED(hr), "D3D11CreateDeviceAndSwapChain failed %#x.\n", hr);
220 ID3D11Device_Release(device);
222 swapchain = (IDXGISwapChain *)0xdeadbeef;
223 device = (ID3D11Device *)0xdeadbeef;
224 feature_level = 0xdeadbeef;
225 immediate_context = (ID3D11DeviceContext *)0xdeadbeef;
226 swapchain_desc.OutputWindow = NULL;
227 hr = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION,
228 &swapchain_desc, &swapchain, &device, &feature_level, &immediate_context);
229 todo_wine ok(hr == DXGI_ERROR_INVALID_CALL, "D3D11CreateDeviceAndSwapChain returned %#x.\n", hr);
230 ok(!swapchain, "Got unexpected swapchain pointer %p.\n", swapchain);
231 ok(!device, "Got unexpected device pointer %p.\n", device);
232 ok(!feature_level, "Got unexpected feature level %#x.\n", feature_level);
233 ok(!immediate_context, "Got unexpected immediate context pointer %p.\n", immediate_context);
235 swapchain = (IDXGISwapChain *)0xdeadbeef;
236 device = (ID3D11Device *)0xdeadbeef;
237 feature_level = 0xdeadbeef;
238 immediate_context = (ID3D11DeviceContext *)0xdeadbeef;
239 swapchain_desc.OutputWindow = window;
240 swapchain_desc.BufferDesc.Format = DXGI_FORMAT_BC5_UNORM;
241 hr = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION,
242 &swapchain_desc, &swapchain, &device, &feature_level, &immediate_context);
243 todo_wine ok(hr == E_INVALIDARG, "D3D11CreateDeviceAndSwapChain returned %#x.\n", hr);
244 ok(!swapchain, "Got unexpected swapchain pointer %p.\n", swapchain);
245 ok(!device, "Got unexpected device pointer %p.\n", device);
246 ok(!feature_level, "Got unexpected feature level %#x.\n", feature_level);
247 ok(!immediate_context, "Got unexpected immediate context pointer %p.\n", immediate_context);
249 DestroyWindow(window);
252 static void test_device_interfaces(void)
254 ID3D11Device *device;
255 IUnknown *iface;
256 ULONG refcount;
257 unsigned int i;
258 HRESULT hr;
260 for (i = 0; i < sizeof(d3d11_feature_levels) / sizeof(*d3d11_feature_levels); ++i)
262 if (!(device = create_device(&d3d11_feature_levels[i])))
264 skip("Failed to create device for feature level %#x.\n", d3d11_feature_levels[i]);
265 continue;
268 hr = ID3D11Device_QueryInterface(device, &IID_IUnknown, (void **)&iface);
269 ok(SUCCEEDED(hr), "Device should implement IUnknown interface, hr %#x.\n", hr);
270 IUnknown_Release(iface);
272 hr = ID3D11Device_QueryInterface(device, &IID_IDXGIObject, (void **)&iface);
273 ok(SUCCEEDED(hr), "Device should implement IDXGIObject interface, hr %#x.\n", hr);
274 IUnknown_Release(iface);
276 hr = ID3D11Device_QueryInterface(device, &IID_IDXGIDevice, (void **)&iface);
277 ok(SUCCEEDED(hr), "Device should implement IDXGIDevice interface, hr %#x.\n", hr);
278 IUnknown_Release(iface);
280 hr = ID3D11Device_QueryInterface(device, &IID_ID3D10Multithread, (void **)&iface);
281 ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */,
282 "Device should implement ID3D10Multithread interface, hr %#x.\n", hr);
283 if (SUCCEEDED(hr)) IUnknown_Release(iface);
285 hr = ID3D11Device_QueryInterface(device, &IID_ID3D10Device, (void **)&iface);
286 todo_wine ok(hr == E_NOINTERFACE, "Device should not implement ID3D10Device interface, hr %#x.\n", hr);
287 if (SUCCEEDED(hr)) IUnknown_Release(iface);
289 hr = ID3D11Device_QueryInterface(device, &IID_ID3D10Device1, (void **)&iface);
290 todo_wine ok(hr == E_NOINTERFACE, "Device should not implement ID3D10Device1 interface, hr %#x.\n", hr);
291 if (SUCCEEDED(hr)) IUnknown_Release(iface);
293 refcount = ID3D11Device_Release(device);
294 ok(!refcount, "Device has %u references left.\n", refcount);
298 static void test_create_texture2d(void)
300 ULONG refcount, expected_refcount;
301 D3D11_SUBRESOURCE_DATA data = {0};
302 ID3D11Device *device, *tmp;
303 D3D11_TEXTURE2D_DESC desc;
304 ID3D11Texture2D *texture;
305 IDXGISurface *surface;
306 HRESULT hr;
308 if (!(device = create_device(NULL)))
310 skip("Failed to create device, skipping tests.\n");
311 return;
314 desc.Width = 512;
315 desc.Height = 512;
316 desc.MipLevels = 1;
317 desc.ArraySize = 1;
318 desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
319 desc.SampleDesc.Count = 1;
320 desc.SampleDesc.Quality = 0;
321 desc.Usage = D3D11_USAGE_DEFAULT;
322 desc.BindFlags = D3D11_BIND_RENDER_TARGET;
323 desc.CPUAccessFlags = 0;
324 desc.MiscFlags = 0;
326 hr = ID3D11Device_CreateTexture2D(device, &desc, &data, &texture);
327 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
329 expected_refcount = get_refcount((IUnknown *)device) + 1;
330 hr = ID3D11Device_CreateTexture2D(device, &desc, NULL, &texture);
331 ok(SUCCEEDED(hr), "Failed to create a 2d texture, hr %#x.\n", hr);
332 refcount = get_refcount((IUnknown *)device);
333 ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount);
334 tmp = NULL;
335 expected_refcount = refcount + 1;
336 ID3D11Texture2D_GetDevice(texture, &tmp);
337 ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
338 refcount = get_refcount((IUnknown *)device);
339 ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
340 ID3D11Device_Release(tmp);
342 hr = ID3D11Texture2D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface);
343 ok(SUCCEEDED(hr), "Texture should implement IDXGISurface.\n");
344 IDXGISurface_Release(surface);
345 ID3D11Texture2D_Release(texture);
347 desc.MipLevels = 0;
348 expected_refcount = get_refcount((IUnknown *)device) + 1;
349 hr = ID3D11Device_CreateTexture2D(device, &desc, NULL, &texture);
350 ok(SUCCEEDED(hr), "Failed to create a 2d texture, hr %#x.\n", hr);
351 refcount = get_refcount((IUnknown *)device);
352 ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount);
353 tmp = NULL;
354 expected_refcount = refcount + 1;
355 ID3D11Texture2D_GetDevice(texture, &tmp);
356 ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
357 refcount = get_refcount((IUnknown *)device);
358 ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
359 ID3D11Device_Release(tmp);
361 ID3D11Texture2D_GetDesc(texture, &desc);
362 ok(desc.Width == 512, "Got unexpected Width %u.\n", desc.Width);
363 ok(desc.Height == 512, "Got unexpected Height %u.\n", desc.Height);
364 ok(desc.MipLevels == 10, "Got unexpected MipLevels %u.\n", desc.MipLevels);
365 ok(desc.ArraySize == 1, "Got unexpected ArraySize %u.\n", desc.ArraySize);
366 ok(desc.Format == DXGI_FORMAT_R8G8B8A8_UNORM, "Got unexpected Format %#x.\n", desc.Format);
367 ok(desc.SampleDesc.Count == 1, "Got unexpected SampleDesc.Count %u.\n", desc.SampleDesc.Count);
368 ok(desc.SampleDesc.Quality == 0, "Got unexpected SampleDesc.Quality %u.\n", desc.SampleDesc.Quality);
369 ok(desc.Usage == D3D11_USAGE_DEFAULT, "Got unexpected Usage %u.\n", desc.Usage);
370 ok(desc.BindFlags == D3D11_BIND_RENDER_TARGET, "Got unexpected BindFlags %#x.\n", desc.BindFlags);
371 ok(desc.CPUAccessFlags == 0, "Got unexpected CPUAccessFlags %#x.\n", desc.CPUAccessFlags);
372 ok(desc.MiscFlags == 0, "Got unexpected MiscFlags %#x.\n", desc.MiscFlags);
374 hr = ID3D11Texture2D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface);
375 ok(FAILED(hr), "Texture should not implement IDXGISurface.\n");
376 ID3D11Texture2D_Release(texture);
378 desc.MipLevels = 1;
379 desc.ArraySize = 2;
380 hr = ID3D11Device_CreateTexture2D(device, &desc, NULL, &texture);
381 ok(SUCCEEDED(hr), "Failed to create a 2d texture, hr %#x.\n", hr);
383 hr = ID3D11Texture2D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface);
384 ok(FAILED(hr), "Texture should not implement IDXGISurface.\n");
385 ID3D11Texture2D_Release(texture);
387 refcount = ID3D11Device_Release(device);
388 ok(!refcount, "Device has %u references left.\n", refcount);
391 static void test_texture2d_interfaces(void)
393 ID3D10Texture2D *d3d10_texture;
394 D3D11_TEXTURE2D_DESC desc;
395 ID3D11Texture2D *texture;
396 IDXGISurface *surface;
397 ID3D11Device *device;
398 unsigned int i;
399 ULONG refcount;
400 HRESULT hr;
402 static const struct test
404 BOOL implements_d3d10_interfaces;
405 UINT bind_flags;
406 UINT misc_flags;
407 UINT expected_bind_flags;
408 UINT expected_misc_flags;
410 desc_conversion_tests[] =
413 TRUE,
414 D3D11_BIND_SHADER_RESOURCE, 0,
415 D3D10_BIND_SHADER_RESOURCE, 0
418 TRUE,
419 D3D11_BIND_UNORDERED_ACCESS, 0,
420 D3D11_BIND_UNORDERED_ACCESS, 0
423 FALSE,
424 0, D3D11_RESOURCE_MISC_RESOURCE_CLAMP,
425 0, 0
428 TRUE,
429 0, D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX,
430 0, D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX
433 TRUE,
434 0, D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX | D3D11_RESOURCE_MISC_SHARED_NTHANDLE,
435 0, D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX
439 if (!(device = create_device(NULL)))
441 skip("Failed to create ID3D11Device, skipping tests.\n");
442 return;
445 desc.Width = 512;
446 desc.Height = 512;
447 desc.MipLevels = 0;
448 desc.ArraySize = 1;
449 desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
450 desc.SampleDesc.Count = 1;
451 desc.SampleDesc.Quality = 0;
452 desc.Usage = D3D11_USAGE_DEFAULT;
453 desc.BindFlags = D3D11_BIND_RENDER_TARGET;
454 desc.CPUAccessFlags = 0;
455 desc.MiscFlags = 0;
457 hr = ID3D11Device_CreateTexture2D(device, &desc, NULL, &texture);
458 ok(SUCCEEDED(hr), "Failed to create a 2d texture, hr %#x.\n", hr);
460 hr = ID3D11Texture2D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface);
461 ok(hr == E_NOINTERFACE, "Texture should not implement IDXGISurface.\n");
463 hr = ID3D11Texture2D_QueryInterface(texture, &IID_ID3D10Texture2D, (void **)&d3d10_texture);
464 ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */,
465 "Texture should implement ID3D10Texture2D.\n");
466 if (SUCCEEDED(hr)) ID3D10Texture2D_Release(d3d10_texture);
467 ID3D11Texture2D_Release(texture);
469 if (FAILED(hr))
471 win_skip("2D textures do not implement ID3D10Texture2D, skipping tests.\n");
472 ID3D11Device_Release(device);
473 return;
476 for (i = 0; i < sizeof(desc_conversion_tests) / sizeof(*desc_conversion_tests); ++i)
478 const struct test *current = &desc_conversion_tests[i];
479 D3D10_TEXTURE2D_DESC d3d10_desc;
480 ID3D10Device *d3d10_device;
482 desc.Width = 512;
483 desc.Height = 512;
484 desc.MipLevels = 1;
485 desc.ArraySize = 1;
486 desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
487 desc.SampleDesc.Count = 1;
488 desc.SampleDesc.Quality = 0;
489 desc.Usage = D3D11_USAGE_DEFAULT;
490 desc.BindFlags = current->bind_flags;
491 desc.CPUAccessFlags = 0;
492 desc.MiscFlags = current->misc_flags;
494 hr = ID3D11Device_CreateTexture2D(device, &desc, NULL, &texture);
495 /* Shared resources are not supported by REF and WARP devices. */
496 ok(SUCCEEDED(hr) || broken(hr == E_OUTOFMEMORY),
497 "Test %u: Failed to create a 2d texture, hr %#x.\n", i, hr);
498 if (FAILED(hr))
500 win_skip("Failed to create ID3D11Texture2D, skipping test %u.\n", i);
501 continue;
504 hr = ID3D11Texture2D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface);
505 ok(SUCCEEDED(hr), "Test %u: Texture should implement IDXGISurface.\n", i);
506 IDXGISurface_Release(surface);
508 hr = ID3D11Texture2D_QueryInterface(texture, &IID_ID3D10Texture2D, (void **)&d3d10_texture);
509 ID3D11Texture2D_Release(texture);
511 if (current->implements_d3d10_interfaces)
513 ok(SUCCEEDED(hr), "Test %u: Texture should implement ID3D10Texture2D.\n", i);
515 else
517 todo_wine ok(hr == E_NOINTERFACE, "Test %u: Texture should not implement ID3D10Texture2D.\n", i);
518 if (SUCCEEDED(hr)) ID3D10Texture2D_Release(d3d10_texture);
519 continue;
522 ID3D10Texture2D_GetDesc(d3d10_texture, &d3d10_desc);
524 ok(d3d10_desc.Width == desc.Width,
525 "Test %u: Got unexpected Width %u.\n", i, d3d10_desc.Width);
526 ok(d3d10_desc.Height == desc.Height,
527 "Test %u: Got unexpected Height %u.\n", i, d3d10_desc.Height);
528 ok(d3d10_desc.MipLevels == desc.MipLevels,
529 "Test %u: Got unexpected MipLevels %u.\n", i, d3d10_desc.MipLevels);
530 ok(d3d10_desc.ArraySize == desc.ArraySize,
531 "Test %u: Got unexpected ArraySize %u.\n", i, d3d10_desc.ArraySize);
532 ok(d3d10_desc.Format == desc.Format,
533 "Test %u: Got unexpected Format %u.\n", i, d3d10_desc.Format);
534 ok(d3d10_desc.SampleDesc.Count == desc.SampleDesc.Count,
535 "Test %u: Got unexpected SampleDesc.Count %u.\n", i, d3d10_desc.SampleDesc.Count);
536 ok(d3d10_desc.SampleDesc.Quality == desc.SampleDesc.Quality,
537 "Test %u: Got unexpected SampleDesc.Quality %u.\n", i, d3d10_desc.SampleDesc.Quality);
538 ok(d3d10_desc.Usage == (D3D10_USAGE)desc.Usage,
539 "Test %u: Got unexpected Usage %u.\n", i, d3d10_desc.Usage);
540 ok(d3d10_desc.BindFlags == current->expected_bind_flags,
541 "Test %u: Got unexpected BindFlags %#x.\n", i, d3d10_desc.BindFlags);
542 ok(d3d10_desc.CPUAccessFlags == desc.CPUAccessFlags,
543 "Test %u: Got unexpected CPUAccessFlags %#x.\n", i, d3d10_desc.CPUAccessFlags);
544 ok(d3d10_desc.MiscFlags == current->expected_misc_flags,
545 "Test %u: Got unexpected MiscFlags %#x.\n", i, d3d10_desc.MiscFlags);
547 d3d10_device = (ID3D10Device *)0xdeadbeef;
548 ID3D10Texture2D_GetDevice(d3d10_texture, &d3d10_device);
549 todo_wine ok(!d3d10_device, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i, d3d10_device);
550 if (d3d10_device) ID3D10Device_Release(d3d10_device);
552 ID3D10Texture2D_Release(d3d10_texture);
555 refcount = ID3D11Device_Release(device);
556 ok(!refcount, "Device has %u references left.\n", refcount);
559 static void test_create_texture3d(void)
561 ULONG refcount, expected_refcount;
562 D3D11_SUBRESOURCE_DATA data = {0};
563 ID3D11Device *device, *tmp;
564 D3D11_TEXTURE3D_DESC desc;
565 ID3D11Texture3D *texture;
566 IDXGISurface *surface;
567 HRESULT hr;
569 if (!(device = create_device(NULL)))
571 skip("Failed to create ID3D11Device, skipping tests.\n");
572 return;
575 desc.Width = 64;
576 desc.Height = 64;
577 desc.Depth = 64;
578 desc.MipLevels = 1;
579 desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
580 desc.Usage = D3D11_USAGE_DEFAULT;
581 desc.BindFlags = D3D11_BIND_RENDER_TARGET;
582 desc.CPUAccessFlags = 0;
583 desc.MiscFlags = 0;
585 hr = ID3D11Device_CreateTexture3D(device, &desc, &data, &texture);
586 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
588 expected_refcount = get_refcount((IUnknown *)device) + 1;
589 hr = ID3D11Device_CreateTexture3D(device, &desc, NULL, &texture);
590 ok(SUCCEEDED(hr), "Failed to create a 3d texture, hr %#x.\n", hr);
591 refcount = get_refcount((IUnknown *)device);
592 ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount);
593 tmp = NULL;
594 expected_refcount = refcount + 1;
595 ID3D11Texture3D_GetDevice(texture, &tmp);
596 ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
597 refcount = get_refcount((IUnknown *)device);
598 ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
599 ID3D11Device_Release(tmp);
601 hr = ID3D11Texture3D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface);
602 ok(FAILED(hr), "Texture should not implement IDXGISurface.\n");
603 ID3D11Texture3D_Release(texture);
605 desc.MipLevels = 0;
606 expected_refcount = get_refcount((IUnknown *)device) + 1;
607 hr = ID3D11Device_CreateTexture3D(device, &desc, NULL, &texture);
608 ok(SUCCEEDED(hr), "Failed to create a 3d texture, hr %#x.\n", hr);
609 refcount = get_refcount((IUnknown *)device);
610 ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount);
611 tmp = NULL;
612 expected_refcount = refcount + 1;
613 ID3D11Texture3D_GetDevice(texture, &tmp);
614 ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
615 refcount = get_refcount((IUnknown *)device);
616 ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
617 ID3D11Device_Release(tmp);
619 ID3D11Texture3D_GetDesc(texture, &desc);
620 ok(desc.Width == 64, "Got unexpected Width %u.\n", desc.Width);
621 ok(desc.Height == 64, "Got unexpected Height %u.\n", desc.Height);
622 ok(desc.Depth == 64, "Got unexpected Depth %u.\n", desc.Depth);
623 ok(desc.MipLevels == 7, "Got unexpected MipLevels %u.\n", desc.MipLevels);
624 ok(desc.Format == DXGI_FORMAT_R8G8B8A8_UNORM, "Got unexpected Format %#x.\n", desc.Format);
625 ok(desc.Usage == D3D11_USAGE_DEFAULT, "Got unexpected Usage %u.\n", desc.Usage);
626 ok(desc.BindFlags == D3D11_BIND_RENDER_TARGET, "Got unexpected BindFlags %u.\n", desc.BindFlags);
627 ok(desc.CPUAccessFlags == 0, "Got unexpected CPUAccessFlags %u.\n", desc.CPUAccessFlags);
628 ok(desc.MiscFlags == 0, "Got unexpected MiscFlags %u.\n", desc.MiscFlags);
630 hr = ID3D11Texture3D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface);
631 ok(FAILED(hr), "Texture should not implement IDXGISurface.\n");
632 ID3D11Texture3D_Release(texture);
634 refcount = ID3D11Device_Release(device);
635 ok(!refcount, "Device has %u references left.\n", refcount);
638 static void test_texture3d_interfaces(void)
640 ID3D10Texture3D *d3d10_texture;
641 D3D11_TEXTURE3D_DESC desc;
642 ID3D11Texture3D *texture;
643 IDXGISurface *surface;
644 ID3D11Device *device;
645 unsigned int i;
646 ULONG refcount;
647 HRESULT hr;
649 static const struct test
651 BOOL implements_d3d10_interfaces;
652 UINT bind_flags;
653 UINT misc_flags;
654 UINT expected_bind_flags;
655 UINT expected_misc_flags;
657 desc_conversion_tests[] =
660 TRUE,
661 D3D11_BIND_SHADER_RESOURCE, 0,
662 D3D10_BIND_SHADER_RESOURCE, 0
665 TRUE,
666 D3D11_BIND_UNORDERED_ACCESS, 0,
667 D3D11_BIND_UNORDERED_ACCESS, 0
670 FALSE,
671 0, D3D11_RESOURCE_MISC_RESOURCE_CLAMP,
672 0, 0
675 TRUE,
676 0, D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX,
677 0, D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX
681 if (!(device = create_device(NULL)))
683 skip("Failed to create ID3D11Device.\n");
684 return;
687 desc.Width = 64;
688 desc.Height = 64;
689 desc.Depth = 64;
690 desc.MipLevels = 0;
691 desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
692 desc.Usage = D3D11_USAGE_DEFAULT;
693 desc.BindFlags = D3D11_BIND_RENDER_TARGET;
694 desc.CPUAccessFlags = 0;
695 desc.MiscFlags = 0;
697 hr = ID3D11Device_CreateTexture3D(device, &desc, NULL, &texture);
698 ok(SUCCEEDED(hr), "Failed to create a 3d texture, hr %#x.\n", hr);
700 hr = ID3D11Texture3D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface);
701 ok(hr == E_NOINTERFACE, "Texture should not implement IDXGISurface.\n");
703 hr = ID3D11Texture3D_QueryInterface(texture, &IID_ID3D10Texture3D, (void **)&d3d10_texture);
704 ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */,
705 "Texture should implement ID3D10Texture3D.\n");
706 if (SUCCEEDED(hr)) ID3D10Texture3D_Release(d3d10_texture);
707 ID3D11Texture3D_Release(texture);
709 if (FAILED(hr))
711 win_skip("3D textures do not implement ID3D10Texture3D.\n");
712 ID3D11Device_Release(device);
713 return;
716 for (i = 0; i < sizeof(desc_conversion_tests) / sizeof(*desc_conversion_tests); ++i)
718 const struct test *current = &desc_conversion_tests[i];
719 D3D10_TEXTURE3D_DESC d3d10_desc;
720 ID3D10Device *d3d10_device;
722 desc.Width = 64;
723 desc.Height = 64;
724 desc.Depth = 64;
725 desc.MipLevels = 1;
726 desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
727 desc.Usage = D3D11_USAGE_DEFAULT;
728 desc.BindFlags = current->bind_flags;
729 desc.CPUAccessFlags = 0;
730 desc.MiscFlags = current->misc_flags;
732 hr = ID3D11Device_CreateTexture3D(device, &desc, NULL, &texture);
733 /* Shared resources are not supported by REF and WARP devices. */
734 ok(SUCCEEDED(hr) || broken(hr == E_OUTOFMEMORY),
735 "Test %u: Failed to create a 3d texture, hr %#x.\n", i, hr);
736 if (FAILED(hr))
738 win_skip("Failed to create ID3D11Texture3D, skipping test %u.\n", i);
739 continue;
742 hr = ID3D11Texture3D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface);
743 ok(hr == E_NOINTERFACE, "Texture should not implement IDXGISurface.\n");
745 hr = ID3D11Texture3D_QueryInterface(texture, &IID_ID3D10Texture3D, (void **)&d3d10_texture);
746 ID3D11Texture3D_Release(texture);
748 if (current->implements_d3d10_interfaces)
750 ok(SUCCEEDED(hr), "Test %u: Texture should implement ID3D10Texture3D.\n", i);
752 else
754 todo_wine ok(hr == E_NOINTERFACE, "Test %u: Texture should not implement ID3D10Texture3D.\n", i);
755 if (SUCCEEDED(hr)) ID3D10Texture3D_Release(d3d10_texture);
756 continue;
759 ID3D10Texture3D_GetDesc(d3d10_texture, &d3d10_desc);
761 ok(d3d10_desc.Width == desc.Width,
762 "Test %u: Got unexpected Width %u.\n", i, d3d10_desc.Width);
763 ok(d3d10_desc.Height == desc.Height,
764 "Test %u: Got unexpected Height %u.\n", i, d3d10_desc.Height);
765 ok(d3d10_desc.Depth == desc.Depth,
766 "Test %u: Got unexpected Depth %u.\n", i, d3d10_desc.Depth);
767 ok(d3d10_desc.MipLevels == desc.MipLevels,
768 "Test %u: Got unexpected MipLevels %u.\n", i, d3d10_desc.MipLevels);
769 ok(d3d10_desc.Format == desc.Format,
770 "Test %u: Got unexpected Format %u.\n", i, d3d10_desc.Format);
771 ok(d3d10_desc.Usage == (D3D10_USAGE)desc.Usage,
772 "Test %u: Got unexpected Usage %u.\n", i, d3d10_desc.Usage);
773 ok(d3d10_desc.BindFlags == current->expected_bind_flags,
774 "Test %u: Got unexpected BindFlags %#x.\n", i, d3d10_desc.BindFlags);
775 ok(d3d10_desc.CPUAccessFlags == desc.CPUAccessFlags,
776 "Test %u: Got unexpected CPUAccessFlags %#x.\n", i, d3d10_desc.CPUAccessFlags);
777 ok(d3d10_desc.MiscFlags == current->expected_misc_flags,
778 "Test %u: Got unexpected MiscFlags %#x.\n", i, d3d10_desc.MiscFlags);
780 d3d10_device = (ID3D10Device *)0xdeadbeef;
781 ID3D10Texture3D_GetDevice(d3d10_texture, &d3d10_device);
782 todo_wine ok(!d3d10_device, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i, d3d10_device);
783 if (d3d10_device) ID3D10Device_Release(d3d10_device);
785 ID3D10Texture3D_Release(d3d10_texture);
788 refcount = ID3D11Device_Release(device);
789 ok(!refcount, "Device has %u references left.\n", refcount);
792 static void test_buffer_interfaces(void)
794 ID3D10Buffer *d3d10_buffer;
795 D3D11_BUFFER_DESC desc;
796 ID3D11Buffer *buffer;
797 ID3D11Device *device;
798 unsigned int i;
799 ULONG refcount;
800 HRESULT hr;
802 static const struct test
804 BOOL implements_d3d10_interfaces;
805 UINT bind_flags;
806 UINT misc_flags;
807 UINT structure_stride;
808 UINT expected_bind_flags;
809 UINT expected_misc_flags;
811 desc_conversion_tests[] =
814 TRUE,
815 D3D11_BIND_VERTEX_BUFFER, 0, 0,
816 D3D10_BIND_VERTEX_BUFFER, 0
819 TRUE,
820 D3D11_BIND_INDEX_BUFFER, 0, 0,
821 D3D10_BIND_INDEX_BUFFER, 0
824 TRUE,
825 D3D11_BIND_CONSTANT_BUFFER, 0, 0,
826 D3D10_BIND_CONSTANT_BUFFER, 0
829 TRUE,
830 D3D11_BIND_SHADER_RESOURCE, 0, 0,
831 D3D10_BIND_SHADER_RESOURCE, 0
834 TRUE,
835 D3D11_BIND_STREAM_OUTPUT, 0, 0,
836 D3D10_BIND_STREAM_OUTPUT, 0
839 TRUE,
840 D3D11_BIND_RENDER_TARGET, 0, 0,
841 D3D10_BIND_RENDER_TARGET, 0
844 TRUE,
845 D3D11_BIND_UNORDERED_ACCESS, 0, 0,
846 D3D11_BIND_UNORDERED_ACCESS, 0
849 TRUE,
850 0, D3D11_RESOURCE_MISC_SHARED, 0,
851 0, D3D10_RESOURCE_MISC_SHARED
854 TRUE,
855 0, D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS, 0,
856 0, 0
859 TRUE,
860 D3D11_BIND_SHADER_RESOURCE, D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS, 0,
861 D3D10_BIND_SHADER_RESOURCE, 0
864 FALSE /* Structured buffers do not implement ID3D10Buffer. */,
865 0, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED, 16,
866 0, 0
869 TRUE,
870 0, D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX, 0,
871 0, D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX
875 if (!(device = create_device(NULL)))
877 skip("Failed to create ID3D11Device.\n");
878 return;
881 desc.ByteWidth = 1024;
882 desc.Usage = D3D11_USAGE_DEFAULT;
883 desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
884 desc.CPUAccessFlags = 0;
885 desc.MiscFlags = 0;
886 desc.StructureByteStride = 0;
888 hr = ID3D11Device_CreateBuffer(device, &desc, NULL, &buffer);
889 ok(SUCCEEDED(hr), "Failed to create a buffer, hr %#x.\n", hr);
891 hr = ID3D11Buffer_QueryInterface(buffer, &IID_ID3D10Buffer, (void **)&d3d10_buffer);
892 ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */,
893 "Buffer should implement ID3D10Buffer.\n");
894 if (SUCCEEDED(hr)) ID3D10Buffer_Release(d3d10_buffer);
895 ID3D11Buffer_Release(buffer);
897 if (FAILED(hr))
899 win_skip("Buffers do not implement ID3D10Buffer.\n");
900 ID3D11Device_Release(device);
901 return;
904 for (i = 0; i < sizeof(desc_conversion_tests) / sizeof(*desc_conversion_tests); ++i)
906 const struct test *current = &desc_conversion_tests[i];
907 D3D10_BUFFER_DESC d3d10_desc;
908 ID3D10Device *d3d10_device;
910 desc.ByteWidth = 1024;
911 desc.Usage = D3D11_USAGE_DEFAULT;
912 desc.BindFlags = current->bind_flags;
913 desc.CPUAccessFlags = 0;
914 desc.MiscFlags = current->misc_flags;
915 desc.StructureByteStride = current->structure_stride;
917 hr = ID3D11Device_CreateBuffer(device, &desc, NULL, &buffer);
918 /* Shared resources are not supported by REF and WARP devices. */
919 ok(SUCCEEDED(hr) || broken(hr == E_OUTOFMEMORY), "Test %u: Failed to create a buffer, hr %#x.\n", i, hr);
920 if (FAILED(hr))
922 win_skip("Failed to create a buffer, skipping test %u.\n", i);
923 continue;
926 hr = ID3D11Buffer_QueryInterface(buffer, &IID_ID3D10Buffer, (void **)&d3d10_buffer);
927 ID3D11Buffer_Release(buffer);
929 if (current->implements_d3d10_interfaces)
931 ok(SUCCEEDED(hr), "Test %u: Buffer should implement ID3D10Buffer.\n", i);
933 else
935 todo_wine ok(hr == E_NOINTERFACE, "Test %u: Buffer should not implement ID3D10Buffer.\n", i);
936 if (SUCCEEDED(hr)) ID3D10Buffer_Release(d3d10_buffer);
937 continue;
940 ID3D10Buffer_GetDesc(d3d10_buffer, &d3d10_desc);
942 ok(d3d10_desc.ByteWidth == desc.ByteWidth,
943 "Test %u: Got unexpected ByteWidth %u.\n", i, d3d10_desc.ByteWidth);
944 ok(d3d10_desc.Usage == (D3D10_USAGE)desc.Usage,
945 "Test %u: Got unexpected Usage %u.\n", i, d3d10_desc.Usage);
946 ok(d3d10_desc.BindFlags == current->expected_bind_flags,
947 "Test %u: Got unexpected BindFlags %#x.\n", i, d3d10_desc.BindFlags);
948 ok(d3d10_desc.CPUAccessFlags == desc.CPUAccessFlags,
949 "Test %u: Got unexpected CPUAccessFlags %#x.\n", i, d3d10_desc.CPUAccessFlags);
950 ok(d3d10_desc.MiscFlags == current->expected_misc_flags,
951 "Test %u: Got unexpected MiscFlags %#x.\n", i, d3d10_desc.MiscFlags);
953 d3d10_device = (ID3D10Device *)0xdeadbeef;
954 ID3D10Buffer_GetDevice(d3d10_buffer, &d3d10_device);
955 todo_wine ok(!d3d10_device, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i, d3d10_device);
956 if (d3d10_device) ID3D10Device_Release(d3d10_device);
958 ID3D10Buffer_Release(d3d10_buffer);
961 refcount = ID3D11Device_Release(device);
962 ok(!refcount, "Device has %u references left.\n", refcount);
965 static void test_create_depthstencil_view(void)
967 D3D11_DEPTH_STENCIL_VIEW_DESC dsv_desc;
968 D3D11_TEXTURE2D_DESC texture_desc;
969 ULONG refcount, expected_refcount;
970 ID3D11DepthStencilView *dsview;
971 ID3D11Device *device, *tmp;
972 ID3D11Texture2D *texture;
973 HRESULT hr;
975 if (!(device = create_device(NULL)))
977 skip("Failed to create device.\n");
978 return;
981 texture_desc.Width = 512;
982 texture_desc.Height = 512;
983 texture_desc.MipLevels = 1;
984 texture_desc.ArraySize = 1;
985 texture_desc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
986 texture_desc.SampleDesc.Count = 1;
987 texture_desc.SampleDesc.Quality = 0;
988 texture_desc.Usage = D3D11_USAGE_DEFAULT;
989 texture_desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
990 texture_desc.CPUAccessFlags = 0;
991 texture_desc.MiscFlags = 0;
993 hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &texture);
994 ok(SUCCEEDED(hr), "Failed to create a 2d texture, hr %#x.\n", hr);
996 expected_refcount = get_refcount((IUnknown *)device) + 1;
997 hr = ID3D11Device_CreateDepthStencilView(device, (ID3D11Resource *)texture, NULL, &dsview);
998 ok(SUCCEEDED(hr), "Failed to create a depthstencil view, hr %#x.\n", hr);
999 refcount = get_refcount((IUnknown *)device);
1000 ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount);
1001 tmp = NULL;
1002 expected_refcount = refcount + 1;
1003 ID3D11DepthStencilView_GetDevice(dsview, &tmp);
1004 ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
1005 refcount = get_refcount((IUnknown *)device);
1006 ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
1007 ID3D11Device_Release(tmp);
1009 ID3D11DepthStencilView_GetDesc(dsview, &dsv_desc);
1010 ok(dsv_desc.Format == texture_desc.Format, "Got unexpected format %#x.\n", dsv_desc.Format);
1011 ok(dsv_desc.ViewDimension == D3D11_DSV_DIMENSION_TEXTURE2D,
1012 "Got unexpected view dimension %#x.\n", dsv_desc.ViewDimension);
1013 ok(!dsv_desc.Flags, "Got unexpected flags %#x.\n", dsv_desc.Flags);
1014 ok(U(dsv_desc).Texture2D.MipSlice == 0, "Got Unexpected mip slice %u.\n", U(dsv_desc).Texture2D.MipSlice);
1016 ID3D11DepthStencilView_Release(dsview);
1017 ID3D11Texture2D_Release(texture);
1019 refcount = ID3D11Device_Release(device);
1020 ok(!refcount, "Device has %u references left.\n", refcount);
1023 static void test_depthstencil_view_interfaces(void)
1025 D3D10_DEPTH_STENCIL_VIEW_DESC d3d10_dsv_desc;
1026 D3D11_DEPTH_STENCIL_VIEW_DESC dsv_desc;
1027 ID3D10DepthStencilView *d3d10_dsview;
1028 D3D11_TEXTURE2D_DESC texture_desc;
1029 ID3D11DepthStencilView *dsview;
1030 ID3D11Texture2D *texture;
1031 ID3D11Device *device;
1032 ULONG refcount;
1033 HRESULT hr;
1035 if (!(device = create_device(NULL)))
1037 skip("Failed to create device.\n");
1038 return;
1041 texture_desc.Width = 512;
1042 texture_desc.Height = 512;
1043 texture_desc.MipLevels = 1;
1044 texture_desc.ArraySize = 1;
1045 texture_desc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
1046 texture_desc.SampleDesc.Count = 1;
1047 texture_desc.SampleDesc.Quality = 0;
1048 texture_desc.Usage = D3D11_USAGE_DEFAULT;
1049 texture_desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
1050 texture_desc.CPUAccessFlags = 0;
1051 texture_desc.MiscFlags = 0;
1053 hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &texture);
1054 ok(SUCCEEDED(hr), "Failed to create a 2d texture, hr %#x.\n", hr);
1056 dsv_desc.Format = texture_desc.Format;
1057 dsv_desc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
1058 dsv_desc.Flags = 0;
1059 U(dsv_desc).Texture2D.MipSlice = 0;
1061 hr = ID3D11Device_CreateDepthStencilView(device, (ID3D11Resource *)texture, &dsv_desc, &dsview);
1062 ok(SUCCEEDED(hr), "Failed to create a depthstencil view, hr %#x.\n", hr);
1064 hr = ID3D11DepthStencilView_QueryInterface(dsview, &IID_ID3D10DepthStencilView, (void **)&d3d10_dsview);
1065 ID3D11DepthStencilView_Release(dsview);
1066 ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */,
1067 "Depth stencil view should implement ID3D10DepthStencilView.\n");
1069 if (FAILED(hr))
1071 win_skip("Depth stencil view does not implement ID3D10DepthStencilView.\n");
1072 goto done;
1075 ID3D10DepthStencilView_GetDesc(d3d10_dsview, &d3d10_dsv_desc);
1076 ok(d3d10_dsv_desc.Format == dsv_desc.Format, "Got unexpected format %#x.\n", d3d10_dsv_desc.Format);
1077 ok(d3d10_dsv_desc.ViewDimension == (D3D10_DSV_DIMENSION)dsv_desc.ViewDimension,
1078 "Got unexpected view dimension %u.\n", d3d10_dsv_desc.ViewDimension);
1079 ok(U(d3d10_dsv_desc).Texture2D.MipSlice == U(dsv_desc).Texture2D.MipSlice,
1080 "Got unexpected mip slice %u.\n", U(d3d10_dsv_desc).Texture2D.MipSlice);
1082 ID3D10DepthStencilView_Release(d3d10_dsview);
1084 done:
1085 ID3D11Texture2D_Release(texture);
1087 refcount = ID3D11Device_Release(device);
1088 ok(!refcount, "Device has %u references left.\n", refcount);
1091 static void test_create_rendertarget_view(void)
1093 D3D11_RENDER_TARGET_VIEW_DESC rtv_desc;
1094 D3D11_SUBRESOURCE_DATA data = {0};
1095 D3D11_TEXTURE2D_DESC texture_desc;
1096 ULONG refcount, expected_refcount;
1097 D3D11_BUFFER_DESC buffer_desc;
1098 ID3D11RenderTargetView *rtview;
1099 ID3D11Device *device, *tmp;
1100 ID3D11Texture2D *texture;
1101 ID3D11Buffer *buffer;
1102 IUnknown *iface;
1103 HRESULT hr;
1105 if (!(device = create_device(NULL)))
1107 skip("Failed to create device.\n");
1108 return;
1111 buffer_desc.ByteWidth = 1024;
1112 buffer_desc.Usage = D3D11_USAGE_DEFAULT;
1113 buffer_desc.BindFlags = D3D11_BIND_RENDER_TARGET;
1114 buffer_desc.CPUAccessFlags = 0;
1115 buffer_desc.MiscFlags = 0;
1116 buffer_desc.StructureByteStride = 0;
1118 hr = ID3D11Device_CreateBuffer(device, &buffer_desc, &data, &buffer);
1119 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
1121 expected_refcount = get_refcount((IUnknown *)device) + 1;
1122 hr = ID3D11Device_CreateBuffer(device, &buffer_desc, NULL, &buffer);
1123 ok(SUCCEEDED(hr), "Failed to create a buffer, hr %#x.\n", hr);
1124 refcount = get_refcount((IUnknown *)device);
1125 ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount);
1126 tmp = NULL;
1127 expected_refcount = refcount + 1;
1128 ID3D11Buffer_GetDevice(buffer, &tmp);
1129 ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
1130 refcount = get_refcount((IUnknown *)device);
1131 ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
1132 ID3D11Device_Release(tmp);
1134 rtv_desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
1135 rtv_desc.ViewDimension = D3D11_RTV_DIMENSION_BUFFER;
1136 U(rtv_desc).Buffer.ElementOffset = 0;
1137 U(rtv_desc).Buffer.ElementWidth = 64;
1139 expected_refcount = get_refcount((IUnknown *)device) + 1;
1140 hr = ID3D11Device_CreateRenderTargetView(device, (ID3D11Resource *)buffer, &rtv_desc, &rtview);
1141 ok(SUCCEEDED(hr), "Failed to create a rendertarget view, hr %#x.\n", hr);
1142 refcount = get_refcount((IUnknown *)device);
1143 ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount);
1144 tmp = NULL;
1145 expected_refcount = refcount + 1;
1146 ID3D11RenderTargetView_GetDevice(rtview, &tmp);
1147 ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
1148 refcount = get_refcount((IUnknown *)device);
1149 ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
1150 ID3D11Device_Release(tmp);
1152 hr = ID3D11RenderTargetView_QueryInterface(rtview, &IID_ID3D10RenderTargetView, (void **)&iface);
1153 ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */,
1154 "Render target view should implement ID3D10RenderTargetView.\n");
1155 if (SUCCEEDED(hr)) IUnknown_Release(iface);
1157 ID3D11RenderTargetView_Release(rtview);
1158 ID3D11Buffer_Release(buffer);
1160 texture_desc.Width = 512;
1161 texture_desc.Height = 512;
1162 texture_desc.MipLevels = 1;
1163 texture_desc.ArraySize = 1;
1164 texture_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
1165 texture_desc.SampleDesc.Count = 1;
1166 texture_desc.SampleDesc.Quality = 0;
1167 texture_desc.Usage = D3D11_USAGE_DEFAULT;
1168 texture_desc.BindFlags = D3D11_BIND_RENDER_TARGET;
1169 texture_desc.CPUAccessFlags = 0;
1170 texture_desc.MiscFlags = 0;
1172 hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &texture);
1173 ok(SUCCEEDED(hr), "Failed to create a 2d texture, hr %#x.\n", hr);
1175 /* For texture resources it's allowed to specify NULL as desc */
1176 hr = ID3D11Device_CreateRenderTargetView(device, (ID3D11Resource *)texture, NULL, &rtview);
1177 ok(SUCCEEDED(hr), "Failed to create a rendertarget view, hr %#x.\n", hr);
1179 ID3D11RenderTargetView_GetDesc(rtview, &rtv_desc);
1180 ok(rtv_desc.Format == texture_desc.Format, "Got unexpected format %#x.\n", rtv_desc.Format);
1181 ok(rtv_desc.ViewDimension == D3D11_RTV_DIMENSION_TEXTURE2D, "Got unexpected view dimension %#x.\n",
1182 rtv_desc.ViewDimension);
1183 ok(U(rtv_desc).Texture2D.MipSlice == 0, "Got unexpected mip slice %#x.\n", U(rtv_desc).Texture2D.MipSlice);
1185 hr = ID3D11RenderTargetView_QueryInterface(rtview, &IID_ID3D10RenderTargetView, (void **)&iface);
1186 ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */,
1187 "Render target view should implement ID3D10RenderTargetView.\n");
1188 if (SUCCEEDED(hr)) IUnknown_Release(iface);
1190 ID3D11RenderTargetView_Release(rtview);
1191 ID3D11Texture2D_Release(texture);
1193 refcount = ID3D11Device_Release(device);
1194 ok(!refcount, "Device has %u references left.\n", refcount);
1197 static void test_create_shader_resource_view(void)
1199 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc;
1200 D3D11_TEXTURE2D_DESC texture_desc;
1201 ULONG refcount, expected_refcount;
1202 ID3D11ShaderResourceView *srview;
1203 D3D11_BUFFER_DESC buffer_desc;
1204 ID3D11Device *device, *tmp;
1205 ID3D11Texture2D *texture;
1206 ID3D11Buffer *buffer;
1207 IUnknown *iface;
1208 HRESULT hr;
1210 if (!(device = create_device(NULL)))
1212 skip("Failed to create device.\n");
1213 return;
1216 buffer_desc.ByteWidth = 1024;
1217 buffer_desc.Usage = D3D11_USAGE_DEFAULT;
1218 buffer_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
1219 buffer_desc.CPUAccessFlags = 0;
1220 buffer_desc.MiscFlags = 0;
1221 buffer_desc.StructureByteStride = 0;
1223 hr = ID3D11Device_CreateBuffer(device, &buffer_desc, NULL, &buffer);
1224 ok(SUCCEEDED(hr), "Failed to create a buffer, hr %#x.\n", hr);
1226 hr = ID3D11Device_CreateShaderResourceView(device, (ID3D11Resource *)buffer, NULL, &srview);
1227 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
1229 srv_desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
1230 srv_desc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
1231 U(srv_desc).Buffer.ElementOffset = 0;
1232 U(srv_desc).Buffer.ElementWidth = 64;
1234 expected_refcount = get_refcount((IUnknown *)device) + 1;
1235 hr = ID3D11Device_CreateShaderResourceView(device, (ID3D11Resource *)buffer, &srv_desc, &srview);
1236 ok(SUCCEEDED(hr), "Failed to create a shader resource view, hr %#x.\n", hr);
1237 refcount = get_refcount((IUnknown *)device);
1238 ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount);
1239 tmp = NULL;
1240 expected_refcount = refcount + 1;
1241 ID3D11ShaderResourceView_GetDevice(srview, &tmp);
1242 ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
1243 refcount = get_refcount((IUnknown *)device);
1244 ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
1245 ID3D11Device_Release(tmp);
1247 hr = ID3D11ShaderResourceView_QueryInterface(srview, &IID_ID3D10ShaderResourceView, (void **)&iface);
1248 ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */,
1249 "Shader resource view should implement ID3D10ShaderResourceView.\n");
1250 if (SUCCEEDED(hr)) IUnknown_Release(iface);
1252 ID3D11ShaderResourceView_Release(srview);
1253 ID3D11Buffer_Release(buffer);
1255 texture_desc.Width = 512;
1256 texture_desc.Height = 512;
1257 texture_desc.MipLevels = 0;
1258 texture_desc.ArraySize = 1;
1259 texture_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
1260 texture_desc.SampleDesc.Count = 1;
1261 texture_desc.SampleDesc.Quality = 0;
1262 texture_desc.Usage = D3D11_USAGE_DEFAULT;
1263 texture_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
1264 texture_desc.CPUAccessFlags = 0;
1265 texture_desc.MiscFlags = 0;
1267 hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &texture);
1268 ok(SUCCEEDED(hr), "Failed to create a 2d texture, hr %#x.\n", hr);
1270 hr = ID3D11Device_CreateShaderResourceView(device, (ID3D11Resource *)texture, NULL, &srview);
1271 ok(SUCCEEDED(hr), "Failed to create a shader resource view, hr %#x.\n", hr);
1273 hr = ID3D11ShaderResourceView_QueryInterface(srview, &IID_ID3D10ShaderResourceView, (void **)&iface);
1274 ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */,
1275 "Shader resource view should implement ID3D10ShaderResourceView.\n");
1276 if (SUCCEEDED(hr)) IUnknown_Release(iface);
1278 ID3D11ShaderResourceView_GetDesc(srview, &srv_desc);
1279 ok(srv_desc.Format == texture_desc.Format, "Got unexpected format %#x.\n", srv_desc.Format);
1280 ok(srv_desc.ViewDimension == D3D11_SRV_DIMENSION_TEXTURE2D,
1281 "Got unexpected view dimension %#x.\n", srv_desc.ViewDimension);
1282 ok(U(srv_desc).Texture2D.MostDetailedMip == 0, "Got unexpected MostDetailedMip %u.\n",
1283 U(srv_desc).Texture2D.MostDetailedMip);
1284 ok(U(srv_desc).Texture2D.MipLevels == 10, "Got unexpected MipLevels %u.\n", U(srv_desc).Texture2D.MipLevels);
1286 ID3D11ShaderResourceView_Release(srview);
1287 ID3D11Texture2D_Release(texture);
1289 refcount = ID3D11Device_Release(device);
1290 ok(!refcount, "Device has %u references left.\n", refcount);
1293 static void test_create_shader(void)
1295 #if 0
1296 float4 light;
1297 float4x4 mat;
1299 struct input
1301 float4 position : POSITION;
1302 float3 normal : NORMAL;
1305 struct output
1307 float4 position : POSITION;
1308 float4 diffuse : COLOR;
1311 output main(const input v)
1313 output o;
1315 o.position = mul(v.position, mat);
1316 o.diffuse = dot((float3)light, v.normal);
1318 return o;
1320 #endif
1321 static const DWORD vs_4_0[] =
1323 0x43425844, 0x3ae813ca, 0x0f034b91, 0x790f3226, 0x6b4a718a, 0x00000001, 0x000001c0,
1324 0x00000003, 0x0000002c, 0x0000007c, 0x000000cc, 0x4e475349, 0x00000048, 0x00000002,
1325 0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f,
1326 0x00000041, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000707, 0x49534f50,
1327 0x4e4f4954, 0x524f4e00, 0x004c414d, 0x4e47534f, 0x00000048, 0x00000002, 0x00000008,
1328 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x00000041,
1329 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x49534f50, 0x4e4f4954,
1330 0x4c4f4300, 0xab00524f, 0x52444853, 0x000000ec, 0x00010040, 0x0000003b, 0x04000059,
1331 0x00208e46, 0x00000000, 0x00000005, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f,
1332 0x00101072, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x001020f2,
1333 0x00000001, 0x08000011, 0x00102012, 0x00000000, 0x00101e46, 0x00000000, 0x00208e46,
1334 0x00000000, 0x00000001, 0x08000011, 0x00102022, 0x00000000, 0x00101e46, 0x00000000,
1335 0x00208e46, 0x00000000, 0x00000002, 0x08000011, 0x00102042, 0x00000000, 0x00101e46,
1336 0x00000000, 0x00208e46, 0x00000000, 0x00000003, 0x08000011, 0x00102082, 0x00000000,
1337 0x00101e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x08000010, 0x001020f2,
1338 0x00000001, 0x00208246, 0x00000000, 0x00000000, 0x00101246, 0x00000001, 0x0100003e,
1341 static const DWORD vs_2_0[] =
1343 0xfffe0200, 0x002bfffe, 0x42415443, 0x0000001c, 0x00000077, 0xfffe0200, 0x00000002,
1344 0x0000001c, 0x00000100, 0x00000070, 0x00000044, 0x00040002, 0x00000001, 0x0000004c,
1345 0x00000000, 0x0000005c, 0x00000002, 0x00000004, 0x00000060, 0x00000000, 0x6867696c,
1346 0xabab0074, 0x00030001, 0x00040001, 0x00000001, 0x00000000, 0x0074616d, 0x00030003,
1347 0x00040004, 0x00000001, 0x00000000, 0x325f7376, 0x4d00305f, 0x6f726369, 0x74666f73,
1348 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e392072,
1349 0x392e3932, 0x332e3235, 0x00313131, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f,
1350 0x80000003, 0x900f0001, 0x03000009, 0xc0010000, 0x90e40000, 0xa0e40000, 0x03000009,
1351 0xc0020000, 0x90e40000, 0xa0e40001, 0x03000009, 0xc0040000, 0x90e40000, 0xa0e40002,
1352 0x03000009, 0xc0080000, 0x90e40000, 0xa0e40003, 0x03000008, 0xd00f0000, 0xa0e40004,
1353 0x90e40001, 0x0000ffff,
1356 static const DWORD vs_3_0[] =
1358 0xfffe0300, 0x002bfffe, 0x42415443, 0x0000001c, 0x00000077, 0xfffe0300, 0x00000002,
1359 0x0000001c, 0x00000100, 0x00000070, 0x00000044, 0x00040002, 0x00000001, 0x0000004c,
1360 0x00000000, 0x0000005c, 0x00000002, 0x00000004, 0x00000060, 0x00000000, 0x6867696c,
1361 0xabab0074, 0x00030001, 0x00040001, 0x00000001, 0x00000000, 0x0074616d, 0x00030003,
1362 0x00040004, 0x00000001, 0x00000000, 0x335f7376, 0x4d00305f, 0x6f726369, 0x74666f73,
1363 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e392072,
1364 0x392e3932, 0x332e3235, 0x00313131, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f,
1365 0x80000003, 0x900f0001, 0x0200001f, 0x80000000, 0xe00f0000, 0x0200001f, 0x8000000a,
1366 0xe00f0001, 0x03000009, 0xe0010000, 0x90e40000, 0xa0e40000, 0x03000009, 0xe0020000,
1367 0x90e40000, 0xa0e40001, 0x03000009, 0xe0040000, 0x90e40000, 0xa0e40002, 0x03000009,
1368 0xe0080000, 0x90e40000, 0xa0e40003, 0x03000008, 0xe00f0001, 0xa0e40004, 0x90e40001,
1369 0x0000ffff,
1372 #if 0
1373 float4 main(const float4 color : COLOR) : SV_TARGET
1375 float4 o;
1377 o = color;
1379 return o;
1381 #endif
1382 static const DWORD ps_4_0[] =
1384 0x43425844, 0x4da9446f, 0xfbe1f259, 0x3fdb3009, 0x517521fa, 0x00000001, 0x000001ac,
1385 0x00000005, 0x00000034, 0x0000008c, 0x000000bc, 0x000000f0, 0x00000130, 0x46454452,
1386 0x00000050, 0x00000000, 0x00000000, 0x00000000, 0x0000001c, 0xffff0400, 0x00000100,
1387 0x0000001c, 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168,
1388 0x6f432072, 0x6c69706d, 0x39207265, 0x2e39322e, 0x2e323539, 0x31313133, 0xababab00,
1389 0x4e475349, 0x00000028, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
1390 0x00000003, 0x00000000, 0x00000f0f, 0x4f4c4f43, 0xabab0052, 0x4e47534f, 0x0000002c,
1391 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
1392 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040,
1393 0x0000000e, 0x03001062, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000,
1394 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x54415453,
1395 0x00000074, 0x00000002, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000,
1396 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1397 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
1398 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1399 0x00000000, 0x00000000,
1402 #if 0
1403 struct gs_out
1405 float4 pos : SV_POSITION;
1408 [maxvertexcount(4)]
1409 void main(point float4 vin[1] : POSITION, inout TriangleStream<gs_out> vout)
1411 float offset = 0.1 * vin[0].w;
1412 gs_out v;
1414 v.pos = float4(vin[0].x - offset, vin[0].y - offset, vin[0].z, vin[0].w);
1415 vout.Append(v);
1416 v.pos = float4(vin[0].x - offset, vin[0].y + offset, vin[0].z, vin[0].w);
1417 vout.Append(v);
1418 v.pos = float4(vin[0].x + offset, vin[0].y - offset, vin[0].z, vin[0].w);
1419 vout.Append(v);
1420 v.pos = float4(vin[0].x + offset, vin[0].y + offset, vin[0].z, vin[0].w);
1421 vout.Append(v);
1423 #endif
1424 static const DWORD gs_4_0[] =
1426 0x43425844, 0x000ee786, 0xc624c269, 0x885a5cbe, 0x444b3b1f, 0x00000001, 0x0000023c, 0x00000003,
1427 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
1428 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
1429 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
1430 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x000001a0, 0x00020040,
1431 0x00000068, 0x0400005f, 0x002010f2, 0x00000001, 0x00000000, 0x02000068, 0x00000001, 0x0100085d,
1432 0x0100285c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x0200005e, 0x00000004, 0x0f000032,
1433 0x00100032, 0x00000000, 0x80201ff6, 0x00000041, 0x00000000, 0x00000000, 0x00004002, 0x3dcccccd,
1434 0x3dcccccd, 0x00000000, 0x00000000, 0x00201046, 0x00000000, 0x00000000, 0x05000036, 0x00102032,
1435 0x00000000, 0x00100046, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000,
1436 0x00000000, 0x01000013, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0e000032,
1437 0x00100052, 0x00000000, 0x00201ff6, 0x00000000, 0x00000000, 0x00004002, 0x3dcccccd, 0x00000000,
1438 0x3dcccccd, 0x00000000, 0x00201106, 0x00000000, 0x00000000, 0x05000036, 0x00102022, 0x00000000,
1439 0x0010002a, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000, 0x00000000,
1440 0x01000013, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x05000036, 0x00102022,
1441 0x00000000, 0x0010001a, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000,
1442 0x00000000, 0x01000013, 0x05000036, 0x00102032, 0x00000000, 0x00100086, 0x00000000, 0x06000036,
1443 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000, 0x00000000, 0x01000013, 0x0100003e,
1446 ULONG refcount, expected_refcount;
1447 ID3D11Device *device, *tmp;
1448 ID3D11GeometryShader *gs;
1449 ID3D11VertexShader *vs;
1450 ID3D11PixelShader *ps;
1451 IUnknown *iface;
1452 unsigned int i;
1453 HRESULT hr;
1455 for (i = 0; i < sizeof(d3d11_feature_levels) / sizeof(*d3d11_feature_levels); ++i)
1457 D3D_FEATURE_LEVEL feature_level = d3d11_feature_levels[i];
1458 if (!(device = create_device(&feature_level)))
1460 skip("Failed to create device for feature level %#x.\n", feature_level);
1461 continue;
1464 /* vertex shader */
1465 hr = ID3D11Device_CreateVertexShader(device, vs_2_0, sizeof(vs_2_0), NULL, &vs);
1466 ok(hr == E_INVALIDARG, "Created a SM2 vertex shader, hr %#x, feature level %#x.\n", hr, feature_level);
1468 hr = ID3D11Device_CreateVertexShader(device, vs_3_0, sizeof(vs_3_0), NULL, &vs);
1469 ok(hr == E_INVALIDARG, "Created a SM3 vertex shader, hr %#x, feature level %#x.\n", hr, feature_level);
1471 hr = ID3D11Device_CreateVertexShader(device, ps_4_0, sizeof(ps_4_0), NULL, &vs);
1472 ok(hr == E_INVALIDARG, "Created a SM4 vertex shader from a pixel shader source, hr %#x, feature level %#x.\n",
1473 hr, feature_level);
1475 if (feature_level < D3D_FEATURE_LEVEL_10_0)
1477 refcount = ID3D11Device_Release(device);
1478 ok(!refcount, "Device has %u references left.\n", refcount);
1479 continue;
1482 expected_refcount = get_refcount((IUnknown *)device) + 1;
1483 hr = ID3D11Device_CreateVertexShader(device, vs_4_0, sizeof(vs_4_0), NULL, &vs);
1484 ok(SUCCEEDED(hr), "Failed to create SM4 vertex shader, hr %#x, feature level %#x.\n", hr, feature_level);
1486 refcount = get_refcount((IUnknown *)device);
1487 ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n",
1488 refcount, expected_refcount);
1489 tmp = NULL;
1490 expected_refcount = refcount + 1;
1491 ID3D11VertexShader_GetDevice(vs, &tmp);
1492 ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
1493 refcount = get_refcount((IUnknown *)device);
1494 ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n",
1495 refcount, expected_refcount);
1496 ID3D11Device_Release(tmp);
1498 hr = ID3D11VertexShader_QueryInterface(vs, &IID_ID3D10VertexShader, (void **)&iface);
1499 ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */,
1500 "Vertex shader should implement ID3D10VertexShader.\n");
1501 if (SUCCEEDED(hr)) IUnknown_Release(iface);
1503 refcount = ID3D11VertexShader_Release(vs);
1504 ok(!refcount, "Vertex shader has %u references left.\n", refcount);
1506 /* pixel shader */
1507 expected_refcount = get_refcount((IUnknown *)device) + 1;
1508 hr = ID3D11Device_CreatePixelShader(device, ps_4_0, sizeof(ps_4_0), NULL, &ps);
1509 ok(SUCCEEDED(hr), "Failed to create SM4 vertex shader, hr %#x, feature level %#x.\n", hr, feature_level);
1511 refcount = get_refcount((IUnknown *)device);
1512 ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n",
1513 refcount, expected_refcount);
1514 tmp = NULL;
1515 expected_refcount = refcount + 1;
1516 ID3D11PixelShader_GetDevice(ps, &tmp);
1517 ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
1518 refcount = get_refcount((IUnknown *)device);
1519 ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n",
1520 refcount, expected_refcount);
1521 ID3D11Device_Release(tmp);
1523 hr = ID3D11PixelShader_QueryInterface(ps, &IID_ID3D10PixelShader, (void **)&iface);
1524 ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */,
1525 "Pixel shader should implement ID3D10PixelShader.\n");
1526 if (SUCCEEDED(hr)) IUnknown_Release(iface);
1528 refcount = ID3D11PixelShader_Release(ps);
1529 ok(!refcount, "Pixel shader has %u references left.\n", refcount);
1531 /* geometry shader */
1532 expected_refcount = get_refcount((IUnknown *)device) + 1;
1533 hr = ID3D11Device_CreateGeometryShader(device, gs_4_0, sizeof(gs_4_0), NULL, &gs);
1534 ok(SUCCEEDED(hr), "Failed to create SM4 geometry shader, hr %#x.\n", hr);
1536 refcount = get_refcount((IUnknown *)device);
1537 ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n",
1538 refcount, expected_refcount);
1539 tmp = NULL;
1540 expected_refcount = refcount + 1;
1541 ID3D11GeometryShader_GetDevice(gs, &tmp);
1542 ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
1543 refcount = get_refcount((IUnknown *)device);
1544 ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n",
1545 refcount, expected_refcount);
1546 ID3D11Device_Release(tmp);
1548 hr = ID3D11GeometryShader_QueryInterface(gs, &IID_ID3D10GeometryShader, (void **)&iface);
1549 ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */,
1550 "Geometry shader should implement ID3D10GeometryShader.\n");
1551 if (SUCCEEDED(hr)) IUnknown_Release(iface);
1553 refcount = ID3D11GeometryShader_Release(gs);
1554 ok(!refcount, "Geometry shader has %u references left.\n", refcount);
1556 refcount = ID3D11Device_Release(device);
1557 ok(!refcount, "Device has %u references left.\n", refcount);
1561 static void test_create_blend_state(void)
1563 static const D3D11_BLEND_DESC desc_conversion_tests[] =
1566 FALSE, FALSE,
1569 FALSE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD,
1570 D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD
1575 FALSE, TRUE,
1578 TRUE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD,
1579 D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL
1582 FALSE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD,
1583 D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_RED
1586 TRUE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD,
1587 D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL
1590 FALSE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD,
1591 D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_GREEN
1594 TRUE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD,
1595 D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL
1598 TRUE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD,
1599 D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL
1602 TRUE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD,
1603 D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL
1606 TRUE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD,
1607 D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL
1612 FALSE, TRUE,
1615 TRUE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD,
1616 D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL
1619 TRUE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_SUBTRACT,
1620 D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL
1623 TRUE, D3D11_BLEND_ZERO, D3D11_BLEND_ONE, D3D11_BLEND_OP_ADD,
1624 D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL
1627 TRUE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD,
1628 D3D11_BLEND_ZERO, D3D11_BLEND_ONE, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL
1631 TRUE, D3D11_BLEND_ONE, D3D11_BLEND_ONE, D3D11_BLEND_OP_MAX,
1632 D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL
1635 TRUE, D3D11_BLEND_ONE, D3D11_BLEND_ONE, D3D11_BLEND_OP_MIN,
1636 D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL
1639 FALSE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD,
1640 D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL
1643 FALSE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD,
1644 D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL
1650 ID3D11BlendState *blend_state1, *blend_state2;
1651 D3D11_BLEND_DESC desc, obtained_desc;
1652 ID3D10BlendState *d3d10_blend_state;
1653 D3D10_BLEND_DESC d3d10_blend_desc;
1654 ULONG refcount, expected_refcount;
1655 ID3D11Device *device, *tmp;
1656 unsigned int i, j;
1657 HRESULT hr;
1659 if (!(device = create_device(NULL)))
1661 skip("Failed to create device.\n");
1662 return;
1665 hr = ID3D11Device_CreateBlendState(device, NULL, &blend_state1);
1666 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
1668 memset(&desc, 0, sizeof(desc));
1669 desc.AlphaToCoverageEnable = FALSE;
1670 desc.IndependentBlendEnable = FALSE;
1671 desc.RenderTarget[0].BlendEnable = FALSE;
1672 desc.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE;
1673 desc.RenderTarget[0].DestBlend = D3D11_BLEND_ZERO;
1674 desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
1675 desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
1676 desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
1677 desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
1678 desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
1680 expected_refcount = get_refcount((IUnknown *)device) + 1;
1681 hr = ID3D11Device_CreateBlendState(device, &desc, &blend_state1);
1682 ok(SUCCEEDED(hr), "Failed to create blend state, hr %#x.\n", hr);
1683 hr = ID3D11Device_CreateBlendState(device, &desc, &blend_state2);
1684 ok(SUCCEEDED(hr), "Failed to create blend state, hr %#x.\n", hr);
1685 ok(blend_state1 == blend_state2, "Got different blend state objects.\n");
1686 refcount = get_refcount((IUnknown *)device);
1687 ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount);
1688 tmp = NULL;
1689 expected_refcount = refcount + 1;
1690 ID3D11BlendState_GetDevice(blend_state1, &tmp);
1691 ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
1692 refcount = get_refcount((IUnknown *)device);
1693 ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
1694 ID3D11Device_Release(tmp);
1696 ID3D11BlendState_GetDesc(blend_state1, &obtained_desc);
1697 ok(obtained_desc.AlphaToCoverageEnable == FALSE, "Got unexpected alpha to coverage enable %#x.\n",
1698 obtained_desc.AlphaToCoverageEnable);
1699 ok(obtained_desc.IndependentBlendEnable == FALSE, "Got unexpected independent blend enable %#x.\n",
1700 obtained_desc.IndependentBlendEnable);
1701 for (i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
1703 ok(obtained_desc.RenderTarget[i].BlendEnable == FALSE,
1704 "Got unexpected blend enable %#x for render target %u.\n",
1705 obtained_desc.RenderTarget[i].BlendEnable, i);
1706 ok(obtained_desc.RenderTarget[i].SrcBlend == D3D11_BLEND_ONE,
1707 "Got unexpected src blend %u for render target %u.\n",
1708 obtained_desc.RenderTarget[i].SrcBlend, i);
1709 ok(obtained_desc.RenderTarget[i].DestBlend == D3D11_BLEND_ZERO,
1710 "Got unexpected dest blend %u for render target %u.\n",
1711 obtained_desc.RenderTarget[i].DestBlend, i);
1712 ok(obtained_desc.RenderTarget[i].BlendOp == D3D11_BLEND_OP_ADD,
1713 "Got unexpected blend op %u for render target %u.\n",
1714 obtained_desc.RenderTarget[i].BlendOp, i);
1715 ok(obtained_desc.RenderTarget[i].SrcBlendAlpha == D3D11_BLEND_ONE,
1716 "Got unexpected src blend alpha %u for render target %u.\n",
1717 obtained_desc.RenderTarget[i].SrcBlendAlpha, i);
1718 ok(obtained_desc.RenderTarget[i].DestBlendAlpha == D3D11_BLEND_ZERO,
1719 "Got unexpected dest blend alpha %u for render target %u.\n",
1720 obtained_desc.RenderTarget[i].DestBlendAlpha, i);
1721 ok(obtained_desc.RenderTarget[i].BlendOpAlpha == D3D11_BLEND_OP_ADD,
1722 "Got unexpected blend op alpha %u for render target %u.\n",
1723 obtained_desc.RenderTarget[i].BlendOpAlpha, i);
1724 ok(obtained_desc.RenderTarget[i].RenderTargetWriteMask == D3D11_COLOR_WRITE_ENABLE_ALL,
1725 "Got unexpected render target write mask %#x for render target %u.\n",
1726 obtained_desc.RenderTarget[0].RenderTargetWriteMask, i);
1729 refcount = ID3D11BlendState_Release(blend_state1);
1730 ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
1731 refcount = ID3D11BlendState_Release(blend_state2);
1732 ok(!refcount, "Blend state has %u references left.\n", refcount);
1734 for (i = 0; i < sizeof(desc_conversion_tests) / sizeof(*desc_conversion_tests); ++i)
1736 const D3D11_BLEND_DESC *current_desc = &desc_conversion_tests[i];
1738 hr = ID3D11Device_CreateBlendState(device, current_desc, &blend_state1);
1739 ok(SUCCEEDED(hr), "Failed to create blend state, hr %#x.\n", hr);
1741 hr = ID3D11BlendState_QueryInterface(blend_state1, &IID_ID3D10BlendState, (void **)&d3d10_blend_state);
1742 ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */,
1743 "Blend state should implement ID3D10BlendState.\n");
1744 if (FAILED(hr))
1746 win_skip("Blend state does not implement ID3D10BlendState.\n");
1747 ID3D11BlendState_Release(blend_state1);
1748 break;
1751 ID3D10BlendState_GetDesc(d3d10_blend_state, &d3d10_blend_desc);
1752 ok(d3d10_blend_desc.AlphaToCoverageEnable == current_desc->AlphaToCoverageEnable,
1753 "Got unexpected alpha to coverage enable %#x for test %u.\n",
1754 d3d10_blend_desc.AlphaToCoverageEnable, i);
1755 ok(d3d10_blend_desc.SrcBlend == (D3D10_BLEND)current_desc->RenderTarget[0].SrcBlend,
1756 "Got unexpected src blend %u for test %u.\n", d3d10_blend_desc.SrcBlend, i);
1757 ok(d3d10_blend_desc.DestBlend == (D3D10_BLEND)current_desc->RenderTarget[0].DestBlend,
1758 "Got unexpected dest blend %u for test %u.\n", d3d10_blend_desc.DestBlend, i);
1759 ok(d3d10_blend_desc.BlendOp == (D3D10_BLEND_OP)current_desc->RenderTarget[0].BlendOp,
1760 "Got unexpected blend op %u for test %u.\n", d3d10_blend_desc.BlendOp, i);
1761 ok(d3d10_blend_desc.SrcBlendAlpha == (D3D10_BLEND)current_desc->RenderTarget[0].SrcBlendAlpha,
1762 "Got unexpected src blend alpha %u for test %u.\n", d3d10_blend_desc.SrcBlendAlpha, i);
1763 ok(d3d10_blend_desc.DestBlendAlpha == (D3D10_BLEND)current_desc->RenderTarget[0].DestBlendAlpha,
1764 "Got unexpected dest blend alpha %u for test %u.\n", d3d10_blend_desc.DestBlendAlpha, i);
1765 ok(d3d10_blend_desc.BlendOpAlpha == (D3D10_BLEND_OP)current_desc->RenderTarget[0].BlendOpAlpha,
1766 "Got unexpected blend op alpha %u for test %u.\n", d3d10_blend_desc.BlendOpAlpha, i);
1767 for (j = 0; j < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; j++)
1769 unsigned int k = current_desc->IndependentBlendEnable ? j : 0;
1770 ok(d3d10_blend_desc.BlendEnable[j] == current_desc->RenderTarget[k].BlendEnable,
1771 "Got unexpected blend enable %#x for test %u, render target %u.\n",
1772 d3d10_blend_desc.BlendEnable[j], i, j);
1773 ok(d3d10_blend_desc.RenderTargetWriteMask[j] == current_desc->RenderTarget[k].RenderTargetWriteMask,
1774 "Got unexpected render target write mask %#x for test %u, render target %u.\n",
1775 d3d10_blend_desc.RenderTargetWriteMask[j], i, j);
1778 ID3D10BlendState_Release(d3d10_blend_state);
1780 refcount = ID3D11BlendState_Release(blend_state1);
1781 ok(!refcount, "Got unexpected refcount %u.\n", refcount);
1784 refcount = ID3D11Device_Release(device);
1785 ok(!refcount, "Device has %u references left.\n", refcount);
1788 static void test_create_depthstencil_state(void)
1790 ID3D11DepthStencilState *ds_state1, *ds_state2;
1791 ID3D10DepthStencilState *d3d10_ds_state;
1792 ULONG refcount, expected_refcount;
1793 D3D11_DEPTH_STENCIL_DESC ds_desc;
1794 ID3D11Device *device, *tmp;
1795 HRESULT hr;
1797 if (!(device = create_device(NULL)))
1799 skip("Failed to create device.\n");
1800 return;
1803 hr = ID3D11Device_CreateDepthStencilState(device, NULL, &ds_state1);
1804 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
1806 ds_desc.DepthEnable = TRUE;
1807 ds_desc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
1808 ds_desc.DepthFunc = D3D11_COMPARISON_LESS;
1809 ds_desc.StencilEnable = FALSE;
1810 ds_desc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK;
1811 ds_desc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK;
1812 ds_desc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
1813 ds_desc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
1814 ds_desc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
1815 ds_desc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
1816 ds_desc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
1817 ds_desc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
1818 ds_desc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
1819 ds_desc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
1821 expected_refcount = get_refcount((IUnknown *)device) + 1;
1822 hr = ID3D11Device_CreateDepthStencilState(device, &ds_desc, &ds_state1);
1823 ok(SUCCEEDED(hr), "Failed to create depthstencil state, hr %#x.\n", hr);
1824 hr = ID3D11Device_CreateDepthStencilState(device, &ds_desc, &ds_state2);
1825 ok(SUCCEEDED(hr), "Failed to create depthstencil state, hr %#x.\n", hr);
1826 ok(ds_state1 == ds_state2, "Got different depthstencil state objects.\n");
1827 refcount = get_refcount((IUnknown *)device);
1828 ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount);
1829 tmp = NULL;
1830 expected_refcount = refcount + 1;
1831 ID3D11DepthStencilState_GetDevice(ds_state1, &tmp);
1832 ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
1833 refcount = get_refcount((IUnknown *)device);
1834 ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
1835 ID3D11Device_Release(tmp);
1837 hr = ID3D11DepthStencilState_QueryInterface(ds_state1, &IID_ID3D10DepthStencilState, (void **)&d3d10_ds_state);
1838 ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */,
1839 "Depth stencil state should implement ID3D10DepthStencilState.\n");
1840 if (SUCCEEDED(hr)) ID3D10DepthStencilState_Release(d3d10_ds_state);
1842 refcount = ID3D11DepthStencilState_Release(ds_state2);
1843 ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
1844 refcount = ID3D11DepthStencilState_Release(ds_state1);
1845 ok(!refcount, "Got unexpected refcount %u.\n", refcount);
1847 refcount = ID3D11Device_Release(device);
1848 ok(!refcount, "Device has %u references left.\n", refcount);
1851 static void test_create_rasterizer_state(void)
1853 ID3D11RasterizerState *rast_state1, *rast_state2;
1854 ID3D10RasterizerState *d3d10_rast_state;
1855 ULONG refcount, expected_refcount;
1856 D3D10_RASTERIZER_DESC d3d10_desc;
1857 D3D11_RASTERIZER_DESC desc;
1858 ID3D11Device *device, *tmp;
1859 HRESULT hr;
1861 if (!(device = create_device(NULL)))
1863 skip("Failed to create device.\n");
1864 return;
1867 hr = ID3D11Device_CreateRasterizerState(device, NULL, &rast_state1);
1868 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
1870 desc.FillMode = D3D11_FILL_SOLID;
1871 desc.CullMode = D3D11_CULL_BACK;
1872 desc.FrontCounterClockwise = FALSE;
1873 desc.DepthBias = 0;
1874 desc.DepthBiasClamp = 0.0f;
1875 desc.SlopeScaledDepthBias = 0.0f;
1876 desc.DepthClipEnable = TRUE;
1877 desc.ScissorEnable = FALSE;
1878 desc.MultisampleEnable = FALSE;
1879 desc.AntialiasedLineEnable = FALSE;
1881 expected_refcount = get_refcount((IUnknown *)device) + 1;
1882 hr = ID3D11Device_CreateRasterizerState(device, &desc, &rast_state1);
1883 ok(SUCCEEDED(hr), "Failed to create rasterizer state, hr %#x.\n", hr);
1884 hr = ID3D11Device_CreateRasterizerState(device, &desc, &rast_state2);
1885 ok(SUCCEEDED(hr), "Failed to create rasterizer state, hr %#x.\n", hr);
1886 ok(rast_state1 == rast_state2, "Got different rasterizer state objects.\n");
1887 refcount = get_refcount((IUnknown *)device);
1888 ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount);
1889 tmp = NULL;
1890 expected_refcount = refcount + 1;
1891 ID3D11RasterizerState_GetDevice(rast_state1, &tmp);
1892 ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
1893 refcount = get_refcount((IUnknown *)device);
1894 ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
1895 ID3D11Device_Release(tmp);
1897 hr = ID3D11RasterizerState_QueryInterface(rast_state1, &IID_ID3D10RasterizerState, (void **)&d3d10_rast_state);
1898 ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */,
1899 "Rasterizer state should implement ID3D10RasterizerState.\n");
1900 if (SUCCEEDED(hr))
1902 ID3D10RasterizerState_GetDesc(d3d10_rast_state, &d3d10_desc);
1903 ok(d3d10_desc.FillMode == D3D10_FILL_SOLID, "Got unexpected fill mode %u.\n", d3d10_desc.FillMode);
1904 ok(d3d10_desc.CullMode == D3D10_CULL_BACK, "Got unexpected cull mode %u.\n", d3d10_desc.CullMode);
1905 ok(!d3d10_desc.FrontCounterClockwise, "Got unexpected front counter clockwise %#x.\n",
1906 d3d10_desc.FrontCounterClockwise);
1907 ok(!d3d10_desc.DepthBias, "Got unexpected depth bias %d.\n", d3d10_desc.DepthBias);
1908 ok(!d3d10_desc.DepthBiasClamp, "Got unexpected depth bias clamp %f.\n", d3d10_desc.DepthBiasClamp);
1909 ok(!d3d10_desc.SlopeScaledDepthBias, "Got unexpected slope scaled depth bias %f.\n",
1910 d3d10_desc.SlopeScaledDepthBias);
1911 ok(!!d3d10_desc.DepthClipEnable, "Got unexpected depth clip enable %#x.\n", d3d10_desc.DepthClipEnable);
1912 ok(!d3d10_desc.ScissorEnable, "Got unexpected scissor enable %#x.\n", d3d10_desc.ScissorEnable);
1913 ok(!d3d10_desc.MultisampleEnable, "Got unexpected multisample enable %#x.\n",
1914 d3d10_desc.MultisampleEnable);
1915 ok(!d3d10_desc.AntialiasedLineEnable, "Got unexpected antialiased line enable %#x.\n",
1916 d3d10_desc.AntialiasedLineEnable);
1918 refcount = ID3D10RasterizerState_Release(d3d10_rast_state);
1919 ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
1922 refcount = ID3D11RasterizerState_Release(rast_state2);
1923 ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
1924 refcount = ID3D11RasterizerState_Release(rast_state1);
1925 ok(!refcount, "Got unexpected refcount %u.\n", refcount);
1927 refcount = ID3D11Device_Release(device);
1928 ok(!refcount, "Device has %u references left.\n", refcount);
1931 static void test_device_removed_reason(void)
1933 ID3D11Device *device;
1934 ULONG refcount;
1935 HRESULT hr;
1937 if (!(device = create_device(NULL)))
1939 skip("Failed to create device.\n");
1940 return;
1943 hr = ID3D11Device_GetDeviceRemovedReason(device);
1944 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
1945 hr = ID3D11Device_GetDeviceRemovedReason(device);
1946 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
1948 refcount = ID3D11Device_Release(device);
1949 ok(!refcount, "Device has %u references left.\n", refcount);
1952 static void test_private_data(void)
1954 ULONG refcount, expected_refcount;
1955 D3D11_TEXTURE2D_DESC texture_desc;
1956 ID3D10Texture2D *d3d10_texture;
1957 ID3D11Device *test_object;
1958 ID3D11Texture2D *texture;
1959 IDXGIDevice *dxgi_device;
1960 IDXGISurface *surface;
1961 ID3D11Device *device;
1962 IUnknown *ptr;
1963 HRESULT hr;
1964 UINT size;
1966 static const GUID test_guid =
1967 {0xfdb37466, 0x428f, 0x4edf, {0xa3, 0x7f, 0x9b, 0x1d, 0xf4, 0x88, 0xc5, 0xfc}};
1968 static const GUID test_guid2 =
1969 {0x2e5afac2, 0x87b5, 0x4c10, {0x9b, 0x4b, 0x89, 0xd7, 0xd1, 0x12, 0xe7, 0x2b}};
1970 static const DWORD data[] = {1, 2, 3, 4};
1972 if (!(device = create_device(NULL)))
1974 skip("Failed to create device.\n");
1975 return;
1978 test_object = create_device(NULL);
1980 texture_desc.Width = 512;
1981 texture_desc.Height = 512;
1982 texture_desc.MipLevels = 1;
1983 texture_desc.ArraySize = 1;
1984 texture_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
1985 texture_desc.SampleDesc.Count = 1;
1986 texture_desc.SampleDesc.Quality = 0;
1987 texture_desc.Usage = D3D11_USAGE_DEFAULT;
1988 texture_desc.BindFlags = D3D11_BIND_RENDER_TARGET;
1989 texture_desc.CPUAccessFlags = 0;
1990 texture_desc.MiscFlags = 0;
1992 hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &texture);
1993 ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
1994 hr = ID3D11Texture2D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface);
1995 ok(SUCCEEDED(hr), "Failed to get IDXGISurface, hr %#x.\n", hr);
1997 hr = ID3D11Device_SetPrivateData(device, &test_guid, 0, NULL);
1998 ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
1999 hr = ID3D11Device_SetPrivateDataInterface(device, &test_guid, NULL);
2000 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2001 hr = ID3D11Device_SetPrivateData(device, &test_guid, ~0u, NULL);
2002 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2003 hr = ID3D11Device_SetPrivateData(device, &test_guid, ~0u, NULL);
2004 ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
2006 hr = ID3D11Device_SetPrivateDataInterface(device, &test_guid, NULL);
2007 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2008 size = sizeof(ptr) * 2;
2009 ptr = (IUnknown *)0xdeadbeef;
2010 hr = ID3D11Device_GetPrivateData(device, &test_guid, &size, &ptr);
2011 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2012 ok(!ptr, "Got unexpected pointer %p.\n", ptr);
2013 ok(size == sizeof(IUnknown *), "Got unexpected size %u.\n", size);
2015 hr = ID3D11Device_QueryInterface(device, &IID_IDXGIDevice, (void **)&dxgi_device);
2016 ok(SUCCEEDED(hr), "Failed to get DXGI device, hr %#x.\n", hr);
2017 size = sizeof(ptr) * 2;
2018 ptr = (IUnknown *)0xdeadbeef;
2019 hr = IDXGIDevice_GetPrivateData(dxgi_device, &test_guid, &size, &ptr);
2020 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2021 ok(!ptr, "Got unexpected pointer %p.\n", ptr);
2022 ok(size == sizeof(IUnknown *), "Got unexpected size %u.\n", size);
2023 IDXGIDevice_Release(dxgi_device);
2025 refcount = get_refcount((IUnknown *)test_object);
2026 hr = ID3D11Device_SetPrivateDataInterface(device, &test_guid, (IUnknown *)test_object);
2027 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2028 expected_refcount = refcount + 1;
2029 refcount = get_refcount((IUnknown *)test_object);
2030 ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
2031 hr = ID3D11Device_SetPrivateDataInterface(device, &test_guid, (IUnknown *)test_object);
2032 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2033 refcount = get_refcount((IUnknown *)test_object);
2034 ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
2036 hr = ID3D11Device_SetPrivateDataInterface(device, &test_guid, NULL);
2037 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2038 --expected_refcount;
2039 refcount = get_refcount((IUnknown *)test_object);
2040 ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
2042 hr = ID3D11Device_SetPrivateDataInterface(device, &test_guid, (IUnknown *)test_object);
2043 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2044 size = sizeof(data);
2045 hr = ID3D11Device_SetPrivateData(device, &test_guid, size, data);
2046 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2047 refcount = get_refcount((IUnknown *)test_object);
2048 ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
2049 hr = ID3D11Device_SetPrivateData(device, &test_guid, 42, NULL);
2050 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2051 hr = ID3D11Device_SetPrivateData(device, &test_guid, 42, NULL);
2052 ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
2054 hr = ID3D11Device_SetPrivateDataInterface(device, &test_guid, (IUnknown *)test_object);
2055 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2056 ++expected_refcount;
2057 size = 2 * sizeof(ptr);
2058 ptr = NULL;
2059 hr = ID3D11Device_GetPrivateData(device, &test_guid, &size, &ptr);
2060 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2061 ok(size == sizeof(test_object), "Got unexpected size %u.\n", size);
2062 ++expected_refcount;
2063 refcount = get_refcount((IUnknown *)test_object);
2064 ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
2065 IUnknown_Release(ptr);
2066 --expected_refcount;
2068 ptr = (IUnknown *)0xdeadbeef;
2069 size = 1;
2070 hr = ID3D11Device_GetPrivateData(device, &test_guid, &size, NULL);
2071 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2072 ok(size == sizeof(device), "Got unexpected size %u.\n", size);
2073 size = 2 * sizeof(ptr);
2074 hr = ID3D11Device_GetPrivateData(device, &test_guid, &size, NULL);
2075 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2076 ok(size == sizeof(device), "Got unexpected size %u.\n", size);
2077 refcount = get_refcount((IUnknown *)test_object);
2078 ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
2080 size = 1;
2081 hr = ID3D11Device_GetPrivateData(device, &test_guid, &size, &ptr);
2082 ok(hr == DXGI_ERROR_MORE_DATA, "Got unexpected hr %#x.\n", hr);
2083 ok(size == sizeof(device), "Got unexpected size %u.\n", size);
2084 ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
2085 hr = ID3D11Device_GetPrivateData(device, &test_guid2, NULL, NULL);
2086 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
2087 size = 0xdeadbabe;
2088 hr = ID3D11Device_GetPrivateData(device, &test_guid2, &size, &ptr);
2089 ok(hr == DXGI_ERROR_NOT_FOUND, "Got unexpected hr %#x.\n", hr);
2090 ok(size == 0, "Got unexpected size %u.\n", size);
2091 ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
2092 hr = ID3D11Device_GetPrivateData(device, &test_guid, NULL, &ptr);
2093 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
2094 ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
2096 hr = ID3D11Texture2D_SetPrivateDataInterface(texture, &test_guid, (IUnknown *)test_object);
2097 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2098 ptr = NULL;
2099 size = sizeof(ptr);
2100 hr = IDXGISurface_GetPrivateData(surface, &test_guid, &size, &ptr);
2101 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2102 ok(ptr == (IUnknown *)test_object, "Got unexpected ptr %p, expected %p.\n", ptr, test_object);
2103 IUnknown_Release(ptr);
2105 hr = ID3D11Texture2D_QueryInterface(texture, &IID_ID3D10Texture2D, (void **)&d3d10_texture);
2106 ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */,
2107 "Texture should implement ID3D10Texture2D.\n");
2108 if (SUCCEEDED(hr))
2110 ptr = NULL;
2111 size = sizeof(ptr);
2112 hr = ID3D10Texture2D_GetPrivateData(d3d10_texture, &test_guid, &size, &ptr);
2113 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2114 ok(ptr == (IUnknown *)test_object, "Got unexpected ptr %p, expected %p.\n", ptr, test_object);
2115 IUnknown_Release(ptr);
2116 ID3D10Texture2D_Release(d3d10_texture);
2119 IDXGISurface_Release(surface);
2120 ID3D11Texture2D_Release(texture);
2121 refcount = ID3D11Device_Release(device);
2122 ok(!refcount, "Device has %u references left.\n", refcount);
2123 refcount = ID3D11Device_Release(test_object);
2124 ok(!refcount, "Test object has %u references left.\n", refcount);
2127 START_TEST(d3d11)
2129 test_create_device();
2130 test_device_interfaces();
2131 test_create_texture2d();
2132 test_texture2d_interfaces();
2133 test_create_texture3d();
2134 test_texture3d_interfaces();
2135 test_buffer_interfaces();
2136 test_create_depthstencil_view();
2137 test_depthstencil_view_interfaces();
2138 test_create_rendertarget_view();
2139 test_create_shader_resource_view();
2140 test_create_shader();
2141 test_create_blend_state();
2142 test_create_depthstencil_state();
2143 test_create_rasterizer_state();
2144 test_device_removed_reason();
2145 test_private_data();