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
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
,
51 static void set_box(D3D11_BOX
*box
, UINT left
, UINT top
, UINT front
, UINT right
, UINT bottom
, UINT back
)
61 static ULONG
get_refcount(IUnknown
*iface
)
63 IUnknown_AddRef(iface
);
64 return IUnknown_Release(iface
);
67 static BOOL
compare_color(DWORD c1
, DWORD c2
, BYTE max_diff
)
69 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
)
72 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
)
75 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
)
78 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
)
83 struct texture_readback
85 ID3D11Resource
*texture
;
86 D3D11_MAPPED_SUBRESOURCE map_desc
;
87 ID3D11DeviceContext
*immediate_context
;
88 unsigned int width
, height
;
91 static void get_texture_readback(ID3D11Texture2D
*texture
, struct texture_readback
*rb
)
93 D3D11_TEXTURE2D_DESC texture_desc
;
97 memset(rb
, 0, sizeof(*rb
));
99 ID3D11Texture2D_GetDevice(texture
, &device
);
101 ID3D11Texture2D_GetDesc(texture
, &texture_desc
);
102 texture_desc
.Usage
= D3D11_USAGE_STAGING
;
103 texture_desc
.BindFlags
= 0;
104 texture_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
;
105 texture_desc
.MiscFlags
= 0;
106 if (FAILED(hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, (ID3D11Texture2D
**)&rb
->texture
)))
108 trace("Failed to create texture, hr %#x.\n", hr
);
109 ID3D11Device_Release(device
);
113 rb
->width
= texture_desc
.Width
;
114 rb
->height
= texture_desc
.Height
;
116 ID3D11Device_GetImmediateContext(device
, &rb
->immediate_context
);
118 ID3D11DeviceContext_CopyResource(rb
->immediate_context
, rb
->texture
, (ID3D11Resource
*)texture
);
119 if (FAILED(hr
= ID3D11DeviceContext_Map(rb
->immediate_context
, rb
->texture
, 0, D3D11_MAP_READ
, 0, &rb
->map_desc
)))
121 trace("Failed to map texture, hr %#x.\n", hr
);
122 ID3D11Resource_Release(rb
->texture
);
124 ID3D11DeviceContext_Release(rb
->immediate_context
);
125 rb
->immediate_context
= NULL
;
128 ID3D11Device_Release(device
);
131 static DWORD
get_readback_color(struct texture_readback
*rb
, unsigned int x
, unsigned int y
)
134 ? ((DWORD
*)rb
->map_desc
.pData
)[rb
->map_desc
.RowPitch
* y
/ sizeof(DWORD
) + x
] : 0xdeadbeef;
137 static void release_texture_readback(struct texture_readback
*rb
)
142 ID3D11DeviceContext_Unmap(rb
->immediate_context
, rb
->texture
, 0);
143 ID3D11Resource_Release(rb
->texture
);
144 ID3D11DeviceContext_Release(rb
->immediate_context
);
147 static DWORD
get_texture_color(ID3D11Texture2D
*texture
, unsigned int x
, unsigned int y
)
149 struct texture_readback rb
;
152 get_texture_readback(texture
, &rb
);
153 color
= get_readback_color(&rb
, x
, y
);
154 release_texture_readback(&rb
);
159 #define check_texture_color(t, c, d) check_texture_color_(__LINE__, t, c, d)
160 static void check_texture_color_(unsigned int line
, ID3D11Texture2D
*texture
,
161 DWORD expected_color
, BYTE max_diff
)
163 struct texture_readback rb
;
164 unsigned int x
= 0, y
= 0;
165 BOOL all_match
= TRUE
;
168 get_texture_readback(texture
, &rb
);
169 for (y
= 0; y
< rb
.height
; ++y
)
171 for (x
= 0; x
< rb
.width
; ++x
)
173 color
= get_readback_color(&rb
, x
, y
);
174 if (!compare_color(color
, expected_color
, max_diff
))
183 release_texture_readback(&rb
);
184 ok_(__FILE__
, line
)(all_match
,
185 "Got unexpected color 0x%08x at (%u, %u).\n", color
, x
, y
);
188 static ID3D11Device
*create_device(const D3D_FEATURE_LEVEL
*feature_level
)
190 static const D3D_FEATURE_LEVEL default_feature_level
[] =
192 D3D_FEATURE_LEVEL_11_0
,
193 D3D_FEATURE_LEVEL_10_0
,
195 unsigned int feature_level_count
;
196 ID3D11Device
*device
;
200 feature_level_count
= 1;
204 feature_level
= default_feature_level
;
205 feature_level_count
= sizeof(default_feature_level
) / sizeof(default_feature_level
[0]);
208 if (SUCCEEDED(D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, feature_level
, feature_level_count
,
209 D3D11_SDK_VERSION
, &device
, NULL
, NULL
)))
211 if (SUCCEEDED(D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_WARP
, NULL
, 0, feature_level
, feature_level_count
,
212 D3D11_SDK_VERSION
, &device
, NULL
, NULL
)))
214 if (SUCCEEDED(D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_REFERENCE
, NULL
, 0, feature_level
, feature_level_count
,
215 D3D11_SDK_VERSION
, &device
, NULL
, NULL
)))
221 static IDXGISwapChain
*create_swapchain(ID3D11Device
*device
, HWND window
, BOOL windowed
)
223 IDXGISwapChain
*swapchain
;
224 DXGI_SWAP_CHAIN_DESC desc
;
225 IDXGIDevice
*dxgi_device
;
226 IDXGIAdapter
*adapter
;
227 IDXGIFactory
*factory
;
230 hr
= ID3D11Device_QueryInterface(device
, &IID_IDXGIDevice
, (void **)&dxgi_device
);
231 ok(SUCCEEDED(hr
), "Failed to get DXGI device, hr %#x.\n", hr
);
232 hr
= IDXGIDevice_GetAdapter(dxgi_device
, &adapter
);
233 ok(SUCCEEDED(hr
), "Failed to get adapter, hr %#x.\n", hr
);
234 IDXGIDevice_Release(dxgi_device
);
235 hr
= IDXGIAdapter_GetParent(adapter
, &IID_IDXGIFactory
, (void **)&factory
);
236 ok(SUCCEEDED(hr
), "Failed to get factory, hr %#x.\n", hr
);
237 IDXGIAdapter_Release(adapter
);
239 desc
.BufferDesc
.Width
= 640;
240 desc
.BufferDesc
.Height
= 480;
241 desc
.BufferDesc
.RefreshRate
.Numerator
= 60;
242 desc
.BufferDesc
.RefreshRate
.Denominator
= 1;
243 desc
.BufferDesc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
244 desc
.BufferDesc
.ScanlineOrdering
= DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED
;
245 desc
.BufferDesc
.Scaling
= DXGI_MODE_SCALING_UNSPECIFIED
;
246 desc
.SampleDesc
.Count
= 1;
247 desc
.SampleDesc
.Quality
= 0;
248 desc
.BufferUsage
= DXGI_USAGE_RENDER_TARGET_OUTPUT
;
249 desc
.BufferCount
= 1;
250 desc
.OutputWindow
= window
;
251 desc
.Windowed
= windowed
;
252 desc
.SwapEffect
= DXGI_SWAP_EFFECT_DISCARD
;
255 hr
= IDXGIFactory_CreateSwapChain(factory
, (IUnknown
*)device
, &desc
, &swapchain
);
256 ok(SUCCEEDED(hr
), "Failed to create swapchain, hr %#x.\n", hr
);
257 IDXGIFactory_Release(factory
);
262 struct d3d11_test_context
264 ID3D11Device
*device
;
266 IDXGISwapChain
*swapchain
;
267 ID3D11Texture2D
*backbuffer
;
268 ID3D11RenderTargetView
*backbuffer_rtv
;
269 ID3D11DeviceContext
*immediate_context
;
271 ID3D11InputLayout
*input_layout
;
272 ID3D11VertexShader
*vs
;
276 #define init_test_context(c) init_test_context_(__LINE__, c)
277 static BOOL
init_test_context_(unsigned int line
, struct d3d11_test_context
*context
)
282 memset(context
, 0, sizeof(*context
));
284 if (!(context
->device
= create_device(NULL
)))
286 skip_(__FILE__
, line
)("Failed to create device.\n");
289 context
->window
= CreateWindowA("static", "d3d11_test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
290 0, 0, 640, 480, NULL
, NULL
, NULL
, NULL
);
291 context
->swapchain
= create_swapchain(context
->device
, context
->window
, TRUE
);
292 hr
= IDXGISwapChain_GetBuffer(context
->swapchain
, 0, &IID_ID3D11Texture2D
, (void **)&context
->backbuffer
);
293 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to get backbuffer, hr %#x.\n", hr
);
295 hr
= ID3D11Device_CreateRenderTargetView(context
->device
, (ID3D11Resource
*)context
->backbuffer
,
296 NULL
, &context
->backbuffer_rtv
);
297 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
299 ID3D11Device_GetImmediateContext(context
->device
, &context
->immediate_context
);
301 ID3D11DeviceContext_OMSetRenderTargets(context
->immediate_context
, 1, &context
->backbuffer_rtv
, NULL
);
309 ID3D11DeviceContext_RSSetViewports(context
->immediate_context
, 1, &vp
);
314 #define release_test_context(c) release_test_context_(__LINE__, c)
315 static void release_test_context_(unsigned int line
, struct d3d11_test_context
*context
)
319 if (context
->input_layout
)
320 ID3D11InputLayout_Release(context
->input_layout
);
322 ID3D11VertexShader_Release(context
->vs
);
324 ID3D11Buffer_Release(context
->vb
);
326 ID3D11DeviceContext_Release(context
->immediate_context
);
327 ID3D11RenderTargetView_Release(context
->backbuffer_rtv
);
328 ID3D11Texture2D_Release(context
->backbuffer
);
329 IDXGISwapChain_Release(context
->swapchain
);
330 DestroyWindow(context
->window
);
332 ref
= ID3D11Device_Release(context
->device
);
333 ok_(__FILE__
, line
)(!ref
, "Device has %u references left.\n", ref
);
336 #define draw_quad(c) draw_quad_(__LINE__, c)
337 static void draw_quad_(unsigned int line
, struct d3d11_test_context
*context
)
339 static const D3D11_INPUT_ELEMENT_DESC default_layout_desc
[] =
341 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
343 static const DWORD default_vs_code
[] =
346 float4
main(float4 position
: POSITION
) : SV_POSITION
351 0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003,
352 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
353 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
354 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
355 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
356 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
357 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
361 struct vec2 position
;
371 ID3D11Device
*device
= context
->device
;
372 D3D11_SUBRESOURCE_DATA resource_data
;
373 D3D11_BUFFER_DESC buffer_desc
;
374 unsigned int stride
, offset
;
377 if (!context
->input_layout
)
379 hr
= ID3D11Device_CreateInputLayout(device
, default_layout_desc
,
380 sizeof(default_layout_desc
) / sizeof(*default_layout_desc
),
381 default_vs_code
, sizeof(default_vs_code
), &context
->input_layout
);
382 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
384 buffer_desc
.ByteWidth
= sizeof(quad
);
385 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
386 buffer_desc
.BindFlags
= D3D11_BIND_VERTEX_BUFFER
;
387 buffer_desc
.CPUAccessFlags
= 0;
388 buffer_desc
.MiscFlags
= 0;
389 buffer_desc
.StructureByteStride
= 0;
391 resource_data
.pSysMem
= quad
;
392 resource_data
.SysMemPitch
= 0;
393 resource_data
.SysMemSlicePitch
= 0;
395 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &resource_data
, &context
->vb
);
396 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to create vertex buffer, hr %#x.\n", hr
);
398 hr
= ID3D11Device_CreateVertexShader(device
, default_vs_code
, sizeof(default_vs_code
), NULL
, &context
->vs
);
399 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
402 ID3D11DeviceContext_IASetInputLayout(context
->immediate_context
, context
->input_layout
);
403 ID3D11DeviceContext_IASetPrimitiveTopology(context
->immediate_context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
404 stride
= sizeof(*quad
);
406 ID3D11DeviceContext_IASetVertexBuffers(context
->immediate_context
, 0, 1, &context
->vb
, &stride
, &offset
);
407 ID3D11DeviceContext_VSSetShader(context
->immediate_context
, context
->vs
, NULL
, 0);
409 ID3D11DeviceContext_Draw(context
->immediate_context
, 4, 0);
412 static void test_create_device(void)
414 static const D3D_FEATURE_LEVEL default_feature_levels
[] =
416 D3D_FEATURE_LEVEL_11_0
,
417 D3D_FEATURE_LEVEL_10_1
,
418 D3D_FEATURE_LEVEL_10_0
,
419 D3D_FEATURE_LEVEL_9_3
,
420 D3D_FEATURE_LEVEL_9_2
,
421 D3D_FEATURE_LEVEL_9_1
,
423 D3D_FEATURE_LEVEL feature_level
, supported_feature_level
;
424 DXGI_SWAP_CHAIN_DESC swapchain_desc
, obtained_desc
;
425 ID3D11DeviceContext
*immediate_context
;
426 IDXGISwapChain
*swapchain
;
427 ID3D11Device
*device
;
432 hr
= D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
, &device
,
436 skip("Failed to create HAL device.\n");
440 supported_feature_level
= ID3D11Device_GetFeatureLevel(device
);
441 ID3D11Device_Release(device
);
443 hr
= D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
, NULL
, NULL
, NULL
);
444 ok(SUCCEEDED(hr
), "D3D11CreateDevice failed %#x.\n", hr
);
446 hr
= D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
, NULL
,
447 &feature_level
, NULL
);
448 ok(SUCCEEDED(hr
), "D3D11CreateDevice failed %#x.\n", hr
);
449 ok(feature_level
== supported_feature_level
, "Got feature level %#x, expected %#x.\n",
450 feature_level
, supported_feature_level
);
452 hr
= D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, default_feature_levels
,
453 sizeof(default_feature_levels
) / sizeof(default_feature_levels
[0]), D3D11_SDK_VERSION
, NULL
,
454 &feature_level
, NULL
);
455 ok(SUCCEEDED(hr
), "D3D11CreateDevice failed %#x.\n", hr
);
456 ok(feature_level
== supported_feature_level
, "Got feature level %#x, expected %#x.\n",
457 feature_level
, supported_feature_level
);
459 hr
= D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
, NULL
, NULL
,
461 ok(SUCCEEDED(hr
), "D3D11CreateDevice failed %#x.\n", hr
);
463 ok(!!immediate_context
, "Expected immediate device context pointer, got NULL.\n");
464 refcount
= get_refcount((IUnknown
*)immediate_context
);
465 ok(refcount
== 1, "Got refcount %u, expected 1.\n", refcount
);
467 ID3D11DeviceContext_GetDevice(immediate_context
, &device
);
468 refcount
= ID3D11Device_Release(device
);
469 ok(refcount
== 1, "Got refcount %u, expected 1.\n", refcount
);
471 refcount
= ID3D11DeviceContext_Release(immediate_context
);
472 ok(!refcount
, "ID3D11DeviceContext has %u references left.\n", refcount
);
474 device
= (ID3D11Device
*)0xdeadbeef;
475 feature_level
= 0xdeadbeef;
476 immediate_context
= (ID3D11DeviceContext
*)0xdeadbeef;
477 hr
= D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_UNKNOWN
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
478 &device
, &feature_level
, &immediate_context
);
479 todo_wine
ok(hr
== E_INVALIDARG
, "D3D11CreateDevice returned %#x.\n", hr
);
480 ok(!device
, "Got unexpected device pointer %p.\n", device
);
481 ok(!feature_level
, "Got unexpected feature level %#x.\n", feature_level
);
482 ok(!immediate_context
, "Got unexpected immediate context pointer %p.\n", immediate_context
);
484 window
= CreateWindowA("static", "d3d11_test", 0, 0, 0, 0, 0, 0, 0, 0, 0);
486 swapchain_desc
.BufferDesc
.Width
= 800;
487 swapchain_desc
.BufferDesc
.Height
= 600;
488 swapchain_desc
.BufferDesc
.RefreshRate
.Numerator
= 60;
489 swapchain_desc
.BufferDesc
.RefreshRate
.Denominator
= 60;
490 swapchain_desc
.BufferDesc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
491 swapchain_desc
.BufferDesc
.ScanlineOrdering
= DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED
;
492 swapchain_desc
.BufferDesc
.Scaling
= DXGI_MODE_SCALING_UNSPECIFIED
;
493 swapchain_desc
.SampleDesc
.Count
= 1;
494 swapchain_desc
.SampleDesc
.Quality
= 0;
495 swapchain_desc
.BufferUsage
= DXGI_USAGE_RENDER_TARGET_OUTPUT
;
496 swapchain_desc
.BufferCount
= 1;
497 swapchain_desc
.OutputWindow
= window
;
498 swapchain_desc
.Windowed
= TRUE
;
499 swapchain_desc
.SwapEffect
= DXGI_SWAP_EFFECT_DISCARD
;
500 swapchain_desc
.Flags
= 0;
502 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
503 &swapchain_desc
, NULL
, NULL
, NULL
, NULL
);
504 ok(SUCCEEDED(hr
), "D3D11CreateDeviceAndSwapChain failed %#x.\n", hr
);
506 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
507 &swapchain_desc
, NULL
, NULL
, &feature_level
, NULL
);
508 ok(SUCCEEDED(hr
), "D3D11CreateDeviceAndSwapChain failed %#x.\n", hr
);
509 ok(feature_level
== supported_feature_level
, "Got feature level %#x, expected %#x.\n",
510 feature_level
, supported_feature_level
);
512 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
513 &swapchain_desc
, &swapchain
, &device
, NULL
, NULL
);
514 ok(SUCCEEDED(hr
), "D3D11CreateDeviceAndSwapChain failed %#x.\n", hr
);
516 memset(&obtained_desc
, 0, sizeof(obtained_desc
));
517 hr
= IDXGISwapChain_GetDesc(swapchain
, &obtained_desc
);
518 ok(SUCCEEDED(hr
), "GetDesc failed %#x.\n", hr
);
519 ok(obtained_desc
.BufferDesc
.Width
== swapchain_desc
.BufferDesc
.Width
,
520 "Got unexpected BufferDesc.Width %u.\n", obtained_desc
.BufferDesc
.Width
);
521 ok(obtained_desc
.BufferDesc
.Height
== swapchain_desc
.BufferDesc
.Height
,
522 "Got unexpected BufferDesc.Height %u.\n", obtained_desc
.BufferDesc
.Height
);
523 todo_wine
ok(obtained_desc
.BufferDesc
.RefreshRate
.Numerator
== swapchain_desc
.BufferDesc
.RefreshRate
.Numerator
,
524 "Got unexpected BufferDesc.RefreshRate.Numerator %u.\n",
525 obtained_desc
.BufferDesc
.RefreshRate
.Numerator
);
526 todo_wine
ok(obtained_desc
.BufferDesc
.RefreshRate
.Denominator
== swapchain_desc
.BufferDesc
.RefreshRate
.Denominator
,
527 "Got unexpected BufferDesc.RefreshRate.Denominator %u.\n",
528 obtained_desc
.BufferDesc
.RefreshRate
.Denominator
);
529 ok(obtained_desc
.BufferDesc
.Format
== swapchain_desc
.BufferDesc
.Format
,
530 "Got unexpected BufferDesc.Format %#x.\n", obtained_desc
.BufferDesc
.Format
);
531 ok(obtained_desc
.BufferDesc
.ScanlineOrdering
== swapchain_desc
.BufferDesc
.ScanlineOrdering
,
532 "Got unexpected BufferDesc.ScanlineOrdering %#x.\n", obtained_desc
.BufferDesc
.ScanlineOrdering
);
533 ok(obtained_desc
.BufferDesc
.Scaling
== swapchain_desc
.BufferDesc
.Scaling
,
534 "Got unexpected BufferDesc.Scaling %#x.\n", obtained_desc
.BufferDesc
.Scaling
);
535 ok(obtained_desc
.SampleDesc
.Count
== swapchain_desc
.SampleDesc
.Count
,
536 "Got unexpected SampleDesc.Count %u.\n", obtained_desc
.SampleDesc
.Count
);
537 ok(obtained_desc
.SampleDesc
.Quality
== swapchain_desc
.SampleDesc
.Quality
,
538 "Got unexpected SampleDesc.Quality %u.\n", obtained_desc
.SampleDesc
.Quality
);
539 todo_wine
ok(obtained_desc
.BufferUsage
== swapchain_desc
.BufferUsage
,
540 "Got unexpected BufferUsage %#x.\n", obtained_desc
.BufferUsage
);
541 ok(obtained_desc
.BufferCount
== swapchain_desc
.BufferCount
,
542 "Got unexpected BufferCount %u.\n", obtained_desc
.BufferCount
);
543 ok(obtained_desc
.OutputWindow
== swapchain_desc
.OutputWindow
,
544 "Got unexpected OutputWindow %p.\n", obtained_desc
.OutputWindow
);
545 ok(obtained_desc
.Windowed
== swapchain_desc
.Windowed
,
546 "Got unexpected Windowed %#x.\n", obtained_desc
.Windowed
);
547 ok(obtained_desc
.SwapEffect
== swapchain_desc
.SwapEffect
,
548 "Got unexpected SwapEffect %#x.\n", obtained_desc
.SwapEffect
);
549 ok(obtained_desc
.Flags
== swapchain_desc
.Flags
,
550 "Got unexpected Flags %#x.\n", obtained_desc
.Flags
);
552 refcount
= IDXGISwapChain_Release(swapchain
);
553 ok(!refcount
, "Swapchain has %u references left.\n", refcount
);
555 feature_level
= ID3D11Device_GetFeatureLevel(device
);
556 ok(feature_level
== supported_feature_level
, "Got feature level %#x, expected %#x.\n",
557 feature_level
, supported_feature_level
);
559 refcount
= ID3D11Device_Release(device
);
560 ok(!refcount
, "Device has %u references left.\n", refcount
);
562 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
563 NULL
, NULL
, &device
, NULL
, NULL
);
564 ok(SUCCEEDED(hr
), "D3D11CreateDeviceAndSwapChain failed %#x.\n", hr
);
565 ID3D11Device_Release(device
);
567 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
568 NULL
, NULL
, NULL
, NULL
, NULL
);
569 ok(SUCCEEDED(hr
), "D3D11CreateDeviceAndSwapChain failed %#x.\n", hr
);
571 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
572 NULL
, NULL
, NULL
, &feature_level
, NULL
);
573 ok(SUCCEEDED(hr
), "D3D11CreateDeviceAndSwapChain failed %#x.\n", hr
);
574 ok(feature_level
== supported_feature_level
, "Got feature level %#x, expected %#x.\n",
575 feature_level
, supported_feature_level
);
577 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
578 &swapchain_desc
, NULL
, NULL
, NULL
, NULL
);
579 ok(SUCCEEDED(hr
), "D3D11CreateDeviceAndSwapChain failed %#x.\n", hr
);
581 swapchain_desc
.OutputWindow
= NULL
;
582 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
583 &swapchain_desc
, NULL
, &device
, NULL
, NULL
);
584 ok(SUCCEEDED(hr
), "D3D11CreateDeviceAndSwapChain failed %#x.\n", hr
);
585 ID3D11Device_Release(device
);
587 swapchain
= (IDXGISwapChain
*)0xdeadbeef;
588 device
= (ID3D11Device
*)0xdeadbeef;
589 feature_level
= 0xdeadbeef;
590 immediate_context
= (ID3D11DeviceContext
*)0xdeadbeef;
591 swapchain_desc
.OutputWindow
= NULL
;
592 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
593 &swapchain_desc
, &swapchain
, &device
, &feature_level
, &immediate_context
);
594 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "D3D11CreateDeviceAndSwapChain returned %#x.\n", hr
);
595 ok(!swapchain
, "Got unexpected swapchain pointer %p.\n", swapchain
);
596 ok(!device
, "Got unexpected device pointer %p.\n", device
);
597 ok(!feature_level
, "Got unexpected feature level %#x.\n", feature_level
);
598 ok(!immediate_context
, "Got unexpected immediate context pointer %p.\n", immediate_context
);
600 swapchain
= (IDXGISwapChain
*)0xdeadbeef;
601 device
= (ID3D11Device
*)0xdeadbeef;
602 feature_level
= 0xdeadbeef;
603 immediate_context
= (ID3D11DeviceContext
*)0xdeadbeef;
604 swapchain_desc
.OutputWindow
= window
;
605 swapchain_desc
.BufferDesc
.Format
= DXGI_FORMAT_BC5_UNORM
;
606 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
607 &swapchain_desc
, &swapchain
, &device
, &feature_level
, &immediate_context
);
608 todo_wine
ok(hr
== E_INVALIDARG
, "D3D11CreateDeviceAndSwapChain returned %#x.\n", hr
);
609 ok(!swapchain
, "Got unexpected swapchain pointer %p.\n", swapchain
);
610 ok(!device
, "Got unexpected device pointer %p.\n", device
);
611 ok(!feature_level
, "Got unexpected feature level %#x.\n", feature_level
);
612 ok(!immediate_context
, "Got unexpected immediate context pointer %p.\n", immediate_context
);
614 DestroyWindow(window
);
617 static void test_device_interfaces(void)
619 IDXGIAdapter
*dxgi_adapter
;
620 IDXGIDevice
*dxgi_device
;
621 ID3D11Device
*device
;
627 for (i
= 0; i
< sizeof(d3d11_feature_levels
) / sizeof(*d3d11_feature_levels
); ++i
)
629 if (!(device
= create_device(&d3d11_feature_levels
[i
])))
631 skip("Failed to create device for feature level %#x.\n", d3d11_feature_levels
[i
]);
635 hr
= ID3D11Device_QueryInterface(device
, &IID_IUnknown
, (void **)&iface
);
636 ok(SUCCEEDED(hr
), "Device should implement IUnknown interface, hr %#x.\n", hr
);
637 IUnknown_Release(iface
);
639 hr
= ID3D11Device_QueryInterface(device
, &IID_IDXGIObject
, (void **)&iface
);
640 ok(SUCCEEDED(hr
), "Device should implement IDXGIObject interface, hr %#x.\n", hr
);
641 IUnknown_Release(iface
);
643 hr
= ID3D11Device_QueryInterface(device
, &IID_IDXGIDevice
, (void **)&dxgi_device
);
644 ok(SUCCEEDED(hr
), "Device should implement IDXGIDevice.\n");
645 hr
= IDXGIDevice_GetParent(dxgi_device
, &IID_IDXGIAdapter
, (void **)&dxgi_adapter
);
646 ok(SUCCEEDED(hr
), "Device parent should implement IDXGIAdapter.\n");
647 hr
= IDXGIAdapter_GetParent(dxgi_adapter
, &IID_IDXGIFactory
, (void **)&iface
);
648 ok(SUCCEEDED(hr
), "Adapter parent should implement IDXGIFactory.\n");
649 IUnknown_Release(iface
);
650 IDXGIAdapter_Release(dxgi_adapter
);
651 hr
= IDXGIDevice_GetParent(dxgi_device
, &IID_IDXGIAdapter1
, (void **)&dxgi_adapter
);
652 ok(SUCCEEDED(hr
), "Device parent should implement IDXGIAdapter1.\n");
653 hr
= IDXGIAdapter_GetParent(dxgi_adapter
, &IID_IDXGIFactory1
, (void **)&iface
);
654 ok(SUCCEEDED(hr
), "Adapter parent should implement IDXGIFactory1.\n");
655 IUnknown_Release(iface
);
656 IDXGIAdapter_Release(dxgi_adapter
);
657 IDXGIDevice_Release(dxgi_device
);
659 hr
= ID3D11Device_QueryInterface(device
, &IID_IDXGIDevice1
, (void **)&iface
);
660 ok(SUCCEEDED(hr
), "Device should implement IDXGIDevice1.\n");
661 IUnknown_Release(iface
);
663 hr
= ID3D11Device_QueryInterface(device
, &IID_ID3D10Multithread
, (void **)&iface
);
664 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
665 "Device should implement ID3D10Multithread interface, hr %#x.\n", hr
);
666 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
668 hr
= ID3D11Device_QueryInterface(device
, &IID_ID3D10Device
, (void **)&iface
);
669 todo_wine
ok(hr
== E_NOINTERFACE
, "Device should not implement ID3D10Device interface, hr %#x.\n", hr
);
670 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
672 hr
= ID3D11Device_QueryInterface(device
, &IID_ID3D10Device1
, (void **)&iface
);
673 todo_wine
ok(hr
== E_NOINTERFACE
, "Device should not implement ID3D10Device1 interface, hr %#x.\n", hr
);
674 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
676 refcount
= ID3D11Device_Release(device
);
677 ok(!refcount
, "Device has %u references left.\n", refcount
);
681 static void test_get_immediate_context(void)
683 ID3D11DeviceContext
*immediate_context
, *previous_immediate_context
;
684 ULONG expected_refcount
, refcount
;
685 ID3D11Device
*device
;
687 if (!(device
= create_device(NULL
)))
689 skip("Failed to create device.\n");
693 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
694 ID3D11Device_GetImmediateContext(device
, &immediate_context
);
695 refcount
= get_refcount((IUnknown
*)device
);
696 ok(refcount
== expected_refcount
, "Got unexpected refcount %u.\n", refcount
);
697 previous_immediate_context
= immediate_context
;
699 ID3D11Device_GetImmediateContext(device
, &immediate_context
);
700 ok(immediate_context
== previous_immediate_context
, "Got different immediate device context objects.\n");
701 refcount
= get_refcount((IUnknown
*)device
);
702 ok(refcount
== expected_refcount
, "Got unexpected refcount %u.\n", refcount
);
704 refcount
= ID3D11DeviceContext_Release(previous_immediate_context
);
705 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
706 refcount
= ID3D11DeviceContext_Release(immediate_context
);
707 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
709 ID3D11Device_GetImmediateContext(device
, &immediate_context
);
710 ok(immediate_context
== previous_immediate_context
, "Got different immediate device context objects.\n");
711 refcount
= ID3D11DeviceContext_Release(immediate_context
);
712 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
714 refcount
= ID3D11Device_Release(device
);
715 ok(!refcount
, "Device has %u references left.\n", refcount
);
718 static void test_create_texture2d(void)
720 ULONG refcount
, expected_refcount
;
721 D3D11_SUBRESOURCE_DATA data
= {0};
722 ID3D11Device
*device
, *tmp
;
723 D3D11_TEXTURE2D_DESC desc
;
724 ID3D11Texture2D
*texture
;
725 UINT quality_level_count
;
726 IDXGISurface
*surface
;
729 if (!(device
= create_device(NULL
)))
731 skip("Failed to create device, skipping tests.\n");
739 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
740 desc
.SampleDesc
.Count
= 1;
741 desc
.SampleDesc
.Quality
= 0;
742 desc
.Usage
= D3D11_USAGE_DEFAULT
;
743 desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
744 desc
.CPUAccessFlags
= 0;
747 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, &data
, &texture
);
748 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
750 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
751 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
752 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
753 refcount
= get_refcount((IUnknown
*)device
);
754 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
756 expected_refcount
= refcount
+ 1;
757 ID3D11Texture2D_GetDevice(texture
, &tmp
);
758 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
759 refcount
= get_refcount((IUnknown
*)device
);
760 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
761 ID3D11Device_Release(tmp
);
763 hr
= ID3D11Texture2D_QueryInterface(texture
, &IID_IDXGISurface
, (void **)&surface
);
764 ok(SUCCEEDED(hr
), "Texture should implement IDXGISurface.\n");
765 IDXGISurface_Release(surface
);
766 ID3D11Texture2D_Release(texture
);
769 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
770 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
771 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
772 refcount
= get_refcount((IUnknown
*)device
);
773 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
775 expected_refcount
= refcount
+ 1;
776 ID3D11Texture2D_GetDevice(texture
, &tmp
);
777 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
778 refcount
= get_refcount((IUnknown
*)device
);
779 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
780 ID3D11Device_Release(tmp
);
782 ID3D11Texture2D_GetDesc(texture
, &desc
);
783 ok(desc
.Width
== 512, "Got unexpected Width %u.\n", desc
.Width
);
784 ok(desc
.Height
== 512, "Got unexpected Height %u.\n", desc
.Height
);
785 ok(desc
.MipLevels
== 10, "Got unexpected MipLevels %u.\n", desc
.MipLevels
);
786 ok(desc
.ArraySize
== 1, "Got unexpected ArraySize %u.\n", desc
.ArraySize
);
787 ok(desc
.Format
== DXGI_FORMAT_R8G8B8A8_UNORM
, "Got unexpected Format %#x.\n", desc
.Format
);
788 ok(desc
.SampleDesc
.Count
== 1, "Got unexpected SampleDesc.Count %u.\n", desc
.SampleDesc
.Count
);
789 ok(desc
.SampleDesc
.Quality
== 0, "Got unexpected SampleDesc.Quality %u.\n", desc
.SampleDesc
.Quality
);
790 ok(desc
.Usage
== D3D11_USAGE_DEFAULT
, "Got unexpected Usage %u.\n", desc
.Usage
);
791 ok(desc
.BindFlags
== D3D11_BIND_RENDER_TARGET
, "Got unexpected BindFlags %#x.\n", desc
.BindFlags
);
792 ok(desc
.CPUAccessFlags
== 0, "Got unexpected CPUAccessFlags %#x.\n", desc
.CPUAccessFlags
);
793 ok(desc
.MiscFlags
== 0, "Got unexpected MiscFlags %#x.\n", desc
.MiscFlags
);
795 hr
= ID3D11Texture2D_QueryInterface(texture
, &IID_IDXGISurface
, (void **)&surface
);
796 ok(FAILED(hr
), "Texture should not implement IDXGISurface.\n");
797 ID3D11Texture2D_Release(texture
);
801 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
802 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
804 hr
= ID3D11Texture2D_QueryInterface(texture
, &IID_IDXGISurface
, (void **)&surface
);
805 ok(FAILED(hr
), "Texture should not implement IDXGISurface.\n");
806 ID3D11Texture2D_Release(texture
);
808 ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 2, &quality_level_count
);
810 desc
.SampleDesc
.Count
= 2;
811 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
812 if (quality_level_count
)
814 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
815 ID3D11Texture2D_Release(texture
);
816 desc
.SampleDesc
.Quality
= quality_level_count
;
817 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
819 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
821 /* We assume 15 samples multisampling is never supported in practice. */
822 desc
.SampleDesc
.Count
= 15;
823 desc
.SampleDesc
.Quality
= 0;
824 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
825 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
827 refcount
= ID3D11Device_Release(device
);
828 ok(!refcount
, "Device has %u references left.\n", refcount
);
831 static void test_texture2d_interfaces(void)
833 ID3D10Texture2D
*d3d10_texture
;
834 D3D11_TEXTURE2D_DESC desc
;
835 ID3D11Texture2D
*texture
;
836 IDXGISurface
*surface
;
837 ID3D11Device
*device
;
842 static const struct test
844 BOOL implements_d3d10_interfaces
;
847 UINT expected_bind_flags
;
848 UINT expected_misc_flags
;
850 desc_conversion_tests
[] =
854 D3D11_BIND_SHADER_RESOURCE
, 0,
855 D3D10_BIND_SHADER_RESOURCE
, 0
859 D3D11_BIND_UNORDERED_ACCESS
, 0,
860 D3D11_BIND_UNORDERED_ACCESS
, 0
864 0, D3D11_RESOURCE_MISC_RESOURCE_CLAMP
,
869 0, D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX
,
870 0, D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX
874 0, D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX
| D3D11_RESOURCE_MISC_SHARED_NTHANDLE
,
875 0, D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX
879 if (!(device
= create_device(NULL
)))
881 skip("Failed to create ID3D11Device, skipping tests.\n");
889 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
890 desc
.SampleDesc
.Count
= 1;
891 desc
.SampleDesc
.Quality
= 0;
892 desc
.Usage
= D3D11_USAGE_DEFAULT
;
893 desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
894 desc
.CPUAccessFlags
= 0;
897 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
898 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
900 hr
= ID3D11Texture2D_QueryInterface(texture
, &IID_IDXGISurface
, (void **)&surface
);
901 ok(hr
== E_NOINTERFACE
, "Texture should not implement IDXGISurface.\n");
903 hr
= ID3D11Texture2D_QueryInterface(texture
, &IID_ID3D10Texture2D
, (void **)&d3d10_texture
);
904 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
905 "Texture should implement ID3D10Texture2D.\n");
906 if (SUCCEEDED(hr
)) ID3D10Texture2D_Release(d3d10_texture
);
907 ID3D11Texture2D_Release(texture
);
911 win_skip("2D textures do not implement ID3D10Texture2D, skipping tests.\n");
912 ID3D11Device_Release(device
);
916 for (i
= 0; i
< sizeof(desc_conversion_tests
) / sizeof(*desc_conversion_tests
); ++i
)
918 const struct test
*current
= &desc_conversion_tests
[i
];
919 D3D10_TEXTURE2D_DESC d3d10_desc
;
920 ID3D10Device
*d3d10_device
;
926 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
927 desc
.SampleDesc
.Count
= 1;
928 desc
.SampleDesc
.Quality
= 0;
929 desc
.Usage
= D3D11_USAGE_DEFAULT
;
930 desc
.BindFlags
= current
->bind_flags
;
931 desc
.CPUAccessFlags
= 0;
932 desc
.MiscFlags
= current
->misc_flags
;
934 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
935 /* Shared resources are not supported by REF and WARP devices. */
936 ok(SUCCEEDED(hr
) || broken(hr
== E_OUTOFMEMORY
),
937 "Test %u: Failed to create a 2d texture, hr %#x.\n", i
, hr
);
940 win_skip("Failed to create ID3D11Texture2D, skipping test %u.\n", i
);
944 hr
= ID3D11Texture2D_QueryInterface(texture
, &IID_IDXGISurface
, (void **)&surface
);
945 ok(SUCCEEDED(hr
), "Test %u: Texture should implement IDXGISurface.\n", i
);
946 IDXGISurface_Release(surface
);
948 hr
= ID3D11Texture2D_QueryInterface(texture
, &IID_ID3D10Texture2D
, (void **)&d3d10_texture
);
949 ID3D11Texture2D_Release(texture
);
951 if (current
->implements_d3d10_interfaces
)
953 ok(SUCCEEDED(hr
), "Test %u: Texture should implement ID3D10Texture2D.\n", i
);
957 todo_wine
ok(hr
== E_NOINTERFACE
, "Test %u: Texture should not implement ID3D10Texture2D.\n", i
);
958 if (SUCCEEDED(hr
)) ID3D10Texture2D_Release(d3d10_texture
);
962 ID3D10Texture2D_GetDesc(d3d10_texture
, &d3d10_desc
);
964 ok(d3d10_desc
.Width
== desc
.Width
,
965 "Test %u: Got unexpected Width %u.\n", i
, d3d10_desc
.Width
);
966 ok(d3d10_desc
.Height
== desc
.Height
,
967 "Test %u: Got unexpected Height %u.\n", i
, d3d10_desc
.Height
);
968 ok(d3d10_desc
.MipLevels
== desc
.MipLevels
,
969 "Test %u: Got unexpected MipLevels %u.\n", i
, d3d10_desc
.MipLevels
);
970 ok(d3d10_desc
.ArraySize
== desc
.ArraySize
,
971 "Test %u: Got unexpected ArraySize %u.\n", i
, d3d10_desc
.ArraySize
);
972 ok(d3d10_desc
.Format
== desc
.Format
,
973 "Test %u: Got unexpected Format %u.\n", i
, d3d10_desc
.Format
);
974 ok(d3d10_desc
.SampleDesc
.Count
== desc
.SampleDesc
.Count
,
975 "Test %u: Got unexpected SampleDesc.Count %u.\n", i
, d3d10_desc
.SampleDesc
.Count
);
976 ok(d3d10_desc
.SampleDesc
.Quality
== desc
.SampleDesc
.Quality
,
977 "Test %u: Got unexpected SampleDesc.Quality %u.\n", i
, d3d10_desc
.SampleDesc
.Quality
);
978 ok(d3d10_desc
.Usage
== (D3D10_USAGE
)desc
.Usage
,
979 "Test %u: Got unexpected Usage %u.\n", i
, d3d10_desc
.Usage
);
980 ok(d3d10_desc
.BindFlags
== current
->expected_bind_flags
,
981 "Test %u: Got unexpected BindFlags %#x.\n", i
, d3d10_desc
.BindFlags
);
982 ok(d3d10_desc
.CPUAccessFlags
== desc
.CPUAccessFlags
,
983 "Test %u: Got unexpected CPUAccessFlags %#x.\n", i
, d3d10_desc
.CPUAccessFlags
);
984 ok(d3d10_desc
.MiscFlags
== current
->expected_misc_flags
,
985 "Test %u: Got unexpected MiscFlags %#x.\n", i
, d3d10_desc
.MiscFlags
);
987 d3d10_device
= (ID3D10Device
*)0xdeadbeef;
988 ID3D10Texture2D_GetDevice(d3d10_texture
, &d3d10_device
);
989 todo_wine
ok(!d3d10_device
, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i
, d3d10_device
);
990 if (d3d10_device
) ID3D10Device_Release(d3d10_device
);
992 ID3D10Texture2D_Release(d3d10_texture
);
995 refcount
= ID3D11Device_Release(device
);
996 ok(!refcount
, "Device has %u references left.\n", refcount
);
999 static void test_create_texture3d(void)
1001 ULONG refcount
, expected_refcount
;
1002 D3D11_SUBRESOURCE_DATA data
= {0};
1003 ID3D11Device
*device
, *tmp
;
1004 D3D11_TEXTURE3D_DESC desc
;
1005 ID3D11Texture3D
*texture
;
1006 IDXGISurface
*surface
;
1009 if (!(device
= create_device(NULL
)))
1011 skip("Failed to create ID3D11Device, skipping tests.\n");
1019 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
1020 desc
.Usage
= D3D11_USAGE_DEFAULT
;
1021 desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
1022 desc
.CPUAccessFlags
= 0;
1025 hr
= ID3D11Device_CreateTexture3D(device
, &desc
, &data
, &texture
);
1026 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
1028 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
1029 hr
= ID3D11Device_CreateTexture3D(device
, &desc
, NULL
, &texture
);
1030 ok(SUCCEEDED(hr
), "Failed to create a 3d texture, hr %#x.\n", hr
);
1031 refcount
= get_refcount((IUnknown
*)device
);
1032 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
1034 expected_refcount
= refcount
+ 1;
1035 ID3D11Texture3D_GetDevice(texture
, &tmp
);
1036 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
1037 refcount
= get_refcount((IUnknown
*)device
);
1038 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
1039 ID3D11Device_Release(tmp
);
1041 hr
= ID3D11Texture3D_QueryInterface(texture
, &IID_IDXGISurface
, (void **)&surface
);
1042 ok(FAILED(hr
), "Texture should not implement IDXGISurface.\n");
1043 ID3D11Texture3D_Release(texture
);
1046 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
1047 hr
= ID3D11Device_CreateTexture3D(device
, &desc
, NULL
, &texture
);
1048 ok(SUCCEEDED(hr
), "Failed to create a 3d texture, hr %#x.\n", hr
);
1049 refcount
= get_refcount((IUnknown
*)device
);
1050 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
1052 expected_refcount
= refcount
+ 1;
1053 ID3D11Texture3D_GetDevice(texture
, &tmp
);
1054 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
1055 refcount
= get_refcount((IUnknown
*)device
);
1056 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
1057 ID3D11Device_Release(tmp
);
1059 ID3D11Texture3D_GetDesc(texture
, &desc
);
1060 ok(desc
.Width
== 64, "Got unexpected Width %u.\n", desc
.Width
);
1061 ok(desc
.Height
== 64, "Got unexpected Height %u.\n", desc
.Height
);
1062 ok(desc
.Depth
== 64, "Got unexpected Depth %u.\n", desc
.Depth
);
1063 ok(desc
.MipLevels
== 7, "Got unexpected MipLevels %u.\n", desc
.MipLevels
);
1064 ok(desc
.Format
== DXGI_FORMAT_R8G8B8A8_UNORM
, "Got unexpected Format %#x.\n", desc
.Format
);
1065 ok(desc
.Usage
== D3D11_USAGE_DEFAULT
, "Got unexpected Usage %u.\n", desc
.Usage
);
1066 ok(desc
.BindFlags
== D3D11_BIND_RENDER_TARGET
, "Got unexpected BindFlags %u.\n", desc
.BindFlags
);
1067 ok(desc
.CPUAccessFlags
== 0, "Got unexpected CPUAccessFlags %u.\n", desc
.CPUAccessFlags
);
1068 ok(desc
.MiscFlags
== 0, "Got unexpected MiscFlags %u.\n", desc
.MiscFlags
);
1070 hr
= ID3D11Texture3D_QueryInterface(texture
, &IID_IDXGISurface
, (void **)&surface
);
1071 ok(FAILED(hr
), "Texture should not implement IDXGISurface.\n");
1072 ID3D11Texture3D_Release(texture
);
1074 refcount
= ID3D11Device_Release(device
);
1075 ok(!refcount
, "Device has %u references left.\n", refcount
);
1078 static void test_texture3d_interfaces(void)
1080 ID3D10Texture3D
*d3d10_texture
;
1081 D3D11_TEXTURE3D_DESC desc
;
1082 ID3D11Texture3D
*texture
;
1083 IDXGISurface
*surface
;
1084 ID3D11Device
*device
;
1089 static const struct test
1091 BOOL implements_d3d10_interfaces
;
1094 UINT expected_bind_flags
;
1095 UINT expected_misc_flags
;
1097 desc_conversion_tests
[] =
1101 D3D11_BIND_SHADER_RESOURCE
, 0,
1102 D3D10_BIND_SHADER_RESOURCE
, 0
1106 D3D11_BIND_UNORDERED_ACCESS
, 0,
1107 D3D11_BIND_UNORDERED_ACCESS
, 0
1111 0, D3D11_RESOURCE_MISC_RESOURCE_CLAMP
,
1116 0, D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX
,
1117 0, D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX
1121 if (!(device
= create_device(NULL
)))
1123 skip("Failed to create ID3D11Device.\n");
1131 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
1132 desc
.Usage
= D3D11_USAGE_DEFAULT
;
1133 desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
1134 desc
.CPUAccessFlags
= 0;
1137 hr
= ID3D11Device_CreateTexture3D(device
, &desc
, NULL
, &texture
);
1138 ok(SUCCEEDED(hr
), "Failed to create a 3d texture, hr %#x.\n", hr
);
1140 hr
= ID3D11Texture3D_QueryInterface(texture
, &IID_IDXGISurface
, (void **)&surface
);
1141 ok(hr
== E_NOINTERFACE
, "Texture should not implement IDXGISurface.\n");
1143 hr
= ID3D11Texture3D_QueryInterface(texture
, &IID_ID3D10Texture3D
, (void **)&d3d10_texture
);
1144 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
1145 "Texture should implement ID3D10Texture3D.\n");
1146 if (SUCCEEDED(hr
)) ID3D10Texture3D_Release(d3d10_texture
);
1147 ID3D11Texture3D_Release(texture
);
1151 win_skip("3D textures do not implement ID3D10Texture3D.\n");
1152 ID3D11Device_Release(device
);
1156 for (i
= 0; i
< sizeof(desc_conversion_tests
) / sizeof(*desc_conversion_tests
); ++i
)
1158 const struct test
*current
= &desc_conversion_tests
[i
];
1159 D3D10_TEXTURE3D_DESC d3d10_desc
;
1160 ID3D10Device
*d3d10_device
;
1166 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
1167 desc
.Usage
= D3D11_USAGE_DEFAULT
;
1168 desc
.BindFlags
= current
->bind_flags
;
1169 desc
.CPUAccessFlags
= 0;
1170 desc
.MiscFlags
= current
->misc_flags
;
1172 hr
= ID3D11Device_CreateTexture3D(device
, &desc
, NULL
, &texture
);
1173 /* Shared resources are not supported by REF and WARP devices. */
1174 ok(SUCCEEDED(hr
) || broken(hr
== E_OUTOFMEMORY
),
1175 "Test %u: Failed to create a 3d texture, hr %#x.\n", i
, hr
);
1178 win_skip("Failed to create ID3D11Texture3D, skipping test %u.\n", i
);
1182 hr
= ID3D11Texture3D_QueryInterface(texture
, &IID_IDXGISurface
, (void **)&surface
);
1183 ok(hr
== E_NOINTERFACE
, "Texture should not implement IDXGISurface.\n");
1185 hr
= ID3D11Texture3D_QueryInterface(texture
, &IID_ID3D10Texture3D
, (void **)&d3d10_texture
);
1186 ID3D11Texture3D_Release(texture
);
1188 if (current
->implements_d3d10_interfaces
)
1190 ok(SUCCEEDED(hr
), "Test %u: Texture should implement ID3D10Texture3D.\n", i
);
1194 todo_wine
ok(hr
== E_NOINTERFACE
, "Test %u: Texture should not implement ID3D10Texture3D.\n", i
);
1195 if (SUCCEEDED(hr
)) ID3D10Texture3D_Release(d3d10_texture
);
1199 ID3D10Texture3D_GetDesc(d3d10_texture
, &d3d10_desc
);
1201 ok(d3d10_desc
.Width
== desc
.Width
,
1202 "Test %u: Got unexpected Width %u.\n", i
, d3d10_desc
.Width
);
1203 ok(d3d10_desc
.Height
== desc
.Height
,
1204 "Test %u: Got unexpected Height %u.\n", i
, d3d10_desc
.Height
);
1205 ok(d3d10_desc
.Depth
== desc
.Depth
,
1206 "Test %u: Got unexpected Depth %u.\n", i
, d3d10_desc
.Depth
);
1207 ok(d3d10_desc
.MipLevels
== desc
.MipLevels
,
1208 "Test %u: Got unexpected MipLevels %u.\n", i
, d3d10_desc
.MipLevels
);
1209 ok(d3d10_desc
.Format
== desc
.Format
,
1210 "Test %u: Got unexpected Format %u.\n", i
, d3d10_desc
.Format
);
1211 ok(d3d10_desc
.Usage
== (D3D10_USAGE
)desc
.Usage
,
1212 "Test %u: Got unexpected Usage %u.\n", i
, d3d10_desc
.Usage
);
1213 ok(d3d10_desc
.BindFlags
== current
->expected_bind_flags
,
1214 "Test %u: Got unexpected BindFlags %#x.\n", i
, d3d10_desc
.BindFlags
);
1215 ok(d3d10_desc
.CPUAccessFlags
== desc
.CPUAccessFlags
,
1216 "Test %u: Got unexpected CPUAccessFlags %#x.\n", i
, d3d10_desc
.CPUAccessFlags
);
1217 ok(d3d10_desc
.MiscFlags
== current
->expected_misc_flags
,
1218 "Test %u: Got unexpected MiscFlags %#x.\n", i
, d3d10_desc
.MiscFlags
);
1220 d3d10_device
= (ID3D10Device
*)0xdeadbeef;
1221 ID3D10Texture3D_GetDevice(d3d10_texture
, &d3d10_device
);
1222 todo_wine
ok(!d3d10_device
, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i
, d3d10_device
);
1223 if (d3d10_device
) ID3D10Device_Release(d3d10_device
);
1225 ID3D10Texture3D_Release(d3d10_texture
);
1228 refcount
= ID3D11Device_Release(device
);
1229 ok(!refcount
, "Device has %u references left.\n", refcount
);
1232 static void test_buffer_interfaces(void)
1234 ID3D10Buffer
*d3d10_buffer
;
1235 D3D11_BUFFER_DESC desc
;
1236 ID3D11Buffer
*buffer
;
1237 ID3D11Device
*device
;
1242 static const struct test
1244 BOOL implements_d3d10_interfaces
;
1247 UINT structure_stride
;
1248 UINT expected_bind_flags
;
1249 UINT expected_misc_flags
;
1251 desc_conversion_tests
[] =
1255 D3D11_BIND_VERTEX_BUFFER
, 0, 0,
1256 D3D10_BIND_VERTEX_BUFFER
, 0
1260 D3D11_BIND_INDEX_BUFFER
, 0, 0,
1261 D3D10_BIND_INDEX_BUFFER
, 0
1265 D3D11_BIND_CONSTANT_BUFFER
, 0, 0,
1266 D3D10_BIND_CONSTANT_BUFFER
, 0
1270 D3D11_BIND_SHADER_RESOURCE
, 0, 0,
1271 D3D10_BIND_SHADER_RESOURCE
, 0
1275 D3D11_BIND_STREAM_OUTPUT
, 0, 0,
1276 D3D10_BIND_STREAM_OUTPUT
, 0
1280 D3D11_BIND_RENDER_TARGET
, 0, 0,
1281 D3D10_BIND_RENDER_TARGET
, 0
1285 D3D11_BIND_UNORDERED_ACCESS
, 0, 0,
1286 D3D11_BIND_UNORDERED_ACCESS
, 0
1290 0, D3D11_RESOURCE_MISC_SHARED
, 0,
1291 0, D3D10_RESOURCE_MISC_SHARED
1295 0, D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS
, 0,
1300 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
, 0,
1301 D3D10_BIND_SHADER_RESOURCE
, 0
1304 FALSE
/* Structured buffers do not implement ID3D10Buffer. */,
1305 0, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 16,
1310 0, D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX
, 0,
1311 0, D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX
1315 if (!(device
= create_device(NULL
)))
1317 skip("Failed to create ID3D11Device.\n");
1321 desc
.ByteWidth
= 1024;
1322 desc
.Usage
= D3D11_USAGE_DEFAULT
;
1323 desc
.BindFlags
= D3D11_BIND_VERTEX_BUFFER
;
1324 desc
.CPUAccessFlags
= 0;
1326 desc
.StructureByteStride
= 0;
1328 hr
= ID3D11Device_CreateBuffer(device
, &desc
, NULL
, &buffer
);
1329 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
1331 hr
= ID3D11Buffer_QueryInterface(buffer
, &IID_ID3D10Buffer
, (void **)&d3d10_buffer
);
1332 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
1333 "Buffer should implement ID3D10Buffer.\n");
1334 if (SUCCEEDED(hr
)) ID3D10Buffer_Release(d3d10_buffer
);
1335 ID3D11Buffer_Release(buffer
);
1339 win_skip("Buffers do not implement ID3D10Buffer.\n");
1340 ID3D11Device_Release(device
);
1344 for (i
= 0; i
< sizeof(desc_conversion_tests
) / sizeof(*desc_conversion_tests
); ++i
)
1346 const struct test
*current
= &desc_conversion_tests
[i
];
1347 D3D10_BUFFER_DESC d3d10_desc
;
1348 ID3D10Device
*d3d10_device
;
1350 desc
.ByteWidth
= 1024;
1351 desc
.Usage
= D3D11_USAGE_DEFAULT
;
1352 desc
.BindFlags
= current
->bind_flags
;
1353 desc
.CPUAccessFlags
= 0;
1354 desc
.MiscFlags
= current
->misc_flags
;
1355 desc
.StructureByteStride
= current
->structure_stride
;
1357 hr
= ID3D11Device_CreateBuffer(device
, &desc
, NULL
, &buffer
);
1358 /* Shared resources are not supported by REF and WARP devices. */
1359 ok(SUCCEEDED(hr
) || broken(hr
== E_OUTOFMEMORY
), "Test %u: Failed to create a buffer, hr %#x.\n", i
, hr
);
1362 win_skip("Failed to create a buffer, skipping test %u.\n", i
);
1366 hr
= ID3D11Buffer_QueryInterface(buffer
, &IID_ID3D10Buffer
, (void **)&d3d10_buffer
);
1367 ID3D11Buffer_Release(buffer
);
1369 if (current
->implements_d3d10_interfaces
)
1371 ok(SUCCEEDED(hr
), "Test %u: Buffer should implement ID3D10Buffer.\n", i
);
1375 todo_wine
ok(hr
== E_NOINTERFACE
, "Test %u: Buffer should not implement ID3D10Buffer.\n", i
);
1376 if (SUCCEEDED(hr
)) ID3D10Buffer_Release(d3d10_buffer
);
1380 ID3D10Buffer_GetDesc(d3d10_buffer
, &d3d10_desc
);
1382 ok(d3d10_desc
.ByteWidth
== desc
.ByteWidth
,
1383 "Test %u: Got unexpected ByteWidth %u.\n", i
, d3d10_desc
.ByteWidth
);
1384 ok(d3d10_desc
.Usage
== (D3D10_USAGE
)desc
.Usage
,
1385 "Test %u: Got unexpected Usage %u.\n", i
, d3d10_desc
.Usage
);
1386 ok(d3d10_desc
.BindFlags
== current
->expected_bind_flags
,
1387 "Test %u: Got unexpected BindFlags %#x.\n", i
, d3d10_desc
.BindFlags
);
1388 ok(d3d10_desc
.CPUAccessFlags
== desc
.CPUAccessFlags
,
1389 "Test %u: Got unexpected CPUAccessFlags %#x.\n", i
, d3d10_desc
.CPUAccessFlags
);
1390 ok(d3d10_desc
.MiscFlags
== current
->expected_misc_flags
,
1391 "Test %u: Got unexpected MiscFlags %#x.\n", i
, d3d10_desc
.MiscFlags
);
1393 d3d10_device
= (ID3D10Device
*)0xdeadbeef;
1394 ID3D10Buffer_GetDevice(d3d10_buffer
, &d3d10_device
);
1395 todo_wine
ok(!d3d10_device
, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i
, d3d10_device
);
1396 if (d3d10_device
) ID3D10Device_Release(d3d10_device
);
1398 ID3D10Buffer_Release(d3d10_buffer
);
1401 refcount
= ID3D11Device_Release(device
);
1402 ok(!refcount
, "Device has %u references left.\n", refcount
);
1405 static void test_create_depthstencil_view(void)
1407 D3D11_DEPTH_STENCIL_VIEW_DESC dsv_desc
;
1408 D3D11_TEXTURE2D_DESC texture_desc
;
1409 ULONG refcount
, expected_refcount
;
1410 ID3D11DepthStencilView
*dsview
;
1411 ID3D11Device
*device
, *tmp
;
1412 ID3D11Texture2D
*texture
;
1415 if (!(device
= create_device(NULL
)))
1417 skip("Failed to create device.\n");
1421 texture_desc
.Width
= 512;
1422 texture_desc
.Height
= 512;
1423 texture_desc
.MipLevels
= 1;
1424 texture_desc
.ArraySize
= 1;
1425 texture_desc
.Format
= DXGI_FORMAT_D24_UNORM_S8_UINT
;
1426 texture_desc
.SampleDesc
.Count
= 1;
1427 texture_desc
.SampleDesc
.Quality
= 0;
1428 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
1429 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
1430 texture_desc
.CPUAccessFlags
= 0;
1431 texture_desc
.MiscFlags
= 0;
1433 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
1434 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
1436 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
1437 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, NULL
, &dsview
);
1438 ok(SUCCEEDED(hr
), "Failed to create a depthstencil view, hr %#x.\n", hr
);
1439 refcount
= get_refcount((IUnknown
*)device
);
1440 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
1442 expected_refcount
= refcount
+ 1;
1443 ID3D11DepthStencilView_GetDevice(dsview
, &tmp
);
1444 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
1445 refcount
= get_refcount((IUnknown
*)device
);
1446 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
1447 ID3D11Device_Release(tmp
);
1449 ID3D11DepthStencilView_GetDesc(dsview
, &dsv_desc
);
1450 ok(dsv_desc
.Format
== texture_desc
.Format
, "Got unexpected format %#x.\n", dsv_desc
.Format
);
1451 ok(dsv_desc
.ViewDimension
== D3D11_DSV_DIMENSION_TEXTURE2D
,
1452 "Got unexpected view dimension %#x.\n", dsv_desc
.ViewDimension
);
1453 ok(!dsv_desc
.Flags
, "Got unexpected flags %#x.\n", dsv_desc
.Flags
);
1454 ok(U(dsv_desc
).Texture2D
.MipSlice
== 0, "Got Unexpected mip slice %u.\n", U(dsv_desc
).Texture2D
.MipSlice
);
1456 ID3D11DepthStencilView_Release(dsview
);
1458 dsv_desc
.Format
= DXGI_FORMAT_UNKNOWN
;
1459 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, &dsv_desc
, &dsview
);
1460 ok(SUCCEEDED(hr
), "Failed to create a depthstencil view, hr %#x.\n", hr
);
1462 memset(&dsv_desc
, 0, sizeof(dsv_desc
));
1463 ID3D11DepthStencilView_GetDesc(dsview
, &dsv_desc
);
1464 todo_wine
ok(dsv_desc
.Format
== texture_desc
.Format
, "Got unexpected format %#x.\n", dsv_desc
.Format
);
1465 ok(dsv_desc
.ViewDimension
== D3D11_DSV_DIMENSION_TEXTURE2D
,
1466 "Got unexpected view dimension %#x.\n", dsv_desc
.ViewDimension
);
1467 ok(!dsv_desc
.Flags
, "Got unexpected flags %#x.\n", dsv_desc
.Flags
);
1468 ok(!U(dsv_desc
).Texture2D
.MipSlice
, "Got Unexpected mip slice %u.\n", U(dsv_desc
).Texture2D
.MipSlice
);
1470 ID3D11DepthStencilView_Release(dsview
);
1472 ID3D11Texture2D_Release(texture
);
1474 refcount
= ID3D11Device_Release(device
);
1475 ok(!refcount
, "Device has %u references left.\n", refcount
);
1478 static void test_depthstencil_view_interfaces(void)
1480 D3D10_DEPTH_STENCIL_VIEW_DESC d3d10_dsv_desc
;
1481 D3D11_DEPTH_STENCIL_VIEW_DESC dsv_desc
;
1482 ID3D10DepthStencilView
*d3d10_dsview
;
1483 D3D11_TEXTURE2D_DESC texture_desc
;
1484 ID3D11DepthStencilView
*dsview
;
1485 ID3D11Texture2D
*texture
;
1486 ID3D11Device
*device
;
1490 if (!(device
= create_device(NULL
)))
1492 skip("Failed to create device.\n");
1496 texture_desc
.Width
= 512;
1497 texture_desc
.Height
= 512;
1498 texture_desc
.MipLevels
= 1;
1499 texture_desc
.ArraySize
= 1;
1500 texture_desc
.Format
= DXGI_FORMAT_D24_UNORM_S8_UINT
;
1501 texture_desc
.SampleDesc
.Count
= 1;
1502 texture_desc
.SampleDesc
.Quality
= 0;
1503 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
1504 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
1505 texture_desc
.CPUAccessFlags
= 0;
1506 texture_desc
.MiscFlags
= 0;
1508 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
1509 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
1511 dsv_desc
.Format
= texture_desc
.Format
;
1512 dsv_desc
.ViewDimension
= D3D11_DSV_DIMENSION_TEXTURE2D
;
1514 U(dsv_desc
).Texture2D
.MipSlice
= 0;
1516 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, &dsv_desc
, &dsview
);
1517 ok(SUCCEEDED(hr
), "Failed to create a depthstencil view, hr %#x.\n", hr
);
1519 hr
= ID3D11DepthStencilView_QueryInterface(dsview
, &IID_ID3D10DepthStencilView
, (void **)&d3d10_dsview
);
1520 ID3D11DepthStencilView_Release(dsview
);
1521 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
1522 "Depth stencil view should implement ID3D10DepthStencilView.\n");
1526 win_skip("Depth stencil view does not implement ID3D10DepthStencilView.\n");
1530 ID3D10DepthStencilView_GetDesc(d3d10_dsview
, &d3d10_dsv_desc
);
1531 ok(d3d10_dsv_desc
.Format
== dsv_desc
.Format
, "Got unexpected format %#x.\n", d3d10_dsv_desc
.Format
);
1532 ok(d3d10_dsv_desc
.ViewDimension
== (D3D10_DSV_DIMENSION
)dsv_desc
.ViewDimension
,
1533 "Got unexpected view dimension %u.\n", d3d10_dsv_desc
.ViewDimension
);
1534 ok(U(d3d10_dsv_desc
).Texture2D
.MipSlice
== U(dsv_desc
).Texture2D
.MipSlice
,
1535 "Got unexpected mip slice %u.\n", U(d3d10_dsv_desc
).Texture2D
.MipSlice
);
1537 ID3D10DepthStencilView_Release(d3d10_dsview
);
1540 ID3D11Texture2D_Release(texture
);
1542 refcount
= ID3D11Device_Release(device
);
1543 ok(!refcount
, "Device has %u references left.\n", refcount
);
1546 static void test_create_rendertarget_view(void)
1548 D3D11_RENDER_TARGET_VIEW_DESC rtv_desc
;
1549 D3D11_SUBRESOURCE_DATA data
= {0};
1550 D3D11_TEXTURE2D_DESC texture_desc
;
1551 ULONG refcount
, expected_refcount
;
1552 D3D11_BUFFER_DESC buffer_desc
;
1553 ID3D11RenderTargetView
*rtview
;
1554 ID3D11Device
*device
, *tmp
;
1555 ID3D11Texture2D
*texture
;
1556 ID3D11Buffer
*buffer
;
1560 if (!(device
= create_device(NULL
)))
1562 skip("Failed to create device.\n");
1566 buffer_desc
.ByteWidth
= 1024;
1567 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
1568 buffer_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
1569 buffer_desc
.CPUAccessFlags
= 0;
1570 buffer_desc
.MiscFlags
= 0;
1571 buffer_desc
.StructureByteStride
= 0;
1573 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &data
, &buffer
);
1574 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
1576 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
1577 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
1578 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
1579 refcount
= get_refcount((IUnknown
*)device
);
1580 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
1582 expected_refcount
= refcount
+ 1;
1583 ID3D11Buffer_GetDevice(buffer
, &tmp
);
1584 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
1585 refcount
= get_refcount((IUnknown
*)device
);
1586 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
1587 ID3D11Device_Release(tmp
);
1589 rtv_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
1590 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_BUFFER
;
1591 U(rtv_desc
).Buffer
.ElementOffset
= 0;
1592 U(rtv_desc
).Buffer
.ElementWidth
= 64;
1594 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
1595 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)buffer
, &rtv_desc
, &rtview
);
1596 ok(SUCCEEDED(hr
), "Failed to create a rendertarget view, hr %#x.\n", hr
);
1597 refcount
= get_refcount((IUnknown
*)device
);
1598 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
1600 expected_refcount
= refcount
+ 1;
1601 ID3D11RenderTargetView_GetDevice(rtview
, &tmp
);
1602 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
1603 refcount
= get_refcount((IUnknown
*)device
);
1604 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
1605 ID3D11Device_Release(tmp
);
1607 hr
= ID3D11RenderTargetView_QueryInterface(rtview
, &IID_ID3D10RenderTargetView
, (void **)&iface
);
1608 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
1609 "Render target view should implement ID3D10RenderTargetView.\n");
1610 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
1612 ID3D11RenderTargetView_Release(rtview
);
1613 ID3D11Buffer_Release(buffer
);
1615 texture_desc
.Width
= 512;
1616 texture_desc
.Height
= 512;
1617 texture_desc
.MipLevels
= 1;
1618 texture_desc
.ArraySize
= 1;
1619 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
1620 texture_desc
.SampleDesc
.Count
= 1;
1621 texture_desc
.SampleDesc
.Quality
= 0;
1622 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
1623 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
1624 texture_desc
.CPUAccessFlags
= 0;
1625 texture_desc
.MiscFlags
= 0;
1627 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
1628 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
1630 /* For texture resources it's allowed to specify NULL as desc */
1631 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtview
);
1632 ok(SUCCEEDED(hr
), "Failed to create a rendertarget view, hr %#x.\n", hr
);
1634 ID3D11RenderTargetView_GetDesc(rtview
, &rtv_desc
);
1635 ok(rtv_desc
.Format
== texture_desc
.Format
, "Got unexpected format %#x.\n", rtv_desc
.Format
);
1636 ok(rtv_desc
.ViewDimension
== D3D11_RTV_DIMENSION_TEXTURE2D
, "Got unexpected view dimension %#x.\n",
1637 rtv_desc
.ViewDimension
);
1638 ok(U(rtv_desc
).Texture2D
.MipSlice
== 0, "Got unexpected mip slice %#x.\n", U(rtv_desc
).Texture2D
.MipSlice
);
1640 hr
= ID3D11RenderTargetView_QueryInterface(rtview
, &IID_ID3D10RenderTargetView
, (void **)&iface
);
1641 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
1642 "Render target view should implement ID3D10RenderTargetView.\n");
1643 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
1645 ID3D11RenderTargetView_Release(rtview
);
1647 rtv_desc
.Format
= DXGI_FORMAT_UNKNOWN
;
1648 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, &rtv_desc
, &rtview
);
1649 ok(SUCCEEDED(hr
), "Failed to create a rendertarget view, hr %#x.\n", hr
);
1651 memset(&rtv_desc
, 0, sizeof(rtv_desc
));
1652 ID3D11RenderTargetView_GetDesc(rtview
, &rtv_desc
);
1653 todo_wine
ok(rtv_desc
.Format
== texture_desc
.Format
, "Got unexpected format %#x.\n", rtv_desc
.Format
);
1654 ok(rtv_desc
.ViewDimension
== D3D11_RTV_DIMENSION_TEXTURE2D
, "Got unexpected view dimension %#x.\n",
1655 rtv_desc
.ViewDimension
);
1656 ok(!U(rtv_desc
).Texture2D
.MipSlice
, "Got unexpected mip slice %#x.\n", U(rtv_desc
).Texture2D
.MipSlice
);
1658 ID3D11RenderTargetView_Release(rtview
);
1660 ID3D11Texture2D_Release(texture
);
1662 refcount
= ID3D11Device_Release(device
);
1663 ok(!refcount
, "Device has %u references left.\n", refcount
);
1666 static void test_create_shader_resource_view(void)
1668 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
1669 D3D11_TEXTURE2D_DESC texture_desc
;
1670 ULONG refcount
, expected_refcount
;
1671 ID3D11ShaderResourceView
*srview
;
1672 D3D11_BUFFER_DESC buffer_desc
;
1673 ID3D11Device
*device
, *tmp
;
1674 ID3D11Texture2D
*texture
;
1675 ID3D11Buffer
*buffer
;
1679 if (!(device
= create_device(NULL
)))
1681 skip("Failed to create device.\n");
1685 buffer_desc
.ByteWidth
= 1024;
1686 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
1687 buffer_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
1688 buffer_desc
.CPUAccessFlags
= 0;
1689 buffer_desc
.MiscFlags
= 0;
1690 buffer_desc
.StructureByteStride
= 0;
1692 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
1693 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
1695 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)buffer
, NULL
, &srview
);
1696 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
1698 srv_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
1699 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_BUFFER
;
1700 U(srv_desc
).Buffer
.ElementOffset
= 0;
1701 U(srv_desc
).Buffer
.ElementWidth
= 64;
1703 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
1704 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)buffer
, &srv_desc
, &srview
);
1705 ok(SUCCEEDED(hr
), "Failed to create a shader resource view, hr %#x.\n", hr
);
1706 refcount
= get_refcount((IUnknown
*)device
);
1707 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
1709 expected_refcount
= refcount
+ 1;
1710 ID3D11ShaderResourceView_GetDevice(srview
, &tmp
);
1711 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
1712 refcount
= get_refcount((IUnknown
*)device
);
1713 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
1714 ID3D11Device_Release(tmp
);
1716 hr
= ID3D11ShaderResourceView_QueryInterface(srview
, &IID_ID3D10ShaderResourceView
, (void **)&iface
);
1717 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
1718 "Shader resource view should implement ID3D10ShaderResourceView.\n");
1719 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
1720 hr
= ID3D11ShaderResourceView_QueryInterface(srview
, &IID_ID3D10ShaderResourceView1
, (void **)&iface
);
1721 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
1722 "Shader resource view should implement ID3D10ShaderResourceView1.\n");
1723 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
1725 ID3D11ShaderResourceView_Release(srview
);
1726 ID3D11Buffer_Release(buffer
);
1728 texture_desc
.Width
= 512;
1729 texture_desc
.Height
= 512;
1730 texture_desc
.MipLevels
= 0;
1731 texture_desc
.ArraySize
= 1;
1732 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
1733 texture_desc
.SampleDesc
.Count
= 1;
1734 texture_desc
.SampleDesc
.Quality
= 0;
1735 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
1736 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
1737 texture_desc
.CPUAccessFlags
= 0;
1738 texture_desc
.MiscFlags
= 0;
1740 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
1741 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
1743 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srview
);
1744 ok(SUCCEEDED(hr
), "Failed to create a shader resource view, hr %#x.\n", hr
);
1746 hr
= ID3D11ShaderResourceView_QueryInterface(srview
, &IID_ID3D10ShaderResourceView
, (void **)&iface
);
1747 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
1748 "Shader resource view should implement ID3D10ShaderResourceView.\n");
1749 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
1750 hr
= ID3D11ShaderResourceView_QueryInterface(srview
, &IID_ID3D10ShaderResourceView1
, (void **)&iface
);
1751 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
1752 "Shader resource view should implement ID3D10ShaderResourceView1.\n");
1753 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
1755 ID3D11ShaderResourceView_GetDesc(srview
, &srv_desc
);
1756 ok(srv_desc
.Format
== texture_desc
.Format
, "Got unexpected format %#x.\n", srv_desc
.Format
);
1757 ok(srv_desc
.ViewDimension
== D3D11_SRV_DIMENSION_TEXTURE2D
,
1758 "Got unexpected view dimension %#x.\n", srv_desc
.ViewDimension
);
1759 ok(U(srv_desc
).Texture2D
.MostDetailedMip
== 0, "Got unexpected MostDetailedMip %u.\n",
1760 U(srv_desc
).Texture2D
.MostDetailedMip
);
1761 ok(U(srv_desc
).Texture2D
.MipLevels
== 10, "Got unexpected MipLevels %u.\n", U(srv_desc
).Texture2D
.MipLevels
);
1763 ID3D11ShaderResourceView_Release(srview
);
1765 srv_desc
.Format
= DXGI_FORMAT_UNKNOWN
;
1766 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, &srv_desc
, &srview
);
1767 ok(SUCCEEDED(hr
), "Failed to create a shader resource view, hr %#x.\n", hr
);
1769 memset(&srv_desc
, 0, sizeof(srv_desc
));
1770 ID3D11ShaderResourceView_GetDesc(srview
, &srv_desc
);
1771 todo_wine
ok(srv_desc
.Format
== texture_desc
.Format
, "Got unexpected format %#x.\n", srv_desc
.Format
);
1772 ok(srv_desc
.ViewDimension
== D3D11_SRV_DIMENSION_TEXTURE2D
,
1773 "Got unexpected view dimension %#x.\n", srv_desc
.ViewDimension
);
1774 ok(U(srv_desc
).Texture2D
.MostDetailedMip
== 0, "Got unexpected MostDetailedMip %u.\n",
1775 U(srv_desc
).Texture2D
.MostDetailedMip
);
1776 ok(U(srv_desc
).Texture2D
.MipLevels
== 10, "Got unexpected MipLevels %u.\n", U(srv_desc
).Texture2D
.MipLevels
);
1778 ID3D11ShaderResourceView_Release(srview
);
1780 ID3D11Texture2D_Release(texture
);
1782 refcount
= ID3D11Device_Release(device
);
1783 ok(!refcount
, "Device has %u references left.\n", refcount
);
1786 static void test_create_shader(void)
1794 float4 position
: POSITION
;
1795 float3 normal
: NORMAL
;
1800 float4 position
: POSITION
;
1801 float4 diffuse
: COLOR
;
1804 output
main(const input v
)
1808 o
.position
= mul(v
.position
, mat
);
1809 o
.diffuse
= dot((float3
)light
, v
.normal
);
1814 static const DWORD vs_4_0
[] =
1816 0x43425844, 0x3ae813ca, 0x0f034b91, 0x790f3226, 0x6b4a718a, 0x00000001, 0x000001c0,
1817 0x00000003, 0x0000002c, 0x0000007c, 0x000000cc, 0x4e475349, 0x00000048, 0x00000002,
1818 0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f,
1819 0x00000041, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000707, 0x49534f50,
1820 0x4e4f4954, 0x524f4e00, 0x004c414d, 0x4e47534f, 0x00000048, 0x00000002, 0x00000008,
1821 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x00000041,
1822 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x49534f50, 0x4e4f4954,
1823 0x4c4f4300, 0xab00524f, 0x52444853, 0x000000ec, 0x00010040, 0x0000003b, 0x04000059,
1824 0x00208e46, 0x00000000, 0x00000005, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f,
1825 0x00101072, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x001020f2,
1826 0x00000001, 0x08000011, 0x00102012, 0x00000000, 0x00101e46, 0x00000000, 0x00208e46,
1827 0x00000000, 0x00000001, 0x08000011, 0x00102022, 0x00000000, 0x00101e46, 0x00000000,
1828 0x00208e46, 0x00000000, 0x00000002, 0x08000011, 0x00102042, 0x00000000, 0x00101e46,
1829 0x00000000, 0x00208e46, 0x00000000, 0x00000003, 0x08000011, 0x00102082, 0x00000000,
1830 0x00101e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x08000010, 0x001020f2,
1831 0x00000001, 0x00208246, 0x00000000, 0x00000000, 0x00101246, 0x00000001, 0x0100003e,
1834 static const DWORD vs_2_0
[] =
1836 0xfffe0200, 0x002bfffe, 0x42415443, 0x0000001c, 0x00000077, 0xfffe0200, 0x00000002,
1837 0x0000001c, 0x00000100, 0x00000070, 0x00000044, 0x00040002, 0x00000001, 0x0000004c,
1838 0x00000000, 0x0000005c, 0x00000002, 0x00000004, 0x00000060, 0x00000000, 0x6867696c,
1839 0xabab0074, 0x00030001, 0x00040001, 0x00000001, 0x00000000, 0x0074616d, 0x00030003,
1840 0x00040004, 0x00000001, 0x00000000, 0x325f7376, 0x4d00305f, 0x6f726369, 0x74666f73,
1841 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e392072,
1842 0x392e3932, 0x332e3235, 0x00313131, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f,
1843 0x80000003, 0x900f0001, 0x03000009, 0xc0010000, 0x90e40000, 0xa0e40000, 0x03000009,
1844 0xc0020000, 0x90e40000, 0xa0e40001, 0x03000009, 0xc0040000, 0x90e40000, 0xa0e40002,
1845 0x03000009, 0xc0080000, 0x90e40000, 0xa0e40003, 0x03000008, 0xd00f0000, 0xa0e40004,
1846 0x90e40001, 0x0000ffff,
1849 static const DWORD vs_3_0
[] =
1851 0xfffe0300, 0x002bfffe, 0x42415443, 0x0000001c, 0x00000077, 0xfffe0300, 0x00000002,
1852 0x0000001c, 0x00000100, 0x00000070, 0x00000044, 0x00040002, 0x00000001, 0x0000004c,
1853 0x00000000, 0x0000005c, 0x00000002, 0x00000004, 0x00000060, 0x00000000, 0x6867696c,
1854 0xabab0074, 0x00030001, 0x00040001, 0x00000001, 0x00000000, 0x0074616d, 0x00030003,
1855 0x00040004, 0x00000001, 0x00000000, 0x335f7376, 0x4d00305f, 0x6f726369, 0x74666f73,
1856 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e392072,
1857 0x392e3932, 0x332e3235, 0x00313131, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f,
1858 0x80000003, 0x900f0001, 0x0200001f, 0x80000000, 0xe00f0000, 0x0200001f, 0x8000000a,
1859 0xe00f0001, 0x03000009, 0xe0010000, 0x90e40000, 0xa0e40000, 0x03000009, 0xe0020000,
1860 0x90e40000, 0xa0e40001, 0x03000009, 0xe0040000, 0x90e40000, 0xa0e40002, 0x03000009,
1861 0xe0080000, 0x90e40000, 0xa0e40003, 0x03000008, 0xe00f0001, 0xa0e40004, 0x90e40001,
1866 float4
main(const float4 color
: COLOR
) : SV_TARGET
1875 static const DWORD ps_4_0
[] =
1877 0x43425844, 0x4da9446f, 0xfbe1f259, 0x3fdb3009, 0x517521fa, 0x00000001, 0x000001ac,
1878 0x00000005, 0x00000034, 0x0000008c, 0x000000bc, 0x000000f0, 0x00000130, 0x46454452,
1879 0x00000050, 0x00000000, 0x00000000, 0x00000000, 0x0000001c, 0xffff0400, 0x00000100,
1880 0x0000001c, 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168,
1881 0x6f432072, 0x6c69706d, 0x39207265, 0x2e39322e, 0x2e323539, 0x31313133, 0xababab00,
1882 0x4e475349, 0x00000028, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
1883 0x00000003, 0x00000000, 0x00000f0f, 0x4f4c4f43, 0xabab0052, 0x4e47534f, 0x0000002c,
1884 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
1885 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040,
1886 0x0000000e, 0x03001062, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000,
1887 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x54415453,
1888 0x00000074, 0x00000002, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000,
1889 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1890 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
1891 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1892 0x00000000, 0x00000000,
1894 static const DWORD ps_4_0_level_9_0
[] =
1896 0x43425844, 0xbc6626e7, 0x7778dc9d, 0xc8a43be2, 0xe4b53f7a, 0x00000001, 0x00000170,
1897 0x00000005, 0x00000034, 0x00000080, 0x000000cc, 0x0000010c, 0x0000013c, 0x53414e58,
1898 0x00000044, 0x00000044, 0xffff0200, 0x00000020, 0x00000024, 0x00240000, 0x00240000,
1899 0x00240000, 0x00240000, 0x00240000, 0xffff0200, 0x0200001f, 0x80000000, 0xb00f0000,
1900 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, 0x396e6f41, 0x00000044, 0x00000044,
1901 0xffff0200, 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000,
1902 0x00240000, 0xffff0200, 0x0200001f, 0x80000000, 0xb00f0000, 0x02000001, 0x800f0800,
1903 0xb0e40000, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040, 0x0000000e, 0x03001062,
1904 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x05000036, 0x001020f2,
1905 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x4e475349, 0x00000028, 0x00000001,
1906 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f,
1907 0x4f4c4f43, 0xabab0052, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
1908 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241,
1911 static const DWORD ps_4_0_level_9_1
[] =
1913 0x43425844, 0x275ecf38, 0x4349ff01, 0xa6b0e324, 0x6e54a4fc, 0x00000001, 0x00000120,
1914 0x00000004, 0x00000030, 0x0000007c, 0x000000bc, 0x000000ec, 0x396e6f41, 0x00000044,
1915 0x00000044, 0xffff0200, 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000,
1916 0x00240000, 0x00240000, 0xffff0200, 0x0200001f, 0x80000000, 0xb00f0000, 0x02000001,
1917 0x800f0800, 0xb0e40000, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
1918 0x03001062, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
1919 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x4e475349, 0x00000028,
1920 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
1921 0x00000f0f, 0x4f4c4f43, 0xabab0052, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008,
1922 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653,
1923 0x45475241, 0xabab0054,
1925 static const DWORD ps_4_0_level_9_3
[] =
1927 0x43425844, 0xc7d541c4, 0x961d4e0e, 0x9ce7ec57, 0x70f47dcb, 0x00000001, 0x00000120,
1928 0x00000004, 0x00000030, 0x0000007c, 0x000000bc, 0x000000ec, 0x396e6f41, 0x00000044,
1929 0x00000044, 0xffff0200, 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000,
1930 0x00240000, 0x00240000, 0xffff0201, 0x0200001f, 0x80000000, 0xb00f0000, 0x02000001,
1931 0x800f0800, 0xb0e40000, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
1932 0x03001062, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
1933 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x4e475349, 0x00000028,
1934 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
1935 0x00000f0f, 0x4f4c4f43, 0xabab0052, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008,
1936 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653,
1937 0x45475241, 0xabab0054,
1943 float4 pos
: SV_POSITION
;
1947 void main(point float4 vin
[1] : POSITION
, inout TriangleStream
<gs_out
> vout
)
1949 float offset
= 0.1 * vin
[0].w
;
1952 v
.pos
= float4(vin
[0].x
- offset
, vin
[0].y
- offset
, vin
[0].z
, vin
[0].w
);
1954 v
.pos
= float4(vin
[0].x
- offset
, vin
[0].y
+ offset
, vin
[0].z
, vin
[0].w
);
1956 v
.pos
= float4(vin
[0].x
+ offset
, vin
[0].y
- offset
, vin
[0].z
, vin
[0].w
);
1958 v
.pos
= float4(vin
[0].x
+ offset
, vin
[0].y
+ offset
, vin
[0].z
, vin
[0].w
);
1962 static const DWORD gs_4_0
[] =
1964 0x43425844, 0x000ee786, 0xc624c269, 0x885a5cbe, 0x444b3b1f, 0x00000001, 0x0000023c, 0x00000003,
1965 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
1966 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
1967 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
1968 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x000001a0, 0x00020040,
1969 0x00000068, 0x0400005f, 0x002010f2, 0x00000001, 0x00000000, 0x02000068, 0x00000001, 0x0100085d,
1970 0x0100285c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x0200005e, 0x00000004, 0x0f000032,
1971 0x00100032, 0x00000000, 0x80201ff6, 0x00000041, 0x00000000, 0x00000000, 0x00004002, 0x3dcccccd,
1972 0x3dcccccd, 0x00000000, 0x00000000, 0x00201046, 0x00000000, 0x00000000, 0x05000036, 0x00102032,
1973 0x00000000, 0x00100046, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000,
1974 0x00000000, 0x01000013, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0e000032,
1975 0x00100052, 0x00000000, 0x00201ff6, 0x00000000, 0x00000000, 0x00004002, 0x3dcccccd, 0x00000000,
1976 0x3dcccccd, 0x00000000, 0x00201106, 0x00000000, 0x00000000, 0x05000036, 0x00102022, 0x00000000,
1977 0x0010002a, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000, 0x00000000,
1978 0x01000013, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x05000036, 0x00102022,
1979 0x00000000, 0x0010001a, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000,
1980 0x00000000, 0x01000013, 0x05000036, 0x00102032, 0x00000000, 0x00100086, 0x00000000, 0x06000036,
1981 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000, 0x00000000, 0x01000013, 0x0100003e,
1984 ULONG refcount
, expected_refcount
;
1985 ID3D11Device
*device
, *tmp
;
1986 ID3D11GeometryShader
*gs
;
1987 ID3D11VertexShader
*vs
;
1988 ID3D11PixelShader
*ps
;
1993 for (i
= 0; i
< sizeof(d3d11_feature_levels
) / sizeof(*d3d11_feature_levels
); ++i
)
1995 D3D_FEATURE_LEVEL feature_level
= d3d11_feature_levels
[i
];
1996 BOOL todo
= feature_level
<= D3D_FEATURE_LEVEL_9_3
;
1998 if (!(device
= create_device(&feature_level
)))
2000 skip("Failed to create device for feature level %#x.\n", feature_level
);
2004 /* level_9 shaders */
2005 hr
= ID3D11Device_CreatePixelShader(device
, ps_4_0_level_9_0
, sizeof(ps_4_0_level_9_0
), NULL
, &ps
);
2007 ok(SUCCEEDED(hr
), "Failed to create ps_4_0_level_9_0 shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
2009 ID3D11PixelShader_Release(ps
);
2011 hr
= ID3D11Device_CreatePixelShader(device
, ps_4_0_level_9_1
, sizeof(ps_4_0_level_9_1
), NULL
, &ps
);
2013 ok(SUCCEEDED(hr
), "Failed to create ps_4_0_level_9_1 shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
2015 ID3D11PixelShader_Release(ps
);
2017 hr
= ID3D11Device_CreatePixelShader(device
, ps_4_0_level_9_3
, sizeof(ps_4_0_level_9_3
), NULL
, &ps
);
2019 ok(SUCCEEDED(hr
), "Failed to create ps_4_0_level_9_3 shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
2021 ID3D11PixelShader_Release(ps
);
2024 hr
= ID3D11Device_CreateVertexShader(device
, vs_2_0
, sizeof(vs_2_0
), NULL
, &vs
);
2025 ok(hr
== E_INVALIDARG
, "Created a SM2 vertex shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
2027 hr
= ID3D11Device_CreateVertexShader(device
, vs_3_0
, sizeof(vs_3_0
), NULL
, &vs
);
2028 ok(hr
== E_INVALIDARG
, "Created a SM3 vertex shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
2030 hr
= ID3D11Device_CreateVertexShader(device
, ps_4_0
, sizeof(ps_4_0
), NULL
, &vs
);
2031 ok(hr
== E_INVALIDARG
, "Created a SM4 vertex shader from a pixel shader source, hr %#x, feature level %#x.\n",
2034 expected_refcount
= get_refcount((IUnknown
*)device
) + (feature_level
>= D3D_FEATURE_LEVEL_10_0
);
2035 hr
= ID3D11Device_CreateVertexShader(device
, vs_4_0
, sizeof(vs_4_0
), NULL
, &vs
);
2036 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
2037 ok(SUCCEEDED(hr
), "Failed to create SM4 vertex shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
2039 ok(hr
== E_INVALIDARG
, "Created a SM4 vertex shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
2041 refcount
= get_refcount((IUnknown
*)device
);
2042 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n",
2043 refcount
, expected_refcount
);
2044 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
2047 expected_refcount
= refcount
+ 1;
2048 ID3D11VertexShader_GetDevice(vs
, &tmp
);
2049 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2050 refcount
= get_refcount((IUnknown
*)device
);
2051 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n",
2052 refcount
, expected_refcount
);
2053 ID3D11Device_Release(tmp
);
2055 hr
= ID3D11VertexShader_QueryInterface(vs
, &IID_ID3D10VertexShader
, (void **)&iface
);
2056 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
2057 "Vertex shader should implement ID3D10VertexShader.\n");
2058 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
2060 refcount
= ID3D11VertexShader_Release(vs
);
2061 ok(!refcount
, "Vertex shader has %u references left.\n", refcount
);
2065 expected_refcount
= get_refcount((IUnknown
*)device
) + (feature_level
>= D3D_FEATURE_LEVEL_10_0
);
2066 hr
= ID3D11Device_CreatePixelShader(device
, ps_4_0
, sizeof(ps_4_0
), NULL
, &ps
);
2067 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
2068 ok(SUCCEEDED(hr
), "Failed to create SM4 pixel shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
2070 ok(hr
== E_INVALIDARG
, "Created a SM4 pixel shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
2072 refcount
= get_refcount((IUnknown
*)device
);
2073 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n",
2074 refcount
, expected_refcount
);
2075 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
2078 expected_refcount
= refcount
+ 1;
2079 ID3D11PixelShader_GetDevice(ps
, &tmp
);
2080 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2081 refcount
= get_refcount((IUnknown
*)device
);
2082 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n",
2083 refcount
, expected_refcount
);
2084 ID3D11Device_Release(tmp
);
2086 hr
= ID3D11PixelShader_QueryInterface(ps
, &IID_ID3D10PixelShader
, (void **)&iface
);
2087 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
2088 "Pixel shader should implement ID3D10PixelShader.\n");
2089 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
2091 refcount
= ID3D11PixelShader_Release(ps
);
2092 ok(!refcount
, "Pixel shader has %u references left.\n", refcount
);
2095 /* geometry shader */
2096 expected_refcount
= get_refcount((IUnknown
*)device
) + (feature_level
>= D3D_FEATURE_LEVEL_10_0
);
2097 hr
= ID3D11Device_CreateGeometryShader(device
, gs_4_0
, sizeof(gs_4_0
), NULL
, &gs
);
2098 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
2099 ok(SUCCEEDED(hr
), "Failed to create SM4 geometry shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
2101 ok(hr
== E_INVALIDARG
, "Created a SM4 geometry shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
2103 refcount
= get_refcount((IUnknown
*)device
);
2104 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n",
2105 refcount
, expected_refcount
);
2106 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
2109 expected_refcount
= refcount
+ 1;
2110 ID3D11GeometryShader_GetDevice(gs
, &tmp
);
2111 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2112 refcount
= get_refcount((IUnknown
*)device
);
2113 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n",
2114 refcount
, expected_refcount
);
2115 ID3D11Device_Release(tmp
);
2117 hr
= ID3D11GeometryShader_QueryInterface(gs
, &IID_ID3D10GeometryShader
, (void **)&iface
);
2118 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
2119 "Geometry shader should implement ID3D10GeometryShader.\n");
2120 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
2122 refcount
= ID3D11GeometryShader_Release(gs
);
2123 ok(!refcount
, "Geometry shader has %u references left.\n", refcount
);
2126 refcount
= ID3D11Device_Release(device
);
2127 ok(!refcount
, "Device has %u references left.\n", refcount
);
2131 static void test_create_sampler_state(void)
2133 static const struct test
2135 D3D11_FILTER filter
;
2136 D3D10_FILTER expected_filter
;
2138 desc_conversion_tests
[] =
2140 {D3D11_FILTER_MIN_MAG_MIP_POINT
, D3D10_FILTER_MIN_MAG_MIP_POINT
},
2141 {D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR
, D3D10_FILTER_MIN_MAG_POINT_MIP_LINEAR
},
2142 {D3D11_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT
, D3D10_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT
},
2143 {D3D11_FILTER_MIN_POINT_MAG_MIP_LINEAR
, D3D10_FILTER_MIN_POINT_MAG_MIP_LINEAR
},
2144 {D3D11_FILTER_MIN_LINEAR_MAG_MIP_POINT
, D3D10_FILTER_MIN_LINEAR_MAG_MIP_POINT
},
2145 {D3D11_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR
, D3D10_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR
},
2146 {D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT
, D3D10_FILTER_MIN_MAG_LINEAR_MIP_POINT
},
2147 {D3D11_FILTER_MIN_MAG_MIP_LINEAR
, D3D10_FILTER_MIN_MAG_MIP_LINEAR
},
2148 {D3D11_FILTER_ANISOTROPIC
, D3D10_FILTER_ANISOTROPIC
},
2149 {D3D11_FILTER_COMPARISON_MIN_MAG_MIP_POINT
, D3D10_FILTER_COMPARISON_MIN_MAG_MIP_POINT
},
2150 {D3D11_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR
, D3D10_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR
},
2152 D3D11_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT
,
2153 D3D10_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT
2155 {D3D11_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR
, D3D10_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR
},
2156 {D3D11_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT
, D3D10_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT
},
2158 D3D11_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR
,
2159 D3D10_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR
2161 {D3D11_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT
, D3D10_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT
},
2162 {D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR
, D3D10_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR
},
2163 {D3D11_FILTER_COMPARISON_ANISOTROPIC
, D3D10_FILTER_COMPARISON_ANISOTROPIC
},
2166 ID3D11SamplerState
*sampler_state1
, *sampler_state2
;
2167 ID3D10SamplerState
*d3d10_sampler_state
;
2168 ULONG refcount
, expected_refcount
;
2169 ID3D11Device
*device
, *tmp
;
2170 D3D11_SAMPLER_DESC desc
;
2174 if (!(device
= create_device(NULL
)))
2176 skip("Failed to create device.\n");
2180 hr
= ID3D11Device_CreateSamplerState(device
, NULL
, &sampler_state1
);
2181 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
2183 desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_LINEAR
;
2184 desc
.AddressU
= D3D11_TEXTURE_ADDRESS_WRAP
;
2185 desc
.AddressV
= D3D11_TEXTURE_ADDRESS_WRAP
;
2186 desc
.AddressW
= D3D11_TEXTURE_ADDRESS_WRAP
;
2187 desc
.MipLODBias
= 0.0f
;
2188 desc
.MaxAnisotropy
= 16;
2189 desc
.ComparisonFunc
= D3D11_COMPARISON_ALWAYS
;
2190 desc
.BorderColor
[0] = 0.0f
;
2191 desc
.BorderColor
[1] = 1.0f
;
2192 desc
.BorderColor
[2] = 0.0f
;
2193 desc
.BorderColor
[3] = 1.0f
;
2195 desc
.MaxLOD
= 16.0f
;
2197 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
2198 hr
= ID3D11Device_CreateSamplerState(device
, &desc
, &sampler_state1
);
2199 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
2200 hr
= ID3D11Device_CreateSamplerState(device
, &desc
, &sampler_state2
);
2201 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
2202 ok(sampler_state1
== sampler_state2
, "Got different sampler state objects.\n");
2203 refcount
= get_refcount((IUnknown
*)device
);
2204 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2206 expected_refcount
= refcount
+ 1;
2207 ID3D11SamplerState_GetDevice(sampler_state1
, &tmp
);
2208 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2209 refcount
= get_refcount((IUnknown
*)device
);
2210 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2211 ID3D11Device_Release(tmp
);
2213 ID3D11SamplerState_GetDesc(sampler_state1
, &desc
);
2214 ok(desc
.Filter
== D3D11_FILTER_MIN_MAG_MIP_LINEAR
, "Got unexpected filter %#x.\n", desc
.Filter
);
2215 ok(desc
.AddressU
== D3D11_TEXTURE_ADDRESS_WRAP
, "Got unexpected address u %u.\n", desc
.AddressU
);
2216 ok(desc
.AddressV
== D3D11_TEXTURE_ADDRESS_WRAP
, "Got unexpected address v %u.\n", desc
.AddressV
);
2217 ok(desc
.AddressW
== D3D11_TEXTURE_ADDRESS_WRAP
, "Got unexpected address w %u.\n", desc
.AddressW
);
2218 ok(!desc
.MipLODBias
, "Got unexpected mip LOD bias %f.\n", desc
.MipLODBias
);
2219 ok(!desc
.MaxAnisotropy
, "Got unexpected max anisotropy %u.\n", desc
.MaxAnisotropy
);
2220 ok(desc
.ComparisonFunc
== D3D11_COMPARISON_NEVER
, "Got unexpected comparison func %u.\n", desc
.ComparisonFunc
);
2221 ok(!desc
.BorderColor
[0] && !desc
.BorderColor
[1] && !desc
.BorderColor
[2] && !desc
.BorderColor
[3],
2222 "Got unexpected border color {%.8e, %.8e, %.8e, %.8e}.\n",
2223 desc
.BorderColor
[0], desc
.BorderColor
[1], desc
.BorderColor
[2], desc
.BorderColor
[3]);
2224 ok(!desc
.MinLOD
, "Got unexpected min LOD %f.\n", desc
.MinLOD
);
2225 ok(desc
.MaxLOD
== 16.0f
, "Got unexpected max LOD %f.\n", desc
.MaxLOD
);
2227 refcount
= ID3D11SamplerState_Release(sampler_state2
);
2228 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
2229 refcount
= ID3D11SamplerState_Release(sampler_state1
);
2230 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
2232 for (i
= 0; i
< sizeof(desc_conversion_tests
) / sizeof(*desc_conversion_tests
); ++i
)
2234 const struct test
*current
= &desc_conversion_tests
[i
];
2235 D3D10_SAMPLER_DESC d3d10_desc
, expected_desc
;
2237 desc
.Filter
= current
->filter
;
2238 desc
.AddressU
= D3D11_TEXTURE_ADDRESS_WRAP
;
2239 desc
.AddressV
= D3D11_TEXTURE_ADDRESS_WRAP
;
2240 desc
.AddressW
= D3D11_TEXTURE_ADDRESS_BORDER
;
2241 desc
.MipLODBias
= 0.0f
;
2242 desc
.MaxAnisotropy
= 16;
2243 desc
.ComparisonFunc
= D3D11_COMPARISON_ALWAYS
;
2244 desc
.BorderColor
[0] = 0.0f
;
2245 desc
.BorderColor
[1] = 1.0f
;
2246 desc
.BorderColor
[2] = 0.0f
;
2247 desc
.BorderColor
[3] = 1.0f
;
2249 desc
.MaxLOD
= 16.0f
;
2251 hr
= ID3D11Device_CreateSamplerState(device
, &desc
, &sampler_state1
);
2252 ok(SUCCEEDED(hr
), "Test %u: Failed to create sampler state, hr %#x.\n", i
, hr
);
2254 hr
= ID3D11SamplerState_QueryInterface(sampler_state1
, &IID_ID3D10SamplerState
,
2255 (void **)&d3d10_sampler_state
);
2256 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
2257 "Test %u: Sampler state should implement ID3D10SamplerState.\n", i
);
2260 win_skip("Sampler state does not implement ID3D10SamplerState.\n");
2261 ID3D11SamplerState_Release(sampler_state1
);
2265 memcpy(&expected_desc
, &desc
, sizeof(expected_desc
));
2266 expected_desc
.Filter
= current
->expected_filter
;
2267 if (!D3D11_DECODE_IS_ANISOTROPIC_FILTER(current
->filter
))
2268 expected_desc
.MaxAnisotropy
= 0;
2269 if (!D3D11_DECODE_IS_COMPARISON_FILTER(current
->filter
))
2270 expected_desc
.ComparisonFunc
= D3D10_COMPARISON_NEVER
;
2272 ID3D10SamplerState_GetDesc(d3d10_sampler_state
, &d3d10_desc
);
2273 ok(d3d10_desc
.Filter
== expected_desc
.Filter
,
2274 "Test %u: Got unexpected filter %#x.\n", i
, d3d10_desc
.Filter
);
2275 ok(d3d10_desc
.AddressU
== expected_desc
.AddressU
,
2276 "Test %u: Got unexpected address u %u.\n", i
, d3d10_desc
.AddressU
);
2277 ok(d3d10_desc
.AddressV
== expected_desc
.AddressV
,
2278 "Test %u: Got unexpected address v %u.\n", i
, d3d10_desc
.AddressV
);
2279 ok(d3d10_desc
.AddressW
== expected_desc
.AddressW
,
2280 "Test %u: Got unexpected address w %u.\n", i
, d3d10_desc
.AddressW
);
2281 ok(d3d10_desc
.MipLODBias
== expected_desc
.MipLODBias
,
2282 "Test %u: Got unexpected mip LOD bias %f.\n", i
, d3d10_desc
.MipLODBias
);
2283 ok(d3d10_desc
.MaxAnisotropy
== expected_desc
.MaxAnisotropy
,
2284 "Test %u: Got unexpected max anisotropy %u.\n", i
, d3d10_desc
.MaxAnisotropy
);
2285 ok(d3d10_desc
.ComparisonFunc
== expected_desc
.ComparisonFunc
,
2286 "Test %u: Got unexpected comparison func %u.\n", i
, d3d10_desc
.ComparisonFunc
);
2287 ok(d3d10_desc
.BorderColor
[0] == expected_desc
.BorderColor
[0]
2288 && d3d10_desc
.BorderColor
[1] == expected_desc
.BorderColor
[1]
2289 && d3d10_desc
.BorderColor
[2] == expected_desc
.BorderColor
[2]
2290 && d3d10_desc
.BorderColor
[3] == expected_desc
.BorderColor
[3],
2291 "Test %u: Got unexpected border color {%.8e, %.8e, %.8e, %.8e}.\n", i
,
2292 d3d10_desc
.BorderColor
[0], d3d10_desc
.BorderColor
[1],
2293 d3d10_desc
.BorderColor
[2], d3d10_desc
.BorderColor
[3]);
2294 ok(d3d10_desc
.MinLOD
== expected_desc
.MinLOD
,
2295 "Test %u: Got unexpected min LOD %f.\n", i
, d3d10_desc
.MinLOD
);
2296 ok(d3d10_desc
.MaxLOD
== expected_desc
.MaxLOD
,
2297 "Test %u: Got unexpected max LOD %f.\n", i
, d3d10_desc
.MaxLOD
);
2299 refcount
= ID3D10SamplerState_Release(d3d10_sampler_state
);
2300 ok(refcount
== 1, "Test %u: Got unexpected refcount %u.\n", i
, refcount
);
2301 refcount
= ID3D11SamplerState_Release(sampler_state1
);
2302 ok(!refcount
, "Test %u: Got unexpected refcount %u.\n", i
, refcount
);
2305 refcount
= ID3D11Device_Release(device
);
2306 ok(!refcount
, "Device has %u references left.\n", refcount
);
2309 static void test_create_blend_state(void)
2311 static const D3D11_BLEND_DESC desc_conversion_tests
[] =
2317 FALSE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
2318 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
2326 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
2327 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
2330 FALSE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
2331 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_RED
2334 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
2335 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
2338 FALSE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
2339 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_GREEN
2342 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
2343 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
2346 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
2347 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
2350 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
2351 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
2354 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
2355 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
2363 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
2364 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
2367 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_SUBTRACT
,
2368 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
2371 TRUE
, D3D11_BLEND_ZERO
, D3D11_BLEND_ONE
, D3D11_BLEND_OP_ADD
,
2372 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
2375 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
2376 D3D11_BLEND_ZERO
, D3D11_BLEND_ONE
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
2379 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ONE
, D3D11_BLEND_OP_MAX
,
2380 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
2383 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ONE
, D3D11_BLEND_OP_MIN
,
2384 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
2387 FALSE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
2388 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
2391 FALSE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
2392 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
2398 ID3D11BlendState
*blend_state1
, *blend_state2
;
2399 D3D11_BLEND_DESC desc
, obtained_desc
;
2400 ID3D10BlendState
*d3d10_blend_state
;
2401 D3D10_BLEND_DESC d3d10_blend_desc
;
2402 ULONG refcount
, expected_refcount
;
2403 ID3D11Device
*device
, *tmp
;
2408 if (!(device
= create_device(NULL
)))
2410 skip("Failed to create device.\n");
2414 hr
= ID3D11Device_CreateBlendState(device
, NULL
, &blend_state1
);
2415 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
2417 memset(&desc
, 0, sizeof(desc
));
2418 desc
.AlphaToCoverageEnable
= FALSE
;
2419 desc
.IndependentBlendEnable
= FALSE
;
2420 desc
.RenderTarget
[0].BlendEnable
= FALSE
;
2421 desc
.RenderTarget
[0].SrcBlend
= D3D11_BLEND_ONE
;
2422 desc
.RenderTarget
[0].DestBlend
= D3D11_BLEND_ZERO
;
2423 desc
.RenderTarget
[0].BlendOp
= D3D11_BLEND_OP_ADD
;
2424 desc
.RenderTarget
[0].SrcBlendAlpha
= D3D11_BLEND_ONE
;
2425 desc
.RenderTarget
[0].DestBlendAlpha
= D3D11_BLEND_ZERO
;
2426 desc
.RenderTarget
[0].BlendOpAlpha
= D3D11_BLEND_OP_ADD
;
2427 desc
.RenderTarget
[0].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_ALL
;
2429 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
2430 hr
= ID3D11Device_CreateBlendState(device
, &desc
, &blend_state1
);
2431 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
2432 hr
= ID3D11Device_CreateBlendState(device
, &desc
, &blend_state2
);
2433 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
2434 ok(blend_state1
== blend_state2
, "Got different blend state objects.\n");
2435 refcount
= get_refcount((IUnknown
*)device
);
2436 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2438 expected_refcount
= refcount
+ 1;
2439 ID3D11BlendState_GetDevice(blend_state1
, &tmp
);
2440 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2441 refcount
= get_refcount((IUnknown
*)device
);
2442 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2443 ID3D11Device_Release(tmp
);
2445 ID3D11BlendState_GetDesc(blend_state1
, &obtained_desc
);
2446 ok(obtained_desc
.AlphaToCoverageEnable
== FALSE
, "Got unexpected alpha to coverage enable %#x.\n",
2447 obtained_desc
.AlphaToCoverageEnable
);
2448 ok(obtained_desc
.IndependentBlendEnable
== FALSE
, "Got unexpected independent blend enable %#x.\n",
2449 obtained_desc
.IndependentBlendEnable
);
2450 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
2452 ok(obtained_desc
.RenderTarget
[i
].BlendEnable
== FALSE
,
2453 "Got unexpected blend enable %#x for render target %u.\n",
2454 obtained_desc
.RenderTarget
[i
].BlendEnable
, i
);
2455 ok(obtained_desc
.RenderTarget
[i
].SrcBlend
== D3D11_BLEND_ONE
,
2456 "Got unexpected src blend %u for render target %u.\n",
2457 obtained_desc
.RenderTarget
[i
].SrcBlend
, i
);
2458 ok(obtained_desc
.RenderTarget
[i
].DestBlend
== D3D11_BLEND_ZERO
,
2459 "Got unexpected dest blend %u for render target %u.\n",
2460 obtained_desc
.RenderTarget
[i
].DestBlend
, i
);
2461 ok(obtained_desc
.RenderTarget
[i
].BlendOp
== D3D11_BLEND_OP_ADD
,
2462 "Got unexpected blend op %u for render target %u.\n",
2463 obtained_desc
.RenderTarget
[i
].BlendOp
, i
);
2464 ok(obtained_desc
.RenderTarget
[i
].SrcBlendAlpha
== D3D11_BLEND_ONE
,
2465 "Got unexpected src blend alpha %u for render target %u.\n",
2466 obtained_desc
.RenderTarget
[i
].SrcBlendAlpha
, i
);
2467 ok(obtained_desc
.RenderTarget
[i
].DestBlendAlpha
== D3D11_BLEND_ZERO
,
2468 "Got unexpected dest blend alpha %u for render target %u.\n",
2469 obtained_desc
.RenderTarget
[i
].DestBlendAlpha
, i
);
2470 ok(obtained_desc
.RenderTarget
[i
].BlendOpAlpha
== D3D11_BLEND_OP_ADD
,
2471 "Got unexpected blend op alpha %u for render target %u.\n",
2472 obtained_desc
.RenderTarget
[i
].BlendOpAlpha
, i
);
2473 ok(obtained_desc
.RenderTarget
[i
].RenderTargetWriteMask
== D3D11_COLOR_WRITE_ENABLE_ALL
,
2474 "Got unexpected render target write mask %#x for render target %u.\n",
2475 obtained_desc
.RenderTarget
[0].RenderTargetWriteMask
, i
);
2478 hr
= ID3D11BlendState_QueryInterface(blend_state1
, &IID_ID3D10BlendState
, (void **)&iface
);
2479 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
2480 "Blend state should implement ID3D10BlendState.\n");
2481 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
2482 hr
= ID3D11BlendState_QueryInterface(blend_state1
, &IID_ID3D10BlendState1
, (void **)&iface
);
2483 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
2484 "Blend state should implement ID3D10BlendState1.\n");
2485 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
2487 refcount
= ID3D11BlendState_Release(blend_state1
);
2488 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
2489 refcount
= ID3D11BlendState_Release(blend_state2
);
2490 ok(!refcount
, "Blend state has %u references left.\n", refcount
);
2492 for (i
= 0; i
< sizeof(desc_conversion_tests
) / sizeof(*desc_conversion_tests
); ++i
)
2494 const D3D11_BLEND_DESC
*current_desc
= &desc_conversion_tests
[i
];
2496 hr
= ID3D11Device_CreateBlendState(device
, current_desc
, &blend_state1
);
2497 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
2499 hr
= ID3D11BlendState_QueryInterface(blend_state1
, &IID_ID3D10BlendState
, (void **)&d3d10_blend_state
);
2500 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
2501 "Blend state should implement ID3D10BlendState.\n");
2504 win_skip("Blend state does not implement ID3D10BlendState.\n");
2505 ID3D11BlendState_Release(blend_state1
);
2509 ID3D10BlendState_GetDesc(d3d10_blend_state
, &d3d10_blend_desc
);
2510 ok(d3d10_blend_desc
.AlphaToCoverageEnable
== current_desc
->AlphaToCoverageEnable
,
2511 "Got unexpected alpha to coverage enable %#x for test %u.\n",
2512 d3d10_blend_desc
.AlphaToCoverageEnable
, i
);
2513 ok(d3d10_blend_desc
.SrcBlend
== (D3D10_BLEND
)current_desc
->RenderTarget
[0].SrcBlend
,
2514 "Got unexpected src blend %u for test %u.\n", d3d10_blend_desc
.SrcBlend
, i
);
2515 ok(d3d10_blend_desc
.DestBlend
== (D3D10_BLEND
)current_desc
->RenderTarget
[0].DestBlend
,
2516 "Got unexpected dest blend %u for test %u.\n", d3d10_blend_desc
.DestBlend
, i
);
2517 ok(d3d10_blend_desc
.BlendOp
== (D3D10_BLEND_OP
)current_desc
->RenderTarget
[0].BlendOp
,
2518 "Got unexpected blend op %u for test %u.\n", d3d10_blend_desc
.BlendOp
, i
);
2519 ok(d3d10_blend_desc
.SrcBlendAlpha
== (D3D10_BLEND
)current_desc
->RenderTarget
[0].SrcBlendAlpha
,
2520 "Got unexpected src blend alpha %u for test %u.\n", d3d10_blend_desc
.SrcBlendAlpha
, i
);
2521 ok(d3d10_blend_desc
.DestBlendAlpha
== (D3D10_BLEND
)current_desc
->RenderTarget
[0].DestBlendAlpha
,
2522 "Got unexpected dest blend alpha %u for test %u.\n", d3d10_blend_desc
.DestBlendAlpha
, i
);
2523 ok(d3d10_blend_desc
.BlendOpAlpha
== (D3D10_BLEND_OP
)current_desc
->RenderTarget
[0].BlendOpAlpha
,
2524 "Got unexpected blend op alpha %u for test %u.\n", d3d10_blend_desc
.BlendOpAlpha
, i
);
2525 for (j
= 0; j
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; j
++)
2527 unsigned int k
= current_desc
->IndependentBlendEnable
? j
: 0;
2528 ok(d3d10_blend_desc
.BlendEnable
[j
] == current_desc
->RenderTarget
[k
].BlendEnable
,
2529 "Got unexpected blend enable %#x for test %u, render target %u.\n",
2530 d3d10_blend_desc
.BlendEnable
[j
], i
, j
);
2531 ok(d3d10_blend_desc
.RenderTargetWriteMask
[j
] == current_desc
->RenderTarget
[k
].RenderTargetWriteMask
,
2532 "Got unexpected render target write mask %#x for test %u, render target %u.\n",
2533 d3d10_blend_desc
.RenderTargetWriteMask
[j
], i
, j
);
2536 ID3D10BlendState_Release(d3d10_blend_state
);
2538 refcount
= ID3D11BlendState_Release(blend_state1
);
2539 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
2542 refcount
= ID3D11Device_Release(device
);
2543 ok(!refcount
, "Device has %u references left.\n", refcount
);
2546 static void test_create_depthstencil_state(void)
2548 ID3D11DepthStencilState
*ds_state1
, *ds_state2
;
2549 ID3D10DepthStencilState
*d3d10_ds_state
;
2550 ULONG refcount
, expected_refcount
;
2551 D3D11_DEPTH_STENCIL_DESC ds_desc
;
2552 ID3D11Device
*device
, *tmp
;
2555 if (!(device
= create_device(NULL
)))
2557 skip("Failed to create device.\n");
2561 hr
= ID3D11Device_CreateDepthStencilState(device
, NULL
, &ds_state1
);
2562 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
2564 ds_desc
.DepthEnable
= TRUE
;
2565 ds_desc
.DepthWriteMask
= D3D11_DEPTH_WRITE_MASK_ALL
;
2566 ds_desc
.DepthFunc
= D3D11_COMPARISON_LESS
;
2567 ds_desc
.StencilEnable
= FALSE
;
2568 ds_desc
.StencilReadMask
= D3D11_DEFAULT_STENCIL_READ_MASK
;
2569 ds_desc
.StencilWriteMask
= D3D11_DEFAULT_STENCIL_WRITE_MASK
;
2570 ds_desc
.FrontFace
.StencilFailOp
= D3D11_STENCIL_OP_KEEP
;
2571 ds_desc
.FrontFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_KEEP
;
2572 ds_desc
.FrontFace
.StencilPassOp
= D3D11_STENCIL_OP_KEEP
;
2573 ds_desc
.FrontFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
2574 ds_desc
.BackFace
.StencilFailOp
= D3D11_STENCIL_OP_KEEP
;
2575 ds_desc
.BackFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_KEEP
;
2576 ds_desc
.BackFace
.StencilPassOp
= D3D11_STENCIL_OP_KEEP
;
2577 ds_desc
.BackFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
2579 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
2580 hr
= ID3D11Device_CreateDepthStencilState(device
, &ds_desc
, &ds_state1
);
2581 ok(SUCCEEDED(hr
), "Failed to create depthstencil state, hr %#x.\n", hr
);
2582 hr
= ID3D11Device_CreateDepthStencilState(device
, &ds_desc
, &ds_state2
);
2583 ok(SUCCEEDED(hr
), "Failed to create depthstencil state, hr %#x.\n", hr
);
2584 ok(ds_state1
== ds_state2
, "Got different depthstencil state objects.\n");
2585 refcount
= get_refcount((IUnknown
*)device
);
2586 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2588 expected_refcount
= refcount
+ 1;
2589 ID3D11DepthStencilState_GetDevice(ds_state1
, &tmp
);
2590 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2591 refcount
= get_refcount((IUnknown
*)device
);
2592 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2593 ID3D11Device_Release(tmp
);
2595 hr
= ID3D11DepthStencilState_QueryInterface(ds_state1
, &IID_ID3D10DepthStencilState
, (void **)&d3d10_ds_state
);
2596 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
2597 "Depth stencil state should implement ID3D10DepthStencilState.\n");
2598 if (SUCCEEDED(hr
)) ID3D10DepthStencilState_Release(d3d10_ds_state
);
2600 refcount
= ID3D11DepthStencilState_Release(ds_state2
);
2601 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
2602 refcount
= ID3D11DepthStencilState_Release(ds_state1
);
2603 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
2605 refcount
= ID3D11Device_Release(device
);
2606 ok(!refcount
, "Device has %u references left.\n", refcount
);
2609 static void test_create_rasterizer_state(void)
2611 ID3D11RasterizerState
*rast_state1
, *rast_state2
;
2612 ID3D10RasterizerState
*d3d10_rast_state
;
2613 ULONG refcount
, expected_refcount
;
2614 D3D10_RASTERIZER_DESC d3d10_desc
;
2615 D3D11_RASTERIZER_DESC desc
;
2616 ID3D11Device
*device
, *tmp
;
2619 if (!(device
= create_device(NULL
)))
2621 skip("Failed to create device.\n");
2625 hr
= ID3D11Device_CreateRasterizerState(device
, NULL
, &rast_state1
);
2626 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
2628 desc
.FillMode
= D3D11_FILL_SOLID
;
2629 desc
.CullMode
= D3D11_CULL_BACK
;
2630 desc
.FrontCounterClockwise
= FALSE
;
2632 desc
.DepthBiasClamp
= 0.0f
;
2633 desc
.SlopeScaledDepthBias
= 0.0f
;
2634 desc
.DepthClipEnable
= TRUE
;
2635 desc
.ScissorEnable
= FALSE
;
2636 desc
.MultisampleEnable
= FALSE
;
2637 desc
.AntialiasedLineEnable
= FALSE
;
2639 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
2640 hr
= ID3D11Device_CreateRasterizerState(device
, &desc
, &rast_state1
);
2641 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
2642 hr
= ID3D11Device_CreateRasterizerState(device
, &desc
, &rast_state2
);
2643 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
2644 ok(rast_state1
== rast_state2
, "Got different rasterizer state objects.\n");
2645 refcount
= get_refcount((IUnknown
*)device
);
2646 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2648 expected_refcount
= refcount
+ 1;
2649 ID3D11RasterizerState_GetDevice(rast_state1
, &tmp
);
2650 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2651 refcount
= get_refcount((IUnknown
*)device
);
2652 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2653 ID3D11Device_Release(tmp
);
2655 hr
= ID3D11RasterizerState_QueryInterface(rast_state1
, &IID_ID3D10RasterizerState
, (void **)&d3d10_rast_state
);
2656 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
2657 "Rasterizer state should implement ID3D10RasterizerState.\n");
2660 ID3D10RasterizerState_GetDesc(d3d10_rast_state
, &d3d10_desc
);
2661 ok(d3d10_desc
.FillMode
== D3D10_FILL_SOLID
, "Got unexpected fill mode %u.\n", d3d10_desc
.FillMode
);
2662 ok(d3d10_desc
.CullMode
== D3D10_CULL_BACK
, "Got unexpected cull mode %u.\n", d3d10_desc
.CullMode
);
2663 ok(!d3d10_desc
.FrontCounterClockwise
, "Got unexpected front counter clockwise %#x.\n",
2664 d3d10_desc
.FrontCounterClockwise
);
2665 ok(!d3d10_desc
.DepthBias
, "Got unexpected depth bias %d.\n", d3d10_desc
.DepthBias
);
2666 ok(!d3d10_desc
.DepthBiasClamp
, "Got unexpected depth bias clamp %f.\n", d3d10_desc
.DepthBiasClamp
);
2667 ok(!d3d10_desc
.SlopeScaledDepthBias
, "Got unexpected slope scaled depth bias %f.\n",
2668 d3d10_desc
.SlopeScaledDepthBias
);
2669 ok(!!d3d10_desc
.DepthClipEnable
, "Got unexpected depth clip enable %#x.\n", d3d10_desc
.DepthClipEnable
);
2670 ok(!d3d10_desc
.ScissorEnable
, "Got unexpected scissor enable %#x.\n", d3d10_desc
.ScissorEnable
);
2671 ok(!d3d10_desc
.MultisampleEnable
, "Got unexpected multisample enable %#x.\n",
2672 d3d10_desc
.MultisampleEnable
);
2673 ok(!d3d10_desc
.AntialiasedLineEnable
, "Got unexpected antialiased line enable %#x.\n",
2674 d3d10_desc
.AntialiasedLineEnable
);
2676 refcount
= ID3D10RasterizerState_Release(d3d10_rast_state
);
2677 ok(refcount
== 2, "Got unexpected refcount %u.\n", refcount
);
2680 refcount
= ID3D11RasterizerState_Release(rast_state2
);
2681 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
2682 refcount
= ID3D11RasterizerState_Release(rast_state1
);
2683 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
2685 refcount
= ID3D11Device_Release(device
);
2686 ok(!refcount
, "Device has %u references left.\n", refcount
);
2689 static void test_create_predicate(void)
2691 static const D3D11_QUERY other_queries
[] =
2694 D3D11_QUERY_OCCLUSION
,
2695 D3D11_QUERY_TIMESTAMP
,
2696 D3D11_QUERY_TIMESTAMP_DISJOINT
,
2697 D3D11_QUERY_PIPELINE_STATISTICS
,
2698 D3D11_QUERY_SO_STATISTICS
,
2699 D3D11_QUERY_SO_STATISTICS_STREAM0
,
2700 D3D11_QUERY_SO_STATISTICS_STREAM1
,
2701 D3D11_QUERY_SO_STATISTICS_STREAM2
,
2702 D3D11_QUERY_SO_STATISTICS_STREAM3
,
2705 ULONG refcount
, expected_refcount
;
2706 D3D11_QUERY_DESC query_desc
;
2707 ID3D11Predicate
*predicate
;
2708 ID3D11Device
*device
, *tmp
;
2713 if (!(device
= create_device(NULL
)))
2715 skip("Failed to create device.\n");
2719 hr
= ID3D11Device_CreatePredicate(device
, NULL
, &predicate
);
2720 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
2722 query_desc
.MiscFlags
= 0;
2724 for (i
= 0; i
< sizeof(other_queries
) / sizeof(*other_queries
); ++i
)
2726 query_desc
.Query
= other_queries
[i
];
2727 hr
= ID3D11Device_CreatePredicate(device
, &query_desc
, &predicate
);
2728 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x for query type %u.\n", hr
, other_queries
[i
]);
2731 query_desc
.Query
= D3D11_QUERY_OCCLUSION_PREDICATE
;
2732 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
2733 hr
= ID3D11Device_CreatePredicate(device
, &query_desc
, &predicate
);
2734 ok(SUCCEEDED(hr
), "Failed to create predicate, hr %#x.\n", hr
);
2735 refcount
= get_refcount((IUnknown
*)device
);
2736 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2738 expected_refcount
= refcount
+ 1;
2739 ID3D11Predicate_GetDevice(predicate
, &tmp
);
2740 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2741 refcount
= get_refcount((IUnknown
*)device
);
2742 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2743 ID3D11Device_Release(tmp
);
2744 hr
= ID3D11Predicate_QueryInterface(predicate
, &IID_ID3D10Predicate
, (void **)&iface
);
2745 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
2746 "Predicate should implement ID3D10Predicate.\n");
2747 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
2748 ID3D11Predicate_Release(predicate
);
2750 query_desc
.Query
= D3D11_QUERY_SO_OVERFLOW_PREDICATE
;
2751 hr
= ID3D11Device_CreatePredicate(device
, &query_desc
, &predicate
);
2752 todo_wine
ok(SUCCEEDED(hr
), "Failed to create predicate, hr %#x.\n", hr
);
2754 ID3D11Predicate_Release(predicate
);
2756 refcount
= ID3D11Device_Release(device
);
2757 ok(!refcount
, "Device has %u references left.\n", refcount
);
2760 static void test_device_removed_reason(void)
2762 ID3D11Device
*device
;
2766 if (!(device
= create_device(NULL
)))
2768 skip("Failed to create device.\n");
2772 hr
= ID3D11Device_GetDeviceRemovedReason(device
);
2773 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2774 hr
= ID3D11Device_GetDeviceRemovedReason(device
);
2775 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2777 refcount
= ID3D11Device_Release(device
);
2778 ok(!refcount
, "Device has %u references left.\n", refcount
);
2781 static void test_private_data(void)
2783 ULONG refcount
, expected_refcount
;
2784 D3D11_TEXTURE2D_DESC texture_desc
;
2785 ID3D10Texture2D
*d3d10_texture
;
2786 ID3D11Device
*test_object
;
2787 ID3D11Texture2D
*texture
;
2788 IDXGIDevice
*dxgi_device
;
2789 IDXGISurface
*surface
;
2790 ID3D11Device
*device
;
2795 static const GUID test_guid
=
2796 {0xfdb37466, 0x428f, 0x4edf, {0xa3, 0x7f, 0x9b, 0x1d, 0xf4, 0x88, 0xc5, 0xfc}};
2797 static const GUID test_guid2
=
2798 {0x2e5afac2, 0x87b5, 0x4c10, {0x9b, 0x4b, 0x89, 0xd7, 0xd1, 0x12, 0xe7, 0x2b}};
2799 static const DWORD data
[] = {1, 2, 3, 4};
2801 if (!(device
= create_device(NULL
)))
2803 skip("Failed to create device.\n");
2807 test_object
= create_device(NULL
);
2809 texture_desc
.Width
= 512;
2810 texture_desc
.Height
= 512;
2811 texture_desc
.MipLevels
= 1;
2812 texture_desc
.ArraySize
= 1;
2813 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
2814 texture_desc
.SampleDesc
.Count
= 1;
2815 texture_desc
.SampleDesc
.Quality
= 0;
2816 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
2817 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
2818 texture_desc
.CPUAccessFlags
= 0;
2819 texture_desc
.MiscFlags
= 0;
2821 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
2822 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
2823 hr
= ID3D11Texture2D_QueryInterface(texture
, &IID_IDXGISurface
, (void **)&surface
);
2824 ok(SUCCEEDED(hr
), "Failed to get IDXGISurface, hr %#x.\n", hr
);
2826 hr
= ID3D11Device_SetPrivateData(device
, &test_guid
, 0, NULL
);
2827 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
2828 hr
= ID3D11Device_SetPrivateDataInterface(device
, &test_guid
, NULL
);
2829 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2830 hr
= ID3D11Device_SetPrivateData(device
, &test_guid
, ~0u, NULL
);
2831 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2832 hr
= ID3D11Device_SetPrivateData(device
, &test_guid
, ~0u, NULL
);
2833 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
2835 hr
= ID3D11Device_SetPrivateDataInterface(device
, &test_guid
, NULL
);
2836 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2837 size
= sizeof(ptr
) * 2;
2838 ptr
= (IUnknown
*)0xdeadbeef;
2839 hr
= ID3D11Device_GetPrivateData(device
, &test_guid
, &size
, &ptr
);
2840 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2841 ok(!ptr
, "Got unexpected pointer %p.\n", ptr
);
2842 ok(size
== sizeof(IUnknown
*), "Got unexpected size %u.\n", size
);
2844 hr
= ID3D11Device_QueryInterface(device
, &IID_IDXGIDevice
, (void **)&dxgi_device
);
2845 ok(SUCCEEDED(hr
), "Failed to get DXGI device, hr %#x.\n", hr
);
2846 size
= sizeof(ptr
) * 2;
2847 ptr
= (IUnknown
*)0xdeadbeef;
2848 hr
= IDXGIDevice_GetPrivateData(dxgi_device
, &test_guid
, &size
, &ptr
);
2849 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2850 ok(!ptr
, "Got unexpected pointer %p.\n", ptr
);
2851 ok(size
== sizeof(IUnknown
*), "Got unexpected size %u.\n", size
);
2852 IDXGIDevice_Release(dxgi_device
);
2854 refcount
= get_refcount((IUnknown
*)test_object
);
2855 hr
= ID3D11Device_SetPrivateDataInterface(device
, &test_guid
, (IUnknown
*)test_object
);
2856 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2857 expected_refcount
= refcount
+ 1;
2858 refcount
= get_refcount((IUnknown
*)test_object
);
2859 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2860 hr
= ID3D11Device_SetPrivateDataInterface(device
, &test_guid
, (IUnknown
*)test_object
);
2861 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2862 refcount
= get_refcount((IUnknown
*)test_object
);
2863 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2865 hr
= ID3D11Device_SetPrivateDataInterface(device
, &test_guid
, NULL
);
2866 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2867 --expected_refcount
;
2868 refcount
= get_refcount((IUnknown
*)test_object
);
2869 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2871 hr
= ID3D11Device_SetPrivateDataInterface(device
, &test_guid
, (IUnknown
*)test_object
);
2872 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2873 size
= sizeof(data
);
2874 hr
= ID3D11Device_SetPrivateData(device
, &test_guid
, size
, data
);
2875 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2876 refcount
= get_refcount((IUnknown
*)test_object
);
2877 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2878 hr
= ID3D11Device_SetPrivateData(device
, &test_guid
, 42, NULL
);
2879 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2880 hr
= ID3D11Device_SetPrivateData(device
, &test_guid
, 42, NULL
);
2881 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
2883 hr
= ID3D11Device_SetPrivateDataInterface(device
, &test_guid
, (IUnknown
*)test_object
);
2884 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2885 ++expected_refcount
;
2886 size
= 2 * sizeof(ptr
);
2888 hr
= ID3D11Device_GetPrivateData(device
, &test_guid
, &size
, &ptr
);
2889 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2890 ok(size
== sizeof(test_object
), "Got unexpected size %u.\n", size
);
2891 ++expected_refcount
;
2892 refcount
= get_refcount((IUnknown
*)test_object
);
2893 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2894 IUnknown_Release(ptr
);
2895 --expected_refcount
;
2897 ptr
= (IUnknown
*)0xdeadbeef;
2899 hr
= ID3D11Device_GetPrivateData(device
, &test_guid
, &size
, NULL
);
2900 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2901 ok(size
== sizeof(device
), "Got unexpected size %u.\n", size
);
2902 size
= 2 * sizeof(ptr
);
2903 hr
= ID3D11Device_GetPrivateData(device
, &test_guid
, &size
, NULL
);
2904 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2905 ok(size
== sizeof(device
), "Got unexpected size %u.\n", size
);
2906 refcount
= get_refcount((IUnknown
*)test_object
);
2907 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2910 hr
= ID3D11Device_GetPrivateData(device
, &test_guid
, &size
, &ptr
);
2911 ok(hr
== DXGI_ERROR_MORE_DATA
, "Got unexpected hr %#x.\n", hr
);
2912 ok(size
== sizeof(device
), "Got unexpected size %u.\n", size
);
2913 ok(ptr
== (IUnknown
*)0xdeadbeef, "Got unexpected pointer %p.\n", ptr
);
2914 hr
= ID3D11Device_GetPrivateData(device
, &test_guid2
, NULL
, NULL
);
2915 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
2917 hr
= ID3D11Device_GetPrivateData(device
, &test_guid2
, &size
, &ptr
);
2918 ok(hr
== DXGI_ERROR_NOT_FOUND
, "Got unexpected hr %#x.\n", hr
);
2919 ok(size
== 0, "Got unexpected size %u.\n", size
);
2920 ok(ptr
== (IUnknown
*)0xdeadbeef, "Got unexpected pointer %p.\n", ptr
);
2921 hr
= ID3D11Device_GetPrivateData(device
, &test_guid
, NULL
, &ptr
);
2922 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
2923 ok(ptr
== (IUnknown
*)0xdeadbeef, "Got unexpected pointer %p.\n", ptr
);
2925 hr
= ID3D11Texture2D_SetPrivateDataInterface(texture
, &test_guid
, (IUnknown
*)test_object
);
2926 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2929 hr
= IDXGISurface_GetPrivateData(surface
, &test_guid
, &size
, &ptr
);
2930 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2931 ok(ptr
== (IUnknown
*)test_object
, "Got unexpected ptr %p, expected %p.\n", ptr
, test_object
);
2932 IUnknown_Release(ptr
);
2934 hr
= ID3D11Texture2D_QueryInterface(texture
, &IID_ID3D10Texture2D
, (void **)&d3d10_texture
);
2935 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
2936 "Texture should implement ID3D10Texture2D.\n");
2941 hr
= ID3D10Texture2D_GetPrivateData(d3d10_texture
, &test_guid
, &size
, &ptr
);
2942 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2943 ok(ptr
== (IUnknown
*)test_object
, "Got unexpected ptr %p, expected %p.\n", ptr
, test_object
);
2944 IUnknown_Release(ptr
);
2945 ID3D10Texture2D_Release(d3d10_texture
);
2948 IDXGISurface_Release(surface
);
2949 ID3D11Texture2D_Release(texture
);
2950 refcount
= ID3D11Device_Release(device
);
2951 ok(!refcount
, "Device has %u references left.\n", refcount
);
2952 refcount
= ID3D11Device_Release(test_object
);
2953 ok(!refcount
, "Test object has %u references left.\n", refcount
);
2956 static void test_blend(void)
2958 ID3D11BlendState
*src_blend
, *dst_blend
;
2959 struct d3d11_test_context test_context
;
2960 ID3D11RenderTargetView
*offscreen_rtv
;
2961 D3D11_SUBRESOURCE_DATA buffer_data
;
2962 D3D11_TEXTURE2D_DESC texture_desc
;
2963 ID3D11InputLayout
*input_layout
;
2964 D3D11_BUFFER_DESC buffer_desc
;
2965 ID3D11DeviceContext
*context
;
2966 D3D11_BLEND_DESC blend_desc
;
2967 unsigned int stride
, offset
;
2968 ID3D11Texture2D
*offscreen
;
2969 ID3D11VertexShader
*vs
;
2970 ID3D11PixelShader
*ps
;
2971 ID3D11Device
*device
;
2977 static const DWORD vs_code
[] =
2982 float4 position
: SV_POSITION
;
2983 float4 color
: COLOR
;
2986 struct vs_out
main(float4 position
: POSITION
, float4 color
: COLOR
)
2990 o
.position
= position
;
2996 0x43425844, 0x5c73b061, 0x5c71125f, 0x3f8b345f, 0xce04b9ab, 0x00000001, 0x00000140, 0x00000003,
2997 0x0000002c, 0x0000007c, 0x000000d0, 0x4e475349, 0x00000048, 0x00000002, 0x00000008, 0x00000038,
2998 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
2999 0x00000003, 0x00000001, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x4e47534f,
3000 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003, 0x00000000,
3001 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x505f5653,
3002 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000068, 0x00010040, 0x0000001a,
3003 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067, 0x001020f2,
3004 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2, 0x00000000,
3005 0x00101e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001, 0x0100003e,
3007 static const DWORD ps_code
[] =
3012 float4 position
: SV_POSITION
;
3013 float4 color
: COLOR
;
3016 float4
main(struct vs_out i
) : SV_TARGET
3021 0x43425844, 0xe2087fa6, 0xa35fbd95, 0x8e585b3f, 0x67890f54, 0x00000001, 0x000000f4, 0x00000003,
3022 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
3023 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
3024 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
3025 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
3026 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040,
3027 0x0000000e, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
3028 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
3032 struct vec3 position
;
3038 {{-1.0f
, -1.0f
, 0.1f
}, 0x4000ff00},
3039 {{-1.0f
, 0.0f
, 0.1f
}, 0x4000ff00},
3040 {{ 1.0f
, -1.0f
, 0.1f
}, 0x4000ff00},
3041 {{ 1.0f
, 0.0f
, 0.1f
}, 0x4000ff00},
3043 {{-1.0f
, 0.0f
, 0.1f
}, 0xc0ff0000},
3044 {{-1.0f
, 1.0f
, 0.1f
}, 0xc0ff0000},
3045 {{ 1.0f
, 0.0f
, 0.1f
}, 0xc0ff0000},
3046 {{ 1.0f
, 1.0f
, 0.1f
}, 0xc0ff0000},
3048 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
3050 {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
3051 {"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, 12, D3D11_INPUT_PER_VERTEX_DATA
, 0},
3053 static const float blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
3054 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
3056 if (!init_test_context(&test_context
))
3059 device
= test_context
.device
;
3060 context
= test_context
.immediate_context
;
3062 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, sizeof(layout_desc
) / sizeof(*layout_desc
),
3063 vs_code
, sizeof(vs_code
), &input_layout
);
3064 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
3066 buffer_desc
.ByteWidth
= sizeof(quads
);
3067 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
3068 buffer_desc
.BindFlags
= D3D11_BIND_VERTEX_BUFFER
;
3069 buffer_desc
.CPUAccessFlags
= 0;
3070 buffer_desc
.MiscFlags
= 0;
3071 buffer_desc
.StructureByteStride
= 0;
3073 buffer_data
.pSysMem
= quads
;
3074 buffer_data
.SysMemPitch
= 0;
3075 buffer_data
.SysMemSlicePitch
= 0;
3077 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &buffer_data
, &vb
);
3078 ok(SUCCEEDED(hr
), "Failed to create vertex buffer, hr %#x.\n", hr
);
3079 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
3080 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
3081 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
3082 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
3084 memset(&blend_desc
, 0, sizeof(blend_desc
));
3085 blend_desc
.RenderTarget
[0].BlendEnable
= TRUE
;
3086 blend_desc
.RenderTarget
[0].SrcBlend
= D3D11_BLEND_SRC_ALPHA
;
3087 blend_desc
.RenderTarget
[0].DestBlend
= D3D11_BLEND_INV_SRC_ALPHA
;
3088 blend_desc
.RenderTarget
[0].BlendOp
= D3D11_BLEND_OP_ADD
;
3089 blend_desc
.RenderTarget
[0].SrcBlendAlpha
= D3D11_BLEND_SRC_ALPHA
;
3090 blend_desc
.RenderTarget
[0].DestBlendAlpha
= D3D11_BLEND_INV_SRC_ALPHA
;
3091 blend_desc
.RenderTarget
[0].BlendOpAlpha
= D3D11_BLEND_OP_ADD
;
3092 blend_desc
.RenderTarget
[0].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_ALL
;
3094 hr
= ID3D11Device_CreateBlendState(device
, &blend_desc
, &src_blend
);
3095 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
3097 blend_desc
.RenderTarget
[0].SrcBlend
= D3D11_BLEND_DEST_ALPHA
;
3098 blend_desc
.RenderTarget
[0].DestBlend
= D3D11_BLEND_INV_DEST_ALPHA
;
3099 blend_desc
.RenderTarget
[0].SrcBlendAlpha
= D3D11_BLEND_DEST_ALPHA
;
3100 blend_desc
.RenderTarget
[0].DestBlendAlpha
= D3D11_BLEND_INV_DEST_ALPHA
;
3102 hr
= ID3D11Device_CreateBlendState(device
, &blend_desc
, &dst_blend
);
3103 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
3105 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
3106 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
3107 stride
= sizeof(*quads
);
3109 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, &stride
, &offset
);
3110 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
3111 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
3113 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
3115 ID3D11DeviceContext_OMSetBlendState(context
, src_blend
, blend_factor
, D3D11_DEFAULT_SAMPLE_MASK
);
3116 ID3D11DeviceContext_Draw(context
, 4, 0);
3117 ID3D11DeviceContext_OMSetBlendState(context
, dst_blend
, blend_factor
, D3D11_DEFAULT_SAMPLE_MASK
);
3118 ID3D11DeviceContext_Draw(context
, 4, 4);
3120 color
= get_texture_color(test_context
.backbuffer
, 320, 360);
3121 ok(compare_color(color
, 0x700040bf, 1), "Got unexpected color 0x%08x.\n", color
);
3122 color
= get_texture_color(test_context
.backbuffer
, 320, 120);
3123 ok(compare_color(color
, 0xa080007f, 1), "Got unexpected color 0x%08x.\n", color
);
3125 texture_desc
.Width
= 128;
3126 texture_desc
.Height
= 128;
3127 texture_desc
.MipLevels
= 1;
3128 texture_desc
.ArraySize
= 1;
3129 texture_desc
.Format
= DXGI_FORMAT_B8G8R8X8_UNORM
;
3130 texture_desc
.SampleDesc
.Count
= 1;
3131 texture_desc
.SampleDesc
.Quality
= 0;
3132 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
3133 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
| D3D11_BIND_RENDER_TARGET
;
3134 texture_desc
.CPUAccessFlags
= 0;
3135 texture_desc
.MiscFlags
= 0;
3137 /* DXGI_FORMAT_B8G8R8X8_UNORM is not supported on all implementations. */
3138 if (FAILED(ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &offscreen
)))
3140 skip("DXGI_FORMAT_B8G8R8X8_UNORM not supported.\n");
3144 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)offscreen
, NULL
, &offscreen_rtv
);
3145 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
3147 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &offscreen_rtv
, NULL
);
3155 ID3D11DeviceContext_RSSetViewports(context
, 1, &vp
);
3157 ID3D11DeviceContext_ClearRenderTargetView(context
, offscreen_rtv
, red
);
3159 ID3D11DeviceContext_OMSetBlendState(context
, src_blend
, blend_factor
, D3D11_DEFAULT_SAMPLE_MASK
);
3160 ID3D11DeviceContext_Draw(context
, 4, 0);
3161 ID3D11DeviceContext_OMSetBlendState(context
, dst_blend
, blend_factor
, D3D11_DEFAULT_SAMPLE_MASK
);
3162 ID3D11DeviceContext_Draw(context
, 4, 4);
3164 color
= get_texture_color(offscreen
, 64, 96) & 0x00ffffff;
3165 ok(compare_color(color
, 0x00bf4000, 1), "Got unexpected color 0x%08x.\n", color
);
3166 color
= get_texture_color(offscreen
, 64, 32) & 0x00ffffff;
3167 ok(compare_color(color
, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color
);
3169 ID3D11RenderTargetView_Release(offscreen_rtv
);
3170 ID3D11Texture2D_Release(offscreen
);
3172 ID3D11BlendState_Release(dst_blend
);
3173 ID3D11BlendState_Release(src_blend
);
3174 ID3D11PixelShader_Release(ps
);
3175 ID3D11VertexShader_Release(vs
);
3176 ID3D11Buffer_Release(vb
);
3177 ID3D11InputLayout_Release(input_layout
);
3178 release_test_context(&test_context
);
3181 static void test_texture(void)
3192 UINT miplevel_count
;
3194 D3D11_SUBRESOURCE_DATA data
[3];
3197 struct d3d11_test_context test_context
;
3198 const struct texture
*current_texture
;
3199 D3D11_TEXTURE2D_DESC texture_desc
;
3200 D3D11_SAMPLER_DESC sampler_desc
;
3201 const struct shader
*current_ps
;
3202 ID3D11ShaderResourceView
*srv
;
3203 D3D11_BUFFER_DESC buffer_desc
;
3204 ID3D11DeviceContext
*context
;
3205 ID3D11SamplerState
*sampler
;
3206 struct texture_readback rb
;
3207 ID3D11Texture2D
*texture
;
3208 ID3D11PixelShader
*ps
;
3209 ID3D11Device
*device
;
3210 unsigned int i
, x
, y
;
3211 struct vec4 miplevel
;
3216 static const DWORD ps_ld_code
[] =
3223 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
3226 t
.GetDimensions(miplevel
, p
.x
, p
.y
, p
.z
);
3228 p
*= float3(position
.x
/ 640.0f
, position
.y
/ 480.0f
, 1.0f
);
3229 return t
.Load(int3(p
));
3232 0x43425844, 0xbdda6bdf, 0xc6ffcdf1, 0xa58596b3, 0x822383f0, 0x00000001, 0x000001ac, 0x00000003,
3233 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
3234 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
3235 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
3236 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000110, 0x00000040,
3237 0x00000044, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04001858, 0x00107000, 0x00000000,
3238 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
3239 0x02000068, 0x00000001, 0x0600001c, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000,
3240 0x0700003d, 0x001000f2, 0x00000000, 0x0010000a, 0x00000000, 0x00107e46, 0x00000000, 0x07000038,
3241 0x00100032, 0x00000000, 0x00100046, 0x00000000, 0x00101046, 0x00000000, 0x06000036, 0x001000c2,
3242 0x00000000, 0x00208006, 0x00000000, 0x00000000, 0x0a000038, 0x001000f2, 0x00000000, 0x00100e46,
3243 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x3f800000, 0x3f800000, 0x0500001b, 0x001000f2,
3244 0x00000000, 0x00100e46, 0x00000000, 0x0700002d, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
3245 0x00107e46, 0x00000000, 0x0100003e,
3247 static const DWORD ps_ld_sint8_code
[] =
3252 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
3257 p
= float3(position
.x
/ 640.0f
, position
.y
/ 480.0f
, 0.0f
);
3258 t
.GetDimensions(0, s
.x
, s
.y
, s
.z
);
3261 c
= t
.Load(int3(p
));
3262 return (max(c
/ (float4
)127, (float4
)-1) + (float4
)1) / 2.0f
;
3265 0x43425844, 0xb3d0b0fc, 0x0e486f4a, 0xf67eec12, 0xfb9dd52f, 0x00000001, 0x00000240, 0x00000003,
3266 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
3267 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
3268 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
3269 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000001a4, 0x00000040,
3270 0x00000069, 0x04001858, 0x00107000, 0x00000000, 0x00003333, 0x04002064, 0x00101032, 0x00000000,
3271 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x0700003d, 0x001000f2,
3272 0x00000000, 0x00004001, 0x00000000, 0x00107e46, 0x00000000, 0x0a000038, 0x00100032, 0x00000001,
3273 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x08000036,
3274 0x001000c2, 0x00000001, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07000038,
3275 0x001000f2, 0x00000000, 0x00100f46, 0x00000000, 0x00100e46, 0x00000001, 0x0500001b, 0x001000f2,
3276 0x00000000, 0x00100e46, 0x00000000, 0x0700002d, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
3277 0x00107e46, 0x00000000, 0x0500002b, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x0a000038,
3278 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3c010204, 0x3c010204, 0x3c010204,
3279 0x3c010204, 0x0a000034, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0xbf800000,
3280 0xbf800000, 0xbf800000, 0xbf800000, 0x0a000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
3281 0x00004002, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000, 0x0a000038, 0x001020f2, 0x00000000,
3282 0x00100e46, 0x00000000, 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, 0x0100003e,
3284 static const DWORD ps_ld_uint8_code
[] =
3289 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
3293 p
= float3(position
.x
/ 640.0f
, position
.y
/ 480.0f
, 0.0f
);
3294 t
.GetDimensions(0, s
.x
, s
.y
, s
.z
);
3297 return t
.Load(int3(p
)) / (float4
)255;
3300 0x43425844, 0xd09917eb, 0x4508a07e, 0xb0b7250a, 0x228c1f0e, 0x00000001, 0x000001c8, 0x00000003,
3301 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
3302 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
3303 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
3304 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x0000012c, 0x00000040,
3305 0x0000004b, 0x04001858, 0x00107000, 0x00000000, 0x00004444, 0x04002064, 0x00101032, 0x00000000,
3306 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x0700003d, 0x001000f2,
3307 0x00000000, 0x00004001, 0x00000000, 0x00107e46, 0x00000000, 0x0a000038, 0x00100032, 0x00000001,
3308 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x08000036,
3309 0x001000c2, 0x00000001, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07000038,
3310 0x001000f2, 0x00000000, 0x00100f46, 0x00000000, 0x00100e46, 0x00000001, 0x0500001b, 0x001000f2,
3311 0x00000000, 0x00100e46, 0x00000000, 0x0700002d, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
3312 0x00107e46, 0x00000000, 0x05000056, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x0a000038,
3313 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3b808081, 0x3b808081, 0x3b808081,
3314 0x3b808081, 0x0100003e,
3316 static const DWORD ps_sample_code
[] =
3322 float4
main(float4 position
: SV_POSITION
) : SV_Target
3326 p
.x
= position
.x
/ 640.0f
;
3327 p
.y
= position
.y
/ 480.0f
;
3328 return t
.Sample(s
, p
);
3331 0x43425844, 0x1ce9b612, 0xc8176faa, 0xd37844af, 0xdb515605, 0x00000001, 0x00000134, 0x00000003,
3332 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
3333 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
3334 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
3335 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
3336 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
3337 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
3338 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
3339 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
3340 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
3342 static const DWORD ps_sample_b_code
[] =
3350 float4
main(float4 position
: SV_POSITION
) : SV_Target
3354 p
.x
= position
.x
/ 640.0f
;
3355 p
.y
= position
.y
/ 480.0f
;
3356 return t
.SampleBias(s
, p
, bias
);
3359 0x43425844, 0xc39b0686, 0x8244a7fc, 0x14c0b97a, 0x2900b3b7, 0x00000001, 0x00000150, 0x00000003,
3360 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
3361 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
3362 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
3363 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000b4, 0x00000040,
3364 0x0000002d, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000, 0x00000000,
3365 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001,
3366 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0a000038, 0x00100032, 0x00000000,
3367 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x0c00004a,
3368 0x001020f2, 0x00000000, 0x00100046, 0x00000000, 0x00107e46, 0x00000000, 0x00106000, 0x00000000,
3369 0x0020800a, 0x00000000, 0x00000000, 0x0100003e,
3371 static const DWORD ps_sample_l_code
[] =
3379 float4
main(float4 position
: SV_POSITION
) : SV_Target
3383 p
.x
= position
.x
/ 640.0f
;
3384 p
.y
= position
.y
/ 480.0f
;
3385 return t
.SampleLevel(s
, p
, level
);
3388 0x43425844, 0x61e05d85, 0x2a7300fb, 0x0a83706b, 0x889d1683, 0x00000001, 0x00000150, 0x00000003,
3389 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
3390 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
3391 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
3392 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000b4, 0x00000040,
3393 0x0000002d, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000, 0x00000000,
3394 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001,
3395 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0a000038, 0x00100032, 0x00000000,
3396 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x0c000048,
3397 0x001020f2, 0x00000000, 0x00100046, 0x00000000, 0x00107e46, 0x00000000, 0x00106000, 0x00000000,
3398 0x0020800a, 0x00000000, 0x00000000, 0x0100003e,
3400 static const struct shader ps_ld
= {ps_ld_code
, sizeof(ps_ld_code
)};
3401 static const struct shader ps_ld_sint8
= {ps_ld_sint8_code
, sizeof(ps_ld_sint8_code
)};
3402 static const struct shader ps_ld_uint8
= {ps_ld_uint8_code
, sizeof(ps_ld_uint8_code
)};
3403 static const struct shader ps_sample
= {ps_sample_code
, sizeof(ps_sample_code
)};
3404 static const struct shader ps_sample_b
= {ps_sample_b_code
, sizeof(ps_sample_b_code
)};
3405 static const struct shader ps_sample_l
= {ps_sample_l_code
, sizeof(ps_sample_l_code
)};
3406 static const DWORD rgba_level_0
[] =
3408 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
3409 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
3410 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
3411 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
3413 static const DWORD rgba_level_1
[] =
3415 0xffffffff, 0xff0000ff,
3416 0xff000000, 0xff00ff00,
3418 static const DWORD rgba_level_2
[] =
3422 static const DWORD srgb_data
[] =
3424 0x00000000, 0xffffffff, 0xff000000, 0x7f7f7f7f,
3425 0xff010203, 0xff102030, 0xff0a0b0c, 0xff8090a0,
3426 0xffb1c4de, 0xfff0f1f2, 0xfffafdfe, 0xff5a560f,
3427 0xffd5ff00, 0xffc8f99f, 0xffaa00aa, 0xffdd55bb,
3429 static const BYTE bc1_data
[] =
3431 0x00, 0xf8, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
3432 0xe0, 0x07, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00,
3433 0x1f, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
3434 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
3436 static const BYTE bc2_data
[] =
3438 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf8, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
3439 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x07, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00,
3440 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
3441 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
3443 static const BYTE bc3_data
[] =
3445 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
3446 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00,
3447 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
3448 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
3450 static const BYTE bc4_data
[] =
3452 0x10, 0x7f, 0x77, 0x39, 0x05, 0x00, 0x00, 0x00,
3453 0x10, 0x7f, 0x49, 0x92, 0x24, 0x49, 0x92, 0x24,
3454 0x10, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3455 0x10, 0x7f, 0xb6, 0x6d, 0xdb, 0xb6, 0x6d, 0xdb,
3457 static const BYTE bc5_data
[] =
3459 0x10, 0x7f, 0x77, 0x39, 0x05, 0x00, 0x00, 0x00, 0x10, 0x7f, 0x77, 0x39, 0x05, 0x00, 0x00, 0x00,
3460 0x10, 0x7f, 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0x10, 0x7f, 0x49, 0x92, 0x24, 0x49, 0x92, 0x24,
3461 0x10, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x10, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3462 0x10, 0x7f, 0xb6, 0x6d, 0xdb, 0xb6, 0x6d, 0xdb, 0x10, 0x7f, 0xb6, 0x6d, 0xdb, 0xb6, 0x6d, 0xdb,
3464 static const struct texture rgba_texture
=
3466 4, 4, 3, DXGI_FORMAT_R8G8B8A8_UNORM
,
3468 {rgba_level_0
, 4 * sizeof(*rgba_level_0
), 0},
3469 {rgba_level_1
, 2 * sizeof(*rgba_level_1
), 0},
3470 {rgba_level_2
, sizeof(*rgba_level_2
), 0},
3473 static const struct texture srgb_texture
= {4, 4, 1, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
3474 {{srgb_data
, 4 * sizeof(*srgb_data
)}}};
3475 static const struct texture bc1_texture
= {8, 8, 1, DXGI_FORMAT_BC1_UNORM
, {{bc1_data
, 2 * 8}}};
3476 static const struct texture bc2_texture
= {8, 8, 1, DXGI_FORMAT_BC2_UNORM
, {{bc2_data
, 2 * 16}}};
3477 static const struct texture bc3_texture
= {8, 8, 1, DXGI_FORMAT_BC3_UNORM
, {{bc3_data
, 2 * 16}}};
3478 static const struct texture bc4_texture
= {8, 8, 1, DXGI_FORMAT_BC4_UNORM
, {{bc4_data
, 2 * 8}}};
3479 static const struct texture bc5_texture
= {8, 8, 1, DXGI_FORMAT_BC5_UNORM
, {{bc5_data
, 2 * 16}}};
3480 static const struct texture bc1_texture_srgb
= {8, 8, 1, DXGI_FORMAT_BC1_UNORM_SRGB
, {{bc1_data
, 2 * 8}}};
3481 static const struct texture bc2_texture_srgb
= {8, 8, 1, DXGI_FORMAT_BC2_UNORM_SRGB
, {{bc2_data
, 2 * 16}}};
3482 static const struct texture bc3_texture_srgb
= {8, 8, 1, DXGI_FORMAT_BC3_UNORM_SRGB
, {{bc3_data
, 2 * 16}}};
3483 static const struct texture sint8_texture
= {4, 4, 1, DXGI_FORMAT_R8G8B8A8_SINT
,
3484 {{rgba_level_0
, 4 * sizeof(*rgba_level_0
)}}};
3485 static const struct texture uint8_texture
= {4, 4, 1, DXGI_FORMAT_R8G8B8A8_UINT
,
3486 {{rgba_level_0
, 4 * sizeof(*rgba_level_0
)}}};
3487 static const DWORD level_1_colors
[] =
3489 0xffffffff, 0xffffffff, 0xff0000ff, 0xff0000ff,
3490 0xffffffff, 0xffffffff, 0xff0000ff, 0xff0000ff,
3491 0xff000000, 0xff000000, 0xff00ff00, 0xff00ff00,
3492 0xff000000, 0xff000000, 0xff00ff00, 0xff00ff00,
3494 static const DWORD lerp_1_2_colors
[] =
3496 0xffff7f7f, 0xffff7f7f, 0xff7f007f, 0xff7f007f,
3497 0xffff7f7f, 0xffff7f7f, 0xff7f007f, 0xff7f007f,
3498 0xff7f0000, 0xff7f0000, 0xff7f7f00, 0xff7f7f00,
3499 0xff7f0000, 0xff7f0000, 0xff7f7f00, 0xff7f7f00,
3501 static const DWORD level_2_colors
[] =
3503 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
3504 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
3505 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
3506 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
3508 static const DWORD srgb_colors
[] =
3510 0x00000001, 0xffffffff, 0xff000000, 0x7f363636,
3511 0xff000000, 0xff010408, 0xff010101, 0xff37475a,
3512 0xff708cba, 0xffdee0e2, 0xfff3fbfd, 0xff1a1801,
3513 0xffa9ff00, 0xff93f159, 0xff670067, 0xffb8177f,
3515 static const DWORD bc_colors
[] =
3517 0xff0000ff, 0xff0000ff, 0xff00ff00, 0xff00ff00,
3518 0xff0000ff, 0xff0000ff, 0xff00ff00, 0xff00ff00,
3519 0xffff0000, 0xffff0000, 0xffffffff, 0xffffffff,
3520 0xffff0000, 0xffff0000, 0xffffffff, 0xffffffff,
3522 static const DWORD bc4_colors
[] =
3524 0xff000026, 0xff000010, 0xff00007f, 0xff00007f,
3525 0xff000010, 0xff000010, 0xff00007f, 0xff00007f,
3526 0xff0000ff, 0xff0000ff, 0xff000000, 0xff000000,
3527 0xff0000ff, 0xff0000ff, 0xff000000, 0xff000000,
3529 static const DWORD bc5_colors
[] =
3531 0xff002626, 0xff001010, 0xff007f7f, 0xff007f7f,
3532 0xff001010, 0xff001010, 0xff007f7f, 0xff007f7f,
3533 0xff00ffff, 0xff00ffff, 0xff000000, 0xff000000,
3534 0xff00ffff, 0xff00ffff, 0xff000000, 0xff000000,
3536 static const DWORD sint8_colors
[] =
3538 0x7e80807e, 0x7e807e7e, 0x7e807e80, 0x7e7e7e80,
3539 0x7e7e8080, 0x7e7e7f7f, 0x7e808080, 0x7effffff,
3540 0x7e7e7e7e, 0x7e7e7e7e, 0x7e7e7e7e, 0x7e808080,
3541 0x7e7e7e7e, 0x7e7f7f7f, 0x7e7f7f7f, 0x7e7f7f7f,
3543 static const DWORD zero_colors
[4 * 4] = {0};
3544 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
3546 static const struct test
3548 const struct shader
*ps
;
3549 const struct texture
*texture
;
3550 D3D11_FILTER filter
;
3555 const DWORD
*expected_colors
;
3559 {&ps_ld
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, rgba_level_0
},
3560 {&ps_ld
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, level_1_colors
},
3561 {&ps_ld
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 2.0f
, level_2_colors
},
3562 {&ps_ld
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 3.0f
, zero_colors
},
3563 {&ps_ld
, &srgb_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, srgb_colors
},
3564 {&ps_ld
, &bc1_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
3565 {&ps_ld
, &bc1_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, zero_colors
},
3566 {&ps_ld
, &bc2_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
3567 {&ps_ld
, &bc2_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, zero_colors
},
3568 {&ps_ld
, &bc3_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
3569 {&ps_ld
, &bc3_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, zero_colors
},
3570 {&ps_ld
, &bc1_texture_srgb
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
3571 {&ps_ld
, &bc2_texture_srgb
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
3572 {&ps_ld
, &bc3_texture_srgb
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
3573 {&ps_ld
, &bc4_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc4_colors
},
3574 {&ps_ld
, &bc5_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc5_colors
},
3575 {&ps_ld_sint8
, &sint8_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, sint8_colors
},
3576 {&ps_ld_uint8
, &uint8_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, rgba_level_0
},
3577 {&ps_sample
, &bc1_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
3578 {&ps_sample
, &bc2_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
3579 {&ps_sample
, &bc3_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
3580 {&ps_sample
, &bc4_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc4_colors
},
3581 {&ps_sample
, &bc5_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc5_colors
},
3582 {&ps_sample
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, rgba_level_0
},
3583 {&ps_sample
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, D3D11_FLOAT32_MAX
, 0.0f
, rgba_level_0
},
3584 {&ps_sample
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 2.0f
, 0.0f
, D3D11_FLOAT32_MAX
, 0.0f
, rgba_level_0
},
3585 {&ps_sample
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 8.0f
, 0.0f
, D3D11_FLOAT32_MAX
, 0.0f
, level_1_colors
},
3586 {&ps_sample
, &srgb_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, srgb_colors
},
3587 {&ps_sample_b
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, D3D11_FLOAT32_MAX
, 0.0f
, rgba_level_0
},
3588 {&ps_sample_b
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 8.0f
, 0.0f
, D3D11_FLOAT32_MAX
, 0.0f
, level_1_colors
},
3589 {&ps_sample_b
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, D3D11_FLOAT32_MAX
, 8.0f
, level_1_colors
},
3590 {&ps_sample_b
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, D3D11_FLOAT32_MAX
, 8.4f
, level_1_colors
},
3591 {&ps_sample_b
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, D3D11_FLOAT32_MAX
, 8.5f
, level_2_colors
},
3592 {&ps_sample_b
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, D3D11_FLOAT32_MAX
, 9.0f
, level_2_colors
},
3593 {&ps_sample_b
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 2.0f
, 1.0f
, rgba_level_0
},
3594 {&ps_sample_b
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 2.0f
, 9.0f
, level_2_colors
},
3595 {&ps_sample_b
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 1.0f
, 9.0f
, level_1_colors
},
3596 {&ps_sample_b
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, 0.0f
, 9.0f
, rgba_level_0
},
3597 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, D3D11_FLOAT32_MAX
, -1.0f
, rgba_level_0
},
3598 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, D3D11_FLOAT32_MAX
, 0.0f
, rgba_level_0
},
3599 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, D3D11_FLOAT32_MAX
, 0.4f
, rgba_level_0
},
3600 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, D3D11_FLOAT32_MAX
, 0.5f
, level_1_colors
},
3601 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, D3D11_FLOAT32_MAX
, 1.0f
, level_1_colors
},
3602 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, D3D11_FLOAT32_MAX
, 1.4f
, level_1_colors
},
3603 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, D3D11_FLOAT32_MAX
, 1.5f
, level_2_colors
},
3604 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, D3D11_FLOAT32_MAX
, 2.0f
, level_2_colors
},
3605 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, D3D11_FLOAT32_MAX
, 3.0f
, level_2_colors
},
3606 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 0.0f
, 0.0f
, D3D11_FLOAT32_MAX
, 4.0f
, level_2_colors
},
3607 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR
, 0.0f
, 0.0f
, D3D11_FLOAT32_MAX
, 1.5f
, lerp_1_2_colors
},
3608 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR
, 2.0f
, 0.0f
, D3D11_FLOAT32_MAX
, -2.0f
, rgba_level_0
},
3609 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR
, 2.0f
, 0.0f
, D3D11_FLOAT32_MAX
, -1.0f
, level_1_colors
},
3610 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR
, 2.0f
, 0.0f
, D3D11_FLOAT32_MAX
, 0.0f
, level_2_colors
},
3611 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR
, 2.0f
, 0.0f
, D3D11_FLOAT32_MAX
, 1.0f
, level_2_colors
},
3612 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR
, 2.0f
, 0.0f
, D3D11_FLOAT32_MAX
, 1.5f
, level_2_colors
},
3613 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR
, 2.0f
, 2.0f
, 2.0f
, -9.0f
, level_2_colors
},
3614 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR
, 2.0f
, 2.0f
, 2.0f
, -1.0f
, level_2_colors
},
3615 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR
, 2.0f
, 2.0f
, 2.0f
, 0.0f
, level_2_colors
},
3616 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR
, 2.0f
, 2.0f
, 2.0f
, 1.0f
, level_2_colors
},
3617 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR
, 2.0f
, 2.0f
, 2.0f
, 9.0f
, level_2_colors
},
3618 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 2.0f
, 2.0f
, 2.0f
, -9.0f
, level_2_colors
},
3619 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 2.0f
, 2.0f
, 2.0f
, -1.0f
, level_2_colors
},
3620 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 2.0f
, 2.0f
, 2.0f
, 0.0f
, level_2_colors
},
3621 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 2.0f
, 2.0f
, 2.0f
, 1.0f
, level_2_colors
},
3622 {&ps_sample_l
, &rgba_texture
, D3D11_FILTER_MIN_MAG_MIP_POINT
, 2.0f
, 2.0f
, 2.0f
, 9.0f
, level_2_colors
},
3625 if (!init_test_context(&test_context
))
3628 device
= test_context
.device
;
3629 context
= test_context
.immediate_context
;
3631 buffer_desc
.ByteWidth
= sizeof(miplevel
);
3632 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
3633 buffer_desc
.BindFlags
= D3D11_BIND_CONSTANT_BUFFER
;
3634 buffer_desc
.CPUAccessFlags
= 0;
3635 buffer_desc
.MiscFlags
= 0;
3636 buffer_desc
.StructureByteStride
= 0;
3638 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &cb
);
3639 ok(SUCCEEDED(hr
), "Failed to create constant buffer, hr %#x.\n", hr
);
3641 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
3643 texture_desc
.Width
= 4;
3644 texture_desc
.Height
= 4;
3645 texture_desc
.MipLevels
= 3;
3646 texture_desc
.ArraySize
= 1;
3647 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
3648 texture_desc
.SampleDesc
.Count
= 1;
3649 texture_desc
.SampleDesc
.Quality
= 0;
3650 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
3651 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
3652 texture_desc
.CPUAccessFlags
= 0;
3653 texture_desc
.MiscFlags
= 0;
3655 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
3656 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
3657 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
3658 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
3659 sampler_desc
.MipLODBias
= 0.0f
;
3660 sampler_desc
.MaxAnisotropy
= 0;
3661 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
3662 sampler_desc
.BorderColor
[0] = 0.0f
;
3663 sampler_desc
.BorderColor
[1] = 0.0f
;
3664 sampler_desc
.BorderColor
[2] = 0.0f
;
3665 sampler_desc
.BorderColor
[3] = 0.0f
;
3666 sampler_desc
.MinLOD
= 0.0f
;
3667 sampler_desc
.MaxLOD
= D3D11_FLOAT32_MAX
;
3674 current_texture
= NULL
;
3675 for (i
= 0; i
< sizeof(tests
) / sizeof(*tests
); ++i
)
3677 const struct test
*test
= &tests
[i
];
3679 if (current_ps
!= test
->ps
)
3682 ID3D11PixelShader_Release(ps
);
3684 current_ps
= test
->ps
;
3686 hr
= ID3D11Device_CreatePixelShader(device
, current_ps
->code
, current_ps
->size
, NULL
, &ps
);
3687 ok(SUCCEEDED(hr
), "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
3689 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
3692 if (current_texture
!= test
->texture
)
3695 ID3D11Texture2D_Release(texture
);
3697 ID3D11ShaderResourceView_Release(srv
);
3699 current_texture
= test
->texture
;
3701 texture_desc
.Width
= current_texture
->width
;
3702 texture_desc
.Height
= current_texture
->height
;
3703 texture_desc
.MipLevels
= current_texture
->miplevel_count
;
3704 texture_desc
.Format
= current_texture
->format
;
3706 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, current_texture
->data
, &texture
);
3707 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
3709 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
3710 ok(SUCCEEDED(hr
), "Test %u: Failed to create shader resource view, hr %#x.\n", i
, hr
);
3712 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
3715 if (!sampler
|| (sampler_desc
.Filter
!= test
->filter
3716 || sampler_desc
.MipLODBias
!= test
->lod_bias
3717 || sampler_desc
.MinLOD
!= test
->min_lod
3718 || sampler_desc
.MaxLOD
!= test
->max_lod
))
3721 ID3D11SamplerState_Release(sampler
);
3723 sampler_desc
.Filter
= test
->filter
;
3724 sampler_desc
.MipLODBias
= test
->lod_bias
;
3725 sampler_desc
.MinLOD
= test
->min_lod
;
3726 sampler_desc
.MaxLOD
= test
->max_lod
;
3728 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler
);
3729 ok(SUCCEEDED(hr
), "Test %u: Failed to create sampler state, hr %#x.\n", i
, hr
);
3731 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler
);
3734 miplevel
.x
= test
->miplevel
;
3735 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &miplevel
, 0, 0);
3737 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
3739 draw_quad(&test_context
);
3741 get_texture_readback(test_context
.backbuffer
, &rb
);
3742 for (x
= 0; x
< 4; ++x
)
3744 for (y
= 0; y
< 4; ++y
)
3746 color
= get_readback_color(&rb
, 80 + x
* 160, 60 + y
* 120);
3747 ok(compare_color(color
, test
->expected_colors
[y
* 4 + x
], 1),
3748 "Test %u: Got unexpected color 0x%08x at (%u, %u).\n", i
, color
, x
, y
);
3751 release_texture_readback(&rb
);
3753 ID3D11ShaderResourceView_Release(srv
);
3754 ID3D11SamplerState_Release(sampler
);
3755 ID3D11Texture2D_Release(texture
);
3756 ID3D11PixelShader_Release(ps
);
3758 ID3D11Buffer_Release(cb
);
3759 release_test_context(&test_context
);
3762 static void test_multiple_render_targets(void)
3764 D3D11_SUBRESOURCE_DATA resource_data
;
3765 D3D11_TEXTURE2D_DESC texture_desc
;
3766 ID3D11InputLayout
*input_layout
;
3767 unsigned int stride
, offset
, i
;
3768 ID3D11RenderTargetView
*rtv
[4];
3769 D3D11_BUFFER_DESC buffer_desc
;
3770 ID3D11DeviceContext
*context
;
3771 ID3D11Texture2D
*rt
[4];
3772 ID3D11VertexShader
*vs
;
3773 ID3D11PixelShader
*ps
;
3774 ID3D11Device
*device
;
3780 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
3782 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
3784 static const DWORD vs_code
[] =
3787 float4
main(float4 position
: POSITION
) : SV_POSITION
3792 0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003,
3793 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
3794 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
3795 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
3796 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
3797 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
3798 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
3800 static const DWORD ps_code
[] =
3805 float4 t1
: SV_TARGET0
;
3806 float4 t2
: SV_Target1
;
3807 float4 t3
: SV_TARGET2
;
3808 float4 t4
: SV_Target3
;
3811 output
main(float4 position
: SV_POSITION
)
3814 o
.t1
= (float4
)1.0f
;
3815 o
.t2
= (float4
)0.5f
;
3816 o
.t3
= (float4
)0.2f
;
3817 o
.t4
= float4(0.0f
, 0.2f
, 0.5f
, 1.0f
);
3821 0x43425844, 0x8701ad18, 0xe3d5291d, 0x7b4288a6, 0x01917515, 0x00000001, 0x000001a8, 0x00000003,
3822 0x0000002c, 0x00000060, 0x000000e4, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
3823 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
3824 0x4e47534f, 0x0000007c, 0x00000004, 0x00000008, 0x00000068, 0x00000000, 0x00000000, 0x00000003,
3825 0x00000000, 0x0000000f, 0x00000072, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
3826 0x00000068, 0x00000002, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x00000072, 0x00000003,
3827 0x00000000, 0x00000003, 0x00000003, 0x0000000f, 0x545f5653, 0x45475241, 0x56530054, 0x7261545f,
3828 0x00746567, 0x52444853, 0x000000bc, 0x00000040, 0x0000002f, 0x03000065, 0x001020f2, 0x00000000,
3829 0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x03000065, 0x001020f2,
3830 0x00000003, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x3f800000, 0x3f800000,
3831 0x3f800000, 0x08000036, 0x001020f2, 0x00000001, 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000,
3832 0x3f000000, 0x08000036, 0x001020f2, 0x00000002, 0x00004002, 0x3e4ccccd, 0x3e4ccccd, 0x3e4ccccd,
3833 0x3e4ccccd, 0x08000036, 0x001020f2, 0x00000003, 0x00004002, 0x00000000, 0x3e4ccccd, 0x3f000000,
3834 0x3f800000, 0x0100003e,
3838 struct vec2 position
;
3847 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 1.0f
};
3849 if (!(device
= create_device(NULL
)))
3851 skip("Failed to create device.\n");
3855 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, sizeof(layout_desc
) / sizeof(*layout_desc
),
3856 vs_code
, sizeof(vs_code
), &input_layout
);
3857 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
3859 buffer_desc
.ByteWidth
= sizeof(quad
);
3860 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
3861 buffer_desc
.BindFlags
= D3D11_BIND_VERTEX_BUFFER
;
3862 buffer_desc
.CPUAccessFlags
= 0;
3863 buffer_desc
.MiscFlags
= 0;
3864 buffer_desc
.StructureByteStride
= 0;
3866 resource_data
.pSysMem
= quad
;
3867 resource_data
.SysMemPitch
= 0;
3868 resource_data
.SysMemSlicePitch
= 0;
3870 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &resource_data
, &vb
);
3871 ok(SUCCEEDED(hr
), "Failed to create vertex buffer, hr %#x.\n", hr
);
3873 texture_desc
.Width
= 640;
3874 texture_desc
.Height
= 480;
3875 texture_desc
.MipLevels
= 1;
3876 texture_desc
.ArraySize
= 1;
3877 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
3878 texture_desc
.SampleDesc
.Count
= 1;
3879 texture_desc
.SampleDesc
.Quality
= 0;
3880 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
3881 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
3882 texture_desc
.CPUAccessFlags
= 0;
3883 texture_desc
.MiscFlags
= 0;
3885 for (i
= 0; i
< sizeof(rt
) / sizeof(*rt
); ++i
)
3887 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rt
[i
]);
3888 ok(SUCCEEDED(hr
), "Failed to create texture %u, hr %#x.\n", i
, hr
);
3890 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rt
[i
], NULL
, &rtv
[i
]);
3891 ok(SUCCEEDED(hr
), "Failed to create rendertarget view %u, hr %#x.\n", i
, hr
);
3894 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
3895 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
3896 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
3897 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
3899 ID3D11Device_GetImmediateContext(device
, &context
);
3901 ID3D11DeviceContext_OMSetRenderTargets(context
, 4, rtv
, NULL
);
3902 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
3903 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
3904 stride
= sizeof(*quad
);
3906 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, &stride
, &offset
);
3907 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
3908 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
3916 ID3D11DeviceContext_RSSetViewports(context
, 1, &vp
);
3918 for (i
= 0; i
< sizeof(rtv
) / sizeof(*rtv
); ++i
)
3919 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
[i
], red
);
3921 ID3D11DeviceContext_Draw(context
, 4, 0);
3923 check_texture_color(rt
[0], 0xffffffff, 2);
3924 check_texture_color(rt
[1], 0x7f7f7f7f, 2);
3925 check_texture_color(rt
[2], 0x33333333, 2);
3926 check_texture_color(rt
[3], 0xff7f3300, 2);
3928 ID3D11Buffer_Release(vb
);
3929 ID3D11PixelShader_Release(ps
);
3930 ID3D11VertexShader_Release(vs
);
3931 ID3D11InputLayout_Release(input_layout
);
3932 for (i
= 0; i
< sizeof(rtv
) / sizeof(*rtv
); ++i
)
3933 ID3D11RenderTargetView_Release(rtv
[i
]);
3934 for (i
= 0; i
< sizeof(rt
) / sizeof(*rt
); ++i
)
3935 ID3D11Texture2D_Release(rt
[i
]);
3936 ID3D11DeviceContext_Release(context
);
3937 refcount
= ID3D11Device_Release(device
);
3938 ok(!refcount
, "Device has %u references left.\n", refcount
);
3941 static void test_scissor(void)
3943 struct d3d11_test_context test_context
;
3944 ID3D11DeviceContext
*immediate_context
;
3945 D3D11_RASTERIZER_DESC rs_desc
;
3946 ID3D11RasterizerState
*rs
;
3947 D3D11_RECT scissor_rect
;
3948 ID3D11PixelShader
*ps
;
3949 ID3D11Device
*device
;
3953 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 1.0f
};
3954 static const DWORD ps_code
[] =
3957 float4
main(float4 position
: SV_POSITION
) : SV_Target
3959 return float4(0.0, 1.0, 0.0, 1.0);
3962 0x43425844, 0xe70802a0, 0xee334047, 0x7bfd0c79, 0xaeff7804, 0x00000001, 0x000001b0, 0x00000005,
3963 0x00000034, 0x0000008c, 0x000000c0, 0x000000f4, 0x00000134, 0x46454452, 0x00000050, 0x00000000,
3964 0x00000000, 0x00000000, 0x0000001c, 0xffff0400, 0x00000100, 0x0000001c, 0x7263694d, 0x666f736f,
3965 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e30332e,
3966 0x30303239, 0x3336312e, 0xab003438, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
3967 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
3968 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
3969 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000038, 0x00000040,
3970 0x0000000e, 0x03000065, 0x001020f2, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002,
3971 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e, 0x54415453, 0x00000074, 0x00000002,
3972 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
3973 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3974 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3975 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3978 if (!init_test_context(&test_context
))
3981 device
= test_context
.device
;
3982 immediate_context
= test_context
.immediate_context
;
3984 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
3985 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
3987 rs_desc
.FillMode
= D3D11_FILL_SOLID
;
3988 rs_desc
.CullMode
= D3D11_CULL_BACK
;
3989 rs_desc
.FrontCounterClockwise
= FALSE
;
3990 rs_desc
.DepthBias
= 0;
3991 rs_desc
.DepthBiasClamp
= 0.0f
;
3992 rs_desc
.SlopeScaledDepthBias
= 0.0f
;
3993 rs_desc
.DepthClipEnable
= TRUE
;
3994 rs_desc
.ScissorEnable
= TRUE
;
3995 rs_desc
.MultisampleEnable
= FALSE
;
3996 rs_desc
.AntialiasedLineEnable
= FALSE
;
3997 hr
= ID3D11Device_CreateRasterizerState(device
, &rs_desc
, &rs
);
3998 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
4000 ID3D11DeviceContext_PSSetShader(immediate_context
, ps
, NULL
, 0);
4002 scissor_rect
.left
= 160;
4003 scissor_rect
.top
= 120;
4004 scissor_rect
.right
= 480;
4005 scissor_rect
.bottom
= 360;
4006 ID3D11DeviceContext_RSSetScissorRects(immediate_context
, 1, &scissor_rect
);
4008 ID3D11DeviceContext_ClearRenderTargetView(immediate_context
, test_context
.backbuffer_rtv
, red
);
4009 check_texture_color(test_context
.backbuffer
, 0xff0000ff, 1);
4011 draw_quad(&test_context
);
4012 color
= get_texture_color(test_context
.backbuffer
, 320, 60);
4013 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
4014 color
= get_texture_color(test_context
.backbuffer
, 80, 240);
4015 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
4016 color
= get_texture_color(test_context
.backbuffer
, 320, 240);
4017 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
4018 color
= get_texture_color(test_context
.backbuffer
, 560, 240);
4019 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
4020 color
= get_texture_color(test_context
.backbuffer
, 320, 420);
4021 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
4023 ID3D11DeviceContext_ClearRenderTargetView(immediate_context
, test_context
.backbuffer_rtv
, red
);
4024 ID3D11DeviceContext_RSSetState(immediate_context
, rs
);
4025 draw_quad(&test_context
);
4026 color
= get_texture_color(test_context
.backbuffer
, 320, 60);
4027 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
4028 color
= get_texture_color(test_context
.backbuffer
, 80, 240);
4029 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
4030 color
= get_texture_color(test_context
.backbuffer
, 320, 240);
4031 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
4032 color
= get_texture_color(test_context
.backbuffer
, 560, 240);
4033 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
4034 color
= get_texture_color(test_context
.backbuffer
, 320, 420);
4035 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
4037 ID3D11RasterizerState_Release(rs
);
4038 ID3D11PixelShader_Release(ps
);
4039 release_test_context(&test_context
);
4042 static void test_il_append_aligned(void)
4044 struct d3d11_test_context test_context
;
4045 D3D11_SUBRESOURCE_DATA resource_data
;
4046 ID3D11InputLayout
*input_layout
;
4047 D3D11_BUFFER_DESC buffer_desc
;
4048 ID3D11DeviceContext
*context
;
4049 unsigned int stride
, offset
;
4050 ID3D11VertexShader
*vs
;
4051 ID3D11PixelShader
*ps
;
4052 ID3D11Device
*device
;
4053 ID3D11Buffer
*vb
[3];
4057 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
4059 {"COLOR", 2, DXGI_FORMAT_R32G32_FLOAT
, 1, D3D11_APPEND_ALIGNED_ELEMENT
,
4060 D3D11_INPUT_PER_INSTANCE_DATA
, 2},
4061 {"COLOR", 3, DXGI_FORMAT_R32G32_FLOAT
, 2, D3D11_APPEND_ALIGNED_ELEMENT
,
4062 D3D11_INPUT_PER_INSTANCE_DATA
, 1},
4063 {"POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, D3D11_APPEND_ALIGNED_ELEMENT
,
4064 D3D11_INPUT_PER_VERTEX_DATA
, 0},
4065 {"COLOR", 0, DXGI_FORMAT_R32G32_FLOAT
, 2, D3D11_APPEND_ALIGNED_ELEMENT
,
4066 D3D11_INPUT_PER_INSTANCE_DATA
, 1},
4067 {"COLOR", 1, DXGI_FORMAT_R32G32_FLOAT
, 1, D3D11_APPEND_ALIGNED_ELEMENT
,
4068 D3D11_INPUT_PER_INSTANCE_DATA
, 2},
4070 static const DWORD vs_code
[] =
4075 float4 position
: POSITION
;
4076 float2 color_xy
: COLOR0
;
4077 float2 color_zw
: COLOR1
;
4078 unsigned int instance_id
: SV_INSTANCEID
;
4083 float4 position
: SV_POSITION
;
4084 float2 color_xy
: COLOR0
;
4085 float2 color_zw
: COLOR1
;
4088 struct vs_out
main(struct vs_in i
)
4092 o
.position
= i
.position
;
4093 o
.position
.x
+= i
.instance_id
* 0.5;
4094 o
.color_xy
= i
.color_xy
;
4095 o
.color_zw
= i
.color_zw
;
4100 0x43425844, 0x52e3bf46, 0x6300403d, 0x624cffe4, 0xa4fc0013, 0x00000001, 0x00000214, 0x00000003,
4101 0x0000002c, 0x000000bc, 0x00000128, 0x4e475349, 0x00000088, 0x00000004, 0x00000008, 0x00000068,
4102 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000071, 0x00000000, 0x00000000,
4103 0x00000003, 0x00000001, 0x00000303, 0x00000071, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
4104 0x00000303, 0x00000077, 0x00000000, 0x00000008, 0x00000001, 0x00000003, 0x00000101, 0x49534f50,
4105 0x4e4f4954, 0x4c4f4300, 0x5300524f, 0x4e495f56, 0x4e415453, 0x44494543, 0xababab00, 0x4e47534f,
4106 0x00000064, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000,
4107 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000c03, 0x0000005c,
4108 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000030c, 0x505f5653, 0x5449534f, 0x004e4f49,
4109 0x4f4c4f43, 0xabab0052, 0x52444853, 0x000000e4, 0x00010040, 0x00000039, 0x0300005f, 0x001010f2,
4110 0x00000000, 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x00101032, 0x00000002, 0x04000060,
4111 0x00101012, 0x00000003, 0x00000008, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065,
4112 0x00102032, 0x00000001, 0x03000065, 0x001020c2, 0x00000001, 0x02000068, 0x00000001, 0x05000056,
4113 0x00100012, 0x00000000, 0x0010100a, 0x00000003, 0x09000032, 0x00102012, 0x00000000, 0x0010000a,
4114 0x00000000, 0x00004001, 0x3f000000, 0x0010100a, 0x00000000, 0x05000036, 0x001020e2, 0x00000000,
4115 0x00101e56, 0x00000000, 0x05000036, 0x00102032, 0x00000001, 0x00101046, 0x00000001, 0x05000036,
4116 0x001020c2, 0x00000001, 0x00101406, 0x00000002, 0x0100003e,
4118 static const DWORD ps_code
[] =
4123 float4 position
: SV_POSITION
;
4124 float2 color_xy
: COLOR0
;
4125 float2 color_zw
: COLOR1
;
4128 float4
main(struct vs_out i
) : SV_TARGET
4130 return float4(i
.color_xy
.xy
, i
.color_zw
.xy
);
4133 0x43425844, 0x64e48a09, 0xaa484d46, 0xe40a6e78, 0x9885edf3, 0x00000001, 0x00000118, 0x00000003,
4134 0x0000002c, 0x00000098, 0x000000cc, 0x4e475349, 0x00000064, 0x00000003, 0x00000008, 0x00000050,
4135 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000,
4136 0x00000003, 0x00000001, 0x00000303, 0x0000005c, 0x00000001, 0x00000000, 0x00000003, 0x00000001,
4137 0x00000c0c, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x4e47534f, 0x0000002c,
4138 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f,
4139 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000044, 0x00000040, 0x00000011, 0x03001062,
4140 0x00101032, 0x00000001, 0x03001062, 0x001010c2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
4141 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
4145 struct vec4 position
;
4149 {{-1.0f
, -1.0f
, 0.0f
, 1.0f
}},
4150 {{-1.0f
, 1.0f
, 0.0f
, 1.0f
}},
4151 {{-0.5f
, -1.0f
, 0.0f
, 1.0f
}},
4152 {{-0.5f
, 1.0f
, 0.0f
, 1.0f
}},
4161 {{0.5f
, 0.5f
}, {0.0f
, 1.0f
}},
4162 {{0.5f
, 0.5f
}, {1.0f
, 1.0f
}},
4171 {{0.5f
, 0.5f
}, {1.0f
, 0.0f
}},
4172 {{0.5f
, 0.5f
}, {0.0f
, 1.0f
}},
4173 {{0.5f
, 0.5f
}, {0.0f
, 0.0f
}},
4174 {{0.5f
, 0.5f
}, {1.0f
, 0.0f
}},
4176 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
4178 if (!init_test_context(&test_context
))
4181 device
= test_context
.device
;
4182 context
= test_context
.immediate_context
;
4184 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, sizeof(layout_desc
) / sizeof(*layout_desc
),
4185 vs_code
, sizeof(vs_code
), &input_layout
);
4186 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
4188 buffer_desc
.ByteWidth
= sizeof(stream0
);
4189 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
4190 buffer_desc
.BindFlags
= D3D11_BIND_VERTEX_BUFFER
;
4191 buffer_desc
.CPUAccessFlags
= 0;
4192 buffer_desc
.MiscFlags
= 0;
4193 buffer_desc
.StructureByteStride
= 0;
4195 resource_data
.pSysMem
= stream0
;
4196 resource_data
.SysMemPitch
= 0;
4197 resource_data
.SysMemSlicePitch
= 0;
4199 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &resource_data
, &vb
[0]);
4200 ok(SUCCEEDED(hr
), "Failed to create vertex buffer, hr %#x.\n", hr
);
4202 buffer_desc
.ByteWidth
= sizeof(stream1
);
4203 resource_data
.pSysMem
= stream1
;
4205 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &resource_data
, &vb
[1]);
4206 ok(SUCCEEDED(hr
), "Failed to create vertex buffer, hr %#x.\n", hr
);
4208 buffer_desc
.ByteWidth
= sizeof(stream2
);
4209 resource_data
.pSysMem
= stream2
;
4211 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &resource_data
, &vb
[2]);
4212 ok(SUCCEEDED(hr
), "Failed to create vertex buffer, hr %#x.\n", hr
);
4214 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
4215 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
4216 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
4217 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
4219 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
4220 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
4222 stride
= sizeof(*stream0
);
4223 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
[0], &stride
, &offset
);
4224 stride
= sizeof(*stream1
);
4225 ID3D11DeviceContext_IASetVertexBuffers(context
, 1, 1, &vb
[1], &stride
, &offset
);
4226 stride
= sizeof(*stream2
);
4227 ID3D11DeviceContext_IASetVertexBuffers(context
, 2, 1, &vb
[2], &stride
, &offset
);
4228 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
4229 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
4231 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
4233 ID3D11DeviceContext_DrawInstanced(context
, 4, 4, 0, 0);
4235 color
= get_texture_color(test_context
.backbuffer
, 80, 240);
4236 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
4237 color
= get_texture_color(test_context
.backbuffer
, 240, 240);
4238 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
4239 color
= get_texture_color(test_context
.backbuffer
, 400, 240);
4240 ok(compare_color(color
, 0xffff0000, 1), "Got unexpected color 0x%08x.\n", color
);
4241 color
= get_texture_color(test_context
.backbuffer
, 560, 240);
4242 ok(compare_color(color
, 0xffff00ff, 1), "Got unexpected color 0x%08x.\n", color
);
4244 ID3D11PixelShader_Release(ps
);
4245 ID3D11VertexShader_Release(vs
);
4246 ID3D11Buffer_Release(vb
[2]);
4247 ID3D11Buffer_Release(vb
[1]);
4248 ID3D11Buffer_Release(vb
[0]);
4249 ID3D11InputLayout_Release(input_layout
);
4250 release_test_context(&test_context
);
4253 static void test_fragment_coords(void)
4255 struct d3d11_test_context test_context
;
4256 D3D11_SUBRESOURCE_DATA resource_data
;
4257 ID3D11PixelShader
*ps
, *ps_frac
;
4258 D3D11_BUFFER_DESC buffer_desc
;
4259 ID3D11DeviceContext
*context
;
4260 ID3D11Device
*device
;
4261 ID3D11Buffer
*ps_cb
;
4265 static const DWORD ps_code
[] =
4270 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
4272 float4 ret
= float4(0.0, 0.0, 0.0, 1.0);
4274 if (position
.x
> cutoff
.x
)
4276 if (position
.y
> cutoff
.y
)
4282 0x43425844, 0x49fc9e51, 0x8068867d, 0xf20cfa39, 0xb8099e6b, 0x00000001, 0x00000144, 0x00000003,
4283 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
4284 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
4285 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
4286 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000a8, 0x00000040,
4287 0x0000002a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04002064, 0x00101032, 0x00000000,
4288 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x08000031, 0x00100032,
4289 0x00000000, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000000, 0x0a000001, 0x00102062,
4290 0x00000000, 0x00100106, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x3f800000, 0x00000000,
4291 0x08000036, 0x00102092, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x3f800000,
4294 static const DWORD ps_frac_code
[] =
4297 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
4299 return float4(frac(position
.xy
), 0.0, 1.0);
4302 0x43425844, 0x86d9d78a, 0x190b72c2, 0x50841fd6, 0xdc24022e, 0x00000001, 0x000000f8, 0x00000003,
4303 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
4304 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
4305 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
4306 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x0000005c, 0x00000040,
4307 0x00000017, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
4308 0x0500001a, 0x00102032, 0x00000000, 0x00101046, 0x00000000, 0x08000036, 0x001020c2, 0x00000000,
4309 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e,
4311 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
4312 struct vec4 cutoff
= {320.0f
, 240.0f
, 0.0f
, 0.0f
};
4314 if (!init_test_context(&test_context
))
4317 device
= test_context
.device
;
4318 context
= test_context
.immediate_context
;
4320 buffer_desc
.ByteWidth
= sizeof(cutoff
);
4321 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
4322 buffer_desc
.BindFlags
= D3D11_BIND_CONSTANT_BUFFER
;
4323 buffer_desc
.CPUAccessFlags
= 0;
4324 buffer_desc
.MiscFlags
= 0;
4325 buffer_desc
.StructureByteStride
= 0;
4327 resource_data
.pSysMem
= &cutoff
;
4328 resource_data
.SysMemPitch
= 0;
4329 resource_data
.SysMemSlicePitch
= 0;
4331 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &resource_data
, &ps_cb
);
4332 ok(SUCCEEDED(hr
), "Failed to create constant buffer, hr %#x.\n", hr
);
4334 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
4335 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
4336 hr
= ID3D11Device_CreatePixelShader(device
, ps_frac_code
, sizeof(ps_frac_code
), NULL
, &ps_frac
);
4337 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
4339 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &ps_cb
);
4340 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
4342 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
4344 draw_quad(&test_context
);
4346 color
= get_texture_color(test_context
.backbuffer
, 319, 239);
4347 ok(compare_color(color
, 0xff000000, 1), "Got unexpected color 0x%08x.\n", color
);
4348 color
= get_texture_color(test_context
.backbuffer
, 320, 239);
4349 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
4350 color
= get_texture_color(test_context
.backbuffer
, 319, 240);
4351 ok(compare_color(color
, 0xffff0000, 1), "Got unexpected color 0x%08x.\n", color
);
4352 color
= get_texture_color(test_context
.backbuffer
, 320, 240);
4353 ok(compare_color(color
, 0xffffff00, 1), "Got unexpected color 0x%08x.\n", color
);
4355 ID3D11Buffer_Release(ps_cb
);
4358 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &resource_data
, &ps_cb
);
4359 ok(SUCCEEDED(hr
), "Failed to create constant buffer, hr %#x.\n", hr
);
4360 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &ps_cb
);
4362 draw_quad(&test_context
);
4364 color
= get_texture_color(test_context
.backbuffer
, 14, 14);
4365 ok(compare_color(color
, 0xff000000, 1), "Got unexpected color 0x%08x.\n", color
);
4366 color
= get_texture_color(test_context
.backbuffer
, 18, 14);
4367 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
4368 color
= get_texture_color(test_context
.backbuffer
, 14, 18);
4369 ok(compare_color(color
, 0xffff0000, 1), "Got unexpected color 0x%08x.\n", color
);
4370 color
= get_texture_color(test_context
.backbuffer
, 18, 18);
4371 ok(compare_color(color
, 0xffffff00, 1), "Got unexpected color 0x%08x.\n", color
);
4373 ID3D11DeviceContext_PSSetShader(context
, ps_frac
, NULL
, 0);
4374 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
4376 ID3D11DeviceContext_Draw(context
, 4, 0);
4378 color
= get_texture_color(test_context
.backbuffer
, 14, 14);
4379 ok(compare_color(color
, 0xff008080, 1), "Got unexpected color 0x%08x.\n", color
);
4381 ID3D11Buffer_Release(ps_cb
);
4382 ID3D11PixelShader_Release(ps_frac
);
4383 ID3D11PixelShader_Release(ps
);
4384 release_test_context(&test_context
);
4387 static void test_update_subresource(void)
4389 struct d3d11_test_context test_context
;
4390 D3D11_TEXTURE2D_DESC texture_desc
;
4391 ID3D11SamplerState
*sampler_state
;
4392 ID3D11ShaderResourceView
*ps_srv
;
4393 D3D11_SAMPLER_DESC sampler_desc
;
4394 ID3D11DeviceContext
*context
;
4395 struct texture_readback rb
;
4396 ID3D11Texture2D
*texture
;
4397 ID3D11PixelShader
*ps
;
4398 ID3D11Device
*device
;
4404 static const DWORD ps_code
[] =
4410 float4
main(float4 position
: SV_POSITION
) : SV_Target
4414 p
.x
= position
.x
/ 640.0f
;
4415 p
.y
= position
.y
/ 480.0f
;
4416 return t
.Sample(s
, p
);
4419 0x43425844, 0x1ce9b612, 0xc8176faa, 0xd37844af, 0xdb515605, 0x00000001, 0x00000134, 0x00000003,
4420 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
4421 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
4422 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
4423 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
4424 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
4425 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
4426 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
4427 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
4428 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
4430 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
4431 static const DWORD bitmap_data
[] =
4433 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
4434 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
4435 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
4436 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
4438 static const DWORD expected_colors
[] =
4440 0xffffffff, 0xff000000, 0xffffffff, 0xff000000,
4441 0xff00ff00, 0xff0000ff, 0xff00ffff, 0x00000000,
4442 0xffffff00, 0xffff0000, 0xffff00ff, 0x00000000,
4443 0xff000000, 0xff7f7f7f, 0xffffffff, 0x00000000,
4446 if (!init_test_context(&test_context
))
4449 device
= test_context
.device
;
4450 context
= test_context
.immediate_context
;
4452 texture_desc
.Width
= 4;
4453 texture_desc
.Height
= 4;
4454 texture_desc
.MipLevels
= 1;
4455 texture_desc
.ArraySize
= 1;
4456 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
4457 texture_desc
.SampleDesc
.Count
= 1;
4458 texture_desc
.SampleDesc
.Quality
= 0;
4459 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
4460 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
4461 texture_desc
.CPUAccessFlags
= 0;
4462 texture_desc
.MiscFlags
= 0;
4464 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
4465 ok(SUCCEEDED(hr
), "Failed to create 2d texture, hr %#x.\n", hr
);
4467 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &ps_srv
);
4468 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
4470 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
4471 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
4472 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
4473 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
4474 sampler_desc
.MipLODBias
= 0.0f
;
4475 sampler_desc
.MaxAnisotropy
= 0;
4476 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
4477 sampler_desc
.BorderColor
[0] = 0.0f
;
4478 sampler_desc
.BorderColor
[1] = 0.0f
;
4479 sampler_desc
.BorderColor
[2] = 0.0f
;
4480 sampler_desc
.BorderColor
[3] = 0.0f
;
4481 sampler_desc
.MinLOD
= 0.0f
;
4482 sampler_desc
.MaxLOD
= 0.0f
;
4484 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler_state
);
4485 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
4487 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
4488 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
4490 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &ps_srv
);
4491 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler_state
);
4492 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
4494 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
4495 check_texture_color(test_context
.backbuffer
, 0x7f0000ff, 1);
4497 draw_quad(&test_context
);
4498 check_texture_color(test_context
.backbuffer
, 0x00000000, 0);
4500 set_box(&box
, 1, 1, 0, 3, 3, 1);
4501 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture
, 0, &box
,
4502 bitmap_data
, 4 * sizeof(*bitmap_data
), 0);
4503 set_box(&box
, 0, 3, 0, 3, 4, 1);
4504 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture
, 0, &box
,
4505 &bitmap_data
[6], 4 * sizeof(*bitmap_data
), 0);
4506 set_box(&box
, 0, 0, 0, 4, 1, 1);
4507 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture
, 0, &box
,
4508 &bitmap_data
[10], 4 * sizeof(*bitmap_data
), 0);
4509 set_box(&box
, 0, 1, 0, 1, 3, 1);
4510 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture
, 0, &box
,
4511 &bitmap_data
[2], sizeof(*bitmap_data
), 0);
4512 set_box(&box
, 4, 4, 0, 3, 1, 1);
4513 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture
, 0, &box
,
4514 bitmap_data
, sizeof(*bitmap_data
), 0);
4515 set_box(&box
, 0, 0, 0, 4, 4, 0);
4516 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture
, 0, &box
,
4517 bitmap_data
, 4 * sizeof(*bitmap_data
), 0);
4518 draw_quad(&test_context
);
4519 get_texture_readback(test_context
.backbuffer
, &rb
);
4520 for (i
= 0; i
< 4; ++i
)
4522 for (j
= 0; j
< 4; ++j
)
4524 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120);
4525 ok(compare_color(color
, expected_colors
[j
+ i
* 4], 1),
4526 "Got unexpected color 0x%08x at (%u, %u), expected 0x%08x.\n",
4527 color
, j
, i
, expected_colors
[j
+ i
* 4]);
4530 release_texture_readback(&rb
);
4532 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture
, 0, NULL
,
4533 bitmap_data
, 4 * sizeof(*bitmap_data
), 0);
4534 draw_quad(&test_context
);
4535 get_texture_readback(test_context
.backbuffer
, &rb
);
4536 for (i
= 0; i
< 4; ++i
)
4538 for (j
= 0; j
< 4; ++j
)
4540 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120);
4541 ok(compare_color(color
, bitmap_data
[j
+ i
* 4], 1),
4542 "Got unexpected color 0x%08x at (%u, %u), expected 0x%08x.\n",
4543 color
, j
, i
, bitmap_data
[j
+ i
* 4]);
4546 release_texture_readback(&rb
);
4548 ID3D11PixelShader_Release(ps
);
4549 ID3D11SamplerState_Release(sampler_state
);
4550 ID3D11ShaderResourceView_Release(ps_srv
);
4551 ID3D11Texture2D_Release(texture
);
4552 release_test_context(&test_context
);
4555 static void test_copy_subresource_region(void)
4557 ID3D11Texture2D
*dst_texture
, *src_texture
;
4558 struct d3d11_test_context test_context
;
4559 D3D11_SUBRESOURCE_DATA resource_data
;
4560 D3D11_TEXTURE2D_DESC texture_desc
;
4561 ID3D11SamplerState
*sampler_state
;
4562 ID3D11ShaderResourceView
*ps_srv
;
4563 D3D11_SAMPLER_DESC sampler_desc
;
4564 ID3D11DeviceContext
*context
;
4565 struct texture_readback rb
;
4566 ID3D11PixelShader
*ps
;
4567 ID3D11Device
*device
;
4573 static const DWORD ps_code
[] =
4579 float4
main(float4 position
: SV_POSITION
) : SV_Target
4583 p
.x
= position
.x
/ 640.0f
;
4584 p
.y
= position
.y
/ 480.0f
;
4585 return t
.Sample(s
, p
);
4588 0x43425844, 0x1ce9b612, 0xc8176faa, 0xd37844af, 0xdb515605, 0x00000001, 0x00000134, 0x00000003,
4589 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
4590 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
4591 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
4592 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
4593 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
4594 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
4595 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
4596 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
4597 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
4599 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
4600 static const DWORD bitmap_data
[] =
4602 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
4603 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
4604 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
4605 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
4607 static const DWORD expected_colors
[] =
4609 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
4610 0xffffff00, 0xff0000ff, 0xff00ffff, 0x00000000,
4611 0xff7f7f7f, 0xffff0000, 0xffff00ff, 0xff7f7f7f,
4612 0xffffffff, 0xffffffff, 0xff000000, 0x00000000,
4615 if (!init_test_context(&test_context
))
4618 device
= test_context
.device
;
4619 context
= test_context
.immediate_context
;
4621 texture_desc
.Width
= 4;
4622 texture_desc
.Height
= 4;
4623 texture_desc
.MipLevels
= 1;
4624 texture_desc
.ArraySize
= 1;
4625 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
4626 texture_desc
.SampleDesc
.Count
= 1;
4627 texture_desc
.SampleDesc
.Quality
= 0;
4628 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
4629 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
4630 texture_desc
.CPUAccessFlags
= 0;
4631 texture_desc
.MiscFlags
= 0;
4633 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &dst_texture
);
4634 ok(SUCCEEDED(hr
), "Failed to create 2d texture, hr %#x.\n", hr
);
4636 texture_desc
.Usage
= D3D11_USAGE_IMMUTABLE
;
4638 resource_data
.pSysMem
= bitmap_data
;
4639 resource_data
.SysMemPitch
= 4 * sizeof(*bitmap_data
);
4640 resource_data
.SysMemSlicePitch
= 0;
4642 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &src_texture
);
4643 ok(SUCCEEDED(hr
), "Failed to create 2d texture, hr %#x.\n", hr
);
4645 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)dst_texture
, NULL
, &ps_srv
);
4646 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
4648 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
4649 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
4650 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
4651 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
4652 sampler_desc
.MipLODBias
= 0.0f
;
4653 sampler_desc
.MaxAnisotropy
= 0;
4654 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
4655 sampler_desc
.BorderColor
[0] = 0.0f
;
4656 sampler_desc
.BorderColor
[1] = 0.0f
;
4657 sampler_desc
.BorderColor
[2] = 0.0f
;
4658 sampler_desc
.BorderColor
[3] = 0.0f
;
4659 sampler_desc
.MinLOD
= 0.0f
;
4660 sampler_desc
.MaxLOD
= 0.0f
;
4662 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler_state
);
4663 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
4665 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
4666 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
4668 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &ps_srv
);
4669 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler_state
);
4670 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
4672 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
4674 set_box(&box
, 0, 0, 0, 2, 2, 1);
4675 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
4676 1, 1, 0, (ID3D11Resource
*)src_texture
, 0, &box
);
4677 set_box(&box
, 1, 2, 0, 4, 3, 1);
4678 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
4679 0, 3, 0, (ID3D11Resource
*)src_texture
, 0, &box
);
4680 set_box(&box
, 0, 3, 0, 4, 4, 1);
4681 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
4682 0, 0, 0, (ID3D11Resource
*)src_texture
, 0, &box
);
4683 set_box(&box
, 3, 0, 0, 4, 2, 1);
4684 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
4685 0, 1, 0, (ID3D11Resource
*)src_texture
, 0, &box
);
4686 set_box(&box
, 3, 1, 0, 4, 2, 1);
4687 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
4688 3, 2, 0, (ID3D11Resource
*)src_texture
, 0, &box
);
4689 set_box(&box
, 0, 0, 0, 4, 4, 0);
4690 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
4691 0, 0, 0, (ID3D11Resource
*)src_texture
, 0, &box
);
4692 draw_quad(&test_context
);
4693 get_texture_readback(test_context
.backbuffer
, &rb
);
4694 for (i
= 0; i
< 4; ++i
)
4696 for (j
= 0; j
< 4; ++j
)
4698 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120);
4699 ok(compare_color(color
, expected_colors
[j
+ i
* 4], 1),
4700 "Got unexpected color 0x%08x at (%u, %u), expected 0x%08x.\n",
4701 color
, j
, i
, expected_colors
[j
+ i
* 4]);
4704 release_texture_readback(&rb
);
4706 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
4707 0, 0, 0, (ID3D11Resource
*)src_texture
, 0, NULL
);
4708 draw_quad(&test_context
);
4709 get_texture_readback(test_context
.backbuffer
, &rb
);
4710 for (i
= 0; i
< 4; ++i
)
4712 for (j
= 0; j
< 4; ++j
)
4714 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120);
4715 ok(compare_color(color
, bitmap_data
[j
+ i
* 4], 1),
4716 "Got unexpected color 0x%08x at (%u, %u), expected 0x%08x.\n",
4717 color
, j
, i
, bitmap_data
[j
+ i
* 4]);
4720 release_texture_readback(&rb
);
4722 ID3D11PixelShader_Release(ps
);
4723 ID3D11SamplerState_Release(sampler_state
);
4724 ID3D11ShaderResourceView_Release(ps_srv
);
4725 ID3D11Texture2D_Release(dst_texture
);
4726 ID3D11Texture2D_Release(src_texture
);
4727 release_test_context(&test_context
);
4730 static void test_resource_map(void)
4732 D3D11_MAPPED_SUBRESOURCE mapped_subresource
;
4733 D3D11_TEXTURE3D_DESC texture3d_desc
;
4734 D3D11_TEXTURE2D_DESC texture2d_desc
;
4735 D3D11_BUFFER_DESC buffer_desc
;
4736 ID3D11DeviceContext
*context
;
4737 ID3D11Texture3D
*texture3d
;
4738 ID3D11Texture2D
*texture2d
;
4739 ID3D11Buffer
*buffer
;
4740 ID3D11Device
*device
;
4745 if (!(device
= create_device(NULL
)))
4747 skip("Failed to create device.\n");
4751 ID3D11Device_GetImmediateContext(device
, &context
);
4753 buffer_desc
.ByteWidth
= 1024;
4754 buffer_desc
.Usage
= D3D11_USAGE_STAGING
;
4755 buffer_desc
.BindFlags
= 0;
4756 buffer_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
| D3D11_CPU_ACCESS_WRITE
;
4757 buffer_desc
.MiscFlags
= 0;
4758 buffer_desc
.StructureByteStride
= 0;
4760 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
4761 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
4763 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)buffer
, 1, D3D11_MAP_READ
, 0, &mapped_subresource
);
4764 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
4766 memset(&mapped_subresource
, 0, sizeof(mapped_subresource
));
4767 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)buffer
, 0, D3D11_MAP_WRITE
, 0, &mapped_subresource
);
4768 ok(SUCCEEDED(hr
), "Failed to map buffer, hr %#x.\n", hr
);
4769 ok(mapped_subresource
.RowPitch
== 1024, "Got unexpected row pitch %u.\n", mapped_subresource
.RowPitch
);
4770 ok(mapped_subresource
.DepthPitch
== 1024, "Got unexpected depth pitch %u.\n", mapped_subresource
.DepthPitch
);
4771 *((DWORD
*)mapped_subresource
.pData
) = 0xdeadbeef;
4772 ID3D11DeviceContext_Unmap(context
, (ID3D11Resource
*)buffer
, 0);
4774 memset(&mapped_subresource
, 0, sizeof(mapped_subresource
));
4775 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)buffer
, 0, D3D11_MAP_READ
, 0, &mapped_subresource
);
4776 ok(SUCCEEDED(hr
), "Failed to map buffer, hr %#x.\n", hr
);
4777 ok(mapped_subresource
.RowPitch
== 1024, "Got unexpected row pitch %u.\n", mapped_subresource
.RowPitch
);
4778 ok(mapped_subresource
.DepthPitch
== 1024, "Got unexpected depth pitch %u.\n", mapped_subresource
.DepthPitch
);
4779 data
= *((DWORD
*)mapped_subresource
.pData
);
4780 ok(data
== 0xdeadbeef, "Got unexpected data %#x.\n", data
);
4781 ID3D11DeviceContext_Unmap(context
, (ID3D11Resource
*)buffer
, 0);
4783 refcount
= ID3D11Buffer_Release(buffer
);
4784 ok(!refcount
, "Buffer has %u references left.\n", refcount
);
4786 texture2d_desc
.Width
= 512;
4787 texture2d_desc
.Height
= 512;
4788 texture2d_desc
.MipLevels
= 1;
4789 texture2d_desc
.ArraySize
= 1;
4790 texture2d_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
4791 texture2d_desc
.SampleDesc
.Count
= 1;
4792 texture2d_desc
.SampleDesc
.Quality
= 0;
4793 texture2d_desc
.Usage
= D3D11_USAGE_STAGING
;
4794 texture2d_desc
.BindFlags
= 0;
4795 texture2d_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
| D3D11_CPU_ACCESS_WRITE
;
4796 texture2d_desc
.MiscFlags
= 0;
4798 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, &texture2d
);
4799 ok(SUCCEEDED(hr
), "Failed to create 2d texture, hr %#x.\n", hr
);
4801 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)texture2d
, 1, D3D11_MAP_READ
, 0, &mapped_subresource
);
4802 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
4804 memset(&mapped_subresource
, 0, sizeof(mapped_subresource
));
4805 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)texture2d
, 0, D3D11_MAP_WRITE
, 0, &mapped_subresource
);
4806 ok(SUCCEEDED(hr
), "Failed to map texture, hr %#x.\n", hr
);
4807 ok(mapped_subresource
.RowPitch
== 4 * 512, "Got unexpected row pitch %u.\n", mapped_subresource
.RowPitch
);
4808 ok(mapped_subresource
.DepthPitch
== 4 * 512 * 512, "Got unexpected depth pitch %u.\n",
4809 mapped_subresource
.DepthPitch
);
4810 *((DWORD
*)mapped_subresource
.pData
) = 0xdeadbeef;
4811 ID3D11DeviceContext_Unmap(context
, (ID3D11Resource
*)texture2d
, 0);
4813 memset(&mapped_subresource
, 0, sizeof(mapped_subresource
));
4814 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)texture2d
, 0, D3D11_MAP_READ
, 0, &mapped_subresource
);
4815 ok(SUCCEEDED(hr
), "Failed to map texture, hr %#x.\n", hr
);
4816 ok(mapped_subresource
.RowPitch
== 4 * 512, "Got unexpected row pitch %u.\n", mapped_subresource
.RowPitch
);
4817 ok(mapped_subresource
.DepthPitch
== 4 * 512 * 512, "Got unexpected depth pitch %u.\n",
4818 mapped_subresource
.DepthPitch
);
4819 data
= *((DWORD
*)mapped_subresource
.pData
);
4820 ok(data
== 0xdeadbeef, "Got unexpected data %#x.\n", data
);
4821 ID3D11DeviceContext_Unmap(context
, (ID3D11Resource
*)texture2d
, 0);
4823 refcount
= ID3D11Texture2D_Release(texture2d
);
4824 ok(!refcount
, "2D texture has %u references left.\n", refcount
);
4826 texture3d_desc
.Width
= 64;
4827 texture3d_desc
.Height
= 64;
4828 texture3d_desc
.Depth
= 64;
4829 texture3d_desc
.MipLevels
= 1;
4830 texture3d_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
4831 texture3d_desc
.Usage
= D3D11_USAGE_STAGING
;
4832 texture3d_desc
.BindFlags
= 0;
4833 texture3d_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
| D3D11_CPU_ACCESS_WRITE
;
4834 texture3d_desc
.MiscFlags
= 0;
4836 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &texture3d
);
4837 ok(SUCCEEDED(hr
), "Failed to create 3d texture, hr %#x.\n", hr
);
4839 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)texture3d
, 1, D3D11_MAP_READ
, 0, &mapped_subresource
);
4840 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
4842 memset(&mapped_subresource
, 0, sizeof(mapped_subresource
));
4843 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)texture3d
, 0, D3D11_MAP_WRITE
, 0, &mapped_subresource
);
4844 todo_wine
ok(SUCCEEDED(hr
), "Failed to map texture, hr %#x.\n", hr
);
4845 if (FAILED(hr
)) goto done
;
4846 ok(mapped_subresource
.RowPitch
== 4 * 64, "Got unexpected row pitch %u.\n", mapped_subresource
.RowPitch
);
4847 ok(mapped_subresource
.DepthPitch
== 4 * 64 * 64, "Got unexpected depth pitch %u.\n",
4848 mapped_subresource
.DepthPitch
);
4849 *((DWORD
*)mapped_subresource
.pData
) = 0xdeadbeef;
4850 ID3D11DeviceContext_Unmap(context
, (ID3D11Resource
*)texture3d
, 0);
4852 memset(&mapped_subresource
, 0, sizeof(mapped_subresource
));
4853 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)texture3d
, 0, D3D11_MAP_READ
, 0, &mapped_subresource
);
4854 ok(SUCCEEDED(hr
), "Failed to map texture, hr %#x.\n", hr
);
4855 ok(mapped_subresource
.RowPitch
== 4 * 64, "Got unexpected row pitch %u.\n", mapped_subresource
.RowPitch
);
4856 ok(mapped_subresource
.DepthPitch
== 4 * 64 * 64, "Got unexpected depth pitch %u.\n",
4857 mapped_subresource
.DepthPitch
);
4858 data
= *((DWORD
*)mapped_subresource
.pData
);
4859 ok(data
== 0xdeadbeef, "Got unexpected data %#x.\n", data
);
4860 ID3D11DeviceContext_Unmap(context
, (ID3D11Resource
*)texture3d
, 0);
4863 refcount
= ID3D11Texture3D_Release(texture3d
);
4864 ok(!refcount
, "3D texture has %u references left.\n", refcount
);
4866 ID3D11DeviceContext_Release(context
);
4868 refcount
= ID3D11Device_Release(device
);
4869 ok(!refcount
, "Device has %u references left.\n", refcount
);
4872 static void test_multisample_init(void)
4874 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
4875 struct d3d11_test_context test_context
;
4876 ID3D11DeviceContext
*context
;
4877 D3D11_TEXTURE2D_DESC desc
;
4878 ID3D11Texture2D
*multi
;
4879 ID3D11Device
*device
;
4883 if (!init_test_context(&test_context
))
4886 device
= test_context
.device
;
4887 context
= test_context
.immediate_context
;
4889 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 2, &count
);
4890 ok(SUCCEEDED(hr
), "Failed to get quality levels, hr %#x.\n", hr
);
4893 skip("Multisampling not supported for DXGI_FORMAT_R8G8B8A8_UNORM, skipping tests.\n");
4897 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
4903 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
4904 desc
.SampleDesc
.Count
= 2;
4905 desc
.SampleDesc
.Quality
= 0;
4906 desc
.Usage
= D3D11_USAGE_DEFAULT
;
4907 desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
4908 desc
.CPUAccessFlags
= 0;
4910 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &multi
);
4911 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
4913 ID3D11DeviceContext_ResolveSubresource(context
, (ID3D11Resource
*)test_context
.backbuffer
, 0,
4914 (ID3D11Resource
*)multi
, 0, DXGI_FORMAT_R8G8B8A8_UNORM
);
4916 todo_wine
check_texture_color(test_context
.backbuffer
, 0x00000000, 0);
4918 ID3D11Texture2D_Release(multi
);
4920 release_test_context(&test_context
);
4923 static void test_check_multisample_quality_levels(void)
4925 ID3D11Device
*device
;
4926 UINT quality_levels
;
4930 if (!(device
= create_device(NULL
)))
4932 skip("Failed to create device.\n");
4936 ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 2, &quality_levels
);
4937 if (!quality_levels
)
4939 skip("Multisampling not supported for DXGI_FORMAT_R8G8B8A8_UNORM, skipping test.\n");
4943 quality_levels
= 0xdeadbeef;
4944 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_UNKNOWN
, 2, &quality_levels
);
4945 todo_wine
ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
4946 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
4947 quality_levels
= 0xdeadbeef;
4948 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, 65536, 2, &quality_levels
);
4949 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
4950 todo_wine
ok(quality_levels
== 0xdeadbeef, "Got unexpected quality_levels %u.\n", quality_levels
);
4952 quality_levels
= 0xdeadbeef;
4953 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, NULL
);
4954 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
4955 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, &quality_levels
);
4956 ok(hr
== E_FAIL
, "Got unexpected hr %#x.\n", hr
);
4957 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
4959 quality_levels
= 0xdeadbeef;
4960 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 1, NULL
);
4961 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
4962 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 1, &quality_levels
);
4963 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
4964 ok(quality_levels
== 1, "Got unexpected quality_levels %u.\n", quality_levels
);
4966 quality_levels
= 0xdeadbeef;
4967 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 2, NULL
);
4968 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
4969 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 2, &quality_levels
);
4970 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
4971 ok(quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
4973 /* We assume 15 samples multisampling is never supported in practice. */
4974 quality_levels
= 0xdeadbeef;
4975 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 15, &quality_levels
);
4976 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
4977 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
4978 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 32, &quality_levels
);
4979 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
4980 quality_levels
= 0xdeadbeef;
4981 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 33, &quality_levels
);
4982 ok(hr
== E_FAIL
, "Got unexpected hr %#x.\n", hr
);
4983 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
4984 quality_levels
= 0xdeadbeef;
4985 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 64, &quality_levels
);
4986 ok(hr
== E_FAIL
, "Got unexpected hr %#x.\n", hr
);
4987 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
4989 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_BC3_UNORM
, 2, &quality_levels
);
4990 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
4991 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
4994 refcount
= ID3D11Device_Release(device
);
4995 ok(!refcount
, "Device has %u references left.\n", refcount
);
4998 static void test_create_typeless_resource(void)
5000 D3D11_TEXTURE2D_DESC texture2d_desc
;
5001 D3D11_TEXTURE3D_DESC texture3d_desc
;
5002 ID3D11Resource
*resource
;
5003 ID3D11Device
*device
;
5011 D3D11_BIND_FLAG bind_flags
;
5012 D3D11_RESOURCE_DIMENSION type
;
5018 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, D3D11_BIND_VERTEX_BUFFER
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
, FALSE
, TRUE
},
5019 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, D3D11_BIND_INDEX_BUFFER
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
, FALSE
, TRUE
},
5020 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, D3D11_BIND_CONSTANT_BUFFER
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
, FALSE
, TRUE
},
5021 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
, TRUE
, FALSE
},
5022 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_DIMENSION_TEXTURE3D
, TRUE
, FALSE
},
5023 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, D3D11_BIND_RENDER_TARGET
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
, TRUE
, FALSE
},
5024 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, D3D11_BIND_DEPTH_STENCIL
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
, FALSE
, TRUE
},
5025 {DXGI_FORMAT_R32G32B32_TYPELESS
, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
, TRUE
, FALSE
},
5026 {DXGI_FORMAT_R16G16B16A16_TYPELESS
, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
, TRUE
, FALSE
},
5027 {DXGI_FORMAT_R16G16B16A16_TYPELESS
, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_DIMENSION_TEXTURE3D
, TRUE
, FALSE
},
5028 {DXGI_FORMAT_R16G16B16A16_TYPELESS
, D3D11_BIND_RENDER_TARGET
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
, TRUE
, FALSE
},
5029 {DXGI_FORMAT_R32G32_TYPELESS
, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
, TRUE
, FALSE
},
5030 {DXGI_FORMAT_R32G8X24_TYPELESS
, D3D11_BIND_DEPTH_STENCIL
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
, TRUE
, TRUE
},
5031 {DXGI_FORMAT_R10G10B10A2_TYPELESS
, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
, TRUE
, FALSE
},
5032 {DXGI_FORMAT_R10G10B10A2_TYPELESS
, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_DIMENSION_TEXTURE3D
, TRUE
, FALSE
},
5033 {DXGI_FORMAT_R10G10B10A2_TYPELESS
, D3D11_BIND_RENDER_TARGET
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
, TRUE
, FALSE
},
5034 {DXGI_FORMAT_R32_TYPELESS
, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
, TRUE
, FALSE
},
5035 {DXGI_FORMAT_R24G8_TYPELESS
, D3D11_BIND_VERTEX_BUFFER
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
, FALSE
, TRUE
},
5036 {DXGI_FORMAT_R24G8_TYPELESS
, D3D11_BIND_INDEX_BUFFER
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
, FALSE
, TRUE
},
5037 {DXGI_FORMAT_R24G8_TYPELESS
, D3D11_BIND_CONSTANT_BUFFER
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
, FALSE
, TRUE
},
5038 {DXGI_FORMAT_R24G8_TYPELESS
, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
, TRUE
, FALSE
},
5039 {DXGI_FORMAT_R24G8_TYPELESS
, D3D11_BIND_DEPTH_STENCIL
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
, TRUE
, FALSE
},
5040 {DXGI_FORMAT_R8G8_TYPELESS
, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
, TRUE
, FALSE
},
5041 {DXGI_FORMAT_R16_TYPELESS
, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
, TRUE
, FALSE
},
5042 {DXGI_FORMAT_R8_TYPELESS
, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
, TRUE
, FALSE
},
5045 if (!(device
= create_device(NULL
)))
5047 skip("Failed to create device.\n");
5051 texture2d_desc
.Width
= 512;
5052 texture2d_desc
.Height
= 512;
5053 texture2d_desc
.MipLevels
= 1;
5054 texture2d_desc
.ArraySize
= 1;
5055 texture2d_desc
.SampleDesc
.Count
= 1;
5056 texture2d_desc
.SampleDesc
.Quality
= 0;
5057 texture2d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
5058 texture2d_desc
.CPUAccessFlags
= 0;
5059 texture2d_desc
.MiscFlags
= 0;
5061 texture3d_desc
.Width
= 64;
5062 texture3d_desc
.Height
= 64;
5063 texture3d_desc
.Depth
= 64;
5064 texture3d_desc
.MipLevels
= 1;
5065 texture3d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
5066 texture3d_desc
.CPUAccessFlags
= 0;
5067 texture3d_desc
.MiscFlags
= 0;
5069 for (i
= 0; i
< sizeof(tests
) / sizeof(*tests
); ++i
)
5071 if (tests
[i
].type
== D3D11_RESOURCE_DIMENSION_TEXTURE2D
)
5073 texture2d_desc
.Format
= tests
[i
].format
;
5074 texture2d_desc
.BindFlags
= tests
[i
].bind_flags
;
5075 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, (ID3D11Texture2D
**)&resource
);
5077 else if (tests
[i
].type
== D3D11_RESOURCE_DIMENSION_TEXTURE3D
)
5079 texture3d_desc
.Format
= tests
[i
].format
;
5080 texture3d_desc
.BindFlags
= tests
[i
].bind_flags
;
5081 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, (ID3D11Texture3D
**)&resource
);
5085 trace("Test %u: Unknown resource type %#x.\n", i
, tests
[i
].type
);
5089 todo_wine_if(tests
[i
].todo
)
5090 ok(hr
== (tests
[i
].succeeds
? S_OK
: E_INVALIDARG
), "Test %u: Got unexpected hr %#x.\n", i
, hr
);
5093 ID3D11Resource_Release(resource
);
5096 refcount
= ID3D11Device_Release(device
);
5097 ok(!refcount
, "Device has %u references left.\n", refcount
);
5102 test_create_device();
5103 test_device_interfaces();
5104 test_get_immediate_context();
5105 test_create_texture2d();
5106 test_texture2d_interfaces();
5107 test_create_texture3d();
5108 test_texture3d_interfaces();
5109 test_buffer_interfaces();
5110 test_create_depthstencil_view();
5111 test_depthstencil_view_interfaces();
5112 test_create_rendertarget_view();
5113 test_create_shader_resource_view();
5114 test_create_shader();
5115 test_create_sampler_state();
5116 test_create_blend_state();
5117 test_create_depthstencil_state();
5118 test_create_rasterizer_state();
5119 test_create_predicate();
5120 test_device_removed_reason();
5121 test_private_data();
5124 test_multiple_render_targets();
5126 test_il_append_aligned();
5127 test_fragment_coords();
5128 test_update_subresource();
5129 test_copy_subresource_region();
5130 test_resource_map();
5131 test_multisample_init();
5132 test_check_multisample_quality_levels();
5133 test_create_typeless_resource();