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
28 #include "wine/heap.h"
29 #include "wine/test.h"
31 #define BITS_NNAN 0xffc00000
32 #define BITS_NAN 0x7fc00000
33 #define BITS_NINF 0xff800000
34 #define BITS_INF 0x7f800000
35 #define BITS_N1_0 0xbf800000
36 #define BITS_1_0 0x3f800000
38 #define SWAPCHAIN_FLAG_SHADER_INPUT 0x1
40 static unsigned int use_adapter_idx
;
41 static BOOL enable_debug_layer
;
42 static BOOL use_warp_adapter
;
43 static BOOL use_mt
= TRUE
;
45 static struct test_entry
50 void (*test_fl
)(D3D_FEATURE_LEVEL fl
);
54 size_t mt_tests_size
, mt_test_count
;
59 D3D_FEATURE_LEVEL fl_required
;
60 D3D_FEATURE_LEVEL fl_optional
;
63 static const struct format_support display_format_support
[] =
65 {DXGI_FORMAT_R8G8B8A8_UNORM
, D3D_FEATURE_LEVEL_9_1
},
66 {DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
, D3D_FEATURE_LEVEL_9_1
},
67 {DXGI_FORMAT_B8G8R8A8_UNORM
, D3D_FEATURE_LEVEL_9_1
},
68 {DXGI_FORMAT_B8G8R8A8_UNORM_SRGB
, D3D_FEATURE_LEVEL_9_1
},
69 {DXGI_FORMAT_R16G16B16A16_FLOAT
, D3D_FEATURE_LEVEL_10_0
},
70 {DXGI_FORMAT_R10G10B10A2_UNORM
, D3D_FEATURE_LEVEL_10_0
},
71 {DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM
, D3D_FEATURE_LEVEL_11_0
, D3D_FEATURE_LEVEL_10_0
},
96 unsigned int x
, y
, z
, w
;
101 const D3D_FEATURE_LEVEL
*feature_level
;
105 struct swapchain_desc
108 unsigned buffer_count
;
109 unsigned int width
, height
;
110 DXGI_SWAP_EFFECT swap_effect
;
114 static void queue_test_entry(const struct test_entry
*t
)
116 if (mt_test_count
>= mt_tests_size
)
118 mt_tests_size
= max(16, mt_tests_size
* 2);
119 mt_tests
= heap_realloc(mt_tests
, mt_tests_size
* sizeof(*t
));
121 mt_tests
[mt_test_count
++] = *t
;
124 static void queue_test_fl(void (*test
)(const D3D_FEATURE_LEVEL fl
), D3D_FEATURE_LEVEL fl
)
130 queue_test_entry(&t
);
133 static void queue_test(void (*test
)(void))
139 queue_test_entry(&t
);
142 static void run_mt_test(const struct test_entry
*t
)
150 static DWORD WINAPI
thread_func(void *ctx
)
154 while (*i
< mt_test_count
)
157 if (InterlockedCompareExchange(i
, j
+ 1, j
) == j
)
158 run_mt_test(&mt_tests
[j
]);
164 static void run_queued_tests(void)
166 unsigned int thread_count
, i
;
173 for (i
= 0; i
< mt_test_count
; ++i
)
175 run_mt_test(&mt_tests
[i
]);
182 thread_count
= si
.dwNumberOfProcessors
;
183 threads
= heap_calloc(thread_count
, sizeof(*threads
));
184 for (i
= 0, test_idx
= 0; i
< thread_count
; ++i
)
186 threads
[i
] = CreateThread(NULL
, 0, thread_func
, &test_idx
, 0, NULL
);
187 ok(!!threads
[i
], "Failed to create thread %u.\n", i
);
189 WaitForMultipleObjects(thread_count
, threads
, TRUE
, INFINITE
);
190 for (i
= 0; i
< thread_count
; ++i
)
192 CloseHandle(threads
[i
]);
197 static void set_box(D3D11_BOX
*box
, UINT left
, UINT top
, UINT front
, UINT right
, UINT bottom
, UINT back
)
203 box
->bottom
= bottom
;
207 static ULONG
get_refcount(void *iface
)
209 IUnknown
*unknown
= iface
;
210 IUnknown_AddRef(unknown
);
211 return IUnknown_Release(unknown
);
214 #define check_interface(a, b, c, d) check_interface_(__LINE__, a, b, c, d)
215 static HRESULT
check_interface_(unsigned int line
, void *iface
, REFIID riid
, BOOL supported
, BOOL is_broken
)
217 HRESULT hr
, expected_hr
, broken_hr
;
218 IUnknown
*unknown
= iface
, *out
;
223 broken_hr
= E_NOINTERFACE
;
227 expected_hr
= E_NOINTERFACE
;
231 hr
= IUnknown_QueryInterface(unknown
, riid
, (void **)&out
);
232 ok_(__FILE__
, line
)(hr
== expected_hr
|| broken(is_broken
&& hr
== broken_hr
),
233 "Got hr %#x, expected %#x.\n", hr
, expected_hr
);
235 IUnknown_Release(out
);
239 static BOOL
compare_float(float f
, float g
, unsigned int ulps
)
249 if (abs(x
- y
) > ulps
)
255 static BOOL
compare_vec4(const struct vec4
*v1
, const struct vec4
*v2
, unsigned int ulps
)
257 return compare_float(v1
->x
, v2
->x
, ulps
)
258 && compare_float(v1
->y
, v2
->y
, ulps
)
259 && compare_float(v1
->z
, v2
->z
, ulps
)
260 && compare_float(v1
->w
, v2
->w
, ulps
);
263 static BOOL
compare_uvec4(const struct uvec4
* v1
, const struct uvec4
*v2
)
265 return v1
->x
== v2
->x
&& v1
->y
== v2
->y
&& v1
->z
== v2
->z
&& v1
->w
== v2
->w
;
268 static BOOL
compare_color(DWORD c1
, DWORD c2
, BYTE max_diff
)
270 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
)
273 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
)
276 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
)
279 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
)
287 D3D11_SRV_DIMENSION dimension
;
288 unsigned int miplevel_idx
;
289 unsigned int miplevel_count
;
290 unsigned int layer_idx
;
291 unsigned int layer_count
;
294 static void get_srv_desc(D3D11_SHADER_RESOURCE_VIEW_DESC
*d3d11_desc
, const struct srv_desc
*desc
)
296 d3d11_desc
->Format
= desc
->format
;
297 d3d11_desc
->ViewDimension
= desc
->dimension
;
298 if (desc
->dimension
== D3D11_SRV_DIMENSION_TEXTURE1D
)
300 U(*d3d11_desc
).Texture1D
.MostDetailedMip
= desc
->miplevel_idx
;
301 U(*d3d11_desc
).Texture1D
.MipLevels
= desc
->miplevel_count
;
303 else if (desc
->dimension
== D3D11_SRV_DIMENSION_TEXTURE1DARRAY
)
305 U(*d3d11_desc
).Texture1DArray
.MostDetailedMip
= desc
->miplevel_idx
;
306 U(*d3d11_desc
).Texture1DArray
.MipLevels
= desc
->miplevel_count
;
307 U(*d3d11_desc
).Texture1DArray
.FirstArraySlice
= desc
->layer_idx
;
308 U(*d3d11_desc
).Texture1DArray
.ArraySize
= desc
->layer_count
;
310 else if (desc
->dimension
== D3D11_SRV_DIMENSION_TEXTURE2D
)
312 U(*d3d11_desc
).Texture2D
.MostDetailedMip
= desc
->miplevel_idx
;
313 U(*d3d11_desc
).Texture2D
.MipLevels
= desc
->miplevel_count
;
315 else if (desc
->dimension
== D3D11_SRV_DIMENSION_TEXTURE2DARRAY
)
317 U(*d3d11_desc
).Texture2DArray
.MostDetailedMip
= desc
->miplevel_idx
;
318 U(*d3d11_desc
).Texture2DArray
.MipLevels
= desc
->miplevel_count
;
319 U(*d3d11_desc
).Texture2DArray
.FirstArraySlice
= desc
->layer_idx
;
320 U(*d3d11_desc
).Texture2DArray
.ArraySize
= desc
->layer_count
;
322 else if (desc
->dimension
== D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY
)
324 U(*d3d11_desc
).Texture2DMSArray
.FirstArraySlice
= desc
->layer_idx
;
325 U(*d3d11_desc
).Texture2DMSArray
.ArraySize
= desc
->layer_count
;
327 else if (desc
->dimension
== D3D11_SRV_DIMENSION_TEXTURE3D
)
329 U(*d3d11_desc
).Texture3D
.MostDetailedMip
= desc
->miplevel_idx
;
330 U(*d3d11_desc
).Texture3D
.MipLevels
= desc
->miplevel_count
;
332 else if (desc
->dimension
== D3D11_SRV_DIMENSION_TEXTURECUBE
)
334 U(*d3d11_desc
).TextureCube
.MostDetailedMip
= desc
->miplevel_idx
;
335 U(*d3d11_desc
).TextureCube
.MipLevels
= desc
->miplevel_count
;
337 else if (desc
->dimension
== D3D11_SRV_DIMENSION_TEXTURECUBEARRAY
)
339 U(*d3d11_desc
).TextureCubeArray
.MostDetailedMip
= desc
->miplevel_idx
;
340 U(*d3d11_desc
).TextureCubeArray
.MipLevels
= desc
->miplevel_count
;
341 U(*d3d11_desc
).TextureCubeArray
.First2DArrayFace
= desc
->layer_idx
;
342 U(*d3d11_desc
).TextureCubeArray
.NumCubes
= desc
->layer_count
;
344 else if (desc
->dimension
!= D3D11_SRV_DIMENSION_UNKNOWN
345 && desc
->dimension
!= D3D11_SRV_DIMENSION_TEXTURE2DMS
)
347 trace("Unhandled view dimension %#x.\n", desc
->dimension
);
351 #define check_srv_desc(a, b) check_srv_desc_(__LINE__, a, b)
352 static void check_srv_desc_(unsigned int line
, const D3D11_SHADER_RESOURCE_VIEW_DESC
*desc
,
353 const struct srv_desc
*expected_desc
)
355 ok_(__FILE__
, line
)(desc
->Format
== expected_desc
->format
,
356 "Got format %#x, expected %#x.\n", desc
->Format
, expected_desc
->format
);
357 ok_(__FILE__
, line
)(desc
->ViewDimension
== expected_desc
->dimension
,
358 "Got view dimension %#x, expected %#x.\n", desc
->ViewDimension
, expected_desc
->dimension
);
360 if (desc
->ViewDimension
!= expected_desc
->dimension
)
363 if (desc
->ViewDimension
== D3D11_SRV_DIMENSION_TEXTURE2D
)
365 ok_(__FILE__
, line
)(U(*desc
).Texture2D
.MostDetailedMip
== expected_desc
->miplevel_idx
,
366 "Got MostDetailedMip %u, expected %u.\n",
367 U(*desc
).Texture2D
.MostDetailedMip
, expected_desc
->miplevel_idx
);
368 ok_(__FILE__
, line
)(U(*desc
).Texture2D
.MipLevels
== expected_desc
->miplevel_count
,
369 "Got MipLevels %u, expected %u.\n",
370 U(*desc
).Texture2D
.MipLevels
, expected_desc
->miplevel_count
);
372 else if (desc
->ViewDimension
== D3D11_SRV_DIMENSION_TEXTURE2DARRAY
)
374 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.MostDetailedMip
== expected_desc
->miplevel_idx
,
375 "Got MostDetailedMip %u, expected %u.\n",
376 U(*desc
).Texture2DArray
.MostDetailedMip
, expected_desc
->miplevel_idx
);
377 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.MipLevels
== expected_desc
->miplevel_count
,
378 "Got MipLevels %u, expected %u.\n",
379 U(*desc
).Texture2DArray
.MipLevels
, expected_desc
->miplevel_count
);
380 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.FirstArraySlice
== expected_desc
->layer_idx
,
381 "Got FirstArraySlice %u, expected %u.\n",
382 U(*desc
).Texture2DArray
.FirstArraySlice
, expected_desc
->layer_idx
);
383 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.ArraySize
== expected_desc
->layer_count
,
384 "Got ArraySize %u, expected %u.\n",
385 U(*desc
).Texture2DArray
.ArraySize
, expected_desc
->layer_count
);
387 else if (desc
->ViewDimension
== D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY
)
389 ok_(__FILE__
, line
)(U(*desc
).Texture2DMSArray
.FirstArraySlice
== expected_desc
->layer_idx
,
390 "Got FirstArraySlice %u, expected %u.\n",
391 U(*desc
).Texture2DMSArray
.FirstArraySlice
, expected_desc
->layer_idx
);
392 ok_(__FILE__
, line
)(U(*desc
).Texture2DMSArray
.ArraySize
== expected_desc
->layer_count
,
393 "Got ArraySize %u, expected %u.\n",
394 U(*desc
).Texture2DMSArray
.ArraySize
, expected_desc
->layer_count
);
396 else if (desc
->ViewDimension
== D3D11_SRV_DIMENSION_TEXTURE3D
)
398 ok_(__FILE__
, line
)(U(*desc
).Texture3D
.MostDetailedMip
== expected_desc
->miplevel_idx
,
399 "Got MostDetailedMip %u, expected %u.\n",
400 U(*desc
).Texture3D
.MostDetailedMip
, expected_desc
->miplevel_idx
);
401 ok_(__FILE__
, line
)(U(*desc
).Texture3D
.MipLevels
== expected_desc
->miplevel_count
,
402 "Got MipLevels %u, expected %u.\n",
403 U(*desc
).Texture3D
.MipLevels
, expected_desc
->miplevel_count
);
405 else if (desc
->ViewDimension
== D3D11_SRV_DIMENSION_TEXTURECUBE
)
407 ok_(__FILE__
, line
)(U(*desc
).TextureCube
.MostDetailedMip
== expected_desc
->miplevel_idx
,
408 "Got MostDetailedMip %u, expected %u.\n",
409 U(*desc
).TextureCube
.MostDetailedMip
, expected_desc
->miplevel_idx
);
410 ok_(__FILE__
, line
)(U(*desc
).TextureCube
.MipLevels
== expected_desc
->miplevel_count
,
411 "Got MipLevels %u, expected %u.\n",
412 U(*desc
).TextureCube
.MipLevels
, expected_desc
->miplevel_count
);
414 else if (desc
->ViewDimension
== D3D11_SRV_DIMENSION_TEXTURECUBEARRAY
)
416 ok_(__FILE__
, line
)(U(*desc
).TextureCubeArray
.MostDetailedMip
== expected_desc
->miplevel_idx
,
417 "Got MostDetailedMip %u, expected %u.\n",
418 U(*desc
).TextureCubeArray
.MostDetailedMip
, expected_desc
->miplevel_idx
);
419 ok_(__FILE__
, line
)(U(*desc
).TextureCubeArray
.MipLevels
== expected_desc
->miplevel_count
,
420 "Got MipLevels %u, expected %u.\n",
421 U(*desc
).TextureCubeArray
.MipLevels
, expected_desc
->miplevel_count
);
422 ok_(__FILE__
, line
)(U(*desc
).TextureCubeArray
.First2DArrayFace
== expected_desc
->layer_idx
,
423 "Got First2DArrayFace %u, expected %u.\n",
424 U(*desc
).TextureCubeArray
.First2DArrayFace
, expected_desc
->layer_idx
);
425 ok_(__FILE__
, line
)(U(*desc
).TextureCubeArray
.NumCubes
== expected_desc
->layer_count
,
426 "Got NumCubes %u, expected %u.\n",
427 U(*desc
).TextureCubeArray
.NumCubes
, expected_desc
->layer_count
);
429 else if (desc
->ViewDimension
!= D3D11_SRV_DIMENSION_TEXTURE2DMS
)
431 trace("Unhandled view dimension %#x.\n", desc
->ViewDimension
);
438 D3D11_RTV_DIMENSION dimension
;
439 unsigned int miplevel_idx
;
440 unsigned int layer_idx
;
441 unsigned int layer_count
;
444 static void get_rtv_desc(D3D11_RENDER_TARGET_VIEW_DESC
*d3d11_desc
, const struct rtv_desc
*desc
)
446 d3d11_desc
->Format
= desc
->format
;
447 d3d11_desc
->ViewDimension
= desc
->dimension
;
448 if (desc
->dimension
== D3D11_RTV_DIMENSION_TEXTURE1D
)
450 U(*d3d11_desc
).Texture1D
.MipSlice
= desc
->miplevel_idx
;
452 else if (desc
->dimension
== D3D11_RTV_DIMENSION_TEXTURE1DARRAY
)
454 U(*d3d11_desc
).Texture1DArray
.MipSlice
= desc
->miplevel_idx
;
455 U(*d3d11_desc
).Texture1DArray
.FirstArraySlice
= desc
->layer_idx
;
456 U(*d3d11_desc
).Texture1DArray
.ArraySize
= desc
->layer_count
;
458 else if (desc
->dimension
== D3D11_RTV_DIMENSION_TEXTURE2D
)
460 U(*d3d11_desc
).Texture2D
.MipSlice
= desc
->miplevel_idx
;
462 else if (desc
->dimension
== D3D11_RTV_DIMENSION_TEXTURE2DARRAY
)
464 U(*d3d11_desc
).Texture2DArray
.MipSlice
= desc
->miplevel_idx
;
465 U(*d3d11_desc
).Texture2DArray
.FirstArraySlice
= desc
->layer_idx
;
466 U(*d3d11_desc
).Texture2DArray
.ArraySize
= desc
->layer_count
;
468 else if (desc
->dimension
== D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY
)
470 U(*d3d11_desc
).Texture2DMSArray
.FirstArraySlice
= desc
->layer_idx
;
471 U(*d3d11_desc
).Texture2DMSArray
.ArraySize
= desc
->layer_count
;
473 else if (desc
->dimension
== D3D11_RTV_DIMENSION_TEXTURE3D
)
475 U(*d3d11_desc
).Texture3D
.MipSlice
= desc
->miplevel_idx
;
476 U(*d3d11_desc
).Texture3D
.FirstWSlice
= desc
->layer_idx
;
477 U(*d3d11_desc
).Texture3D
.WSize
= desc
->layer_count
;
479 else if (desc
->dimension
!= D3D11_RTV_DIMENSION_UNKNOWN
480 && desc
->dimension
!= D3D11_RTV_DIMENSION_TEXTURE2DMS
)
482 trace("Unhandled view dimension %#x.\n", desc
->dimension
);
486 #define check_rtv_desc(a, b) check_rtv_desc_(__LINE__, a, b)
487 static void check_rtv_desc_(unsigned int line
, const D3D11_RENDER_TARGET_VIEW_DESC
*desc
,
488 const struct rtv_desc
*expected_desc
)
490 ok_(__FILE__
, line
)(desc
->Format
== expected_desc
->format
,
491 "Got format %#x, expected %#x.\n", desc
->Format
, expected_desc
->format
);
492 ok_(__FILE__
, line
)(desc
->ViewDimension
== expected_desc
->dimension
,
493 "Got view dimension %#x, expected %#x.\n", desc
->ViewDimension
, expected_desc
->dimension
);
495 if (desc
->ViewDimension
!= expected_desc
->dimension
)
498 if (desc
->ViewDimension
== D3D11_RTV_DIMENSION_TEXTURE2D
)
500 ok_(__FILE__
, line
)(U(*desc
).Texture2D
.MipSlice
== expected_desc
->miplevel_idx
,
501 "Got MipSlice %u, expected %u.\n",
502 U(*desc
).Texture2D
.MipSlice
, expected_desc
->miplevel_idx
);
504 else if (desc
->ViewDimension
== D3D11_RTV_DIMENSION_TEXTURE2DARRAY
)
506 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.MipSlice
== expected_desc
->miplevel_idx
,
507 "Got MipSlice %u, expected %u.\n",
508 U(*desc
).Texture2DArray
.MipSlice
, expected_desc
->miplevel_idx
);
509 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.FirstArraySlice
== expected_desc
->layer_idx
,
510 "Got FirstArraySlice %u, expected %u.\n",
511 U(*desc
).Texture2DArray
.FirstArraySlice
, expected_desc
->layer_idx
);
512 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.ArraySize
== expected_desc
->layer_count
,
513 "Got ArraySize %u, expected %u.\n",
514 U(*desc
).Texture2DArray
.ArraySize
, expected_desc
->layer_count
);
516 else if (desc
->ViewDimension
== D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY
)
518 ok_(__FILE__
, line
)(U(*desc
).Texture2DMSArray
.FirstArraySlice
== expected_desc
->layer_idx
,
519 "Got FirstArraySlice %u, expected %u.\n",
520 U(*desc
).Texture2DMSArray
.FirstArraySlice
, expected_desc
->layer_idx
);
521 ok_(__FILE__
, line
)(U(*desc
).Texture2DMSArray
.ArraySize
== expected_desc
->layer_count
,
522 "Got ArraySize %u, expected %u.\n",
523 U(*desc
).Texture2DMSArray
.ArraySize
, expected_desc
->layer_count
);
525 else if (desc
->ViewDimension
== D3D11_RTV_DIMENSION_TEXTURE3D
)
527 ok_(__FILE__
, line
)(U(*desc
).Texture3D
.MipSlice
== expected_desc
->miplevel_idx
,
528 "Got MipSlice %u, expected %u.\n",
529 U(*desc
).Texture3D
.MipSlice
, expected_desc
->miplevel_idx
);
530 ok_(__FILE__
, line
)(U(*desc
).Texture3D
.FirstWSlice
== expected_desc
->layer_idx
,
531 "Got FirstWSlice %u, expected %u.\n",
532 U(*desc
).Texture3D
.FirstWSlice
, expected_desc
->layer_idx
);
533 ok_(__FILE__
, line
)(U(*desc
).Texture3D
.WSize
== expected_desc
->layer_count
,
534 "Got WSize %u, expected %u.\n",
535 U(*desc
).Texture3D
.WSize
, expected_desc
->layer_count
);
537 else if (desc
->ViewDimension
!= D3D11_RTV_DIMENSION_TEXTURE2DMS
)
539 trace("Unhandled view dimension %#x.\n", desc
->ViewDimension
);
546 D3D11_DSV_DIMENSION dimension
;
547 unsigned int miplevel_idx
;
548 unsigned int layer_idx
;
549 unsigned int layer_count
;
552 static void get_dsv_desc(D3D11_DEPTH_STENCIL_VIEW_DESC
*d3d11_desc
, const struct dsv_desc
*desc
)
554 d3d11_desc
->Format
= desc
->format
;
555 d3d11_desc
->ViewDimension
= desc
->dimension
;
556 d3d11_desc
->Flags
= 0;
557 if (desc
->dimension
== D3D11_DSV_DIMENSION_TEXTURE1D
)
559 U(*d3d11_desc
).Texture1D
.MipSlice
= desc
->miplevel_idx
;
561 else if (desc
->dimension
== D3D11_DSV_DIMENSION_TEXTURE1DARRAY
)
563 U(*d3d11_desc
).Texture1DArray
.MipSlice
= desc
->miplevel_idx
;
564 U(*d3d11_desc
).Texture1DArray
.FirstArraySlice
= desc
->layer_idx
;
565 U(*d3d11_desc
).Texture1DArray
.ArraySize
= desc
->layer_count
;
567 else if (desc
->dimension
== D3D11_DSV_DIMENSION_TEXTURE2D
)
569 U(*d3d11_desc
).Texture2D
.MipSlice
= desc
->miplevel_idx
;
571 else if (desc
->dimension
== D3D11_DSV_DIMENSION_TEXTURE2DARRAY
)
573 U(*d3d11_desc
).Texture2DArray
.MipSlice
= desc
->miplevel_idx
;
574 U(*d3d11_desc
).Texture2DArray
.FirstArraySlice
= desc
->layer_idx
;
575 U(*d3d11_desc
).Texture2DArray
.ArraySize
= desc
->layer_count
;
577 else if (desc
->dimension
== D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY
)
579 U(*d3d11_desc
).Texture2DMSArray
.FirstArraySlice
= desc
->layer_idx
;
580 U(*d3d11_desc
).Texture2DMSArray
.ArraySize
= desc
->layer_count
;
582 else if (desc
->dimension
!= D3D11_DSV_DIMENSION_UNKNOWN
583 && desc
->dimension
!= D3D11_DSV_DIMENSION_TEXTURE2DMS
)
585 trace("Unhandled view dimension %#x.\n", desc
->dimension
);
589 #define check_dsv_desc(a, b) check_dsv_desc_(__LINE__, a, b)
590 static void check_dsv_desc_(unsigned int line
, const D3D11_DEPTH_STENCIL_VIEW_DESC
*desc
,
591 const struct dsv_desc
*expected_desc
)
593 ok_(__FILE__
, line
)(desc
->Format
== expected_desc
->format
,
594 "Got format %#x, expected %#x.\n", desc
->Format
, expected_desc
->format
);
595 ok_(__FILE__
, line
)(desc
->ViewDimension
== expected_desc
->dimension
,
596 "Got view dimension %#x, expected %#x.\n", desc
->ViewDimension
, expected_desc
->dimension
);
598 if (desc
->ViewDimension
!= expected_desc
->dimension
)
601 if (desc
->ViewDimension
== D3D11_DSV_DIMENSION_TEXTURE2D
)
603 ok_(__FILE__
, line
)(U(*desc
).Texture2D
.MipSlice
== expected_desc
->miplevel_idx
,
604 "Got MipSlice %u, expected %u.\n",
605 U(*desc
).Texture2D
.MipSlice
, expected_desc
->miplevel_idx
);
607 else if (desc
->ViewDimension
== D3D11_DSV_DIMENSION_TEXTURE2DARRAY
)
609 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.MipSlice
== expected_desc
->miplevel_idx
,
610 "Got MipSlice %u, expected %u.\n",
611 U(*desc
).Texture2DArray
.MipSlice
, expected_desc
->miplevel_idx
);
612 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.FirstArraySlice
== expected_desc
->layer_idx
,
613 "Got FirstArraySlice %u, expected %u.\n",
614 U(*desc
).Texture2DArray
.FirstArraySlice
, expected_desc
->layer_idx
);
615 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.ArraySize
== expected_desc
->layer_count
,
616 "Got ArraySize %u, expected %u.\n",
617 U(*desc
).Texture2DArray
.ArraySize
, expected_desc
->layer_count
);
619 else if (desc
->ViewDimension
== D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY
)
621 ok_(__FILE__
, line
)(U(*desc
).Texture2DMSArray
.FirstArraySlice
== expected_desc
->layer_idx
,
622 "Got FirstArraySlice %u, expected %u.\n",
623 U(*desc
).Texture2DMSArray
.FirstArraySlice
, expected_desc
->layer_idx
);
624 ok_(__FILE__
, line
)(U(*desc
).Texture2DMSArray
.ArraySize
== expected_desc
->layer_count
,
625 "Got ArraySize %u, expected %u.\n",
626 U(*desc
).Texture2DMSArray
.ArraySize
, expected_desc
->layer_count
);
628 else if (desc
->ViewDimension
!= D3D11_DSV_DIMENSION_TEXTURE2DMS
)
630 trace("Unhandled view dimension %#x.\n", desc
->ViewDimension
);
637 D3D11_UAV_DIMENSION dimension
;
638 unsigned int miplevel_idx
;
639 unsigned int layer_idx
;
640 unsigned int layer_count
;
643 static void get_uav_desc(D3D11_UNORDERED_ACCESS_VIEW_DESC
*d3d11_desc
, const struct uav_desc
*desc
)
645 d3d11_desc
->Format
= desc
->format
;
646 d3d11_desc
->ViewDimension
= desc
->dimension
;
647 if (desc
->dimension
== D3D11_UAV_DIMENSION_TEXTURE1D
)
649 U(*d3d11_desc
).Texture1D
.MipSlice
= desc
->miplevel_idx
;
651 else if (desc
->dimension
== D3D11_UAV_DIMENSION_TEXTURE1DARRAY
)
653 U(*d3d11_desc
).Texture1DArray
.MipSlice
= desc
->miplevel_idx
;
654 U(*d3d11_desc
).Texture1DArray
.FirstArraySlice
= desc
->layer_idx
;
655 U(*d3d11_desc
).Texture1DArray
.ArraySize
= desc
->layer_count
;
657 else if (desc
->dimension
== D3D11_UAV_DIMENSION_TEXTURE2D
)
659 U(*d3d11_desc
).Texture2D
.MipSlice
= desc
->miplevel_idx
;
661 else if (desc
->dimension
== D3D11_UAV_DIMENSION_TEXTURE2DARRAY
)
663 U(*d3d11_desc
).Texture2DArray
.MipSlice
= desc
->miplevel_idx
;
664 U(*d3d11_desc
).Texture2DArray
.FirstArraySlice
= desc
->layer_idx
;
665 U(*d3d11_desc
).Texture2DArray
.ArraySize
= desc
->layer_count
;
667 else if (desc
->dimension
== D3D11_UAV_DIMENSION_TEXTURE3D
)
669 U(*d3d11_desc
).Texture3D
.MipSlice
= desc
->miplevel_idx
;
670 U(*d3d11_desc
).Texture3D
.FirstWSlice
= desc
->layer_idx
;
671 U(*d3d11_desc
).Texture3D
.WSize
= desc
->layer_count
;
673 else if (desc
->dimension
!= D3D11_UAV_DIMENSION_UNKNOWN
)
675 trace("Unhandled view dimension %#x.\n", desc
->dimension
);
679 #define check_uav_desc(a, b) check_uav_desc_(__LINE__, a, b)
680 static void check_uav_desc_(unsigned int line
, const D3D11_UNORDERED_ACCESS_VIEW_DESC
*desc
,
681 const struct uav_desc
*expected_desc
)
683 ok_(__FILE__
, line
)(desc
->Format
== expected_desc
->format
,
684 "Got format %#x, expected %#x.\n", desc
->Format
, expected_desc
->format
);
685 ok_(__FILE__
, line
)(desc
->ViewDimension
== expected_desc
->dimension
,
686 "Got view dimension %#x, expected %#x.\n", desc
->ViewDimension
, expected_desc
->dimension
);
688 if (desc
->ViewDimension
!= expected_desc
->dimension
)
691 if (desc
->ViewDimension
== D3D11_UAV_DIMENSION_TEXTURE2D
)
693 ok_(__FILE__
, line
)(U(*desc
).Texture2D
.MipSlice
== expected_desc
->miplevel_idx
,
694 "Got MipSlice %u, expected %u.\n",
695 U(*desc
).Texture2D
.MipSlice
, expected_desc
->miplevel_idx
);
697 else if (desc
->ViewDimension
== D3D11_UAV_DIMENSION_TEXTURE2DARRAY
)
699 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.MipSlice
== expected_desc
->miplevel_idx
,
700 "Got MipSlice %u, expected %u.\n",
701 U(*desc
).Texture2DArray
.MipSlice
, expected_desc
->miplevel_idx
);
702 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.FirstArraySlice
== expected_desc
->layer_idx
,
703 "Got FirstArraySlice %u, expected %u.\n",
704 U(*desc
).Texture2DArray
.FirstArraySlice
, expected_desc
->layer_idx
);
705 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.ArraySize
== expected_desc
->layer_count
,
706 "Got ArraySize %u, expected %u.\n",
707 U(*desc
).Texture2DArray
.ArraySize
, expected_desc
->layer_count
);
709 else if (desc
->ViewDimension
== D3D11_UAV_DIMENSION_TEXTURE3D
)
711 ok_(__FILE__
, line
)(U(*desc
).Texture3D
.MipSlice
== expected_desc
->miplevel_idx
,
712 "Got MipSlice %u, expected %u.\n",
713 U(*desc
).Texture3D
.MipSlice
, expected_desc
->miplevel_idx
);
714 ok_(__FILE__
, line
)(U(*desc
).Texture3D
.FirstWSlice
== expected_desc
->layer_idx
,
715 "Got FirstWSlice %u, expected %u.\n",
716 U(*desc
).Texture3D
.FirstWSlice
, expected_desc
->layer_idx
);
717 ok_(__FILE__
, line
)(U(*desc
).Texture3D
.WSize
== expected_desc
->layer_count
,
718 "Got WSize %u, expected %u.\n",
719 U(*desc
).Texture3D
.WSize
, expected_desc
->layer_count
);
723 trace("Unhandled view dimension %#x.\n", desc
->ViewDimension
);
727 static void set_viewport(ID3D11DeviceContext
*context
, float x
, float y
,
728 float width
, float height
, float min_depth
, float max_depth
)
736 vp
.MinDepth
= min_depth
;
737 vp
.MaxDepth
= max_depth
;
739 ID3D11DeviceContext_RSSetViewports(context
, 1, &vp
);
742 #define create_buffer(a, b, c, d) create_buffer_(__LINE__, a, b, 0, c, d)
743 #define create_buffer_misc(a, b, c, d, e) create_buffer_(__LINE__, a, b, c, d, e)
744 static ID3D11Buffer
*create_buffer_(unsigned int line
, ID3D11Device
*device
,
745 unsigned int bind_flags
, unsigned int misc_flags
, unsigned int size
, const void *data
)
747 D3D11_SUBRESOURCE_DATA resource_data
;
748 D3D11_BUFFER_DESC buffer_desc
;
749 ID3D11Buffer
*buffer
;
752 buffer_desc
.ByteWidth
= size
;
753 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
754 buffer_desc
.BindFlags
= bind_flags
;
755 buffer_desc
.CPUAccessFlags
= 0;
756 buffer_desc
.MiscFlags
= misc_flags
;
757 buffer_desc
.StructureByteStride
= 0;
759 resource_data
.pSysMem
= data
;
760 resource_data
.SysMemPitch
= 0;
761 resource_data
.SysMemSlicePitch
= 0;
763 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, data
? &resource_data
: NULL
, &buffer
);
764 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
768 struct resource_readback
770 ID3D11Resource
*resource
;
771 D3D11_MAPPED_SUBRESOURCE map_desc
;
772 ID3D11DeviceContext
*immediate_context
;
773 unsigned int width
, height
, depth
, sub_resource_idx
;
776 static void init_resource_readback(ID3D11Resource
*resource
, ID3D11Resource
*readback_resource
,
777 unsigned int width
, unsigned int height
, unsigned int depth
, unsigned int sub_resource_idx
,
778 ID3D11Device
*device
, struct resource_readback
*rb
)
782 rb
->resource
= readback_resource
;
786 rb
->sub_resource_idx
= sub_resource_idx
;
788 ID3D11Device_GetImmediateContext(device
, &rb
->immediate_context
);
790 ID3D11DeviceContext_CopyResource(rb
->immediate_context
, rb
->resource
, resource
);
791 if (FAILED(hr
= ID3D11DeviceContext_Map(rb
->immediate_context
,
792 rb
->resource
, sub_resource_idx
, D3D11_MAP_READ
, 0, &rb
->map_desc
)))
794 trace("Failed to map resource, hr %#x.\n", hr
);
795 ID3D11Resource_Release(rb
->resource
);
797 ID3D11DeviceContext_Release(rb
->immediate_context
);
798 rb
->immediate_context
= NULL
;
802 static void get_buffer_readback(ID3D11Buffer
*buffer
, struct resource_readback
*rb
)
804 D3D11_BUFFER_DESC buffer_desc
;
805 ID3D11Resource
*rb_buffer
;
806 ID3D11Device
*device
;
809 memset(rb
, 0, sizeof(*rb
));
811 ID3D11Buffer_GetDevice(buffer
, &device
);
813 ID3D11Buffer_GetDesc(buffer
, &buffer_desc
);
814 buffer_desc
.Usage
= D3D11_USAGE_STAGING
;
815 buffer_desc
.BindFlags
= 0;
816 buffer_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
;
817 buffer_desc
.MiscFlags
= 0;
818 buffer_desc
.StructureByteStride
= 0;
819 if (FAILED(hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, (ID3D11Buffer
**)&rb_buffer
)))
821 trace("Failed to create staging buffer, hr %#x.\n", hr
);
822 ID3D11Device_Release(device
);
826 init_resource_readback((ID3D11Resource
*)buffer
, rb_buffer
,
827 buffer_desc
.ByteWidth
, 1, 1, 0, device
, rb
);
829 ID3D11Device_Release(device
);
832 static void get_texture1d_readback(ID3D11Texture1D
*texture
, unsigned int sub_resource_idx
,
833 struct resource_readback
*rb
)
835 D3D11_TEXTURE1D_DESC texture_desc
;
836 ID3D11Resource
*rb_texture
;
837 unsigned int miplevel
;
838 ID3D11Device
*device
;
841 memset(rb
, 0, sizeof(*rb
));
843 ID3D11Texture1D_GetDevice(texture
, &device
);
845 ID3D11Texture1D_GetDesc(texture
, &texture_desc
);
846 texture_desc
.Usage
= D3D11_USAGE_STAGING
;
847 texture_desc
.BindFlags
= 0;
848 texture_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
;
849 texture_desc
.MiscFlags
= 0;
850 if (FAILED(hr
= ID3D11Device_CreateTexture1D(device
, &texture_desc
, NULL
, (ID3D11Texture1D
**)&rb_texture
)))
852 trace("Failed to create texture, hr %#x.\n", hr
);
853 ID3D11Device_Release(device
);
857 miplevel
= sub_resource_idx
% texture_desc
.MipLevels
;
858 init_resource_readback((ID3D11Resource
*)texture
, rb_texture
,
859 max(1, texture_desc
.Width
>> miplevel
), 1, 1, sub_resource_idx
, device
, rb
);
861 ID3D11Device_Release(device
);
864 static void get_texture_readback(ID3D11Texture2D
*texture
, unsigned int sub_resource_idx
,
865 struct resource_readback
*rb
)
867 D3D11_TEXTURE2D_DESC texture_desc
;
868 ID3D11Resource
*rb_texture
;
869 unsigned int miplevel
;
870 ID3D11Device
*device
;
873 memset(rb
, 0, sizeof(*rb
));
875 ID3D11Texture2D_GetDevice(texture
, &device
);
877 ID3D11Texture2D_GetDesc(texture
, &texture_desc
);
878 texture_desc
.Usage
= D3D11_USAGE_STAGING
;
879 texture_desc
.BindFlags
= 0;
880 texture_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
;
881 texture_desc
.MiscFlags
= 0;
882 if (FAILED(hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, (ID3D11Texture2D
**)&rb_texture
)))
884 trace("Failed to create texture, hr %#x.\n", hr
);
885 ID3D11Device_Release(device
);
889 miplevel
= sub_resource_idx
% texture_desc
.MipLevels
;
890 init_resource_readback((ID3D11Resource
*)texture
, rb_texture
,
891 max(1, texture_desc
.Width
>> miplevel
),
892 max(1, texture_desc
.Height
>> miplevel
),
893 1, sub_resource_idx
, device
, rb
);
895 ID3D11Device_Release(device
);
898 static void get_texture3d_readback(ID3D11Texture3D
*texture
, unsigned int sub_resource_idx
,
899 struct resource_readback
*rb
)
901 D3D11_TEXTURE3D_DESC texture_desc
;
902 ID3D11Resource
*rb_texture
;
903 unsigned int miplevel
;
904 ID3D11Device
*device
;
907 memset(rb
, 0, sizeof(*rb
));
909 ID3D11Texture3D_GetDevice(texture
, &device
);
911 ID3D11Texture3D_GetDesc(texture
, &texture_desc
);
912 texture_desc
.Usage
= D3D11_USAGE_STAGING
;
913 texture_desc
.BindFlags
= 0;
914 texture_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
;
915 texture_desc
.MiscFlags
= 0;
916 if (FAILED(hr
= ID3D11Device_CreateTexture3D(device
, &texture_desc
, NULL
, (ID3D11Texture3D
**)&rb_texture
)))
918 trace("Failed to create texture, hr %#x.\n", hr
);
919 ID3D11Device_Release(device
);
923 miplevel
= sub_resource_idx
% texture_desc
.MipLevels
;
924 init_resource_readback((ID3D11Resource
*)texture
, rb_texture
,
925 max(1, texture_desc
.Width
>> miplevel
),
926 max(1, texture_desc
.Height
>> miplevel
),
927 max(1, texture_desc
.Depth
>> miplevel
),
928 sub_resource_idx
, device
, rb
);
930 ID3D11Device_Release(device
);
933 static void *get_readback_data(struct resource_readback
*rb
,
934 unsigned int x
, unsigned int y
, unsigned int z
, unsigned byte_width
)
936 return (BYTE
*)rb
->map_desc
.pData
+ z
* rb
->map_desc
.DepthPitch
+ y
* rb
->map_desc
.RowPitch
+ x
* byte_width
;
939 static BYTE
get_readback_u8(struct resource_readback
*rb
, unsigned int x
, unsigned int y
, unsigned int z
)
941 return *(BYTE
*)get_readback_data(rb
, x
, y
, z
, sizeof(BYTE
));
944 static WORD
get_readback_u16(struct resource_readback
*rb
, unsigned int x
, unsigned int y
, unsigned int z
)
946 return *(WORD
*)get_readback_data(rb
, x
, y
, z
, sizeof(WORD
));
949 static DWORD
get_readback_u32(struct resource_readback
*rb
, unsigned int x
, unsigned int y
, unsigned int z
)
951 return *(DWORD
*)get_readback_data(rb
, x
, y
, z
, sizeof(DWORD
));
954 static DWORD
get_readback_color(struct resource_readback
*rb
, unsigned int x
, unsigned int y
, unsigned int z
)
956 return get_readback_u32(rb
, x
, y
, z
);
959 static float get_readback_float(struct resource_readback
*rb
, unsigned int x
, unsigned int y
)
961 return *(float *)get_readback_data(rb
, x
, y
, 0, sizeof(float));
964 static const struct vec4
*get_readback_vec4(struct resource_readback
*rb
, unsigned int x
, unsigned int y
)
966 return get_readback_data(rb
, x
, y
, 0, sizeof(struct vec4
));
969 static const struct uvec4
*get_readback_uvec4(struct resource_readback
*rb
, unsigned int x
, unsigned int y
)
971 return get_readback_data(rb
, x
, y
, 0, sizeof(struct uvec4
));
974 static void release_resource_readback(struct resource_readback
*rb
)
976 ID3D11DeviceContext_Unmap(rb
->immediate_context
, rb
->resource
, rb
->sub_resource_idx
);
977 ID3D11Resource_Release(rb
->resource
);
978 ID3D11DeviceContext_Release(rb
->immediate_context
);
981 static DWORD
get_texture_color(ID3D11Texture2D
*texture
, unsigned int x
, unsigned int y
)
983 struct resource_readback rb
;
986 get_texture_readback(texture
, 0, &rb
);
987 color
= get_readback_color(&rb
, x
, y
, 0);
988 release_resource_readback(&rb
);
993 #define check_readback_data_u8(a, b, c, d) check_readback_data_u8_(__LINE__, a, b, c, d)
994 static void check_readback_data_u8_(unsigned int line
, struct resource_readback
*rb
,
995 const RECT
*rect
, BYTE expected_value
, BYTE max_diff
)
997 unsigned int x
= 0, y
= 0, z
= 0;
998 BOOL all_match
= FALSE
;
1004 SetRect(&default_rect
, 0, 0, rb
->width
, rb
->height
);
1005 rect
= &default_rect
;
1008 for (z
= 0; z
< rb
->depth
; ++z
)
1010 for (y
= rect
->top
; y
< rect
->bottom
; ++y
)
1012 for (x
= rect
->left
; x
< rect
->right
; ++x
)
1014 value
= get_readback_u8(rb
, x
, y
, z
);
1015 if (abs((int)value
- (int)expected_value
) > max_diff
)
1023 ok_(__FILE__
, line
)(all_match
,
1024 "Got 0x%02x, expected 0x%02x at (%u, %u, %u), sub-resource %u.\n",
1025 value
, expected_value
, x
, y
, z
, rb
->sub_resource_idx
);
1028 #define check_readback_data_u16(a, b, c, d) check_readback_data_u16_(__LINE__, a, b, c, d)
1029 static void check_readback_data_u16_(unsigned int line
, struct resource_readback
*rb
,
1030 const RECT
*rect
, WORD expected_value
, BYTE max_diff
)
1032 unsigned int x
= 0, y
= 0, z
= 0;
1033 BOOL all_match
= FALSE
;
1039 SetRect(&default_rect
, 0, 0, rb
->width
, rb
->height
);
1040 rect
= &default_rect
;
1043 for (z
= 0; z
< rb
->depth
; ++z
)
1045 for (y
= rect
->top
; y
< rect
->bottom
; ++y
)
1047 for (x
= rect
->left
; x
< rect
->right
; ++x
)
1049 value
= get_readback_u16(rb
, x
, y
, z
);
1050 if (abs((int)value
- (int)expected_value
) > max_diff
)
1058 ok_(__FILE__
, line
)(all_match
,
1059 "Got 0x%04x, expected 0x%04x at (%u, %u, %u), sub-resource %u.\n",
1060 value
, expected_value
, x
, y
, z
, rb
->sub_resource_idx
);
1063 #define check_readback_data_u24(a, b, c, d, e) check_readback_data_u24_(__LINE__, a, b, c, d, e)
1064 static void check_readback_data_u24_(unsigned int line
, struct resource_readback
*rb
,
1065 const RECT
*rect
, unsigned int shift
, DWORD expected_value
, BYTE max_diff
)
1067 unsigned int x
= 0, y
= 0, z
= 0;
1068 BOOL all_match
= FALSE
;
1074 SetRect(&default_rect
, 0, 0, rb
->width
, rb
->height
);
1075 rect
= &default_rect
;
1078 for (z
= 0; z
< rb
->depth
; ++z
)
1080 for (y
= rect
->top
; y
< rect
->bottom
; ++y
)
1082 for (x
= rect
->left
; x
< rect
->right
; ++x
)
1084 value
= get_readback_u32(rb
, x
, y
, z
) >> shift
;
1085 if (abs((int)value
- (int)expected_value
) > max_diff
)
1093 ok_(__FILE__
, line
)(all_match
,
1094 "Got 0x%06x, expected 0x%06x at (%u, %u, %u), sub-resource %u.\n",
1095 value
, expected_value
, x
, y
, z
, rb
->sub_resource_idx
);
1098 #define check_readback_data_color(a, b, c, d) check_readback_data_color_(__LINE__, a, b, c, d)
1099 static void check_readback_data_color_(unsigned int line
, struct resource_readback
*rb
,
1100 const RECT
*rect
, DWORD expected_color
, BYTE max_diff
)
1102 unsigned int x
= 0, y
= 0, z
= 0;
1103 BOOL all_match
= FALSE
;
1109 SetRect(&default_rect
, 0, 0, rb
->width
, rb
->height
);
1110 rect
= &default_rect
;
1113 for (z
= 0; z
< rb
->depth
; ++z
)
1115 for (y
= rect
->top
; y
< rect
->bottom
; ++y
)
1117 for (x
= rect
->left
; x
< rect
->right
; ++x
)
1119 color
= get_readback_color(rb
, x
, y
, z
);
1120 if (!compare_color(color
, expected_color
, max_diff
))
1128 ok_(__FILE__
, line
)(all_match
,
1129 "Got 0x%08x, expected 0x%08x at (%u, %u, %u), sub-resource %u.\n",
1130 color
, expected_color
, x
, y
, z
, rb
->sub_resource_idx
);
1133 #define check_texture_sub_resource_color(a, b, c, d, e) check_texture_sub_resource_color_(__LINE__, a, b, c, d, e)
1134 static void check_texture_sub_resource_color_(unsigned int line
, ID3D11Texture2D
*texture
,
1135 unsigned int sub_resource_idx
, const RECT
*rect
, DWORD expected_color
, BYTE max_diff
)
1137 struct resource_readback rb
;
1139 get_texture_readback(texture
, sub_resource_idx
, &rb
);
1140 check_readback_data_color_(line
, &rb
, rect
, expected_color
, max_diff
);
1141 release_resource_readback(&rb
);
1144 #define check_texture_color(t, c, d) check_texture_color_(__LINE__, t, c, d)
1145 static void check_texture_color_(unsigned int line
, ID3D11Texture2D
*texture
,
1146 DWORD expected_color
, BYTE max_diff
)
1148 unsigned int sub_resource_idx
, sub_resource_count
;
1149 D3D11_TEXTURE2D_DESC texture_desc
;
1151 ID3D11Texture2D_GetDesc(texture
, &texture_desc
);
1152 sub_resource_count
= texture_desc
.ArraySize
* texture_desc
.MipLevels
;
1153 for (sub_resource_idx
= 0; sub_resource_idx
< sub_resource_count
; ++sub_resource_idx
)
1154 check_texture_sub_resource_color_(line
, texture
, sub_resource_idx
, NULL
, expected_color
, max_diff
);
1157 #define check_texture1d_sub_resource_color(a, b, c, d, e) check_texture1d_sub_resource_color_(__LINE__, a, b, c, d, e)
1158 static void check_texture1d_sub_resource_color_(unsigned int line
, ID3D11Texture1D
*texture
,
1159 unsigned int sub_resource_idx
, const RECT
*rect
, DWORD expected_color
, BYTE max_diff
)
1161 struct resource_readback rb
;
1163 get_texture1d_readback(texture
, sub_resource_idx
, &rb
);
1164 check_readback_data_color_(line
, &rb
, rect
, expected_color
, max_diff
);
1165 release_resource_readback(&rb
);
1168 #define check_texture1d_color(t, c, d) check_texture1d_color_(__LINE__, t, c, d)
1169 static void check_texture1d_color_(unsigned int line
, ID3D11Texture1D
*texture
,
1170 DWORD expected_color
, BYTE max_diff
)
1172 unsigned int sub_resource_idx
, sub_resource_count
;
1173 D3D11_TEXTURE1D_DESC texture_desc
;
1175 ID3D11Texture1D_GetDesc(texture
, &texture_desc
);
1176 sub_resource_count
= texture_desc
.ArraySize
* texture_desc
.MipLevels
;
1177 for (sub_resource_idx
= 0; sub_resource_idx
< sub_resource_count
; ++sub_resource_idx
)
1178 check_texture1d_sub_resource_color_(line
, texture
, sub_resource_idx
, NULL
, expected_color
, max_diff
);
1181 #define check_texture3d_sub_resource_color(a, b, c, d, e) check_texture3d_sub_resource_color_(__LINE__, a, b, c, d, e)
1182 static void check_texture3d_sub_resource_color_(unsigned int line
, ID3D11Texture3D
*texture
,
1183 unsigned int sub_resource_idx
, const RECT
*rect
, DWORD expected_color
, BYTE max_diff
)
1185 struct resource_readback rb
;
1187 get_texture3d_readback(texture
, sub_resource_idx
, &rb
);
1188 check_readback_data_color_(line
, &rb
, rect
, expected_color
, max_diff
);
1189 release_resource_readback(&rb
);
1192 #define check_texture3d_color(t, c, d) check_texture3d_color_(__LINE__, t, c, d)
1193 static void check_texture3d_color_(unsigned int line
, ID3D11Texture3D
*texture
,
1194 DWORD expected_color
, BYTE max_diff
)
1196 unsigned int sub_resource_idx
, sub_resource_count
;
1197 D3D11_TEXTURE3D_DESC texture_desc
;
1199 ID3D11Texture3D_GetDesc(texture
, &texture_desc
);
1200 sub_resource_count
= texture_desc
.MipLevels
;
1201 for (sub_resource_idx
= 0; sub_resource_idx
< sub_resource_count
; ++sub_resource_idx
)
1202 check_texture3d_sub_resource_color_(line
, texture
, sub_resource_idx
, NULL
, expected_color
, max_diff
);
1205 #define check_texture_sub_resource_float(a, b, c, d, e) check_texture_sub_resource_float_(__LINE__, a, b, c, d, e)
1206 static void check_texture_sub_resource_float_(unsigned int line
, ID3D11Texture2D
*texture
,
1207 unsigned int sub_resource_idx
, const RECT
*rect
, float expected_value
, BYTE max_diff
)
1209 struct resource_readback rb
;
1210 unsigned int x
= 0, y
= 0;
1211 BOOL all_match
= TRUE
;
1215 get_texture_readback(texture
, sub_resource_idx
, &rb
);
1218 SetRect(&default_rect
, 0, 0, rb
.width
, rb
.height
);
1219 rect
= &default_rect
;
1221 for (y
= rect
->top
; y
< rect
->bottom
; ++y
)
1223 for (x
= rect
->left
; x
< rect
->right
; ++x
)
1225 value
= get_readback_float(&rb
, x
, y
);
1226 if (!compare_float(value
, expected_value
, max_diff
))
1235 release_resource_readback(&rb
);
1236 ok_(__FILE__
, line
)(all_match
,
1237 "Got %.8e, expected %.8e at (%u, %u), sub-resource %u.\n",
1238 value
, expected_value
, x
, y
, sub_resource_idx
);
1241 #define check_texture_float(r, f, d) check_texture_float_(__LINE__, r, f, d)
1242 static void check_texture_float_(unsigned int line
, ID3D11Texture2D
*texture
,
1243 float expected_value
, BYTE max_diff
)
1245 unsigned int sub_resource_idx
, sub_resource_count
;
1246 D3D11_TEXTURE2D_DESC texture_desc
;
1248 ID3D11Texture2D_GetDesc(texture
, &texture_desc
);
1249 sub_resource_count
= texture_desc
.ArraySize
* texture_desc
.MipLevels
;
1250 for (sub_resource_idx
= 0; sub_resource_idx
< sub_resource_count
; ++sub_resource_idx
)
1251 check_texture_sub_resource_float_(line
, texture
, sub_resource_idx
, NULL
, expected_value
, max_diff
);
1254 #define check_texture_sub_resource_vec4(a, b, c, d, e) check_texture_sub_resource_vec4_(__LINE__, a, b, c, d, e)
1255 static void check_texture_sub_resource_vec4_(unsigned int line
, ID3D11Texture2D
*texture
,
1256 unsigned int sub_resource_idx
, const RECT
*rect
, const struct vec4
*expected_value
, BYTE max_diff
)
1258 struct resource_readback rb
;
1259 unsigned int x
= 0, y
= 0;
1260 struct vec4 value
= {0};
1261 BOOL all_match
= TRUE
;
1264 get_texture_readback(texture
, sub_resource_idx
, &rb
);
1267 SetRect(&default_rect
, 0, 0, rb
.width
, rb
.height
);
1268 rect
= &default_rect
;
1270 for (y
= rect
->top
; y
< rect
->bottom
; ++y
)
1272 for (x
= rect
->left
; x
< rect
->right
; ++x
)
1274 value
= *get_readback_vec4(&rb
, x
, y
);
1275 if (!compare_vec4(&value
, expected_value
, max_diff
))
1284 release_resource_readback(&rb
);
1285 ok_(__FILE__
, line
)(all_match
,
1286 "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e} at (%u, %u), sub-resource %u.\n",
1287 value
.x
, value
.y
, value
.z
, value
.w
,
1288 expected_value
->x
, expected_value
->y
, expected_value
->z
, expected_value
->w
,
1289 x
, y
, sub_resource_idx
);
1292 #define check_texture_vec4(a, b, c) check_texture_vec4_(__LINE__, a, b, c)
1293 static void check_texture_vec4_(unsigned int line
, ID3D11Texture2D
*texture
,
1294 const struct vec4
*expected_value
, BYTE max_diff
)
1296 unsigned int sub_resource_idx
, sub_resource_count
;
1297 D3D11_TEXTURE2D_DESC texture_desc
;
1299 ID3D11Texture2D_GetDesc(texture
, &texture_desc
);
1300 sub_resource_count
= texture_desc
.ArraySize
* texture_desc
.MipLevels
;
1301 for (sub_resource_idx
= 0; sub_resource_idx
< sub_resource_count
; ++sub_resource_idx
)
1302 check_texture_sub_resource_vec4_(line
, texture
, sub_resource_idx
, NULL
, expected_value
, max_diff
);
1305 #define check_texture_sub_resource_uvec4(a, b, c, d) check_texture_sub_resource_uvec4_(__LINE__, a, b, c, d)
1306 static void check_texture_sub_resource_uvec4_(unsigned int line
, ID3D11Texture2D
*texture
,
1307 unsigned int sub_resource_idx
, const RECT
*rect
, const struct uvec4
*expected_value
)
1309 struct resource_readback rb
;
1310 unsigned int x
= 0, y
= 0;
1311 struct uvec4 value
= {0};
1312 BOOL all_match
= TRUE
;
1315 get_texture_readback(texture
, sub_resource_idx
, &rb
);
1318 SetRect(&default_rect
, 0, 0, rb
.width
, rb
.height
);
1319 rect
= &default_rect
;
1321 for (y
= rect
->top
; y
< rect
->bottom
; ++y
)
1323 for (x
= rect
->left
; x
< rect
->right
; ++x
)
1325 value
= *get_readback_uvec4(&rb
, x
, y
);
1326 if (!compare_uvec4(&value
, expected_value
))
1335 release_resource_readback(&rb
);
1336 ok_(__FILE__
, line
)(all_match
,
1337 "Got {0x%08x, 0x%08x, 0x%08x, 0x%08x}, expected {0x%08x, 0x%08x, 0x%08x, 0x%08x} "
1338 "at (%u, %u), sub-resource %u.\n",
1339 value
.x
, value
.y
, value
.z
, value
.w
,
1340 expected_value
->x
, expected_value
->y
, expected_value
->z
, expected_value
->w
,
1341 x
, y
, sub_resource_idx
);
1344 #define check_texture_uvec4(a, b) check_texture_uvec4_(__LINE__, a, b)
1345 static void check_texture_uvec4_(unsigned int line
, ID3D11Texture2D
*texture
,
1346 const struct uvec4
*expected_value
)
1348 unsigned int sub_resource_idx
, sub_resource_count
;
1349 D3D11_TEXTURE2D_DESC texture_desc
;
1351 ID3D11Texture2D_GetDesc(texture
, &texture_desc
);
1352 sub_resource_count
= texture_desc
.ArraySize
* texture_desc
.MipLevels
;
1353 for (sub_resource_idx
= 0; sub_resource_idx
< sub_resource_count
; ++sub_resource_idx
)
1354 check_texture_sub_resource_uvec4_(line
, texture
, sub_resource_idx
, NULL
, expected_value
);
1357 static IDXGIAdapter
*create_adapter(void)
1359 IDXGIFactory4
*factory4
;
1360 IDXGIFactory
*factory
;
1361 IDXGIAdapter
*adapter
;
1364 if (!use_warp_adapter
&& !use_adapter_idx
)
1367 if (FAILED(hr
= CreateDXGIFactory1(&IID_IDXGIFactory
, (void **)&factory
)))
1369 trace("Failed to create IDXGIFactory, hr %#x.\n", hr
);
1374 if (use_warp_adapter
)
1376 if (SUCCEEDED(hr
= IDXGIFactory_QueryInterface(factory
, &IID_IDXGIFactory4
, (void **)&factory4
)))
1378 hr
= IDXGIFactory4_EnumWarpAdapter(factory4
, &IID_IDXGIAdapter
, (void **)&adapter
);
1379 IDXGIFactory4_Release(factory4
);
1383 trace("Failed to get IDXGIFactory4, hr %#x.\n", hr
);
1388 hr
= IDXGIFactory_EnumAdapters(factory
, use_adapter_idx
, &adapter
);
1390 IDXGIFactory_Release(factory
);
1392 trace("Failed to get adapter, hr %#x.\n", hr
);
1396 static ID3D11Device
*create_device(const struct device_desc
*desc
)
1398 static const D3D_FEATURE_LEVEL default_feature_level
[] =
1400 D3D_FEATURE_LEVEL_11_0
,
1401 D3D_FEATURE_LEVEL_10_1
,
1402 D3D_FEATURE_LEVEL_10_0
,
1404 const D3D_FEATURE_LEVEL
*feature_level
;
1405 UINT flags
= desc
? desc
->flags
: 0;
1406 unsigned int feature_level_count
;
1407 IDXGIAdapter
*adapter
;
1408 ID3D11Device
*device
;
1411 if (desc
&& desc
->feature_level
)
1413 feature_level
= desc
->feature_level
;
1414 feature_level_count
= 1;
1418 feature_level
= default_feature_level
;
1419 feature_level_count
= ARRAY_SIZE(default_feature_level
);
1422 if (enable_debug_layer
)
1423 flags
|= D3D11_CREATE_DEVICE_DEBUG
;
1425 if ((adapter
= create_adapter()))
1427 hr
= D3D11CreateDevice(adapter
, D3D_DRIVER_TYPE_UNKNOWN
, NULL
, flags
,
1428 feature_level
, feature_level_count
, D3D11_SDK_VERSION
, &device
, NULL
, NULL
);
1429 IDXGIAdapter_Release(adapter
);
1430 return SUCCEEDED(hr
) ? device
: NULL
;
1433 if (SUCCEEDED(D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, flags
,
1434 feature_level
, feature_level_count
, D3D11_SDK_VERSION
, &device
, NULL
, NULL
)))
1436 if (SUCCEEDED(D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_WARP
, NULL
, flags
,
1437 feature_level
, feature_level_count
, D3D11_SDK_VERSION
, &device
, NULL
, NULL
)))
1439 if (SUCCEEDED(D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_REFERENCE
, NULL
, flags
,
1440 feature_level
, feature_level_count
, D3D11_SDK_VERSION
, &device
, NULL
, NULL
)))
1446 static void get_device_adapter_desc(ID3D11Device
*device
, DXGI_ADAPTER_DESC
*adapter_desc
)
1448 IDXGIDevice
*dxgi_device
;
1449 IDXGIAdapter
*adapter
;
1452 hr
= ID3D11Device_QueryInterface(device
, &IID_IDXGIDevice
, (void **)&dxgi_device
);
1453 ok(SUCCEEDED(hr
), "Failed to query IDXGIDevice interface, hr %#x.\n", hr
);
1454 hr
= IDXGIDevice_GetAdapter(dxgi_device
, &adapter
);
1455 ok(SUCCEEDED(hr
), "Failed to get adapter, hr %#x.\n", hr
);
1456 IDXGIDevice_Release(dxgi_device
);
1457 hr
= IDXGIAdapter_GetDesc(adapter
, adapter_desc
);
1458 ok(SUCCEEDED(hr
), "Failed to get adapter desc, hr %#x.\n", hr
);
1459 IDXGIAdapter_Release(adapter
);
1462 static void print_adapter_info(void)
1464 DXGI_ADAPTER_DESC adapter_desc
;
1465 ID3D11Device
*device
;
1467 if (!(device
= create_device(NULL
)))
1470 get_device_adapter_desc(device
, &adapter_desc
);
1471 trace("Adapter: %s, %04x:%04x.\n", wine_dbgstr_w(adapter_desc
.Description
),
1472 adapter_desc
.VendorId
, adapter_desc
.DeviceId
);
1473 ID3D11Device_Release(device
);
1476 static BOOL
is_warp_device(ID3D11Device
*device
)
1478 DXGI_ADAPTER_DESC adapter_desc
;
1479 get_device_adapter_desc(device
, &adapter_desc
);
1480 return !adapter_desc
.SubSysId
&& !adapter_desc
.Revision
1481 && ((!adapter_desc
.VendorId
&& !adapter_desc
.DeviceId
)
1482 || (adapter_desc
.VendorId
== 0x1414 && adapter_desc
.DeviceId
== 0x008c));
1485 static BOOL
is_vendor_device(ID3D11Device
*device
, unsigned int vendor_id
)
1487 DXGI_ADAPTER_DESC adapter_desc
;
1489 if (!strcmp(winetest_platform
, "wine"))
1492 get_device_adapter_desc(device
, &adapter_desc
);
1493 return adapter_desc
.VendorId
== vendor_id
;
1496 static BOOL
is_amd_device(ID3D11Device
*device
)
1498 return is_vendor_device(device
, 0x1002);
1501 static BOOL
is_intel_device(ID3D11Device
*device
)
1503 return is_vendor_device(device
, 0x8086);
1506 static BOOL
is_nvidia_device(ID3D11Device
*device
)
1508 return is_vendor_device(device
, 0x10de);
1511 static BOOL
is_d3d11_2_runtime(ID3D11Device
*device
)
1513 ID3D11Device2
*device2
;
1516 hr
= ID3D11Device_QueryInterface(device
, &IID_ID3D11Device2
, (void **)&device2
);
1518 ID3D11Device2_Release(device2
);
1522 static BOOL
check_compute_shaders_via_sm4_support(ID3D11Device
*device
)
1524 D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS options
;
1526 if (FAILED(ID3D11Device_CheckFeatureSupport(device
,
1527 D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
, &options
, sizeof(options
))))
1529 return options
.ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x
;
1532 static BOOL
check_viewport_array_index_from_any_shader_support(ID3D11Device
*device
)
1534 D3D11_FEATURE_DATA_D3D11_OPTIONS3 options
;
1536 if (FAILED(ID3D11Device_CheckFeatureSupport(device
,
1537 D3D11_FEATURE_D3D11_OPTIONS3
, &options
, sizeof(options
))))
1539 return options
.VPAndRTArrayIndexFromAnyShaderFeedingRasterizer
;
1542 static BOOL
is_buffer(ID3D11Resource
*resource
)
1544 D3D11_RESOURCE_DIMENSION dimension
;
1545 ID3D11Resource_GetType(resource
, &dimension
);
1546 return dimension
== D3D11_RESOURCE_DIMENSION_BUFFER
;
1549 static IDXGISwapChain
*create_swapchain(ID3D11Device
*device
, HWND window
,
1550 const struct swapchain_desc
*swapchain_desc
)
1552 DXGI_SWAP_CHAIN_DESC dxgi_desc
;
1553 IDXGISwapChain
*swapchain
;
1554 IDXGIDevice
*dxgi_device
;
1555 IDXGIAdapter
*adapter
;
1556 IDXGIFactory
*factory
;
1559 hr
= ID3D11Device_QueryInterface(device
, &IID_IDXGIDevice
, (void **)&dxgi_device
);
1560 ok(SUCCEEDED(hr
), "Failed to get DXGI device, hr %#x.\n", hr
);
1561 hr
= IDXGIDevice_GetAdapter(dxgi_device
, &adapter
);
1562 ok(SUCCEEDED(hr
), "Failed to get adapter, hr %#x.\n", hr
);
1563 IDXGIDevice_Release(dxgi_device
);
1564 hr
= IDXGIAdapter_GetParent(adapter
, &IID_IDXGIFactory
, (void **)&factory
);
1565 ok(SUCCEEDED(hr
), "Failed to get factory, hr %#x.\n", hr
);
1566 IDXGIAdapter_Release(adapter
);
1568 dxgi_desc
.BufferDesc
.Width
= 640;
1569 dxgi_desc
.BufferDesc
.Height
= 480;
1570 dxgi_desc
.BufferDesc
.RefreshRate
.Numerator
= 60;
1571 dxgi_desc
.BufferDesc
.RefreshRate
.Denominator
= 1;
1572 dxgi_desc
.BufferDesc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
1573 dxgi_desc
.BufferDesc
.ScanlineOrdering
= DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED
;
1574 dxgi_desc
.BufferDesc
.Scaling
= DXGI_MODE_SCALING_UNSPECIFIED
;
1575 dxgi_desc
.SampleDesc
.Count
= 1;
1576 dxgi_desc
.SampleDesc
.Quality
= 0;
1577 dxgi_desc
.BufferUsage
= DXGI_USAGE_RENDER_TARGET_OUTPUT
;
1578 dxgi_desc
.BufferCount
= 1;
1579 dxgi_desc
.OutputWindow
= window
;
1580 dxgi_desc
.Windowed
= TRUE
;
1581 dxgi_desc
.SwapEffect
= DXGI_SWAP_EFFECT_DISCARD
;
1582 dxgi_desc
.Flags
= 0;
1586 dxgi_desc
.Windowed
= swapchain_desc
->windowed
;
1587 dxgi_desc
.SwapEffect
= swapchain_desc
->swap_effect
;
1588 dxgi_desc
.BufferCount
= swapchain_desc
->buffer_count
;
1589 if (swapchain_desc
->width
)
1590 dxgi_desc
.BufferDesc
.Width
= swapchain_desc
->width
;
1591 if (swapchain_desc
->height
)
1592 dxgi_desc
.BufferDesc
.Height
= swapchain_desc
->height
;
1594 if (swapchain_desc
->flags
& SWAPCHAIN_FLAG_SHADER_INPUT
)
1595 dxgi_desc
.BufferUsage
|= DXGI_USAGE_SHADER_INPUT
;
1598 hr
= IDXGIFactory_CreateSwapChain(factory
, (IUnknown
*)device
, &dxgi_desc
, &swapchain
);
1599 ok(SUCCEEDED(hr
), "Failed to create swapchain, hr %#x.\n", hr
);
1600 IDXGIFactory_Release(factory
);
1605 struct d3d11_test_context
1607 ID3D11Device
*device
;
1609 IDXGISwapChain
*swapchain
;
1610 ID3D11Texture2D
*backbuffer
;
1611 ID3D11RenderTargetView
*backbuffer_rtv
;
1612 ID3D11DeviceContext
*immediate_context
;
1614 ID3D11InputLayout
*input_layout
;
1615 ID3D11VertexShader
*vs
;
1616 const DWORD
*vs_code
;
1617 ID3D11Buffer
*vs_cb
;
1620 ID3D11PixelShader
*ps
;
1621 ID3D11Buffer
*ps_cb
;
1624 #define init_test_context(a, b) init_test_context_(__LINE__, a, b, NULL)
1625 #define init_test_context_ext(a, b, c) init_test_context_(__LINE__, a, b, c)
1626 static BOOL
init_test_context_(unsigned int line
, struct d3d11_test_context
*context
,
1627 const D3D_FEATURE_LEVEL
*feature_level
, const struct swapchain_desc
*swapchain_desc
)
1629 unsigned int rt_width
, rt_height
;
1630 struct device_desc device_desc
;
1634 memset(context
, 0, sizeof(*context
));
1636 device_desc
.feature_level
= feature_level
;
1637 device_desc
.flags
= 0;
1638 if (!(context
->device
= create_device(&device_desc
)))
1640 skip_(__FILE__
, line
)("Failed to create device.\n");
1644 rt_width
= swapchain_desc
&& swapchain_desc
->width
? swapchain_desc
->width
: 640;
1645 rt_height
= swapchain_desc
&& swapchain_desc
->height
? swapchain_desc
->height
: 480;
1646 SetRect(&rect
, 0, 0, rt_width
, rt_height
);
1647 AdjustWindowRect(&rect
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
, FALSE
);
1648 context
->window
= CreateWindowA("static", "d3d11_test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
1649 0, 0, rect
.right
- rect
.left
, rect
.bottom
- rect
.top
, NULL
, NULL
, NULL
, NULL
);
1650 context
->swapchain
= create_swapchain(context
->device
, context
->window
, swapchain_desc
);
1651 hr
= IDXGISwapChain_GetBuffer(context
->swapchain
, 0, &IID_ID3D11Texture2D
, (void **)&context
->backbuffer
);
1652 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to get backbuffer, hr %#x.\n", hr
);
1654 hr
= ID3D11Device_CreateRenderTargetView(context
->device
, (ID3D11Resource
*)context
->backbuffer
,
1655 NULL
, &context
->backbuffer_rtv
);
1656 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
1658 ID3D11Device_GetImmediateContext(context
->device
, &context
->immediate_context
);
1660 ID3D11DeviceContext_OMSetRenderTargets(context
->immediate_context
, 1, &context
->backbuffer_rtv
, NULL
);
1662 set_viewport(context
->immediate_context
, 0.0f
, 0.0f
, rt_width
, rt_height
, 0.0f
, 1.0f
);
1667 #define release_test_context(context) release_test_context_(__LINE__, context)
1668 static void release_test_context_(unsigned int line
, struct d3d11_test_context
*context
)
1672 if (context
->input_layout
)
1673 ID3D11InputLayout_Release(context
->input_layout
);
1675 ID3D11VertexShader_Release(context
->vs
);
1677 ID3D11Buffer_Release(context
->vs_cb
);
1679 ID3D11Buffer_Release(context
->vb
);
1681 ID3D11PixelShader_Release(context
->ps
);
1683 ID3D11Buffer_Release(context
->ps_cb
);
1685 ID3D11DeviceContext_Release(context
->immediate_context
);
1686 ID3D11RenderTargetView_Release(context
->backbuffer_rtv
);
1687 ID3D11Texture2D_Release(context
->backbuffer
);
1688 IDXGISwapChain_Release(context
->swapchain
);
1689 DestroyWindow(context
->window
);
1691 ref
= ID3D11Device_Release(context
->device
);
1692 ok_(__FILE__
, line
)(!ref
, "Device has %u references left.\n", ref
);
1695 #define draw_quad(context) draw_quad_vs_(__LINE__, context, NULL, 0)
1696 #define draw_quad_vs(a, b, c) draw_quad_vs_(__LINE__, a, b, c)
1697 static void draw_quad_vs_(unsigned int line
, struct d3d11_test_context
*context
,
1698 const DWORD
*vs_code
, size_t vs_code_size
)
1700 static const D3D11_INPUT_ELEMENT_DESC default_layout_desc
[] =
1702 {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
1704 static const DWORD default_vs_code
[] =
1707 float4
main(float4 position
: POSITION
) : SV_POSITION
1712 0x43425844, 0x4fb19b86, 0x955fa240, 0x1a630688, 0x24eb9db4, 0x00000001, 0x000001e0, 0x00000006,
1713 0x00000038, 0x00000084, 0x000000d0, 0x00000134, 0x00000178, 0x000001ac, 0x53414e58, 0x00000044,
1714 0x00000044, 0xfffe0200, 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000,
1715 0x00240000, 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000, 0x02000001, 0xc00f0000, 0x80e40000,
1716 0x0000ffff, 0x50414e58, 0x00000044, 0x00000044, 0xfffe0200, 0x00000020, 0x00000024, 0x00240000,
1717 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000,
1718 0x02000001, 0xc00f0000, 0x80e40000, 0x0000ffff, 0x396e6f41, 0x0000005c, 0x0000005c, 0xfffe0200,
1719 0x00000034, 0x00000028, 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0x00240001, 0x00000000,
1720 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000, 0x04000004, 0xc0030000, 0x90ff0000, 0xa0e40000,
1721 0x90e40000, 0x02000001, 0xc00c0000, 0x90e40000, 0x0000ffff, 0x52444853, 0x0000003c, 0x00010040,
1722 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
1723 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x4e475349, 0x0000002c,
1724 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f,
1725 0x49534f50, 0x4e4f4954, 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
1726 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
1728 static const struct vec3 quad
[] =
1730 {-1.0f
, -1.0f
, 0.0f
},
1731 {-1.0f
, 1.0f
, 0.0f
},
1732 { 1.0f
, -1.0f
, 0.0f
},
1733 { 1.0f
, 1.0f
, 0.0f
},
1736 ID3D11Device
*device
= context
->device
;
1737 unsigned int stride
, offset
;
1742 vs_code
= default_vs_code
;
1743 vs_code_size
= sizeof(default_vs_code
);
1746 if (!context
->input_layout
)
1748 hr
= ID3D11Device_CreateInputLayout(device
, default_layout_desc
, ARRAY_SIZE(default_layout_desc
),
1749 vs_code
, vs_code_size
, &context
->input_layout
);
1750 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
1753 if (context
->vs_code
!= vs_code
)
1756 ID3D11VertexShader_Release(context
->vs
);
1758 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, vs_code_size
, NULL
, &context
->vs
);
1759 ok_(__FILE__
, line
)(hr
== S_OK
, "Failed to create vertex shader, hr %#x.\n", hr
);
1761 context
->vs_code
= vs_code
;
1765 context
->vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(quad
), quad
);
1767 ID3D11DeviceContext_IASetInputLayout(context
->immediate_context
, context
->input_layout
);
1768 ID3D11DeviceContext_IASetPrimitiveTopology(context
->immediate_context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
1769 stride
= sizeof(*quad
);
1771 ID3D11DeviceContext_IASetVertexBuffers(context
->immediate_context
, 0, 1, &context
->vb
, &stride
, &offset
);
1772 ID3D11DeviceContext_VSSetShader(context
->immediate_context
, context
->vs
, NULL
, 0);
1774 ID3D11DeviceContext_Draw(context
->immediate_context
, 4, 0);
1777 #define draw_quad_z(context, z) draw_quad_z_(__LINE__, context, z)
1778 static void draw_quad_z_(unsigned int line
, struct d3d11_test_context
*context
, float z
)
1780 static const DWORD vs_code
[] =
1785 void main(float4 in_position
: POSITION
, out float4 out_position
: SV_Position
)
1787 out_position
= in_position
;
1788 out_position
.z
= depth
;
1791 0x43425844, 0x22d7ff76, 0xd53b167c, 0x1b49ccf1, 0xbebfec39, 0x00000001, 0x00000100, 0x00000003,
1792 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
1793 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000b0f, 0x49534f50, 0x4e4f4954, 0xababab00,
1794 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
1795 0x00000000, 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69, 0x52444853, 0x00000064, 0x00010040,
1796 0x00000019, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005f, 0x001010b2, 0x00000000,
1797 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x05000036, 0x001020b2, 0x00000000, 0x00101c46,
1798 0x00000000, 0x06000036, 0x00102042, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x0100003e,
1801 struct vec4 data
= {z
};
1803 if (!context
->vs_cb
)
1804 context
->vs_cb
= create_buffer(context
->device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(data
), NULL
);
1806 ID3D11DeviceContext_UpdateSubresource(context
->immediate_context
,
1807 (ID3D11Resource
*)context
->vs_cb
, 0, NULL
, &data
, 0, 0);
1809 ID3D11DeviceContext_VSSetConstantBuffers(context
->immediate_context
, 0, 1, &context
->vs_cb
);
1810 draw_quad_vs_(__LINE__
, context
, vs_code
, sizeof(vs_code
));
1813 static void set_quad_color(struct d3d11_test_context
*context
, const struct vec4
*color
)
1815 ID3D11DeviceContext_UpdateSubresource(context
->immediate_context
,
1816 (ID3D11Resource
*)context
->ps_cb
, 0, NULL
, color
, 0, 0);
1819 #define draw_color_quad(a, b) draw_color_quad_(__LINE__, a, b, NULL, 0)
1820 #define draw_color_quad_vs(a, b, c, d) draw_color_quad_(__LINE__, a, b, c, d)
1821 static void draw_color_quad_(unsigned int line
, struct d3d11_test_context
*context
,
1822 const struct vec4
*color
, const DWORD
*vs_code
, size_t vs_code_size
)
1824 static const DWORD ps_color_code
[] =
1829 float4
main() : SV_TARGET
1834 0x43425844, 0xe7ffb369, 0x72bb84ee, 0x6f684dcd, 0xd367d788, 0x00000001, 0x00000158, 0x00000005,
1835 0x00000034, 0x00000080, 0x000000cc, 0x00000114, 0x00000124, 0x53414e58, 0x00000044, 0x00000044,
1836 0xffff0200, 0x00000014, 0x00000030, 0x00240001, 0x00300000, 0x00300000, 0x00240000, 0x00300000,
1837 0x00000000, 0x00000001, 0x00000000, 0xffff0200, 0x02000001, 0x800f0800, 0xa0e40000, 0x0000ffff,
1838 0x396e6f41, 0x00000044, 0x00000044, 0xffff0200, 0x00000014, 0x00000030, 0x00240001, 0x00300000,
1839 0x00300000, 0x00240000, 0x00300000, 0x00000000, 0x00000001, 0x00000000, 0xffff0200, 0x02000001,
1840 0x800f0800, 0xa0e40000, 0x0000ffff, 0x52444853, 0x00000040, 0x00000040, 0x00000010, 0x04000059,
1841 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x06000036, 0x001020f2,
1842 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x0100003e, 0x4e475349, 0x00000008, 0x00000000,
1843 0x00000008, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
1844 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054,
1847 ID3D11Device
*device
= context
->device
;
1852 hr
= ID3D11Device_CreatePixelShader(device
, ps_color_code
, sizeof(ps_color_code
), NULL
, &context
->ps
);
1853 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
1856 if (!context
->ps_cb
)
1857 context
->ps_cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(*color
), NULL
);
1859 ID3D11DeviceContext_PSSetShader(context
->immediate_context
, context
->ps
, NULL
, 0);
1860 ID3D11DeviceContext_PSSetConstantBuffers(context
->immediate_context
, 0, 1, &context
->ps_cb
);
1862 set_quad_color(context
, color
);
1864 draw_quad_vs_(line
, context
, vs_code
, vs_code_size
);
1867 static void test_create_device(void)
1869 static const D3D_FEATURE_LEVEL default_feature_levels
[] =
1871 D3D_FEATURE_LEVEL_11_0
,
1872 D3D_FEATURE_LEVEL_10_1
,
1873 D3D_FEATURE_LEVEL_10_0
,
1874 D3D_FEATURE_LEVEL_9_3
,
1875 D3D_FEATURE_LEVEL_9_2
,
1876 D3D_FEATURE_LEVEL_9_1
,
1878 D3D_FEATURE_LEVEL feature_level
, supported_feature_level
;
1879 DXGI_SWAP_CHAIN_DESC swapchain_desc
, obtained_desc
;
1880 ID3D11DeviceContext
*immediate_context
;
1881 IDXGISwapChain
*swapchain
;
1882 ID3D11Device
*device
;
1887 if (FAILED(hr
= D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
1888 &device
, NULL
, NULL
)))
1890 skip("Failed to create HAL device.\n");
1891 if ((device
= create_device(NULL
)))
1893 trace("Feature level %#x.\n", ID3D11Device_GetFeatureLevel(device
));
1894 ID3D11Device_Release(device
);
1899 supported_feature_level
= ID3D11Device_GetFeatureLevel(device
);
1900 trace("Feature level %#x.\n", supported_feature_level
);
1901 ID3D11Device_Release(device
);
1903 hr
= D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
, NULL
, NULL
, NULL
);
1904 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
1906 hr
= D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
, NULL
,
1907 &feature_level
, NULL
);
1908 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
1909 ok(feature_level
== supported_feature_level
, "Got feature level %#x, expected %#x.\n",
1910 feature_level
, supported_feature_level
);
1912 hr
= D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, default_feature_levels
,
1913 ARRAY_SIZE(default_feature_levels
), D3D11_SDK_VERSION
, NULL
, &feature_level
, NULL
);
1914 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
1915 ok(feature_level
== supported_feature_level
, "Got feature level %#x, expected %#x.\n",
1916 feature_level
, supported_feature_level
);
1918 hr
= D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
, NULL
, NULL
,
1919 &immediate_context
);
1920 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
1922 ok(!!immediate_context
, "Expected immediate device context pointer, got NULL.\n");
1923 refcount
= get_refcount(immediate_context
);
1924 ok(refcount
== 1, "Got refcount %u, expected 1.\n", refcount
);
1926 ID3D11DeviceContext_GetDevice(immediate_context
, &device
);
1927 refcount
= ID3D11Device_Release(device
);
1928 ok(refcount
== 1, "Got refcount %u, expected 1.\n", refcount
);
1930 refcount
= ID3D11DeviceContext_Release(immediate_context
);
1931 ok(!refcount
, "ID3D11DeviceContext has %u references left.\n", refcount
);
1933 device
= (ID3D11Device
*)0xdeadbeef;
1934 feature_level
= 0xdeadbeef;
1935 immediate_context
= (ID3D11DeviceContext
*)0xdeadbeef;
1936 hr
= D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_UNKNOWN
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
1937 &device
, &feature_level
, &immediate_context
);
1938 todo_wine
ok(hr
== E_INVALIDARG
, "D3D11CreateDevice returned %#x.\n", hr
);
1939 ok(!device
, "Got unexpected device pointer %p.\n", device
);
1940 ok(!feature_level
, "Got unexpected feature level %#x.\n", feature_level
);
1941 ok(!immediate_context
, "Got unexpected immediate context pointer %p.\n", immediate_context
);
1943 window
= CreateWindowA("static", "d3d11_test", 0, 0, 0, 0, 0, 0, 0, 0, 0);
1945 swapchain_desc
.BufferDesc
.Width
= 800;
1946 swapchain_desc
.BufferDesc
.Height
= 600;
1947 swapchain_desc
.BufferDesc
.RefreshRate
.Numerator
= 60;
1948 swapchain_desc
.BufferDesc
.RefreshRate
.Denominator
= 60;
1949 swapchain_desc
.BufferDesc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
1950 swapchain_desc
.BufferDesc
.ScanlineOrdering
= DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED
;
1951 swapchain_desc
.BufferDesc
.Scaling
= DXGI_MODE_SCALING_UNSPECIFIED
;
1952 swapchain_desc
.SampleDesc
.Count
= 1;
1953 swapchain_desc
.SampleDesc
.Quality
= 0;
1954 swapchain_desc
.BufferUsage
= DXGI_USAGE_RENDER_TARGET_OUTPUT
;
1955 swapchain_desc
.BufferCount
= 1;
1956 swapchain_desc
.OutputWindow
= window
;
1957 swapchain_desc
.Windowed
= TRUE
;
1958 swapchain_desc
.SwapEffect
= DXGI_SWAP_EFFECT_DISCARD
;
1959 swapchain_desc
.Flags
= 0;
1961 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
1962 &swapchain_desc
, NULL
, NULL
, NULL
, NULL
);
1963 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
1965 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
1966 &swapchain_desc
, NULL
, NULL
, &feature_level
, NULL
);
1967 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
1968 ok(feature_level
== supported_feature_level
, "Got feature level %#x, expected %#x.\n",
1969 feature_level
, supported_feature_level
);
1971 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
1972 &swapchain_desc
, &swapchain
, &device
, NULL
, NULL
);
1973 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
1975 check_interface(swapchain
, &IID_IDXGISwapChain1
, TRUE
, FALSE
);
1977 memset(&obtained_desc
, 0, sizeof(obtained_desc
));
1978 hr
= IDXGISwapChain_GetDesc(swapchain
, &obtained_desc
);
1979 ok(SUCCEEDED(hr
), "GetDesc failed %#x.\n", hr
);
1980 ok(obtained_desc
.BufferDesc
.Width
== swapchain_desc
.BufferDesc
.Width
,
1981 "Got unexpected BufferDesc.Width %u.\n", obtained_desc
.BufferDesc
.Width
);
1982 ok(obtained_desc
.BufferDesc
.Height
== swapchain_desc
.BufferDesc
.Height
,
1983 "Got unexpected BufferDesc.Height %u.\n", obtained_desc
.BufferDesc
.Height
);
1984 todo_wine
ok(obtained_desc
.BufferDesc
.RefreshRate
.Numerator
== swapchain_desc
.BufferDesc
.RefreshRate
.Numerator
,
1985 "Got unexpected BufferDesc.RefreshRate.Numerator %u.\n",
1986 obtained_desc
.BufferDesc
.RefreshRate
.Numerator
);
1987 todo_wine
ok(obtained_desc
.BufferDesc
.RefreshRate
.Denominator
== swapchain_desc
.BufferDesc
.RefreshRate
.Denominator
,
1988 "Got unexpected BufferDesc.RefreshRate.Denominator %u.\n",
1989 obtained_desc
.BufferDesc
.RefreshRate
.Denominator
);
1990 ok(obtained_desc
.BufferDesc
.Format
== swapchain_desc
.BufferDesc
.Format
,
1991 "Got unexpected BufferDesc.Format %#x.\n", obtained_desc
.BufferDesc
.Format
);
1992 ok(obtained_desc
.BufferDesc
.ScanlineOrdering
== swapchain_desc
.BufferDesc
.ScanlineOrdering
,
1993 "Got unexpected BufferDesc.ScanlineOrdering %#x.\n", obtained_desc
.BufferDesc
.ScanlineOrdering
);
1994 ok(obtained_desc
.BufferDesc
.Scaling
== swapchain_desc
.BufferDesc
.Scaling
,
1995 "Got unexpected BufferDesc.Scaling %#x.\n", obtained_desc
.BufferDesc
.Scaling
);
1996 ok(obtained_desc
.SampleDesc
.Count
== swapchain_desc
.SampleDesc
.Count
,
1997 "Got unexpected SampleDesc.Count %u.\n", obtained_desc
.SampleDesc
.Count
);
1998 ok(obtained_desc
.SampleDesc
.Quality
== swapchain_desc
.SampleDesc
.Quality
,
1999 "Got unexpected SampleDesc.Quality %u.\n", obtained_desc
.SampleDesc
.Quality
);
2000 ok(obtained_desc
.BufferUsage
== swapchain_desc
.BufferUsage
,
2001 "Got unexpected BufferUsage %#x.\n", obtained_desc
.BufferUsage
);
2002 ok(obtained_desc
.BufferCount
== swapchain_desc
.BufferCount
,
2003 "Got unexpected BufferCount %u.\n", obtained_desc
.BufferCount
);
2004 ok(obtained_desc
.OutputWindow
== swapchain_desc
.OutputWindow
,
2005 "Got unexpected OutputWindow %p.\n", obtained_desc
.OutputWindow
);
2006 ok(obtained_desc
.Windowed
== swapchain_desc
.Windowed
,
2007 "Got unexpected Windowed %#x.\n", obtained_desc
.Windowed
);
2008 ok(obtained_desc
.SwapEffect
== swapchain_desc
.SwapEffect
,
2009 "Got unexpected SwapEffect %#x.\n", obtained_desc
.SwapEffect
);
2010 ok(obtained_desc
.Flags
== swapchain_desc
.Flags
,
2011 "Got unexpected Flags %#x.\n", obtained_desc
.Flags
);
2013 refcount
= IDXGISwapChain_Release(swapchain
);
2014 ok(!refcount
, "Swapchain has %u references left.\n", refcount
);
2016 feature_level
= ID3D11Device_GetFeatureLevel(device
);
2017 ok(feature_level
== supported_feature_level
, "Got feature level %#x, expected %#x.\n",
2018 feature_level
, supported_feature_level
);
2020 refcount
= ID3D11Device_Release(device
);
2021 ok(!refcount
, "Device has %u references left.\n", refcount
);
2023 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
2024 NULL
, NULL
, &device
, NULL
, NULL
);
2025 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2026 ID3D11Device_Release(device
);
2028 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
2029 NULL
, NULL
, NULL
, NULL
, NULL
);
2030 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
2032 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
2033 NULL
, NULL
, NULL
, &feature_level
, NULL
);
2034 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
2035 ok(feature_level
== supported_feature_level
, "Got feature level %#x, expected %#x.\n",
2036 feature_level
, supported_feature_level
);
2038 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
2039 NULL
, NULL
, NULL
, NULL
, &immediate_context
);
2040 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2041 ID3D11DeviceContext_Release(immediate_context
);
2043 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
2044 &swapchain_desc
, NULL
, NULL
, NULL
, NULL
);
2045 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
2047 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
2048 &swapchain_desc
, &swapchain
, NULL
, NULL
, NULL
);
2049 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2050 IDXGISwapChain_Release(swapchain
);
2052 swapchain_desc
.OutputWindow
= NULL
;
2053 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
2054 &swapchain_desc
, NULL
, NULL
, NULL
, NULL
);
2055 ok(hr
== S_FALSE
, "D3D11CreateDeviceAndSwapChain returned %#x.\n", hr
);
2056 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
2057 &swapchain_desc
, NULL
, &device
, NULL
, NULL
);
2058 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2059 ID3D11Device_Release(device
);
2061 swapchain
= (IDXGISwapChain
*)0xdeadbeef;
2062 device
= (ID3D11Device
*)0xdeadbeef;
2063 feature_level
= 0xdeadbeef;
2064 immediate_context
= (ID3D11DeviceContext
*)0xdeadbeef;
2065 swapchain_desc
.OutputWindow
= NULL
;
2066 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
2067 &swapchain_desc
, &swapchain
, &device
, &feature_level
, &immediate_context
);
2068 ok(hr
== DXGI_ERROR_INVALID_CALL
, "D3D11CreateDeviceAndSwapChain returned %#x.\n", hr
);
2069 ok(!swapchain
, "Got unexpected swapchain pointer %p.\n", swapchain
);
2070 ok(!device
, "Got unexpected device pointer %p.\n", device
);
2071 ok(!feature_level
, "Got unexpected feature level %#x.\n", feature_level
);
2072 ok(!immediate_context
, "Got unexpected immediate context pointer %p.\n", immediate_context
);
2074 swapchain
= (IDXGISwapChain
*)0xdeadbeef;
2075 device
= (ID3D11Device
*)0xdeadbeef;
2076 feature_level
= 0xdeadbeef;
2077 immediate_context
= (ID3D11DeviceContext
*)0xdeadbeef;
2078 swapchain_desc
.OutputWindow
= window
;
2079 swapchain_desc
.BufferDesc
.Format
= DXGI_FORMAT_BC5_UNORM
;
2080 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
2081 &swapchain_desc
, &swapchain
, &device
, &feature_level
, &immediate_context
);
2082 ok(hr
== E_INVALIDARG
, "D3D11CreateDeviceAndSwapChain returned %#x.\n", hr
);
2083 ok(!swapchain
, "Got unexpected swapchain pointer %p.\n", swapchain
);
2084 ok(!device
, "Got unexpected device pointer %p.\n", device
);
2085 ok(!feature_level
, "Got unexpected feature level %#x.\n", feature_level
);
2086 ok(!immediate_context
, "Got unexpected immediate context pointer %p.\n", immediate_context
);
2088 DestroyWindow(window
);
2091 static void test_device_interfaces(const D3D_FEATURE_LEVEL feature_level
)
2093 struct device_desc device_desc
;
2094 IDXGIAdapter
*dxgi_adapter
;
2095 IDXGIDevice
*dxgi_device
;
2096 ID3D11Device
*device
;
2101 device_desc
.feature_level
= &feature_level
;
2102 device_desc
.flags
= 0;
2103 if (!(device
= create_device(&device_desc
)))
2105 skip("Failed to create device for feature level %#x.\n", feature_level
);
2109 check_interface(device
, &IID_IUnknown
, TRUE
, FALSE
);
2110 check_interface(device
, &IID_IDXGIObject
, TRUE
, FALSE
);
2111 check_interface(device
, &IID_IDXGIDevice
, TRUE
, FALSE
);
2112 check_interface(device
, &IID_IDXGIDevice1
, TRUE
, FALSE
);
2113 check_interface(device
, &IID_ID3D10Multithread
, TRUE
, TRUE
); /* Not available on all Windows versions. */
2114 todo_wine
check_interface(device
, &IID_ID3D10Device
, FALSE
, FALSE
);
2115 todo_wine
check_interface(device
, &IID_ID3D10Device1
, FALSE
, FALSE
);
2116 check_interface(device
, &IID_ID3D11InfoQueue
, enable_debug_layer
, FALSE
);
2118 hr
= ID3D11Device_QueryInterface(device
, &IID_IDXGIDevice
, (void **)&dxgi_device
);
2119 ok(SUCCEEDED(hr
), "Device should implement IDXGIDevice.\n");
2120 hr
= IDXGIDevice_GetParent(dxgi_device
, &IID_IDXGIAdapter
, (void **)&dxgi_adapter
);
2121 ok(SUCCEEDED(hr
), "Device parent should implement IDXGIAdapter.\n");
2122 hr
= IDXGIAdapter_GetParent(dxgi_adapter
, &IID_IDXGIFactory
, (void **)&iface
);
2123 ok(SUCCEEDED(hr
), "Adapter parent should implement IDXGIFactory.\n");
2124 IUnknown_Release(iface
);
2125 IDXGIAdapter_Release(dxgi_adapter
);
2126 hr
= IDXGIDevice_GetParent(dxgi_device
, &IID_IDXGIAdapter1
, (void **)&dxgi_adapter
);
2127 ok(SUCCEEDED(hr
), "Device parent should implement IDXGIAdapter1.\n");
2128 hr
= IDXGIAdapter_GetParent(dxgi_adapter
, &IID_IDXGIFactory1
, (void **)&iface
);
2129 ok(SUCCEEDED(hr
), "Adapter parent should implement IDXGIFactory1.\n");
2130 IUnknown_Release(iface
);
2131 IDXGIAdapter_Release(dxgi_adapter
);
2132 IDXGIDevice_Release(dxgi_device
);
2134 refcount
= ID3D11Device_Release(device
);
2135 ok(!refcount
, "Device has %u references left.\n", refcount
);
2137 device_desc
.feature_level
= &feature_level
;
2138 device_desc
.flags
= D3D11_CREATE_DEVICE_DEBUG
;
2139 if (!(device
= create_device(&device_desc
)))
2141 skip("Failed to create debug device for feature level %#x.\n", feature_level
);
2145 todo_wine
check_interface(device
, &IID_ID3D11InfoQueue
, TRUE
, FALSE
);
2147 refcount
= ID3D11Device_Release(device
);
2148 ok(!refcount
, "Device has %u references left.\n", refcount
);
2151 static void test_get_immediate_context(void)
2153 ID3D11DeviceContext
*immediate_context
, *previous_immediate_context
;
2154 ULONG expected_refcount
, refcount
;
2155 ID3D11Multithread
*multithread
;
2156 ID3D11Device
*device
;
2160 if (!(device
= create_device(NULL
)))
2162 skip("Failed to create device.\n");
2166 expected_refcount
= get_refcount(device
) + 1;
2167 ID3D11Device_GetImmediateContext(device
, &immediate_context
);
2168 refcount
= get_refcount(device
);
2169 ok(refcount
== expected_refcount
, "Got unexpected refcount %u.\n", refcount
);
2170 previous_immediate_context
= immediate_context
;
2172 ID3D11Device_GetImmediateContext(device
, &immediate_context
);
2173 ok(immediate_context
== previous_immediate_context
, "Got different immediate device context objects.\n");
2174 refcount
= get_refcount(device
);
2175 ok(refcount
== expected_refcount
, "Got unexpected refcount %u.\n", refcount
);
2177 refcount
= ID3D11DeviceContext_Release(previous_immediate_context
);
2178 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
2179 refcount
= ID3D11DeviceContext_Release(immediate_context
);
2180 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
2182 ID3D11Device_GetImmediateContext(device
, &immediate_context
);
2183 ok(immediate_context
== previous_immediate_context
, "Got different immediate device context objects.\n");
2184 refcount
= ID3D11DeviceContext_Release(immediate_context
);
2185 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
2187 ID3D11Device_GetImmediateContext(device
, &immediate_context
);
2188 expected_refcount
= get_refcount(immediate_context
) + 1;
2189 hr
= ID3D11DeviceContext_QueryInterface(immediate_context
, &IID_ID3D11Multithread
, (void **)&multithread
);
2190 if (hr
== E_NOINTERFACE
)
2192 win_skip("ID3D11Multithread is not supported.\n");
2195 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2197 refcount
= get_refcount(immediate_context
);
2198 ok(refcount
== expected_refcount
, "Got refcount %u, expected %u.\n", refcount
, expected_refcount
);
2200 expected_refcount
= refcount
;
2201 refcount
= get_refcount(multithread
);
2202 ok(refcount
== expected_refcount
, "Got refcount %u, expected %u.\n", refcount
, expected_refcount
);
2204 enabled
= ID3D11Multithread_GetMultithreadProtected(multithread
);
2205 todo_wine
ok(!enabled
, "Multithread protection is %#x.\n", enabled
);
2207 ID3D11Multithread_Release(multithread
);
2210 refcount
= ID3D11DeviceContext_Release(immediate_context
);
2211 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
2212 refcount
= ID3D11Device_Release(device
);
2213 ok(!refcount
, "Device has %u references left.\n", refcount
);
2216 static void test_create_deferred_context(void)
2218 ULONG refcount
, expected_refcount
;
2219 struct device_desc device_desc
;
2220 ID3D11DeviceContext
*context
;
2221 ID3D11Device
*device
;
2224 device_desc
.feature_level
= NULL
;
2225 device_desc
.flags
= D3D11_CREATE_DEVICE_SINGLETHREADED
;
2226 if (!(device
= create_device(&device_desc
)))
2228 skip("Failed to create single-threaded device.\n");
2232 hr
= ID3D11Device_CreateDeferredContext(device
, 0, &context
);
2233 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Failed to create deferred context, hr %#x.\n", hr
);
2235 refcount
= ID3D11Device_Release(device
);
2236 ok(!refcount
, "Device has %u references left.\n", refcount
);
2238 if (!(device
= create_device(NULL
)))
2240 skip("Failed to create device.\n");
2244 expected_refcount
= get_refcount(device
) + 1;
2245 hr
= ID3D11Device_CreateDeferredContext(device
, 0, &context
);
2246 todo_wine
ok(hr
== S_OK
, "Failed to create deferred context, hr %#x.\n", hr
);
2249 refcount
= get_refcount(device
);
2250 ok(refcount
== expected_refcount
, "Got refcount %u, expected %u.\n", refcount
, expected_refcount
);
2251 refcount
= get_refcount(context
);
2252 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
2254 check_interface(context
, &IID_IUnknown
, TRUE
, FALSE
);
2255 check_interface(context
, &IID_ID3D11DeviceChild
, TRUE
, FALSE
);
2256 check_interface(context
, &IID_ID3D11DeviceContext
, TRUE
, FALSE
);
2257 check_interface(context
, &IID_ID3D11Multithread
, FALSE
, FALSE
);
2259 refcount
= ID3D11DeviceContext_Release(context
);
2260 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
2263 refcount
= ID3D11Device_Release(device
);
2264 ok(!refcount
, "Device has %u references left.\n", refcount
);
2267 static void test_create_texture1d(void)
2269 ULONG refcount
, expected_refcount
;
2270 D3D11_SUBRESOURCE_DATA data
= {0};
2271 ID3D11Device
*device
, *tmp
;
2272 D3D11_TEXTURE1D_DESC desc
;
2273 ID3D11Texture1D
*texture
;
2277 if (!(device
= create_device(NULL
)))
2279 skip("Failed to create device.\n");
2286 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
2287 desc
.Usage
= D3D11_USAGE_DEFAULT
;
2288 desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
2289 desc
.CPUAccessFlags
= 0;
2292 hr
= ID3D11Device_CreateTexture1D(device
, &desc
, &data
, &texture
);
2293 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
2295 expected_refcount
= get_refcount(device
) + 1;
2296 hr
= ID3D11Device_CreateTexture1D(device
, &desc
, NULL
, &texture
);
2297 ok(SUCCEEDED(hr
), "Failed to create a 1d texture, hr %#x.\n", hr
);
2298 refcount
= get_refcount(device
);
2299 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2301 expected_refcount
= refcount
+ 1;
2302 ID3D11Texture1D_GetDevice(texture
, &tmp
);
2303 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2304 refcount
= get_refcount(device
);
2305 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2306 ID3D11Device_Release(tmp
);
2308 check_interface(texture
, &IID_IDXGISurface
, TRUE
, FALSE
);
2309 ID3D11Texture1D_Release(texture
);
2312 expected_refcount
= get_refcount(device
) + 1;
2313 hr
= ID3D11Device_CreateTexture1D(device
, &desc
, NULL
, &texture
);
2314 ok(SUCCEEDED(hr
), "Failed to create a 1d texture, hr %#x.\n", hr
);
2315 refcount
= get_refcount(device
);
2316 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2318 expected_refcount
= refcount
+ 1;
2319 ID3D11Texture1D_GetDevice(texture
, &tmp
);
2320 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2321 refcount
= get_refcount(device
);
2322 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2323 ID3D11Device_Release(tmp
);
2325 ID3D11Texture1D_GetDesc(texture
, &desc
);
2326 ok(desc
.Width
== 512, "Got unexpected Width %u.\n", desc
.Width
);
2327 ok(desc
.MipLevels
== 10, "Got unexpected MipLevels %u.\n", desc
.MipLevels
);
2328 ok(desc
.ArraySize
== 1, "Got unexpected ArraySize %u.\n", desc
.ArraySize
);
2329 ok(desc
.Format
== DXGI_FORMAT_R8G8B8A8_UNORM
, "Got unexpected Format %#x.\n", desc
.Format
);
2330 ok(desc
.Usage
== D3D11_USAGE_DEFAULT
, "Got unexpected Usage %u.\n", desc
.Usage
);
2331 ok(desc
.BindFlags
== D3D11_BIND_SHADER_RESOURCE
, "Got unexpected BindFlags %#x.\n", desc
.BindFlags
);
2332 ok(desc
.CPUAccessFlags
== 0, "Got unexpected CPUAccessFlags %#x.\n", desc
.CPUAccessFlags
);
2333 ok(desc
.MiscFlags
== 0, "Got unexpected MiscFlags %#x.\n", desc
.MiscFlags
);
2335 check_interface(texture
, &IID_IDXGISurface
, FALSE
, FALSE
);
2336 ID3D11Texture1D_Release(texture
);
2340 hr
= ID3D11Device_CreateTexture1D(device
, &desc
, NULL
, &texture
);
2341 ok(SUCCEEDED(hr
), "Failed to create a 1d texture, hr %#x.\n", hr
);
2343 check_interface(texture
, &IID_IDXGISurface
, FALSE
, FALSE
);
2344 ID3D11Texture1D_Release(texture
);
2346 for (i
= 0; i
< 4; ++i
)
2349 desc
.Format
= DXGI_FORMAT_R32G32B32A32_TYPELESS
;
2350 desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
2352 hr
= ID3D11Device_CreateTexture1D(device
, &desc
, NULL
, &texture
);
2353 ok(hr
== (i
? S_OK
: E_INVALIDARG
), "Test %u: Got unexpected hr %#x.\n", i
, hr
);
2355 ID3D11Texture1D_Release(texture
);
2358 refcount
= ID3D11Device_Release(device
);
2359 ok(!refcount
, "Device has %u references left.\n", refcount
);
2362 static void test_texture1d_interfaces(void)
2364 ID3D10Texture1D
*d3d10_texture
;
2365 D3D11_TEXTURE1D_DESC desc
;
2366 ID3D11Texture1D
*texture
;
2367 ID3D11Device
*device
;
2372 static const struct test
2374 BOOL implements_d3d10_interfaces
;
2377 UINT expected_bind_flags
;
2378 UINT expected_misc_flags
;
2380 desc_conversion_tests
[] =
2384 D3D11_BIND_SHADER_RESOURCE
, 0,
2385 D3D10_BIND_SHADER_RESOURCE
, 0
2389 D3D11_BIND_UNORDERED_ACCESS
, 0,
2390 D3D11_BIND_UNORDERED_ACCESS
, 0
2394 0, D3D11_RESOURCE_MISC_RESOURCE_CLAMP
,
2399 0, D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX
,
2400 0, D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX
2404 if (!(device
= create_device(NULL
)))
2406 skip("Failed to create ID3D11Device, skipping tests.\n");
2413 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
2414 desc
.Usage
= D3D11_USAGE_DEFAULT
;
2415 desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
2416 desc
.CPUAccessFlags
= 0;
2419 hr
= ID3D11Device_CreateTexture1D(device
, &desc
, NULL
, &texture
);
2420 ok(SUCCEEDED(hr
), "Failed to create a 1d texture, hr %#x.\n", hr
);
2421 check_interface(texture
, &IID_IDXGISurface
, FALSE
, FALSE
);
2422 hr
= check_interface(texture
, &IID_ID3D10Texture1D
, TRUE
, TRUE
); /* Not available on all Windows versions. */
2423 ID3D11Texture1D_Release(texture
);
2426 win_skip("1D textures do not implement ID3D10Texture1D, skipping tests.\n");
2427 ID3D11Device_Release(device
);
2431 for (i
= 0; i
< ARRAY_SIZE(desc_conversion_tests
); ++i
)
2433 const struct test
*current
= &desc_conversion_tests
[i
];
2434 D3D10_TEXTURE1D_DESC d3d10_desc
;
2435 ID3D10Device
*d3d10_device
;
2440 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
2441 desc
.Usage
= D3D11_USAGE_DEFAULT
;
2442 desc
.BindFlags
= current
->bind_flags
;
2443 desc
.CPUAccessFlags
= 0;
2444 desc
.MiscFlags
= current
->misc_flags
;
2446 hr
= ID3D11Device_CreateTexture1D(device
, &desc
, NULL
, &texture
);
2447 /* Shared resources are not supported by REF and WARP devices. */
2448 ok(SUCCEEDED(hr
) || broken(hr
== E_OUTOFMEMORY
),
2449 "Test %u: Failed to create a 1d texture, hr %#x.\n", i
, hr
);
2452 win_skip("Failed to create ID3D11Texture1D, skipping test %u.\n", i
);
2456 check_interface(texture
, &IID_IDXGISurface
, TRUE
, FALSE
);
2458 hr
= ID3D11Texture1D_QueryInterface(texture
, &IID_ID3D10Texture1D
, (void **)&d3d10_texture
);
2459 ID3D11Texture1D_Release(texture
);
2461 if (current
->implements_d3d10_interfaces
)
2463 ok(SUCCEEDED(hr
), "Test %u: Texture should implement ID3D10Texture1D.\n", i
);
2467 todo_wine
ok(hr
== E_NOINTERFACE
, "Test %u: Texture should not implement ID3D10Texture1D.\n", i
);
2468 if (SUCCEEDED(hr
)) ID3D10Texture1D_Release(d3d10_texture
);
2472 ID3D10Texture1D_GetDesc(d3d10_texture
, &d3d10_desc
);
2474 ok(d3d10_desc
.Width
== desc
.Width
,
2475 "Test %u: Got unexpected Width %u.\n", i
, d3d10_desc
.Width
);
2476 ok(d3d10_desc
.MipLevels
== desc
.MipLevels
,
2477 "Test %u: Got unexpected MipLevels %u.\n", i
, d3d10_desc
.MipLevels
);
2478 ok(d3d10_desc
.ArraySize
== desc
.ArraySize
,
2479 "Test %u: Got unexpected ArraySize %u.\n", i
, d3d10_desc
.ArraySize
);
2480 ok(d3d10_desc
.Format
== desc
.Format
,
2481 "Test %u: Got unexpected Format %u.\n", i
, d3d10_desc
.Format
);
2482 ok(d3d10_desc
.BindFlags
== current
->expected_bind_flags
,
2483 "Test %u: Got unexpected BindFlags %#x.\n", i
, d3d10_desc
.BindFlags
);
2484 ok(d3d10_desc
.CPUAccessFlags
== desc
.CPUAccessFlags
,
2485 "Test %u: Got unexpected CPUAccessFlags %#x.\n", i
, d3d10_desc
.CPUAccessFlags
);
2486 ok(d3d10_desc
.MiscFlags
== current
->expected_misc_flags
,
2487 "Test %u: Got unexpected MiscFlags %#x.\n", i
, d3d10_desc
.MiscFlags
);
2489 d3d10_device
= (ID3D10Device
*)0xdeadbeef;
2490 ID3D10Texture1D_GetDevice(d3d10_texture
, &d3d10_device
);
2491 todo_wine
ok(!d3d10_device
, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i
, d3d10_device
);
2492 if (d3d10_device
) ID3D10Device_Release(d3d10_device
);
2494 ID3D10Texture1D_Release(d3d10_texture
);
2497 refcount
= ID3D11Device_Release(device
);
2498 ok(!refcount
, "Device has %u references left.\n", refcount
);
2501 static void test_create_texture2d(void)
2503 ULONG refcount
, expected_refcount
;
2504 D3D11_SUBRESOURCE_DATA data
= {0};
2505 D3D_FEATURE_LEVEL feature_level
;
2506 ID3D11Device
*device
, *tmp
;
2507 D3D11_TEXTURE2D_DESC desc
;
2508 ID3D11Texture2D
*texture
;
2509 UINT quality_level_count
;
2517 D3D11_BIND_FLAG bind_flags
;
2524 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 1, D3D11_BIND_VERTEX_BUFFER
, 0, FALSE
, TRUE
},
2525 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 1, D3D11_BIND_INDEX_BUFFER
, 0, FALSE
, TRUE
},
2526 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 1, D3D11_BIND_CONSTANT_BUFFER
, 0, FALSE
, TRUE
},
2527 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 0, D3D11_BIND_SHADER_RESOURCE
, 0, FALSE
, FALSE
},
2528 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2529 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 2, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2530 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 3, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2531 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 3, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_TEXTURECUBE
,
2533 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_TEXTURECUBE
,
2535 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 5, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_TEXTURECUBE
,
2537 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 6, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_TEXTURECUBE
,
2539 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 7, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_TEXTURECUBE
,
2541 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 10, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_TEXTURECUBE
,
2543 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 12, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_TEXTURECUBE
,
2545 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 0, D3D11_BIND_RENDER_TARGET
, 0, FALSE
, FALSE
},
2546 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2547 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 2, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2548 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 9, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2549 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 1, D3D11_BIND_DEPTH_STENCIL
, 0, FALSE
, FALSE
},
2550 {DXGI_FORMAT_R32G32B32A32_UINT
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2551 {DXGI_FORMAT_R32G32B32A32_SINT
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2552 {DXGI_FORMAT_R32G32B32_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2553 {DXGI_FORMAT_R16G16B16A16_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2554 {DXGI_FORMAT_R16G16B16A16_TYPELESS
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2555 {DXGI_FORMAT_R32G32_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2556 {DXGI_FORMAT_R32G8X24_TYPELESS
, 1, D3D11_BIND_DEPTH_STENCIL
, 0, TRUE
, FALSE
},
2557 {DXGI_FORMAT_R32G8X24_TYPELESS
, 1, D3D11_BIND_UNORDERED_ACCESS
, 0, FALSE
, TRUE
},
2558 {DXGI_FORMAT_X32_TYPELESS_G8X24_UINT
, 1, D3D11_BIND_UNORDERED_ACCESS
, 0, FALSE
, TRUE
},
2559 {DXGI_FORMAT_R10G10B10A2_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2560 {DXGI_FORMAT_R10G10B10A2_TYPELESS
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2561 {DXGI_FORMAT_R16G16_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2562 {DXGI_FORMAT_R16G16_UNORM
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2563 {DXGI_FORMAT_R16G16_SNORM
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2564 {DXGI_FORMAT_R32_TYPELESS
, 0, D3D11_BIND_SHADER_RESOURCE
, 0, FALSE
, FALSE
},
2565 {DXGI_FORMAT_R32_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2566 {DXGI_FORMAT_R32_TYPELESS
, 9, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2567 {DXGI_FORMAT_R32_TYPELESS
, 9, D3D11_BIND_SHADER_RESOURCE
| D3D11_BIND_DEPTH_STENCIL
, 0,
2569 {DXGI_FORMAT_R32_TYPELESS
, 9, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_TEXTURECUBE
,
2571 {DXGI_FORMAT_R32_TYPELESS
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2572 {DXGI_FORMAT_R32_TYPELESS
, 1, D3D11_BIND_RENDER_TARGET
| D3D11_BIND_DEPTH_STENCIL
, 0,
2574 {DXGI_FORMAT_R32_TYPELESS
, 1, D3D11_BIND_DEPTH_STENCIL
, 0, TRUE
, FALSE
},
2575 {DXGI_FORMAT_R32_TYPELESS
, 1, D3D11_BIND_DEPTH_STENCIL
| D3D11_BIND_UNORDERED_ACCESS
, 0,
2577 {DXGI_FORMAT_R24G8_TYPELESS
, 1, D3D11_BIND_VERTEX_BUFFER
, 0, FALSE
, TRUE
},
2578 {DXGI_FORMAT_R24G8_TYPELESS
, 1, D3D11_BIND_INDEX_BUFFER
, 0, FALSE
, TRUE
},
2579 {DXGI_FORMAT_R24G8_TYPELESS
, 1, D3D11_BIND_CONSTANT_BUFFER
, 0, FALSE
, TRUE
},
2580 {DXGI_FORMAT_R24G8_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2581 {DXGI_FORMAT_R24G8_TYPELESS
, 1, D3D11_BIND_DEPTH_STENCIL
, 0, TRUE
, FALSE
},
2582 {DXGI_FORMAT_R24G8_TYPELESS
, 1, D3D11_BIND_UNORDERED_ACCESS
, 0, FALSE
, TRUE
},
2583 {DXGI_FORMAT_X24_TYPELESS_G8_UINT
, 1, D3D11_BIND_UNORDERED_ACCESS
, 0, FALSE
, TRUE
},
2584 {DXGI_FORMAT_R8G8_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2585 {DXGI_FORMAT_R8G8_TYPELESS
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2586 {DXGI_FORMAT_R8G8_UNORM
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2587 {DXGI_FORMAT_R8G8_SNORM
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2588 {DXGI_FORMAT_R16_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2589 {DXGI_FORMAT_R16_TYPELESS
, 1, D3D11_BIND_DEPTH_STENCIL
, 0, TRUE
, FALSE
},
2590 {DXGI_FORMAT_R16_TYPELESS
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2591 {DXGI_FORMAT_R16_UINT
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2592 {DXGI_FORMAT_R16_SINT
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2593 {DXGI_FORMAT_R8_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2594 {DXGI_FORMAT_R8G8B8A8_UNORM
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2595 {DXGI_FORMAT_R8G8B8A8_UNORM
, 1, D3D11_BIND_DEPTH_STENCIL
, 0, FALSE
, FALSE
},
2596 {DXGI_FORMAT_R8G8B8A8_UINT
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2597 {DXGI_FORMAT_R8G8B8A8_SNORM
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2598 {DXGI_FORMAT_R8G8B8A8_SINT
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2599 {DXGI_FORMAT_D24_UNORM_S8_UINT
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, FALSE
, TRUE
},
2600 {DXGI_FORMAT_D24_UNORM_S8_UINT
, 1, D3D11_BIND_RENDER_TARGET
, 0, FALSE
, FALSE
},
2601 {DXGI_FORMAT_D32_FLOAT
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, FALSE
, TRUE
},
2602 {DXGI_FORMAT_D32_FLOAT
, 1, D3D11_BIND_SHADER_RESOURCE
| D3D11_BIND_DEPTH_STENCIL
, 0,
2604 {DXGI_FORMAT_D32_FLOAT
, 1, D3D11_BIND_RENDER_TARGET
, 0, FALSE
, FALSE
},
2605 {DXGI_FORMAT_D32_FLOAT
, 1, D3D11_BIND_DEPTH_STENCIL
, 0, TRUE
, FALSE
},
2606 {DXGI_FORMAT_R9G9B9E5_SHAREDEXP
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2607 {DXGI_FORMAT_R9G9B9E5_SHAREDEXP
, 1, D3D11_BIND_RENDER_TARGET
, 0, FALSE
, FALSE
},
2608 {DXGI_FORMAT_R9G9B9E5_SHAREDEXP
, 1, D3D11_BIND_DEPTH_STENCIL
, 0, FALSE
, FALSE
},
2611 if (!(device
= create_device(NULL
)))
2613 skip("Failed to create device.\n");
2617 feature_level
= ID3D11Device_GetFeatureLevel(device
);
2623 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
2624 desc
.SampleDesc
.Count
= 1;
2625 desc
.SampleDesc
.Quality
= 0;
2626 desc
.Usage
= D3D11_USAGE_DEFAULT
;
2627 desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
2628 desc
.CPUAccessFlags
= 0;
2631 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, &data
, &texture
);
2632 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
2634 expected_refcount
= get_refcount(device
) + 1;
2635 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
2636 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
2637 refcount
= get_refcount(device
);
2638 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2640 expected_refcount
= refcount
+ 1;
2641 ID3D11Texture2D_GetDevice(texture
, &tmp
);
2642 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2643 refcount
= get_refcount(device
);
2644 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2645 ID3D11Device_Release(tmp
);
2647 check_interface(texture
, &IID_IDXGISurface
, TRUE
, FALSE
);
2648 ID3D11Texture2D_Release(texture
);
2651 expected_refcount
= get_refcount(device
) + 1;
2652 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
2653 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
2654 refcount
= get_refcount(device
);
2655 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2657 expected_refcount
= refcount
+ 1;
2658 ID3D11Texture2D_GetDevice(texture
, &tmp
);
2659 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2660 refcount
= get_refcount(device
);
2661 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2662 ID3D11Device_Release(tmp
);
2664 ID3D11Texture2D_GetDesc(texture
, &desc
);
2665 ok(desc
.Width
== 512, "Got unexpected Width %u.\n", desc
.Width
);
2666 ok(desc
.Height
== 512, "Got unexpected Height %u.\n", desc
.Height
);
2667 ok(desc
.MipLevels
== 10, "Got unexpected MipLevels %u.\n", desc
.MipLevels
);
2668 ok(desc
.ArraySize
== 1, "Got unexpected ArraySize %u.\n", desc
.ArraySize
);
2669 ok(desc
.Format
== DXGI_FORMAT_R8G8B8A8_UNORM
, "Got unexpected Format %#x.\n", desc
.Format
);
2670 ok(desc
.SampleDesc
.Count
== 1, "Got unexpected SampleDesc.Count %u.\n", desc
.SampleDesc
.Count
);
2671 ok(desc
.SampleDesc
.Quality
== 0, "Got unexpected SampleDesc.Quality %u.\n", desc
.SampleDesc
.Quality
);
2672 ok(desc
.Usage
== D3D11_USAGE_DEFAULT
, "Got unexpected Usage %u.\n", desc
.Usage
);
2673 ok(desc
.BindFlags
== D3D11_BIND_RENDER_TARGET
, "Got unexpected BindFlags %#x.\n", desc
.BindFlags
);
2674 ok(desc
.CPUAccessFlags
== 0, "Got unexpected CPUAccessFlags %#x.\n", desc
.CPUAccessFlags
);
2675 ok(desc
.MiscFlags
== 0, "Got unexpected MiscFlags %#x.\n", desc
.MiscFlags
);
2677 check_interface(texture
, &IID_IDXGISurface
, FALSE
, FALSE
);
2678 ID3D11Texture2D_Release(texture
);
2682 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
2683 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
2685 check_interface(texture
, &IID_IDXGISurface
, FALSE
, FALSE
);
2686 ID3D11Texture2D_Release(texture
);
2688 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 2, &quality_level_count
);
2689 ok(hr
== S_OK
, "Failed to check multisample quality levels, hr %#x.\n", hr
);
2691 desc
.SampleDesc
.Count
= 2;
2692 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
2693 if (quality_level_count
)
2695 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
2696 ID3D11Texture2D_Release(texture
);
2697 desc
.SampleDesc
.Quality
= quality_level_count
;
2698 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
2700 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
2702 /* We assume 15 samples multisampling is never supported in practice. */
2703 desc
.SampleDesc
.Count
= 15;
2704 desc
.SampleDesc
.Quality
= 0;
2705 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
2706 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
2708 desc
.SampleDesc
.Count
= 1;
2709 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
2711 HRESULT expected_hr
= tests
[i
].succeeds
? S_OK
: E_INVALIDARG
;
2712 BOOL todo
= tests
[i
].todo
;
2714 if (feature_level
< D3D_FEATURE_LEVEL_10_1
2715 && (tests
[i
].misc_flags
& D3D11_RESOURCE_MISC_TEXTURECUBE
)
2716 && tests
[i
].array_size
> 6)
2718 expected_hr
= E_INVALIDARG
;
2722 desc
.ArraySize
= tests
[i
].array_size
;
2723 desc
.Format
= tests
[i
].format
;
2724 desc
.BindFlags
= tests
[i
].bind_flags
;
2725 desc
.MiscFlags
= tests
[i
].misc_flags
;
2726 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
2729 ok(hr
== expected_hr
, "Test %u: Got unexpected hr %#x (format %#x).\n",
2730 i
, hr
, desc
.Format
);
2733 ID3D11Texture2D_Release(texture
);
2736 refcount
= ID3D11Device_Release(device
);
2737 ok(!refcount
, "Device has %u references left.\n", refcount
);
2740 static void test_texture2d_interfaces(void)
2742 ID3D10Texture2D
*d3d10_texture
;
2743 D3D11_TEXTURE2D_DESC desc
;
2744 ID3D11Texture2D
*texture
;
2745 ID3D11Device
*device
;
2750 static const struct test
2752 BOOL implements_d3d10_interfaces
;
2755 UINT expected_bind_flags
;
2756 UINT expected_misc_flags
;
2758 desc_conversion_tests
[] =
2762 D3D11_BIND_SHADER_RESOURCE
, 0,
2763 D3D10_BIND_SHADER_RESOURCE
, 0
2767 D3D11_BIND_UNORDERED_ACCESS
, 0,
2768 D3D11_BIND_UNORDERED_ACCESS
, 0
2772 0, D3D11_RESOURCE_MISC_RESOURCE_CLAMP
,
2777 0, D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX
,
2778 0, D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX
2782 0, D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX
| D3D11_RESOURCE_MISC_SHARED_NTHANDLE
,
2783 0, D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX
2787 if (!(device
= create_device(NULL
)))
2789 skip("Failed to create ID3D11Device, skipping tests.\n");
2797 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
2798 desc
.SampleDesc
.Count
= 1;
2799 desc
.SampleDesc
.Quality
= 0;
2800 desc
.Usage
= D3D11_USAGE_DEFAULT
;
2801 desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
2802 desc
.CPUAccessFlags
= 0;
2805 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
2806 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
2807 check_interface(texture
, &IID_IDXGISurface
, FALSE
, FALSE
);
2808 hr
= check_interface(texture
, &IID_ID3D10Texture2D
, TRUE
, TRUE
); /* Not available on all Windows versions. */
2809 ID3D11Texture2D_Release(texture
);
2812 win_skip("2D textures do not implement ID3D10Texture2D, skipping tests.\n");
2813 ID3D11Device_Release(device
);
2817 for (i
= 0; i
< ARRAY_SIZE(desc_conversion_tests
); ++i
)
2819 const struct test
*current
= &desc_conversion_tests
[i
];
2820 D3D10_TEXTURE2D_DESC d3d10_desc
;
2821 ID3D10Device
*d3d10_device
;
2827 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
2828 desc
.SampleDesc
.Count
= 1;
2829 desc
.SampleDesc
.Quality
= 0;
2830 desc
.Usage
= D3D11_USAGE_DEFAULT
;
2831 desc
.BindFlags
= current
->bind_flags
;
2832 desc
.CPUAccessFlags
= 0;
2833 desc
.MiscFlags
= current
->misc_flags
;
2835 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
2836 /* Shared resources are not supported by REF and WARP devices. */
2837 ok(SUCCEEDED(hr
) || broken(hr
== E_OUTOFMEMORY
),
2838 "Test %u: Failed to create a 2d texture, hr %#x.\n", i
, hr
);
2841 win_skip("Failed to create ID3D11Texture2D, skipping test %u.\n", i
);
2845 check_interface(texture
, &IID_IDXGISurface
, TRUE
, FALSE
);
2847 hr
= ID3D11Texture2D_QueryInterface(texture
, &IID_ID3D10Texture2D
, (void **)&d3d10_texture
);
2848 ID3D11Texture2D_Release(texture
);
2850 if (current
->implements_d3d10_interfaces
)
2852 ok(SUCCEEDED(hr
), "Test %u: Texture should implement ID3D10Texture2D.\n", i
);
2856 todo_wine
ok(hr
== E_NOINTERFACE
, "Test %u: Texture should not implement ID3D10Texture2D.\n", i
);
2857 if (SUCCEEDED(hr
)) ID3D10Texture2D_Release(d3d10_texture
);
2861 ID3D10Texture2D_GetDesc(d3d10_texture
, &d3d10_desc
);
2863 ok(d3d10_desc
.Width
== desc
.Width
,
2864 "Test %u: Got unexpected Width %u.\n", i
, d3d10_desc
.Width
);
2865 ok(d3d10_desc
.Height
== desc
.Height
,
2866 "Test %u: Got unexpected Height %u.\n", i
, d3d10_desc
.Height
);
2867 ok(d3d10_desc
.MipLevels
== desc
.MipLevels
,
2868 "Test %u: Got unexpected MipLevels %u.\n", i
, d3d10_desc
.MipLevels
);
2869 ok(d3d10_desc
.ArraySize
== desc
.ArraySize
,
2870 "Test %u: Got unexpected ArraySize %u.\n", i
, d3d10_desc
.ArraySize
);
2871 ok(d3d10_desc
.Format
== desc
.Format
,
2872 "Test %u: Got unexpected Format %u.\n", i
, d3d10_desc
.Format
);
2873 ok(d3d10_desc
.SampleDesc
.Count
== desc
.SampleDesc
.Count
,
2874 "Test %u: Got unexpected SampleDesc.Count %u.\n", i
, d3d10_desc
.SampleDesc
.Count
);
2875 ok(d3d10_desc
.SampleDesc
.Quality
== desc
.SampleDesc
.Quality
,
2876 "Test %u: Got unexpected SampleDesc.Quality %u.\n", i
, d3d10_desc
.SampleDesc
.Quality
);
2877 ok(d3d10_desc
.Usage
== (D3D10_USAGE
)desc
.Usage
,
2878 "Test %u: Got unexpected Usage %u.\n", i
, d3d10_desc
.Usage
);
2879 ok(d3d10_desc
.BindFlags
== current
->expected_bind_flags
,
2880 "Test %u: Got unexpected BindFlags %#x.\n", i
, d3d10_desc
.BindFlags
);
2881 ok(d3d10_desc
.CPUAccessFlags
== desc
.CPUAccessFlags
,
2882 "Test %u: Got unexpected CPUAccessFlags %#x.\n", i
, d3d10_desc
.CPUAccessFlags
);
2883 ok(d3d10_desc
.MiscFlags
== current
->expected_misc_flags
,
2884 "Test %u: Got unexpected MiscFlags %#x.\n", i
, d3d10_desc
.MiscFlags
);
2886 d3d10_device
= (ID3D10Device
*)0xdeadbeef;
2887 ID3D10Texture2D_GetDevice(d3d10_texture
, &d3d10_device
);
2888 todo_wine
ok(!d3d10_device
, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i
, d3d10_device
);
2889 if (d3d10_device
) ID3D10Device_Release(d3d10_device
);
2891 ID3D10Texture2D_Release(d3d10_texture
);
2894 refcount
= ID3D11Device_Release(device
);
2895 ok(!refcount
, "Device has %u references left.\n", refcount
);
2898 static void test_create_texture3d(void)
2900 ULONG refcount
, expected_refcount
;
2901 D3D11_SUBRESOURCE_DATA data
= {0};
2902 ID3D11Device
*device
, *tmp
;
2903 D3D11_TEXTURE3D_DESC desc
;
2904 ID3D11Texture3D
*texture
;
2911 D3D11_BIND_FLAG bind_flags
;
2917 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, D3D11_BIND_VERTEX_BUFFER
, FALSE
, TRUE
},
2918 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, D3D11_BIND_INDEX_BUFFER
, FALSE
, TRUE
},
2919 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, D3D11_BIND_CONSTANT_BUFFER
, FALSE
, TRUE
},
2920 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, D3D11_BIND_SHADER_RESOURCE
, TRUE
, FALSE
},
2921 {DXGI_FORMAT_R16G16B16A16_TYPELESS
, D3D11_BIND_SHADER_RESOURCE
, TRUE
, FALSE
},
2922 {DXGI_FORMAT_R10G10B10A2_TYPELESS
, D3D11_BIND_SHADER_RESOURCE
, TRUE
, FALSE
},
2923 {DXGI_FORMAT_R8G8B8A8_UNORM
, D3D11_BIND_DEPTH_STENCIL
, FALSE
, FALSE
},
2924 {DXGI_FORMAT_D24_UNORM_S8_UINT
, D3D11_BIND_RENDER_TARGET
, FALSE
, FALSE
},
2925 {DXGI_FORMAT_D32_FLOAT
, D3D11_BIND_RENDER_TARGET
, FALSE
, FALSE
},
2926 {DXGI_FORMAT_R9G9B9E5_SHAREDEXP
, D3D11_BIND_SHADER_RESOURCE
, TRUE
, FALSE
},
2927 {DXGI_FORMAT_R9G9B9E5_SHAREDEXP
, D3D11_BIND_RENDER_TARGET
, FALSE
, FALSE
},
2928 {DXGI_FORMAT_R9G9B9E5_SHAREDEXP
, D3D11_BIND_DEPTH_STENCIL
, FALSE
, FALSE
},
2931 if (!(device
= create_device(NULL
)))
2933 skip("Failed to create ID3D11Device, skipping tests.\n");
2941 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
2942 desc
.Usage
= D3D11_USAGE_DEFAULT
;
2943 desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
2944 desc
.CPUAccessFlags
= 0;
2947 hr
= ID3D11Device_CreateTexture3D(device
, &desc
, &data
, &texture
);
2948 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
2950 expected_refcount
= get_refcount(device
) + 1;
2951 hr
= ID3D11Device_CreateTexture3D(device
, &desc
, NULL
, &texture
);
2952 ok(SUCCEEDED(hr
), "Failed to create a 3d texture, hr %#x.\n", hr
);
2953 refcount
= get_refcount(device
);
2954 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2956 expected_refcount
= refcount
+ 1;
2957 ID3D11Texture3D_GetDevice(texture
, &tmp
);
2958 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2959 refcount
= get_refcount(device
);
2960 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2961 ID3D11Device_Release(tmp
);
2963 check_interface(texture
, &IID_IDXGISurface
, FALSE
, FALSE
);
2964 ID3D11Texture3D_Release(texture
);
2967 expected_refcount
= get_refcount(device
) + 1;
2968 hr
= ID3D11Device_CreateTexture3D(device
, &desc
, NULL
, &texture
);
2969 ok(SUCCEEDED(hr
), "Failed to create a 3d texture, hr %#x.\n", hr
);
2970 refcount
= get_refcount(device
);
2971 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2973 expected_refcount
= refcount
+ 1;
2974 ID3D11Texture3D_GetDevice(texture
, &tmp
);
2975 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2976 refcount
= get_refcount(device
);
2977 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2978 ID3D11Device_Release(tmp
);
2980 ID3D11Texture3D_GetDesc(texture
, &desc
);
2981 ok(desc
.Width
== 64, "Got unexpected Width %u.\n", desc
.Width
);
2982 ok(desc
.Height
== 64, "Got unexpected Height %u.\n", desc
.Height
);
2983 ok(desc
.Depth
== 64, "Got unexpected Depth %u.\n", desc
.Depth
);
2984 ok(desc
.MipLevels
== 7, "Got unexpected MipLevels %u.\n", desc
.MipLevels
);
2985 ok(desc
.Format
== DXGI_FORMAT_R8G8B8A8_UNORM
, "Got unexpected Format %#x.\n", desc
.Format
);
2986 ok(desc
.Usage
== D3D11_USAGE_DEFAULT
, "Got unexpected Usage %u.\n", desc
.Usage
);
2987 ok(desc
.BindFlags
== D3D11_BIND_RENDER_TARGET
, "Got unexpected BindFlags %u.\n", desc
.BindFlags
);
2988 ok(desc
.CPUAccessFlags
== 0, "Got unexpected CPUAccessFlags %u.\n", desc
.CPUAccessFlags
);
2989 ok(desc
.MiscFlags
== 0, "Got unexpected MiscFlags %u.\n", desc
.MiscFlags
);
2991 check_interface(texture
, &IID_IDXGISurface
, FALSE
, FALSE
);
2992 ID3D11Texture3D_Release(texture
);
2995 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
2997 desc
.Format
= tests
[i
].format
;
2998 desc
.BindFlags
= tests
[i
].bind_flags
;
2999 hr
= ID3D11Device_CreateTexture3D(device
, &desc
, NULL
, &texture
);
3001 todo_wine_if(tests
[i
].todo
)
3002 ok(hr
== (tests
[i
].succeeds
? S_OK
: E_INVALIDARG
), "Test %u: Got unexpected hr %#x.\n", i
, hr
);
3005 ID3D11Texture3D_Release(texture
);
3008 refcount
= ID3D11Device_Release(device
);
3009 ok(!refcount
, "Device has %u references left.\n", refcount
);
3012 static void test_texture3d_interfaces(void)
3014 ID3D10Texture3D
*d3d10_texture
;
3015 D3D11_TEXTURE3D_DESC desc
;
3016 ID3D11Texture3D
*texture
;
3017 ID3D11Device
*device
;
3022 static const struct test
3024 BOOL implements_d3d10_interfaces
;
3027 UINT expected_bind_flags
;
3028 UINT expected_misc_flags
;
3030 desc_conversion_tests
[] =
3034 D3D11_BIND_SHADER_RESOURCE
, 0,
3035 D3D10_BIND_SHADER_RESOURCE
, 0
3039 D3D11_BIND_UNORDERED_ACCESS
, 0,
3040 D3D11_BIND_UNORDERED_ACCESS
, 0
3044 0, D3D11_RESOURCE_MISC_RESOURCE_CLAMP
,
3049 0, D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX
,
3050 0, D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX
3054 if (!(device
= create_device(NULL
)))
3056 skip("Failed to create ID3D11Device.\n");
3064 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
3065 desc
.Usage
= D3D11_USAGE_DEFAULT
;
3066 desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
3067 desc
.CPUAccessFlags
= 0;
3070 hr
= ID3D11Device_CreateTexture3D(device
, &desc
, NULL
, &texture
);
3071 ok(SUCCEEDED(hr
), "Failed to create a 3d texture, hr %#x.\n", hr
);
3072 check_interface(texture
, &IID_IDXGISurface
, FALSE
, FALSE
);
3073 hr
= check_interface(texture
, &IID_ID3D10Texture3D
, TRUE
, TRUE
); /* Not available on all Windows versions. */
3074 ID3D11Texture3D_Release(texture
);
3077 win_skip("3D textures do not implement ID3D10Texture3D.\n");
3078 ID3D11Device_Release(device
);
3082 for (i
= 0; i
< ARRAY_SIZE(desc_conversion_tests
); ++i
)
3084 const struct test
*current
= &desc_conversion_tests
[i
];
3085 D3D10_TEXTURE3D_DESC d3d10_desc
;
3086 ID3D10Device
*d3d10_device
;
3092 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
3093 desc
.Usage
= D3D11_USAGE_DEFAULT
;
3094 desc
.BindFlags
= current
->bind_flags
;
3095 desc
.CPUAccessFlags
= 0;
3096 desc
.MiscFlags
= current
->misc_flags
;
3098 hr
= ID3D11Device_CreateTexture3D(device
, &desc
, NULL
, &texture
);
3099 /* Shared resources are not supported by REF and WARP devices. */
3100 ok(SUCCEEDED(hr
) || broken(hr
== E_OUTOFMEMORY
),
3101 "Test %u: Failed to create a 3d texture, hr %#x.\n", i
, hr
);
3104 win_skip("Failed to create ID3D11Texture3D, skipping test %u.\n", i
);
3108 check_interface(texture
, &IID_IDXGISurface
, FALSE
, FALSE
);
3110 hr
= ID3D11Texture3D_QueryInterface(texture
, &IID_ID3D10Texture3D
, (void **)&d3d10_texture
);
3111 ID3D11Texture3D_Release(texture
);
3113 if (current
->implements_d3d10_interfaces
)
3115 ok(SUCCEEDED(hr
), "Test %u: Texture should implement ID3D10Texture3D.\n", i
);
3119 todo_wine
ok(hr
== E_NOINTERFACE
, "Test %u: Texture should not implement ID3D10Texture3D.\n", i
);
3120 if (SUCCEEDED(hr
)) ID3D10Texture3D_Release(d3d10_texture
);
3124 ID3D10Texture3D_GetDesc(d3d10_texture
, &d3d10_desc
);
3126 ok(d3d10_desc
.Width
== desc
.Width
,
3127 "Test %u: Got unexpected Width %u.\n", i
, d3d10_desc
.Width
);
3128 ok(d3d10_desc
.Height
== desc
.Height
,
3129 "Test %u: Got unexpected Height %u.\n", i
, d3d10_desc
.Height
);
3130 ok(d3d10_desc
.Depth
== desc
.Depth
,
3131 "Test %u: Got unexpected Depth %u.\n", i
, d3d10_desc
.Depth
);
3132 ok(d3d10_desc
.MipLevels
== desc
.MipLevels
,
3133 "Test %u: Got unexpected MipLevels %u.\n", i
, d3d10_desc
.MipLevels
);
3134 ok(d3d10_desc
.Format
== desc
.Format
,
3135 "Test %u: Got unexpected Format %u.\n", i
, d3d10_desc
.Format
);
3136 ok(d3d10_desc
.Usage
== (D3D10_USAGE
)desc
.Usage
,
3137 "Test %u: Got unexpected Usage %u.\n", i
, d3d10_desc
.Usage
);
3138 ok(d3d10_desc
.BindFlags
== current
->expected_bind_flags
,
3139 "Test %u: Got unexpected BindFlags %#x.\n", i
, d3d10_desc
.BindFlags
);
3140 ok(d3d10_desc
.CPUAccessFlags
== desc
.CPUAccessFlags
,
3141 "Test %u: Got unexpected CPUAccessFlags %#x.\n", i
, d3d10_desc
.CPUAccessFlags
);
3142 ok(d3d10_desc
.MiscFlags
== current
->expected_misc_flags
,
3143 "Test %u: Got unexpected MiscFlags %#x.\n", i
, d3d10_desc
.MiscFlags
);
3145 d3d10_device
= (ID3D10Device
*)0xdeadbeef;
3146 ID3D10Texture3D_GetDevice(d3d10_texture
, &d3d10_device
);
3147 todo_wine
ok(!d3d10_device
, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i
, d3d10_device
);
3148 if (d3d10_device
) ID3D10Device_Release(d3d10_device
);
3150 ID3D10Texture3D_Release(d3d10_texture
);
3153 refcount
= ID3D11Device_Release(device
);
3154 ok(!refcount
, "Device has %u references left.\n", refcount
);
3157 static void test_create_buffer(void)
3159 ID3D10Buffer
*d3d10_buffer
;
3160 HRESULT expected_hr
, hr
;
3161 D3D11_BUFFER_DESC desc
;
3162 ID3D11Buffer
*buffer
;
3163 ID3D11Device
*device
;
3167 static const struct test
3170 BOOL implements_d3d10_interfaces
;
3173 UINT structure_stride
;
3174 UINT expected_bind_flags
;
3175 UINT expected_misc_flags
;
3181 D3D11_BIND_VERTEX_BUFFER
, 0, 0,
3182 D3D10_BIND_VERTEX_BUFFER
, 0
3186 D3D11_BIND_INDEX_BUFFER
, 0, 0,
3187 D3D10_BIND_INDEX_BUFFER
, 0
3191 D3D11_BIND_CONSTANT_BUFFER
, 0, 0,
3192 D3D10_BIND_CONSTANT_BUFFER
, 0
3196 D3D11_BIND_SHADER_RESOURCE
, 0, 0,
3197 D3D10_BIND_SHADER_RESOURCE
, 0
3201 D3D11_BIND_STREAM_OUTPUT
, 0, 0,
3202 D3D10_BIND_STREAM_OUTPUT
, 0
3206 D3D11_BIND_RENDER_TARGET
, 0, 0,
3207 D3D10_BIND_RENDER_TARGET
, 0
3211 D3D11_BIND_UNORDERED_ACCESS
, 0, 0,
3212 D3D11_BIND_UNORDERED_ACCESS
, 0
3216 0, D3D11_RESOURCE_MISC_SHARED
, 0,
3217 0, D3D10_RESOURCE_MISC_SHARED
3221 0, D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS
, 0,
3226 D3D11_BIND_VERTEX_BUFFER
, D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
, 0,
3230 D3D11_BIND_INDEX_BUFFER
, D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
, 0,
3234 D3D11_BIND_CONSTANT_BUFFER
, D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
, 0,
3238 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
, 0,
3239 D3D10_BIND_SHADER_RESOURCE
, 0
3243 D3D11_BIND_STREAM_OUTPUT
, D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
, 0,
3247 D3D11_BIND_RENDER_TARGET
, D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
, 0,
3251 D3D11_BIND_UNORDERED_ACCESS
, D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
, 0,
3252 D3D11_BIND_UNORDERED_ACCESS
, 0
3256 0, D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
, 0,
3258 /* Structured buffers do not implement ID3D10Buffer. */
3261 0, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 16,
3265 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 16,
3269 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, ~0u,
3273 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 0,
3277 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 1,
3281 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 2,
3285 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 3,
3289 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 4,
3293 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 5,
3297 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 8,
3301 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 512,
3305 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 513,
3309 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 1024,
3318 D3D11_BIND_CONSTANT_BUFFER
, 0, 513,
3319 D3D10_BIND_CONSTANT_BUFFER
, 0
3323 D3D11_BIND_SHADER_RESOURCE
, 0, 513,
3324 D3D10_BIND_SHADER_RESOURCE
, 0
3328 D3D11_BIND_UNORDERED_ACCESS
, 0, 513,
3329 D3D11_BIND_UNORDERED_ACCESS
, 0
3333 0, D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
| D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 16,
3337 D3D11_BIND_SHADER_RESOURCE
,
3338 D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
| D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 16,
3342 0, D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX
, 0,
3343 0, D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX
3347 if (!(device
= create_device(NULL
)))
3349 skip("Failed to create ID3D11Device.\n");
3353 buffer
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, 1024, NULL
);
3354 hr
= check_interface(buffer
, &IID_ID3D10Buffer
, TRUE
, TRUE
); /* Not available on all Windows versions. */
3355 ID3D11Buffer_Release(buffer
);
3358 win_skip("Buffers do not implement ID3D10Buffer.\n");
3359 ID3D11Device_Release(device
);
3363 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
3365 const struct test
*current
= &tests
[i
];
3366 D3D11_BUFFER_DESC obtained_desc
;
3367 D3D10_BUFFER_DESC d3d10_desc
;
3368 ID3D10Device
*d3d10_device
;
3370 desc
.ByteWidth
= 1024;
3371 desc
.Usage
= D3D11_USAGE_DEFAULT
;
3372 desc
.BindFlags
= current
->bind_flags
;
3373 desc
.CPUAccessFlags
= 0;
3374 desc
.MiscFlags
= current
->misc_flags
;
3375 desc
.StructureByteStride
= current
->structure_stride
;
3377 hr
= ID3D11Device_CreateBuffer(device
, &desc
, NULL
, &buffer
);
3378 expected_hr
= current
->succeeds
? S_OK
: E_INVALIDARG
;
3379 /* Shared resources are not supported by REF and WARP devices. */
3380 ok(hr
== expected_hr
|| broken(hr
== E_OUTOFMEMORY
), "Test %u: Got hr %#x, expected %#x.\n",
3381 i
, hr
, expected_hr
);
3384 if (hr
== E_OUTOFMEMORY
)
3385 win_skip("Failed to create a buffer, skipping test %u.\n", i
);
3389 if (!(desc
.MiscFlags
& D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
))
3390 desc
.StructureByteStride
= 0;
3392 ID3D11Buffer_GetDesc(buffer
, &obtained_desc
);
3394 ok(obtained_desc
.ByteWidth
== desc
.ByteWidth
,
3395 "Test %u: Got unexpected ByteWidth %u.\n", i
, obtained_desc
.ByteWidth
);
3396 ok(obtained_desc
.Usage
== desc
.Usage
,
3397 "Test %u: Got unexpected Usage %u.\n", i
, obtained_desc
.Usage
);
3398 ok(obtained_desc
.BindFlags
== desc
.BindFlags
,
3399 "Test %u: Got unexpected BindFlags %#x.\n", i
, obtained_desc
.BindFlags
);
3400 ok(obtained_desc
.CPUAccessFlags
== desc
.CPUAccessFlags
,
3401 "Test %u: Got unexpected CPUAccessFlags %#x.\n", i
, obtained_desc
.CPUAccessFlags
);
3402 ok(obtained_desc
.MiscFlags
== desc
.MiscFlags
,
3403 "Test %u: Got unexpected MiscFlags %#x.\n", i
, obtained_desc
.MiscFlags
);
3404 ok(obtained_desc
.StructureByteStride
== desc
.StructureByteStride
,
3405 "Test %u: Got unexpected StructureByteStride %u.\n", i
, obtained_desc
.StructureByteStride
);
3407 hr
= ID3D11Buffer_QueryInterface(buffer
, &IID_ID3D10Buffer
, (void **)&d3d10_buffer
);
3408 ID3D11Buffer_Release(buffer
);
3410 if (current
->implements_d3d10_interfaces
)
3412 ok(SUCCEEDED(hr
), "Test %u: Buffer should implement ID3D10Buffer.\n", i
);
3416 todo_wine
ok(hr
== E_NOINTERFACE
, "Test %u: Buffer should not implement ID3D10Buffer.\n", i
);
3417 if (SUCCEEDED(hr
)) ID3D10Buffer_Release(d3d10_buffer
);
3421 ID3D10Buffer_GetDesc(d3d10_buffer
, &d3d10_desc
);
3423 ok(d3d10_desc
.ByteWidth
== desc
.ByteWidth
,
3424 "Test %u: Got unexpected ByteWidth %u.\n", i
, d3d10_desc
.ByteWidth
);
3425 ok(d3d10_desc
.Usage
== (D3D10_USAGE
)desc
.Usage
,
3426 "Test %u: Got unexpected Usage %u.\n", i
, d3d10_desc
.Usage
);
3427 ok(d3d10_desc
.BindFlags
== current
->expected_bind_flags
,
3428 "Test %u: Got unexpected BindFlags %#x.\n", i
, d3d10_desc
.BindFlags
);
3429 ok(d3d10_desc
.CPUAccessFlags
== desc
.CPUAccessFlags
,
3430 "Test %u: Got unexpected CPUAccessFlags %#x.\n", i
, d3d10_desc
.CPUAccessFlags
);
3431 ok(d3d10_desc
.MiscFlags
== current
->expected_misc_flags
,
3432 "Test %u: Got unexpected MiscFlags %#x.\n", i
, d3d10_desc
.MiscFlags
);
3434 d3d10_device
= (ID3D10Device
*)0xdeadbeef;
3435 ID3D10Buffer_GetDevice(d3d10_buffer
, &d3d10_device
);
3436 todo_wine
ok(!d3d10_device
, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i
, d3d10_device
);
3437 if (d3d10_device
) ID3D10Device_Release(d3d10_device
);
3439 ID3D10Buffer_Release(d3d10_buffer
);
3442 memset(&desc
, 0, sizeof(desc
));
3443 desc
.BindFlags
= D3D11_BIND_CONSTANT_BUFFER
;
3444 for (i
= 0; i
<= 32; ++i
)
3447 expected_hr
= !i
|| i
% 16 ? E_INVALIDARG
: S_OK
;
3448 hr
= ID3D11Device_CreateBuffer(device
, &desc
, NULL
, &buffer
);
3449 ok(hr
== expected_hr
, "Got unexpected hr %#x for constant buffer size %u.\n", hr
, i
);
3451 ID3D11Buffer_Release(buffer
);
3454 refcount
= ID3D11Device_Release(device
);
3455 ok(!refcount
, "Device has %u references left.\n", refcount
);
3458 static void test_create_depthstencil_view(void)
3460 D3D11_DEPTH_STENCIL_VIEW_DESC dsv_desc
;
3461 D3D11_TEXTURE2D_DESC texture_desc
;
3462 ULONG refcount
, expected_refcount
;
3463 ID3D11DepthStencilView
*dsview
;
3464 ID3D11Device
*device
, *tmp
;
3465 ID3D11Texture2D
*texture
;
3469 #define FMT_UNKNOWN DXGI_FORMAT_UNKNOWN
3470 #define D24S8 DXGI_FORMAT_D24_UNORM_S8_UINT
3471 #define R24G8_TL DXGI_FORMAT_R24G8_TYPELESS
3472 #define DIM_UNKNOWN D3D11_DSV_DIMENSION_UNKNOWN
3473 #define TEX_1D D3D11_DSV_DIMENSION_TEXTURE1D
3474 #define TEX_1D_ARRAY D3D11_DSV_DIMENSION_TEXTURE1DARRAY
3475 #define TEX_2D D3D11_DSV_DIMENSION_TEXTURE2D
3476 #define TEX_2D_ARRAY D3D11_DSV_DIMENSION_TEXTURE2DARRAY
3477 #define TEX_2DMS D3D11_DSV_DIMENSION_TEXTURE2DMS
3478 #define TEX_2DMS_ARR D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY
3483 unsigned int miplevel_count
;
3484 unsigned int array_size
;
3487 struct dsv_desc dsv_desc
;
3488 struct dsv_desc expected_dsv_desc
;
3492 {{ 1, 1, D24S8
}, {0}, {D24S8
, TEX_2D
, 0}},
3493 {{10, 1, D24S8
}, {0}, {D24S8
, TEX_2D
, 0}},
3494 {{10, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2D
, 0}, {D24S8
, TEX_2D
, 0}},
3495 {{10, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2D
, 1}, {D24S8
, TEX_2D
, 1}},
3496 {{10, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2D
, 9}, {D24S8
, TEX_2D
, 9}},
3497 {{ 1, 1, R24G8_TL
}, {D24S8
, TEX_2D
, 0}, {D24S8
, TEX_2D
, 0}},
3498 {{10, 1, R24G8_TL
}, {D24S8
, TEX_2D
, 0}, {D24S8
, TEX_2D
, 0}},
3499 {{ 1, 4, D24S8
}, {0}, {D24S8
, TEX_2D_ARRAY
, 0, 0, 4}},
3500 {{10, 4, D24S8
}, {0}, {D24S8
, TEX_2D_ARRAY
, 0, 0, 4}},
3501 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 0, ~0u}, {D24S8
, TEX_2D_ARRAY
, 0, 0, 4}},
3502 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 1, 0, ~0u}, {D24S8
, TEX_2D_ARRAY
, 1, 0, 4}},
3503 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 3, 0, ~0u}, {D24S8
, TEX_2D_ARRAY
, 3, 0, 4}},
3504 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 5, 0, ~0u}, {D24S8
, TEX_2D_ARRAY
, 5, 0, 4}},
3505 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 9, 0, ~0u}, {D24S8
, TEX_2D_ARRAY
, 9, 0, 4}},
3506 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 1, ~0u}, {D24S8
, TEX_2D_ARRAY
, 0, 1, 3}},
3507 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 2, ~0u}, {D24S8
, TEX_2D_ARRAY
, 0, 2, 2}},
3508 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 3, ~0u}, {D24S8
, TEX_2D_ARRAY
, 0, 3, 1}},
3509 {{ 1, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS
}, {D24S8
, TEX_2DMS
}},
3510 {{ 1, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS
}, {D24S8
, TEX_2DMS
}},
3511 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS
}, {D24S8
, TEX_2DMS
}},
3512 {{ 1, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 1}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 1}},
3513 {{ 1, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, ~0u}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 1}},
3514 {{10, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 1}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 1}},
3515 {{10, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, ~0u}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 1}},
3516 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 1}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 1}},
3517 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 4}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 4}},
3518 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, ~0u}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 4}},
3524 unsigned int miplevel_count
;
3525 unsigned int array_size
;
3528 struct dsv_desc dsv_desc
;
3530 invalid_desc_tests
[] =
3532 {{1, 1, D24S8
}, {D24S8
, DIM_UNKNOWN
}},
3533 {{6, 4, D24S8
}, {D24S8
, DIM_UNKNOWN
}},
3534 {{1, 1, D24S8
}, {D24S8
, TEX_1D
, 0}},
3535 {{1, 1, D24S8
}, {D24S8
, TEX_1D_ARRAY
, 0, 0, 1}},
3536 {{1, 1, D24S8
}, {R24G8_TL
, TEX_2D
, 0}},
3537 {{1, 1, R24G8_TL
}, {FMT_UNKNOWN
, TEX_2D
, 0}},
3538 {{1, 1, D24S8
}, {D24S8
, TEX_2D
, 1}},
3539 {{1, 1, D24S8
}, {D24S8
, TEX_2D_ARRAY
, 0, 0, 0}},
3540 {{1, 1, D24S8
}, {D24S8
, TEX_2D_ARRAY
, 1, 0, 1}},
3541 {{1, 1, D24S8
}, {D24S8
, TEX_2D_ARRAY
, 0, 0, 2}},
3542 {{1, 1, D24S8
}, {D24S8
, TEX_2D_ARRAY
, 0, 1, 1}},
3543 {{1, 1, D24S8
}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 2}},
3544 {{1, 1, D24S8
}, {D24S8
, TEX_2DMS_ARR
, 0, 1, 1}},
3557 if (!(device
= create_device(NULL
)))
3559 skip("Failed to create device.\n");
3563 texture_desc
.Width
= 512;
3564 texture_desc
.Height
= 512;
3565 texture_desc
.MipLevels
= 1;
3566 texture_desc
.ArraySize
= 1;
3567 texture_desc
.Format
= DXGI_FORMAT_D24_UNORM_S8_UINT
;
3568 texture_desc
.SampleDesc
.Count
= 1;
3569 texture_desc
.SampleDesc
.Quality
= 0;
3570 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
3571 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
3572 texture_desc
.CPUAccessFlags
= 0;
3573 texture_desc
.MiscFlags
= 0;
3575 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
3576 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
3578 expected_refcount
= get_refcount(device
) + 1;
3579 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, NULL
, &dsview
);
3580 ok(SUCCEEDED(hr
), "Failed to create a depthstencil view, hr %#x.\n", hr
);
3581 refcount
= get_refcount(device
);
3582 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
3584 expected_refcount
= refcount
+ 1;
3585 ID3D11DepthStencilView_GetDevice(dsview
, &tmp
);
3586 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
3587 refcount
= get_refcount(device
);
3588 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
3589 ID3D11Device_Release(tmp
);
3591 memset(&dsv_desc
, 0, sizeof(dsv_desc
));
3592 ID3D11DepthStencilView_GetDesc(dsview
, &dsv_desc
);
3593 ok(dsv_desc
.Format
== texture_desc
.Format
, "Got unexpected format %#x.\n", dsv_desc
.Format
);
3594 ok(dsv_desc
.ViewDimension
== D3D11_DSV_DIMENSION_TEXTURE2D
,
3595 "Got unexpected view dimension %#x.\n", dsv_desc
.ViewDimension
);
3596 ok(!dsv_desc
.Flags
, "Got unexpected flags %#x.\n", dsv_desc
.Flags
);
3597 ok(!U(dsv_desc
).Texture2D
.MipSlice
, "Got unexpected mip slice %u.\n", U(dsv_desc
).Texture2D
.MipSlice
);
3599 ID3D11DepthStencilView_Release(dsview
);
3600 ID3D11Texture2D_Release(texture
);
3602 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
3604 D3D11_DEPTH_STENCIL_VIEW_DESC
*current_desc
;
3606 texture_desc
.MipLevels
= tests
[i
].texture
.miplevel_count
;
3607 texture_desc
.ArraySize
= tests
[i
].texture
.array_size
;
3608 texture_desc
.Format
= tests
[i
].texture
.format
;
3610 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
3611 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
3613 if (tests
[i
].dsv_desc
.dimension
== D3D11_DSV_DIMENSION_UNKNOWN
)
3615 current_desc
= NULL
;
3619 current_desc
= &dsv_desc
;
3620 get_dsv_desc(current_desc
, &tests
[i
].dsv_desc
);
3623 expected_refcount
= get_refcount(texture
);
3624 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, current_desc
, &dsview
);
3625 ok(SUCCEEDED(hr
), "Test %u: Failed to create depth stencil view, hr %#x.\n", i
, hr
);
3626 refcount
= get_refcount(texture
);
3627 ok(refcount
== expected_refcount
, "Got refcount %u, expected %u.\n", refcount
, expected_refcount
);
3629 /* Not available on all Windows versions. */
3630 check_interface(dsview
, &IID_ID3D10DepthStencilView
, TRUE
, TRUE
);
3632 memset(&dsv_desc
, 0, sizeof(dsv_desc
));
3633 ID3D11DepthStencilView_GetDesc(dsview
, &dsv_desc
);
3634 check_dsv_desc(&dsv_desc
, &tests
[i
].expected_dsv_desc
);
3636 ID3D11DepthStencilView_Release(dsview
);
3637 ID3D11Texture2D_Release(texture
);
3640 for (i
= 0; i
< ARRAY_SIZE(invalid_desc_tests
); ++i
)
3642 texture_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
3643 texture_desc
.ArraySize
= invalid_desc_tests
[i
].texture
.array_size
;
3644 texture_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
3646 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
3647 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
3649 get_dsv_desc(&dsv_desc
, &invalid_desc_tests
[i
].dsv_desc
);
3650 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, &dsv_desc
, &dsview
);
3651 ok(hr
== E_INVALIDARG
, "Test %u: Got unexpected hr %#x.\n", i
, hr
);
3653 ID3D11Texture2D_Release(texture
);
3656 refcount
= ID3D11Device_Release(device
);
3657 ok(!refcount
, "Device has %u references left.\n", refcount
);
3660 static void test_depthstencil_view_interfaces(void)
3662 D3D10_DEPTH_STENCIL_VIEW_DESC d3d10_dsv_desc
;
3663 D3D11_DEPTH_STENCIL_VIEW_DESC dsv_desc
;
3664 ID3D10DepthStencilView
*d3d10_dsview
;
3665 D3D11_TEXTURE2D_DESC texture_desc
;
3666 ID3D11DepthStencilView
*dsview
;
3667 ID3D11Texture2D
*texture
;
3668 ID3D11Device
*device
;
3672 if (!(device
= create_device(NULL
)))
3674 skip("Failed to create device.\n");
3678 texture_desc
.Width
= 512;
3679 texture_desc
.Height
= 512;
3680 texture_desc
.MipLevels
= 1;
3681 texture_desc
.ArraySize
= 1;
3682 texture_desc
.Format
= DXGI_FORMAT_D24_UNORM_S8_UINT
;
3683 texture_desc
.SampleDesc
.Count
= 1;
3684 texture_desc
.SampleDesc
.Quality
= 0;
3685 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
3686 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
3687 texture_desc
.CPUAccessFlags
= 0;
3688 texture_desc
.MiscFlags
= 0;
3690 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
3691 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
3693 dsv_desc
.Format
= texture_desc
.Format
;
3694 dsv_desc
.ViewDimension
= D3D11_DSV_DIMENSION_TEXTURE2D
;
3696 U(dsv_desc
).Texture2D
.MipSlice
= 0;
3698 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, &dsv_desc
, &dsview
);
3699 ok(SUCCEEDED(hr
), "Failed to create a depthstencil view, hr %#x.\n", hr
);
3701 hr
= ID3D11DepthStencilView_QueryInterface(dsview
, &IID_ID3D10DepthStencilView
, (void **)&d3d10_dsview
);
3702 ID3D11DepthStencilView_Release(dsview
);
3703 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
3704 "Depth stencil view should implement ID3D10DepthStencilView.\n");
3708 win_skip("Depth stencil view does not implement ID3D10DepthStencilView.\n");
3712 ID3D10DepthStencilView_GetDesc(d3d10_dsview
, &d3d10_dsv_desc
);
3713 ok(d3d10_dsv_desc
.Format
== dsv_desc
.Format
, "Got unexpected format %#x.\n", d3d10_dsv_desc
.Format
);
3714 ok(d3d10_dsv_desc
.ViewDimension
== (D3D10_DSV_DIMENSION
)dsv_desc
.ViewDimension
,
3715 "Got unexpected view dimension %u.\n", d3d10_dsv_desc
.ViewDimension
);
3716 ok(U(d3d10_dsv_desc
).Texture2D
.MipSlice
== U(dsv_desc
).Texture2D
.MipSlice
,
3717 "Got unexpected mip slice %u.\n", U(d3d10_dsv_desc
).Texture2D
.MipSlice
);
3719 ID3D10DepthStencilView_Release(d3d10_dsview
);
3722 ID3D11Texture2D_Release(texture
);
3724 refcount
= ID3D11Device_Release(device
);
3725 ok(!refcount
, "Device has %u references left.\n", refcount
);
3728 static void test_create_rendertarget_view(void)
3730 D3D11_RENDER_TARGET_VIEW_DESC rtv_desc
;
3731 D3D11_TEXTURE3D_DESC texture3d_desc
;
3732 D3D11_TEXTURE2D_DESC texture2d_desc
;
3733 D3D11_SUBRESOURCE_DATA data
= {0};
3734 ULONG refcount
, expected_refcount
;
3735 D3D11_BUFFER_DESC buffer_desc
;
3736 ID3D11RenderTargetView
*rtview
;
3737 ID3D11Device
*device
, *tmp
;
3738 ID3D11Texture3D
*texture3d
;
3739 ID3D11Texture2D
*texture2d
;
3740 ID3D11Resource
*texture
;
3741 ID3D11Buffer
*buffer
;
3745 #define FMT_UNKNOWN DXGI_FORMAT_UNKNOWN
3746 #define RGBA8_UNORM DXGI_FORMAT_R8G8B8A8_UNORM
3747 #define RGBA8_TL DXGI_FORMAT_R8G8B8A8_TYPELESS
3748 #define DIM_UNKNOWN D3D11_RTV_DIMENSION_UNKNOWN
3749 #define TEX_1D D3D11_RTV_DIMENSION_TEXTURE1D
3750 #define TEX_1D_ARRAY D3D11_RTV_DIMENSION_TEXTURE1DARRAY
3751 #define TEX_2D D3D11_RTV_DIMENSION_TEXTURE2D
3752 #define TEX_2D_ARRAY D3D11_RTV_DIMENSION_TEXTURE2DARRAY
3753 #define TEX_2DMS D3D11_RTV_DIMENSION_TEXTURE2DMS
3754 #define TEX_2DMS_ARR D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY
3755 #define TEX_3D D3D11_RTV_DIMENSION_TEXTURE3D
3760 unsigned int miplevel_count
;
3761 unsigned int depth_or_array_size
;
3764 struct rtv_desc rtv_desc
;
3765 struct rtv_desc expected_rtv_desc
;
3769 {{ 1, 1, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D
, 0}},
3770 {{10, 1, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D
, 0}},
3771 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D
, 0}, {RGBA8_UNORM
, TEX_2D
, 0}},
3772 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D
, 1}, {RGBA8_UNORM
, TEX_2D
, 1}},
3773 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D
, 9}, {RGBA8_UNORM
, TEX_2D
, 9}},
3774 {{ 1, 1, RGBA8_TL
}, {RGBA8_UNORM
, TEX_2D
, 0}, {RGBA8_UNORM
, TEX_2D
, 0}},
3775 {{10, 1, RGBA8_TL
}, {RGBA8_UNORM
, TEX_2D
, 0}, {RGBA8_UNORM
, TEX_2D
, 0}},
3776 {{ 1, 4, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 4}},
3777 {{10, 4, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 4}},
3778 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 4}},
3779 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 1, 0, 4}},
3780 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 3, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 3, 0, 4}},
3781 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 5, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 5, 0, 4}},
3782 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 9, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 9, 0, 4}},
3783 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 1, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 3}},
3784 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 2, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 2, 2}},
3785 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 3, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 3, 1}},
3786 {{ 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS
}, {RGBA8_UNORM
, TEX_2DMS
}},
3787 {{ 1, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS
}, {RGBA8_UNORM
, TEX_2DMS
}},
3788 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS
}, {RGBA8_UNORM
, TEX_2DMS
}},
3789 {{ 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 1}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 1}},
3790 {{ 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 1}},
3791 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 1}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 1}},
3792 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 1}},
3793 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 1}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 1}},
3794 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 4}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 4}},
3795 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 4}},
3796 {{ 1, 6, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 6}},
3797 {{ 2, 6, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 6}},
3798 {{ 2, 6, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 6}},
3799 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 2}},
3800 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 2}},
3801 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 1, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 1, 3}},
3802 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 2, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 2, 2}},
3803 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 3, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 3, 1}},
3804 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 1, 1}, {RGBA8_UNORM
, TEX_3D
, 0, 1, 1}},
3805 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 1, 1}, {RGBA8_UNORM
, TEX_3D
, 1, 1, 1}},
3806 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 1, ~0u}, {RGBA8_UNORM
, TEX_3D
, 1, 1, 1}},
3807 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 8}},
3808 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 4}},
3809 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 2, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 2, 0, 2}},
3810 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 3, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 3, 0, 1}},
3811 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 4, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 4, 0, 1}},
3812 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 5, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 5, 0, 1}},
3818 D3D11_RTV_DIMENSION dimension
;
3819 unsigned int miplevel_count
;
3820 unsigned int depth_or_array_size
;
3823 struct rtv_desc rtv_desc
;
3825 invalid_desc_tests
[] =
3827 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, DIM_UNKNOWN
}},
3828 {{TEX_2D
, 6, 4, RGBA8_UNORM
}, {RGBA8_UNORM
, DIM_UNKNOWN
}},
3829 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0}},
3830 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 0, 1}},
3831 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 1}},
3832 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, ~0u}},
3833 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_2D
, 0}},
3834 {{TEX_2D
, 1, 1, RGBA8_TL
}, {FMT_UNKNOWN
, TEX_2D
, 0}},
3835 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 1}},
3836 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 0}},
3837 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 1, 0, 1}},
3838 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 2}},
3839 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 1}},
3840 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 2}},
3841 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 1}},
3842 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0}},
3843 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 0, 1}},
3844 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0}},
3845 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 1}},
3846 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0}},
3847 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 0, 1}},
3848 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0}},
3849 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 1}},
3850 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 0}},
3851 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 1}},
3852 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_3D
, 0, 0, 1}},
3853 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_TL
, TEX_3D
, 0, 0, 1}},
3854 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 9}},
3855 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 3, 0, 2}},
3856 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 2, 0, 4}},
3857 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 8}},
3858 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 8, ~0u}},
3859 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 4, ~0u}},
3860 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 2, 2, ~0u}},
3861 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 3, 1, ~0u}},
3875 if (!(device
= create_device(NULL
)))
3877 skip("Failed to create device.\n");
3881 buffer_desc
.ByteWidth
= 1024;
3882 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
3883 buffer_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
3884 buffer_desc
.CPUAccessFlags
= 0;
3885 buffer_desc
.MiscFlags
= 0;
3886 buffer_desc
.StructureByteStride
= 0;
3888 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &data
, &buffer
);
3889 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
3891 expected_refcount
= get_refcount(device
) + 1;
3892 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
3893 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
3894 refcount
= get_refcount(device
);
3895 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
3897 expected_refcount
= refcount
+ 1;
3898 ID3D11Buffer_GetDevice(buffer
, &tmp
);
3899 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
3900 refcount
= get_refcount(device
);
3901 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
3902 ID3D11Device_Release(tmp
);
3904 rtv_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
3905 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_BUFFER
;
3906 U1(U(rtv_desc
).Buffer
).ElementOffset
= 0;
3907 U2(U(rtv_desc
).Buffer
).ElementWidth
= 64;
3909 if (!enable_debug_layer
)
3911 hr
= ID3D11Device_CreateRenderTargetView(device
, NULL
, &rtv_desc
, &rtview
);
3912 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
3915 expected_refcount
= get_refcount(device
) + 1;
3916 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)buffer
, &rtv_desc
, &rtview
);
3917 ok(SUCCEEDED(hr
), "Failed to create a rendertarget view, hr %#x.\n", hr
);
3918 refcount
= get_refcount(device
);
3919 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
3921 expected_refcount
= refcount
+ 1;
3922 ID3D11RenderTargetView_GetDevice(rtview
, &tmp
);
3923 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
3924 refcount
= get_refcount(device
);
3925 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
3926 ID3D11Device_Release(tmp
);
3928 /* Not available on all Windows versions. */
3929 check_interface(rtview
, &IID_ID3D10RenderTargetView
, TRUE
, TRUE
);
3931 ID3D11RenderTargetView_Release(rtview
);
3932 ID3D11Buffer_Release(buffer
);
3934 texture2d_desc
.Width
= 512;
3935 texture2d_desc
.Height
= 512;
3936 texture2d_desc
.SampleDesc
.Count
= 1;
3937 texture2d_desc
.SampleDesc
.Quality
= 0;
3938 texture2d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
3939 texture2d_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
3940 texture2d_desc
.CPUAccessFlags
= 0;
3941 texture2d_desc
.MiscFlags
= 0;
3943 texture3d_desc
.Width
= 64;
3944 texture3d_desc
.Height
= 64;
3945 texture3d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
3946 texture3d_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
3947 texture3d_desc
.CPUAccessFlags
= 0;
3948 texture3d_desc
.MiscFlags
= 0;
3950 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
3952 D3D11_RENDER_TARGET_VIEW_DESC
*current_desc
;
3954 if (tests
[i
].expected_rtv_desc
.dimension
!= D3D11_RTV_DIMENSION_TEXTURE3D
)
3956 texture2d_desc
.MipLevels
= tests
[i
].texture
.miplevel_count
;
3957 texture2d_desc
.ArraySize
= tests
[i
].texture
.depth_or_array_size
;
3958 texture2d_desc
.Format
= tests
[i
].texture
.format
;
3960 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, &texture2d
);
3961 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
3962 texture
= (ID3D11Resource
*)texture2d
;
3966 texture3d_desc
.MipLevels
= tests
[i
].texture
.miplevel_count
;
3967 texture3d_desc
.Depth
= tests
[i
].texture
.depth_or_array_size
;
3968 texture3d_desc
.Format
= tests
[i
].texture
.format
;
3970 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &texture3d
);
3971 ok(SUCCEEDED(hr
), "Test %u: Failed to create 3d texture, hr %#x.\n", i
, hr
);
3972 texture
= (ID3D11Resource
*)texture3d
;
3975 if (tests
[i
].rtv_desc
.dimension
== D3D11_RTV_DIMENSION_UNKNOWN
)
3977 current_desc
= NULL
;
3981 current_desc
= &rtv_desc
;
3982 get_rtv_desc(current_desc
, &tests
[i
].rtv_desc
);
3985 expected_refcount
= get_refcount(texture
);
3986 hr
= ID3D11Device_CreateRenderTargetView(device
, texture
, current_desc
, &rtview
);
3987 ok(SUCCEEDED(hr
), "Test %u: Failed to create render target view, hr %#x.\n", i
, hr
);
3988 refcount
= get_refcount(texture
);
3989 ok(refcount
== expected_refcount
, "Got refcount %u, expected %u.\n", refcount
, expected_refcount
);
3991 /* Not available on all Windows versions. */
3992 check_interface(rtview
, &IID_ID3D10RenderTargetView
, TRUE
, TRUE
);
3994 memset(&rtv_desc
, 0, sizeof(rtv_desc
));
3995 ID3D11RenderTargetView_GetDesc(rtview
, &rtv_desc
);
3996 check_rtv_desc(&rtv_desc
, &tests
[i
].expected_rtv_desc
);
3998 ID3D11RenderTargetView_Release(rtview
);
3999 ID3D11Resource_Release(texture
);
4002 for (i
= 0; i
< ARRAY_SIZE(invalid_desc_tests
); ++i
)
4004 assert(invalid_desc_tests
[i
].texture
.dimension
== D3D11_RTV_DIMENSION_TEXTURE2D
4005 || invalid_desc_tests
[i
].texture
.dimension
== D3D11_RTV_DIMENSION_TEXTURE3D
);
4007 if (invalid_desc_tests
[i
].texture
.dimension
!= D3D11_RTV_DIMENSION_TEXTURE3D
)
4009 texture2d_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
4010 texture2d_desc
.ArraySize
= invalid_desc_tests
[i
].texture
.depth_or_array_size
;
4011 texture2d_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
4013 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, &texture2d
);
4014 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
4015 texture
= (ID3D11Resource
*)texture2d
;
4019 texture3d_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
4020 texture3d_desc
.Depth
= invalid_desc_tests
[i
].texture
.depth_or_array_size
;
4021 texture3d_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
4023 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &texture3d
);
4024 ok(SUCCEEDED(hr
), "Test %u: Failed to create 3d texture, hr %#x.\n", i
, hr
);
4025 texture
= (ID3D11Resource
*)texture3d
;
4028 get_rtv_desc(&rtv_desc
, &invalid_desc_tests
[i
].rtv_desc
);
4029 hr
= ID3D11Device_CreateRenderTargetView(device
, texture
, &rtv_desc
, &rtview
);
4030 ok(hr
== E_INVALIDARG
, "Test %u: Got unexpected hr %#x.\n", i
, hr
);
4032 ID3D11Resource_Release(texture
);
4035 refcount
= ID3D11Device_Release(device
);
4036 ok(!refcount
, "Device has %u references left.\n", refcount
);
4039 static void test_create_shader_resource_view(void)
4041 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
4042 D3D11_TEXTURE3D_DESC texture3d_desc
;
4043 D3D11_TEXTURE2D_DESC texture2d_desc
;
4044 ULONG refcount
, expected_refcount
;
4045 ID3D11ShaderResourceView
*srview
;
4046 D3D_FEATURE_LEVEL feature_level
;
4047 D3D11_BUFFER_DESC buffer_desc
;
4048 ID3D11Device
*device
, *tmp
;
4049 ID3D11Texture3D
*texture3d
;
4050 ID3D11Texture2D
*texture2d
;
4051 ID3D11Resource
*texture
;
4052 ID3D11Buffer
*buffer
;
4056 #define FMT_UNKNOWN DXGI_FORMAT_UNKNOWN
4057 #define RGBA8_UNORM DXGI_FORMAT_R8G8B8A8_UNORM
4058 #define RGBA8_SRGB DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
4059 #define RGBA8_UINT DXGI_FORMAT_R8G8B8A8_UINT
4060 #define RGBA8_TL DXGI_FORMAT_R8G8B8A8_TYPELESS
4061 #define DIM_UNKNOWN D3D11_SRV_DIMENSION_UNKNOWN
4062 #define TEX_1D D3D11_SRV_DIMENSION_TEXTURE1D
4063 #define TEX_1D_ARRAY D3D11_SRV_DIMENSION_TEXTURE1DARRAY
4064 #define TEX_2D D3D11_SRV_DIMENSION_TEXTURE2D
4065 #define TEX_2D_ARRAY D3D11_SRV_DIMENSION_TEXTURE2DARRAY
4066 #define TEX_2DMS D3D11_SRV_DIMENSION_TEXTURE2DMS
4067 #define TEX_2DMS_ARR D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY
4068 #define TEX_3D D3D11_SRV_DIMENSION_TEXTURE3D
4069 #define TEX_CUBE D3D11_SRV_DIMENSION_TEXTURECUBE
4070 #define CUBE_ARRAY D3D11_SRV_DIMENSION_TEXTURECUBEARRAY
4075 unsigned int miplevel_count
;
4076 unsigned int depth_or_array_size
;
4079 struct srv_desc srv_desc
;
4080 struct srv_desc expected_srv_desc
;
4084 {{10, 1, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D
, 0, 10}},
4085 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D
, 0, ~0u}, {RGBA8_UNORM
, TEX_2D
, 0, 10}},
4086 {{10, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0, ~0u}, {RGBA8_UNORM
, TEX_2D
, 0, 10}},
4087 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D
, 0, 10}, {RGBA8_UNORM
, TEX_2D
, 0, 10}},
4088 {{ 1, 1, RGBA8_TL
}, {RGBA8_UNORM
, TEX_2D
, 0, ~0u}, {RGBA8_UNORM
, TEX_2D
, 0, 1}},
4089 {{10, 1, RGBA8_TL
}, {RGBA8_UNORM
, TEX_2D
, 0, ~0u}, {RGBA8_UNORM
, TEX_2D
, 0, 10}},
4090 {{10, 4, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 10, 0, 4}},
4091 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, ~0u, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 10, 0, 4}},
4092 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 1, ~0u, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 1, 9, 0, 4}},
4093 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 3, ~0u, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 3, 7, 0, 4}},
4094 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 5, ~0u, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 5, 5, 0, 4}},
4095 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 9, ~0u, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 9, 1, 0, 4}},
4096 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, ~0u, 1, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 10, 1, 3}},
4097 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, ~0u, 2, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 10, 2, 2}},
4098 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, ~0u, 3, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 10, 3, 1}},
4099 {{ 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS
}, {RGBA8_UNORM
, TEX_2DMS
}},
4100 {{ 1, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS
}, {RGBA8_UNORM
, TEX_2DMS
}},
4101 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS
}, {RGBA8_UNORM
, TEX_2DMS
}},
4102 {{ 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 1, 0, 1}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 1}},
4103 {{ 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 1}},
4104 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 1, 0, 1}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 1}},
4105 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 1}},
4106 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 1, 0, 1}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 1}},
4107 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 1, 0, 4}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 4}},
4108 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 4}},
4109 {{ 1, 12, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_3D
, 0, 1}},
4110 {{ 1, 12, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 1}, {RGBA8_UNORM
, TEX_3D
, 0, 1}},
4111 {{ 1, 12, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 1}},
4112 {{ 4, 12, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 4}},
4113 {{ 1, 6, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_CUBE
, 0, 1}},
4114 {{ 2, 6, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_CUBE
, 0, 2}},
4115 {{ 2, 9, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_CUBE
, 0, 2}},
4116 {{ 2, 11, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_CUBE
, 0, 2}},
4117 {{ 2, 6, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_CUBE
, 0, ~0u}, {RGBA8_UNORM
, TEX_CUBE
, 0, 2}},
4118 {{ 2, 6, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_CUBE
, 0, 1}, {RGBA8_UNORM
, TEX_CUBE
, 0, 1}},
4119 {{ 2, 6, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_CUBE
, 1, 1}, {RGBA8_UNORM
, TEX_CUBE
, 1, 1}},
4120 {{ 2, 6, RGBA8_UNORM
}, {FMT_UNKNOWN
, CUBE_ARRAY
, 0, 1, 0, 1}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 1}},
4121 {{ 2, 6, RGBA8_UNORM
}, {FMT_UNKNOWN
, CUBE_ARRAY
, 0, ~0u, 0, ~0u}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 2, 0, 1}},
4122 {{ 1, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, CUBE_ARRAY
, 0, ~0u, 0, ~0u}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 1}},
4123 {{ 1, 12, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 2}},
4124 {{ 1, 12, RGBA8_UNORM
}, {FMT_UNKNOWN
, CUBE_ARRAY
, 0, ~0u, 0, ~0u}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 2}},
4125 {{ 1, 12, RGBA8_UNORM
}, {FMT_UNKNOWN
, CUBE_ARRAY
, 0, ~0u, 0, 1}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 1}},
4126 {{ 1, 12, RGBA8_UNORM
}, {FMT_UNKNOWN
, CUBE_ARRAY
, 0, ~0u, 0, 2}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 2}},
4127 {{ 1, 13, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 2}},
4128 {{ 1, 14, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 2}},
4129 {{ 1, 18, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 3}},
4130 {{ 1, 1, RGBA8_UINT
}, {0}, {RGBA8_UINT
, TEX_2D
, 0, 1, 0, 1}},
4131 {{ 1, 1, RGBA8_TL
}, {RGBA8_UINT
, TEX_2D
, 0, ~0u}, {RGBA8_UINT
, TEX_2D
, 0, 1, 0, 1}},
4137 D3D11_SRV_DIMENSION dimension
;
4138 unsigned int miplevel_count
;
4139 unsigned int depth_or_array_size
;
4142 struct srv_desc srv_desc
;
4144 invalid_desc_tests
[] =
4146 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, DIM_UNKNOWN
}},
4147 {{TEX_2D
, 6, 4, RGBA8_UNORM
}, {RGBA8_UNORM
, DIM_UNKNOWN
}},
4148 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0, 1}},
4149 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 1, 0, 1}},
4150 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 1}},
4151 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_2D
, 0, ~0u}},
4152 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_2D
, 0, 1}},
4153 {{TEX_2D
, 1, 1, RGBA8_TL
}, {FMT_UNKNOWN
, TEX_2D
, 0, ~0u}},
4154 {{TEX_2D
, 1, 1, RGBA8_TL
}, {FMT_UNKNOWN
, TEX_2D
, 0, 1}},
4155 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0, 0}},
4156 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0, 2}},
4157 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 1, 1}},
4158 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 0, 0}},
4159 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 0, 1}},
4160 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 0, 0}},
4161 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 2, 0, 1}},
4162 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 1, 1, 0, 1}},
4163 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 0, 2}},
4164 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 1, 1}},
4165 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 2}},
4166 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 1, 1}},
4167 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_CUBE
, 0, 0}},
4168 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_CUBE
, 0, 2}},
4169 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_CUBE
, 1, 1}},
4170 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 0, 0, 0}},
4171 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 0, 0, 1}},
4172 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 0}},
4173 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 0}},
4174 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 2, 0, 1}},
4175 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 1, 1, 0, 1}},
4176 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 1, 1}},
4177 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 1, ~0u}},
4178 {{TEX_2D
, 1, 7, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 2, 1}},
4179 {{TEX_2D
, 1, 7, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 2, ~0u}},
4180 {{TEX_2D
, 1, 7, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 2}},
4181 {{TEX_2D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 2}},
4182 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UINT
, TEX_2D
, 0, 1}},
4183 {{TEX_2D
, 1, 1, RGBA8_UINT
}, {RGBA8_UNORM
, TEX_2D
, 0, 1}},
4184 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_SRGB
, TEX_2D
, 0, 1}},
4185 {{TEX_2D
, 1, 1, RGBA8_SRGB
}, {RGBA8_UNORM
, TEX_2D
, 0, 1}},
4186 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0, 1}},
4187 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 1, 0, 1}},
4188 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0, 1}},
4189 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_CUBE
, 0, 1}},
4190 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 0, 1}},
4191 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0, 1}},
4192 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 1, 0, 1}},
4193 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0, 1}},
4194 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_CUBE
, 0, 1}},
4195 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 0, 1}},
4196 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0}},
4197 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_3D
, 0, 1}},
4198 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 2}},
4199 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 1}},
4200 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 2}},
4201 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 1}},
4219 if (!(device
= create_device(NULL
)))
4221 skip("Failed to create device.\n");
4224 feature_level
= ID3D11Device_GetFeatureLevel(device
);
4226 buffer
= create_buffer(device
, D3D11_BIND_SHADER_RESOURCE
, 1024, NULL
);
4228 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)buffer
, NULL
, &srview
);
4229 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
4231 srv_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
4232 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_BUFFER
;
4233 U1(U(srv_desc
).Buffer
).ElementOffset
= 0;
4234 U2(U(srv_desc
).Buffer
).ElementWidth
= 64;
4236 hr
= ID3D11Device_CreateShaderResourceView(device
, NULL
, &srv_desc
, &srview
);
4237 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
4239 expected_refcount
= get_refcount(device
) + 1;
4240 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)buffer
, &srv_desc
, &srview
);
4241 ok(SUCCEEDED(hr
), "Failed to create a shader resource view, hr %#x.\n", hr
);
4242 refcount
= get_refcount(device
);
4243 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
4245 expected_refcount
= refcount
+ 1;
4246 ID3D11ShaderResourceView_GetDevice(srview
, &tmp
);
4247 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
4248 refcount
= get_refcount(device
);
4249 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
4250 ID3D11Device_Release(tmp
);
4252 /* Not available on all Windows versions. */
4253 check_interface(srview
, &IID_ID3D10ShaderResourceView
, TRUE
, TRUE
);
4254 check_interface(srview
, &IID_ID3D10ShaderResourceView1
, TRUE
, TRUE
);
4256 ID3D11ShaderResourceView_Release(srview
);
4257 ID3D11Buffer_Release(buffer
);
4259 /* Without D3D11_BIND_SHADER_RESOURCE. */
4260 buffer
= create_buffer(device
, 0, 1024, NULL
);
4262 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)buffer
, &srv_desc
, &srview
);
4263 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
4265 ID3D11Buffer_Release(buffer
);
4267 if (feature_level
>= D3D_FEATURE_LEVEL_11_0
)
4269 buffer_desc
.ByteWidth
= 1024;
4270 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
4271 buffer_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
4272 buffer_desc
.CPUAccessFlags
= 0;
4273 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
;
4274 buffer_desc
.StructureByteStride
= 4;
4276 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
4277 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
4279 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)buffer
, NULL
, &srview
);
4280 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
4282 memset(&srv_desc
, 0, sizeof(srv_desc
));
4283 ID3D11ShaderResourceView_GetDesc(srview
, &srv_desc
);
4285 ok(srv_desc
.Format
== DXGI_FORMAT_UNKNOWN
, "Got unexpected format %#x.\n", srv_desc
.Format
);
4286 ok(srv_desc
.ViewDimension
== D3D11_SRV_DIMENSION_BUFFER
, "Got unexpected view dimension %#x.\n",
4287 srv_desc
.ViewDimension
);
4288 ok(!U1(U(srv_desc
).Buffer
).FirstElement
, "Got unexpected first element %u.\n",
4289 U1(U(srv_desc
).Buffer
).FirstElement
);
4290 ok(U2(U(srv_desc
).Buffer
).NumElements
== 256, "Got unexpected num elements %u.\n",
4291 U2(U(srv_desc
).Buffer
).NumElements
);
4293 ID3D11ShaderResourceView_Release(srview
);
4294 ID3D11Buffer_Release(buffer
);
4298 skip("Structured buffers require feature level 11_0.\n");
4301 texture2d_desc
.Width
= 512;
4302 texture2d_desc
.Height
= 512;
4303 texture2d_desc
.SampleDesc
.Count
= 1;
4304 texture2d_desc
.SampleDesc
.Quality
= 0;
4305 texture2d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
4306 texture2d_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
4307 texture2d_desc
.CPUAccessFlags
= 0;
4309 texture3d_desc
.Width
= 64;
4310 texture3d_desc
.Height
= 64;
4311 texture3d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
4312 texture3d_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
4313 texture3d_desc
.CPUAccessFlags
= 0;
4314 texture3d_desc
.MiscFlags
= 0;
4316 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
4318 D3D11_SHADER_RESOURCE_VIEW_DESC
*current_desc
;
4320 if (tests
[i
].expected_srv_desc
.dimension
!= D3D11_SRV_DIMENSION_TEXTURE3D
)
4322 texture2d_desc
.MipLevels
= tests
[i
].texture
.miplevel_count
;
4323 texture2d_desc
.ArraySize
= tests
[i
].texture
.depth_or_array_size
;
4324 texture2d_desc
.Format
= tests
[i
].texture
.format
;
4325 texture2d_desc
.MiscFlags
= 0;
4327 if (tests
[i
].expected_srv_desc
.dimension
== D3D11_SRV_DIMENSION_TEXTURECUBE
4328 || tests
[i
].expected_srv_desc
.dimension
== D3D11_SRV_DIMENSION_TEXTURECUBEARRAY
)
4329 texture2d_desc
.MiscFlags
|= D3D11_RESOURCE_MISC_TEXTURECUBE
;
4331 if (texture2d_desc
.MiscFlags
& D3D11_RESOURCE_MISC_TEXTURECUBE
4332 && (texture2d_desc
.ArraySize
!= 6
4333 || tests
[i
].expected_srv_desc
.dimension
== D3D11_SRV_DIMENSION_TEXTURECUBEARRAY
)
4334 && feature_level
< D3D_FEATURE_LEVEL_10_1
)
4336 skip("Test %u: Cube map array textures require feature level 10_1.\n", i
);
4340 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, &texture2d
);
4341 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
4342 texture
= (ID3D11Resource
*)texture2d
;
4346 texture3d_desc
.MipLevels
= tests
[i
].texture
.miplevel_count
;
4347 texture3d_desc
.Depth
= tests
[i
].texture
.depth_or_array_size
;
4348 texture3d_desc
.Format
= tests
[i
].texture
.format
;
4350 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &texture3d
);
4351 ok(SUCCEEDED(hr
), "Test %u: Failed to create 3d texture, hr %#x.\n", i
, hr
);
4352 texture
= (ID3D11Resource
*)texture3d
;
4355 if (tests
[i
].srv_desc
.dimension
== D3D11_SRV_DIMENSION_UNKNOWN
)
4357 current_desc
= NULL
;
4361 current_desc
= &srv_desc
;
4362 get_srv_desc(current_desc
, &tests
[i
].srv_desc
);
4365 expected_refcount
= get_refcount(texture
);
4366 hr
= ID3D11Device_CreateShaderResourceView(device
, texture
, current_desc
, &srview
);
4367 ok(SUCCEEDED(hr
), "Test %u: Failed to create a shader resource view, hr %#x.\n", i
, hr
);
4368 refcount
= get_refcount(texture
);
4369 ok(refcount
== expected_refcount
, "Got refcount %u, expected %u.\n", refcount
, expected_refcount
);
4371 /* Not available on all Windows versions. */
4372 check_interface(srview
, &IID_ID3D10ShaderResourceView
, TRUE
, TRUE
);
4373 check_interface(srview
, &IID_ID3D10ShaderResourceView1
, TRUE
, TRUE
);
4375 memset(&srv_desc
, 0, sizeof(srv_desc
));
4376 ID3D11ShaderResourceView_GetDesc(srview
, &srv_desc
);
4377 check_srv_desc(&srv_desc
, &tests
[i
].expected_srv_desc
);
4379 ID3D11ShaderResourceView_Release(srview
);
4380 ID3D11Resource_Release(texture
);
4383 for (i
= 0; i
< ARRAY_SIZE(invalid_desc_tests
); ++i
)
4385 assert(invalid_desc_tests
[i
].texture
.dimension
== D3D11_SRV_DIMENSION_TEXTURE2D
4386 || invalid_desc_tests
[i
].texture
.dimension
== D3D11_SRV_DIMENSION_TEXTURE3D
);
4388 if (invalid_desc_tests
[i
].texture
.dimension
== D3D11_SRV_DIMENSION_TEXTURE2D
)
4390 texture2d_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
4391 texture2d_desc
.ArraySize
= invalid_desc_tests
[i
].texture
.depth_or_array_size
;
4392 texture2d_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
4393 texture2d_desc
.MiscFlags
= 0;
4395 if (invalid_desc_tests
[i
].srv_desc
.dimension
== D3D11_SRV_DIMENSION_TEXTURECUBE
4396 || invalid_desc_tests
[i
].srv_desc
.dimension
== D3D11_SRV_DIMENSION_TEXTURECUBEARRAY
)
4397 texture2d_desc
.MiscFlags
|= D3D11_RESOURCE_MISC_TEXTURECUBE
;
4399 if (invalid_desc_tests
[i
].srv_desc
.dimension
== D3D11_SRV_DIMENSION_TEXTURECUBEARRAY
4400 && feature_level
< D3D_FEATURE_LEVEL_10_1
)
4402 skip("Test %u: Cube map array textures require feature level 10_1.\n", i
);
4406 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, &texture2d
);
4407 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
4408 texture
= (ID3D11Resource
*)texture2d
;
4412 texture3d_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
4413 texture3d_desc
.Depth
= invalid_desc_tests
[i
].texture
.depth_or_array_size
;
4414 texture3d_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
4416 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &texture3d
);
4417 ok(SUCCEEDED(hr
), "Test %u: Failed to create 3d texture, hr %#x.\n", i
, hr
);
4418 texture
= (ID3D11Resource
*)texture3d
;
4421 get_srv_desc(&srv_desc
, &invalid_desc_tests
[i
].srv_desc
);
4422 hr
= ID3D11Device_CreateShaderResourceView(device
, texture
, &srv_desc
, &srview
);
4423 ok(hr
== E_INVALIDARG
, "Test %u: Got unexpected hr %#x.\n", i
, hr
);
4425 ID3D11Resource_Release(texture
);
4428 refcount
= ID3D11Device_Release(device
);
4429 ok(!refcount
, "Device has %u references left.\n", refcount
);
4432 static void test_create_shader(const D3D_FEATURE_LEVEL feature_level
)
4440 float4 position
: POSITION
;
4441 float3 normal
: NORMAL
;
4446 float4 position
: POSITION
;
4447 float4 diffuse
: COLOR
;
4450 output
main(const input v
)
4454 o
.position
= mul(v
.position
, mat
);
4455 o
.diffuse
= dot((float3
)light
, v
.normal
);
4460 static const DWORD vs_4_1
[] =
4462 0x43425844, 0xfce5b27c, 0x965db93d, 0x8c3d0459, 0x9890ebac, 0x00000001, 0x000001c4, 0x00000003,
4463 0x0000002c, 0x0000007c, 0x000000cc, 0x4e475349, 0x00000048, 0x00000002, 0x00000008, 0x00000038,
4464 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
4465 0x00000003, 0x00000001, 0x00000707, 0x49534f50, 0x4e4f4954, 0x524f4e00, 0x004c414d, 0x4e47534f,
4466 0x00000048, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
4467 0x0000000f, 0x00000041, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x49534f50,
4468 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x52444853, 0x000000f0, 0x00010041, 0x0000003c, 0x0100086a,
4469 0x04000059, 0x00208e46, 0x00000000, 0x00000005, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f,
4470 0x00101072, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000001,
4471 0x08000011, 0x00102012, 0x00000000, 0x00101e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000001,
4472 0x08000011, 0x00102022, 0x00000000, 0x00101e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000002,
4473 0x08000011, 0x00102042, 0x00000000, 0x00101e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000003,
4474 0x08000011, 0x00102082, 0x00000000, 0x00101e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000004,
4475 0x08000010, 0x001020f2, 0x00000001, 0x00208246, 0x00000000, 0x00000000, 0x00101246, 0x00000001,
4478 static const DWORD vs_4_0
[] =
4480 0x43425844, 0x3ae813ca, 0x0f034b91, 0x790f3226, 0x6b4a718a, 0x00000001, 0x000001c0,
4481 0x00000003, 0x0000002c, 0x0000007c, 0x000000cc, 0x4e475349, 0x00000048, 0x00000002,
4482 0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f,
4483 0x00000041, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000707, 0x49534f50,
4484 0x4e4f4954, 0x524f4e00, 0x004c414d, 0x4e47534f, 0x00000048, 0x00000002, 0x00000008,
4485 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x00000041,
4486 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x49534f50, 0x4e4f4954,
4487 0x4c4f4300, 0xab00524f, 0x52444853, 0x000000ec, 0x00010040, 0x0000003b, 0x04000059,
4488 0x00208e46, 0x00000000, 0x00000005, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f,
4489 0x00101072, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x001020f2,
4490 0x00000001, 0x08000011, 0x00102012, 0x00000000, 0x00101e46, 0x00000000, 0x00208e46,
4491 0x00000000, 0x00000001, 0x08000011, 0x00102022, 0x00000000, 0x00101e46, 0x00000000,
4492 0x00208e46, 0x00000000, 0x00000002, 0x08000011, 0x00102042, 0x00000000, 0x00101e46,
4493 0x00000000, 0x00208e46, 0x00000000, 0x00000003, 0x08000011, 0x00102082, 0x00000000,
4494 0x00101e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x08000010, 0x001020f2,
4495 0x00000001, 0x00208246, 0x00000000, 0x00000000, 0x00101246, 0x00000001, 0x0100003e,
4497 static const DWORD vs_3_0
[] =
4499 0xfffe0300, 0x002bfffe, 0x42415443, 0x0000001c, 0x00000077, 0xfffe0300, 0x00000002,
4500 0x0000001c, 0x00000100, 0x00000070, 0x00000044, 0x00040002, 0x00000001, 0x0000004c,
4501 0x00000000, 0x0000005c, 0x00000002, 0x00000004, 0x00000060, 0x00000000, 0x6867696c,
4502 0xabab0074, 0x00030001, 0x00040001, 0x00000001, 0x00000000, 0x0074616d, 0x00030003,
4503 0x00040004, 0x00000001, 0x00000000, 0x335f7376, 0x4d00305f, 0x6f726369, 0x74666f73,
4504 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e392072,
4505 0x392e3932, 0x332e3235, 0x00313131, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f,
4506 0x80000003, 0x900f0001, 0x0200001f, 0x80000000, 0xe00f0000, 0x0200001f, 0x8000000a,
4507 0xe00f0001, 0x03000009, 0xe0010000, 0x90e40000, 0xa0e40000, 0x03000009, 0xe0020000,
4508 0x90e40000, 0xa0e40001, 0x03000009, 0xe0040000, 0x90e40000, 0xa0e40002, 0x03000009,
4509 0xe0080000, 0x90e40000, 0xa0e40003, 0x03000008, 0xe00f0001, 0xa0e40004, 0x90e40001,
4512 static const DWORD vs_2_0
[] =
4514 0xfffe0200, 0x002bfffe, 0x42415443, 0x0000001c, 0x00000077, 0xfffe0200, 0x00000002,
4515 0x0000001c, 0x00000100, 0x00000070, 0x00000044, 0x00040002, 0x00000001, 0x0000004c,
4516 0x00000000, 0x0000005c, 0x00000002, 0x00000004, 0x00000060, 0x00000000, 0x6867696c,
4517 0xabab0074, 0x00030001, 0x00040001, 0x00000001, 0x00000000, 0x0074616d, 0x00030003,
4518 0x00040004, 0x00000001, 0x00000000, 0x325f7376, 0x4d00305f, 0x6f726369, 0x74666f73,
4519 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e392072,
4520 0x392e3932, 0x332e3235, 0x00313131, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f,
4521 0x80000003, 0x900f0001, 0x03000009, 0xc0010000, 0x90e40000, 0xa0e40000, 0x03000009,
4522 0xc0020000, 0x90e40000, 0xa0e40001, 0x03000009, 0xc0040000, 0x90e40000, 0xa0e40002,
4523 0x03000009, 0xc0080000, 0x90e40000, 0xa0e40003, 0x03000008, 0xd00f0000, 0xa0e40004,
4524 0x90e40001, 0x0000ffff,
4528 float4
main(const float4 color
: COLOR
) : SV_TARGET
4537 static const DWORD ps_4_1
[] =
4539 0x43425844, 0xa1a44423, 0xa4cfcec2, 0x64610832, 0xb7a852bd, 0x00000001, 0x000000d4, 0x00000003,
4540 0x0000002c, 0x0000005c, 0x00000090, 0x4e475349, 0x00000028, 0x00000001, 0x00000008, 0x00000020,
4541 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x4f4c4f43, 0xabab0052, 0x4e47534f,
4542 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
4543 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x0000003c, 0x00000041, 0x0000000f,
4544 0x0100086a, 0x03001062, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
4545 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
4547 static const DWORD ps_4_0
[] =
4549 0x43425844, 0x08c2b568, 0x17d33120, 0xb7d82948, 0x13a570fb, 0x00000001, 0x000000d0, 0x00000003,
4550 0x0000002c, 0x0000005c, 0x00000090, 0x4e475349, 0x00000028, 0x00000001, 0x00000008, 0x00000020,
4551 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x4f4c4f43, 0xabab0052, 0x4e47534f,
4552 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
4553 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
4554 0x03001062, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x05000036, 0x001020f2,
4555 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
4557 static const DWORD ps_4_0_level_9_0
[] =
4559 0x43425844, 0xbc6626e7, 0x7778dc9d, 0xc8a43be2, 0xe4b53f7a, 0x00000001, 0x00000170,
4560 0x00000005, 0x00000034, 0x00000080, 0x000000cc, 0x0000010c, 0x0000013c, 0x53414e58,
4561 0x00000044, 0x00000044, 0xffff0200, 0x00000020, 0x00000024, 0x00240000, 0x00240000,
4562 0x00240000, 0x00240000, 0x00240000, 0xffff0200, 0x0200001f, 0x80000000, 0xb00f0000,
4563 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, 0x396e6f41, 0x00000044, 0x00000044,
4564 0xffff0200, 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000,
4565 0x00240000, 0xffff0200, 0x0200001f, 0x80000000, 0xb00f0000, 0x02000001, 0x800f0800,
4566 0xb0e40000, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040, 0x0000000e, 0x03001062,
4567 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x05000036, 0x001020f2,
4568 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x4e475349, 0x00000028, 0x00000001,
4569 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f,
4570 0x4f4c4f43, 0xabab0052, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
4571 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241,
4574 static const DWORD ps_4_0_level_9_1
[] =
4576 0x43425844, 0x275ecf38, 0x4349ff01, 0xa6b0e324, 0x6e54a4fc, 0x00000001, 0x00000120,
4577 0x00000004, 0x00000030, 0x0000007c, 0x000000bc, 0x000000ec, 0x396e6f41, 0x00000044,
4578 0x00000044, 0xffff0200, 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000,
4579 0x00240000, 0x00240000, 0xffff0200, 0x0200001f, 0x80000000, 0xb00f0000, 0x02000001,
4580 0x800f0800, 0xb0e40000, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
4581 0x03001062, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
4582 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x4e475349, 0x00000028,
4583 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
4584 0x00000f0f, 0x4f4c4f43, 0xabab0052, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008,
4585 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653,
4586 0x45475241, 0xabab0054,
4588 static const DWORD ps_4_0_level_9_3
[] =
4590 0x43425844, 0xc7d541c4, 0x961d4e0e, 0x9ce7ec57, 0x70f47dcb, 0x00000001, 0x00000120,
4591 0x00000004, 0x00000030, 0x0000007c, 0x000000bc, 0x000000ec, 0x396e6f41, 0x00000044,
4592 0x00000044, 0xffff0200, 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000,
4593 0x00240000, 0x00240000, 0xffff0201, 0x0200001f, 0x80000000, 0xb00f0000, 0x02000001,
4594 0x800f0800, 0xb0e40000, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
4595 0x03001062, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
4596 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x4e475349, 0x00000028,
4597 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
4598 0x00000f0f, 0x4f4c4f43, 0xabab0052, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008,
4599 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653,
4600 0x45475241, 0xabab0054,
4606 float4 pos
: SV_POSITION
;
4610 void main(point float4 vin
[1] : POSITION
, inout TriangleStream
<gs_out
> vout
)
4612 float offset
= 0.1 * vin
[0].w
;
4615 v
.pos
= float4(vin
[0].x
- offset
, vin
[0].y
- offset
, vin
[0].z
, vin
[0].w
);
4617 v
.pos
= float4(vin
[0].x
- offset
, vin
[0].y
+ offset
, vin
[0].z
, vin
[0].w
);
4619 v
.pos
= float4(vin
[0].x
+ offset
, vin
[0].y
- offset
, vin
[0].z
, vin
[0].w
);
4621 v
.pos
= float4(vin
[0].x
+ offset
, vin
[0].y
+ offset
, vin
[0].z
, vin
[0].w
);
4625 static const DWORD gs_4_1
[] =
4627 0x43425844, 0x779daaf5, 0x7e154197, 0xcf5e99da, 0xb502b4d2, 0x00000001, 0x00000240, 0x00000003,
4628 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
4629 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
4630 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
4631 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x000001a4, 0x00020041,
4632 0x00000069, 0x0100086a, 0x0400005f, 0x002010f2, 0x00000001, 0x00000000, 0x02000068, 0x00000001,
4633 0x0100085d, 0x0100285c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x0200005e, 0x00000004,
4634 0x0f000032, 0x00100032, 0x00000000, 0x80201ff6, 0x00000041, 0x00000000, 0x00000000, 0x00004002,
4635 0x3dcccccd, 0x3dcccccd, 0x00000000, 0x00000000, 0x00201046, 0x00000000, 0x00000000, 0x05000036,
4636 0x00102032, 0x00000000, 0x00100046, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6,
4637 0x00000000, 0x00000000, 0x01000013, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000,
4638 0x0e000032, 0x00100052, 0x00000000, 0x00201ff6, 0x00000000, 0x00000000, 0x00004002, 0x3dcccccd,
4639 0x00000000, 0x3dcccccd, 0x00000000, 0x00201106, 0x00000000, 0x00000000, 0x05000036, 0x00102022,
4640 0x00000000, 0x0010002a, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000,
4641 0x00000000, 0x01000013, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x05000036,
4642 0x00102022, 0x00000000, 0x0010001a, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6,
4643 0x00000000, 0x00000000, 0x01000013, 0x05000036, 0x00102032, 0x00000000, 0x00100086, 0x00000000,
4644 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000, 0x00000000, 0x01000013, 0x0100003e,
4646 static const DWORD gs_4_0
[] =
4648 0x43425844, 0x000ee786, 0xc624c269, 0x885a5cbe, 0x444b3b1f, 0x00000001, 0x0000023c, 0x00000003,
4649 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
4650 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
4651 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
4652 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x000001a0, 0x00020040,
4653 0x00000068, 0x0400005f, 0x002010f2, 0x00000001, 0x00000000, 0x02000068, 0x00000001, 0x0100085d,
4654 0x0100285c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x0200005e, 0x00000004, 0x0f000032,
4655 0x00100032, 0x00000000, 0x80201ff6, 0x00000041, 0x00000000, 0x00000000, 0x00004002, 0x3dcccccd,
4656 0x3dcccccd, 0x00000000, 0x00000000, 0x00201046, 0x00000000, 0x00000000, 0x05000036, 0x00102032,
4657 0x00000000, 0x00100046, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000,
4658 0x00000000, 0x01000013, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0e000032,
4659 0x00100052, 0x00000000, 0x00201ff6, 0x00000000, 0x00000000, 0x00004002, 0x3dcccccd, 0x00000000,
4660 0x3dcccccd, 0x00000000, 0x00201106, 0x00000000, 0x00000000, 0x05000036, 0x00102022, 0x00000000,
4661 0x0010002a, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000, 0x00000000,
4662 0x01000013, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x05000036, 0x00102022,
4663 0x00000000, 0x0010001a, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000,
4664 0x00000000, 0x01000013, 0x05000036, 0x00102032, 0x00000000, 0x00100086, 0x00000000, 0x06000036,
4665 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000, 0x00000000, 0x01000013, 0x0100003e,
4668 ULONG refcount
, expected_refcount
;
4669 struct device_desc device_desc
;
4670 ID3D11Device
*device
, *tmp
;
4671 ID3D11GeometryShader
*gs
;
4672 ID3D11VertexShader
*vs
;
4673 ID3D11PixelShader
*ps
;
4676 device_desc
.feature_level
= &feature_level
;
4677 device_desc
.flags
= 0;
4678 if (!(device
= create_device(&device_desc
)))
4680 skip("Failed to create device for feature level %#x.\n", feature_level
);
4684 /* level_9 shaders */
4685 hr
= ID3D11Device_CreatePixelShader(device
, ps_4_0_level_9_0
, sizeof(ps_4_0_level_9_0
), NULL
, &ps
);
4686 ok(SUCCEEDED(hr
), "Failed to create ps_4_0_level_9_0 shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4687 ID3D11PixelShader_Release(ps
);
4689 hr
= ID3D11Device_CreatePixelShader(device
, ps_4_0_level_9_1
, sizeof(ps_4_0_level_9_1
), NULL
, &ps
);
4690 ok(SUCCEEDED(hr
), "Failed to create ps_4_0_level_9_1 shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4691 ID3D11PixelShader_Release(ps
);
4693 hr
= ID3D11Device_CreatePixelShader(device
, ps_4_0_level_9_3
, sizeof(ps_4_0_level_9_3
), NULL
, &ps
);
4694 ok(SUCCEEDED(hr
), "Failed to create ps_4_0_level_9_3 shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4695 ID3D11PixelShader_Release(ps
);
4698 hr
= ID3D11Device_CreateVertexShader(device
, vs_2_0
, sizeof(vs_2_0
), NULL
, &vs
);
4699 ok(hr
== E_INVALIDARG
, "Created a SM2 vertex shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4701 hr
= ID3D11Device_CreateVertexShader(device
, vs_3_0
, sizeof(vs_3_0
), NULL
, &vs
);
4702 ok(hr
== E_INVALIDARG
, "Created a SM3 vertex shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4704 hr
= ID3D11Device_CreateVertexShader(device
, ps_4_0
, sizeof(ps_4_0
), NULL
, &vs
);
4705 ok(hr
== E_INVALIDARG
, "Created a SM4 vertex shader from a pixel shader source, hr %#x, feature level %#x.\n",
4708 expected_refcount
= get_refcount(device
) + (feature_level
>= D3D_FEATURE_LEVEL_10_0
);
4709 hr
= ID3D11Device_CreateVertexShader(device
, vs_4_0
, sizeof(vs_4_0
), NULL
, &vs
);
4710 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
4711 ok(SUCCEEDED(hr
), "Failed to create SM4 vertex shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4713 ok(hr
== E_INVALIDARG
, "Created a SM4 vertex shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4715 refcount
= get_refcount(device
);
4716 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n",
4717 refcount
, expected_refcount
);
4718 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
4721 expected_refcount
= refcount
+ 1;
4722 ID3D11VertexShader_GetDevice(vs
, &tmp
);
4723 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
4724 refcount
= get_refcount(device
);
4725 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n",
4726 refcount
, expected_refcount
);
4727 ID3D11Device_Release(tmp
);
4729 /* Not available on all Windows versions. */
4730 check_interface(vs
, &IID_ID3D10VertexShader
, TRUE
, TRUE
);
4732 refcount
= ID3D11VertexShader_Release(vs
);
4733 ok(!refcount
, "Vertex shader has %u references left.\n", refcount
);
4736 hr
= ID3D11Device_CreateVertexShader(device
, vs_4_1
, sizeof(vs_4_1
), NULL
, &vs
);
4737 if (feature_level
>= D3D_FEATURE_LEVEL_10_1
)
4739 ok(SUCCEEDED(hr
), "Failed to create SM4.1 vertex shader, hr %#x, feature level %#x.\n",
4741 refcount
= ID3D11VertexShader_Release(vs
);
4742 ok(!refcount
, "Vertex shader has %u references left.\n", refcount
);
4746 todo_wine_if(feature_level
>= D3D_FEATURE_LEVEL_10_0
)
4747 ok(hr
== E_INVALIDARG
, "Created a SM4.1 vertex shader, hr %#x, feature level %#x.\n",
4750 ID3D11VertexShader_Release(vs
);
4754 expected_refcount
= get_refcount(device
) + (feature_level
>= D3D_FEATURE_LEVEL_10_0
);
4755 hr
= ID3D11Device_CreatePixelShader(device
, ps_4_0
, sizeof(ps_4_0
), NULL
, &ps
);
4756 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
4757 ok(SUCCEEDED(hr
), "Failed to create SM4 pixel shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4759 ok(hr
== E_INVALIDARG
, "Created a SM4 pixel shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4761 refcount
= get_refcount(device
);
4762 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n",
4763 refcount
, expected_refcount
);
4764 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
4767 expected_refcount
= refcount
+ 1;
4768 ID3D11PixelShader_GetDevice(ps
, &tmp
);
4769 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
4770 refcount
= get_refcount(device
);
4771 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n",
4772 refcount
, expected_refcount
);
4773 ID3D11Device_Release(tmp
);
4775 /* Not available on all Windows versions. */
4776 check_interface(ps
, &IID_ID3D10PixelShader
, TRUE
, TRUE
);
4778 refcount
= ID3D11PixelShader_Release(ps
);
4779 ok(!refcount
, "Pixel shader has %u references left.\n", refcount
);
4782 hr
= ID3D11Device_CreatePixelShader(device
, ps_4_1
, sizeof(ps_4_1
), NULL
, &ps
);
4783 if (feature_level
>= D3D_FEATURE_LEVEL_10_1
)
4785 ok(SUCCEEDED(hr
), "Failed to create SM4.1 pixel shader, hr %#x, feature level %#x.\n",
4787 refcount
= ID3D11PixelShader_Release(ps
);
4788 ok(!refcount
, "Pixel shader has %u references left.\n", refcount
);
4792 todo_wine_if(feature_level
>= D3D_FEATURE_LEVEL_10_0
)
4793 ok(hr
== E_INVALIDARG
, "Created a SM4.1 pixel shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4795 ID3D11PixelShader_Release(ps
);
4798 /* geometry shader */
4799 expected_refcount
= get_refcount(device
) + (feature_level
>= D3D_FEATURE_LEVEL_10_0
);
4800 hr
= ID3D11Device_CreateGeometryShader(device
, gs_4_0
, sizeof(gs_4_0
), NULL
, &gs
);
4801 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
4802 ok(SUCCEEDED(hr
), "Failed to create SM4 geometry shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4804 ok(hr
== E_INVALIDARG
, "Created a SM4 geometry shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4806 refcount
= get_refcount(device
);
4807 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n",
4808 refcount
, expected_refcount
);
4809 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
4812 expected_refcount
= refcount
+ 1;
4813 ID3D11GeometryShader_GetDevice(gs
, &tmp
);
4814 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
4815 refcount
= get_refcount(device
);
4816 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n",
4817 refcount
, expected_refcount
);
4818 ID3D11Device_Release(tmp
);
4820 /* Not available on all Windows versions. */
4821 check_interface(gs
, &IID_ID3D10GeometryShader
, TRUE
, TRUE
);
4823 refcount
= ID3D11GeometryShader_Release(gs
);
4824 ok(!refcount
, "Geometry shader has %u references left.\n", refcount
);
4827 hr
= ID3D11Device_CreateGeometryShader(device
, gs_4_1
, sizeof(gs_4_1
), NULL
, &gs
);
4828 if (feature_level
>= D3D_FEATURE_LEVEL_10_1
)
4830 ok(SUCCEEDED(hr
), "Failed to create SM4.1 geometry shader, hr %#x, feature level %#x.\n",
4832 refcount
= ID3D11GeometryShader_Release(gs
);
4833 ok(!refcount
, "Geometry shader has %u references left.\n", refcount
);
4837 todo_wine_if(feature_level
>= D3D_FEATURE_LEVEL_10_0
)
4838 ok(hr
== E_INVALIDARG
, "Created a SM4.1 geometry shader, hr %#x, feature level %#x.\n",
4841 ID3D11GeometryShader_Release(gs
);
4844 refcount
= ID3D11Device_Release(device
);
4845 ok(!refcount
, "Device has %u references left.\n", refcount
);
4848 static void test_create_sampler_state(void)
4850 static const struct test
4852 D3D11_FILTER filter
;
4853 D3D10_FILTER expected_filter
;
4855 desc_conversion_tests
[] =
4857 {D3D11_FILTER_MIN_MAG_MIP_POINT
, D3D10_FILTER_MIN_MAG_MIP_POINT
},
4858 {D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR
, D3D10_FILTER_MIN_MAG_POINT_MIP_LINEAR
},
4859 {D3D11_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT
, D3D10_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT
},
4860 {D3D11_FILTER_MIN_POINT_MAG_MIP_LINEAR
, D3D10_FILTER_MIN_POINT_MAG_MIP_LINEAR
},
4861 {D3D11_FILTER_MIN_LINEAR_MAG_MIP_POINT
, D3D10_FILTER_MIN_LINEAR_MAG_MIP_POINT
},
4862 {D3D11_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR
, D3D10_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR
},
4863 {D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT
, D3D10_FILTER_MIN_MAG_LINEAR_MIP_POINT
},
4864 {D3D11_FILTER_MIN_MAG_MIP_LINEAR
, D3D10_FILTER_MIN_MAG_MIP_LINEAR
},
4865 {D3D11_FILTER_ANISOTROPIC
, D3D10_FILTER_ANISOTROPIC
},
4866 {D3D11_FILTER_COMPARISON_MIN_MAG_MIP_POINT
, D3D10_FILTER_COMPARISON_MIN_MAG_MIP_POINT
},
4867 {D3D11_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR
, D3D10_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR
},
4869 D3D11_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT
,
4870 D3D10_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT
4872 {D3D11_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR
, D3D10_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR
},
4873 {D3D11_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT
, D3D10_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT
},
4875 D3D11_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR
,
4876 D3D10_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR
4878 {D3D11_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT
, D3D10_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT
},
4879 {D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR
, D3D10_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR
},
4880 {D3D11_FILTER_COMPARISON_ANISOTROPIC
, D3D10_FILTER_COMPARISON_ANISOTROPIC
},
4883 ID3D11SamplerState
*sampler_state1
, *sampler_state2
;
4884 ID3D10SamplerState
*d3d10_sampler_state
;
4885 ULONG refcount
, expected_refcount
;
4886 ID3D11Device
*device
, *tmp
;
4887 D3D11_SAMPLER_DESC desc
;
4891 if (!(device
= create_device(NULL
)))
4893 skip("Failed to create device.\n");
4897 hr
= ID3D11Device_CreateSamplerState(device
, NULL
, &sampler_state1
);
4898 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
4900 desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_LINEAR
;
4901 desc
.AddressU
= D3D11_TEXTURE_ADDRESS_WRAP
;
4902 desc
.AddressV
= D3D11_TEXTURE_ADDRESS_WRAP
;
4903 desc
.AddressW
= D3D11_TEXTURE_ADDRESS_WRAP
;
4904 desc
.MipLODBias
= 0.0f
;
4905 desc
.MaxAnisotropy
= 16;
4906 desc
.ComparisonFunc
= D3D11_COMPARISON_ALWAYS
;
4907 desc
.BorderColor
[0] = 0.0f
;
4908 desc
.BorderColor
[1] = 1.0f
;
4909 desc
.BorderColor
[2] = 0.0f
;
4910 desc
.BorderColor
[3] = 1.0f
;
4912 desc
.MaxLOD
= 16.0f
;
4914 expected_refcount
= get_refcount(device
) + 1;
4915 hr
= ID3D11Device_CreateSamplerState(device
, &desc
, &sampler_state1
);
4916 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
4917 hr
= ID3D11Device_CreateSamplerState(device
, &desc
, &sampler_state2
);
4918 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
4919 ok(sampler_state1
== sampler_state2
, "Got different sampler state objects.\n");
4920 refcount
= get_refcount(device
);
4921 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
4923 expected_refcount
= refcount
+ 1;
4924 ID3D11SamplerState_GetDevice(sampler_state1
, &tmp
);
4925 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
4926 refcount
= get_refcount(device
);
4927 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
4928 ID3D11Device_Release(tmp
);
4930 ID3D11SamplerState_GetDesc(sampler_state1
, &desc
);
4931 ok(desc
.Filter
== D3D11_FILTER_MIN_MAG_MIP_LINEAR
, "Got unexpected filter %#x.\n", desc
.Filter
);
4932 ok(desc
.AddressU
== D3D11_TEXTURE_ADDRESS_WRAP
, "Got unexpected address u %u.\n", desc
.AddressU
);
4933 ok(desc
.AddressV
== D3D11_TEXTURE_ADDRESS_WRAP
, "Got unexpected address v %u.\n", desc
.AddressV
);
4934 ok(desc
.AddressW
== D3D11_TEXTURE_ADDRESS_WRAP
, "Got unexpected address w %u.\n", desc
.AddressW
);
4935 ok(!desc
.MipLODBias
, "Got unexpected mip LOD bias %f.\n", desc
.MipLODBias
);
4936 ok(!desc
.MaxAnisotropy
, "Got unexpected max anisotropy %u.\n", desc
.MaxAnisotropy
);
4937 ok(desc
.ComparisonFunc
== D3D11_COMPARISON_NEVER
, "Got unexpected comparison func %u.\n", desc
.ComparisonFunc
);
4938 ok(!desc
.BorderColor
[0] && !desc
.BorderColor
[1] && !desc
.BorderColor
[2] && !desc
.BorderColor
[3],
4939 "Got unexpected border color {%.8e, %.8e, %.8e, %.8e}.\n",
4940 desc
.BorderColor
[0], desc
.BorderColor
[1], desc
.BorderColor
[2], desc
.BorderColor
[3]);
4941 ok(!desc
.MinLOD
, "Got unexpected min LOD %f.\n", desc
.MinLOD
);
4942 ok(desc
.MaxLOD
== 16.0f
, "Got unexpected max LOD %f.\n", desc
.MaxLOD
);
4944 refcount
= ID3D11SamplerState_Release(sampler_state2
);
4945 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
4946 refcount
= ID3D11SamplerState_Release(sampler_state1
);
4947 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
4949 for (i
= 0; i
< ARRAY_SIZE(desc_conversion_tests
); ++i
)
4951 const struct test
*current
= &desc_conversion_tests
[i
];
4952 D3D10_SAMPLER_DESC d3d10_desc
, expected_desc
;
4954 desc
.Filter
= current
->filter
;
4955 desc
.AddressU
= D3D11_TEXTURE_ADDRESS_WRAP
;
4956 desc
.AddressV
= D3D11_TEXTURE_ADDRESS_WRAP
;
4957 desc
.AddressW
= D3D11_TEXTURE_ADDRESS_BORDER
;
4958 desc
.MipLODBias
= 0.0f
;
4959 desc
.MaxAnisotropy
= 16;
4960 desc
.ComparisonFunc
= D3D11_COMPARISON_ALWAYS
;
4961 desc
.BorderColor
[0] = 0.0f
;
4962 desc
.BorderColor
[1] = 1.0f
;
4963 desc
.BorderColor
[2] = 0.0f
;
4964 desc
.BorderColor
[3] = 1.0f
;
4966 desc
.MaxLOD
= 16.0f
;
4968 hr
= ID3D11Device_CreateSamplerState(device
, &desc
, &sampler_state1
);
4969 ok(SUCCEEDED(hr
), "Test %u: Failed to create sampler state, hr %#x.\n", i
, hr
);
4971 hr
= ID3D11SamplerState_QueryInterface(sampler_state1
, &IID_ID3D10SamplerState
,
4972 (void **)&d3d10_sampler_state
);
4973 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
4974 "Test %u: Sampler state should implement ID3D10SamplerState.\n", i
);
4977 win_skip("Sampler state does not implement ID3D10SamplerState.\n");
4978 ID3D11SamplerState_Release(sampler_state1
);
4982 memcpy(&expected_desc
, &desc
, sizeof(expected_desc
));
4983 expected_desc
.Filter
= current
->expected_filter
;
4984 if (!D3D11_DECODE_IS_ANISOTROPIC_FILTER(current
->filter
))
4985 expected_desc
.MaxAnisotropy
= 0;
4986 if (!D3D11_DECODE_IS_COMPARISON_FILTER(current
->filter
))
4987 expected_desc
.ComparisonFunc
= D3D10_COMPARISON_NEVER
;
4989 ID3D10SamplerState_GetDesc(d3d10_sampler_state
, &d3d10_desc
);
4990 ok(d3d10_desc
.Filter
== expected_desc
.Filter
,
4991 "Test %u: Got unexpected filter %#x.\n", i
, d3d10_desc
.Filter
);
4992 ok(d3d10_desc
.AddressU
== expected_desc
.AddressU
,
4993 "Test %u: Got unexpected address u %u.\n", i
, d3d10_desc
.AddressU
);
4994 ok(d3d10_desc
.AddressV
== expected_desc
.AddressV
,
4995 "Test %u: Got unexpected address v %u.\n", i
, d3d10_desc
.AddressV
);
4996 ok(d3d10_desc
.AddressW
== expected_desc
.AddressW
,
4997 "Test %u: Got unexpected address w %u.\n", i
, d3d10_desc
.AddressW
);
4998 ok(d3d10_desc
.MipLODBias
== expected_desc
.MipLODBias
,
4999 "Test %u: Got unexpected mip LOD bias %f.\n", i
, d3d10_desc
.MipLODBias
);
5000 ok(d3d10_desc
.MaxAnisotropy
== expected_desc
.MaxAnisotropy
,
5001 "Test %u: Got unexpected max anisotropy %u.\n", i
, d3d10_desc
.MaxAnisotropy
);
5002 ok(d3d10_desc
.ComparisonFunc
== expected_desc
.ComparisonFunc
,
5003 "Test %u: Got unexpected comparison func %u.\n", i
, d3d10_desc
.ComparisonFunc
);
5004 ok(d3d10_desc
.BorderColor
[0] == expected_desc
.BorderColor
[0]
5005 && d3d10_desc
.BorderColor
[1] == expected_desc
.BorderColor
[1]
5006 && d3d10_desc
.BorderColor
[2] == expected_desc
.BorderColor
[2]
5007 && d3d10_desc
.BorderColor
[3] == expected_desc
.BorderColor
[3],
5008 "Test %u: Got unexpected border color {%.8e, %.8e, %.8e, %.8e}.\n", i
,
5009 d3d10_desc
.BorderColor
[0], d3d10_desc
.BorderColor
[1],
5010 d3d10_desc
.BorderColor
[2], d3d10_desc
.BorderColor
[3]);
5011 ok(d3d10_desc
.MinLOD
== expected_desc
.MinLOD
,
5012 "Test %u: Got unexpected min LOD %f.\n", i
, d3d10_desc
.MinLOD
);
5013 ok(d3d10_desc
.MaxLOD
== expected_desc
.MaxLOD
,
5014 "Test %u: Got unexpected max LOD %f.\n", i
, d3d10_desc
.MaxLOD
);
5016 refcount
= ID3D10SamplerState_Release(d3d10_sampler_state
);
5017 ok(refcount
== 1, "Test %u: Got unexpected refcount %u.\n", i
, refcount
);
5018 refcount
= ID3D11SamplerState_Release(sampler_state1
);
5019 ok(!refcount
, "Test %u: Got unexpected refcount %u.\n", i
, refcount
);
5022 refcount
= ID3D11Device_Release(device
);
5023 ok(!refcount
, "Device has %u references left.\n", refcount
);
5026 static void test_create_blend_state(void)
5028 static const D3D11_BLEND_DESC desc_conversion_tests
[] =
5034 FALSE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5035 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
5043 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5044 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5047 FALSE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5048 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_RED
5051 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5052 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5055 FALSE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5056 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_GREEN
5059 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5060 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5063 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5064 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5067 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5068 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5071 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5072 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5080 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5081 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5084 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_SUBTRACT
,
5085 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5088 TRUE
, D3D11_BLEND_ZERO
, D3D11_BLEND_ONE
, D3D11_BLEND_OP_ADD
,
5089 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5092 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5093 D3D11_BLEND_ZERO
, D3D11_BLEND_ONE
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5096 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ONE
, D3D11_BLEND_OP_MAX
,
5097 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5100 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ONE
, D3D11_BLEND_OP_MIN
,
5101 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5104 FALSE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5105 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5108 FALSE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5109 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5115 ID3D11BlendState
*blend_state1
, *blend_state2
;
5116 D3D11_BLEND_DESC desc
, obtained_desc
;
5117 ID3D10BlendState
*d3d10_blend_state
;
5118 D3D10_BLEND_DESC d3d10_blend_desc
;
5119 ULONG refcount
, expected_refcount
;
5120 ID3D11Device
*device
, *tmp
;
5124 if (!(device
= create_device(NULL
)))
5126 skip("Failed to create device.\n");
5130 hr
= ID3D11Device_CreateBlendState(device
, NULL
, &blend_state1
);
5131 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5133 memset(&desc
, 0, sizeof(desc
));
5134 desc
.AlphaToCoverageEnable
= FALSE
;
5135 desc
.IndependentBlendEnable
= FALSE
;
5136 desc
.RenderTarget
[0].BlendEnable
= FALSE
;
5137 desc
.RenderTarget
[0].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_ALL
;
5139 expected_refcount
= get_refcount(device
) + 1;
5140 hr
= ID3D11Device_CreateBlendState(device
, &desc
, &blend_state1
);
5141 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
5142 hr
= ID3D11Device_CreateBlendState(device
, &desc
, &blend_state2
);
5143 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
5144 ok(blend_state1
== blend_state2
, "Got different blend state objects.\n");
5145 refcount
= get_refcount(device
);
5146 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
5148 expected_refcount
= refcount
+ 1;
5149 ID3D11BlendState_GetDevice(blend_state1
, &tmp
);
5150 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
5151 refcount
= get_refcount(device
);
5152 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
5153 ID3D11Device_Release(tmp
);
5155 ID3D11BlendState_GetDesc(blend_state1
, &obtained_desc
);
5156 ok(obtained_desc
.AlphaToCoverageEnable
== FALSE
, "Got unexpected alpha to coverage enable %#x.\n",
5157 obtained_desc
.AlphaToCoverageEnable
);
5158 ok(obtained_desc
.IndependentBlendEnable
== FALSE
, "Got unexpected independent blend enable %#x.\n",
5159 obtained_desc
.IndependentBlendEnable
);
5160 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
5162 ok(obtained_desc
.RenderTarget
[i
].BlendEnable
== FALSE
,
5163 "Got unexpected blend enable %#x for render target %u.\n",
5164 obtained_desc
.RenderTarget
[i
].BlendEnable
, i
);
5165 ok(obtained_desc
.RenderTarget
[i
].SrcBlend
== D3D11_BLEND_ONE
,
5166 "Got unexpected src blend %u for render target %u.\n",
5167 obtained_desc
.RenderTarget
[i
].SrcBlend
, i
);
5168 ok(obtained_desc
.RenderTarget
[i
].DestBlend
== D3D11_BLEND_ZERO
,
5169 "Got unexpected dest blend %u for render target %u.\n",
5170 obtained_desc
.RenderTarget
[i
].DestBlend
, i
);
5171 ok(obtained_desc
.RenderTarget
[i
].BlendOp
== D3D11_BLEND_OP_ADD
,
5172 "Got unexpected blend op %u for render target %u.\n",
5173 obtained_desc
.RenderTarget
[i
].BlendOp
, i
);
5174 ok(obtained_desc
.RenderTarget
[i
].SrcBlendAlpha
== D3D11_BLEND_ONE
,
5175 "Got unexpected src blend alpha %u for render target %u.\n",
5176 obtained_desc
.RenderTarget
[i
].SrcBlendAlpha
, i
);
5177 ok(obtained_desc
.RenderTarget
[i
].DestBlendAlpha
== D3D11_BLEND_ZERO
,
5178 "Got unexpected dest blend alpha %u for render target %u.\n",
5179 obtained_desc
.RenderTarget
[i
].DestBlendAlpha
, i
);
5180 ok(obtained_desc
.RenderTarget
[i
].BlendOpAlpha
== D3D11_BLEND_OP_ADD
,
5181 "Got unexpected blend op alpha %u for render target %u.\n",
5182 obtained_desc
.RenderTarget
[i
].BlendOpAlpha
, i
);
5183 ok(obtained_desc
.RenderTarget
[i
].RenderTargetWriteMask
== D3D11_COLOR_WRITE_ENABLE_ALL
,
5184 "Got unexpected render target write mask %#x for render target %u.\n",
5185 obtained_desc
.RenderTarget
[0].RenderTargetWriteMask
, i
);
5188 /* Not available on all Windows versions. */
5189 check_interface(blend_state1
, &IID_ID3D10BlendState
, TRUE
, TRUE
);
5190 check_interface(blend_state1
, &IID_ID3D10BlendState1
, TRUE
, TRUE
);
5192 refcount
= ID3D11BlendState_Release(blend_state1
);
5193 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
5194 refcount
= ID3D11BlendState_Release(blend_state2
);
5195 ok(!refcount
, "Blend state has %u references left.\n", refcount
);
5197 for (i
= 0; i
< ARRAY_SIZE(desc_conversion_tests
); ++i
)
5199 const D3D11_BLEND_DESC
*current_desc
= &desc_conversion_tests
[i
];
5201 hr
= ID3D11Device_CreateBlendState(device
, current_desc
, &blend_state1
);
5202 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
5204 hr
= ID3D11BlendState_QueryInterface(blend_state1
, &IID_ID3D10BlendState
, (void **)&d3d10_blend_state
);
5205 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
5206 "Blend state should implement ID3D10BlendState.\n");
5209 win_skip("Blend state does not implement ID3D10BlendState.\n");
5210 ID3D11BlendState_Release(blend_state1
);
5214 ID3D10BlendState_GetDesc(d3d10_blend_state
, &d3d10_blend_desc
);
5215 ok(d3d10_blend_desc
.AlphaToCoverageEnable
== current_desc
->AlphaToCoverageEnable
,
5216 "Got unexpected alpha to coverage enable %#x for test %u.\n",
5217 d3d10_blend_desc
.AlphaToCoverageEnable
, i
);
5218 ok(d3d10_blend_desc
.SrcBlend
== (D3D10_BLEND
)current_desc
->RenderTarget
[0].SrcBlend
,
5219 "Got unexpected src blend %u for test %u.\n", d3d10_blend_desc
.SrcBlend
, i
);
5220 ok(d3d10_blend_desc
.DestBlend
== (D3D10_BLEND
)current_desc
->RenderTarget
[0].DestBlend
,
5221 "Got unexpected dest blend %u for test %u.\n", d3d10_blend_desc
.DestBlend
, i
);
5222 ok(d3d10_blend_desc
.BlendOp
== (D3D10_BLEND_OP
)current_desc
->RenderTarget
[0].BlendOp
,
5223 "Got unexpected blend op %u for test %u.\n", d3d10_blend_desc
.BlendOp
, i
);
5224 ok(d3d10_blend_desc
.SrcBlendAlpha
== (D3D10_BLEND
)current_desc
->RenderTarget
[0].SrcBlendAlpha
,
5225 "Got unexpected src blend alpha %u for test %u.\n", d3d10_blend_desc
.SrcBlendAlpha
, i
);
5226 ok(d3d10_blend_desc
.DestBlendAlpha
== (D3D10_BLEND
)current_desc
->RenderTarget
[0].DestBlendAlpha
,
5227 "Got unexpected dest blend alpha %u for test %u.\n", d3d10_blend_desc
.DestBlendAlpha
, i
);
5228 ok(d3d10_blend_desc
.BlendOpAlpha
== (D3D10_BLEND_OP
)current_desc
->RenderTarget
[0].BlendOpAlpha
,
5229 "Got unexpected blend op alpha %u for test %u.\n", d3d10_blend_desc
.BlendOpAlpha
, i
);
5230 for (j
= 0; j
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; j
++)
5232 unsigned int k
= current_desc
->IndependentBlendEnable
? j
: 0;
5233 ok(d3d10_blend_desc
.BlendEnable
[j
] == current_desc
->RenderTarget
[k
].BlendEnable
,
5234 "Got unexpected blend enable %#x for test %u, render target %u.\n",
5235 d3d10_blend_desc
.BlendEnable
[j
], i
, j
);
5236 ok(d3d10_blend_desc
.RenderTargetWriteMask
[j
] == current_desc
->RenderTarget
[k
].RenderTargetWriteMask
,
5237 "Got unexpected render target write mask %#x for test %u, render target %u.\n",
5238 d3d10_blend_desc
.RenderTargetWriteMask
[j
], i
, j
);
5241 ID3D10BlendState_Release(d3d10_blend_state
);
5243 refcount
= ID3D11BlendState_Release(blend_state1
);
5244 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
5247 refcount
= ID3D11Device_Release(device
);
5248 ok(!refcount
, "Device has %u references left.\n", refcount
);
5251 static void test_create_depthstencil_state(void)
5253 ID3D11DepthStencilState
*ds_state1
, *ds_state2
;
5254 ULONG refcount
, expected_refcount
;
5255 D3D11_DEPTH_STENCIL_DESC ds_desc
;
5256 ID3D11Device
*device
, *tmp
;
5259 if (!(device
= create_device(NULL
)))
5261 skip("Failed to create device.\n");
5265 hr
= ID3D11Device_CreateDepthStencilState(device
, NULL
, &ds_state1
);
5266 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5268 ds_desc
.DepthEnable
= TRUE
;
5269 ds_desc
.DepthWriteMask
= D3D11_DEPTH_WRITE_MASK_ALL
;
5270 ds_desc
.DepthFunc
= D3D11_COMPARISON_LESS
;
5271 ds_desc
.StencilEnable
= FALSE
;
5272 ds_desc
.StencilReadMask
= D3D11_DEFAULT_STENCIL_READ_MASK
;
5273 ds_desc
.StencilWriteMask
= D3D11_DEFAULT_STENCIL_WRITE_MASK
;
5274 ds_desc
.FrontFace
.StencilFailOp
= D3D11_STENCIL_OP_KEEP
;
5275 ds_desc
.FrontFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_KEEP
;
5276 ds_desc
.FrontFace
.StencilPassOp
= D3D11_STENCIL_OP_KEEP
;
5277 ds_desc
.FrontFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
5278 ds_desc
.BackFace
.StencilFailOp
= D3D11_STENCIL_OP_KEEP
;
5279 ds_desc
.BackFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_KEEP
;
5280 ds_desc
.BackFace
.StencilPassOp
= D3D11_STENCIL_OP_KEEP
;
5281 ds_desc
.BackFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
5283 expected_refcount
= get_refcount(device
) + 1;
5284 hr
= ID3D11Device_CreateDepthStencilState(device
, &ds_desc
, &ds_state1
);
5285 ok(SUCCEEDED(hr
), "Failed to create depthstencil state, hr %#x.\n", hr
);
5286 hr
= ID3D11Device_CreateDepthStencilState(device
, &ds_desc
, &ds_state2
);
5287 ok(SUCCEEDED(hr
), "Failed to create depthstencil state, hr %#x.\n", hr
);
5288 ok(ds_state1
== ds_state2
, "Got different depthstencil state objects.\n");
5289 refcount
= get_refcount(device
);
5290 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
5292 expected_refcount
= refcount
+ 1;
5293 ID3D11DepthStencilState_GetDevice(ds_state1
, &tmp
);
5294 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
5295 refcount
= get_refcount(device
);
5296 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
5297 ID3D11Device_Release(tmp
);
5299 /* Not available on all Windows versions. */
5300 check_interface(ds_state1
, &IID_ID3D10DepthStencilState
, TRUE
, TRUE
);
5302 refcount
= ID3D11DepthStencilState_Release(ds_state2
);
5303 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
5304 refcount
= ID3D11DepthStencilState_Release(ds_state1
);
5305 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
5307 ds_desc
.DepthEnable
= FALSE
;
5308 ds_desc
.DepthWriteMask
= D3D11_DEPTH_WRITE_MASK_ZERO
;
5309 ds_desc
.DepthFunc
= D3D11_COMPARISON_NEVER
;
5310 ds_desc
.StencilEnable
= FALSE
;
5311 ds_desc
.StencilReadMask
= 0;
5312 ds_desc
.StencilWriteMask
= 0;
5313 ds_desc
.FrontFace
.StencilFailOp
= D3D11_STENCIL_OP_ZERO
;
5314 ds_desc
.FrontFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_ZERO
;
5315 ds_desc
.FrontFace
.StencilPassOp
= D3D11_STENCIL_OP_ZERO
;
5316 ds_desc
.FrontFace
.StencilFunc
= D3D11_COMPARISON_NEVER
;
5317 ds_desc
.BackFace
= ds_desc
.FrontFace
;
5319 hr
= ID3D11Device_CreateDepthStencilState(device
, &ds_desc
, &ds_state1
);
5320 ok(SUCCEEDED(hr
), "Failed to create depthstencil state, hr %#x.\n", hr
);
5322 memset(&ds_desc
, 0, sizeof(ds_desc
));
5323 ID3D11DepthStencilState_GetDesc(ds_state1
, &ds_desc
);
5324 ok(!ds_desc
.DepthEnable
, "Got unexpected depth enable %#x.\n", ds_desc
.DepthEnable
);
5325 ok(ds_desc
.DepthWriteMask
== D3D11_DEPTH_WRITE_MASK_ALL
,
5326 "Got unexpected depth write mask %#x.\n", ds_desc
.DepthWriteMask
);
5327 ok(ds_desc
.DepthFunc
== D3D11_COMPARISON_LESS
, "Got unexpected depth func %#x.\n", ds_desc
.DepthFunc
);
5328 ok(!ds_desc
.StencilEnable
, "Got unexpected stencil enable %#x.\n", ds_desc
.StencilEnable
);
5329 ok(ds_desc
.StencilReadMask
== D3D11_DEFAULT_STENCIL_READ_MASK
,
5330 "Got unexpected stencil read mask %#x.\n", ds_desc
.StencilReadMask
);
5331 ok(ds_desc
.StencilWriteMask
== D3D11_DEFAULT_STENCIL_WRITE_MASK
,
5332 "Got unexpected stencil write mask %#x.\n", ds_desc
.StencilWriteMask
);
5333 ok(ds_desc
.FrontFace
.StencilDepthFailOp
== D3D11_STENCIL_OP_KEEP
,
5334 "Got unexpected front face stencil depth fail op %#x.\n", ds_desc
.FrontFace
.StencilDepthFailOp
);
5335 ok(ds_desc
.FrontFace
.StencilPassOp
== D3D11_STENCIL_OP_KEEP
,
5336 "Got unexpected front face stencil pass op %#x.\n", ds_desc
.FrontFace
.StencilPassOp
);
5337 ok(ds_desc
.FrontFace
.StencilFailOp
== D3D11_STENCIL_OP_KEEP
,
5338 "Got unexpected front face stencil fail op %#x.\n", ds_desc
.FrontFace
.StencilFailOp
);
5339 ok(ds_desc
.FrontFace
.StencilFunc
== D3D11_COMPARISON_ALWAYS
,
5340 "Got unexpected front face stencil func %#x.\n", ds_desc
.FrontFace
.StencilFunc
);
5341 ok(ds_desc
.BackFace
.StencilDepthFailOp
== D3D11_STENCIL_OP_KEEP
,
5342 "Got unexpected back face stencil depth fail op %#x.\n", ds_desc
.BackFace
.StencilDepthFailOp
);
5343 ok(ds_desc
.BackFace
.StencilPassOp
== D3D11_STENCIL_OP_KEEP
,
5344 "Got unexpected back face stencil pass op %#x.\n", ds_desc
.BackFace
.StencilPassOp
);
5345 ok(ds_desc
.BackFace
.StencilFailOp
== D3D11_STENCIL_OP_KEEP
,
5346 "Got unexpected back face stencil fail op %#x.\n", ds_desc
.BackFace
.StencilFailOp
);
5347 ok(ds_desc
.BackFace
.StencilFunc
== D3D11_COMPARISON_ALWAYS
,
5348 "Got unexpected back face stencil func %#x.\n", ds_desc
.BackFace
.StencilFunc
);
5350 ID3D11DepthStencilState_Release(ds_state1
);
5352 refcount
= ID3D11Device_Release(device
);
5353 ok(!refcount
, "Device has %u references left.\n", refcount
);
5356 static void test_create_rasterizer_state(void)
5358 ID3D11RasterizerState
*rast_state1
, *rast_state2
;
5359 ID3D10RasterizerState
*d3d10_rast_state
;
5360 ULONG refcount
, expected_refcount
;
5361 D3D10_RASTERIZER_DESC d3d10_desc
;
5362 D3D11_RASTERIZER_DESC desc
;
5363 ID3D11Device
*device
, *tmp
;
5366 if (!(device
= create_device(NULL
)))
5368 skip("Failed to create device.\n");
5372 hr
= ID3D11Device_CreateRasterizerState(device
, NULL
, &rast_state1
);
5373 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5375 desc
.FillMode
= D3D11_FILL_SOLID
;
5376 desc
.CullMode
= D3D11_CULL_BACK
;
5377 desc
.FrontCounterClockwise
= FALSE
;
5379 desc
.DepthBiasClamp
= 0.0f
;
5380 desc
.SlopeScaledDepthBias
= 0.0f
;
5381 desc
.DepthClipEnable
= TRUE
;
5382 desc
.ScissorEnable
= FALSE
;
5383 desc
.MultisampleEnable
= FALSE
;
5384 desc
.AntialiasedLineEnable
= FALSE
;
5386 expected_refcount
= get_refcount(device
) + 1;
5387 hr
= ID3D11Device_CreateRasterizerState(device
, &desc
, &rast_state1
);
5388 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
5389 hr
= ID3D11Device_CreateRasterizerState(device
, &desc
, &rast_state2
);
5390 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
5391 ok(rast_state1
== rast_state2
, "Got different rasterizer state objects.\n");
5392 refcount
= get_refcount(device
);
5393 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
5395 expected_refcount
= refcount
+ 1;
5396 ID3D11RasterizerState_GetDevice(rast_state1
, &tmp
);
5397 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
5398 refcount
= get_refcount(device
);
5399 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
5400 ID3D11Device_Release(tmp
);
5402 hr
= ID3D11RasterizerState_QueryInterface(rast_state1
, &IID_ID3D10RasterizerState
, (void **)&d3d10_rast_state
);
5403 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
5404 "Rasterizer state should implement ID3D10RasterizerState.\n");
5407 ID3D10RasterizerState_GetDesc(d3d10_rast_state
, &d3d10_desc
);
5408 ok(d3d10_desc
.FillMode
== D3D10_FILL_SOLID
, "Got unexpected fill mode %u.\n", d3d10_desc
.FillMode
);
5409 ok(d3d10_desc
.CullMode
== D3D10_CULL_BACK
, "Got unexpected cull mode %u.\n", d3d10_desc
.CullMode
);
5410 ok(!d3d10_desc
.FrontCounterClockwise
, "Got unexpected front counter clockwise %#x.\n",
5411 d3d10_desc
.FrontCounterClockwise
);
5412 ok(!d3d10_desc
.DepthBias
, "Got unexpected depth bias %d.\n", d3d10_desc
.DepthBias
);
5413 ok(!d3d10_desc
.DepthBiasClamp
, "Got unexpected depth bias clamp %f.\n", d3d10_desc
.DepthBiasClamp
);
5414 ok(!d3d10_desc
.SlopeScaledDepthBias
, "Got unexpected slope scaled depth bias %f.\n",
5415 d3d10_desc
.SlopeScaledDepthBias
);
5416 ok(!!d3d10_desc
.DepthClipEnable
, "Got unexpected depth clip enable %#x.\n", d3d10_desc
.DepthClipEnable
);
5417 ok(!d3d10_desc
.ScissorEnable
, "Got unexpected scissor enable %#x.\n", d3d10_desc
.ScissorEnable
);
5418 ok(!d3d10_desc
.MultisampleEnable
, "Got unexpected multisample enable %#x.\n",
5419 d3d10_desc
.MultisampleEnable
);
5420 ok(!d3d10_desc
.AntialiasedLineEnable
, "Got unexpected antialiased line enable %#x.\n",
5421 d3d10_desc
.AntialiasedLineEnable
);
5423 refcount
= ID3D10RasterizerState_Release(d3d10_rast_state
);
5424 ok(refcount
== 2, "Got unexpected refcount %u.\n", refcount
);
5427 refcount
= ID3D11RasterizerState_Release(rast_state2
);
5428 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
5429 refcount
= ID3D11RasterizerState_Release(rast_state1
);
5430 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
5432 refcount
= ID3D11Device_Release(device
);
5433 ok(!refcount
, "Device has %u references left.\n", refcount
);
5436 static void test_create_query(void)
5441 D3D_FEATURE_LEVEL required_feature_level
;
5443 BOOL can_use_create_predicate
;
5448 {D3D11_QUERY_EVENT
, D3D_FEATURE_LEVEL_10_0
, FALSE
, FALSE
, FALSE
},
5449 {D3D11_QUERY_OCCLUSION
, D3D_FEATURE_LEVEL_10_0
, FALSE
, FALSE
, FALSE
},
5450 {D3D11_QUERY_TIMESTAMP
, D3D_FEATURE_LEVEL_10_0
, FALSE
, FALSE
, FALSE
},
5451 {D3D11_QUERY_TIMESTAMP_DISJOINT
, D3D_FEATURE_LEVEL_10_0
, FALSE
, FALSE
, FALSE
},
5452 {D3D11_QUERY_PIPELINE_STATISTICS
, D3D_FEATURE_LEVEL_10_0
, FALSE
, FALSE
, FALSE
},
5453 {D3D11_QUERY_OCCLUSION_PREDICATE
, D3D_FEATURE_LEVEL_10_0
, TRUE
, TRUE
, FALSE
},
5454 {D3D11_QUERY_SO_STATISTICS
, D3D_FEATURE_LEVEL_10_0
, FALSE
, FALSE
, FALSE
},
5455 {D3D11_QUERY_SO_OVERFLOW_PREDICATE
, D3D_FEATURE_LEVEL_10_0
, TRUE
, TRUE
, TRUE
},
5456 {D3D11_QUERY_SO_STATISTICS_STREAM0
, D3D_FEATURE_LEVEL_11_0
, FALSE
, FALSE
, FALSE
},
5457 {D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM0
, D3D_FEATURE_LEVEL_11_0
, TRUE
, FALSE
, TRUE
},
5458 {D3D11_QUERY_SO_STATISTICS_STREAM1
, D3D_FEATURE_LEVEL_11_0
, FALSE
, FALSE
, FALSE
},
5459 {D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM1
, D3D_FEATURE_LEVEL_11_0
, TRUE
, FALSE
, TRUE
},
5460 {D3D11_QUERY_SO_STATISTICS_STREAM2
, D3D_FEATURE_LEVEL_11_0
, FALSE
, FALSE
, FALSE
},
5461 {D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM2
, D3D_FEATURE_LEVEL_11_0
, TRUE
, FALSE
, TRUE
},
5462 {D3D11_QUERY_SO_STATISTICS_STREAM3
, D3D_FEATURE_LEVEL_11_0
, FALSE
, FALSE
, FALSE
},
5463 {D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM3
, D3D_FEATURE_LEVEL_11_0
, TRUE
, FALSE
, TRUE
},
5466 ULONG refcount
, expected_refcount
;
5467 D3D_FEATURE_LEVEL feature_level
;
5468 D3D11_QUERY_DESC query_desc
;
5469 ID3D11Predicate
*predicate
;
5470 ID3D11Device
*device
, *tmp
;
5471 HRESULT hr
, expected_hr
;
5475 if (!(device
= create_device(NULL
)))
5477 skip("Failed to create device.\n");
5480 feature_level
= ID3D11Device_GetFeatureLevel(device
);
5482 hr
= ID3D11Device_CreateQuery(device
, NULL
, &query
);
5483 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5484 hr
= ID3D11Device_CreatePredicate(device
, NULL
, &predicate
);
5485 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5487 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
5489 if (tests
[i
].required_feature_level
> feature_level
)
5491 skip("Query type %u requires feature level %#x.\n", tests
[i
].query
, tests
[i
].required_feature_level
);
5495 query_desc
.Query
= tests
[i
].query
;
5496 query_desc
.MiscFlags
= 0;
5498 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, NULL
);
5499 todo_wine_if(tests
[i
].todo
)
5500 ok(hr
== S_FALSE
, "Got unexpected hr %#x for query type %u.\n", hr
, query_desc
.Query
);
5502 query_desc
.Query
= tests
[i
].query
;
5503 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, &query
);
5504 todo_wine_if(tests
[i
].todo
)
5505 ok(hr
== S_OK
, "Got unexpected hr %#x for query type %u.\n", hr
, query_desc
.Query
);
5509 check_interface(query
, &IID_ID3D11Predicate
, tests
[i
].is_predicate
, FALSE
);
5510 ID3D11Query_Release(query
);
5512 expected_hr
= tests
[i
].can_use_create_predicate
? S_FALSE
: E_INVALIDARG
;
5513 hr
= ID3D11Device_CreatePredicate(device
, &query_desc
, NULL
);
5514 ok(hr
== expected_hr
, "Got unexpected hr %#x for query type %u.\n", hr
, query_desc
.Query
);
5516 expected_hr
= tests
[i
].can_use_create_predicate
? S_OK
: E_INVALIDARG
;
5517 hr
= ID3D11Device_CreatePredicate(device
, &query_desc
, &predicate
);
5518 ok(hr
== expected_hr
, "Got unexpected hr %#x for query type %u.\n", hr
, query_desc
.Query
);
5520 ID3D11Predicate_Release(predicate
);
5523 query_desc
.Query
= D3D11_QUERY_OCCLUSION_PREDICATE
;
5524 expected_refcount
= get_refcount(device
) + 1;
5525 hr
= ID3D11Device_CreatePredicate(device
, &query_desc
, &predicate
);
5526 ok(SUCCEEDED(hr
), "Failed to create predicate, hr %#x.\n", hr
);
5527 refcount
= get_refcount(device
);
5528 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
5530 expected_refcount
= refcount
+ 1;
5531 ID3D11Predicate_GetDevice(predicate
, &tmp
);
5532 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
5533 refcount
= get_refcount(device
);
5534 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
5535 ID3D11Device_Release(tmp
);
5536 /* Not available on all Windows versions. */
5537 check_interface(predicate
, &IID_ID3D10Predicate
, TRUE
, TRUE
);
5538 ID3D11Predicate_Release(predicate
);
5540 refcount
= ID3D11Device_Release(device
);
5541 ok(!refcount
, "Device has %u references left.\n", refcount
);
5544 #define get_query_data(a, b, c, d) get_query_data_(__LINE__, a, b, c, d)
5545 static void get_query_data_(unsigned int line
, ID3D11DeviceContext
*context
,
5546 ID3D11Asynchronous
*query
, void *data
, unsigned int data_size
)
5551 for (i
= 0; i
< 500; ++i
)
5553 if ((hr
= ID3D11DeviceContext_GetData(context
, query
, NULL
, 0, 0)) != S_FALSE
)
5557 ok_(__FILE__
, line
)(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5558 memset(data
, 0xff, data_size
);
5559 hr
= ID3D11DeviceContext_GetData(context
, query
, data
, data_size
, 0);
5560 ok_(__FILE__
, line
)(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5563 static void test_occlusion_query(void)
5565 static const struct vec4 red
= {1.0f
, 0.0f
, 0.0f
, 1.0f
};
5566 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
5568 struct d3d11_test_context test_context
;
5569 D3D11_TEXTURE2D_DESC texture_desc
;
5570 ID3D11DeviceContext
*context
;
5571 ID3D11RenderTargetView
*rtv
;
5572 D3D11_QUERY_DESC query_desc
;
5573 ID3D11Asynchronous
*query
;
5574 unsigned int data_size
, i
;
5575 ID3D11Texture2D
*texture
;
5576 ID3D11Device
*device
;
5584 if (!init_test_context(&test_context
, NULL
))
5587 device
= test_context
.device
;
5588 context
= test_context
.immediate_context
;
5590 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
5592 query_desc
.Query
= D3D11_QUERY_OCCLUSION
;
5593 query_desc
.MiscFlags
= 0;
5594 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, (ID3D11Query
**)&query
);
5595 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5596 data_size
= ID3D11Asynchronous_GetDataSize(query
);
5597 ok(data_size
== sizeof(data
), "Got unexpected data size %u.\n", data_size
);
5599 memset(&data
, 0xff, sizeof(data
));
5600 hr
= ID3D11DeviceContext_GetData(context
, query
, NULL
, 0, 0);
5601 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5602 hr
= ID3D11DeviceContext_GetData(context
, query
, &data
, sizeof(data
), 0);
5603 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5604 ok(data
.dword
[0] == 0xffffffff && data
.dword
[1] == 0xffffffff,
5605 "Data was modified 0x%08x%08x.\n", data
.dword
[1], data
.dword
[0]);
5607 ID3D11DeviceContext_End(context
, query
);
5608 ID3D11DeviceContext_Begin(context
, query
);
5609 ID3D11DeviceContext_Begin(context
, query
);
5611 memset(&data
, 0xff, sizeof(data
));
5612 hr
= ID3D11DeviceContext_GetData(context
, query
, NULL
, 0, 0);
5613 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5614 hr
= ID3D11DeviceContext_GetData(context
, query
, &data
, sizeof(data
), 0);
5615 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5616 ok(data
.dword
[0] == 0xffffffff && data
.dword
[1] == 0xffffffff,
5617 "Data was modified 0x%08x%08x.\n", data
.dword
[1], data
.dword
[0]);
5619 draw_color_quad(&test_context
, &red
);
5621 ID3D11DeviceContext_End(context
, query
);
5622 get_query_data(context
, query
, &data
, sizeof(data
));
5623 ok(data
.uint
== 640 * 480, "Got unexpected query result 0x%08x%08x.\n", data
.dword
[1], data
.dword
[0]);
5625 memset(&data
, 0xff, sizeof(data
));
5626 hr
= ID3D11DeviceContext_GetData(context
, query
, &data
, sizeof(DWORD
), 0);
5627 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5628 hr
= ID3D11DeviceContext_GetData(context
, query
, &data
, sizeof(WORD
), 0);
5629 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5630 hr
= ID3D11DeviceContext_GetData(context
, query
, &data
, sizeof(data
) - 1, 0);
5631 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5632 hr
= ID3D11DeviceContext_GetData(context
, query
, &data
, sizeof(data
) + 1, 0);
5633 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5634 ok(data
.dword
[0] == 0xffffffff && data
.dword
[1] == 0xffffffff,
5635 "Data was modified 0x%08x%08x.\n", data
.dword
[1], data
.dword
[0]);
5637 memset(&data
, 0xff, sizeof(data
));
5638 hr
= ID3D11DeviceContext_GetData(context
, query
, &data
, 0, 0);
5639 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5640 ok(data
.dword
[0] == 0xffffffff && data
.dword
[1] == 0xffffffff,
5641 "Data was modified 0x%08x%08x.\n", data
.dword
[1], data
.dword
[0]);
5643 hr
= ID3D11DeviceContext_GetData(context
, query
, NULL
, sizeof(DWORD
), 0);
5644 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5645 hr
= ID3D11DeviceContext_GetData(context
, query
, NULL
, sizeof(data
), 0);
5646 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5648 ID3D11DeviceContext_Begin(context
, query
);
5649 ID3D11DeviceContext_End(context
, query
);
5650 ID3D11DeviceContext_End(context
, query
);
5652 get_query_data(context
, query
, &data
, sizeof(data
));
5653 ok(!data
.uint
, "Got unexpected query result 0x%08x%08x.\n", data
.dword
[1], data
.dword
[0]);
5654 hr
= ID3D11DeviceContext_GetData(context
, query
, NULL
, 0, 0);
5655 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5657 texture_desc
.Width
= D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION
;
5658 texture_desc
.Height
= D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION
;
5659 texture_desc
.MipLevels
= 1;
5660 texture_desc
.ArraySize
= 1;
5661 texture_desc
.Format
= DXGI_FORMAT_R8_UNORM
;
5662 texture_desc
.SampleDesc
.Count
= 1;
5663 texture_desc
.SampleDesc
.Quality
= 0;
5664 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
5665 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
5666 texture_desc
.CPUAccessFlags
= 0;
5667 texture_desc
.MiscFlags
= 0;
5668 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
5669 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
5670 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
5671 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
5673 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
5674 set_viewport(context
, 0.0f
, 0.0f
, texture_desc
.Width
, texture_desc
.Height
, 0.0f
, 1.0f
);
5676 ID3D11DeviceContext_Begin(context
, query
);
5677 for (i
= 0; i
< 100; i
++)
5678 draw_color_quad(&test_context
, &red
);
5679 ID3D11DeviceContext_End(context
, query
);
5681 get_query_data(context
, query
, &data
, sizeof(data
));
5682 ok((data
.dword
[0] == 0x90000000 && data
.dword
[1] == 0x1)
5683 || (data
.dword
[0] == 0xffffffff && !data
.dword
[1])
5684 || broken(!data
.uint
),
5685 "Got unexpected query result 0x%08x%08x.\n", data
.dword
[1], data
.dword
[0]);
5686 hr
= ID3D11DeviceContext_GetData(context
, query
, NULL
, 0, 0);
5687 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5689 ID3D11Asynchronous_Release(query
);
5691 /* The following test exercises a code path in wined3d. A wined3d context
5692 * associated with the query is destroyed when the swapchain is released. */
5693 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, (ID3D11Query
**)&query
);
5694 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5696 set_viewport(context
, 0.0f
, 0.0f
, 64.0f
, 64.0f
, 0.0f
, 1.0f
);
5697 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
5698 ID3D11DeviceContext_Begin(context
, query
);
5699 draw_color_quad(&test_context
, &red
);
5700 ID3D11DeviceContext_End(context
, query
);
5702 ID3D11RenderTargetView_Release(test_context
.backbuffer_rtv
);
5703 ID3D11Texture2D_Release(test_context
.backbuffer
);
5704 IDXGISwapChain_Release(test_context
.swapchain
);
5705 test_context
.swapchain
= create_swapchain(device
, test_context
.window
, NULL
);
5706 hr
= IDXGISwapChain_GetBuffer(test_context
.swapchain
, 0, &IID_ID3D11Texture2D
,
5707 (void **)&test_context
.backbuffer
);
5708 ok(SUCCEEDED(hr
), "Failed to get backbuffer, hr %#x.\n", hr
);
5709 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)test_context
.backbuffer
,
5710 NULL
, &test_context
.backbuffer_rtv
);
5711 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
5712 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &test_context
.backbuffer_rtv
, NULL
);
5713 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
5715 get_query_data(context
, query
, &data
, sizeof(data
));
5716 /* This test occasionally succeeds with CSMT enabled because of a race condition. */
5718 todo_wine
ok(data
.dword
[0] == 0x1000 && !data
.dword
[1],
5719 "Got unexpected query result 0x%08x%08x.\n", data
.dword
[1], data
.dword
[0]);
5721 ID3D11Asynchronous_Release(query
);
5722 ID3D11RenderTargetView_Release(rtv
);
5723 ID3D11Texture2D_Release(texture
);
5724 release_test_context(&test_context
);
5727 static void test_pipeline_statistics_query(void)
5729 static const struct vec4 red
= {1.0f
, 0.0f
, 0.0f
, 1.0f
};
5730 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
5732 D3D11_QUERY_DATA_PIPELINE_STATISTICS data
;
5733 struct d3d11_test_context test_context
;
5734 ID3D11DeviceContext
*context
;
5735 D3D11_QUERY_DESC query_desc
;
5736 ID3D11Asynchronous
*query
;
5737 unsigned int data_size
;
5738 ID3D11Device
*device
;
5741 if (!init_test_context(&test_context
, NULL
))
5744 device
= test_context
.device
;
5745 context
= test_context
.immediate_context
;
5747 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
5749 query_desc
.Query
= D3D11_QUERY_PIPELINE_STATISTICS
;
5750 query_desc
.MiscFlags
= 0;
5751 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, (ID3D11Query
**)&query
);
5752 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5753 data_size
= ID3D11Asynchronous_GetDataSize(query
);
5754 ok(data_size
== sizeof(data
), "Got unexpected data size %u.\n", data_size
);
5756 hr
= ID3D11DeviceContext_GetData(context
, query
, NULL
, 0, 0);
5757 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5758 hr
= ID3D11DeviceContext_GetData(context
, query
, &data
, sizeof(data
), 0);
5759 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5761 ID3D11DeviceContext_End(context
, query
);
5762 ID3D11DeviceContext_Begin(context
, query
);
5763 ID3D11DeviceContext_Begin(context
, query
);
5765 memset(&data
, 0xff, sizeof(data
));
5766 hr
= ID3D11DeviceContext_GetData(context
, query
, NULL
, 0, 0);
5767 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5768 hr
= ID3D11DeviceContext_GetData(context
, query
, &data
, sizeof(data
), 0);
5769 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5770 ok(data
.IAVertices
== ~(UINT64
)0, "Data was modified.\n");
5772 draw_quad(&test_context
);
5774 ID3D11DeviceContext_End(context
, query
);
5775 get_query_data(context
, query
, &data
, sizeof(data
));
5776 ok(data
.IAVertices
== 4, "Got unexpected IAVertices count: %u.\n", (unsigned int)data
.IAVertices
);
5777 ok(data
.IAPrimitives
== 2, "Got unexpected IAPrimitives count: %u.\n", (unsigned int)data
.IAPrimitives
);
5778 ok(data
.VSInvocations
== 4, "Got unexpected VSInvocations count: %u.\n", (unsigned int)data
.VSInvocations
);
5779 ok(!data
.GSInvocations
, "Got unexpected GSInvocations count: %u.\n", (unsigned int)data
.GSInvocations
);
5780 ok(!data
.GSPrimitives
, "Got unexpected GSPrimitives count: %u.\n", (unsigned int)data
.GSPrimitives
);
5781 ok(data
.CInvocations
== 2, "Got unexpected CInvocations count: %u.\n", (unsigned int)data
.CInvocations
);
5782 ok(data
.CPrimitives
== 2, "Got unexpected CPrimitives count: %u.\n", (unsigned int)data
.CPrimitives
);
5784 ok(!data
.PSInvocations
, "Got unexpected PSInvocations count: %u.\n", (unsigned int)data
.PSInvocations
);
5785 ok(!data
.HSInvocations
, "Got unexpected HSInvocations count: %u.\n", (unsigned int)data
.HSInvocations
);
5786 ok(!data
.DSInvocations
, "Got unexpected DSInvocations count: %u.\n", (unsigned int)data
.DSInvocations
);
5787 ok(!data
.CSInvocations
, "Got unexpected CSInvocations count: %u.\n", (unsigned int)data
.CSInvocations
);
5789 ID3D11DeviceContext_Begin(context
, query
);
5790 draw_color_quad(&test_context
, &red
);
5791 ID3D11DeviceContext_End(context
, query
);
5792 get_query_data(context
, query
, &data
, sizeof(data
));
5793 ok(data
.IAVertices
== 4, "Got unexpected IAVertices count: %u.\n", (unsigned int)data
.IAVertices
);
5794 ok(data
.IAPrimitives
== 2, "Got unexpected IAPrimitives count: %u.\n", (unsigned int)data
.IAPrimitives
);
5795 ok(data
.VSInvocations
== 4, "Got unexpected VSInvocations count: %u.\n", (unsigned int)data
.VSInvocations
);
5796 ok(!data
.GSInvocations
, "Got unexpected GSInvocations count: %u.\n", (unsigned int)data
.GSInvocations
);
5797 ok(!data
.GSPrimitives
, "Got unexpected GSPrimitives count: %u.\n", (unsigned int)data
.GSPrimitives
);
5798 ok(data
.CInvocations
== 2, "Got unexpected CInvocations count: %u.\n", (unsigned int)data
.CInvocations
);
5799 ok(data
.CPrimitives
== 2, "Got unexpected CPrimitives count: %u.\n", (unsigned int)data
.CPrimitives
);
5800 ok(data
.PSInvocations
>= 640 * 480, "Got unexpected PSInvocations count: %u.\n", (unsigned int)data
.PSInvocations
);
5801 ok(!data
.HSInvocations
, "Got unexpected HSInvocations count: %u.\n", (unsigned int)data
.HSInvocations
);
5802 ok(!data
.DSInvocations
, "Got unexpected DSInvocations count: %u.\n", (unsigned int)data
.DSInvocations
);
5803 ok(!data
.CSInvocations
, "Got unexpected CSInvocations count: %u.\n", (unsigned int)data
.CSInvocations
);
5805 ID3D11Asynchronous_Release(query
);
5806 release_test_context(&test_context
);
5809 static void test_timestamp_query(void)
5811 static const struct vec4 red
= {1.0f
, 0.0f
, 0.0f
, 1.0f
};
5813 ID3D11Asynchronous
*timestamp_query
, *timestamp_disjoint_query
;
5814 D3D11_QUERY_DATA_TIMESTAMP_DISJOINT disjoint
, prev_disjoint
;
5815 struct d3d11_test_context test_context
;
5816 ID3D11DeviceContext
*context
;
5817 D3D11_QUERY_DESC query_desc
;
5818 unsigned int data_size
;
5819 ID3D11Device
*device
;
5823 if (!init_test_context(&test_context
, NULL
))
5826 device
= test_context
.device
;
5827 context
= test_context
.immediate_context
;
5829 query_desc
.Query
= D3D11_QUERY_TIMESTAMP
;
5830 query_desc
.MiscFlags
= 0;
5831 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, (ID3D11Query
**)×tamp_query
);
5832 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5833 data_size
= ID3D11Asynchronous_GetDataSize(timestamp_query
);
5834 ok(data_size
== sizeof(UINT64
), "Got unexpected data size %u.\n", data_size
);
5836 query_desc
.Query
= D3D11_QUERY_TIMESTAMP_DISJOINT
;
5837 query_desc
.MiscFlags
= 0;
5838 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, (ID3D11Query
**)×tamp_disjoint_query
);
5839 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5840 data_size
= ID3D11Asynchronous_GetDataSize(timestamp_disjoint_query
);
5841 ok(data_size
== sizeof(disjoint
), "Got unexpected data size %u.\n", data_size
);
5843 disjoint
.Frequency
= 0xdeadbeef;
5844 disjoint
.Disjoint
= 0xdeadbeef;
5845 hr
= ID3D11DeviceContext_GetData(context
, timestamp_disjoint_query
, NULL
, 0, 0);
5846 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5847 hr
= ID3D11DeviceContext_GetData(context
, timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
), 0);
5848 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5849 ok(disjoint
.Frequency
== 0xdeadbeef, "Frequency data was modified.\n");
5850 ok(disjoint
.Disjoint
== 0xdeadbeef, "Disjoint data was modified.\n");
5852 /* Test a TIMESTAMP_DISJOINT query. */
5853 ID3D11DeviceContext_Begin(context
, timestamp_disjoint_query
);
5855 disjoint
.Frequency
= 0xdeadbeef;
5856 disjoint
.Disjoint
= 0xdeadbeef;
5857 hr
= ID3D11DeviceContext_GetData(context
, timestamp_disjoint_query
, NULL
, 0, 0);
5858 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5859 hr
= ID3D11DeviceContext_GetData(context
, timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
), 0);
5860 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5861 ok(disjoint
.Frequency
== 0xdeadbeef, "Frequency data was modified.\n");
5862 ok(disjoint
.Disjoint
== 0xdeadbeef, "Disjoint data was modified.\n");
5864 ID3D11DeviceContext_End(context
, timestamp_disjoint_query
);
5865 get_query_data(context
, timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
));
5866 ok(disjoint
.Frequency
!= ~(UINT64
)0, "Frequency data was not modified.\n");
5867 ok(disjoint
.Disjoint
== TRUE
|| disjoint
.Disjoint
== FALSE
, "Got unexpected disjoint %#x.\n", disjoint
.Disjoint
);
5869 prev_disjoint
= disjoint
;
5871 disjoint
.Frequency
= 0xdeadbeef;
5872 disjoint
.Disjoint
= 0xff;
5873 hr
= ID3D11DeviceContext_GetData(context
, timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
) - 1, 0);
5874 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5875 hr
= ID3D11DeviceContext_GetData(context
, timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
) + 1, 0);
5876 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5877 hr
= ID3D11DeviceContext_GetData(context
, timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
) / 2, 0);
5878 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5879 hr
= ID3D11DeviceContext_GetData(context
, timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
) * 2, 0);
5880 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5881 ok(disjoint
.Frequency
== 0xdeadbeef, "Frequency data was modified.\n");
5882 ok(disjoint
.Disjoint
== 0xff, "Disjoint data was modified.\n");
5884 hr
= ID3D11DeviceContext_GetData(context
, timestamp_disjoint_query
, NULL
, 0, 0);
5885 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5886 hr
= ID3D11DeviceContext_GetData(context
, timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
),
5887 D3D11_ASYNC_GETDATA_DONOTFLUSH
);
5888 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5889 ok(disjoint
.Frequency
== prev_disjoint
.Frequency
, "Frequency data mismatch.\n");
5890 ok(disjoint
.Disjoint
== prev_disjoint
.Disjoint
, "Disjoint data mismatch.\n");
5892 memset(×tamp
, 0xff, sizeof(timestamp
));
5893 hr
= ID3D11DeviceContext_GetData(context
, timestamp_query
, NULL
, 0, 0);
5894 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5895 hr
= ID3D11DeviceContext_GetData(context
, timestamp_query
, ×tamp
, sizeof(timestamp
), 0);
5896 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5897 ok(timestamp
== ~(UINT64
)0, "Timestamp data was modified.\n");
5899 /* Test a TIMESTAMP query inside a TIMESTAMP_DISJOINT query. */
5900 ID3D11DeviceContext_Begin(context
, timestamp_disjoint_query
);
5902 memset(×tamp
, 0xff, sizeof(timestamp
));
5903 hr
= ID3D11DeviceContext_GetData(context
, timestamp_query
, ×tamp
, sizeof(timestamp
), 0);
5904 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5905 ok(timestamp
== ~(UINT64
)0, "Timestamp data was modified.\n");
5907 draw_color_quad(&test_context
, &red
);
5909 ID3D11DeviceContext_End(context
, timestamp_query
);
5910 get_query_data(context
, timestamp_query
, ×tamp
, sizeof(timestamp
));
5912 timestamp
= 0xdeadbeef;
5913 hr
= ID3D11DeviceContext_GetData(context
, timestamp_query
, ×tamp
, sizeof(timestamp
) / 2, 0);
5914 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5915 ok(timestamp
== 0xdeadbeef, "Timestamp was modified.\n");
5917 hr
= ID3D11DeviceContext_GetData(context
, timestamp_query
, ×tamp
, sizeof(timestamp
), 0);
5918 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5919 ok(timestamp
!= 0xdeadbeef, "Timestamp was not modified.\n");
5921 timestamp
= 0xdeadbeef;
5922 hr
= ID3D11DeviceContext_GetData(context
, timestamp_query
, ×tamp
, sizeof(timestamp
) - 1, 0);
5923 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5924 hr
= ID3D11DeviceContext_GetData(context
, timestamp_query
, ×tamp
, sizeof(timestamp
) + 1, 0);
5925 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5926 hr
= ID3D11DeviceContext_GetData(context
, timestamp_query
, ×tamp
, sizeof(timestamp
) / 2, 0);
5927 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5928 hr
= ID3D11DeviceContext_GetData(context
, timestamp_query
, ×tamp
, sizeof(timestamp
) * 2, 0);
5929 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5930 ok(timestamp
== 0xdeadbeef, "Timestamp was modified.\n");
5932 ID3D11DeviceContext_End(context
, timestamp_disjoint_query
);
5933 get_query_data(context
, timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
));
5934 disjoint
.Frequency
= 0xdeadbeef;
5935 disjoint
.Disjoint
= 0xff;
5936 hr
= ID3D11DeviceContext_GetData(context
, timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
), 0);
5937 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5938 ok(disjoint
.Frequency
!= 0xdeadbeef, "Frequency data was not modified.\n");
5939 ok(disjoint
.Disjoint
== TRUE
|| disjoint
.Disjoint
== FALSE
, "Got unexpected disjoint %#x.\n", disjoint
.Disjoint
);
5941 /* It's not strictly necessary for the TIMESTAMP query to be inside a TIMESTAMP_DISJOINT query. */
5942 ID3D11Asynchronous_Release(timestamp_query
);
5943 query_desc
.Query
= D3D11_QUERY_TIMESTAMP
;
5944 query_desc
.MiscFlags
= 0;
5945 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, (ID3D11Query
**)×tamp_query
);
5946 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5948 draw_color_quad(&test_context
, &red
);
5950 ID3D11DeviceContext_End(context
, timestamp_query
);
5951 get_query_data(context
, timestamp_query
, ×tamp
, sizeof(timestamp
));
5953 ID3D11Asynchronous_Release(timestamp_query
);
5954 ID3D11Asynchronous_Release(timestamp_disjoint_query
);
5955 release_test_context(&test_context
);
5958 static void test_so_statistics_query(void)
5960 struct d3d11_test_context test_context
;
5961 D3D11_QUERY_DATA_SO_STATISTICS data
;
5962 ID3D11DeviceContext
*context
;
5963 unsigned int vertex_count
[4];
5964 D3D11_QUERY_DESC query_desc
;
5965 ID3D11Buffer
*so_buffer
[4];
5966 ID3D11Asynchronous
*query
;
5967 ID3D11GeometryShader
*gs
;
5968 ID3D11VertexShader
*vs
;
5969 unsigned int data_size
;
5970 ID3D11Device
*device
;
5975 static const DWORD vs_code
[] =
5978 float4
main(uint id
: SV_VertexID
) : custom
5983 0x43425844, 0x8b0e47b9, 0x6efc9512, 0xd55ca6ff, 0x487c5ef2, 0x00000001, 0x000000d4, 0x00000003,
5984 0x0000002c, 0x00000060, 0x00000090, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
5985 0x00000000, 0x00000006, 0x00000001, 0x00000000, 0x00000101, 0x565f5653, 0x65747265, 0x00444978,
5986 0x4e47534f, 0x00000028, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
5987 0x00000000, 0x0000000f, 0x74737563, 0xab006d6f, 0x52444853, 0x0000003c, 0x00010040, 0x0000000f,
5988 0x04000060, 0x00101012, 0x00000000, 0x00000006, 0x03000065, 0x001020f2, 0x00000000, 0x05000056,
5989 0x001020f2, 0x00000000, 0x00101006, 0x00000000, 0x0100003e,
5991 static const DWORD gs_code
[] =
5996 float4 data
: custom
;
6001 [maxvertexcount(32)]
6002 void main(point vertex input
[1], uint id
: SV_PrimitiveID
,
6003 inout PointStream
<vertex
> output0
,
6004 inout PointStream
<vertex
> output1
,
6005 inout PointStream
<vertex
> output2
,
6006 inout PointStream
<vertex
> output3
)
6008 if (id
< vertex_count
.x
)
6009 output0
.Append(input
[0]);
6010 if (id
< vertex_count
.y
)
6011 output1
.Append(input
[0]);
6012 if (id
< vertex_count
.z
)
6013 output2
.Append(input
[0]);
6014 if (id
< vertex_count
.w
)
6015 output3
.Append(input
[0]);
6018 0x43425844, 0xd616829d, 0x4355ce2a, 0xd71909e5, 0xdc916d4c, 0x00000001, 0x000002bc, 0x00000003,
6019 0x0000002c, 0x00000084, 0x0000010c, 0x4e475349, 0x00000050, 0x00000002, 0x00000008, 0x00000038,
6020 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x0000003f, 0x00000000, 0x00000007,
6021 0x00000001, 0xffffffff, 0x00000101, 0x74737563, 0x53006d6f, 0x72505f56, 0x74696d69, 0x49657669,
6022 0xabab0044, 0x3547534f, 0x00000080, 0x00000004, 0x00000008, 0x00000000, 0x00000078, 0x00000000,
6023 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x00000001, 0x00000078, 0x00000000, 0x00000000,
6024 0x00000003, 0x00000000, 0x0000000f, 0x00000002, 0x00000078, 0x00000000, 0x00000000, 0x00000003,
6025 0x00000000, 0x0000000f, 0x00000003, 0x00000078, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
6026 0x0000000f, 0x74737563, 0xab006d6f, 0x58454853, 0x000001a8, 0x00020050, 0x0000006a, 0x0100086a,
6027 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0400005f, 0x002010f2, 0x00000001, 0x00000000,
6028 0x0200005f, 0x0000b000, 0x02000068, 0x00000001, 0x0100085d, 0x0300008f, 0x00110000, 0x00000000,
6029 0x0100085c, 0x03000065, 0x001020f2, 0x00000000, 0x0300008f, 0x00110000, 0x00000001, 0x0100085c,
6030 0x03000065, 0x001020f2, 0x00000000, 0x0300008f, 0x00110000, 0x00000002, 0x0100085c, 0x03000065,
6031 0x001020f2, 0x00000000, 0x0300008f, 0x00110000, 0x00000003, 0x0100085c, 0x03000065, 0x001020f2,
6032 0x00000000, 0x0200005e, 0x00000020, 0x0700004f, 0x001000f2, 0x00000000, 0x0000b001, 0x00208e46,
6033 0x00000000, 0x00000000, 0x0304001f, 0x0010000a, 0x00000000, 0x06000036, 0x001020f2, 0x00000000,
6034 0x00201e46, 0x00000000, 0x00000000, 0x03000075, 0x00110000, 0x00000000, 0x01000015, 0x0304001f,
6035 0x0010001a, 0x00000000, 0x06000036, 0x001020f2, 0x00000000, 0x00201e46, 0x00000000, 0x00000000,
6036 0x03000075, 0x00110000, 0x00000001, 0x01000015, 0x0304001f, 0x0010002a, 0x00000000, 0x06000036,
6037 0x001020f2, 0x00000000, 0x00201e46, 0x00000000, 0x00000000, 0x03000075, 0x00110000, 0x00000002,
6038 0x01000015, 0x0304001f, 0x0010003a, 0x00000000, 0x06000036, 0x001020f2, 0x00000000, 0x00201e46,
6039 0x00000000, 0x00000000, 0x03000075, 0x00110000, 0x00000003, 0x01000015, 0x0100003e,
6041 static const D3D11_SO_DECLARATION_ENTRY so_declaration
[] =
6043 {0, "custom", 0, 0, 4, 0},
6044 {1, "custom", 0, 0, 4, 1},
6045 {2, "custom", 0, 0, 4, 2},
6046 {3, "custom", 0, 0, 4, 3},
6048 static const unsigned int offset
[4] = {0};
6053 D3D_FEATURE_LEVEL feature_level
;
6057 {D3D11_QUERY_SO_STATISTICS
, D3D_FEATURE_LEVEL_10_0
},
6058 {D3D11_QUERY_SO_STATISTICS_STREAM0
, D3D_FEATURE_LEVEL_11_0
},
6059 {D3D11_QUERY_SO_STATISTICS_STREAM1
, D3D_FEATURE_LEVEL_11_0
},
6060 {D3D11_QUERY_SO_STATISTICS_STREAM2
, D3D_FEATURE_LEVEL_11_0
},
6061 {D3D11_QUERY_SO_STATISTICS_STREAM3
, D3D_FEATURE_LEVEL_11_0
},
6064 if (!init_test_context(&test_context
, NULL
))
6067 device
= test_context
.device
;
6068 context
= test_context
.immediate_context
;
6070 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
6072 if (ID3D11Device_GetFeatureLevel(device
) < tests
[i
].feature_level
)
6074 skip("Feature level %#x is required.\n", tests
[i
].feature_level
);
6078 query_desc
.Query
= tests
[i
].query
;
6079 query_desc
.MiscFlags
= 0;
6080 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, (ID3D11Query
**)&query
);
6081 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6082 data_size
= ID3D11Asynchronous_GetDataSize(query
);
6083 ok(data_size
== sizeof(data
), "Got unexpected data size %u.\n", data_size
);
6085 hr
= ID3D11DeviceContext_GetData(context
, query
, NULL
, 0, 0);
6086 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
6087 hr
= ID3D11DeviceContext_GetData(context
, query
, &data
, sizeof(data
), 0);
6088 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
6090 ID3D11DeviceContext_End(context
, query
);
6091 ID3D11DeviceContext_Begin(context
, query
);
6092 ID3D11DeviceContext_Begin(context
, query
);
6094 memset(&data
, 0xff, sizeof(data
));
6095 hr
= ID3D11DeviceContext_GetData(context
, query
, NULL
, 0, 0);
6096 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
6097 hr
= ID3D11DeviceContext_GetData(context
, query
, &data
, sizeof(data
), 0);
6098 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
6099 ok(data
.NumPrimitivesWritten
== ~(UINT64
)0, "Data was modified.\n");
6100 ok(data
.PrimitivesStorageNeeded
== ~(UINT64
)0, "Data was modified.\n");
6102 draw_quad(&test_context
);
6104 ID3D11DeviceContext_End(context
, query
);
6105 get_query_data(context
, query
, &data
, sizeof(data
));
6106 ok(!data
.NumPrimitivesWritten
, "Got unexpected NumPrimitivesWritten: %u.\n",
6107 (unsigned int)data
.NumPrimitivesWritten
);
6108 todo_wine_if(query_desc
.Query
== D3D11_QUERY_SO_STATISTICS
|| query_desc
.Query
== D3D11_QUERY_SO_STATISTICS_STREAM0
)
6109 ok(!data
.PrimitivesStorageNeeded
, "Got unexpected PrimitivesStorageNeeded: %u.\n",
6110 (unsigned int)data
.PrimitivesStorageNeeded
);
6112 ID3D11DeviceContext_Begin(context
, query
);
6113 draw_quad(&test_context
);
6114 ID3D11DeviceContext_End(context
, query
);
6115 get_query_data(context
, query
, &data
, sizeof(data
));
6116 ok(!data
.NumPrimitivesWritten
, "Got unexpected NumPrimitivesWritten: %u.\n",
6117 (unsigned int)data
.NumPrimitivesWritten
);
6118 todo_wine_if(query_desc
.Query
== D3D11_QUERY_SO_STATISTICS
|| query_desc
.Query
== D3D11_QUERY_SO_STATISTICS_STREAM0
)
6119 ok(!data
.PrimitivesStorageNeeded
, "Got unexpected PrimitivesStorageNeeded: %u.\n",
6120 (unsigned int)data
.PrimitivesStorageNeeded
);
6122 ID3D11Asynchronous_Release(query
);
6125 if (ID3D11Device_GetFeatureLevel(device
) < D3D_FEATURE_LEVEL_11_0
)
6127 skip("Vertex streams are not supported.\n");
6131 /* multiple vertex streams */
6132 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
6133 ok(hr
== S_OK
, "Failed to create vertex shader, hr %#x.\n", hr
);
6134 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
6136 hr
= ID3D11Device_CreateGeometryShaderWithStreamOutput(device
, gs_code
, sizeof(gs_code
),
6137 so_declaration
, ARRAY_SIZE(so_declaration
),
6138 NULL
, 0, D3D11_SO_NO_RASTERIZED_STREAM
, NULL
, &gs
);
6140 ok(hr
== S_OK
, "Failed to create geometry shader with stream output, hr %#x.\n", hr
);
6143 ID3D11VertexShader_Release(vs
);
6146 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
6148 for (i
= 0; i
< ARRAY_SIZE(vertex_count
); ++i
)
6149 vertex_count
[i
] = 5;
6150 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(vertex_count
), vertex_count
);
6151 ID3D11DeviceContext_GSSetConstantBuffers(context
, 0, 1, &cb
);
6153 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST
);
6155 query_desc
.Query
= D3D11_QUERY_SO_STATISTICS
;
6156 query_desc
.MiscFlags
= 0;
6157 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, (ID3D11Query
**)&query
);
6158 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6160 ID3D11DeviceContext_Begin(context
, query
);
6161 ID3D11DeviceContext_Draw(context
, 5, 0);
6162 ID3D11DeviceContext_End(context
, query
);
6164 memset(&data
, 0xff, sizeof(data
));
6165 get_query_data(context
, query
, &data
, sizeof(data
));
6166 ok(!data
.NumPrimitivesWritten
, "Got unexpected primitives written %u.\n",
6167 (unsigned int)data
.NumPrimitivesWritten
);
6168 ok(data
.PrimitivesStorageNeeded
== 5, "Got unexpected primitives storage needed %u.\n",
6169 (unsigned int)data
.PrimitivesStorageNeeded
);
6171 for (i
= 0; i
< ARRAY_SIZE(so_buffer
); ++i
)
6172 so_buffer
[i
] = create_buffer(device
, D3D11_BIND_STREAM_OUTPUT
, sizeof(struct vec4
) * 10, NULL
);
6174 ID3D11DeviceContext_SOSetTargets(context
, D3D11_SO_BUFFER_SLOT_COUNT
, so_buffer
, offset
);
6175 ID3D11DeviceContext_Begin(context
, query
);
6176 ID3D11DeviceContext_Draw(context
, 16, 0);
6177 ID3D11DeviceContext_End(context
, query
);
6178 memset(&data
, 0xff, sizeof(data
));
6179 get_query_data(context
, query
, &data
, sizeof(data
));
6180 ok(data
.NumPrimitivesWritten
== 5, "Got unexpected primitives written %u.\n",
6181 (unsigned int)data
.NumPrimitivesWritten
);
6182 ok(data
.PrimitivesStorageNeeded
== 5, "Got unexpected primitives storage needed %u.\n",
6183 (unsigned int)data
.PrimitivesStorageNeeded
);
6185 vertex_count
[0] = 3;
6186 vertex_count
[1] = 6;
6187 vertex_count
[2] = 4;
6188 vertex_count
[3] = 12;
6189 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, vertex_count
, 0, 0);
6191 ID3D11DeviceContext_SOSetTargets(context
, D3D11_SO_BUFFER_SLOT_COUNT
, so_buffer
, offset
);
6192 ID3D11DeviceContext_Begin(context
, query
);
6193 ID3D11DeviceContext_Draw(context
, 32, 0);
6194 ID3D11DeviceContext_End(context
, query
);
6195 memset(&data
, 0xff, sizeof(data
));
6196 get_query_data(context
, query
, &data
, sizeof(data
));
6197 ok(data
.NumPrimitivesWritten
== 3, "Got unexpected primitives written %u.\n",
6198 (unsigned int)data
.NumPrimitivesWritten
);
6199 ok(data
.PrimitivesStorageNeeded
== 3, "Got unexpected primitives storage needed %u.\n",
6200 (unsigned int)data
.PrimitivesStorageNeeded
);
6202 vertex_count
[0] = 16;
6203 vertex_count
[1] = 6;
6204 vertex_count
[2] = 4;
6205 vertex_count
[3] = 12;
6206 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, vertex_count
, 0, 0);
6208 ID3D11DeviceContext_SOSetTargets(context
, D3D11_SO_BUFFER_SLOT_COUNT
, so_buffer
, offset
);
6209 ID3D11DeviceContext_Begin(context
, query
);
6210 ID3D11DeviceContext_Draw(context
, 32, 0);
6211 ID3D11DeviceContext_End(context
, query
);
6212 memset(&data
, 0xff, sizeof(data
));
6213 get_query_data(context
, query
, &data
, sizeof(data
));
6214 ok(data
.NumPrimitivesWritten
== 10, "Got unexpected primitives written %u.\n",
6215 (unsigned int)data
.NumPrimitivesWritten
);
6216 ok(data
.PrimitivesStorageNeeded
== 16, "Got unexpected primitives storage needed %u.\n",
6217 (unsigned int)data
.PrimitivesStorageNeeded
);
6219 ID3D11Asynchronous_Release(query
);
6221 for (i
= 0; i
< ARRAY_SIZE(so_buffer
); ++i
)
6222 ID3D11Buffer_Release(so_buffer
[i
]);
6223 ID3D11Buffer_Release(cb
);
6224 ID3D11GeometryShader_Release(gs
);
6225 ID3D11VertexShader_Release(vs
);
6228 release_test_context(&test_context
);
6231 static void test_device_removed_reason(void)
6233 ID3D11Device
*device
;
6237 if (!(device
= create_device(NULL
)))
6239 skip("Failed to create device.\n");
6243 hr
= ID3D11Device_GetDeviceRemovedReason(device
);
6244 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6245 hr
= ID3D11Device_GetDeviceRemovedReason(device
);
6246 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6248 refcount
= ID3D11Device_Release(device
);
6249 ok(!refcount
, "Device has %u references left.\n", refcount
);
6252 static void test_private_data(void)
6254 ULONG refcount
, expected_refcount
;
6255 D3D11_TEXTURE2D_DESC texture_desc
;
6256 ID3D10Texture2D
*d3d10_texture
;
6257 ID3D11Device
*test_object
;
6258 ID3D11Texture2D
*texture
;
6259 IDXGIDevice
*dxgi_device
;
6260 IDXGISurface
*surface
;
6261 ID3D11Device
*device
;
6266 static const GUID test_guid
=
6267 {0xfdb37466, 0x428f, 0x4edf, {0xa3, 0x7f, 0x9b, 0x1d, 0xf4, 0x88, 0xc5, 0xfc}};
6268 static const GUID test_guid2
=
6269 {0x2e5afac2, 0x87b5, 0x4c10, {0x9b, 0x4b, 0x89, 0xd7, 0xd1, 0x12, 0xe7, 0x2b}};
6270 static const DWORD data
[] = {1, 2, 3, 4};
6272 if (!(device
= create_device(NULL
)))
6274 skip("Failed to create device.\n");
6278 test_object
= create_device(NULL
);
6280 texture_desc
.Width
= 512;
6281 texture_desc
.Height
= 512;
6282 texture_desc
.MipLevels
= 1;
6283 texture_desc
.ArraySize
= 1;
6284 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
6285 texture_desc
.SampleDesc
.Count
= 1;
6286 texture_desc
.SampleDesc
.Quality
= 0;
6287 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
6288 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
6289 texture_desc
.CPUAccessFlags
= 0;
6290 texture_desc
.MiscFlags
= 0;
6292 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
6293 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
6294 hr
= ID3D11Texture2D_QueryInterface(texture
, &IID_IDXGISurface
, (void **)&surface
);
6295 ok(SUCCEEDED(hr
), "Failed to get IDXGISurface, hr %#x.\n", hr
);
6297 hr
= ID3D11Device_SetPrivateData(device
, &test_guid
, 0, NULL
);
6298 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
6299 hr
= ID3D11Device_SetPrivateDataInterface(device
, &test_guid
, NULL
);
6300 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6301 hr
= ID3D11Device_SetPrivateData(device
, &test_guid
, ~0u, NULL
);
6302 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6303 hr
= ID3D11Device_SetPrivateData(device
, &test_guid
, ~0u, NULL
);
6304 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
6306 hr
= ID3D11Device_SetPrivateDataInterface(device
, &test_guid
, NULL
);
6307 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6308 size
= sizeof(ptr
) * 2;
6309 ptr
= (IUnknown
*)0xdeadbeef;
6310 hr
= ID3D11Device_GetPrivateData(device
, &test_guid
, &size
, &ptr
);
6311 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6312 ok(!ptr
, "Got unexpected pointer %p.\n", ptr
);
6313 ok(size
== sizeof(IUnknown
*), "Got unexpected size %u.\n", size
);
6315 hr
= ID3D11Device_QueryInterface(device
, &IID_IDXGIDevice
, (void **)&dxgi_device
);
6316 ok(SUCCEEDED(hr
), "Failed to get DXGI device, hr %#x.\n", hr
);
6317 size
= sizeof(ptr
) * 2;
6318 ptr
= (IUnknown
*)0xdeadbeef;
6319 hr
= IDXGIDevice_GetPrivateData(dxgi_device
, &test_guid
, &size
, &ptr
);
6320 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6321 ok(!ptr
, "Got unexpected pointer %p.\n", ptr
);
6322 ok(size
== sizeof(IUnknown
*), "Got unexpected size %u.\n", size
);
6323 IDXGIDevice_Release(dxgi_device
);
6325 refcount
= get_refcount(test_object
);
6326 hr
= ID3D11Device_SetPrivateDataInterface(device
, &test_guid
, (IUnknown
*)test_object
);
6327 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6328 expected_refcount
= refcount
+ 1;
6329 refcount
= get_refcount(test_object
);
6330 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
6331 hr
= ID3D11Device_SetPrivateDataInterface(device
, &test_guid
, (IUnknown
*)test_object
);
6332 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6333 refcount
= get_refcount(test_object
);
6334 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
6336 hr
= ID3D11Device_SetPrivateDataInterface(device
, &test_guid
, NULL
);
6337 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6338 --expected_refcount
;
6339 refcount
= get_refcount(test_object
);
6340 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
6342 hr
= ID3D11Device_SetPrivateDataInterface(device
, &test_guid
, (IUnknown
*)test_object
);
6343 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6344 size
= sizeof(data
);
6345 hr
= ID3D11Device_SetPrivateData(device
, &test_guid
, size
, data
);
6346 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6347 refcount
= get_refcount(test_object
);
6348 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
6349 hr
= ID3D11Device_SetPrivateData(device
, &test_guid
, 42, NULL
);
6350 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6351 hr
= ID3D11Device_SetPrivateData(device
, &test_guid
, 42, NULL
);
6352 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
6354 hr
= ID3D11Device_SetPrivateDataInterface(device
, &test_guid
, (IUnknown
*)test_object
);
6355 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6356 ++expected_refcount
;
6357 size
= 2 * sizeof(ptr
);
6359 hr
= ID3D11Device_GetPrivateData(device
, &test_guid
, &size
, &ptr
);
6360 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6361 ok(size
== sizeof(test_object
), "Got unexpected size %u.\n", size
);
6362 ++expected_refcount
;
6363 refcount
= get_refcount(test_object
);
6364 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
6365 IUnknown_Release(ptr
);
6366 --expected_refcount
;
6368 ptr
= (IUnknown
*)0xdeadbeef;
6370 hr
= ID3D11Device_GetPrivateData(device
, &test_guid
, &size
, NULL
);
6371 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6372 ok(size
== sizeof(device
), "Got unexpected size %u.\n", size
);
6373 size
= 2 * sizeof(ptr
);
6374 hr
= ID3D11Device_GetPrivateData(device
, &test_guid
, &size
, NULL
);
6375 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6376 ok(size
== sizeof(device
), "Got unexpected size %u.\n", size
);
6377 refcount
= get_refcount(test_object
);
6378 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
6381 hr
= ID3D11Device_GetPrivateData(device
, &test_guid
, &size
, &ptr
);
6382 ok(hr
== DXGI_ERROR_MORE_DATA
, "Got unexpected hr %#x.\n", hr
);
6383 ok(size
== sizeof(device
), "Got unexpected size %u.\n", size
);
6384 ok(ptr
== (IUnknown
*)0xdeadbeef, "Got unexpected pointer %p.\n", ptr
);
6385 if (!enable_debug_layer
)
6387 hr
= ID3D11Device_GetPrivateData(device
, &test_guid2
, NULL
, NULL
);
6388 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
6390 hr
= ID3D11Device_GetPrivateData(device
, &test_guid2
, &size
, &ptr
);
6391 ok(hr
== DXGI_ERROR_NOT_FOUND
, "Got unexpected hr %#x.\n", hr
);
6392 ok(size
== 0, "Got unexpected size %u.\n", size
);
6393 ok(ptr
== (IUnknown
*)0xdeadbeef, "Got unexpected pointer %p.\n", ptr
);
6394 hr
= ID3D11Device_GetPrivateData(device
, &test_guid
, NULL
, &ptr
);
6395 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
6396 ok(ptr
== (IUnknown
*)0xdeadbeef, "Got unexpected pointer %p.\n", ptr
);
6399 hr
= ID3D11Texture2D_SetPrivateDataInterface(texture
, &test_guid
, (IUnknown
*)test_object
);
6400 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6403 hr
= IDXGISurface_GetPrivateData(surface
, &test_guid
, &size
, &ptr
);
6404 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6405 ok(ptr
== (IUnknown
*)test_object
, "Got unexpected ptr %p, expected %p.\n", ptr
, test_object
);
6406 IUnknown_Release(ptr
);
6408 hr
= ID3D11Texture2D_QueryInterface(texture
, &IID_ID3D10Texture2D
, (void **)&d3d10_texture
);
6409 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
6410 "Texture should implement ID3D10Texture2D.\n");
6415 hr
= ID3D10Texture2D_GetPrivateData(d3d10_texture
, &test_guid
, &size
, &ptr
);
6416 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6417 ok(ptr
== (IUnknown
*)test_object
, "Got unexpected ptr %p, expected %p.\n", ptr
, test_object
);
6418 IUnknown_Release(ptr
);
6419 ID3D10Texture2D_Release(d3d10_texture
);
6422 IDXGISurface_Release(surface
);
6423 ID3D11Texture2D_Release(texture
);
6424 refcount
= ID3D11Device_Release(device
);
6425 ok(!refcount
, "Device has %u references left.\n", refcount
);
6426 refcount
= ID3D11Device_Release(test_object
);
6427 ok(!refcount
, "Test object has %u references left.\n", refcount
);
6430 static void test_state_refcounting(const D3D_FEATURE_LEVEL feature_level
)
6432 ID3D11RasterizerState
*rasterizer_state
, *tmp_rasterizer_state
;
6433 ID3D11Predicate
*predicate
, *tmp_predicate
;
6434 ID3D11SamplerState
*sampler
, *tmp_sampler
;
6435 ID3D11ShaderResourceView
*srv
, *tmp_srv
;
6436 ID3D11RenderTargetView
*rtv
, *tmp_rtv
;
6437 D3D11_RASTERIZER_DESC rasterizer_desc
;
6438 D3D11_TEXTURE2D_DESC texture_desc
;
6439 D3D11_QUERY_DESC predicate_desc
;
6440 D3D11_SAMPLER_DESC sampler_desc
;
6441 struct device_desc device_desc
;
6442 ID3D11DeviceContext
*context
;
6443 ID3D11Texture2D
*texture
;
6444 ID3D11Device
*device
;
6448 device_desc
.feature_level
= &feature_level
;
6449 device_desc
.flags
= 0;
6450 if (!(device
= create_device(&device_desc
)))
6452 skip("Failed to create device for feature level %#x.\n", feature_level
);
6456 ID3D11Device_GetImmediateContext(device
, &context
);
6458 /* ID3D11SamplerState */
6459 memset(&sampler_desc
, 0, sizeof(sampler_desc
));
6460 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_LINEAR
;
6461 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_WRAP
;
6462 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_WRAP
;
6463 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_WRAP
;
6464 sampler_desc
.MaxLOD
= FLT_MAX
;
6465 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler
);
6466 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
6468 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &tmp_sampler
);
6469 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
6470 ok(tmp_sampler
== sampler
, "Got sampler %p, expected %p.\n", tmp_sampler
, sampler
);
6471 ID3D11SamplerState_Release(tmp_sampler
);
6473 tmp_sampler
= sampler
;
6474 refcount
= get_refcount(sampler
);
6475 ok(refcount
== 1, "Got refcount %u, expected 1.\n", refcount
);
6476 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler
);
6477 refcount
= ID3D11SamplerState_Release(sampler
);
6478 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6480 ID3D11DeviceContext_PSGetSamplers(context
, 0, 1, &sampler
);
6481 ok(sampler
== tmp_sampler
, "Got sampler %p, expected %p.\n", sampler
, tmp_sampler
);
6482 refcount
= ID3D11SamplerState_Release(sampler
);
6483 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6485 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &tmp_sampler
);
6486 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
6487 ok(tmp_sampler
== sampler
, "Got sampler %p, expected %p.\n", tmp_sampler
, sampler
);
6488 refcount
= ID3D11SamplerState_Release(tmp_sampler
);
6489 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6491 /* ID3D11RasterizerState */
6492 memset(&rasterizer_desc
, 0, sizeof(rasterizer_desc
));
6493 rasterizer_desc
.FillMode
= D3D11_FILL_SOLID
;
6494 rasterizer_desc
.CullMode
= D3D11_CULL_BACK
;
6495 rasterizer_desc
.DepthClipEnable
= TRUE
;
6496 hr
= ID3D11Device_CreateRasterizerState(device
, &rasterizer_desc
, &rasterizer_state
);
6497 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
6499 ID3D11DeviceContext_RSSetState(context
, rasterizer_state
);
6500 refcount
= ID3D11RasterizerState_Release(rasterizer_state
);
6501 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6502 ID3D11DeviceContext_RSGetState(context
, &tmp_rasterizer_state
);
6503 ok(tmp_rasterizer_state
== rasterizer_state
, "Got rasterizer state %p, expected %p.\n",
6504 tmp_rasterizer_state
, rasterizer_state
);
6505 refcount
= ID3D11RasterizerState_Release(tmp_rasterizer_state
);
6506 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6508 /* ID3D11ShaderResourceView */
6509 memset(&texture_desc
, 0, sizeof(texture_desc
));
6510 texture_desc
.Width
= 32;
6511 texture_desc
.Height
= 32;
6512 texture_desc
.MipLevels
= 1;
6513 texture_desc
.ArraySize
= 1;
6514 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
6515 texture_desc
.SampleDesc
.Count
= 1;
6516 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
6517 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
6518 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
6519 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
6520 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
6521 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
6522 ID3D11Texture2D_Release(texture
);
6524 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
6525 refcount
= ID3D11ShaderResourceView_Release(srv
);
6526 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6527 ID3D11DeviceContext_PSGetShaderResources(context
, 0, 1, &tmp_srv
);
6528 ok(tmp_srv
== srv
, "Got SRV %p, expected %p.\n", tmp_srv
, srv
);
6529 refcount
= ID3D11ShaderResourceView_Release(tmp_srv
);
6530 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6532 /* ID3D11RenderTargetView */
6533 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
6534 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
6535 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
6536 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
6537 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
6538 ID3D11Texture2D_Release(texture
);
6540 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
6541 refcount
= ID3D11RenderTargetView_Release(rtv
);
6542 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6543 ID3D11DeviceContext_OMGetRenderTargets(context
, 1, &tmp_rtv
, NULL
);
6544 ok(tmp_rtv
== rtv
, "Got RTV %p, expected %p.\n", tmp_rtv
, rtv
);
6545 refcount
= ID3D11RenderTargetView_Release(tmp_rtv
);
6546 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6548 /* ID3D11Predicate */
6549 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
6551 predicate_desc
.Query
= D3D11_QUERY_OCCLUSION_PREDICATE
;
6552 predicate_desc
.MiscFlags
= 0;
6553 hr
= ID3D11Device_CreatePredicate(device
, &predicate_desc
, &predicate
);
6554 ok(SUCCEEDED(hr
), "Failed to create predicate, hr %#x.\n", hr
);
6556 ID3D11DeviceContext_SetPredication(context
, predicate
, TRUE
);
6557 refcount
= ID3D11Predicate_Release(predicate
);
6558 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6559 ID3D11DeviceContext_GetPredication(context
, &tmp_predicate
, NULL
);
6560 ok(tmp_predicate
== predicate
, "Got predicate %p, expected %p.\n", tmp_predicate
, predicate
);
6561 refcount
= ID3D11Predicate_Release(tmp_predicate
);
6562 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6565 ID3D11DeviceContext_Release(context
);
6566 refcount
= ID3D11Device_Release(device
);
6567 ok(!refcount
, "Device has %u references left.\n", refcount
);
6570 static void test_device_context_state(void)
6572 ID3DDeviceContextState
*context_state
, *previous_context_state
;
6573 ID3D11SamplerState
*sampler
, *tmp_sampler
;
6574 ID3D11DeviceContext1
*context
= NULL
;
6575 D3D11_SAMPLER_DESC sampler_desc
;
6576 D3D_FEATURE_LEVEL feature_level
;
6577 ID3D11Device
*d3d11_device
;
6578 ID3D11Device1
*device
;
6582 if (!(d3d11_device
= create_device(NULL
)))
6584 skip("Failed to create device.\n");
6588 hr
= ID3D11Device_QueryInterface(d3d11_device
, &IID_ID3D11Device1
, (void **)&device
);
6589 ID3D11Device_Release(d3d11_device
);
6592 skip("ID3D11Device1 is not available.\n");
6596 todo_wine
check_interface(device
, &IID_ID3D10Device
, FALSE
, FALSE
);
6597 todo_wine
check_interface(device
, &IID_ID3D10Device1
, FALSE
, FALSE
);
6599 feature_level
= ID3D11Device1_GetFeatureLevel(device
);
6600 ID3D11Device1_GetImmediateContext1(device
, &context
);
6601 ok(!!context
, "Failed to get immediate context.\n");
6603 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_LINEAR
;
6604 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_WRAP
;
6605 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_WRAP
;
6606 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_WRAP
;
6607 sampler_desc
.MipLODBias
= 0.0f
;
6608 sampler_desc
.MaxAnisotropy
= 0;
6609 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_ALWAYS
;
6610 sampler_desc
.BorderColor
[0] = 0.0f
;
6611 sampler_desc
.BorderColor
[1] = 1.0f
;
6612 sampler_desc
.BorderColor
[2] = 0.0f
;
6613 sampler_desc
.BorderColor
[3] = 1.0f
;
6614 sampler_desc
.MinLOD
= 0.0f
;
6615 sampler_desc
.MaxLOD
= 16.0f
;
6616 hr
= ID3D11Device1_CreateSamplerState(device
, &sampler_desc
, &sampler
);
6617 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
6619 ID3D11DeviceContext1_PSSetSamplers(context
, 0, 1, &sampler
);
6621 ID3D11DeviceContext1_PSGetSamplers(context
, 0, 1, &tmp_sampler
);
6622 ok(tmp_sampler
== sampler
, "Got sampler %p, expected %p.\n", tmp_sampler
, sampler
);
6623 ID3D11SamplerState_Release(tmp_sampler
);
6625 feature_level
= min(feature_level
, D3D_FEATURE_LEVEL_10_1
);
6626 hr
= ID3D11Device1_CreateDeviceContextState(device
, 0, &feature_level
, 1, D3D11_SDK_VERSION
,
6627 &IID_ID3D10Device
, NULL
, &context_state
);
6629 ok(SUCCEEDED(hr
), "Failed to create device context state, hr %#x.\n", hr
);
6632 ID3D11SamplerState_Release(sampler
);
6633 ID3D11Device1_Release(device
);
6636 refcount
= get_refcount(context_state
);
6637 ok(refcount
== 1, "Got refcount %u, expected 1.\n", refcount
);
6639 /* Enable ID3D10Device behavior. */
6640 previous_context_state
= NULL
;
6641 ID3D11DeviceContext1_SwapDeviceContextState(context
, context_state
, &previous_context_state
);
6642 refcount
= ID3DDeviceContextState_Release(context_state
);
6643 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6645 ID3D11DeviceContext1_PSSetSamplers(context
, 0, 1, &sampler
);
6646 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
6647 ID3D11DeviceContext1_PSGetSamplers(context
, 0, 1, &tmp_sampler
);
6648 ok(tmp_sampler
== (ID3D11SamplerState
*)0xdeadbeef, "Got unexpected sampler %p.\n", tmp_sampler
);
6649 if (!enable_debug_layer
)
6650 ID3D11DeviceContext1_PSSetSamplers(context
, 0, 1, &tmp_sampler
);
6652 check_interface(device
, &IID_ID3D10Device
, TRUE
, FALSE
);
6653 check_interface(device
, &IID_ID3D10Device1
, TRUE
, FALSE
);
6655 ID3D11DeviceContext1_SwapDeviceContextState(context
, previous_context_state
, &context_state
);
6656 refcount
= ID3DDeviceContextState_Release(context_state
);
6657 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6658 refcount
= ID3DDeviceContextState_Release(previous_context_state
);
6659 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6661 /* ID3DDeviceContextState retains the previous state. */
6663 ID3D11DeviceContext1_PSGetSamplers(context
, 0, 1, &tmp_sampler
);
6664 ok(tmp_sampler
== sampler
, "Got sampler %p, expected %p.\n", tmp_sampler
, sampler
);
6665 ID3D11SamplerState_Release(tmp_sampler
);
6668 ID3D11DeviceContext1_PSSetSamplers(context
, 0, 1, &tmp_sampler
);
6669 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
6670 ID3D11DeviceContext1_PSGetSamplers(context
, 0, 1, &tmp_sampler
);
6671 ok(!tmp_sampler
, "Got unexpected sampler %p.\n", tmp_sampler
);
6672 ID3D11DeviceContext1_PSSetSamplers(context
, 0, 1, &sampler
);
6674 ID3D11DeviceContext1_PSGetSamplers(context
, 0, 1, &tmp_sampler
);
6675 ok(tmp_sampler
== sampler
, "Got sampler %p, expected %p.\n", tmp_sampler
, sampler
);
6676 ID3D11SamplerState_Release(tmp_sampler
);
6678 check_interface(device
, &IID_ID3D10Device
, TRUE
, FALSE
);
6679 check_interface(device
, &IID_ID3D10Device1
, TRUE
, FALSE
);
6681 ID3D11SamplerState_Release(sampler
);
6682 ID3D11DeviceContext1_Release(context
);
6683 refcount
= ID3D11Device1_Release(device
);
6684 ok(!refcount
, "Device has %u references left.\n", refcount
);
6687 static void test_blend(void)
6689 ID3D11BlendState
*src_blend
, *dst_blend
, *dst_blend_factor
;
6690 struct d3d11_test_context test_context
;
6691 ID3D11RenderTargetView
*offscreen_rtv
;
6692 D3D11_TEXTURE2D_DESC texture_desc
;
6693 ID3D11InputLayout
*input_layout
;
6694 ID3D11DeviceContext
*context
;
6695 D3D11_BLEND_DESC blend_desc
;
6696 unsigned int stride
, offset
;
6697 ID3D11Texture2D
*offscreen
;
6698 ID3D11VertexShader
*vs
;
6699 ID3D11PixelShader
*ps
;
6700 ID3D11Device
*device
;
6705 static const DWORD vs_code
[] =
6710 float4 position
: SV_POSITION
;
6711 float4 color
: COLOR
;
6714 struct vs_out
main(float4 position
: POSITION
, float4 color
: COLOR
)
6718 o
.position
= position
;
6724 0x43425844, 0x5c73b061, 0x5c71125f, 0x3f8b345f, 0xce04b9ab, 0x00000001, 0x00000140, 0x00000003,
6725 0x0000002c, 0x0000007c, 0x000000d0, 0x4e475349, 0x00000048, 0x00000002, 0x00000008, 0x00000038,
6726 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
6727 0x00000003, 0x00000001, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x4e47534f,
6728 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003, 0x00000000,
6729 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x505f5653,
6730 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000068, 0x00010040, 0x0000001a,
6731 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067, 0x001020f2,
6732 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2, 0x00000000,
6733 0x00101e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001, 0x0100003e,
6735 static const DWORD ps_code
[] =
6740 float4 position
: SV_POSITION
;
6741 float4 color
: COLOR
;
6744 float4
main(struct vs_out i
) : SV_TARGET
6749 0x43425844, 0xe2087fa6, 0xa35fbd95, 0x8e585b3f, 0x67890f54, 0x00000001, 0x000000f4, 0x00000003,
6750 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
6751 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
6752 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
6753 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
6754 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040,
6755 0x0000000e, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
6756 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
6760 struct vec3 position
;
6766 {{-1.0f
, -1.0f
, 0.1f
}, 0x4000ff00},
6767 {{-1.0f
, 0.0f
, 0.1f
}, 0x4000ff00},
6768 {{ 1.0f
, -1.0f
, 0.1f
}, 0x4000ff00},
6769 {{ 1.0f
, 0.0f
, 0.1f
}, 0x4000ff00},
6771 {{-1.0f
, 0.0f
, 0.1f
}, 0xc0ff0000},
6772 {{-1.0f
, 1.0f
, 0.1f
}, 0xc0ff0000},
6773 {{ 1.0f
, 0.0f
, 0.1f
}, 0xc0ff0000},
6774 {{ 1.0f
, 1.0f
, 0.1f
}, 0xc0ff0000},
6776 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
6778 {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
6779 {"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, 12, D3D11_INPUT_PER_VERTEX_DATA
, 0},
6781 static const float blend_factor
[] = {0.3f
, 0.4f
, 0.8f
, 0.9f
};
6782 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
6784 if (!init_test_context(&test_context
, NULL
))
6787 device
= test_context
.device
;
6788 context
= test_context
.immediate_context
;
6790 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
6791 vs_code
, sizeof(vs_code
), &input_layout
);
6792 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
6794 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(quads
), quads
);
6796 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
6797 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
6798 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
6799 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
6801 memset(&blend_desc
, 0, sizeof(blend_desc
));
6802 blend_desc
.RenderTarget
[0].BlendEnable
= TRUE
;
6803 blend_desc
.RenderTarget
[0].SrcBlend
= D3D11_BLEND_SRC_ALPHA
;
6804 blend_desc
.RenderTarget
[0].DestBlend
= D3D11_BLEND_INV_SRC_ALPHA
;
6805 blend_desc
.RenderTarget
[0].BlendOp
= D3D11_BLEND_OP_ADD
;
6806 blend_desc
.RenderTarget
[0].SrcBlendAlpha
= D3D11_BLEND_SRC_ALPHA
;
6807 blend_desc
.RenderTarget
[0].DestBlendAlpha
= D3D11_BLEND_INV_SRC_ALPHA
;
6808 blend_desc
.RenderTarget
[0].BlendOpAlpha
= D3D11_BLEND_OP_ADD
;
6809 blend_desc
.RenderTarget
[0].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_ALL
;
6811 hr
= ID3D11Device_CreateBlendState(device
, &blend_desc
, &src_blend
);
6812 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
6814 blend_desc
.RenderTarget
[0].SrcBlend
= D3D11_BLEND_DEST_ALPHA
;
6815 blend_desc
.RenderTarget
[0].DestBlend
= D3D11_BLEND_INV_DEST_ALPHA
;
6816 blend_desc
.RenderTarget
[0].SrcBlendAlpha
= D3D11_BLEND_DEST_ALPHA
;
6817 blend_desc
.RenderTarget
[0].DestBlendAlpha
= D3D11_BLEND_INV_DEST_ALPHA
;
6819 hr
= ID3D11Device_CreateBlendState(device
, &blend_desc
, &dst_blend
);
6820 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
6822 blend_desc
.RenderTarget
[0].SrcBlend
= D3D11_BLEND_BLEND_FACTOR
;
6823 blend_desc
.RenderTarget
[0].DestBlend
= D3D11_BLEND_INV_BLEND_FACTOR
;
6824 blend_desc
.RenderTarget
[0].SrcBlendAlpha
= D3D11_BLEND_DEST_ALPHA
;
6825 blend_desc
.RenderTarget
[0].DestBlendAlpha
= D3D11_BLEND_INV_DEST_ALPHA
;
6827 hr
= ID3D11Device_CreateBlendState(device
, &blend_desc
, &dst_blend_factor
);
6828 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
6830 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
6831 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
6832 stride
= sizeof(*quads
);
6834 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, &stride
, &offset
);
6835 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
6836 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
6838 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
6840 ID3D11DeviceContext_OMSetBlendState(context
, src_blend
, NULL
, D3D11_DEFAULT_SAMPLE_MASK
);
6841 ID3D11DeviceContext_Draw(context
, 4, 0);
6842 ID3D11DeviceContext_OMSetBlendState(context
, dst_blend
, NULL
, D3D11_DEFAULT_SAMPLE_MASK
);
6843 ID3D11DeviceContext_Draw(context
, 4, 4);
6845 color
= get_texture_color(test_context
.backbuffer
, 320, 360);
6846 ok(compare_color(color
, 0x700040bf, 1), "Got unexpected color 0x%08x.\n", color
);
6847 color
= get_texture_color(test_context
.backbuffer
, 320, 120);
6848 ok(compare_color(color
, 0xa080007f, 1), "Got unexpected color 0x%08x.\n", color
);
6850 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
6852 ID3D11DeviceContext_OMSetBlendState(context
, dst_blend_factor
, blend_factor
, D3D11_DEFAULT_SAMPLE_MASK
);
6853 ID3D11DeviceContext_Draw(context
, 4, 0);
6854 ID3D11DeviceContext_Draw(context
, 4, 4);
6856 color
= get_texture_color(test_context
.backbuffer
, 320, 360);
6857 ok(compare_color(color
, 0x600066b3, 1), "Got unexpected color 0x%08x.\n", color
);
6858 color
= get_texture_color(test_context
.backbuffer
, 320, 120);
6859 ok(compare_color(color
, 0xa0cc00b3, 1), "Got unexpected color 0x%08x.\n", color
);
6861 texture_desc
.Width
= 128;
6862 texture_desc
.Height
= 128;
6863 texture_desc
.MipLevels
= 1;
6864 texture_desc
.ArraySize
= 1;
6865 texture_desc
.Format
= DXGI_FORMAT_B8G8R8X8_UNORM
;
6866 texture_desc
.SampleDesc
.Count
= 1;
6867 texture_desc
.SampleDesc
.Quality
= 0;
6868 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
6869 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
| D3D11_BIND_RENDER_TARGET
;
6870 texture_desc
.CPUAccessFlags
= 0;
6871 texture_desc
.MiscFlags
= 0;
6873 /* DXGI_FORMAT_B8G8R8X8_UNORM is not supported on all implementations. */
6874 if (FAILED(ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &offscreen
)))
6876 skip("DXGI_FORMAT_B8G8R8X8_UNORM not supported.\n");
6880 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)offscreen
, NULL
, &offscreen_rtv
);
6881 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
6883 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &offscreen_rtv
, NULL
);
6885 set_viewport(context
, 0.0f
, 0.0f
, 128.0f
, 128.0f
, 0.0f
, 1.0f
);
6887 ID3D11DeviceContext_ClearRenderTargetView(context
, offscreen_rtv
, red
);
6889 ID3D11DeviceContext_OMSetBlendState(context
, src_blend
, NULL
, D3D11_DEFAULT_SAMPLE_MASK
);
6890 ID3D11DeviceContext_Draw(context
, 4, 0);
6891 ID3D11DeviceContext_OMSetBlendState(context
, dst_blend
, NULL
, D3D11_DEFAULT_SAMPLE_MASK
);
6892 ID3D11DeviceContext_Draw(context
, 4, 4);
6894 color
= get_texture_color(offscreen
, 64, 96) & 0x00ffffff;
6895 ok(compare_color(color
, 0x00bf4000, 1), "Got unexpected color 0x%08x.\n", color
);
6896 color
= get_texture_color(offscreen
, 64, 32) & 0x00ffffff;
6897 ok(compare_color(color
, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color
);
6899 ID3D11RenderTargetView_Release(offscreen_rtv
);
6900 ID3D11Texture2D_Release(offscreen
);
6902 ID3D11BlendState_Release(dst_blend_factor
);
6903 ID3D11BlendState_Release(dst_blend
);
6904 ID3D11BlendState_Release(src_blend
);
6905 ID3D11PixelShader_Release(ps
);
6906 ID3D11VertexShader_Release(vs
);
6907 ID3D11Buffer_Release(vb
);
6908 ID3D11InputLayout_Release(input_layout
);
6909 release_test_context(&test_context
);
6912 static void test_texture1d(void)
6922 UINT miplevel_count
;
6925 D3D11_SUBRESOURCE_DATA data
[3];
6928 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
6929 struct d3d11_test_context test_context
;
6930 const struct texture
*current_texture
;
6931 D3D11_TEXTURE1D_DESC texture_desc
;
6932 D3D11_SAMPLER_DESC sampler_desc
;
6933 const struct shader
*current_ps
;
6934 D3D_FEATURE_LEVEL feature_level
;
6935 ID3D11ShaderResourceView
*srv
;
6936 ID3D11DeviceContext
*context
;
6937 ID3D11SamplerState
*sampler
;
6938 struct resource_readback rb
;
6939 ID3D11Texture1D
*texture
;
6940 struct vec4 ps_constant
;
6941 ID3D11PixelShader
*ps
;
6942 ID3D11Device
*device
;
6948 static const DWORD ps_ld_code
[] =
6955 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
6958 t
.GetDimensions(miplevel
, p
.x
, p
.y
);
6960 p
*= float2(position
.x
/ 640.0f
, 1.0f
);
6961 return t
.Load(int2(p
));
6964 0x43425844, 0x7b0c6359, 0x598178f6, 0xef2ddbdb, 0x88fc794c, 0x00000001, 0x000001ac, 0x00000003,
6965 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
6966 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000010f, 0x505f5653, 0x5449534f, 0x004e4f49,
6967 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
6968 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000110, 0x00000040,
6969 0x00000044, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04001058, 0x00107000, 0x00000000,
6970 0x00005555, 0x04002064, 0x00101012, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
6971 0x02000068, 0x00000001, 0x0600001c, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000,
6972 0x0700003d, 0x001000f2, 0x00000000, 0x0010000a, 0x00000000, 0x00107e46, 0x00000000, 0x07000038,
6973 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x0010100a, 0x00000000, 0x06000036, 0x001000e2,
6974 0x00000000, 0x00208006, 0x00000000, 0x00000000, 0x0a000038, 0x001000f2, 0x00000000, 0x00100e46,
6975 0x00000000, 0x00004002, 0x3acccccd, 0x3f800000, 0x3f800000, 0x3f800000, 0x0500001b, 0x001000f2,
6976 0x00000000, 0x00100e46, 0x00000000, 0x0700002d, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
6977 0x00107e46, 0x00000000, 0x0100003e,
6979 static const struct shader ps_ld
= {ps_ld_code
, sizeof(ps_ld_code
)};
6980 static const DWORD ps_ld_sint8_code
[] =
6985 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
6990 p
= float2(position
.x
/ 640.0f
, 0.0f
);
6991 t
.GetDimensions(0, s
.x
, s
.y
);
6994 c
= t
.Load(int2(p
));
6995 return (max(c
/ (float4
)127, (float4
)-1) + (float4
)1) / 2.0f
;
6998 0x43425844, 0x65a13d1e, 0x8a0bfc92, 0xa2f2708a, 0x0bafafb6, 0x00000001, 0x00000234, 0x00000003,
6999 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
7000 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000010f, 0x505f5653, 0x5449534f, 0x004e4f49,
7001 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
7002 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000198, 0x00000040,
7003 0x00000066, 0x04001058, 0x00107000, 0x00000000, 0x00003333, 0x04002064, 0x00101012, 0x00000000,
7004 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x0700003d, 0x001000f2,
7005 0x00000000, 0x00004001, 0x00000000, 0x00107e46, 0x00000000, 0x07000038, 0x00100012, 0x00000001,
7006 0x0010100a, 0x00000000, 0x00004001, 0x3acccccd, 0x08000036, 0x001000e2, 0x00000001, 0x00004002,
7007 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07000038, 0x001000f2, 0x00000000, 0x00100fc6,
7008 0x00000000, 0x00100e46, 0x00000001, 0x0500001b, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
7009 0x0700002d, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00107e46, 0x00000000, 0x0500002b,
7010 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x0a000038, 0x001000f2, 0x00000000, 0x00100e46,
7011 0x00000000, 0x00004002, 0x3c010204, 0x3c010204, 0x3c010204, 0x3c010204, 0x0a000034, 0x001000f2,
7012 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0xbf800000, 0xbf800000, 0xbf800000, 0xbf800000,
7013 0x0a000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3f800000, 0x3f800000,
7014 0x3f800000, 0x3f800000, 0x0a000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002,
7015 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, 0x0100003e,
7017 static const struct shader ps_ld_sint8
= {ps_ld_sint8_code
, sizeof(ps_ld_sint8_code
)};
7018 static const DWORD ps_ld_uint8_code
[] =
7023 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
7027 p
= float2(position
.x
/ 640.0f
, 0.0f
);
7028 t
.GetDimensions(0, s
.x
, s
.y
);
7031 return t
.Load(int2(p
)) / (float4
)255;
7034 0x43425844, 0x35186c1f, 0x55bad4fd, 0xb7c97a57, 0x99c060e7, 0x00000001, 0x000001bc, 0x00000003,
7035 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
7036 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000010f, 0x505f5653, 0x5449534f, 0x004e4f49,
7037 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
7038 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000120, 0x00000040,
7039 0x00000048, 0x04001058, 0x00107000, 0x00000000, 0x00004444, 0x04002064, 0x00101012, 0x00000000,
7040 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x0700003d, 0x001000f2,
7041 0x00000000, 0x00004001, 0x00000000, 0x00107e46, 0x00000000, 0x07000038, 0x00100012, 0x00000001,
7042 0x0010100a, 0x00000000, 0x00004001, 0x3acccccd, 0x08000036, 0x001000e2, 0x00000001, 0x00004002,
7043 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07000038, 0x001000f2, 0x00000000, 0x00100fc6,
7044 0x00000000, 0x00100e46, 0x00000001, 0x0500001b, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
7045 0x0700002d, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00107e46, 0x00000000, 0x05000056,
7046 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x0a000038, 0x001020f2, 0x00000000, 0x00100e46,
7047 0x00000000, 0x00004002, 0x3b808081, 0x3b808081, 0x3b808081, 0x3b808081, 0x0100003e,
7049 static const struct shader ps_ld_uint8
= {ps_ld_uint8_code
, sizeof(ps_ld_uint8_code
)};
7050 static DWORD ps_ld_array_code
[] =
7057 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
7060 t
.GetDimensions(miplevel
, p
.x
, p
.y
, p
.z
);
7063 p
*= float3(position
.x
/ 640.0f
, 1.0f
, 1.0f
);
7064 return t
.Load(int3(p
));
7067 0x43425844, 0xbfccadc4, 0xc00ff13d, 0x2ba75365, 0xf747cbee, 0x00000001, 0x000001c0, 0x00000003,
7068 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
7069 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000010f, 0x505f5653, 0x5449534f, 0x004e4f49,
7070 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
7071 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000124, 0x00000040,
7072 0x00000049, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04003858, 0x00107000, 0x00000000,
7073 0x00005555, 0x04002064, 0x00101012, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
7074 0x02000068, 0x00000001, 0x0600001c, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000,
7075 0x0700003d, 0x001000f2, 0x00000000, 0x0010000a, 0x00000000, 0x00107e46, 0x00000000, 0x07000038,
7076 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x0010100a, 0x00000000, 0x06000036, 0x001000c2,
7077 0x00000000, 0x00208006, 0x00000000, 0x00000000, 0x0a000038, 0x00100072, 0x00000000, 0x00100386,
7078 0x00000000, 0x00004002, 0x3acccccd, 0x3f800000, 0x3f800000, 0x00000000, 0x0500001b, 0x001000d2,
7079 0x00000000, 0x00100906, 0x00000000, 0x05000036, 0x00100022, 0x00000000, 0x00004001, 0x00000001,
7080 0x0700002d, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00107e46, 0x00000000, 0x0100003e,
7082 static const struct shader ps_ld_array
= {ps_ld_array_code
, sizeof(ps_ld_array_code
)};
7084 static const DWORD rgba_level_0
[] =
7086 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
7088 static const DWORD rgba_level_1
[] =
7090 0xffffffff, 0xff0000ff,
7092 static const DWORD rgba_level_2
[] =
7096 static const DWORD srgb_data
[] =
7098 0x00000000, 0xffffffff, 0xff000000, 0x7f7f7f7f,
7100 static const DWORD r32_uint
[] =
7104 static const DWORD r9g9b9e5_data
[] =
7106 0x80000100, 0x80020000, 0x84000000, 0x84000100,
7108 static const DWORD array_data0
[] =
7110 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
7112 static const DWORD array_data1
[] =
7114 0x00ffff00, 0xff000000, 0x00ff0000, 0x000000ff,
7116 static const DWORD array_data2
[] =
7118 0x000000ff, 0xffff00ff, 0x0000ff00, 0xff000000,
7120 static const struct texture rgba_texture
=
7122 4, 3, 1, DXGI_FORMAT_R8G8B8A8_UNORM
,
7124 {rgba_level_0
, 4 * sizeof(*rgba_level_0
), 0},
7125 {rgba_level_1
, 2 * sizeof(*rgba_level_1
), 0},
7126 {rgba_level_2
, sizeof(*rgba_level_2
), 0},
7129 static const struct texture srgb_texture
= {4, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
7130 {{srgb_data
, 4 * sizeof(*srgb_data
)}}};
7131 static const struct texture sint8_texture
= {4, 1, 1, DXGI_FORMAT_R8G8B8A8_SINT
,
7132 {{rgba_level_0
, 4 * sizeof(*rgba_level_0
)}}};
7133 static const struct texture uint8_texture
= {4, 1, 1, DXGI_FORMAT_R8G8B8A8_UINT
,
7134 {{rgba_level_0
, 4 * sizeof(*rgba_level_0
)}}};
7135 static const struct texture r32u_typeless
= {4, 1, 1, DXGI_FORMAT_R32_TYPELESS
,
7136 {{r32_uint
, 4 * sizeof(*r32_uint
)}}};
7137 static const struct texture r9g9b9e5_texture
= {4, 1, 1, DXGI_FORMAT_R9G9B9E5_SHAREDEXP
,
7138 {{r9g9b9e5_data
, 4 * sizeof(*r9g9b9e5_data
)}}};
7139 static const struct texture array_texture
= {4, 1, 3, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
7141 {array_data0
, 4 * sizeof(*array_data0
)},
7142 {array_data1
, 4 * sizeof(*array_data1
)},
7143 {array_data2
, 4 * sizeof(*array_data2
)},
7147 static const DWORD level_1_colors
[] =
7149 0xffffffff, 0xffffffff, 0xff0000ff, 0xff0000ff,
7151 static const DWORD level_2_colors
[] =
7153 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
7155 static const DWORD srgb_colors
[] =
7157 0x00000001, 0xffffffff, 0xff000000, 0x7f363636,
7159 static const DWORD sint8_colors
[] =
7161 0x7e80807e, 0x7e807e7e, 0x7e807e80, 0x7e7e7e80,
7163 static const DWORD r32u_colors
[4] =
7165 0x01000000, 0x01000001, 0x01000002, 0x01000003,
7167 static const DWORD r9g9b9e5_colors
[4] =
7169 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffff00ff,
7171 static const DWORD zero_colors
[4] = {0};
7172 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
7173 static const struct texture_test
7175 const struct shader
*ps
;
7176 const struct texture
*texture
;
7177 D3D11_FILTER filter
;
7182 const DWORD
*expected_colors
;
7186 #define POINT D3D11_FILTER_MIN_MAG_MIP_POINT
7187 #define POINT_LINEAR D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR
7188 #define MIP_MAX D3D11_FLOAT32_MAX
7189 {&ps_ld
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, rgba_level_0
},
7190 {&ps_ld
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, level_1_colors
},
7191 {&ps_ld
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 2.0f
, level_2_colors
},
7192 {&ps_ld
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 3.0f
, zero_colors
},
7193 {&ps_ld
, &srgb_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, srgb_colors
},
7194 {&ps_ld
, &r9g9b9e5_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, r9g9b9e5_colors
},
7195 {&ps_ld
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, zero_colors
},
7196 {&ps_ld
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, zero_colors
},
7197 {&ps_ld_sint8
, &sint8_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, sint8_colors
},
7198 {&ps_ld_uint8
, &uint8_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, rgba_level_0
},
7199 {&ps_ld_array
, &array_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, array_data1
},
7204 static const struct srv_test
7206 const struct shader
*ps
;
7207 const struct texture
*texture
;
7208 struct srv_desc srv_desc
;
7210 const DWORD
*expected_colors
;
7214 #define TEX_1D D3D11_SRV_DIMENSION_TEXTURE1D
7215 #define R32_UINT DXGI_FORMAT_R32_UINT
7216 {&ps_ld_uint8
, &r32u_typeless
, {R32_UINT
, TEX_1D
, 0, 1}, 0.0f
, r32u_colors
},
7222 if (!init_test_context(&test_context
, NULL
))
7225 device
= test_context
.device
;
7226 context
= test_context
.immediate_context
;
7227 feature_level
= ID3D11Device_GetFeatureLevel(device
);
7229 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(ps_constant
), NULL
);
7231 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
7233 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
7234 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
7235 texture_desc
.CPUAccessFlags
= 0;
7236 texture_desc
.MiscFlags
= 0;
7238 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
7239 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
7240 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
7241 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
7242 sampler_desc
.MipLODBias
= 0.0f
;
7243 sampler_desc
.MaxAnisotropy
= 0;
7244 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
7245 sampler_desc
.BorderColor
[0] = 0.0f
;
7246 sampler_desc
.BorderColor
[1] = 0.0f
;
7247 sampler_desc
.BorderColor
[2] = 0.0f
;
7248 sampler_desc
.BorderColor
[3] = 0.0f
;
7249 sampler_desc
.MinLOD
= 0.0f
;
7250 sampler_desc
.MaxLOD
= D3D11_FLOAT32_MAX
;
7257 current_texture
= NULL
;
7258 for (i
= 0; i
< ARRAY_SIZE(texture_tests
); ++i
)
7260 const struct texture_test
*test
= &texture_tests
[i
];
7262 if (current_ps
!= test
->ps
)
7265 ID3D11PixelShader_Release(ps
);
7267 current_ps
= test
->ps
;
7269 hr
= ID3D11Device_CreatePixelShader(device
, current_ps
->code
, current_ps
->size
, NULL
, &ps
);
7270 ok(SUCCEEDED(hr
), "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
7272 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
7275 if (current_texture
!= test
->texture
)
7278 ID3D11Texture1D_Release(texture
);
7280 ID3D11ShaderResourceView_Release(srv
);
7282 current_texture
= test
->texture
;
7284 if (current_texture
)
7286 texture_desc
.Width
= current_texture
->width
;
7287 texture_desc
.MipLevels
= current_texture
->miplevel_count
;
7288 texture_desc
.ArraySize
= current_texture
->array_size
;
7289 texture_desc
.Format
= current_texture
->format
;
7291 hr
= ID3D11Device_CreateTexture1D(device
, &texture_desc
, current_texture
->data
, &texture
);
7292 ok(SUCCEEDED(hr
), "Test %u: Failed to create 1d texture, hr %#x.\n", i
, hr
);
7294 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
7295 ok(SUCCEEDED(hr
), "Test %u: Failed to create shader resource view, hr %#x.\n", i
, hr
);
7303 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
7306 if (!sampler
|| (sampler_desc
.Filter
!= test
->filter
7307 || sampler_desc
.MipLODBias
!= test
->lod_bias
7308 || sampler_desc
.MinLOD
!= test
->min_lod
7309 || sampler_desc
.MaxLOD
!= test
->max_lod
))
7312 ID3D11SamplerState_Release(sampler
);
7314 sampler_desc
.Filter
= test
->filter
;
7315 sampler_desc
.MipLODBias
= test
->lod_bias
;
7316 sampler_desc
.MinLOD
= test
->min_lod
;
7317 sampler_desc
.MaxLOD
= test
->max_lod
;
7319 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler
);
7320 ok(SUCCEEDED(hr
), "Test %u: Failed to create sampler state, hr %#x.\n", i
, hr
);
7322 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler
);
7325 ps_constant
.x
= test
->ps_constant
;
7326 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &ps_constant
, 0, 0);
7328 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
7330 draw_quad(&test_context
);
7332 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
7333 for (x
= 0; x
< 4; ++x
)
7335 color
= get_readback_color(&rb
, 80 + x
* 160, 0, 0);
7336 ok(compare_color(color
, test
->expected_colors
[x
], 2),
7337 "Test %u: Got unexpected color 0x%08x at (%u).\n", i
, color
, x
);
7339 release_resource_readback(&rb
);
7342 ID3D11ShaderResourceView_Release(srv
);
7343 ID3D11SamplerState_Release(sampler
);
7345 ID3D11Texture1D_Release(texture
);
7346 ID3D11PixelShader_Release(ps
);
7348 if (is_warp_device(device
) && feature_level
< D3D_FEATURE_LEVEL_11_0
)
7350 win_skip("SRV tests are broken on WARP.\n");
7351 ID3D11Buffer_Release(cb
);
7352 release_test_context(&test_context
);
7356 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
7357 sampler_desc
.MipLODBias
= 0.0f
;
7358 sampler_desc
.MinLOD
= 0.0f
;
7359 sampler_desc
.MaxLOD
= D3D11_FLOAT32_MAX
;
7361 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler
);
7362 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
7364 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler
);
7370 current_texture
= NULL
;
7371 for (i
= 0; i
< ARRAY_SIZE(srv_tests
); ++i
)
7373 const struct srv_test
*test
= &srv_tests
[i
];
7375 if (current_ps
!= test
->ps
)
7378 ID3D11PixelShader_Release(ps
);
7380 current_ps
= test
->ps
;
7382 hr
= ID3D11Device_CreatePixelShader(device
, current_ps
->code
, current_ps
->size
, NULL
, &ps
);
7383 ok(SUCCEEDED(hr
), "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
7385 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
7388 if (current_texture
!= test
->texture
)
7391 ID3D11Texture1D_Release(texture
);
7393 current_texture
= test
->texture
;
7395 texture_desc
.Width
= current_texture
->width
;
7396 texture_desc
.MipLevels
= current_texture
->miplevel_count
;
7397 texture_desc
.ArraySize
= current_texture
->array_size
;
7398 texture_desc
.Format
= current_texture
->format
;
7400 hr
= ID3D11Device_CreateTexture1D(device
, &texture_desc
, current_texture
->data
, &texture
);
7401 ok(SUCCEEDED(hr
), "Test %u: Failed to create 1d texture, hr %#x.\n", i
, hr
);
7405 ID3D11ShaderResourceView_Release(srv
);
7407 get_srv_desc(&srv_desc
, &test
->srv_desc
);
7408 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, &srv_desc
, &srv
);
7409 ok(SUCCEEDED(hr
), "Test %u: Failed to create shader resource view, hr %#x.\n", i
, hr
);
7411 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
7413 ps_constant
.x
= test
->ps_constant
;
7414 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &ps_constant
, 0, 0);
7416 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
7418 draw_quad(&test_context
);
7420 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
7421 for (x
= 0; x
< 4; ++x
)
7423 color
= get_readback_color(&rb
, 80 + x
* 160, 0, 0);
7424 ok(compare_color(color
, test
->expected_colors
[x
], 1),
7425 "Test %u: Got unexpected color 0x%08x at (%u).\n", i
, color
, x
);
7427 release_resource_readback(&rb
);
7429 ID3D11PixelShader_Release(ps
);
7430 ID3D11Texture1D_Release(texture
);
7431 ID3D11ShaderResourceView_Release(srv
);
7432 ID3D11SamplerState_Release(sampler
);
7434 ID3D11Buffer_Release(cb
);
7435 release_test_context(&test_context
);
7438 static void test_texture(void)
7449 UINT miplevel_count
;
7452 D3D11_SUBRESOURCE_DATA data
[3];
7455 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
7456 struct d3d11_test_context test_context
;
7457 const struct texture
*current_texture
;
7458 D3D11_TEXTURE2D_DESC texture_desc
;
7459 D3D11_SAMPLER_DESC sampler_desc
;
7460 const struct shader
*current_ps
;
7461 D3D_FEATURE_LEVEL feature_level
;
7462 ID3D11ShaderResourceView
*srv
;
7463 ID3D11DeviceContext
*context
;
7464 ID3D11SamplerState
*sampler
;
7465 struct resource_readback rb
;
7466 ID3D11Texture2D
*texture
;
7467 struct vec4 ps_constant
;
7468 ID3D11PixelShader
*ps
;
7469 ID3D11Device
*device
;
7470 unsigned int i
, x
, y
;
7475 static const DWORD ps_ld_code
[] =
7482 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
7485 t
.GetDimensions(miplevel
, p
.x
, p
.y
, p
.z
);
7487 p
*= float3(position
.x
/ 640.0f
, position
.y
/ 480.0f
, 1.0f
);
7488 return t
.Load(int3(p
));
7491 0x43425844, 0xbdda6bdf, 0xc6ffcdf1, 0xa58596b3, 0x822383f0, 0x00000001, 0x000001ac, 0x00000003,
7492 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
7493 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
7494 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
7495 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000110, 0x00000040,
7496 0x00000044, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04001858, 0x00107000, 0x00000000,
7497 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
7498 0x02000068, 0x00000001, 0x0600001c, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000,
7499 0x0700003d, 0x001000f2, 0x00000000, 0x0010000a, 0x00000000, 0x00107e46, 0x00000000, 0x07000038,
7500 0x00100032, 0x00000000, 0x00100046, 0x00000000, 0x00101046, 0x00000000, 0x06000036, 0x001000c2,
7501 0x00000000, 0x00208006, 0x00000000, 0x00000000, 0x0a000038, 0x001000f2, 0x00000000, 0x00100e46,
7502 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x3f800000, 0x3f800000, 0x0500001b, 0x001000f2,
7503 0x00000000, 0x00100e46, 0x00000000, 0x0700002d, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
7504 0x00107e46, 0x00000000, 0x0100003e,
7506 static const struct shader ps_ld
= {ps_ld_code
, sizeof(ps_ld_code
)};
7507 static const DWORD ps_ld_sint8_code
[] =
7512 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
7517 p
= float3(position
.x
/ 640.0f
, position
.y
/ 480.0f
, 0.0f
);
7518 t
.GetDimensions(0, s
.x
, s
.y
, s
.z
);
7521 c
= t
.Load(int3(p
));
7522 return (max(c
/ (float4
)127, (float4
)-1) + (float4
)1) / 2.0f
;
7525 0x43425844, 0xb3d0b0fc, 0x0e486f4a, 0xf67eec12, 0xfb9dd52f, 0x00000001, 0x00000240, 0x00000003,
7526 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
7527 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
7528 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
7529 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000001a4, 0x00000040,
7530 0x00000069, 0x04001858, 0x00107000, 0x00000000, 0x00003333, 0x04002064, 0x00101032, 0x00000000,
7531 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x0700003d, 0x001000f2,
7532 0x00000000, 0x00004001, 0x00000000, 0x00107e46, 0x00000000, 0x0a000038, 0x00100032, 0x00000001,
7533 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x08000036,
7534 0x001000c2, 0x00000001, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07000038,
7535 0x001000f2, 0x00000000, 0x00100f46, 0x00000000, 0x00100e46, 0x00000001, 0x0500001b, 0x001000f2,
7536 0x00000000, 0x00100e46, 0x00000000, 0x0700002d, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
7537 0x00107e46, 0x00000000, 0x0500002b, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x0a000038,
7538 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3c010204, 0x3c010204, 0x3c010204,
7539 0x3c010204, 0x0a000034, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0xbf800000,
7540 0xbf800000, 0xbf800000, 0xbf800000, 0x0a000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
7541 0x00004002, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000, 0x0a000038, 0x001020f2, 0x00000000,
7542 0x00100e46, 0x00000000, 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, 0x0100003e,
7544 static const struct shader ps_ld_sint8
= {ps_ld_sint8_code
, sizeof(ps_ld_sint8_code
)};
7545 static const DWORD ps_ld_uint8_code
[] =
7550 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
7554 p
= float3(position
.x
/ 640.0f
, position
.y
/ 480.0f
, 0.0f
);
7555 t
.GetDimensions(0, s
.x
, s
.y
, s
.z
);
7558 return t
.Load(int3(p
)) / (float4
)255;
7561 0x43425844, 0xd09917eb, 0x4508a07e, 0xb0b7250a, 0x228c1f0e, 0x00000001, 0x000001c8, 0x00000003,
7562 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
7563 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
7564 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
7565 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x0000012c, 0x00000040,
7566 0x0000004b, 0x04001858, 0x00107000, 0x00000000, 0x00004444, 0x04002064, 0x00101032, 0x00000000,
7567 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x0700003d, 0x001000f2,
7568 0x00000000, 0x00004001, 0x00000000, 0x00107e46, 0x00000000, 0x0a000038, 0x00100032, 0x00000001,
7569 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x08000036,
7570 0x001000c2, 0x00000001, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07000038,
7571 0x001000f2, 0x00000000, 0x00100f46, 0x00000000, 0x00100e46, 0x00000001, 0x0500001b, 0x001000f2,
7572 0x00000000, 0x00100e46, 0x00000000, 0x0700002d, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
7573 0x00107e46, 0x00000000, 0x05000056, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x0a000038,
7574 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3b808081, 0x3b808081, 0x3b808081,
7575 0x3b808081, 0x0100003e,
7577 static const struct shader ps_ld_uint8
= {ps_ld_uint8_code
, sizeof(ps_ld_uint8_code
)};
7578 static const DWORD ps_sample_code
[] =
7584 float4
main(float4 position
: SV_POSITION
) : SV_Target
7588 p
.x
= position
.x
/ 640.0f
;
7589 p
.y
= position
.y
/ 480.0f
;
7590 return t
.Sample(s
, p
);
7593 0x43425844, 0x1ce9b612, 0xc8176faa, 0xd37844af, 0xdb515605, 0x00000001, 0x00000134, 0x00000003,
7594 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
7595 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
7596 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
7597 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
7598 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
7599 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
7600 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
7601 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
7602 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
7604 static const struct shader ps_sample
= {ps_sample_code
, sizeof(ps_sample_code
)};
7605 static const DWORD ps_sample_b_code
[] =
7613 float4
main(float4 position
: SV_POSITION
) : SV_Target
7617 p
.x
= position
.x
/ 640.0f
;
7618 p
.y
= position
.y
/ 480.0f
;
7619 return t
.SampleBias(s
, p
, bias
);
7622 0x43425844, 0xc39b0686, 0x8244a7fc, 0x14c0b97a, 0x2900b3b7, 0x00000001, 0x00000150, 0x00000003,
7623 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
7624 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
7625 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
7626 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000b4, 0x00000040,
7627 0x0000002d, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000, 0x00000000,
7628 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001,
7629 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0a000038, 0x00100032, 0x00000000,
7630 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x0c00004a,
7631 0x001020f2, 0x00000000, 0x00100046, 0x00000000, 0x00107e46, 0x00000000, 0x00106000, 0x00000000,
7632 0x0020800a, 0x00000000, 0x00000000, 0x0100003e,
7634 static const struct shader ps_sample_b
= {ps_sample_b_code
, sizeof(ps_sample_b_code
)};
7635 static const DWORD ps_sample_l_code
[] =
7643 float4
main(float4 position
: SV_POSITION
) : SV_Target
7647 p
.x
= position
.x
/ 640.0f
;
7648 p
.y
= position
.y
/ 480.0f
;
7649 return t
.SampleLevel(s
, p
, level
);
7652 0x43425844, 0x61e05d85, 0x2a7300fb, 0x0a83706b, 0x889d1683, 0x00000001, 0x00000150, 0x00000003,
7653 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
7654 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
7655 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
7656 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000b4, 0x00000040,
7657 0x0000002d, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000, 0x00000000,
7658 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001,
7659 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0a000038, 0x00100032, 0x00000000,
7660 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x0c000048,
7661 0x001020f2, 0x00000000, 0x00100046, 0x00000000, 0x00107e46, 0x00000000, 0x00106000, 0x00000000,
7662 0x0020800a, 0x00000000, 0x00000000, 0x0100003e,
7664 static const struct shader ps_sample_l
= {ps_sample_l_code
, sizeof(ps_sample_l_code
)};
7665 static const DWORD ps_sample_2d_array_code
[] =
7673 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
7676 float3 p
= float3(position
.x
/ 640.0f
, position
.y
/ 480.0f
, 1.0f
);
7677 t
.GetDimensions(d
.x
, d
.y
, d
.z
);
7679 return t
.Sample(s
, p
* d
);
7682 0x43425844, 0xa9457e44, 0xc0b3ef8e, 0x3d751ae8, 0x23fa4807, 0x00000001, 0x00000194, 0x00000003,
7683 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
7684 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
7685 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
7686 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000f8, 0x00000040,
7687 0x0000003e, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000, 0x00000000,
7688 0x04004058, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001,
7689 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0700003d, 0x001000f2, 0x00000000,
7690 0x00004001, 0x00000000, 0x00107e46, 0x00000000, 0x0a000038, 0x001000c2, 0x00000000, 0x00101406,
7691 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x3acccccd, 0x3b088889, 0x07000038, 0x00100032,
7692 0x00000000, 0x00100046, 0x00000000, 0x00100ae6, 0x00000000, 0x06000036, 0x00100042, 0x00000000,
7693 0x0020800a, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100246, 0x00000000,
7694 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
7696 static const struct shader ps_sample_2d_array
= {ps_sample_2d_array_code
, sizeof(ps_sample_2d_array_code
)};
7697 static const DWORD red_data
[] =
7699 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff, 0x00000000, 0x00000000,
7700 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff, 0x00000000, 0x00000000,
7701 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff, 0x00000000, 0x00000000,
7702 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff, 0x00000000, 0x00000000,
7704 static const DWORD green_data
[] =
7706 0xff00ff00, 0xff00ff00, 0xff00ff00, 0xff00ff00,
7707 0xff00ff00, 0xff00ff00, 0xff00ff00, 0xff00ff00,
7708 0xff00ff00, 0xff00ff00, 0xff00ff00, 0xff00ff00,
7709 0xff00ff00, 0xff00ff00, 0xff00ff00, 0xff00ff00,
7711 static const DWORD blue_data
[] =
7713 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000, 0x00000000,
7714 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000, 0x00000000,
7715 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000, 0x00000000,
7716 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000, 0x00000000,
7718 static const DWORD rgba_level_0
[] =
7720 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
7721 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
7722 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
7723 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
7725 static const DWORD rgba_level_1
[] =
7727 0xffffffff, 0xff0000ff,
7728 0xff000000, 0xff00ff00,
7730 static const DWORD rgba_level_2
[] =
7734 static const DWORD srgb_data
[] =
7736 0x00000000, 0xffffffff, 0xff000000, 0x7f7f7f7f,
7737 0xff010203, 0xff102030, 0xff0a0b0c, 0xff8090a0,
7738 0xffb1c4de, 0xfff0f1f2, 0xfffafdfe, 0xff5a560f,
7739 0xffd5ff00, 0xffc8f99f, 0xffaa00aa, 0xffdd55bb,
7741 static const WORD r8g8_data
[] =
7743 0x0000, 0xffff, 0x0000, 0x7fff,
7744 0x0203, 0xff10, 0x0b0c, 0x8000,
7745 0xc4de, 0xfff0, 0xfdfe, 0x5a6f,
7746 0xff00, 0xffc8, 0x00aa, 0xdd5b,
7748 static const BYTE a8_data
[] =
7750 0x00, 0x10, 0x20, 0x30,
7751 0x40, 0x50, 0x60, 0x70,
7752 0x80, 0x90, 0xa0, 0xb0,
7753 0xc0, 0xd0, 0xe0, 0xf0,
7755 static const BYTE bc1_data
[] =
7757 0x00, 0xf8, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
7758 0xe0, 0x07, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00,
7759 0x1f, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
7760 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
7762 static const BYTE bc2_data
[] =
7764 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf8, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
7765 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x07, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00,
7766 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
7767 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
7769 static const BYTE bc3_data
[] =
7771 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
7772 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00,
7773 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
7774 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
7776 static const BYTE bc4_data
[] =
7778 0x10, 0x7f, 0x77, 0x39, 0x05, 0x00, 0x00, 0x00,
7779 0x10, 0x7f, 0x49, 0x92, 0x24, 0x49, 0x92, 0x24,
7780 0x10, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
7781 0x10, 0x7f, 0xb6, 0x6d, 0xdb, 0xb6, 0x6d, 0xdb,
7783 static const BYTE bc5_data
[] =
7785 0x10, 0x7f, 0x77, 0x39, 0x05, 0x00, 0x00, 0x00, 0x10, 0x7f, 0x77, 0x39, 0x05, 0x00, 0x00, 0x00,
7786 0x10, 0x7f, 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0x10, 0x7f, 0x49, 0x92, 0x24, 0x49, 0x92, 0x24,
7787 0x10, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x10, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
7788 0x10, 0x7f, 0xb6, 0x6d, 0xdb, 0xb6, 0x6d, 0xdb, 0x10, 0x7f, 0xb6, 0x6d, 0xdb, 0xb6, 0x6d, 0xdb,
7790 static const BYTE bc6h_u_data
[] =
7792 0xe3, 0x5e, 0x00, 0x00, 0x78, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7793 0x03, 0x80, 0x7b, 0x01, 0x00, 0xe0, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7794 0x03, 0x00, 0x00, 0xee, 0x05, 0x00, 0x80, 0xf7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7795 0xe3, 0xde, 0x7b, 0xef, 0x7d, 0xef, 0xbd, 0xf7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7797 static const BYTE bc6h_s_data
[] =
7799 0x63, 0x2f, 0x00, 0x00, 0xb8, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7800 0x03, 0x80, 0xbd, 0x00, 0x00, 0xe0, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7801 0x03, 0x00, 0x00, 0xf6, 0x02, 0x00, 0x80, 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7802 0x63, 0xaf, 0xbd, 0xf6, 0xba, 0xe7, 0x9e, 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7804 static const BYTE bc7_data
[] =
7806 0x02, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7807 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7808 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7809 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
7811 static const float r32_float
[] =
7813 0.0f
, 1.0f
, 0.5f
, 0.50f
,
7814 1.0f
, 0.0f
, 0.0f
, 0.75f
,
7815 0.0f
, 1.0f
, 0.5f
, 0.25f
,
7816 1.0f
, 0.0f
, 0.0f
, 0.75f
,
7818 static const DWORD r32_uint
[] =
7825 static const DWORD r9g9b9e5_data
[] =
7827 0x80000100, 0x80020000, 0x84000000, 0x84000100,
7828 0x78000100, 0x78020000, 0x7c000000, 0x78020100,
7829 0x70000133, 0x70026600, 0x74cc0000, 0x74cc0133,
7830 0x6800019a, 0x68033400, 0x6e680000, 0x6e6b359a,
7832 static const struct texture rgba_texture
=
7834 4, 4, 3, 1, DXGI_FORMAT_R8G8B8A8_UNORM
,
7836 {rgba_level_0
, 4 * sizeof(*rgba_level_0
), 0},
7837 {rgba_level_1
, 2 * sizeof(*rgba_level_1
), 0},
7838 {rgba_level_2
, sizeof(*rgba_level_2
), 0},
7841 static const struct texture srgb_texture
= {4, 4, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
7842 {{srgb_data
, 4 * sizeof(*srgb_data
)}}};
7843 static const struct texture srgb_typeless
= {4, 4, 1, 1, DXGI_FORMAT_R8G8B8A8_TYPELESS
,
7844 {{srgb_data
, 4 * sizeof(*srgb_data
)}}};
7845 static const struct texture a8_texture
= {4, 4, 1, 1, DXGI_FORMAT_A8_UNORM
,
7846 {{a8_data
, 4 * sizeof(*a8_data
)}}};
7847 static const struct texture bc1_texture
= {8, 8, 1, 1, DXGI_FORMAT_BC1_UNORM
, {{bc1_data
, 2 * 8}}};
7848 static const struct texture bc2_texture
= {8, 8, 1, 1, DXGI_FORMAT_BC2_UNORM
, {{bc2_data
, 2 * 16}}};
7849 static const struct texture bc3_texture
= {8, 8, 1, 1, DXGI_FORMAT_BC3_UNORM
, {{bc3_data
, 2 * 16}}};
7850 static const struct texture bc4_texture
= {8, 8, 1, 1, DXGI_FORMAT_BC4_UNORM
, {{bc4_data
, 2 * 8}}};
7851 static const struct texture bc5_texture
= {8, 8, 1, 1, DXGI_FORMAT_BC5_UNORM
, {{bc5_data
, 2 * 16}}};
7852 static const struct texture bc6h_u_texture
= {8, 8, 1, 1, DXGI_FORMAT_BC6H_UF16
, {{bc6h_u_data
, 2 * 16}}};
7853 static const struct texture bc6h_s_texture
= {8, 8, 1, 1, DXGI_FORMAT_BC6H_SF16
, {{bc6h_s_data
, 2 * 16}}};
7854 static const struct texture bc7_texture
= {8, 8, 1, 1, DXGI_FORMAT_BC7_UNORM
, {{bc7_data
, 2 * 16}}};
7855 static const struct texture bc1_texture_srgb
= {8, 8, 1, 1, DXGI_FORMAT_BC1_UNORM_SRGB
, {{bc1_data
, 2 * 8}}};
7856 static const struct texture bc2_texture_srgb
= {8, 8, 1, 1, DXGI_FORMAT_BC2_UNORM_SRGB
, {{bc2_data
, 2 * 16}}};
7857 static const struct texture bc3_texture_srgb
= {8, 8, 1, 1, DXGI_FORMAT_BC3_UNORM_SRGB
, {{bc3_data
, 2 * 16}}};
7858 static const struct texture bc7_texture_srgb
= {8, 8, 1, 1, DXGI_FORMAT_BC7_UNORM_SRGB
, {{bc7_data
, 2 * 16}}};
7859 static const struct texture bc1_typeless
= {8, 8, 1, 1, DXGI_FORMAT_BC1_TYPELESS
, {{bc1_data
, 2 * 8}}};
7860 static const struct texture bc2_typeless
= {8, 8, 1, 1, DXGI_FORMAT_BC2_TYPELESS
, {{bc2_data
, 2 * 16}}};
7861 static const struct texture bc3_typeless
= {8, 8, 1, 1, DXGI_FORMAT_BC3_TYPELESS
, {{bc3_data
, 2 * 16}}};
7862 static const struct texture sint8_texture
= {4, 4, 1, 1, DXGI_FORMAT_R8G8B8A8_SINT
,
7863 {{rgba_level_0
, 4 * sizeof(*rgba_level_0
)}}};
7864 static const struct texture uint8_texture
= {4, 4, 1, 1, DXGI_FORMAT_R8G8B8A8_UINT
,
7865 {{rgba_level_0
, 4 * sizeof(*rgba_level_0
)}}};
7866 static const struct texture array_2d_texture
=
7868 4, 4, 1, 3, DXGI_FORMAT_R8G8B8A8_UNORM
,
7870 {red_data
, 6 * sizeof(*red_data
)},
7871 {green_data
, 4 * sizeof(*green_data
)},
7872 {blue_data
, 5 * sizeof(*blue_data
)},
7875 static const struct texture r32f_float
= {4, 4, 1, 1, DXGI_FORMAT_R32_FLOAT
,
7876 {{r32_float
, 4 * sizeof(*r32_float
)}}};
7877 static const struct texture r32f_typeless
= {4, 4, 1, 1, DXGI_FORMAT_R32_TYPELESS
,
7878 {{r32_float
, 4 * sizeof(*r32_float
)}}};
7879 static const struct texture r32u_typeless
= {4, 4, 1, 1, DXGI_FORMAT_R32_TYPELESS
,
7880 {{r32_uint
, 4 * sizeof(*r32_uint
)}}};
7881 static const struct texture r8g8_snorm
= {4, 4, 1, 1, DXGI_FORMAT_R8G8_SNORM
,
7882 {{r8g8_data
, 4 * sizeof(*r8g8_data
)}}};
7883 static const struct texture r9g9b9e5_texture
= {4, 4, 1, 1, DXGI_FORMAT_R9G9B9E5_SHAREDEXP
,
7884 {{r9g9b9e5_data
, 4 * sizeof(*r9g9b9e5_data
)}}};
7885 static const DWORD red_colors
[] =
7887 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff,
7888 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff,
7889 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff,
7890 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff,
7892 static const DWORD blue_colors
[] =
7894 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
7895 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
7896 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
7897 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
7899 static const DWORD level_1_colors
[] =
7901 0xffffffff, 0xffffffff, 0xff0000ff, 0xff0000ff,
7902 0xffffffff, 0xffffffff, 0xff0000ff, 0xff0000ff,
7903 0xff000000, 0xff000000, 0xff00ff00, 0xff00ff00,
7904 0xff000000, 0xff000000, 0xff00ff00, 0xff00ff00,
7906 static const DWORD lerp_1_2_colors
[] =
7908 0xffff7f7f, 0xffff7f7f, 0xff7f007f, 0xff7f007f,
7909 0xffff7f7f, 0xffff7f7f, 0xff7f007f, 0xff7f007f,
7910 0xff7f0000, 0xff7f0000, 0xff7f7f00, 0xff7f7f00,
7911 0xff7f0000, 0xff7f0000, 0xff7f7f00, 0xff7f7f00,
7913 static const DWORD level_2_colors
[] =
7915 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
7916 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
7917 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
7918 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
7920 static const DWORD srgb_colors
[] =
7922 0x00000001, 0xffffffff, 0xff000000, 0x7f363636,
7923 0xff000000, 0xff010408, 0xff010101, 0xff37475a,
7924 0xff708cba, 0xffdee0e2, 0xfff3fbfd, 0xff1a1801,
7925 0xffa9ff00, 0xff93f159, 0xff670067, 0xffb8177f,
7927 static const DWORD a8_colors
[] =
7929 0x00000000, 0x10000000, 0x20000000, 0x30000000,
7930 0x40000000, 0x50000000, 0x60000000, 0x70000000,
7931 0x80000000, 0x90000000, 0xa0000000, 0xb0000000,
7932 0xc0000000, 0xd0000000, 0xe0000000, 0xf0000000,
7934 static const DWORD bc_colors
[] =
7936 0xff0000ff, 0xff0000ff, 0xff00ff00, 0xff00ff00,
7937 0xff0000ff, 0xff0000ff, 0xff00ff00, 0xff00ff00,
7938 0xffff0000, 0xffff0000, 0xffffffff, 0xffffffff,
7939 0xffff0000, 0xffff0000, 0xffffffff, 0xffffffff,
7941 static const DWORD bc4_colors
[] =
7943 0xff000026, 0xff000010, 0xff00007f, 0xff00007f,
7944 0xff000010, 0xff000010, 0xff00007f, 0xff00007f,
7945 0xff0000ff, 0xff0000ff, 0xff000000, 0xff000000,
7946 0xff0000ff, 0xff0000ff, 0xff000000, 0xff000000,
7948 static const DWORD bc5_colors
[] =
7950 0xff002626, 0xff001010, 0xff007f7f, 0xff007f7f,
7951 0xff001010, 0xff001010, 0xff007f7f, 0xff007f7f,
7952 0xff00ffff, 0xff00ffff, 0xff000000, 0xff000000,
7953 0xff00ffff, 0xff00ffff, 0xff000000, 0xff000000,
7955 static const DWORD bc7_colors
[] =
7957 0xff0000fc, 0xff0000fc, 0xff00fc00, 0xff00fc00,
7958 0xff0000fc, 0xff0000fc, 0xff00fc00, 0xff00fc00,
7959 0xfffc0000, 0xfffc0000, 0xffffffff, 0xffffffff,
7960 0xfffc0000, 0xfffc0000, 0xffffffff, 0xffffffff,
7962 static const DWORD sint8_colors
[] =
7964 0x7e80807e, 0x7e807e7e, 0x7e807e80, 0x7e7e7e80,
7965 0x7e7e8080, 0x7e7e7f7f, 0x7e808080, 0x7effffff,
7966 0x7e7e7e7e, 0x7e7e7e7e, 0x7e7e7e7e, 0x7e808080,
7967 0x7e7e7e7e, 0x7e7f7f7f, 0x7e7f7f7f, 0x7e7f7f7f,
7969 static const DWORD snorm_colors
[] =
7971 0xff000000, 0xff000000, 0xff000000, 0xff00ff00,
7972 0xff000406, 0xff000020, 0xff001618, 0xff000000,
7973 0xff000000, 0xff000000, 0xff000000, 0xff00b5df,
7974 0xff000000, 0xff000000, 0xff000000, 0xff0000b7,
7976 static const DWORD r32f_colors
[] =
7978 0xff000000, 0xff0000ff, 0xff00007f, 0xff00007f,
7979 0xff0000ff, 0xff000000, 0xff000000, 0xff0000bf,
7980 0xff000000, 0xff0000ff, 0xff00007f, 0xff000040,
7981 0xff0000ff, 0xff000000, 0xff000000, 0xff0000bf,
7983 static const DWORD r32u_colors
[16] =
7985 0x01000000, 0x01000001, 0x01000002, 0x01000003,
7986 0x01000064, 0x010000c8, 0x010000ff, 0x01000080,
7987 0x01000028, 0x0100001e, 0x01000014, 0x0100000a,
7988 0x010000fa, 0x010000d2, 0x0100009b, 0x010000be,
7990 static const DWORD r9g9b9e5_colors
[16] =
7992 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffff00ff,
7993 0xff00007f, 0xff007f00, 0xff7f0000, 0xff007f7f,
7994 0xff00004c, 0xff004c00, 0xff4c0000, 0xff4c004c,
7995 0xff000033, 0xff003300, 0xff330000, 0xff333333,
7997 static const DWORD zero_colors
[4 * 4] = {0};
7998 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
8000 static const struct texture_test
8002 const struct shader
*ps
;
8003 const struct texture
*texture
;
8004 D3D11_FILTER filter
;
8009 const DWORD
*expected_colors
;
8013 #define POINT D3D11_FILTER_MIN_MAG_MIP_POINT
8014 #define POINT_LINEAR D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR
8015 #define MIP_MAX D3D11_FLOAT32_MAX
8016 {&ps_ld
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, rgba_level_0
},
8017 {&ps_ld
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, level_1_colors
},
8018 {&ps_ld
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 2.0f
, level_2_colors
},
8019 {&ps_ld
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 3.0f
, zero_colors
},
8020 {&ps_ld
, &srgb_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, srgb_colors
},
8021 {&ps_ld
, &bc1_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
8022 {&ps_ld
, &bc1_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, zero_colors
},
8023 {&ps_ld
, &bc2_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
8024 {&ps_ld
, &bc2_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, zero_colors
},
8025 {&ps_ld
, &bc3_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
8026 {&ps_ld
, &bc3_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, zero_colors
},
8027 {&ps_ld
, &bc1_texture_srgb
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
8028 {&ps_ld
, &bc2_texture_srgb
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
8029 {&ps_ld
, &bc3_texture_srgb
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
8030 {&ps_ld
, &bc4_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc4_colors
},
8031 {&ps_ld
, &bc5_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc5_colors
},
8032 {&ps_ld
, &bc6h_u_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
8033 {&ps_ld
, &bc6h_s_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
8034 {&ps_ld
, &bc7_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc7_colors
},
8035 {&ps_ld
, &bc7_texture_srgb
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc7_colors
},
8036 {&ps_ld
, &r9g9b9e5_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, r9g9b9e5_colors
},
8037 {&ps_ld
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, zero_colors
},
8038 {&ps_ld
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, zero_colors
},
8039 {&ps_ld_sint8
, &sint8_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, sint8_colors
},
8040 {&ps_ld_uint8
, &uint8_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, rgba_level_0
},
8041 {&ps_sample
, &bc1_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
8042 {&ps_sample
, &bc2_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
8043 {&ps_sample
, &bc3_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
8044 {&ps_sample
, &bc4_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc4_colors
},
8045 {&ps_sample
, &bc5_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc5_colors
},
8046 {&ps_sample
, &bc6h_u_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
8047 {&ps_sample
, &bc6h_s_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
8048 {&ps_sample
, &bc7_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc7_colors
},
8049 {&ps_sample
, &bc7_texture_srgb
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc7_colors
},
8050 {&ps_sample
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, rgba_level_0
},
8051 {&ps_sample
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, rgba_level_0
},
8052 {&ps_sample
, &rgba_texture
, POINT
, 2.0f
, 0.0f
, MIP_MAX
, 0.0f
, rgba_level_0
},
8053 {&ps_sample
, &rgba_texture
, POINT
, 8.0f
, 0.0f
, MIP_MAX
, 0.0f
, level_1_colors
},
8054 {&ps_sample
, &srgb_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, srgb_colors
},
8055 {&ps_sample
, &a8_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, a8_colors
},
8056 {&ps_sample
, &r9g9b9e5_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, r9g9b9e5_colors
},
8057 {&ps_sample
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, zero_colors
},
8058 {&ps_sample
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, zero_colors
},
8059 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, rgba_level_0
},
8060 {&ps_sample_b
, &rgba_texture
, POINT
, 8.0f
, 0.0f
, MIP_MAX
, 0.0f
, level_1_colors
},
8061 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 8.0f
, level_1_colors
},
8062 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 8.4f
, level_1_colors
},
8063 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 8.5f
, level_2_colors
},
8064 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 9.0f
, level_2_colors
},
8065 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 2.0f
, 1.0f
, rgba_level_0
},
8066 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 2.0f
, 9.0f
, level_2_colors
},
8067 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 1.0f
, 9.0f
, level_1_colors
},
8068 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 9.0f
, rgba_level_0
},
8069 {&ps_sample_b
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, zero_colors
},
8070 {&ps_sample_b
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, zero_colors
},
8071 {&ps_sample_b
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, zero_colors
},
8072 {&ps_sample_b
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 1.0f
, zero_colors
},
8073 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, -1.0f
, rgba_level_0
},
8074 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, rgba_level_0
},
8075 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.4f
, rgba_level_0
},
8076 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.5f
, level_1_colors
},
8077 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 1.0f
, level_1_colors
},
8078 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 1.4f
, level_1_colors
},
8079 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 1.5f
, level_2_colors
},
8080 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 2.0f
, level_2_colors
},
8081 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 3.0f
, level_2_colors
},
8082 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 4.0f
, level_2_colors
},
8083 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 0.0f
, 0.0f
, MIP_MAX
, 1.5f
, lerp_1_2_colors
},
8084 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 0.0f
, MIP_MAX
, -2.0f
, rgba_level_0
},
8085 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 0.0f
, MIP_MAX
, -1.0f
, level_1_colors
},
8086 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 0.0f
, MIP_MAX
, 0.0f
, level_2_colors
},
8087 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 0.0f
, MIP_MAX
, 1.0f
, level_2_colors
},
8088 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 0.0f
, MIP_MAX
, 1.5f
, level_2_colors
},
8089 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 2.0f
, 2.0f
, -9.0f
, level_2_colors
},
8090 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 2.0f
, 2.0f
, -1.0f
, level_2_colors
},
8091 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 2.0f
, 2.0f
, 0.0f
, level_2_colors
},
8092 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 2.0f
, 2.0f
, 1.0f
, level_2_colors
},
8093 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 2.0f
, 2.0f
, 9.0f
, level_2_colors
},
8094 {&ps_sample_l
, &rgba_texture
, POINT
, 2.0f
, 2.0f
, 2.0f
, -9.0f
, level_2_colors
},
8095 {&ps_sample_l
, &rgba_texture
, POINT
, 2.0f
, 2.0f
, 2.0f
, -1.0f
, level_2_colors
},
8096 {&ps_sample_l
, &rgba_texture
, POINT
, 2.0f
, 2.0f
, 2.0f
, 0.0f
, level_2_colors
},
8097 {&ps_sample_l
, &rgba_texture
, POINT
, 2.0f
, 2.0f
, 2.0f
, 1.0f
, level_2_colors
},
8098 {&ps_sample_l
, &rgba_texture
, POINT
, 2.0f
, 2.0f
, 2.0f
, 9.0f
, level_2_colors
},
8099 {&ps_sample_l
, NULL
, POINT
, 2.0f
, 2.0f
, 0.0f
, 0.0f
, zero_colors
},
8100 {&ps_sample_l
, NULL
, POINT
, 2.0f
, 2.0f
, 0.0f
, 1.0f
, zero_colors
},
8101 {&ps_sample_l
, NULL
, POINT
, 2.0f
, 2.0f
, MIP_MAX
, 0.0f
, zero_colors
},
8102 {&ps_sample_l
, NULL
, POINT
, 2.0f
, 2.0f
, MIP_MAX
, 1.0f
, zero_colors
},
8103 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, -9.0f
, red_colors
},
8104 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, -1.0f
, red_colors
},
8105 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, red_colors
},
8106 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.4f
, red_colors
},
8107 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.5f
, red_colors
},
8108 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 1.0f
, green_data
},
8109 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 1.4f
, green_data
},
8110 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 2.0f
, blue_colors
},
8111 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 2.1f
, blue_colors
},
8112 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 3.0f
, blue_colors
},
8113 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 3.1f
, blue_colors
},
8114 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 9.0f
, blue_colors
},
8115 {&ps_sample_2d_array
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, zero_colors
},
8116 {&ps_sample_2d_array
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, zero_colors
},
8117 {&ps_sample_2d_array
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 2.0f
, zero_colors
},
8118 {&ps_sample_2d_array
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, zero_colors
},
8119 {&ps_sample_2d_array
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 1.0f
, zero_colors
},
8120 {&ps_sample_2d_array
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 2.0f
, zero_colors
},
8125 static const struct srv_test
8127 const struct shader
*ps
;
8128 const struct texture
*texture
;
8129 struct srv_desc srv_desc
;
8131 const DWORD
*expected_colors
;
8135 #define TEX_2D D3D11_SRV_DIMENSION_TEXTURE2D
8136 #define TEX_2D_ARRAY D3D11_SRV_DIMENSION_TEXTURE2DARRAY
8137 #define BC1_UNORM DXGI_FORMAT_BC1_UNORM
8138 #define BC1_UNORM_SRGB DXGI_FORMAT_BC1_UNORM_SRGB
8139 #define BC2_UNORM DXGI_FORMAT_BC2_UNORM
8140 #define BC2_UNORM_SRGB DXGI_FORMAT_BC2_UNORM_SRGB
8141 #define BC3_UNORM DXGI_FORMAT_BC3_UNORM
8142 #define BC3_UNORM_SRGB DXGI_FORMAT_BC3_UNORM_SRGB
8143 #define R8G8B8A8_UNORM_SRGB DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
8144 #define R8G8B8A8_UNORM DXGI_FORMAT_R8G8B8A8_UNORM
8145 #define R8G8_SNORM DXGI_FORMAT_R8G8_SNORM
8146 #define R32_FLOAT DXGI_FORMAT_R32_FLOAT
8147 #define R32_UINT DXGI_FORMAT_R32_UINT
8148 #define FMT_UNKNOWN DXGI_FORMAT_UNKNOWN
8149 {&ps_sample
, &bc1_typeless
, {BC1_UNORM
, TEX_2D
, 0, 1}, 0.0f
, bc_colors
},
8150 {&ps_sample
, &bc1_typeless
, {BC1_UNORM_SRGB
, TEX_2D
, 0, 1}, 0.0f
, bc_colors
},
8151 {&ps_sample
, &bc2_typeless
, {BC2_UNORM
, TEX_2D
, 0, 1}, 0.0f
, bc_colors
},
8152 {&ps_sample
, &bc2_typeless
, {BC2_UNORM_SRGB
, TEX_2D
, 0, 1}, 0.0f
, bc_colors
},
8153 {&ps_sample
, &bc3_typeless
, {BC3_UNORM
, TEX_2D
, 0, 1}, 0.0f
, bc_colors
},
8154 {&ps_sample
, &bc3_typeless
, {BC3_UNORM_SRGB
, TEX_2D
, 0, 1}, 0.0f
, bc_colors
},
8155 {&ps_sample
, &srgb_typeless
, {R8G8B8A8_UNORM_SRGB
, TEX_2D
, 0, 1}, 0.0f
, srgb_colors
},
8156 {&ps_sample
, &srgb_typeless
, {R8G8B8A8_UNORM
, TEX_2D
, 0, 1}, 0.0f
, srgb_data
},
8157 {&ps_sample
, &r32f_typeless
, {R32_FLOAT
, TEX_2D
, 0, 1}, 0.0f
, r32f_colors
},
8158 {&ps_sample
, &r32f_float
, {R32_FLOAT
, TEX_2D
, 0, 1}, 0.0f
, r32f_colors
},
8159 {&ps_sample
, &r8g8_snorm
, {R8G8_SNORM
, TEX_2D
, 0, 1}, 0.0f
, snorm_colors
},
8160 {&ps_sample
, &array_2d_texture
, {FMT_UNKNOWN
, TEX_2D
, 0, 1}, 0.0f
, red_colors
},
8161 {&ps_sample_2d_array
, &array_2d_texture
, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 1, 0, 1}, 0.0f
, red_colors
},
8162 {&ps_sample_2d_array
, &array_2d_texture
, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 1, 1, 1}, 0.0f
, green_data
},
8163 {&ps_sample_2d_array
, &array_2d_texture
, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 1, 2, 1}, 0.0f
, blue_colors
},
8164 {&ps_ld_uint8
, &r32u_typeless
, {R32_UINT
, TEX_2D
, 0, 1}, 0.0f
, r32u_colors
},
8168 #undef BC1_UNORM_SRGB
8170 #undef BC2_UNORM_SRGB
8172 #undef BC3_UNORM_SRGB
8173 #undef R8G8B8A8_UNORM_SRGB
8174 #undef R8G8B8A8_UNORM
8181 if (!init_test_context(&test_context
, NULL
))
8184 device
= test_context
.device
;
8185 context
= test_context
.immediate_context
;
8186 feature_level
= ID3D11Device_GetFeatureLevel(device
);
8188 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(ps_constant
), NULL
);
8190 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
8192 texture_desc
.SampleDesc
.Count
= 1;
8193 texture_desc
.SampleDesc
.Quality
= 0;
8194 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
8195 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
8196 texture_desc
.CPUAccessFlags
= 0;
8197 texture_desc
.MiscFlags
= 0;
8199 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
8200 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
8201 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
8202 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
8203 sampler_desc
.MipLODBias
= 0.0f
;
8204 sampler_desc
.MaxAnisotropy
= 0;
8205 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
8206 sampler_desc
.BorderColor
[0] = 0.0f
;
8207 sampler_desc
.BorderColor
[1] = 0.0f
;
8208 sampler_desc
.BorderColor
[2] = 0.0f
;
8209 sampler_desc
.BorderColor
[3] = 0.0f
;
8210 sampler_desc
.MinLOD
= 0.0f
;
8211 sampler_desc
.MaxLOD
= D3D11_FLOAT32_MAX
;
8218 current_texture
= NULL
;
8219 for (i
= 0; i
< ARRAY_SIZE(texture_tests
); ++i
)
8221 const struct texture_test
*test
= &texture_tests
[i
];
8223 if (test
->texture
&& (test
->texture
->format
== DXGI_FORMAT_BC7_UNORM
8224 || test
->texture
->format
== DXGI_FORMAT_BC7_UNORM_SRGB
)
8225 && feature_level
< D3D_FEATURE_LEVEL_11_0
)
8227 skip("Feature level >= 11.0 is required for BC7 tests.\n");
8231 if (test
->texture
&& (test
->texture
->format
== DXGI_FORMAT_BC6H_UF16
8232 || test
->texture
->format
== DXGI_FORMAT_BC6H_SF16
)
8233 && feature_level
< D3D_FEATURE_LEVEL_11_0
)
8235 skip("Feature level >= 11.0 is required for BC6H tests.\n");
8239 if (current_ps
!= test
->ps
)
8242 ID3D11PixelShader_Release(ps
);
8244 current_ps
= test
->ps
;
8246 hr
= ID3D11Device_CreatePixelShader(device
, current_ps
->code
, current_ps
->size
, NULL
, &ps
);
8247 ok(SUCCEEDED(hr
), "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
8249 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
8252 if (current_texture
!= test
->texture
)
8255 ID3D11Texture2D_Release(texture
);
8257 ID3D11ShaderResourceView_Release(srv
);
8259 current_texture
= test
->texture
;
8261 if (current_texture
)
8263 texture_desc
.Width
= current_texture
->width
;
8264 texture_desc
.Height
= current_texture
->height
;
8265 texture_desc
.MipLevels
= current_texture
->miplevel_count
;
8266 texture_desc
.ArraySize
= current_texture
->array_size
;
8267 texture_desc
.Format
= current_texture
->format
;
8269 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, current_texture
->data
, &texture
);
8270 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
8272 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
8273 ok(SUCCEEDED(hr
), "Test %u: Failed to create shader resource view, hr %#x.\n", i
, hr
);
8281 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
8284 if (!sampler
|| (sampler_desc
.Filter
!= test
->filter
8285 || sampler_desc
.MipLODBias
!= test
->lod_bias
8286 || sampler_desc
.MinLOD
!= test
->min_lod
8287 || sampler_desc
.MaxLOD
!= test
->max_lod
))
8290 ID3D11SamplerState_Release(sampler
);
8292 sampler_desc
.Filter
= test
->filter
;
8293 sampler_desc
.MipLODBias
= test
->lod_bias
;
8294 sampler_desc
.MinLOD
= test
->min_lod
;
8295 sampler_desc
.MaxLOD
= test
->max_lod
;
8297 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler
);
8298 ok(SUCCEEDED(hr
), "Test %u: Failed to create sampler state, hr %#x.\n", i
, hr
);
8300 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler
);
8303 ps_constant
.x
= test
->ps_constant
;
8304 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &ps_constant
, 0, 0);
8306 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
8308 draw_quad(&test_context
);
8310 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
8311 for (y
= 0; y
< 4; ++y
)
8313 for (x
= 0; x
< 4; ++x
)
8315 color
= get_readback_color(&rb
, 80 + x
* 160, 60 + y
* 120, 0);
8316 ok(compare_color(color
, test
->expected_colors
[y
* 4 + x
], 2),
8317 "Test %u: Got unexpected color 0x%08x at (%u, %u).\n", i
, color
, x
, y
);
8320 release_resource_readback(&rb
);
8323 ID3D11ShaderResourceView_Release(srv
);
8324 ID3D11SamplerState_Release(sampler
);
8326 ID3D11Texture2D_Release(texture
);
8327 ID3D11PixelShader_Release(ps
);
8329 if (is_warp_device(device
) && feature_level
< D3D_FEATURE_LEVEL_11_0
)
8331 win_skip("SRV tests are broken on WARP.\n");
8332 ID3D11Buffer_Release(cb
);
8333 release_test_context(&test_context
);
8337 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
8338 sampler_desc
.MipLODBias
= 0.0f
;
8339 sampler_desc
.MinLOD
= 0.0f
;
8340 sampler_desc
.MaxLOD
= D3D11_FLOAT32_MAX
;
8342 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler
);
8343 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
8345 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler
);
8351 current_texture
= NULL
;
8352 for (i
= 0; i
< ARRAY_SIZE(srv_tests
); ++i
)
8354 const struct srv_test
*test
= &srv_tests
[i
];
8356 if (current_ps
!= test
->ps
)
8359 ID3D11PixelShader_Release(ps
);
8361 current_ps
= test
->ps
;
8363 hr
= ID3D11Device_CreatePixelShader(device
, current_ps
->code
, current_ps
->size
, NULL
, &ps
);
8364 ok(SUCCEEDED(hr
), "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
8366 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
8369 if (current_texture
!= test
->texture
)
8372 ID3D11Texture2D_Release(texture
);
8374 current_texture
= test
->texture
;
8376 texture_desc
.Width
= current_texture
->width
;
8377 texture_desc
.Height
= current_texture
->height
;
8378 texture_desc
.MipLevels
= current_texture
->miplevel_count
;
8379 texture_desc
.ArraySize
= current_texture
->array_size
;
8380 texture_desc
.Format
= current_texture
->format
;
8382 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, current_texture
->data
, &texture
);
8383 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
8387 ID3D11ShaderResourceView_Release(srv
);
8389 get_srv_desc(&srv_desc
, &test
->srv_desc
);
8390 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, &srv_desc
, &srv
);
8391 ok(SUCCEEDED(hr
), "Test %u: Failed to create shader resource view, hr %#x.\n", i
, hr
);
8393 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
8395 ps_constant
.x
= test
->ps_constant
;
8396 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &ps_constant
, 0, 0);
8398 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
8400 draw_quad(&test_context
);
8402 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
8403 for (y
= 0; y
< 4; ++y
)
8405 for (x
= 0; x
< 4; ++x
)
8407 color
= get_readback_color(&rb
, 80 + x
* 160, 60 + y
* 120, 0);
8408 ok(compare_color(color
, test
->expected_colors
[y
* 4 + x
], 1),
8409 "Test %u: Got unexpected color 0x%08x at (%u, %u).\n", i
, color
, x
, y
);
8412 release_resource_readback(&rb
);
8414 ID3D11PixelShader_Release(ps
);
8415 ID3D11Texture2D_Release(texture
);
8416 ID3D11ShaderResourceView_Release(srv
);
8417 ID3D11SamplerState_Release(sampler
);
8419 ID3D11Buffer_Release(cb
);
8420 release_test_context(&test_context
);
8423 static void test_cube_maps(void)
8431 unsigned int i
, j
, sub_resource_idx
, sub_resource_count
;
8432 struct d3d11_test_context test_context
;
8433 D3D11_TEXTURE2D_DESC texture_desc
;
8434 const struct shader
*current_ps
;
8435 D3D_FEATURE_LEVEL feature_level
;
8436 ID3D11ShaderResourceView
*srv
;
8437 ID3D11DeviceContext
*context
;
8438 ID3D11Texture2D
*rtv_texture
;
8439 ID3D11RenderTargetView
*rtv
;
8440 struct vec4 expected_result
;
8441 ID3D11Resource
*texture
;
8442 ID3D11PixelShader
*ps
;
8443 ID3D11Device
*device
;
8444 float data
[64 * 64];
8453 unsigned int padding
;
8456 static const DWORD ps_cube_code
[] =
8465 float4
main(float4 position
: SV_POSITION
) : SV_Target
8468 p
.x
= position
.x
/ 640.0f
;
8469 p
.y
= position
.y
/ 480.0f
;
8475 coord
= float3(1.0f
, p
.x
, p
.y
);
8478 coord
= float3(-1.0f
, p
.x
, p
.y
);
8481 coord
= float3(p
.x
, 1.0f
, p
.y
);
8484 coord
= float3(p
.x
, -1.0f
, p
.y
);
8487 coord
= float3(p
.x
, p
.y
, 1.0f
);
8491 coord
= float3(p
.x
, p
.y
, -1.0f
);
8494 return t
.SampleLevel(s
, coord
, level
);
8497 0x43425844, 0x039aee18, 0xfd630453, 0xb884cf0f, 0x10100744, 0x00000001, 0x00000310, 0x00000003,
8498 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
8499 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
8500 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
8501 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000274, 0x00000040,
8502 0x0000009d, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000, 0x00000000,
8503 0x04003058, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001,
8504 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0400004c, 0x0020800a, 0x00000000,
8505 0x00000000, 0x03000006, 0x00004001, 0x00000000, 0x05000036, 0x00100012, 0x00000000, 0x00004001,
8506 0x3f800000, 0x0a000038, 0x00100062, 0x00000000, 0x00101106, 0x00000000, 0x00004002, 0x00000000,
8507 0x3acccccd, 0x3b088889, 0x00000000, 0x01000002, 0x03000006, 0x00004001, 0x00000001, 0x05000036,
8508 0x00100012, 0x00000000, 0x00004001, 0xbf800000, 0x0a000038, 0x00100062, 0x00000000, 0x00101106,
8509 0x00000000, 0x00004002, 0x00000000, 0x3acccccd, 0x3b088889, 0x00000000, 0x01000002, 0x03000006,
8510 0x00004001, 0x00000002, 0x0a000038, 0x00100052, 0x00000000, 0x00101106, 0x00000000, 0x00004002,
8511 0x3acccccd, 0x00000000, 0x3b088889, 0x00000000, 0x05000036, 0x00100022, 0x00000000, 0x00004001,
8512 0x3f800000, 0x01000002, 0x03000006, 0x00004001, 0x00000003, 0x0a000038, 0x00100052, 0x00000000,
8513 0x00101106, 0x00000000, 0x00004002, 0x3acccccd, 0x00000000, 0x3b088889, 0x00000000, 0x05000036,
8514 0x00100022, 0x00000000, 0x00004001, 0xbf800000, 0x01000002, 0x03000006, 0x00004001, 0x00000004,
8515 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889,
8516 0x00000000, 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0x3f800000, 0x01000002,
8517 0x0100000a, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
8518 0x3b088889, 0x00000000, 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0xbf800000,
8519 0x01000002, 0x01000017, 0x06000056, 0x00100082, 0x00000000, 0x0020801a, 0x00000000, 0x00000000,
8520 0x0b000048, 0x001020f2, 0x00000000, 0x00100246, 0x00000000, 0x00107e46, 0x00000000, 0x00106000,
8521 0x00000000, 0x0010003a, 0x00000000, 0x0100003e,
8523 static const struct shader ps_cube
= {ps_cube_code
, sizeof(ps_cube_code
)};
8524 static const DWORD ps_cube_array_code
[] =
8534 float4
main(float4 position
: SV_POSITION
) : SV_Target
8537 p
.x
= position
.x
/ 640.0f
;
8538 p
.y
= position
.y
/ 480.0f
;
8544 coord
= float3(1.0f
, p
.x
, p
.y
);
8547 coord
= float3(-1.0f
, p
.x
, p
.y
);
8550 coord
= float3(p
.x
, 1.0f
, p
.y
);
8553 coord
= float3(p
.x
, -1.0f
, p
.y
);
8556 coord
= float3(p
.x
, p
.y
, 1.0f
);
8560 coord
= float3(p
.x
, p
.y
, -1.0f
);
8563 return t
.SampleLevel(s
, float4(coord
, cube
), level
);
8566 0x43425844, 0xb8d5b94a, 0xdb4be034, 0x183aed19, 0xad4af415, 0x00000001, 0x00000328, 0x00000003,
8567 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
8568 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
8569 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
8570 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x0000028c, 0x00000041,
8571 0x000000a3, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000,
8572 0x00000000, 0x04005058, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000,
8573 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x0400004c, 0x0020800a,
8574 0x00000000, 0x00000000, 0x03000006, 0x00004001, 0x00000000, 0x05000036, 0x00100012, 0x00000000,
8575 0x00004001, 0x3f800000, 0x0a000038, 0x00100062, 0x00000000, 0x00101106, 0x00000000, 0x00004002,
8576 0x00000000, 0x3acccccd, 0x3b088889, 0x00000000, 0x01000002, 0x03000006, 0x00004001, 0x00000001,
8577 0x05000036, 0x00100012, 0x00000000, 0x00004001, 0xbf800000, 0x0a000038, 0x00100062, 0x00000000,
8578 0x00101106, 0x00000000, 0x00004002, 0x00000000, 0x3acccccd, 0x3b088889, 0x00000000, 0x01000002,
8579 0x03000006, 0x00004001, 0x00000002, 0x0a000038, 0x00100052, 0x00000000, 0x00101106, 0x00000000,
8580 0x00004002, 0x3acccccd, 0x00000000, 0x3b088889, 0x00000000, 0x05000036, 0x00100022, 0x00000000,
8581 0x00004001, 0x3f800000, 0x01000002, 0x03000006, 0x00004001, 0x00000003, 0x0a000038, 0x00100052,
8582 0x00000000, 0x00101106, 0x00000000, 0x00004002, 0x3acccccd, 0x00000000, 0x3b088889, 0x00000000,
8583 0x05000036, 0x00100022, 0x00000000, 0x00004001, 0xbf800000, 0x01000002, 0x03000006, 0x00004001,
8584 0x00000004, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
8585 0x3b088889, 0x00000000, 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0x3f800000,
8586 0x01000002, 0x0100000a, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002,
8587 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x00004001,
8588 0xbf800000, 0x01000002, 0x01000017, 0x06000056, 0x00100032, 0x00000001, 0x00208a66, 0x00000000,
8589 0x00000000, 0x05000036, 0x00100082, 0x00000000, 0x0010000a, 0x00000001, 0x0b000048, 0x001020f2,
8590 0x00000000, 0x00100e46, 0x00000000, 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0010001a,
8591 0x00000001, 0x0100003e,
8593 static const struct shader ps_cube_array
= {ps_cube_array_code
, sizeof(ps_cube_array_code
)};
8594 static const struct ps_test
8596 const struct shader
*ps
;
8597 unsigned int miplevel_count
;
8598 unsigned int array_size
;
8607 {&ps_cube_array
, 1, 12},
8608 {&ps_cube_array
, 2, 12},
8609 {&ps_cube_array
, 3, 12},
8610 {&ps_cube_array
, 0, 12},
8613 if (!init_test_context(&test_context
, NULL
))
8616 device
= test_context
.device
;
8617 context
= test_context
.immediate_context
;
8618 feature_level
= ID3D11Device_GetFeatureLevel(device
);
8620 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
8621 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
8622 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rtv_texture
);
8623 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
8624 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rtv_texture
, NULL
, &rtv
);
8625 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
8627 memset(&constant
, 0, sizeof(constant
));
8628 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(constant
), &constant
);
8630 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
8631 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
8635 for (i
= 0; i
< ARRAY_SIZE(ps_tests
); ++i
)
8637 const struct ps_test
*test
= &ps_tests
[i
];
8639 if (test
->array_size
/ 6 > 1 && feature_level
< D3D_FEATURE_LEVEL_10_1
)
8641 skip("Test %u: Cube map array textures require feature level 10_1.\n", i
);
8645 if (current_ps
!= test
->ps
)
8648 ID3D11PixelShader_Release(ps
);
8650 current_ps
= test
->ps
;
8652 hr
= ID3D11Device_CreatePixelShader(device
, current_ps
->code
, current_ps
->size
, NULL
, &ps
);
8653 ok(SUCCEEDED(hr
), "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
8654 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
8657 if (!test
->miplevel_count
)
8660 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
8662 memset(&expected_result
, 0, sizeof(expected_result
));
8664 memset(&constant
, 0, sizeof(constant
));
8665 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
8666 draw_quad(&test_context
);
8667 check_texture_vec4(rtv_texture
, &expected_result
, 0);
8669 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
8670 draw_quad(&test_context
);
8671 check_texture_vec4(rtv_texture
, &expected_result
, 0);
8675 texture_desc
.Width
= 64;
8676 texture_desc
.Height
= 64;
8677 texture_desc
.MipLevels
= test
->miplevel_count
;
8678 texture_desc
.ArraySize
= test
->array_size
;
8679 texture_desc
.Format
= DXGI_FORMAT_R32_FLOAT
;
8680 texture_desc
.SampleDesc
.Count
= 1;
8681 texture_desc
.SampleDesc
.Quality
= 0;
8682 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
8683 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
8684 texture_desc
.CPUAccessFlags
= 0;
8685 texture_desc
.MiscFlags
= D3D11_RESOURCE_MISC_TEXTURECUBE
;
8686 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, (ID3D11Texture2D
**)&texture
);
8687 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
8689 hr
= ID3D11Device_CreateShaderResourceView(device
, texture
, NULL
, &srv
);
8690 ok(SUCCEEDED(hr
), "Test %u: Failed to create shader resource view, hr %#x.\n", i
, hr
);
8691 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
8693 sub_resource_count
= texture_desc
.MipLevels
* texture_desc
.ArraySize
;
8694 for (sub_resource_idx
= 0; sub_resource_idx
< sub_resource_count
; ++sub_resource_idx
)
8696 for (j
= 0; j
< ARRAY_SIZE(data
); ++j
)
8697 data
[j
] = sub_resource_idx
;
8698 ID3D11DeviceContext_UpdateSubresource(context
, texture
, sub_resource_idx
, NULL
, data
,
8699 texture_desc
.Width
* sizeof(*data
), 0);
8702 expected_result
.y
= expected_result
.z
= 0.0f
;
8703 expected_result
.w
= 1.0f
;
8704 for (sub_resource_idx
= 0; sub_resource_idx
< sub_resource_count
; ++sub_resource_idx
)
8706 constant
.face
= (sub_resource_idx
/ texture_desc
.MipLevels
) % 6;
8707 constant
.level
= sub_resource_idx
% texture_desc
.MipLevels
;
8708 constant
.cube
= (sub_resource_idx
/ texture_desc
.MipLevels
) / 6;
8709 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
8711 draw_quad(&test_context
);
8712 expected_result
.x
= sub_resource_idx
;
8713 /* Avoid testing values affected by seamless cube map filtering. */
8714 SetRect(&rect
, 100, 100, 540, 380);
8715 check_texture_sub_resource_vec4(rtv_texture
, 0, &rect
, &expected_result
, 0);
8718 ID3D11Resource_Release(texture
);
8719 ID3D11ShaderResourceView_Release(srv
);
8721 ID3D11PixelShader_Release(ps
);
8723 ID3D11Buffer_Release(cb
);
8724 ID3D11RenderTargetView_Release(rtv
);
8725 ID3D11Texture2D_Release(rtv_texture
);
8726 release_test_context(&test_context
);
8729 static void test_depth_stencil_sampling(void)
8731 ID3D11PixelShader
*ps_cmp
, *ps_depth
, *ps_stencil
, *ps_depth_stencil
;
8732 ID3D11ShaderResourceView
*depth_srv
, *stencil_srv
;
8733 ID3D11SamplerState
*cmp_sampler
, *sampler
;
8734 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
8735 D3D11_DEPTH_STENCIL_VIEW_DESC dsv_desc
;
8736 struct d3d11_test_context test_context
;
8737 ID3D11Texture2D
*texture
, *rt_texture
;
8738 D3D11_TEXTURE2D_DESC texture_desc
;
8739 D3D11_SAMPLER_DESC sampler_desc
;
8740 ID3D11DeviceContext
*context
;
8741 ID3D11DepthStencilView
*dsv
;
8742 ID3D11RenderTargetView
*rtv
;
8743 struct vec4 ps_constant
;
8744 ID3D11Device
*device
;
8749 static const float black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
8750 static const DWORD ps_compare_code
[] =
8754 SamplerComparisonState s
;
8758 float4
main(float4 position
: SV_Position
) : SV_Target
8760 return t
.SampleCmp(s
, float2(position
.x
/ 640.0f
, position
.y
/ 480.0f
), ref
);
8763 0x43425844, 0xc2e0d84e, 0x0522c395, 0x9ff41580, 0xd3ca29cc, 0x00000001, 0x00000164, 0x00000003,
8764 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
8765 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
8766 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
8767 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000c8, 0x00000040,
8768 0x00000032, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300085a, 0x00106000, 0x00000000,
8769 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001,
8770 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0a000038, 0x00100032, 0x00000000,
8771 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x0c000046,
8772 0x00100012, 0x00000000, 0x00100046, 0x00000000, 0x00107006, 0x00000000, 0x00106000, 0x00000000,
8773 0x0020800a, 0x00000000, 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100006, 0x00000000,
8776 static const DWORD ps_sample_code
[] =
8782 float4
main(float4 position
: SV_Position
) : SV_Target
8784 return t
.Sample(s
, float2(position
.x
/ 640.0f
, position
.y
/ 480.0f
));
8787 0x43425844, 0x7472c092, 0x5548f00e, 0xf4e007f1, 0x5970429c, 0x00000001, 0x00000134, 0x00000003,
8788 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
8789 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
8790 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
8791 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
8792 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
8793 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
8794 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
8795 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
8796 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
8798 static const DWORD ps_stencil_code
[] =
8803 float4
main(float4 position
: SV_Position
) : SV_Target
8806 t
.GetDimensions(s
.x
, s
.y
);
8807 return t
.Load(int3(float3(s
.x
* position
.x
/ 640.0f
, s
.y
* position
.y
/ 480.0f
, 0))).y
;
8810 0x43425844, 0x929fced8, 0x2cd93320, 0x0591ece3, 0xee50d04a, 0x00000001, 0x000001a0, 0x00000003,
8811 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
8812 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
8813 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
8814 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000104, 0x00000040,
8815 0x00000041, 0x04001858, 0x00107000, 0x00000000, 0x00004444, 0x04002064, 0x00101032, 0x00000000,
8816 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0700003d, 0x001000f2,
8817 0x00000000, 0x00004001, 0x00000000, 0x00107e46, 0x00000000, 0x07000038, 0x00100032, 0x00000000,
8818 0x00100046, 0x00000000, 0x00101046, 0x00000000, 0x0a000038, 0x00100032, 0x00000000, 0x00100046,
8819 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x0500001b, 0x00100032,
8820 0x00000000, 0x00100046, 0x00000000, 0x08000036, 0x001000c2, 0x00000000, 0x00004002, 0x00000000,
8821 0x00000000, 0x00000000, 0x00000000, 0x0700002d, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
8822 0x00107e46, 0x00000000, 0x05000056, 0x001020f2, 0x00000000, 0x00100556, 0x00000000, 0x0100003e,
8824 static const DWORD ps_depth_stencil_code
[] =
8828 Texture2D depth_tex
;
8829 Texture2D
<uint4
> stencil_tex
;
8831 float main(float4 position
: SV_Position
) : SV_Target
8834 float depth
, stencil
;
8835 depth_tex
.GetDimensions(s
.x
, s
.y
);
8836 p
= float2(s
.x
* position
.x
/ 640.0f
, s
.y
* position
.y
/ 480.0f
);
8837 depth
= depth_tex
.Sample(samp
, p
).r
;
8838 stencil
= stencil_tex
.Load(int3(float3(p
.x
, p
.y
, 0))).y
;
8839 return depth
+ stencil
;
8842 0x43425844, 0x348f8377, 0x977d1ee0, 0x8cca4f35, 0xff5c5afc, 0x00000001, 0x000001fc, 0x00000003,
8843 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
8844 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
8845 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
8846 0x00000000, 0x00000e01, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000160, 0x00000040,
8847 0x00000058, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
8848 0x04001858, 0x00107000, 0x00000001, 0x00004444, 0x04002064, 0x00101032, 0x00000000, 0x00000001,
8849 0x03000065, 0x00102012, 0x00000000, 0x02000068, 0x00000002, 0x0700003d, 0x001000f2, 0x00000000,
8850 0x00004001, 0x00000000, 0x00107e46, 0x00000000, 0x07000038, 0x00100032, 0x00000000, 0x00100046,
8851 0x00000000, 0x00101046, 0x00000000, 0x0a000038, 0x00100032, 0x00000000, 0x00100046, 0x00000000,
8852 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x0500001b, 0x00100032, 0x00000001,
8853 0x00100046, 0x00000000, 0x09000045, 0x001000f2, 0x00000000, 0x00100046, 0x00000000, 0x00107e46,
8854 0x00000000, 0x00106000, 0x00000000, 0x08000036, 0x001000c2, 0x00000001, 0x00004002, 0x00000000,
8855 0x00000000, 0x00000000, 0x00000000, 0x0700002d, 0x001000f2, 0x00000001, 0x00100e46, 0x00000001,
8856 0x00107e46, 0x00000001, 0x05000056, 0x00100022, 0x00000000, 0x0010001a, 0x00000001, 0x07000000,
8857 0x00102012, 0x00000000, 0x0010001a, 0x00000000, 0x0010000a, 0x00000000, 0x0100003e,
8859 static const struct test
8861 DXGI_FORMAT typeless_format
;
8862 DXGI_FORMAT dsv_format
;
8863 DXGI_FORMAT depth_view_format
;
8864 DXGI_FORMAT stencil_view_format
;
8868 {DXGI_FORMAT_R32G8X24_TYPELESS
, DXGI_FORMAT_D32_FLOAT_S8X24_UINT
,
8869 DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS
, DXGI_FORMAT_X32_TYPELESS_G8X24_UINT
},
8870 {DXGI_FORMAT_R32_TYPELESS
, DXGI_FORMAT_D32_FLOAT
,
8871 DXGI_FORMAT_R32_FLOAT
},
8872 {DXGI_FORMAT_R24G8_TYPELESS
, DXGI_FORMAT_D24_UNORM_S8_UINT
,
8873 DXGI_FORMAT_R24_UNORM_X8_TYPELESS
, DXGI_FORMAT_X24_TYPELESS_G8_UINT
},
8874 {DXGI_FORMAT_R16_TYPELESS
, DXGI_FORMAT_D16_UNORM
,
8875 DXGI_FORMAT_R16_UNORM
},
8878 if (!init_test_context(&test_context
, NULL
))
8881 device
= test_context
.device
;
8882 context
= test_context
.immediate_context
;
8884 if (is_amd_device(device
))
8886 /* Reads from depth/stencil shader resource views return stale values on some AMD drivers. */
8887 win_skip("Some AMD drivers have a bug affecting the test.\n");
8888 release_test_context(&test_context
);
8892 sampler_desc
.Filter
= D3D11_FILTER_COMPARISON_MIN_MAG_MIP_POINT
;
8893 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
8894 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
8895 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
8896 sampler_desc
.MipLODBias
= 0.0f
;
8897 sampler_desc
.MaxAnisotropy
= 0;
8898 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_GREATER
;
8899 sampler_desc
.BorderColor
[0] = 0.0f
;
8900 sampler_desc
.BorderColor
[1] = 0.0f
;
8901 sampler_desc
.BorderColor
[2] = 0.0f
;
8902 sampler_desc
.BorderColor
[3] = 0.0f
;
8903 sampler_desc
.MinLOD
= 0.0f
;
8904 sampler_desc
.MaxLOD
= 0.0f
;
8905 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &cmp_sampler
);
8906 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
8908 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
8909 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
8910 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler
);
8911 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
8913 texture_desc
.Width
= 640;
8914 texture_desc
.Height
= 480;
8915 texture_desc
.MipLevels
= 1;
8916 texture_desc
.ArraySize
= 1;
8917 texture_desc
.Format
= DXGI_FORMAT_R32_FLOAT
;
8918 texture_desc
.SampleDesc
.Count
= 1;
8919 texture_desc
.SampleDesc
.Quality
= 0;
8920 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
8921 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
8922 texture_desc
.CPUAccessFlags
= 0;
8923 texture_desc
.MiscFlags
= 0;
8924 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rt_texture
);
8925 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
8926 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rt_texture
, NULL
, &rtv
);
8927 ok(SUCCEEDED(hr
), "Failed to create render target, hr %#x.\n", hr
);
8928 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
8930 memset(&ps_constant
, 0, sizeof(ps_constant
));
8931 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(ps_constant
), &ps_constant
);
8932 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
8934 hr
= ID3D11Device_CreatePixelShader(device
, ps_compare_code
, sizeof(ps_compare_code
), NULL
, &ps_cmp
);
8935 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
8936 hr
= ID3D11Device_CreatePixelShader(device
, ps_sample_code
, sizeof(ps_sample_code
), NULL
, &ps_depth
);
8937 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
8938 hr
= ID3D11Device_CreatePixelShader(device
, ps_stencil_code
, sizeof(ps_stencil_code
), NULL
, &ps_stencil
);
8939 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
8940 hr
= ID3D11Device_CreatePixelShader(device
, ps_depth_stencil_code
, sizeof(ps_depth_stencil_code
), NULL
,
8942 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
8944 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
8946 texture_desc
.Format
= tests
[i
].typeless_format
;
8947 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
| D3D11_BIND_DEPTH_STENCIL
;
8948 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
8949 ok(SUCCEEDED(hr
), "Failed to create texture for format %#x, hr %#x.\n",
8950 texture_desc
.Format
, hr
);
8952 dsv_desc
.Format
= tests
[i
].dsv_format
;
8953 dsv_desc
.ViewDimension
= D3D11_DSV_DIMENSION_TEXTURE2D
;
8955 U(dsv_desc
).Texture2D
.MipSlice
= 0;
8956 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, &dsv_desc
, &dsv
);
8957 ok(SUCCEEDED(hr
), "Failed to create depth stencil view for format %#x, hr %#x.\n",
8958 dsv_desc
.Format
, hr
);
8960 srv_desc
.Format
= tests
[i
].depth_view_format
;
8961 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_TEXTURE2D
;
8962 U(srv_desc
).Texture2D
.MostDetailedMip
= 0;
8963 U(srv_desc
).Texture2D
.MipLevels
= 1;
8964 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, &srv_desc
, &depth_srv
);
8965 ok(SUCCEEDED(hr
), "Failed to create depth shader resource view for format %#x, hr %#x.\n",
8966 srv_desc
.Format
, hr
);
8968 ID3D11DeviceContext_PSSetShader(context
, ps_cmp
, NULL
, 0);
8969 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &depth_srv
);
8970 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &cmp_sampler
);
8972 ps_constant
.x
= 0.5f
;
8973 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
8974 NULL
, &ps_constant
, 0, 0);
8976 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
8977 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
8978 draw_quad(&test_context
);
8979 check_texture_float(rt_texture
, 0.0f
, 2);
8981 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 0.0f
, 0);
8982 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
8983 draw_quad(&test_context
);
8984 check_texture_float(rt_texture
, 1.0f
, 2);
8986 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 0.5f
, 0);
8987 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
8988 draw_quad(&test_context
);
8989 check_texture_float(rt_texture
, 0.0f
, 2);
8991 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 0.6f
, 0);
8992 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
8993 draw_quad(&test_context
);
8994 check_texture_float(rt_texture
, 0.0f
, 2);
8996 ps_constant
.x
= 0.7f
;
8997 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
8998 NULL
, &ps_constant
, 0, 0);
9000 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
9001 draw_quad(&test_context
);
9002 check_texture_float(rt_texture
, 1.0f
, 2);
9004 ID3D11DeviceContext_PSSetShader(context
, ps_depth
, NULL
, 0);
9005 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler
);
9007 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
9008 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
9009 draw_quad(&test_context
);
9010 check_texture_float(rt_texture
, 1.0f
, 2);
9012 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 0.2f
, 0);
9013 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
9014 draw_quad(&test_context
);
9015 check_texture_float(rt_texture
, 0.2f
, 2);
9017 if (!tests
[i
].stencil_view_format
)
9019 ID3D11DepthStencilView_Release(dsv
);
9020 ID3D11ShaderResourceView_Release(depth_srv
);
9021 ID3D11Texture2D_Release(texture
);
9025 srv_desc
.Format
= tests
[i
].stencil_view_format
;
9026 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, &srv_desc
, &stencil_srv
);
9027 if (hr
== E_OUTOFMEMORY
)
9029 skip("Could not create SRV for format %#x.\n", srv_desc
.Format
);
9030 ID3D11DepthStencilView_Release(dsv
);
9031 ID3D11ShaderResourceView_Release(depth_srv
);
9032 ID3D11Texture2D_Release(texture
);
9035 ok(SUCCEEDED(hr
), "Failed to create stencil shader resource view for format %#x, hr %#x.\n",
9036 srv_desc
.Format
, hr
);
9038 ID3D11DeviceContext_PSSetShader(context
, ps_stencil
, NULL
, 0);
9039 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &stencil_srv
);
9041 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_STENCIL
, 0.0f
, 0);
9042 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
9043 draw_quad(&test_context
);
9044 check_texture_float(rt_texture
, 0.0f
, 0);
9046 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_STENCIL
, 0.0f
, 100);
9047 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
9048 draw_quad(&test_context
);
9049 check_texture_float(rt_texture
, 100.0f
, 0);
9051 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_STENCIL
, 0.0f
, 255);
9052 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
9053 draw_quad(&test_context
);
9054 check_texture_float(rt_texture
, 255.0f
, 0);
9056 ID3D11DeviceContext_PSSetShader(context
, ps_depth_stencil
, NULL
, 0);
9057 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &depth_srv
);
9058 ID3D11DeviceContext_PSSetShaderResources(context
, 1, 1, &stencil_srv
);
9060 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
| D3D11_CLEAR_STENCIL
, 0.3f
, 3);
9061 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
9062 draw_quad(&test_context
);
9063 check_texture_float(rt_texture
, 3.3f
, 2);
9065 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
| D3D11_CLEAR_STENCIL
, 1.0f
, 3);
9066 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
9067 draw_quad(&test_context
);
9068 check_texture_float(rt_texture
, 4.0f
, 2);
9070 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
| D3D11_CLEAR_STENCIL
, 0.0f
, 0);
9071 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
9072 draw_quad(&test_context
);
9073 check_texture_float(rt_texture
, 0.0f
, 2);
9075 ID3D11DepthStencilView_Release(dsv
);
9076 ID3D11ShaderResourceView_Release(depth_srv
);
9077 ID3D11ShaderResourceView_Release(stencil_srv
);
9078 ID3D11Texture2D_Release(texture
);
9081 ID3D11Buffer_Release(cb
);
9082 ID3D11PixelShader_Release(ps_cmp
);
9083 ID3D11PixelShader_Release(ps_depth
);
9084 ID3D11PixelShader_Release(ps_depth_stencil
);
9085 ID3D11PixelShader_Release(ps_stencil
);
9086 ID3D11RenderTargetView_Release(rtv
);
9087 ID3D11SamplerState_Release(cmp_sampler
);
9088 ID3D11SamplerState_Release(sampler
);
9089 ID3D11Texture2D_Release(rt_texture
);
9090 release_test_context(&test_context
);
9093 static void test_sample_c_lz(void)
9095 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
9096 D3D11_DEPTH_STENCIL_VIEW_DESC dsv_desc
;
9097 struct d3d11_test_context test_context
;
9098 ID3D11Texture2D
*texture
, *rt_texture
;
9099 D3D11_TEXTURE2D_DESC texture_desc
;
9100 D3D11_SAMPLER_DESC sampler_desc
;
9101 ID3D11ShaderResourceView
*srv
;
9102 ID3D11DeviceContext
*context
;
9103 ID3D11DepthStencilView
*dsv
;
9104 ID3D11RenderTargetView
*rtv
;
9105 ID3D11SamplerState
*sampler
;
9106 struct vec4 ps_constant
;
9107 ID3D11PixelShader
*ps
;
9108 ID3D11Device
*device
;
9114 static const float clear_color
[] = {0.5f
, 0.5f
, 0.5f
, 0.5f
};
9115 static const DWORD ps_array_code
[] =
9119 SamplerComparisonState s
;
9124 float4
main(float4 position
: SV_Position
) : SV_Target
9126 return t
.SampleCmpLevelZero(s
, float3(position
.x
/ 640.0f
, position
.y
/ 480.0f
, layer
), ref
);
9129 0x43425844, 0xfe28b3c3, 0xdd7ef404, 0x8d5874a1, 0x984ff182, 0x00000001, 0x00000180, 0x00000003,
9130 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
9131 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
9132 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
9133 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000e4, 0x00000041,
9134 0x00000039, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300085a, 0x00106000,
9135 0x00000000, 0x04004058, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000,
9136 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0a000038, 0x00100032,
9137 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000,
9138 0x06000036, 0x00100042, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0c000047, 0x00100012,
9139 0x00000000, 0x00100246, 0x00000000, 0x00107006, 0x00000000, 0x00106000, 0x00000000, 0x0020800a,
9140 0x00000000, 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100006, 0x00000000, 0x0100003e,
9142 static const DWORD ps_cube_code
[] =
9146 SamplerComparisonState s
;
9151 float4
main(float4 position
: SV_Position
) : SV_Target
9154 p
.x
= position
.x
/ 640.0f
;
9155 p
.y
= position
.y
/ 480.0f
;
9161 coord
= float3(1.0f
, p
.x
, p
.y
);
9164 coord
= float3(-1.0f
, p
.x
, p
.y
);
9167 coord
= float3(p
.x
, 1.0f
, p
.y
);
9170 coord
= float3(p
.x
, -1.0f
, p
.y
);
9173 coord
= float3(p
.x
, p
.y
, 1.0f
);
9177 coord
= float3(p
.x
, p
.y
, -1.0f
);
9181 return t
.SampleCmpLevelZero(s
, coord
, ref
);
9184 0x43425844, 0xde5655e5, 0x1b116fa1, 0xfce9e757, 0x41c28aac, 0x00000001, 0x00000328, 0x00000003,
9185 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
9186 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
9187 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
9188 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x0000028c, 0x00000041,
9189 0x000000a3, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300085a, 0x00106000,
9190 0x00000000, 0x04003058, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000,
9191 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0600001c, 0x00100012,
9192 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0300004c, 0x0010000a, 0x00000000, 0x03000006,
9193 0x00004001, 0x00000000, 0x05000036, 0x00100012, 0x00000000, 0x00004001, 0x3f800000, 0x0a000038,
9194 0x00100062, 0x00000000, 0x00101106, 0x00000000, 0x00004002, 0x00000000, 0x3acccccd, 0x3b088889,
9195 0x00000000, 0x01000002, 0x03000006, 0x00004001, 0x00000001, 0x05000036, 0x00100012, 0x00000000,
9196 0x00004001, 0xbf800000, 0x0a000038, 0x00100062, 0x00000000, 0x00101106, 0x00000000, 0x00004002,
9197 0x00000000, 0x3acccccd, 0x3b088889, 0x00000000, 0x01000002, 0x03000006, 0x00004001, 0x00000002,
9198 0x0a000038, 0x00100052, 0x00000000, 0x00101106, 0x00000000, 0x00004002, 0x3acccccd, 0x00000000,
9199 0x3b088889, 0x00000000, 0x05000036, 0x00100022, 0x00000000, 0x00004001, 0x3f800000, 0x01000002,
9200 0x03000006, 0x00004001, 0x00000003, 0x0a000038, 0x00100052, 0x00000000, 0x00101106, 0x00000000,
9201 0x00004002, 0x3acccccd, 0x00000000, 0x3b088889, 0x00000000, 0x05000036, 0x00100022, 0x00000000,
9202 0x00004001, 0xbf800000, 0x01000002, 0x03000006, 0x00004001, 0x00000004, 0x0a000038, 0x00100032,
9203 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000,
9204 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0x3f800000, 0x01000002, 0x0100000a, 0x0a000038,
9205 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000,
9206 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0xbf800000, 0x01000002, 0x01000017,
9207 0x0c000047, 0x00100012, 0x00000000, 0x00100246, 0x00000000, 0x00107006, 0x00000000, 0x00106000,
9208 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100006,
9209 0x00000000, 0x0100003e,
9211 static const float depth_values
[] = {1.0f
, 0.0f
, 0.5f
, 0.6f
, 0.4f
, 0.1f
};
9242 if (!init_test_context(&test_context
, NULL
))
9245 device
= test_context
.device
;
9246 context
= test_context
.immediate_context
;
9248 sampler_desc
.Filter
= D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR
;
9249 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
9250 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
9251 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
9252 sampler_desc
.MipLODBias
= 0.0f
;
9253 sampler_desc
.MaxAnisotropy
= 0;
9254 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_GREATER
;
9255 sampler_desc
.BorderColor
[0] = 0.0f
;
9256 sampler_desc
.BorderColor
[1] = 0.0f
;
9257 sampler_desc
.BorderColor
[2] = 0.0f
;
9258 sampler_desc
.BorderColor
[3] = 0.0f
;
9259 sampler_desc
.MinLOD
= 0.0f
;
9260 sampler_desc
.MaxLOD
= 10.0f
;
9261 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler
);
9262 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
9264 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
9265 texture_desc
.Format
= DXGI_FORMAT_R32_FLOAT
;
9266 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rt_texture
);
9267 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
9268 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rt_texture
, NULL
, &rtv
);
9269 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
9270 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
9272 memset(&ps_constant
, 0, sizeof(ps_constant
));
9273 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(ps_constant
), &ps_constant
);
9275 /* 2D array texture */
9276 texture_desc
.Width
= 32;
9277 texture_desc
.Height
= 32;
9278 texture_desc
.MipLevels
= 2;
9279 texture_desc
.ArraySize
= ARRAY_SIZE(depth_values
);
9280 texture_desc
.Format
= DXGI_FORMAT_R32_TYPELESS
;
9281 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
| D3D11_BIND_DEPTH_STENCIL
;
9282 texture_desc
.MiscFlags
= 0;
9283 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
9284 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
9286 for (i
= 0; i
< ARRAY_SIZE(depth_values
); ++i
)
9288 dsv_desc
.Format
= DXGI_FORMAT_D32_FLOAT
;
9289 dsv_desc
.ViewDimension
= D3D11_DSV_DIMENSION_TEXTURE2DARRAY
;
9291 U(dsv_desc
).Texture2DArray
.MipSlice
= 0;
9292 U(dsv_desc
).Texture2DArray
.FirstArraySlice
= i
;
9293 U(dsv_desc
).Texture2DArray
.ArraySize
= 1;
9295 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, &dsv_desc
, &dsv
);
9296 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
9297 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, depth_values
[i
], 0);
9298 ID3D11DepthStencilView_Release(dsv
);
9300 U(dsv_desc
).Texture2DArray
.MipSlice
= 1;
9301 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, &dsv_desc
, &dsv
);
9302 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
9303 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
9304 ID3D11DepthStencilView_Release(dsv
);
9307 srv_desc
.Format
= DXGI_FORMAT_R32_FLOAT
;
9308 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_TEXTURE2DARRAY
;
9309 U(srv_desc
).Texture2DArray
.MostDetailedMip
= 0;
9310 U(srv_desc
).Texture2DArray
.MipLevels
= ~0u;
9311 U(srv_desc
).Texture2DArray
.FirstArraySlice
= 0;
9312 U(srv_desc
).Texture2DArray
.ArraySize
= ~0u;
9313 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, &srv_desc
, &srv
);
9314 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
9316 hr
= ID3D11Device_CreatePixelShader(device
, ps_array_code
, sizeof(ps_array_code
), NULL
, &ps
);
9317 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
9319 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
9320 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
9321 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler
);
9322 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
9324 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
9326 ps_constant
.x
= tests
[i
].d_ref
;
9327 ps_constant
.y
= tests
[i
].layer
;
9328 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
9329 NULL
, &ps_constant
, 0, 0);
9330 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, clear_color
);
9331 draw_quad(&test_context
);
9332 check_texture_float(rt_texture
, tests
[i
].expected
, 2);
9335 ID3D11Texture2D_Release(texture
);
9336 ID3D11ShaderResourceView_Release(srv
);
9337 ID3D11PixelShader_Release(ps
);
9340 texture_desc
.MiscFlags
= D3D11_RESOURCE_MISC_TEXTURECUBE
;
9341 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
9342 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
9344 for (i
= 0; i
< ARRAY_SIZE(depth_values
); ++i
)
9346 dsv_desc
.Format
= DXGI_FORMAT_D32_FLOAT
;
9347 dsv_desc
.ViewDimension
= D3D11_DSV_DIMENSION_TEXTURE2DARRAY
;
9349 U(dsv_desc
).Texture2DArray
.MipSlice
= 0;
9350 U(dsv_desc
).Texture2DArray
.FirstArraySlice
= i
;
9351 U(dsv_desc
).Texture2DArray
.ArraySize
= 1;
9353 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, &dsv_desc
, &dsv
);
9354 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
9355 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, depth_values
[i
], 0);
9356 ID3D11DepthStencilView_Release(dsv
);
9358 U(dsv_desc
).Texture2DArray
.MipSlice
= 1;
9359 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, &dsv_desc
, &dsv
);
9360 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
9361 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
9362 ID3D11DepthStencilView_Release(dsv
);
9365 srv_desc
.Format
= DXGI_FORMAT_R32_FLOAT
;
9366 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_TEXTURECUBE
;
9367 U(srv_desc
).TextureCube
.MostDetailedMip
= 0;
9368 U(srv_desc
).TextureCube
.MipLevels
= ~0u;
9369 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, &srv_desc
, &srv
);
9370 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
9372 hr
= ID3D11Device_CreatePixelShader(device
, ps_cube_code
, sizeof(ps_cube_code
), NULL
, &ps
);
9373 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
9375 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
9376 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
9377 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler
);
9378 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
9380 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
9382 ps_constant
.x
= tests
[i
].d_ref
;
9383 ps_constant
.y
= tests
[i
].layer
;
9384 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
9385 NULL
, &ps_constant
, 0, 0);
9386 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, clear_color
);
9387 draw_quad(&test_context
);
9388 /* Avoid testing values affected by seamless cube map filtering. */
9389 SetRect(&rect
, 100, 100, 540, 380);
9390 check_texture_sub_resource_float(rt_texture
, 0, &rect
, tests
[i
].expected
, 2);
9393 ID3D11Texture2D_Release(texture
);
9394 ID3D11ShaderResourceView_Release(srv
);
9396 ID3D11Buffer_Release(cb
);
9397 ID3D11PixelShader_Release(ps
);
9398 ID3D11RenderTargetView_Release(rtv
);
9399 ID3D11SamplerState_Release(sampler
);
9400 ID3D11Texture2D_Release(rt_texture
);
9401 release_test_context(&test_context
);
9404 static void test_multiple_render_targets(void)
9406 ID3D11RenderTargetView
*rtv
[4], *tmp_rtv
[4];
9407 D3D11_TEXTURE2D_DESC texture_desc
;
9408 ID3D11InputLayout
*input_layout
;
9409 unsigned int stride
, offset
, i
;
9410 ID3D11DeviceContext
*context
;
9411 ID3D11Texture2D
*rt
[4];
9412 ID3D11VertexShader
*vs
;
9413 ID3D11PixelShader
*ps
;
9414 ID3D11Device
*device
;
9419 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
9421 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
9423 static const DWORD vs_code
[] =
9426 float4
main(float4 position
: POSITION
) : SV_POSITION
9431 0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003,
9432 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
9433 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
9434 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
9435 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
9436 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
9437 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
9439 static const DWORD ps_code
[] =
9444 float4 t1
: SV_TARGET0
;
9445 float4 t2
: SV_Target1
;
9446 float4 t3
: SV_TARGET2
;
9447 float4 t4
: SV_Target3
;
9450 output
main(float4 position
: SV_POSITION
)
9453 o
.t1
= (float4
)1.0f
;
9454 o
.t2
= (float4
)0.5f
;
9455 o
.t3
= (float4
)0.2f
;
9456 o
.t4
= float4(0.0f
, 0.2f
, 0.5f
, 1.0f
);
9460 0x43425844, 0x8701ad18, 0xe3d5291d, 0x7b4288a6, 0x01917515, 0x00000001, 0x000001a8, 0x00000003,
9461 0x0000002c, 0x00000060, 0x000000e4, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
9462 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
9463 0x4e47534f, 0x0000007c, 0x00000004, 0x00000008, 0x00000068, 0x00000000, 0x00000000, 0x00000003,
9464 0x00000000, 0x0000000f, 0x00000072, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
9465 0x00000068, 0x00000002, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x00000072, 0x00000003,
9466 0x00000000, 0x00000003, 0x00000003, 0x0000000f, 0x545f5653, 0x45475241, 0x56530054, 0x7261545f,
9467 0x00746567, 0x52444853, 0x000000bc, 0x00000040, 0x0000002f, 0x03000065, 0x001020f2, 0x00000000,
9468 0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x03000065, 0x001020f2,
9469 0x00000003, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x3f800000, 0x3f800000,
9470 0x3f800000, 0x08000036, 0x001020f2, 0x00000001, 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000,
9471 0x3f000000, 0x08000036, 0x001020f2, 0x00000002, 0x00004002, 0x3e4ccccd, 0x3e4ccccd, 0x3e4ccccd,
9472 0x3e4ccccd, 0x08000036, 0x001020f2, 0x00000003, 0x00004002, 0x00000000, 0x3e4ccccd, 0x3f000000,
9473 0x3f800000, 0x0100003e,
9475 static const struct vec2 quad
[] =
9482 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 1.0f
};
9484 if (!(device
= create_device(NULL
)))
9486 skip("Failed to create device.\n");
9490 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
9491 vs_code
, sizeof(vs_code
), &input_layout
);
9492 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
9494 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(quad
), quad
);
9496 texture_desc
.Width
= 640;
9497 texture_desc
.Height
= 480;
9498 texture_desc
.MipLevels
= 1;
9499 texture_desc
.ArraySize
= 1;
9500 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
9501 texture_desc
.SampleDesc
.Count
= 1;
9502 texture_desc
.SampleDesc
.Quality
= 0;
9503 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
9504 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
9505 texture_desc
.CPUAccessFlags
= 0;
9506 texture_desc
.MiscFlags
= 0;
9508 for (i
= 0; i
< ARRAY_SIZE(rt
); ++i
)
9510 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rt
[i
]);
9511 ok(SUCCEEDED(hr
), "Failed to create texture %u, hr %#x.\n", i
, hr
);
9513 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rt
[i
], NULL
, &rtv
[i
]);
9514 ok(SUCCEEDED(hr
), "Failed to create rendertarget view %u, hr %#x.\n", i
, hr
);
9517 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
9518 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
9519 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
9520 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
9522 ID3D11Device_GetImmediateContext(device
, &context
);
9524 ID3D11DeviceContext_OMSetRenderTargets(context
, 4, rtv
, NULL
);
9525 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
9526 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
9527 stride
= sizeof(*quad
);
9529 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, &stride
, &offset
);
9530 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
9531 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
9533 set_viewport(context
, 0.0f
, 0.0f
, 640.0f
, 480.0f
, 0.0f
, 1.0f
);
9535 for (i
= 0; i
< ARRAY_SIZE(rtv
); ++i
)
9536 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
[i
], red
);
9537 ID3D11DeviceContext_Draw(context
, 4, 0);
9538 check_texture_color(rt
[0], 0xffffffff, 2);
9539 check_texture_color(rt
[1], 0x7f7f7f7f, 2);
9540 check_texture_color(rt
[2], 0x33333333, 2);
9541 check_texture_color(rt
[3], 0xff7f3300, 2);
9543 for (i
= 0; i
< ARRAY_SIZE(rtv
); ++i
)
9544 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
[i
], red
);
9545 for (i
= 0; i
< ARRAY_SIZE(tmp_rtv
); ++i
)
9547 memset(tmp_rtv
, 0, sizeof(tmp_rtv
));
9548 tmp_rtv
[i
] = rtv
[i
];
9549 ID3D11DeviceContext_OMSetRenderTargets(context
, 4, tmp_rtv
, NULL
);
9550 ID3D11DeviceContext_Draw(context
, 4, 0);
9552 check_texture_color(rt
[0], 0xffffffff, 2);
9553 check_texture_color(rt
[1], 0x7f7f7f7f, 2);
9554 check_texture_color(rt
[2], 0x33333333, 2);
9555 check_texture_color(rt
[3], 0xff7f3300, 2);
9557 ID3D11Buffer_Release(vb
);
9558 ID3D11PixelShader_Release(ps
);
9559 ID3D11VertexShader_Release(vs
);
9560 ID3D11InputLayout_Release(input_layout
);
9561 for (i
= 0; i
< ARRAY_SIZE(rtv
); ++i
)
9563 ID3D11RenderTargetView_Release(rtv
[i
]);
9564 ID3D11Texture2D_Release(rt
[i
]);
9566 ID3D11DeviceContext_Release(context
);
9567 refcount
= ID3D11Device_Release(device
);
9568 ok(!refcount
, "Device has %u references left.\n", refcount
);
9571 static void test_render_target_views(void)
9575 UINT miplevel_count
;
9579 static const struct vec4 red
= {1.0f
, 0.0f
, 0.0f
, 1.0f
};
9582 struct texture texture
;
9583 struct rtv_desc rtv
;
9584 DWORD expected_colors
[4];
9588 {{2, 1}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2D
, 0},
9589 {0xff0000ff, 0x00000000}},
9590 {{2, 1}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2D
, 1},
9591 {0x00000000, 0xff0000ff}},
9592 {{2, 1}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 0, 1},
9593 {0xff0000ff, 0x00000000}},
9594 {{2, 1}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2DARRAY
, 1, 0, 1},
9595 {0x00000000, 0xff0000ff}},
9596 {{1, 4}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2D
, 0},
9597 {0xff0000ff, 0x00000000, 0x00000000, 0x00000000}},
9598 {{1, 4}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 0, 1},
9599 {0xff0000ff, 0x00000000, 0x00000000, 0x00000000}},
9600 {{1, 4}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 1, 1},
9601 {0x00000000, 0xff0000ff, 0x00000000, 0x00000000}},
9602 {{1, 4}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 2, 1},
9603 {0x00000000, 0x00000000, 0xff0000ff, 0x00000000}},
9604 {{1, 4}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 3, 1},
9605 {0x00000000, 0x00000000, 0x00000000, 0xff0000ff}},
9606 {{1, 4}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 0, 4},
9607 {0xff0000ff, 0x00000000, 0x00000000, 0x00000000}},
9608 {{2, 2}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2D
, 0},
9609 {0xff0000ff, 0x00000000, 0x00000000, 0x00000000}},
9610 {{2, 2}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 0, 1},
9611 {0xff0000ff, 0x00000000, 0x00000000, 0x00000000}},
9612 {{2, 2}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 1, 1},
9613 {0x00000000, 0x00000000, 0xff0000ff, 0x00000000}},
9614 {{2, 2}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2DARRAY
, 1, 0, 1},
9615 {0x00000000, 0xff0000ff, 0x00000000, 0x00000000}},
9616 {{2, 2}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2DARRAY
, 1, 1, 1},
9617 {0x00000000, 0x00000000, 0x00000000, 0xff0000ff}},
9619 #define FMT_UNKNOWN DXGI_FORMAT_UNKNOWN
9620 #define RGBA8_UNORM DXGI_FORMAT_R8G8B8A8_UNORM
9621 #define RGBA8_SRGB DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
9622 #define RGBA8_UINT DXGI_FORMAT_R8G8B8A8_UINT
9623 #define RGBA8_TL DXGI_FORMAT_R8G8B8A8_TYPELESS
9624 #define DIM_UNKNOWN D3D11_RTV_DIMENSION_UNKNOWN
9625 #define TEX_1D D3D11_RTV_DIMENSION_TEXTURE1D
9626 #define TEX_1D_ARRAY D3D11_RTV_DIMENSION_TEXTURE1DARRAY
9627 #define TEX_2D D3D11_RTV_DIMENSION_TEXTURE2D
9628 #define TEX_2D_ARRAY D3D11_RTV_DIMENSION_TEXTURE2DARRAY
9629 #define TEX_3D D3D11_RTV_DIMENSION_TEXTURE3D
9634 D3D11_RTV_DIMENSION dimension
;
9635 unsigned int miplevel_count
;
9636 unsigned int depth_or_array_size
;
9639 struct rtv_desc rtv_desc
;
9641 invalid_desc_tests
[] =
9643 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, DIM_UNKNOWN
}},
9644 {{TEX_2D
, 6, 4, RGBA8_UNORM
}, {RGBA8_UNORM
, DIM_UNKNOWN
}},
9645 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0}},
9646 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 0, 1}},
9647 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 1}},
9648 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, ~0u}},
9649 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_2D
, 0}},
9650 {{TEX_2D
, 1, 1, RGBA8_TL
}, {FMT_UNKNOWN
, TEX_2D
, 0}},
9651 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 1}},
9652 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 0}},
9653 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 1, 0, 1}},
9654 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 2}},
9655 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 1}},
9656 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UINT
, TEX_2D
, 0, 0, 1}},
9657 {{TEX_2D
, 1, 1, RGBA8_UINT
}, {RGBA8_UNORM
, TEX_2D
, 0, 0, 1}},
9658 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_SRGB
, TEX_2D
, 0, 0, 1}},
9659 {{TEX_2D
, 1, 1, RGBA8_SRGB
}, {RGBA8_UNORM
, TEX_2D
, 0, 0, 1}},
9660 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0}},
9661 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 0, 1}},
9662 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0}},
9663 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 1}},
9664 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0}},
9665 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 0, 1}},
9666 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0}},
9667 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 1}},
9668 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 0}},
9669 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 1}},
9670 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_3D
, 0, 0, 1}},
9671 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_TL
, TEX_3D
, 0, 0, 1}},
9672 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 9}},
9673 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 3, 0, 2}},
9674 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 2, 0, 4}},
9675 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 8}},
9676 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 8, ~0u}},
9677 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 4, ~0u}},
9678 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 2, 2, ~0u}},
9679 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 3, 1, ~0u}},
9693 struct d3d11_test_context test_context
;
9694 D3D11_RENDER_TARGET_VIEW_DESC rtv_desc
;
9695 D3D11_TEXTURE3D_DESC texture3d_desc
;
9696 D3D11_TEXTURE2D_DESC texture_desc
;
9697 ID3D11DeviceContext
*context
;
9698 ID3D11RenderTargetView
*rtv
;
9699 ID3D11Texture3D
*texture3d
;
9700 ID3D11Texture2D
*texture
;
9701 ID3D11Resource
*resource
;
9702 ID3D11Device
*device
;
9703 unsigned int i
, j
, k
;
9707 if (!init_test_context(&test_context
, NULL
))
9710 device
= test_context
.device
;
9711 context
= test_context
.immediate_context
;
9713 texture_desc
.Width
= 32;
9714 texture_desc
.Height
= 32;
9715 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
9716 texture_desc
.SampleDesc
.Count
= 1;
9717 texture_desc
.SampleDesc
.Quality
= 0;
9718 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
9719 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
9720 texture_desc
.CPUAccessFlags
= 0;
9721 texture_desc
.MiscFlags
= 0;
9723 data
= heap_alloc_zero(texture_desc
.Width
* texture_desc
.Height
* 4);
9724 ok(!!data
, "Failed to allocate memory.\n");
9726 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
9728 const struct test
*test
= &tests
[i
];
9729 unsigned int sub_resource_count
;
9731 texture_desc
.MipLevels
= test
->texture
.miplevel_count
;
9732 texture_desc
.ArraySize
= test
->texture
.array_size
;
9734 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
9735 ok(SUCCEEDED(hr
), "Test %u: Failed to create texture, hr %#x.\n", i
, hr
);
9737 get_rtv_desc(&rtv_desc
, &test
->rtv
);
9738 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, &rtv_desc
, &rtv
);
9739 ok(SUCCEEDED(hr
), "Test %u: Failed to create render target view, hr %#x.\n", i
, hr
);
9741 for (j
= 0; j
< texture_desc
.ArraySize
; ++j
)
9743 for (k
= 0; k
< texture_desc
.MipLevels
; ++k
)
9745 unsigned int sub_resource_idx
= j
* texture_desc
.MipLevels
+ k
;
9746 ID3D11DeviceContext_UpdateSubresource(context
,
9747 (ID3D11Resource
*)texture
, sub_resource_idx
, NULL
, data
, texture_desc
.Width
* 4, 0);
9750 check_texture_color(texture
, 0, 0);
9752 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
9753 draw_color_quad(&test_context
, &red
);
9755 sub_resource_count
= texture_desc
.MipLevels
* texture_desc
.ArraySize
;
9756 assert(sub_resource_count
<= ARRAY_SIZE(test
->expected_colors
));
9757 for (j
= 0; j
< sub_resource_count
; ++j
)
9758 check_texture_sub_resource_color(texture
, j
, NULL
, test
->expected_colors
[j
], 1);
9760 ID3D11RenderTargetView_Release(rtv
);
9761 ID3D11Texture2D_Release(texture
);
9764 texture3d_desc
.Width
= 32;
9765 texture3d_desc
.Height
= 32;
9766 texture3d_desc
.Depth
= 32;
9767 texture3d_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
9768 texture3d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
9769 texture3d_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
9770 texture3d_desc
.CPUAccessFlags
= 0;
9771 texture3d_desc
.MiscFlags
= 0;
9773 for (i
= 0; i
< ARRAY_SIZE(invalid_desc_tests
); ++i
)
9775 assert(invalid_desc_tests
[i
].texture
.dimension
== D3D11_RTV_DIMENSION_TEXTURE2D
9776 || invalid_desc_tests
[i
].texture
.dimension
== D3D11_RTV_DIMENSION_TEXTURE3D
);
9778 if (invalid_desc_tests
[i
].texture
.dimension
== D3D11_RTV_DIMENSION_TEXTURE2D
)
9780 texture_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
9781 texture_desc
.ArraySize
= invalid_desc_tests
[i
].texture
.depth_or_array_size
;
9782 texture_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
9783 texture_desc
.MiscFlags
= 0;
9785 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
9786 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
9787 resource
= (ID3D11Resource
*)texture
;
9791 texture3d_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
9792 texture3d_desc
.Depth
= invalid_desc_tests
[i
].texture
.depth_or_array_size
;
9793 texture3d_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
9795 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &texture3d
);
9796 ok(SUCCEEDED(hr
), "Test %u: Failed to create 3d texture, hr %#x.\n", i
, hr
);
9797 resource
= (ID3D11Resource
*)texture3d
;
9800 get_rtv_desc(&rtv_desc
, &invalid_desc_tests
[i
].rtv_desc
);
9801 hr
= ID3D11Device_CreateRenderTargetView(device
, resource
, &rtv_desc
, &rtv
);
9802 ok(hr
== E_INVALIDARG
, "Test %u: Got unexpected hr %#x.\n", i
, hr
);
9804 ID3D11Resource_Release(resource
);
9808 release_test_context(&test_context
);
9811 static void test_layered_rendering(void)
9815 unsigned int layer_offset
;
9816 unsigned int draw_id
;
9817 unsigned int padding
[2];
9819 struct d3d11_test_context test_context
;
9820 D3D11_RENDER_TARGET_VIEW_DESC rtv_desc
;
9821 unsigned int i
, sub_resource_count
;
9822 D3D11_TEXTURE2D_DESC texture_desc
;
9823 ID3D11DeviceContext
*context
;
9824 ID3D11RenderTargetView
*rtv
;
9825 ID3D11Texture2D
*texture
;
9826 ID3D11GeometryShader
*gs
;
9827 ID3D11VertexShader
*vs
;
9828 ID3D11PixelShader
*ps
;
9829 ID3D11Device
*device
;
9834 static const DWORD vs_code
[] =
9839 void main(float4 position
: POSITION
,
9840 out float4 out_position
: SV_POSITION
,
9841 out uint layer
: SV_RenderTargetArrayIndex
)
9843 out_position
= position
;
9844 layer
= layer_offset
;
9847 0x43425844, 0x71f7b9cd, 0x2ab8c713, 0x53e77663, 0x54a9ba68, 0x00000001, 0x00000158, 0x00000004,
9848 0x00000030, 0x00000064, 0x000000cc, 0x00000148, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008,
9849 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954,
9850 0xababab00, 0x4e47534f, 0x00000060, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001,
9851 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000004, 0x00000001, 0x00000001,
9852 0x00000e01, 0x505f5653, 0x5449534f, 0x004e4f49, 0x525f5653, 0x65646e65, 0x72615472, 0x41746567,
9853 0x79617272, 0x65646e49, 0xabab0078, 0x52444853, 0x00000074, 0x00010040, 0x0000001d, 0x04000059,
9854 0x00208e46, 0x00000000, 0x00000001, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2,
9855 0x00000000, 0x00000001, 0x04000067, 0x00102012, 0x00000001, 0x00000004, 0x05000036, 0x001020f2,
9856 0x00000000, 0x00101e46, 0x00000000, 0x06000036, 0x00102012, 0x00000001, 0x0020800a, 0x00000000,
9857 0x00000000, 0x0100003e, 0x30494653, 0x00000008, 0x00002000, 0x00000000,
9859 static const DWORD gs_5_code
[] =
9866 float4 pos
: SV_Position
;
9871 float4 pos
: SV_Position
;
9872 uint layer
: SV_RenderTargetArrayIndex
;
9877 void main(triangle gs_in vin
[3], in uint instance_id
: SV_GSInstanceID
,
9878 inout TriangleStream
<gs_out
> vout
)
9881 o
.layer
= layer_offset
+ instance_id
;
9882 for (uint i
= 0; i
< 3; ++i
)
9889 0x43425844, 0xb52da162, 0x9a13d8ee, 0xf7c30b50, 0xe80bc2e7, 0x00000001, 0x00000218, 0x00000003,
9890 0x0000002c, 0x00000060, 0x000000d0, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
9891 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x7469736f, 0x006e6f69,
9892 0x3547534f, 0x00000068, 0x00000002, 0x00000008, 0x00000000, 0x00000040, 0x00000000, 0x00000001,
9893 0x00000003, 0x00000000, 0x0000000f, 0x00000000, 0x0000004c, 0x00000000, 0x00000004, 0x00000001,
9894 0x00000001, 0x00000e01, 0x505f5653, 0x7469736f, 0x006e6f69, 0x525f5653, 0x65646e65, 0x72615472,
9895 0x41746567, 0x79617272, 0x65646e49, 0xabab0078, 0x58454853, 0x00000140, 0x00020050, 0x00000050,
9896 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x05000061, 0x002010f2, 0x00000003,
9897 0x00000000, 0x00000001, 0x0200005f, 0x00025000, 0x02000068, 0x00000001, 0x020000ce, 0x00000004,
9898 0x0100185d, 0x0300008f, 0x00110000, 0x00000000, 0x0100285c, 0x04000067, 0x001020f2, 0x00000000,
9899 0x00000001, 0x04000067, 0x00102012, 0x00000001, 0x00000004, 0x0200005e, 0x00000003, 0x0700001e,
9900 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x0002500a, 0x05000036, 0x00100022,
9901 0x00000000, 0x00004001, 0x00000000, 0x01000030, 0x07000050, 0x00100042, 0x00000000, 0x0010001a,
9902 0x00000000, 0x00004001, 0x00000003, 0x03040003, 0x0010002a, 0x00000000, 0x07000036, 0x001020f2,
9903 0x00000000, 0x00a01e46, 0x0010001a, 0x00000000, 0x00000000, 0x05000036, 0x00102012, 0x00000001,
9904 0x0010000a, 0x00000000, 0x03000075, 0x00110000, 0x00000000, 0x0700001e, 0x00100022, 0x00000000,
9905 0x0010001a, 0x00000000, 0x00004001, 0x00000001, 0x01000016, 0x0100003e,
9907 static const DWORD gs_4_code
[] =
9914 float4 pos
: SV_Position
;
9919 float4 pos
: SV_Position
;
9920 uint layer
: SV_RenderTargetArrayIndex
;
9923 [maxvertexcount(12)]
9924 void main(triangle gs_in vin
[3], inout TriangleStream
<gs_out
> vout
)
9927 for (uint instance_id
= 0; instance_id
< 4; ++instance_id
)
9929 o
.layer
= layer_offset
+ instance_id
;
9930 for (uint i
= 0; i
< 3; ++i
)
9935 vout
.RestartStrip();
9939 0x43425844, 0x7eabd7c5, 0x8af1468e, 0xd585cade, 0xfe0d761d, 0x00000001, 0x00000250, 0x00000003,
9940 0x0000002c, 0x00000060, 0x000000c8, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
9941 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x7469736f, 0x006e6f69,
9942 0x4e47534f, 0x00000060, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
9943 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000004, 0x00000001, 0x00000001, 0x00000e01,
9944 0x505f5653, 0x7469736f, 0x006e6f69, 0x525f5653, 0x65646e65, 0x72615472, 0x41746567, 0x79617272,
9945 0x65646e49, 0xabab0078, 0x52444853, 0x00000180, 0x00020040, 0x00000060, 0x04000059, 0x00208e46,
9946 0x00000000, 0x00000001, 0x05000061, 0x002010f2, 0x00000003, 0x00000000, 0x00000001, 0x02000068,
9947 0x00000001, 0x0100185d, 0x0100285c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x04000067,
9948 0x00102012, 0x00000001, 0x00000004, 0x0200005e, 0x0000000c, 0x05000036, 0x00100012, 0x00000000,
9949 0x00004001, 0x00000000, 0x01000030, 0x07000050, 0x00100022, 0x00000000, 0x0010000a, 0x00000000,
9950 0x00004001, 0x00000004, 0x03040003, 0x0010001a, 0x00000000, 0x0800001e, 0x00100022, 0x00000000,
9951 0x0020800a, 0x00000000, 0x00000000, 0x0010000a, 0x00000000, 0x05000036, 0x00100042, 0x00000000,
9952 0x00004001, 0x00000000, 0x01000030, 0x07000050, 0x00100082, 0x00000000, 0x0010002a, 0x00000000,
9953 0x00004001, 0x00000003, 0x03040003, 0x0010003a, 0x00000000, 0x07000036, 0x001020f2, 0x00000000,
9954 0x00a01e46, 0x0010002a, 0x00000000, 0x00000000, 0x05000036, 0x00102012, 0x00000001, 0x0010001a,
9955 0x00000000, 0x01000013, 0x0700001e, 0x00100042, 0x00000000, 0x0010002a, 0x00000000, 0x00004001,
9956 0x00000001, 0x01000016, 0x01000009, 0x0700001e, 0x00100012, 0x00000000, 0x0010000a, 0x00000000,
9957 0x00004001, 0x00000001, 0x01000016, 0x0100003e,
9959 static const DWORD ps_code
[] =
9965 float4
main(in float4 pos
: SV_Position
,
9966 in uint layer
: SV_RenderTargetArrayIndex
) : SV_Target
9968 return float4(layer
, draw_id
, 0, 0);
9971 0x43425844, 0x5fa6ae84, 0x3f893c81, 0xf15892d6, 0x142e2e6b, 0x00000001, 0x00000154, 0x00000003,
9972 0x0000002c, 0x00000094, 0x000000c8, 0x4e475349, 0x00000060, 0x00000002, 0x00000008, 0x00000038,
9973 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000004,
9974 0x00000001, 0x00000001, 0x00000101, 0x505f5653, 0x7469736f, 0x006e6f69, 0x525f5653, 0x65646e65,
9975 0x72615472, 0x41746567, 0x79617272, 0x65646e49, 0xabab0078, 0x4e47534f, 0x0000002c, 0x00000001,
9976 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653,
9977 0x65677261, 0xabab0074, 0x52444853, 0x00000084, 0x00000040, 0x00000021, 0x04000059, 0x00208e46,
9978 0x00000000, 0x00000001, 0x04000864, 0x00101012, 0x00000001, 0x00000004, 0x03000065, 0x001020f2,
9979 0x00000000, 0x05000056, 0x00102012, 0x00000000, 0x0010100a, 0x00000001, 0x06000056, 0x00102022,
9980 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x08000036, 0x001020c2, 0x00000000, 0x00004002,
9981 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0100003e,
9983 static const struct vec4 expected_values
[] =
9985 {0.0f
, 0.0f
}, {0.0f
, 3.0f
}, {3.0f
, 11.0f
}, {1.0f
, 0.0f
}, {1.0f
, 3.0f
}, {3.0f
, 10.0f
},
9986 {2.0f
, 0.0f
}, {2.0f
, 3.0f
}, {3.0f
, 9.0f
}, {4.0f
, 2.0f
}, {3.0f
, 3.0f
}, {3.0f
, 8.0f
},
9987 {4.0f
, 1.0f
}, {4.0f
, 3.0f
}, {3.0f
, 7.0f
}, {5.0f
, 1.0f
}, {5.0f
, 3.0f
}, {3.0f
, 6.0f
},
9988 {6.0f
, 1.0f
}, {6.0f
, 3.0f
}, {3.0f
, 5.0f
}, {7.0f
, 1.0f
}, {7.0f
, 3.0f
}, {3.0f
, 4.0f
},
9990 static const struct vec4 vs_expected_value
= {1.0f
, 42.0f
};
9992 if (!init_test_context(&test_context
, NULL
))
9995 device
= test_context
.device
;
9996 context
= test_context
.immediate_context
;
9998 warp
= is_warp_device(device
);
10000 memset(&constant
, 0, sizeof(constant
));
10001 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(constant
), &constant
);
10002 ID3D11DeviceContext_VSSetConstantBuffers(context
, 0, 1, &cb
);
10003 ID3D11DeviceContext_GSSetConstantBuffers(context
, 0, 1, &cb
);
10004 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
10006 /* Geometry shader instancing seems broken on WARP. */
10007 if (ID3D11Device_GetFeatureLevel(device
) < D3D_FEATURE_LEVEL_11_0
|| warp
)
10009 hr
= ID3D11Device_CreateGeometryShader(device
, gs_4_code
, sizeof(gs_4_code
), NULL
, &gs
);
10010 ok(SUCCEEDED(hr
), "Failed to create geometry shader, hr %#x.\n", hr
);
10014 hr
= ID3D11Device_CreateGeometryShader(device
, gs_5_code
, sizeof(gs_5_code
), NULL
, &gs
);
10015 ok(SUCCEEDED(hr
), "Failed to create geometry shader, hr %#x.\n", hr
);
10017 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
10019 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
10020 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
10021 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
10023 texture_desc
.Width
= 32;
10024 texture_desc
.Height
= 32;
10025 texture_desc
.MipLevels
= 3;
10026 texture_desc
.ArraySize
= 8;
10027 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
10028 texture_desc
.SampleDesc
.Count
= 1;
10029 texture_desc
.SampleDesc
.Quality
= 0;
10030 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
10031 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
10032 texture_desc
.CPUAccessFlags
= 0;
10033 texture_desc
.MiscFlags
= 0;
10034 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
10035 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
10037 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
10038 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
10039 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
10040 constant
.layer_offset
= 0;
10041 constant
.draw_id
= 0;
10042 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
10043 draw_quad(&test_context
);
10044 constant
.layer_offset
= 4;
10045 constant
.draw_id
= 1;
10046 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
10047 draw_quad(&test_context
);
10048 ID3D11RenderTargetView_Release(rtv
);
10050 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_TEXTURE2DARRAY
;
10051 rtv_desc
.Format
= texture_desc
.Format
;
10052 U(rtv_desc
).Texture2DArray
.MipSlice
= 0;
10053 U(rtv_desc
).Texture2DArray
.FirstArraySlice
= 3;
10054 U(rtv_desc
).Texture2DArray
.ArraySize
= 1;
10055 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, &rtv_desc
, &rtv
);
10056 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
10057 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
10058 constant
.layer_offset
= 1;
10059 constant
.draw_id
= 2;
10060 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
10061 draw_quad(&test_context
);
10062 ID3D11RenderTargetView_Release(rtv
);
10064 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_TEXTURE2DARRAY
;
10065 U(rtv_desc
).Texture2DArray
.MipSlice
= 1;
10066 U(rtv_desc
).Texture2DArray
.FirstArraySlice
= 0;
10067 U(rtv_desc
).Texture2DArray
.ArraySize
= ~0u;
10068 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, &rtv_desc
, &rtv
);
10069 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
10070 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
10071 constant
.layer_offset
= 0;
10072 constant
.draw_id
= 3;
10073 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
10074 draw_quad(&test_context
);
10075 constant
.layer_offset
= 4;
10076 constant
.draw_id
= 3;
10077 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
10078 draw_quad(&test_context
);
10079 ID3D11RenderTargetView_Release(rtv
);
10081 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_TEXTURE2DARRAY
;
10082 U(rtv_desc
).Texture2DArray
.MipSlice
= 2;
10083 U(rtv_desc
).Texture2DArray
.ArraySize
= 1;
10084 for (i
= 0; i
< texture_desc
.ArraySize
; ++i
)
10086 U(rtv_desc
).Texture2DArray
.FirstArraySlice
= texture_desc
.ArraySize
- 1 - i
;
10087 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, &rtv_desc
, &rtv
);
10088 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
10089 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
10090 constant
.layer_offset
= 0;
10091 constant
.draw_id
= 4 + i
;
10092 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
10093 draw_quad(&test_context
);
10094 ID3D11RenderTargetView_Release(rtv
);
10097 sub_resource_count
= texture_desc
.MipLevels
* texture_desc
.ArraySize
;
10098 assert(ARRAY_SIZE(expected_values
) == sub_resource_count
);
10099 for (i
= 0; i
< sub_resource_count
; ++i
)
10101 if (warp
&& (i
== 3 || i
== 4)) /* Broken on WARP. */
10103 check_texture_sub_resource_vec4(texture
, i
, NULL
, &expected_values
[i
], 1);
10106 /* layered rendering without GS */
10107 if (!check_viewport_array_index_from_any_shader_support(device
))
10109 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
10110 todo_wine
ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
10112 ID3D11VertexShader_Release(vs
);
10113 skip("Viewport array index not supported in vertex shaders.\n");
10117 ID3D11DeviceContext_GSSetShader(context
, NULL
, NULL
, 0);
10119 constant
.layer_offset
= 1;
10120 constant
.draw_id
= 42;
10121 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
10122 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_TEXTURE2DARRAY
;
10123 U(rtv_desc
).Texture2DArray
.MipSlice
= 0;
10124 U(rtv_desc
).Texture2DArray
.FirstArraySlice
= 0;
10125 U(rtv_desc
).Texture2DArray
.ArraySize
= ~0u;
10126 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, &rtv_desc
, &rtv
);
10127 ok(hr
== S_OK
, "Failed to create render target view, hr %#x.\n", hr
);
10128 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
10129 draw_quad_vs(&test_context
, vs_code
, sizeof(vs_code
));
10130 check_texture_sub_resource_vec4(texture
,
10131 constant
.layer_offset
* texture_desc
.MipLevels
, NULL
, &vs_expected_value
, 1);
10132 ID3D11RenderTargetView_Release(rtv
);
10135 ID3D11Texture2D_Release(texture
);
10137 ID3D11Buffer_Release(cb
);
10138 ID3D11GeometryShader_Release(gs
);
10139 ID3D11PixelShader_Release(ps
);
10140 release_test_context(&test_context
);
10143 static void test_scissor(void)
10145 struct d3d11_test_context test_context
;
10146 ID3D11DeviceContext
*immediate_context
;
10147 D3D11_RASTERIZER_DESC rs_desc
;
10148 ID3D11RasterizerState
*rs
;
10149 D3D11_RECT scissor_rect
;
10150 ID3D11Device
*device
;
10154 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 1.0f
};
10155 static const struct vec4 green
= {0.0f
, 1.0f
, 0.0f
, 1.0f
};
10157 if (!init_test_context(&test_context
, NULL
))
10160 device
= test_context
.device
;
10161 immediate_context
= test_context
.immediate_context
;
10163 rs_desc
.FillMode
= D3D11_FILL_SOLID
;
10164 rs_desc
.CullMode
= D3D11_CULL_BACK
;
10165 rs_desc
.FrontCounterClockwise
= FALSE
;
10166 rs_desc
.DepthBias
= 0;
10167 rs_desc
.DepthBiasClamp
= 0.0f
;
10168 rs_desc
.SlopeScaledDepthBias
= 0.0f
;
10169 rs_desc
.DepthClipEnable
= TRUE
;
10170 rs_desc
.ScissorEnable
= TRUE
;
10171 rs_desc
.MultisampleEnable
= FALSE
;
10172 rs_desc
.AntialiasedLineEnable
= FALSE
;
10173 hr
= ID3D11Device_CreateRasterizerState(device
, &rs_desc
, &rs
);
10174 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
10176 SetRect(&scissor_rect
, 160, 120, 480, 360);
10177 ID3D11DeviceContext_RSSetScissorRects(immediate_context
, 1, &scissor_rect
);
10179 ID3D11DeviceContext_ClearRenderTargetView(immediate_context
, test_context
.backbuffer_rtv
, red
);
10180 check_texture_color(test_context
.backbuffer
, 0xff0000ff, 1);
10182 draw_color_quad(&test_context
, &green
);
10183 color
= get_texture_color(test_context
.backbuffer
, 320, 60);
10184 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
10185 color
= get_texture_color(test_context
.backbuffer
, 80, 240);
10186 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
10187 color
= get_texture_color(test_context
.backbuffer
, 320, 240);
10188 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
10189 color
= get_texture_color(test_context
.backbuffer
, 560, 240);
10190 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
10191 color
= get_texture_color(test_context
.backbuffer
, 320, 420);
10192 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
10194 ID3D11DeviceContext_ClearRenderTargetView(immediate_context
, test_context
.backbuffer_rtv
, red
);
10195 ID3D11DeviceContext_RSSetState(immediate_context
, rs
);
10196 draw_color_quad(&test_context
, &green
);
10197 color
= get_texture_color(test_context
.backbuffer
, 320, 60);
10198 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
10199 color
= get_texture_color(test_context
.backbuffer
, 80, 240);
10200 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
10201 color
= get_texture_color(test_context
.backbuffer
, 320, 240);
10202 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
10203 color
= get_texture_color(test_context
.backbuffer
, 560, 240);
10204 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
10205 color
= get_texture_color(test_context
.backbuffer
, 320, 420);
10206 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
10208 ID3D11RasterizerState_Release(rs
);
10209 release_test_context(&test_context
);
10212 static void test_clear_state(void)
10214 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
10215 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
10217 {"POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
10220 float4
main(float4 pos
: POSITION
) : POSITION
10225 static const DWORD simple_vs
[] =
10227 0x43425844, 0x66689e7c, 0x643f0971, 0xb7f67ff4, 0xabc48688, 0x00000001, 0x000000d4, 0x00000003,
10228 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
10229 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
10230 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
10231 0x00000000, 0x0000000f, 0x49534f50, 0x4e4f4954, 0xababab00, 0x52444853, 0x00000038, 0x00010040,
10232 0x0000000e, 0x0300005f, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
10233 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
10238 float4 position
: SV_Position
;
10241 struct patch_constant_data
10243 float edges
[3] : SV_TessFactor
;
10244 float inside
: SV_InsideTessFactor
;
10247 void patch_constant(InputPatch
<data
, 3> input
, out patch_constant_data output
)
10249 output
.edges
[0] = output
.edges
[1] = output
.edges
[2] = 1.0f
;
10250 output
.inside
= 1.0f
;
10254 [outputcontrolpoints(3)]
10255 [partitioning("integer")]
10256 [outputtopology("triangle_ccw")]
10257 [patchconstantfunc("patch_constant")]
10258 data
hs_main(InputPatch
<data
, 3> input
, uint i
: SV_OutputControlPointID
)
10264 void ds_main(patch_constant_data input
,
10265 float3 tess_coord
: SV_DomainLocation
,
10266 const OutputPatch
<data
, 3> patch
,
10269 output
.position
= tess_coord
.x
* patch
[0].position
10270 + tess_coord
.y
* patch
[1].position
10271 + tess_coord
.z
* patch
[2].position
;
10274 static const DWORD simple_hs
[] =
10276 0x43425844, 0x42b5df25, 0xfd8aa2b1, 0xbe5490cb, 0xb595f8b1, 0x00000001, 0x0000020c, 0x00000004,
10277 0x00000030, 0x00000064, 0x00000098, 0x0000012c, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008,
10278 0x00000020, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x7469736f,
10279 0x006e6f69, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
10280 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69, 0x47534350, 0x0000008c,
10281 0x00000004, 0x00000008, 0x00000068, 0x00000000, 0x0000000d, 0x00000003, 0x00000000, 0x00000e01,
10282 0x00000068, 0x00000001, 0x0000000d, 0x00000003, 0x00000001, 0x00000e01, 0x00000068, 0x00000002,
10283 0x0000000d, 0x00000003, 0x00000002, 0x00000e01, 0x00000076, 0x00000000, 0x0000000e, 0x00000003,
10284 0x00000003, 0x00000e01, 0x545f5653, 0x46737365, 0x6f746361, 0x56530072, 0x736e495f, 0x54656469,
10285 0x46737365, 0x6f746361, 0xabab0072, 0x58454853, 0x000000d8, 0x00030050, 0x00000036, 0x01000071,
10286 0x01001893, 0x01001894, 0x01001095, 0x01000896, 0x01002097, 0x0100086a, 0x01000073, 0x02000099,
10287 0x00000003, 0x0200005f, 0x00017000, 0x04000067, 0x00102012, 0x00000000, 0x00000011, 0x04000067,
10288 0x00102012, 0x00000001, 0x00000012, 0x04000067, 0x00102012, 0x00000002, 0x00000013, 0x02000068,
10289 0x00000001, 0x0400005b, 0x00102012, 0x00000000, 0x00000003, 0x04000036, 0x00100012, 0x00000000,
10290 0x0001700a, 0x06000036, 0x00902012, 0x0010000a, 0x00000000, 0x00004001, 0x3f800000, 0x0100003e,
10291 0x01000073, 0x04000067, 0x00102012, 0x00000003, 0x00000014, 0x05000036, 0x00102012, 0x00000003,
10292 0x00004001, 0x3f800000, 0x0100003e,
10294 static const DWORD simple_ds
[] =
10296 0x43425844, 0xb7e35b82, 0x1b930ff2, 0x48d3a0f2, 0x375219ed, 0x00000001, 0x000001e0, 0x00000004,
10297 0x00000030, 0x00000064, 0x000000f8, 0x0000012c, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008,
10298 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x7469736f,
10299 0x006e6f69, 0x47534350, 0x0000008c, 0x00000004, 0x00000008, 0x00000068, 0x00000000, 0x0000000d,
10300 0x00000003, 0x00000000, 0x00000001, 0x00000068, 0x00000001, 0x0000000d, 0x00000003, 0x00000001,
10301 0x00000001, 0x00000068, 0x00000002, 0x0000000d, 0x00000003, 0x00000002, 0x00000001, 0x00000076,
10302 0x00000000, 0x0000000e, 0x00000003, 0x00000003, 0x00000001, 0x545f5653, 0x46737365, 0x6f746361,
10303 0x56530072, 0x736e495f, 0x54656469, 0x46737365, 0x6f746361, 0xabab0072, 0x4e47534f, 0x0000002c,
10304 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
10305 0x505f5653, 0x7469736f, 0x006e6f69, 0x58454853, 0x000000ac, 0x00040050, 0x0000002b, 0x01001893,
10306 0x01001095, 0x0100086a, 0x0200005f, 0x0001c072, 0x0400005f, 0x002190f2, 0x00000003, 0x00000000,
10307 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x02000068, 0x00000001, 0x07000038, 0x001000f2,
10308 0x00000000, 0x0001c556, 0x00219e46, 0x00000001, 0x00000000, 0x09000032, 0x001000f2, 0x00000000,
10309 0x0001c006, 0x00219e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000, 0x09000032, 0x001020f2,
10310 0x00000000, 0x0001caa6, 0x00219e46, 0x00000002, 0x00000000, 0x00100e46, 0x00000000, 0x0100003e,
10315 float4 pos
: SV_POSITION
;
10318 [maxvertexcount(4)]
10319 void main(point float4 vin
[1] : POSITION
, inout TriangleStream
<gs_out
> vout
)
10321 float offset
= 0.1 * vin
[0].w
;
10324 v
.pos
= float4(vin
[0].x
- offset
, vin
[0].y
- offset
, vin
[0].z
, vin
[0].w
);
10326 v
.pos
= float4(vin
[0].x
- offset
, vin
[0].y
+ offset
, vin
[0].z
, vin
[0].w
);
10328 v
.pos
= float4(vin
[0].x
+ offset
, vin
[0].y
- offset
, vin
[0].z
, vin
[0].w
);
10330 v
.pos
= float4(vin
[0].x
+ offset
, vin
[0].y
+ offset
, vin
[0].z
, vin
[0].w
);
10334 static const DWORD simple_gs
[] =
10336 0x43425844, 0x000ee786, 0xc624c269, 0x885a5cbe, 0x444b3b1f, 0x00000001, 0x0000023c, 0x00000003,
10337 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
10338 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
10339 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
10340 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x000001a0, 0x00020040,
10341 0x00000068, 0x0400005f, 0x002010f2, 0x00000001, 0x00000000, 0x02000068, 0x00000001, 0x0100085d,
10342 0x0100285c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x0200005e, 0x00000004, 0x0f000032,
10343 0x00100032, 0x00000000, 0x80201ff6, 0x00000041, 0x00000000, 0x00000000, 0x00004002, 0x3dcccccd,
10344 0x3dcccccd, 0x00000000, 0x00000000, 0x00201046, 0x00000000, 0x00000000, 0x05000036, 0x00102032,
10345 0x00000000, 0x00100046, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000,
10346 0x00000000, 0x01000013, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0e000032,
10347 0x00100052, 0x00000000, 0x00201ff6, 0x00000000, 0x00000000, 0x00004002, 0x3dcccccd, 0x00000000,
10348 0x3dcccccd, 0x00000000, 0x00201106, 0x00000000, 0x00000000, 0x05000036, 0x00102022, 0x00000000,
10349 0x0010002a, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000, 0x00000000,
10350 0x01000013, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x05000036, 0x00102022,
10351 0x00000000, 0x0010001a, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000,
10352 0x00000000, 0x01000013, 0x05000036, 0x00102032, 0x00000000, 0x00100086, 0x00000000, 0x06000036,
10353 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000, 0x00000000, 0x01000013, 0x0100003e,
10356 float4
main(float4 color
: COLOR
) : SV_TARGET
10361 static const DWORD simple_ps
[] =
10363 0x43425844, 0x08c2b568, 0x17d33120, 0xb7d82948, 0x13a570fb, 0x00000001, 0x000000d0, 0x00000003,
10364 0x0000002c, 0x0000005c, 0x00000090, 0x4e475349, 0x00000028, 0x00000001, 0x00000008, 0x00000020,
10365 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x4f4c4f43, 0xabab0052, 0x4e47534f,
10366 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
10367 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
10368 0x03001062, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x05000036, 0x001020f2,
10369 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
10372 [numthreads(1, 1, 1)]
10375 static const DWORD simple_cs
[] =
10377 0x43425844, 0x1acc3ad0, 0x71c7b057, 0xc72c4306, 0xf432cb57, 0x00000001, 0x00000074, 0x00000003,
10378 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
10379 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000020, 0x00050050, 0x00000008, 0x0100086a,
10380 0x0400009b, 0x00000001, 0x00000001, 0x00000001, 0x0100003e,
10383 D3D11_VIEWPORT tmp_viewport
[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
];
10384 ID3D11ShaderResourceView
*tmp_srv
[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
];
10385 ID3D11ShaderResourceView
*srv
[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
];
10386 ID3D11RenderTargetView
*tmp_rtv
[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
];
10387 RECT tmp_rect
[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
];
10388 ID3D11SamplerState
*tmp_sampler
[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
];
10389 ID3D11RenderTargetView
*rtv
[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
];
10390 ID3D11Texture2D
*rt_texture
[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
];
10391 ID3D11Buffer
*cb
[D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
];
10392 ID3D11Buffer
*tmp_buffer
[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
];
10393 ID3D11SamplerState
*sampler
[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
];
10394 ID3D11UnorderedAccessView
*tmp_uav
[D3D11_PS_CS_UAV_REGISTER_COUNT
];
10395 ID3D11UnorderedAccessView
*cs_uav
[D3D11_PS_CS_UAV_REGISTER_COUNT
];
10396 ID3D11Buffer
*buffer
[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
];
10397 ID3D11Buffer
*cs_uav_buffer
[D3D11_PS_CS_UAV_REGISTER_COUNT
];
10398 UINT offset
[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
];
10399 UINT stride
[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
];
10400 ID3D11Buffer
*so_buffer
[D3D11_SO_BUFFER_SLOT_COUNT
];
10401 ID3D11InputLayout
*tmp_input_layout
, *input_layout
;
10402 ID3D11DepthStencilState
*tmp_ds_state
, *ds_state
;
10403 ID3D11BlendState
*tmp_blend_state
, *blend_state
;
10404 ID3D11RasterizerState
*tmp_rs_state
, *rs_state
;
10405 ID3D11Predicate
*tmp_predicate
, *predicate
;
10406 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
10407 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
10408 ID3D11DepthStencilView
*tmp_dsv
, *dsv
;
10409 ID3D11UnorderedAccessView
*ps_uav
;
10410 D3D11_PRIMITIVE_TOPOLOGY topology
;
10411 D3D11_TEXTURE2D_DESC texture_desc
;
10412 ID3D11GeometryShader
*tmp_gs
, *gs
;
10413 ID3D11ComputeShader
*tmp_cs
, *cs
;
10414 D3D11_DEPTH_STENCIL_DESC ds_desc
;
10415 ID3D11VertexShader
*tmp_vs
, *vs
;
10416 ID3D11DomainShader
*tmp_ds
, *ds
;
10417 D3D11_SAMPLER_DESC sampler_desc
;
10418 D3D11_QUERY_DESC predicate_desc
;
10419 struct device_desc device_desc
;
10420 ID3D11PixelShader
*tmp_ps
, *ps
;
10421 ID3D11HullShader
*tmp_hs
, *hs
;
10422 D3D11_RASTERIZER_DESC rs_desc
;
10423 ID3D11DeviceContext
*context
;
10424 D3D11_BLEND_DESC blend_desc
;
10425 ID3D11Texture2D
*ds_texture
;
10426 ID3D11Buffer
*ps_uav_buffer
;
10427 float blend_factor
[4];
10428 ID3D11Device
*device
;
10429 BOOL predicate_value
;
10430 UINT instance_count
;
10431 DXGI_FORMAT format
;
10438 device_desc
.feature_level
= &feature_level
;
10439 device_desc
.flags
= 0;
10440 if (!(device
= create_device(&device_desc
)))
10442 skip("Failed to create device.\n");
10446 ID3D11Device_GetImmediateContext(device
, &context
);
10448 /* Verify the initial state after device creation. */
10450 ID3D11DeviceContext_VSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
10452 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
10454 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
10456 ID3D11DeviceContext_VSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
10457 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
10459 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
10461 ID3D11DeviceContext_VSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
10462 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
10464 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
10466 instance_count
= 100;
10467 ID3D11DeviceContext_VSGetShader(context
, &tmp_vs
, NULL
, &instance_count
);
10468 ok(!tmp_vs
, "Got unexpected vertex shader %p.\n", tmp_vs
);
10469 ok(!instance_count
, "Got unexpected instance count %u.\n", instance_count
);
10471 ID3D11DeviceContext_HSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
10473 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
10475 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
10477 ID3D11DeviceContext_HSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
10478 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
10480 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
10482 ID3D11DeviceContext_HSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
10483 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
10485 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
10487 instance_count
= 100;
10488 ID3D11DeviceContext_HSGetShader(context
, &tmp_hs
, NULL
, &instance_count
);
10489 ok(!tmp_hs
, "Got unexpected hull shader %p.\n", tmp_hs
);
10490 ok(!instance_count
, "Got unexpected instance count %u.\n", instance_count
);
10492 ID3D11DeviceContext_DSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
10494 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
10496 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
10498 ID3D11DeviceContext_DSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
10499 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
10501 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
10503 ID3D11DeviceContext_DSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
10504 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
10506 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
10508 instance_count
= 100;
10509 ID3D11DeviceContext_DSGetShader(context
, &tmp_ds
, NULL
, &instance_count
);
10510 ok(!tmp_ds
, "Got unexpected domain shader %p.\n", tmp_ds
);
10511 ok(!instance_count
, "Got unexpected instance count %u.\n", instance_count
);
10513 ID3D11DeviceContext_GSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
10515 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
10517 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
10519 ID3D11DeviceContext_GSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
10520 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
10522 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
10524 ID3D11DeviceContext_GSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
10525 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
10527 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
10529 instance_count
= 100;
10530 ID3D11DeviceContext_GSGetShader(context
, &tmp_gs
, NULL
, &instance_count
);
10531 ok(!tmp_gs
, "Got unexpected geometry shader %p.\n", tmp_gs
);
10532 ok(!instance_count
, "Got unexpected instance count %u.\n", instance_count
);
10534 ID3D11DeviceContext_PSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
10536 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
10538 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
10540 ID3D11DeviceContext_PSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
,
10542 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
10544 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
10546 ID3D11DeviceContext_PSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
10547 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
10549 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
10551 instance_count
= 100;
10552 ID3D11DeviceContext_PSGetShader(context
, &tmp_ps
, NULL
, &instance_count
);
10553 ok(!tmp_ps
, "Got unexpected pixel shader %p.\n", tmp_ps
);
10554 ok(!instance_count
, "Got unexpected instance count %u.\n", instance_count
);
10556 ID3D11DeviceContext_CSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
10558 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
10560 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
10562 ID3D11DeviceContext_CSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
,
10564 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
10566 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
10568 ID3D11DeviceContext_CSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
10569 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
10571 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
10573 instance_count
= 100;
10574 ID3D11DeviceContext_CSGetShader(context
, &tmp_cs
, NULL
, &instance_count
);
10575 ok(!tmp_cs
, "Got unexpected compute shader %p.\n", tmp_cs
);
10576 ok(!instance_count
, "Got unexpected instance count %u.\n", instance_count
);
10577 ID3D11DeviceContext_CSGetUnorderedAccessViews(context
, 0, D3D11_PS_CS_UAV_REGISTER_COUNT
, tmp_uav
);
10578 for (i
= 0; i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
10580 ok(!tmp_uav
[i
], "Got unexpected unordered access view %p in slot %u.\n", tmp_uav
[i
], i
);
10583 ID3D11DeviceContext_IAGetVertexBuffers(context
, 0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
,
10584 tmp_buffer
, stride
, offset
);
10585 for (i
= 0; i
< D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
10587 ok(!tmp_buffer
[i
], "Got unexpected vertex buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
10588 ok(!stride
[i
], "Got unexpected stride %u in slot %u.\n", stride
[i
], i
);
10589 ok(!offset
[i
], "Got unexpected offset %u in slot %u.\n", offset
[i
], i
);
10591 ID3D11DeviceContext_IAGetIndexBuffer(context
, tmp_buffer
, &format
, offset
);
10592 ok(!tmp_buffer
[0], "Got unexpected index buffer %p.\n", tmp_buffer
[0]);
10593 ok(format
== DXGI_FORMAT_UNKNOWN
, "Got unexpected index buffer format %#x.\n", format
);
10594 ok(!offset
[0], "Got unexpected index buffer offset %u.\n", offset
[0]);
10595 ID3D11DeviceContext_IAGetInputLayout(context
, &tmp_input_layout
);
10596 ok(!tmp_input_layout
, "Got unexpected input layout %p.\n", tmp_input_layout
);
10597 ID3D11DeviceContext_IAGetPrimitiveTopology(context
, &topology
);
10598 ok(topology
== D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED
, "Got unexpected primitive topology %#x.\n", topology
);
10600 ID3D11DeviceContext_OMGetBlendState(context
, &tmp_blend_state
, blend_factor
, &sample_mask
);
10601 ok(!tmp_blend_state
, "Got unexpected blend state %p.\n", tmp_blend_state
);
10602 ok(blend_factor
[0] == 1.0f
&& blend_factor
[1] == 1.0f
10603 && blend_factor
[2] == 1.0f
&& blend_factor
[3] == 1.0f
,
10604 "Got unexpected blend factor {%.8e, %.8e, %.8e, %.8e}.\n",
10605 blend_factor
[0], blend_factor
[1], blend_factor
[2], blend_factor
[3]);
10606 ok(sample_mask
== D3D11_DEFAULT_SAMPLE_MASK
, "Got unexpected sample mask %#x.\n", sample_mask
);
10607 ID3D11DeviceContext_OMGetDepthStencilState(context
, &tmp_ds_state
, &stencil_ref
);
10608 ok(!tmp_ds_state
, "Got unexpected depth stencil state %p.\n", tmp_ds_state
);
10609 ok(!stencil_ref
, "Got unexpected stencil ref %u.\n", stencil_ref
);
10610 ID3D11DeviceContext_OMGetRenderTargets(context
, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
, tmp_rtv
, &tmp_dsv
);
10611 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
10613 ok(!tmp_rtv
[i
], "Got unexpected render target view %p in slot %u.\n", tmp_rtv
[i
], i
);
10615 ok(!tmp_dsv
, "Got unexpected depth stencil view %p.\n", tmp_dsv
);
10616 ID3D11DeviceContext_OMGetRenderTargetsAndUnorderedAccessViews(context
,
10617 D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
, tmp_rtv
, &tmp_dsv
,
10618 0, D3D11_PS_CS_UAV_REGISTER_COUNT
, tmp_uav
);
10619 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
10621 ok(!tmp_rtv
[i
], "Got unexpected render target view %p in slot %u.\n", tmp_rtv
[i
], i
);
10623 ok(!tmp_dsv
, "Got unexpected depth stencil view %p.\n", tmp_dsv
);
10624 for (i
= 0; i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
10626 ok(!tmp_uav
[i
], "Got unexpected unordered access view %p in slot %u.\n", tmp_uav
[i
], i
);
10629 if (!enable_debug_layer
)
10631 ID3D11DeviceContext_RSGetScissorRects(context
, &count
, NULL
);
10632 ok(!count
, "Got unexpected scissor rect count %u.\n", count
);
10634 memset(tmp_rect
, 0x55, sizeof(tmp_rect
));
10635 count
= D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
;
10636 ID3D11DeviceContext_RSGetScissorRects(context
, &count
, tmp_rect
);
10637 for (i
= 0; i
< D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
; ++i
)
10639 ok(!tmp_rect
[i
].left
&& !tmp_rect
[i
].top
&& !tmp_rect
[i
].right
&& !tmp_rect
[i
].bottom
,
10640 "Got unexpected scissor rect %s in slot %u.\n", wine_dbgstr_rect(&tmp_rect
[i
]), i
);
10642 ID3D11DeviceContext_RSGetViewports(context
, &count
, NULL
);
10643 ok(!count
, "Got unexpected viewport count %u.\n", count
);
10644 memset(tmp_viewport
, 0x55, sizeof(tmp_viewport
));
10645 count
= D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
;
10646 ID3D11DeviceContext_RSGetViewports(context
, &count
, tmp_viewport
);
10647 for (i
= 0; i
< D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
; ++i
)
10649 ok(!tmp_viewport
[i
].TopLeftX
&& !tmp_viewport
[i
].TopLeftY
&& !tmp_viewport
[i
].Width
10650 && !tmp_viewport
[i
].Height
&& !tmp_viewport
[i
].MinDepth
&& !tmp_viewport
[i
].MaxDepth
,
10651 "Got unexpected viewport {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e} in slot %u.\n",
10652 tmp_viewport
[i
].TopLeftX
, tmp_viewport
[i
].TopLeftY
, tmp_viewport
[i
].Width
,
10653 tmp_viewport
[i
].Height
, tmp_viewport
[i
].MinDepth
, tmp_viewport
[i
].MaxDepth
, i
);
10655 ID3D11DeviceContext_RSGetState(context
, &tmp_rs_state
);
10656 ok(!tmp_rs_state
, "Got unexpected rasterizer state %p.\n", tmp_rs_state
);
10658 ID3D11DeviceContext_SOGetTargets(context
, D3D11_SO_BUFFER_SLOT_COUNT
, tmp_buffer
);
10659 for (i
= 0; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
10661 ok(!tmp_buffer
[i
], "Got unexpected stream output %p in slot %u.\n", tmp_buffer
[i
], i
);
10664 ID3D11DeviceContext_GetPredication(context
, &tmp_predicate
, &predicate_value
);
10665 ok(!tmp_predicate
, "Got unexpected predicate %p.\n", tmp_predicate
);
10666 ok(!predicate_value
, "Got unexpected predicate value %#x.\n", predicate_value
);
10668 /* Create resources. */
10670 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
10671 cb
[i
] = create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, 1024, NULL
);
10673 for (i
= 0; i
< D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
10675 buffer
[i
] = create_buffer(device
,
10676 D3D11_BIND_VERTEX_BUFFER
| D3D11_BIND_INDEX_BUFFER
| D3D11_BIND_SHADER_RESOURCE
,
10679 stride
[i
] = (i
+ 1) * 4;
10680 offset
[i
] = (i
+ 1) * 16;
10683 for (i
= 0; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
10684 so_buffer
[i
] = create_buffer(device
, D3D11_BIND_STREAM_OUTPUT
, 1024, NULL
);
10686 srv_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
10687 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_BUFFER
;
10688 U(srv_desc
).Buffer
.ElementOffset
= 0;
10689 U(srv_desc
).Buffer
.ElementWidth
= 64;
10691 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
10693 hr
= ID3D11Device_CreateShaderResourceView(device
,
10694 (ID3D11Resource
*)buffer
[i
% D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
], &srv_desc
, &srv
[i
]);
10695 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
10698 uav_desc
.Format
= DXGI_FORMAT_R32_UINT
;
10699 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
10700 U(uav_desc
).Buffer
.FirstElement
= 0;
10701 U(uav_desc
).Buffer
.NumElements
= 8;
10702 U(uav_desc
).Buffer
.Flags
= 0;
10704 for (i
= 0; i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
10706 cs_uav_buffer
[i
] = create_buffer(device
, D3D11_BIND_UNORDERED_ACCESS
, 32, NULL
);
10707 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)cs_uav_buffer
[i
],
10708 &uav_desc
, &cs_uav
[i
]);
10709 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
10712 ps_uav_buffer
= create_buffer(device
, D3D11_BIND_UNORDERED_ACCESS
, 32, NULL
);
10713 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)ps_uav_buffer
,
10714 &uav_desc
, &ps_uav
);
10715 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
10717 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_LINEAR
;
10718 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
10719 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
10720 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
10721 sampler_desc
.MipLODBias
= 0.0f
;
10722 sampler_desc
.MaxAnisotropy
= 16;
10723 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
10724 sampler_desc
.BorderColor
[0] = 0.0f
;
10725 sampler_desc
.BorderColor
[1] = 0.0f
;
10726 sampler_desc
.BorderColor
[2] = 0.0f
;
10727 sampler_desc
.BorderColor
[3] = 0.0f
;
10728 sampler_desc
.MinLOD
= 0.0f
;
10729 sampler_desc
.MaxLOD
= 16.0f
;
10731 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
10733 sampler_desc
.MinLOD
= (float)i
;
10735 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler
[i
]);
10736 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
10739 hr
= ID3D11Device_CreateVertexShader(device
, simple_vs
, sizeof(simple_vs
), NULL
, &vs
);
10740 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
10742 hr
= ID3D11Device_CreateHullShader(device
, simple_hs
, sizeof(simple_hs
), NULL
, &hs
);
10743 ok(SUCCEEDED(hr
), "Failed to create hull shader, hr %#x.\n", hr
);
10745 hr
= ID3D11Device_CreateDomainShader(device
, simple_ds
, sizeof(simple_ds
), NULL
, &ds
);
10746 ok(SUCCEEDED(hr
), "Failed to create domain shader, hr %#x.\n", hr
);
10748 hr
= ID3D11Device_CreateGeometryShader(device
, simple_gs
, sizeof(simple_gs
), NULL
, &gs
);
10749 ok(SUCCEEDED(hr
), "Failed to create geometry shader, hr %#x.\n", hr
);
10751 hr
= ID3D11Device_CreatePixelShader(device
, simple_ps
, sizeof(simple_ps
), NULL
, &ps
);
10752 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
10754 hr
= ID3D11Device_CreateComputeShader(device
, simple_cs
, sizeof(simple_cs
), NULL
, &cs
);
10755 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
10757 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
10758 simple_vs
, sizeof(simple_vs
), &input_layout
);
10759 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
10761 memset(&blend_desc
, 0, sizeof(blend_desc
));
10762 blend_desc
.AlphaToCoverageEnable
= FALSE
;
10763 blend_desc
.IndependentBlendEnable
= FALSE
;
10764 blend_desc
.RenderTarget
[0].BlendEnable
= TRUE
;
10765 blend_desc
.RenderTarget
[0].SrcBlend
= D3D11_BLEND_ONE
;
10766 blend_desc
.RenderTarget
[0].DestBlend
= D3D11_BLEND_ZERO
;
10767 blend_desc
.RenderTarget
[0].BlendOp
= D3D11_BLEND_OP_ADD
;
10768 blend_desc
.RenderTarget
[0].SrcBlendAlpha
= D3D11_BLEND_ONE
;
10769 blend_desc
.RenderTarget
[0].DestBlendAlpha
= D3D11_BLEND_ZERO
;
10770 blend_desc
.RenderTarget
[0].BlendOpAlpha
= D3D11_BLEND_OP_ADD
;
10771 blend_desc
.RenderTarget
[0].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_ALL
;
10773 hr
= ID3D11Device_CreateBlendState(device
, &blend_desc
, &blend_state
);
10774 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
10776 ds_desc
.DepthEnable
= TRUE
;
10777 ds_desc
.DepthWriteMask
= D3D11_DEPTH_WRITE_MASK_ALL
;
10778 ds_desc
.DepthFunc
= D3D11_COMPARISON_LESS
;
10779 ds_desc
.StencilEnable
= FALSE
;
10780 ds_desc
.StencilReadMask
= D3D11_DEFAULT_STENCIL_READ_MASK
;
10781 ds_desc
.StencilWriteMask
= D3D11_DEFAULT_STENCIL_WRITE_MASK
;
10782 ds_desc
.FrontFace
.StencilFailOp
= D3D11_STENCIL_OP_KEEP
;
10783 ds_desc
.FrontFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_KEEP
;
10784 ds_desc
.FrontFace
.StencilPassOp
= D3D11_STENCIL_OP_KEEP
;
10785 ds_desc
.FrontFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
10786 ds_desc
.BackFace
.StencilFailOp
= D3D11_STENCIL_OP_KEEP
;
10787 ds_desc
.BackFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_KEEP
;
10788 ds_desc
.BackFace
.StencilPassOp
= D3D11_STENCIL_OP_KEEP
;
10789 ds_desc
.BackFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
10791 hr
= ID3D11Device_CreateDepthStencilState(device
, &ds_desc
, &ds_state
);
10792 ok(SUCCEEDED(hr
), "Failed to create depthstencil state, hr %#x.\n", hr
);
10794 texture_desc
.Width
= 512;
10795 texture_desc
.Height
= 512;
10796 texture_desc
.MipLevels
= 1;
10797 texture_desc
.ArraySize
= 1;
10798 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
10799 texture_desc
.SampleDesc
.Count
= 1;
10800 texture_desc
.SampleDesc
.Quality
= 0;
10801 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
10802 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
10803 texture_desc
.CPUAccessFlags
= 0;
10804 texture_desc
.MiscFlags
= 0;
10806 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
10808 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rt_texture
[i
]);
10809 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
10812 texture_desc
.Format
= DXGI_FORMAT_D24_UNORM_S8_UINT
;
10813 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
10815 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &ds_texture
);
10816 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
10818 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
10820 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rt_texture
[i
], NULL
, &rtv
[i
]);
10821 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
10824 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)ds_texture
, NULL
, &dsv
);
10825 ok(SUCCEEDED(hr
), "Failed to create depthstencil view, hr %#x.\n", hr
);
10827 for (i
= 0; i
< D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
; ++i
)
10829 SetRect(&tmp_rect
[i
], i
, i
* 2, i
+ 1, (i
+ 1) * 2);
10831 tmp_viewport
[i
].TopLeftX
= i
* 3;
10832 tmp_viewport
[i
].TopLeftY
= i
* 4;
10833 tmp_viewport
[i
].Width
= 3;
10834 tmp_viewport
[i
].Height
= 4;
10835 tmp_viewport
[i
].MinDepth
= i
* 0.01f
;
10836 tmp_viewport
[i
].MaxDepth
= (i
+ 1) * 0.01f
;
10839 rs_desc
.FillMode
= D3D11_FILL_SOLID
;
10840 rs_desc
.CullMode
= D3D11_CULL_BACK
;
10841 rs_desc
.FrontCounterClockwise
= FALSE
;
10842 rs_desc
.DepthBias
= 0;
10843 rs_desc
.DepthBiasClamp
= 0.0f
;
10844 rs_desc
.SlopeScaledDepthBias
= 0.0f
;
10845 rs_desc
.DepthClipEnable
= TRUE
;
10846 rs_desc
.ScissorEnable
= FALSE
;
10847 rs_desc
.MultisampleEnable
= FALSE
;
10848 rs_desc
.AntialiasedLineEnable
= FALSE
;
10850 hr
= ID3D11Device_CreateRasterizerState(device
, &rs_desc
, &rs_state
);
10851 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
10853 predicate_desc
.Query
= D3D11_QUERY_OCCLUSION_PREDICATE
;
10854 predicate_desc
.MiscFlags
= 0;
10856 hr
= ID3D11Device_CreatePredicate(device
, &predicate_desc
, &predicate
);
10857 ok(SUCCEEDED(hr
), "Failed to create predicate, hr %#x.\n", hr
);
10861 /* Some versions of Windows AMD drivers hang while the device is being
10862 * released, if the total number of used resource slots exceeds some limit.
10863 * Do not use all constant buffers slots in order to not trigger this
10865 ID3D11DeviceContext_VSSetConstantBuffers(context
, 0, 1, &cb
[0]);
10866 ID3D11DeviceContext_VSSetConstantBuffers(context
, 7, 1, &cb
[7]);
10867 ID3D11DeviceContext_VSSetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, srv
);
10868 ID3D11DeviceContext_VSSetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, sampler
);
10869 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
10871 ID3D11DeviceContext_HSSetConstantBuffers(context
, 0, 1, &cb
[0]);
10872 ID3D11DeviceContext_HSSetConstantBuffers(context
, 7, 1, &cb
[7]);
10873 ID3D11DeviceContext_HSSetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, srv
);
10874 ID3D11DeviceContext_HSSetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, sampler
);
10875 ID3D11DeviceContext_HSSetShader(context
, hs
, NULL
, 0);
10877 ID3D11DeviceContext_DSSetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, cb
);
10878 ID3D11DeviceContext_DSSetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, srv
);
10879 ID3D11DeviceContext_DSSetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, sampler
);
10880 ID3D11DeviceContext_DSSetShader(context
, ds
, NULL
, 0);
10882 ID3D11DeviceContext_GSSetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, cb
);
10883 ID3D11DeviceContext_GSSetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, srv
);
10884 ID3D11DeviceContext_GSSetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, sampler
);
10885 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
10887 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, cb
);
10888 ID3D11DeviceContext_PSSetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, srv
);
10889 ID3D11DeviceContext_PSSetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, sampler
);
10890 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
10892 ID3D11DeviceContext_CSSetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, cb
);
10893 ID3D11DeviceContext_CSSetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, srv
);
10894 ID3D11DeviceContext_CSSetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, sampler
);
10895 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
10896 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, D3D11_PS_CS_UAV_REGISTER_COUNT
, cs_uav
, NULL
);
10898 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
,
10899 buffer
, stride
, offset
);
10900 ID3D11DeviceContext_IASetIndexBuffer(context
, buffer
[0], DXGI_FORMAT_R32_UINT
, offset
[0]);
10901 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
10902 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
10904 blend_factor
[0] = 0.1f
;
10905 blend_factor
[1] = 0.2f
;
10906 blend_factor
[2] = 0.3f
;
10907 blend_factor
[3] = 0.4f
;
10908 ID3D11DeviceContext_OMSetBlendState(context
, blend_state
, blend_factor
, 0xff00ff00);
10909 ID3D11DeviceContext_OMSetDepthStencilState(context
, ds_state
, 3);
10910 ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context
,
10911 D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
- 1, rtv
, dsv
,
10912 D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
- 1, 1, &ps_uav
, NULL
);
10914 ID3D11DeviceContext_RSSetScissorRects(context
, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
,
10916 ID3D11DeviceContext_RSSetViewports(context
, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
,
10918 ID3D11DeviceContext_RSSetState(context
, rs_state
);
10920 ID3D11DeviceContext_SOSetTargets(context
, D3D11_SO_BUFFER_SLOT_COUNT
, so_buffer
, offset
);
10922 ID3D11DeviceContext_SetPredication(context
, predicate
, TRUE
);
10924 /* Verify the set state. */
10926 ID3D11DeviceContext_VSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
10928 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
10930 ID3D11Buffer
*expected_cb
= i
% 7 ? NULL
: cb
[i
];
10931 ok(tmp_buffer
[i
] == expected_cb
, "Got unexpected constant buffer %p in slot %u, expected %p.\n",
10932 tmp_buffer
[i
], i
, expected_cb
);
10934 ID3D11Buffer_Release(tmp_buffer
[i
]);
10936 ID3D11DeviceContext_VSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
10937 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
10939 ok(tmp_srv
[i
] == srv
[i
], "Got unexpected shader resource view %p in slot %u, expected %p.\n",
10940 tmp_srv
[i
], i
, srv
[i
]);
10941 ID3D11ShaderResourceView_Release(tmp_srv
[i
]);
10943 ID3D11DeviceContext_VSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
10944 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
10946 ok(tmp_sampler
[i
] == sampler
[i
], "Got unexpected sampler %p in slot %u, expected %p.\n",
10947 tmp_sampler
[i
], i
, sampler
[i
]);
10948 ID3D11SamplerState_Release(tmp_sampler
[i
]);
10950 ID3D11DeviceContext_VSGetShader(context
, &tmp_vs
, NULL
, 0);
10951 ok(tmp_vs
== vs
, "Got unexpected vertex shader %p, expected %p.\n", tmp_vs
, vs
);
10952 ID3D11VertexShader_Release(tmp_vs
);
10954 ID3D11DeviceContext_HSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
10956 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
10958 ID3D11Buffer
*expected_cb
= i
% 7 ? NULL
: cb
[i
];
10959 ok(tmp_buffer
[i
] == expected_cb
, "Got unexpected constant buffer %p in slot %u, expected %p.\n",
10960 tmp_buffer
[i
], i
, expected_cb
);
10962 ID3D11Buffer_Release(tmp_buffer
[i
]);
10964 ID3D11DeviceContext_HSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
10965 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
10967 ok(tmp_srv
[i
] == srv
[i
], "Got unexpected shader resource view %p in slot %u, expected %p.\n",
10968 tmp_srv
[i
], i
, srv
[i
]);
10969 ID3D11ShaderResourceView_Release(tmp_srv
[i
]);
10971 ID3D11DeviceContext_HSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
10972 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
10974 ok(tmp_sampler
[i
] == sampler
[i
], "Got unexpected sampler %p in slot %u, expected %p.\n",
10975 tmp_sampler
[i
], i
, sampler
[i
]);
10976 ID3D11SamplerState_Release(tmp_sampler
[i
]);
10978 ID3D11DeviceContext_HSGetShader(context
, &tmp_hs
, NULL
, 0);
10979 ok(tmp_hs
== hs
, "Got unexpected hull shader %p, expected %p.\n", tmp_hs
, hs
);
10980 ID3D11HullShader_Release(tmp_hs
);
10982 ID3D11DeviceContext_DSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
10984 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
10986 ok(tmp_buffer
[i
] == cb
[i
], "Got unexpected constant buffer %p in slot %u, expected %p.\n",
10987 tmp_buffer
[i
], i
, cb
[i
]);
10988 ID3D11Buffer_Release(tmp_buffer
[i
]);
10990 ID3D11DeviceContext_DSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
10991 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
10993 ok(tmp_srv
[i
] == srv
[i
], "Got unexpected shader resource view %p in slot %u, expected %p.\n",
10994 tmp_srv
[i
], i
, srv
[i
]);
10995 ID3D11ShaderResourceView_Release(tmp_srv
[i
]);
10997 ID3D11DeviceContext_DSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
10998 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
11000 ok(tmp_sampler
[i
] == sampler
[i
], "Got unexpected sampler %p in slot %u, expected %p.\n",
11001 tmp_sampler
[i
], i
, sampler
[i
]);
11002 ID3D11SamplerState_Release(tmp_sampler
[i
]);
11004 ID3D11DeviceContext_DSGetShader(context
, &tmp_ds
, NULL
, 0);
11005 ok(tmp_ds
== ds
, "Got unexpected domain shader %p, expected %p.\n", tmp_ds
, ds
);
11006 ID3D11DomainShader_Release(tmp_ds
);
11008 ID3D11DeviceContext_GSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
11010 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
11012 ok(tmp_buffer
[i
] == cb
[i
], "Got unexpected constant buffer %p in slot %u, expected %p.\n",
11013 tmp_buffer
[i
], i
, cb
[i
]);
11014 ID3D11Buffer_Release(tmp_buffer
[i
]);
11016 ID3D11DeviceContext_GSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
11017 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
11019 ok(tmp_srv
[i
] == srv
[i
], "Got unexpected shader resource view %p in slot %u, expected %p.\n",
11020 tmp_srv
[i
], i
, srv
[i
]);
11021 ID3D11ShaderResourceView_Release(tmp_srv
[i
]);
11023 ID3D11DeviceContext_GSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
11024 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
11026 ok(tmp_sampler
[i
] == sampler
[i
], "Got unexpected sampler %p in slot %u, expected %p.\n",
11027 tmp_sampler
[i
], i
, sampler
[i
]);
11028 ID3D11SamplerState_Release(tmp_sampler
[i
]);
11030 ID3D11DeviceContext_GSGetShader(context
, &tmp_gs
, NULL
, 0);
11031 ok(tmp_gs
== gs
, "Got unexpected geometry shader %p, expected %p.\n", tmp_gs
, gs
);
11032 ID3D11GeometryShader_Release(tmp_gs
);
11034 ID3D11DeviceContext_PSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
11036 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
11038 ok(tmp_buffer
[i
] == cb
[i
], "Got unexpected constant buffer %p in slot %u, expected %p.\n",
11039 tmp_buffer
[i
], i
, cb
[i
]);
11040 ID3D11Buffer_Release(tmp_buffer
[i
]);
11042 ID3D11DeviceContext_PSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
11043 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
11045 ok(tmp_srv
[i
] == srv
[i
], "Got unexpected shader resource view %p in slot %u, expected %p.\n",
11046 tmp_srv
[i
], i
, srv
[i
]);
11047 ID3D11ShaderResourceView_Release(tmp_srv
[i
]);
11049 ID3D11DeviceContext_PSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
11050 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
11052 ok(tmp_sampler
[i
] == sampler
[i
], "Got unexpected sampler %p in slot %u, expected %p.\n",
11053 tmp_sampler
[i
], i
, sampler
[i
]);
11054 ID3D11SamplerState_Release(tmp_sampler
[i
]);
11056 ID3D11DeviceContext_PSGetShader(context
, &tmp_ps
, NULL
, 0);
11057 ok(tmp_ps
== ps
, "Got unexpected pixel shader %p, expected %p.\n", tmp_ps
, ps
);
11058 ID3D11PixelShader_Release(tmp_ps
);
11060 ID3D11DeviceContext_CSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
11062 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
11064 ok(tmp_buffer
[i
] == cb
[i
], "Got unexpected constant buffer %p in slot %u, expected %p.\n",
11065 tmp_buffer
[i
], i
, cb
[i
]);
11066 ID3D11Buffer_Release(tmp_buffer
[i
]);
11068 ID3D11DeviceContext_CSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
11069 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
11071 ok(tmp_srv
[i
] == srv
[i
], "Got unexpected shader resource view %p in slot %u, expected %p.\n",
11072 tmp_srv
[i
], i
, srv
[i
]);
11073 ID3D11ShaderResourceView_Release(tmp_srv
[i
]);
11075 ID3D11DeviceContext_CSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
11076 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
11078 ok(tmp_sampler
[i
] == sampler
[i
], "Got unexpected sampler %p in slot %u, expected %p.\n",
11079 tmp_sampler
[i
], i
, sampler
[i
]);
11080 ID3D11SamplerState_Release(tmp_sampler
[i
]);
11082 ID3D11DeviceContext_CSGetShader(context
, &tmp_cs
, NULL
, 0);
11083 ok(tmp_cs
== cs
, "Got unexpected compute shader %p, expected %p.\n", tmp_cs
, cs
);
11084 ID3D11ComputeShader_Release(tmp_cs
);
11085 ID3D11DeviceContext_CSGetUnorderedAccessViews(context
, 0, D3D11_PS_CS_UAV_REGISTER_COUNT
, tmp_uav
);
11086 for (i
= 0; i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
11088 ok(tmp_uav
[i
] == cs_uav
[i
], "Got unexpected unordered access view %p in slot %u, expected %p.\n",
11089 tmp_uav
[i
], i
, cs_uav
[i
]);
11090 ID3D11UnorderedAccessView_Release(tmp_uav
[i
]);
11093 ID3D11DeviceContext_IAGetVertexBuffers(context
, 0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
,
11094 tmp_buffer
, stride
, offset
);
11095 for (i
= 0; i
< D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
11097 todo_wine_if(i
>= D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
)
11099 ok(tmp_buffer
[i
] == buffer
[i
], "Got unexpected vertex buffer %p in slot %u, expected %p.\n",
11100 tmp_buffer
[i
], i
, buffer
[i
]);
11101 ok(stride
[i
] == (i
+ 1) * 4, "Got unexpected stride %u in slot %u.\n", stride
[i
], i
);
11102 ok(offset
[i
] == (i
+ 1) * 16, "Got unexpected offset %u in slot %u.\n", offset
[i
], i
);
11105 ID3D11Buffer_Release(tmp_buffer
[i
]);
11107 ID3D11DeviceContext_IAGetIndexBuffer(context
, tmp_buffer
, &format
, offset
);
11108 ok(tmp_buffer
[0] == buffer
[0], "Got unexpected index buffer %p, expected %p.\n", tmp_buffer
[0], buffer
[0]);
11109 ID3D11Buffer_Release(tmp_buffer
[0]);
11110 ok(format
== DXGI_FORMAT_R32_UINT
, "Got unexpected index buffer format %#x.\n", format
);
11111 ok(offset
[0] == 16, "Got unexpected index buffer offset %u.\n", offset
[0]);
11112 ID3D11DeviceContext_IAGetInputLayout(context
, &tmp_input_layout
);
11113 ok(tmp_input_layout
== input_layout
, "Got unexpected input layout %p, expected %p.\n",
11114 tmp_input_layout
, input_layout
);
11115 ID3D11InputLayout_Release(tmp_input_layout
);
11116 ID3D11DeviceContext_IAGetPrimitiveTopology(context
, &topology
);
11117 ok(topology
== D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
, "Got unexpected primitive topology %#x.\n", topology
);
11119 ID3D11DeviceContext_OMGetBlendState(context
, &tmp_blend_state
, blend_factor
, &sample_mask
);
11120 ok(tmp_blend_state
== blend_state
, "Got unexpected blend state %p, expected %p.\n", tmp_blend_state
, blend_state
);
11121 ID3D11BlendState_Release(tmp_blend_state
);
11122 ok(blend_factor
[0] == 0.1f
&& blend_factor
[1] == 0.2f
11123 && blend_factor
[2] == 0.3f
&& blend_factor
[3] == 0.4f
,
11124 "Got unexpected blend factor {%.8e, %.8e, %.8e, %.8e}.\n",
11125 blend_factor
[0], blend_factor
[1], blend_factor
[2], blend_factor
[3]);
11126 ok(sample_mask
== 0xff00ff00, "Got unexpected sample mask %#x.\n", sample_mask
);
11127 ID3D11DeviceContext_OMGetDepthStencilState(context
, &tmp_ds_state
, &stencil_ref
);
11128 ok(tmp_ds_state
== ds_state
, "Got unexpected depth stencil state %p, expected %p.\n", tmp_ds_state
, ds_state
);
11129 ID3D11DepthStencilState_Release(tmp_ds_state
);
11130 ok(stencil_ref
== 3, "Got unexpected stencil ref %u.\n", stencil_ref
);
11131 ID3D11DeviceContext_OMGetRenderTargets(context
, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
, tmp_rtv
, &tmp_dsv
);
11132 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
- 1; ++i
)
11134 ok(tmp_rtv
[i
] == rtv
[i
], "Got unexpected render target view %p in slot %u, expected %p.\n",
11135 tmp_rtv
[i
], i
, rtv
[i
]);
11136 ID3D11RenderTargetView_Release(tmp_rtv
[i
]);
11138 ok(!tmp_rtv
[i
], "Got unexpected render target view %p in slot %u.\n", tmp_rtv
[i
], i
);
11139 ok(tmp_dsv
== dsv
, "Got unexpected depth stencil view %p, expected %p.\n", tmp_dsv
, dsv
);
11140 ID3D11DepthStencilView_Release(tmp_dsv
);
11141 ID3D11DeviceContext_OMGetRenderTargetsAndUnorderedAccessViews(context
,
11142 D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
, tmp_rtv
, &tmp_dsv
,
11143 0, D3D11_PS_CS_UAV_REGISTER_COUNT
, tmp_uav
);
11144 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
- 1; ++i
)
11146 ok(tmp_rtv
[i
] == rtv
[i
], "Got unexpected render target view %p in slot %u, expected %p.\n",
11147 tmp_rtv
[i
], i
, rtv
[i
]);
11148 ID3D11RenderTargetView_Release(tmp_rtv
[i
]);
11150 ok(!tmp_rtv
[i
], "Got unexpected render target view %p in slot %u.\n", tmp_rtv
[i
], i
);
11151 ok(tmp_dsv
== dsv
, "Got unexpected depth stencil view %p, expected %p.\n", tmp_dsv
, dsv
);
11152 ID3D11DepthStencilView_Release(tmp_dsv
);
11153 for (i
= 0; i
< D3D11_PS_CS_UAV_REGISTER_COUNT
- 1; ++i
)
11155 ok(!tmp_uav
[i
], "Got unexpected unordered access view %p in slot %u.\n", tmp_uav
[i
], i
);
11157 ok(tmp_uav
[i
] == ps_uav
, "Got unexpected unordered access view %p in slot %u, expected %p.\n",
11158 tmp_uav
[i
], i
, ps_uav
);
11159 ID3D11UnorderedAccessView_Release(tmp_uav
[i
]);
11161 ID3D11DeviceContext_RSGetScissorRects(context
, &count
, NULL
);
11162 ok(count
== D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
,
11163 "Got unexpected scissor rect count %u.\n", count
);
11164 memset(tmp_rect
, 0x55, sizeof(tmp_rect
));
11165 ID3D11DeviceContext_RSGetScissorRects(context
, &count
, tmp_rect
);
11166 for (i
= 0; i
< count
; ++i
)
11168 ok(tmp_rect
[i
].left
== i
11169 && tmp_rect
[i
].top
== i
* 2
11170 && tmp_rect
[i
].right
== i
+ 1
11171 && tmp_rect
[i
].bottom
== (i
+ 1) * 2,
11172 "Got unexpected scissor rect %s in slot %u.\n", wine_dbgstr_rect(&tmp_rect
[i
]), i
);
11174 ID3D11DeviceContext_RSGetViewports(context
, &count
, NULL
);
11175 ok(count
== D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
,
11176 "Got unexpected viewport count %u.\n", count
);
11177 memset(tmp_viewport
, 0x55, sizeof(tmp_viewport
));
11178 ID3D11DeviceContext_RSGetViewports(context
, &count
, tmp_viewport
);
11179 for (i
= 0; i
< count
; ++i
)
11181 ok(tmp_viewport
[i
].TopLeftX
== i
* 3
11182 && tmp_viewport
[i
].TopLeftY
== i
* 4
11183 && tmp_viewport
[i
].Width
== 3
11184 && tmp_viewport
[i
].Height
== 4
11185 && compare_float(tmp_viewport
[i
].MinDepth
, i
* 0.01f
, 16)
11186 && compare_float(tmp_viewport
[i
].MaxDepth
, (i
+ 1) * 0.01f
, 16),
11187 "Got unexpected viewport {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e} in slot %u.\n",
11188 tmp_viewport
[i
].TopLeftX
, tmp_viewport
[i
].TopLeftY
, tmp_viewport
[i
].Width
,
11189 tmp_viewport
[i
].Height
, tmp_viewport
[i
].MinDepth
, tmp_viewport
[i
].MaxDepth
, i
);
11191 ID3D11DeviceContext_RSGetState(context
, &tmp_rs_state
);
11192 ok(tmp_rs_state
== rs_state
, "Got unexpected rasterizer state %p, expected %p.\n", tmp_rs_state
, rs_state
);
11193 ID3D11RasterizerState_Release(tmp_rs_state
);
11195 ID3D11DeviceContext_SOGetTargets(context
, D3D11_SO_BUFFER_SLOT_COUNT
, tmp_buffer
);
11196 for (i
= 0; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
11198 ok(tmp_buffer
[i
] == so_buffer
[i
], "Got unexpected stream output %p in slot %u, expected %p.\n",
11199 tmp_buffer
[i
], i
, so_buffer
[i
]);
11200 ID3D11Buffer_Release(tmp_buffer
[i
]);
11203 ID3D11DeviceContext_GetPredication(context
, &tmp_predicate
, &predicate_value
);
11204 ok(tmp_predicate
== predicate
, "Got unexpected predicate %p, expected %p.\n", tmp_predicate
, predicate
);
11205 ID3D11Predicate_Release(tmp_predicate
);
11206 ok(predicate_value
, "Got unexpected predicate value %#x.\n", predicate_value
);
11208 /* Verify ClearState(). */
11210 ID3D11DeviceContext_ClearState(context
);
11212 ID3D11DeviceContext_VSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
11214 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
11216 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
11218 ID3D11DeviceContext_VSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
11219 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
11221 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
11223 ID3D11DeviceContext_VSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
11224 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
11226 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
11228 ID3D11DeviceContext_VSGetShader(context
, &tmp_vs
, NULL
, 0);
11229 ok(!tmp_vs
, "Got unexpected vertex shader %p.\n", tmp_vs
);
11231 ID3D11DeviceContext_HSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
11233 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
11235 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
11237 ID3D11DeviceContext_HSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
11238 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
11240 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
11242 ID3D11DeviceContext_HSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
11243 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
11245 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
11247 ID3D11DeviceContext_HSGetShader(context
, &tmp_hs
, NULL
, 0);
11248 ok(!tmp_hs
, "Got unexpected hull shader %p.\n", tmp_hs
);
11250 ID3D11DeviceContext_DSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
11252 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
11254 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
11256 ID3D11DeviceContext_DSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
11257 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
11259 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
11261 ID3D11DeviceContext_DSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
11262 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
11264 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
11266 ID3D11DeviceContext_DSGetShader(context
, &tmp_ds
, NULL
, 0);
11267 ok(!tmp_ds
, "Got unexpected domain shader %p.\n", tmp_ds
);
11269 ID3D11DeviceContext_GSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
11271 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
11273 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
11275 ID3D11DeviceContext_GSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
11276 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
11278 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
11280 ID3D11DeviceContext_GSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
11281 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
11283 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
11285 ID3D11DeviceContext_GSGetShader(context
, &tmp_gs
, NULL
, 0);
11286 ok(!tmp_gs
, "Got unexpected geometry shader %p.\n", tmp_gs
);
11288 ID3D11DeviceContext_PSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
11290 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
11292 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
11294 ID3D11DeviceContext_PSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
11295 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
11297 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
11299 ID3D11DeviceContext_PSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
11300 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
11302 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
11304 ID3D11DeviceContext_PSGetShader(context
, &tmp_ps
, NULL
, 0);
11305 ok(!tmp_ps
, "Got unexpected pixel shader %p.\n", tmp_ps
);
11307 ID3D11DeviceContext_CSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
11309 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
11311 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
11313 ID3D11DeviceContext_CSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
,
11315 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
11317 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
11319 ID3D11DeviceContext_CSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
11320 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
11322 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
11324 ID3D11DeviceContext_CSGetShader(context
, &tmp_cs
, NULL
, 0);
11325 ok(!tmp_cs
, "Got unexpected compute shader %p.\n", tmp_cs
);
11326 ID3D11DeviceContext_CSGetUnorderedAccessViews(context
, 0, D3D11_PS_CS_UAV_REGISTER_COUNT
, tmp_uav
);
11327 for (i
= 0; i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
11329 ok(!tmp_uav
[i
], "Got unexpected unordered access view %p in slot %u.\n", tmp_uav
[i
], i
);
11332 ID3D11DeviceContext_IAGetVertexBuffers(context
, 0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
,
11333 tmp_buffer
, stride
, offset
);
11334 for (i
= 0; i
< D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
11336 ok(!tmp_buffer
[i
], "Got unexpected vertex buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
11337 ok(!stride
[i
], "Got unexpected stride %u in slot %u.\n", stride
[i
], i
);
11338 ok(!offset
[i
], "Got unexpected offset %u in slot %u.\n", offset
[i
], i
);
11340 ID3D11DeviceContext_IAGetIndexBuffer(context
, tmp_buffer
, &format
, offset
);
11341 ok(!tmp_buffer
[0], "Got unexpected index buffer %p.\n", tmp_buffer
[0]);
11342 ok(format
== DXGI_FORMAT_UNKNOWN
, "Got unexpected index buffer format %#x.\n", format
);
11343 ok(!offset
[0], "Got unexpected index buffer offset %u.\n", offset
[0]);
11344 ID3D11DeviceContext_IAGetInputLayout(context
, &tmp_input_layout
);
11345 ok(!tmp_input_layout
, "Got unexpected input layout %p.\n", tmp_input_layout
);
11346 ID3D11DeviceContext_IAGetPrimitiveTopology(context
, &topology
);
11347 ok(topology
== D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED
, "Got unexpected primitive topology %#x.\n", topology
);
11349 ID3D11DeviceContext_OMGetBlendState(context
, &tmp_blend_state
, blend_factor
, &sample_mask
);
11350 ok(!tmp_blend_state
, "Got unexpected blend state %p.\n", tmp_blend_state
);
11351 ok(blend_factor
[0] == 1.0f
&& blend_factor
[1] == 1.0f
11352 && blend_factor
[2] == 1.0f
&& blend_factor
[3] == 1.0f
,
11353 "Got unexpected blend factor {%.8e, %.8e, %.8e, %.8e}.\n",
11354 blend_factor
[0], blend_factor
[1], blend_factor
[2], blend_factor
[3]);
11355 ok(sample_mask
== D3D11_DEFAULT_SAMPLE_MASK
, "Got unexpected sample mask %#x.\n", sample_mask
);
11356 ID3D11DeviceContext_OMGetDepthStencilState(context
, &tmp_ds_state
, &stencil_ref
);
11357 ok(!tmp_ds_state
, "Got unexpected depth stencil state %p.\n", tmp_ds_state
);
11358 ok(!stencil_ref
, "Got unexpected stencil ref %u.\n", stencil_ref
);
11359 ID3D11DeviceContext_OMGetRenderTargets(context
, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
, tmp_rtv
, &tmp_dsv
);
11360 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
11362 ok(!tmp_rtv
[i
], "Got unexpected render target view %p in slot %u.\n", tmp_rtv
[i
], i
);
11364 ok(!tmp_dsv
, "Got unexpected depth stencil view %p.\n", tmp_dsv
);
11365 ID3D11DeviceContext_OMGetRenderTargetsAndUnorderedAccessViews(context
,
11366 D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
, tmp_rtv
, &tmp_dsv
,
11367 0, D3D11_PS_CS_UAV_REGISTER_COUNT
, tmp_uav
);
11368 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
11370 ok(!tmp_rtv
[i
], "Got unexpected render target view %p in slot %u.\n", tmp_rtv
[i
], i
);
11372 ok(!tmp_dsv
, "Got unexpected depth stencil view %p.\n", tmp_dsv
);
11373 for (i
= 0; i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
11375 ok(!tmp_uav
[i
], "Got unexpected unordered access view %p in slot %u.\n", tmp_uav
[i
], i
);
11378 ID3D11DeviceContext_RSGetScissorRects(context
, &count
, NULL
);
11379 ok(!count
, "Got unexpected scissor rect count %u.\n", count
);
11380 memset(tmp_rect
, 0x55, sizeof(tmp_rect
));
11381 count
= D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
;
11382 ID3D11DeviceContext_RSGetScissorRects(context
, &count
, tmp_rect
);
11383 for (i
= 0; i
< D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
; ++i
)
11385 ok(!tmp_rect
[i
].left
&& !tmp_rect
[i
].top
&& !tmp_rect
[i
].right
&& !tmp_rect
[i
].bottom
,
11386 "Got unexpected scissor rect %s in slot %u.\n",
11387 wine_dbgstr_rect(&tmp_rect
[i
]), i
);
11389 ID3D11DeviceContext_RSGetViewports(context
, &count
, NULL
);
11390 ok(!count
, "Got unexpected viewport count %u.\n", count
);
11391 memset(tmp_viewport
, 0x55, sizeof(tmp_viewport
));
11392 count
= D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
;
11393 ID3D11DeviceContext_RSGetViewports(context
, &count
, tmp_viewport
);
11394 for (i
= 0; i
< D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
; ++i
)
11396 ok(!tmp_viewport
[i
].TopLeftX
&& !tmp_viewport
[i
].TopLeftY
&& !tmp_viewport
[i
].Width
11397 && !tmp_viewport
[i
].Height
&& !tmp_viewport
[i
].MinDepth
&& !tmp_viewport
[i
].MaxDepth
,
11398 "Got unexpected viewport {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e} in slot %u.\n",
11399 tmp_viewport
[i
].TopLeftX
, tmp_viewport
[i
].TopLeftY
, tmp_viewport
[i
].Width
,
11400 tmp_viewport
[i
].Height
, tmp_viewport
[i
].MinDepth
, tmp_viewport
[i
].MaxDepth
, i
);
11402 ID3D11DeviceContext_RSGetState(context
, &tmp_rs_state
);
11403 ok(!tmp_rs_state
, "Got unexpected rasterizer state %p.\n", tmp_rs_state
);
11405 ID3D11DeviceContext_SOGetTargets(context
, D3D11_SO_BUFFER_SLOT_COUNT
, tmp_buffer
);
11406 for (i
= 0; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
11408 ok(!tmp_buffer
[i
], "Got unexpected stream output %p in slot %u.\n", tmp_buffer
[i
], i
);
11411 ID3D11DeviceContext_GetPredication(context
, &tmp_predicate
, &predicate_value
);
11412 ok(!tmp_predicate
, "Got unexpected predicate %p.\n", tmp_predicate
);
11413 ok(!predicate_value
, "Got unexpected predicate value %#x.\n", predicate_value
);
11417 ID3D11Predicate_Release(predicate
);
11418 ID3D11RasterizerState_Release(rs_state
);
11419 ID3D11DepthStencilView_Release(dsv
);
11420 ID3D11Texture2D_Release(ds_texture
);
11422 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
11424 ID3D11RenderTargetView_Release(rtv
[i
]);
11425 ID3D11Texture2D_Release(rt_texture
[i
]);
11428 ID3D11DepthStencilState_Release(ds_state
);
11429 ID3D11BlendState_Release(blend_state
);
11430 ID3D11InputLayout_Release(input_layout
);
11431 ID3D11VertexShader_Release(vs
);
11432 ID3D11HullShader_Release(hs
);
11433 ID3D11DomainShader_Release(ds
);
11434 ID3D11GeometryShader_Release(gs
);
11435 ID3D11PixelShader_Release(ps
);
11436 ID3D11ComputeShader_Release(cs
);
11438 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
11440 ID3D11SamplerState_Release(sampler
[i
]);
11443 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
11445 ID3D11ShaderResourceView_Release(srv
[i
]);
11448 for (i
= 0; i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
11450 ID3D11UnorderedAccessView_Release(cs_uav
[i
]);
11451 ID3D11Buffer_Release(cs_uav_buffer
[i
]);
11453 ID3D11UnorderedAccessView_Release(ps_uav
);
11454 ID3D11Buffer_Release(ps_uav_buffer
);
11456 for (i
= 0; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
11458 ID3D11Buffer_Release(so_buffer
[i
]);
11461 for (i
= 0; i
< D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
11463 ID3D11Buffer_Release(buffer
[i
]);
11466 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
11468 ID3D11Buffer_Release(cb
[i
]);
11471 ID3D11DeviceContext_Release(context
);
11472 refcount
= ID3D11Device_Release(device
);
11473 ok(!refcount
, "Device has %u references left.\n", refcount
);
11476 static void test_il_append_aligned(void)
11478 struct d3d11_test_context test_context
;
11479 ID3D11InputLayout
*input_layout
;
11480 ID3D11DeviceContext
*context
;
11481 unsigned int stride
, offset
;
11482 ID3D11VertexShader
*vs
;
11483 ID3D11PixelShader
*ps
;
11484 ID3D11Device
*device
;
11485 ID3D11Buffer
*vb
[3];
11489 /* Semantic names are case-insensitive. */
11490 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
11492 {"CoLoR", 2, DXGI_FORMAT_R32G32_FLOAT
, 1, D3D11_APPEND_ALIGNED_ELEMENT
,
11493 D3D11_INPUT_PER_INSTANCE_DATA
, 2},
11494 {"ColoR", 3, DXGI_FORMAT_R32G32_FLOAT
, 2, D3D11_APPEND_ALIGNED_ELEMENT
,
11495 D3D11_INPUT_PER_INSTANCE_DATA
, 1},
11496 {"POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, D3D11_APPEND_ALIGNED_ELEMENT
,
11497 D3D11_INPUT_PER_VERTEX_DATA
, 0},
11498 {"ColoR", 0, DXGI_FORMAT_R32G32_FLOAT
, 2, D3D11_APPEND_ALIGNED_ELEMENT
,
11499 D3D11_INPUT_PER_INSTANCE_DATA
, 1},
11500 {"cOLOr", 1, DXGI_FORMAT_R32G32_FLOAT
, 1, D3D11_APPEND_ALIGNED_ELEMENT
,
11501 D3D11_INPUT_PER_INSTANCE_DATA
, 2},
11503 static const DWORD vs_code
[] =
11508 float4 position
: POSITION
;
11509 float2 color_xy
: COLOR0
;
11510 float2 color_zw
: COLOR1
;
11511 unsigned int instance_id
: SV_INSTANCEID
;
11516 float4 position
: SV_POSITION
;
11517 float2 color_xy
: COLOR0
;
11518 float2 color_zw
: COLOR1
;
11521 struct vs_out
main(struct vs_in i
)
11525 o
.position
= i
.position
;
11526 o
.position
.x
+= i
.instance_id
* 0.5;
11527 o
.color_xy
= i
.color_xy
;
11528 o
.color_zw
= i
.color_zw
;
11533 0x43425844, 0x52e3bf46, 0x6300403d, 0x624cffe4, 0xa4fc0013, 0x00000001, 0x00000214, 0x00000003,
11534 0x0000002c, 0x000000bc, 0x00000128, 0x4e475349, 0x00000088, 0x00000004, 0x00000008, 0x00000068,
11535 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000071, 0x00000000, 0x00000000,
11536 0x00000003, 0x00000001, 0x00000303, 0x00000071, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
11537 0x00000303, 0x00000077, 0x00000000, 0x00000008, 0x00000001, 0x00000003, 0x00000101, 0x49534f50,
11538 0x4e4f4954, 0x4c4f4300, 0x5300524f, 0x4e495f56, 0x4e415453, 0x44494543, 0xababab00, 0x4e47534f,
11539 0x00000064, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000,
11540 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000c03, 0x0000005c,
11541 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000030c, 0x505f5653, 0x5449534f, 0x004e4f49,
11542 0x4f4c4f43, 0xabab0052, 0x52444853, 0x000000e4, 0x00010040, 0x00000039, 0x0300005f, 0x001010f2,
11543 0x00000000, 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x00101032, 0x00000002, 0x04000060,
11544 0x00101012, 0x00000003, 0x00000008, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065,
11545 0x00102032, 0x00000001, 0x03000065, 0x001020c2, 0x00000001, 0x02000068, 0x00000001, 0x05000056,
11546 0x00100012, 0x00000000, 0x0010100a, 0x00000003, 0x09000032, 0x00102012, 0x00000000, 0x0010000a,
11547 0x00000000, 0x00004001, 0x3f000000, 0x0010100a, 0x00000000, 0x05000036, 0x001020e2, 0x00000000,
11548 0x00101e56, 0x00000000, 0x05000036, 0x00102032, 0x00000001, 0x00101046, 0x00000001, 0x05000036,
11549 0x001020c2, 0x00000001, 0x00101406, 0x00000002, 0x0100003e,
11551 static const DWORD ps_code
[] =
11556 float4 position
: SV_POSITION
;
11557 float2 color_xy
: COLOR0
;
11558 float2 color_zw
: COLOR1
;
11561 float4
main(struct vs_out i
) : SV_TARGET
11563 return float4(i
.color_xy
.xy
, i
.color_zw
.xy
);
11566 0x43425844, 0x64e48a09, 0xaa484d46, 0xe40a6e78, 0x9885edf3, 0x00000001, 0x00000118, 0x00000003,
11567 0x0000002c, 0x00000098, 0x000000cc, 0x4e475349, 0x00000064, 0x00000003, 0x00000008, 0x00000050,
11568 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000,
11569 0x00000003, 0x00000001, 0x00000303, 0x0000005c, 0x00000001, 0x00000000, 0x00000003, 0x00000001,
11570 0x00000c0c, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x4e47534f, 0x0000002c,
11571 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f,
11572 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000044, 0x00000040, 0x00000011, 0x03001062,
11573 0x00101032, 0x00000001, 0x03001062, 0x001010c2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
11574 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
11576 static const struct
11578 struct vec4 position
;
11582 {{-1.0f
, -1.0f
, 0.0f
, 1.0f
}},
11583 {{-1.0f
, 1.0f
, 0.0f
, 1.0f
}},
11584 {{-0.5f
, -1.0f
, 0.0f
, 1.0f
}},
11585 {{-0.5f
, 1.0f
, 0.0f
, 1.0f
}},
11587 static const struct
11589 struct vec2 color2
;
11590 struct vec2 color1
;
11594 {{0.5f
, 0.5f
}, {0.0f
, 1.0f
}},
11595 {{0.5f
, 0.5f
}, {1.0f
, 1.0f
}},
11597 static const struct
11599 struct vec2 color3
;
11600 struct vec2 color0
;
11604 {{0.5f
, 0.5f
}, {1.0f
, 0.0f
}},
11605 {{0.5f
, 0.5f
}, {0.0f
, 1.0f
}},
11606 {{0.5f
, 0.5f
}, {0.0f
, 0.0f
}},
11607 {{0.5f
, 0.5f
}, {1.0f
, 0.0f
}},
11609 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
11611 if (!init_test_context(&test_context
, NULL
))
11614 device
= test_context
.device
;
11615 context
= test_context
.immediate_context
;
11617 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
11618 vs_code
, sizeof(vs_code
), &input_layout
);
11619 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
11621 vb
[0] = create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(stream0
), stream0
);
11622 vb
[1] = create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(stream1
), stream1
);
11623 vb
[2] = create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(stream2
), stream2
);
11625 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
11626 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
11627 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
11628 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
11630 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
11631 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
11633 stride
= sizeof(*stream0
);
11634 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
[0], &stride
, &offset
);
11635 stride
= sizeof(*stream1
);
11636 ID3D11DeviceContext_IASetVertexBuffers(context
, 1, 1, &vb
[1], &stride
, &offset
);
11637 stride
= sizeof(*stream2
);
11638 ID3D11DeviceContext_IASetVertexBuffers(context
, 2, 1, &vb
[2], &stride
, &offset
);
11639 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
11640 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
11642 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
11644 ID3D11DeviceContext_DrawInstanced(context
, 4, 4, 0, 0);
11646 color
= get_texture_color(test_context
.backbuffer
, 80, 240);
11647 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
11648 color
= get_texture_color(test_context
.backbuffer
, 240, 240);
11649 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
11650 color
= get_texture_color(test_context
.backbuffer
, 400, 240);
11651 ok(compare_color(color
, 0xffff0000, 1), "Got unexpected color 0x%08x.\n", color
);
11652 color
= get_texture_color(test_context
.backbuffer
, 560, 240);
11653 ok(compare_color(color
, 0xffff00ff, 1), "Got unexpected color 0x%08x.\n", color
);
11655 ID3D11PixelShader_Release(ps
);
11656 ID3D11VertexShader_Release(vs
);
11657 ID3D11Buffer_Release(vb
[2]);
11658 ID3D11Buffer_Release(vb
[1]);
11659 ID3D11Buffer_Release(vb
[0]);
11660 ID3D11InputLayout_Release(input_layout
);
11661 release_test_context(&test_context
);
11664 static void test_instance_id(void)
11666 struct d3d11_test_context test_context
;
11667 D3D11_TEXTURE2D_DESC texture_desc
;
11668 ID3D11InputLayout
*input_layout
;
11669 ID3D11RenderTargetView
*rtvs
[2];
11670 ID3D11Texture2D
*render_target
;
11671 ID3D11DeviceContext
*context
;
11672 struct resource_readback rb
;
11673 unsigned int stride
, offset
;
11674 ID3D11Buffer
*args_buffer
;
11675 ID3D11VertexShader
*vs
;
11676 ID3D11PixelShader
*ps
;
11677 ID3D11Device
*device
;
11678 ID3D11Buffer
*vb
[2];
11682 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
11684 {"position", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, D3D11_APPEND_ALIGNED_ELEMENT
,
11685 D3D11_INPUT_PER_VERTEX_DATA
, 0},
11686 {"color", 0, DXGI_FORMAT_R8_UNORM
, 1, D3D11_APPEND_ALIGNED_ELEMENT
,
11687 D3D11_INPUT_PER_INSTANCE_DATA
, 1},
11688 {"v_offset", 0, DXGI_FORMAT_R32_FLOAT
, 1, D3D11_APPEND_ALIGNED_ELEMENT
,
11689 D3D11_INPUT_PER_INSTANCE_DATA
, 1},
11691 static const DWORD vs_code
[] =
11696 float4 position
: Position
;
11697 float color
: Color
;
11698 float v_offset
: V_Offset
;
11699 uint instance_id
: SV_InstanceId
;
11704 float4 position
: SV_Position
;
11705 float color
: Color
;
11706 uint instance_id
: InstanceId
;
11709 void main(vs_in i
, out vs_out o
)
11711 o
.position
= i
.position
;
11712 o
.position
.x
+= i
.v_offset
;
11714 o
.instance_id
= i
.instance_id
;
11717 0x43425844, 0xcde3cfbf, 0xe2e3d090, 0xe2eb1038, 0x7e5ad1cf, 0x00000001, 0x00000204, 0x00000003,
11718 0x0000002c, 0x000000c4, 0x0000013c, 0x4e475349, 0x00000090, 0x00000004, 0x00000008, 0x00000068,
11719 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000071, 0x00000000, 0x00000000,
11720 0x00000003, 0x00000001, 0x00000101, 0x00000077, 0x00000000, 0x00000000, 0x00000003, 0x00000002,
11721 0x00000101, 0x00000080, 0x00000000, 0x00000008, 0x00000001, 0x00000003, 0x00000101, 0x69736f50,
11722 0x6e6f6974, 0x6c6f4300, 0x5600726f, 0x66664f5f, 0x00746573, 0x495f5653, 0x6174736e, 0x4965636e,
11723 0xabab0064, 0x4e47534f, 0x00000070, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001,
11724 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001,
11725 0x00000e01, 0x00000062, 0x00000000, 0x00000000, 0x00000001, 0x00000002, 0x00000e01, 0x505f5653,
11726 0x7469736f, 0x006e6f69, 0x6f6c6f43, 0x6e490072, 0x6e617473, 0x64496563, 0xababab00, 0x52444853,
11727 0x000000c0, 0x00010040, 0x00000030, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x00101012,
11728 0x00000001, 0x0300005f, 0x00101012, 0x00000002, 0x04000060, 0x00101012, 0x00000003, 0x00000008,
11729 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000001, 0x03000065,
11730 0x00102012, 0x00000002, 0x07000000, 0x00102012, 0x00000000, 0x0010100a, 0x00000000, 0x0010100a,
11731 0x00000002, 0x05000036, 0x001020e2, 0x00000000, 0x00101e56, 0x00000000, 0x05000036, 0x00102012,
11732 0x00000001, 0x0010100a, 0x00000001, 0x05000036, 0x00102012, 0x00000002, 0x0010100a, 0x00000003,
11735 static const DWORD ps_code
[] =
11740 float4 position
: SV_Position
;
11741 float color
: Color
;
11742 uint instance_id
: InstanceId
;
11745 void main(vs_out i
, out float4 o0
: SV_Target0
, out uint4 o1
: SV_Target1
)
11747 o0
= float4(i
.color
, i
.color
, i
.color
, 1.0f
);
11748 o1
= i
.instance_id
;
11751 0x43425844, 0xda0ad0bb, 0x4743f5f5, 0xfbc6d0b1, 0x7c8e7df5, 0x00000001, 0x00000170, 0x00000003,
11752 0x0000002c, 0x000000a4, 0x000000f0, 0x4e475349, 0x00000070, 0x00000003, 0x00000008, 0x00000050,
11753 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000,
11754 0x00000003, 0x00000001, 0x00000101, 0x00000062, 0x00000000, 0x00000000, 0x00000001, 0x00000002,
11755 0x00000101, 0x505f5653, 0x7469736f, 0x006e6f69, 0x6f6c6f43, 0x6e490072, 0x6e617473, 0x64496563,
11756 0xababab00, 0x4e47534f, 0x00000044, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000000,
11757 0x00000003, 0x00000000, 0x0000000f, 0x00000038, 0x00000001, 0x00000000, 0x00000001, 0x00000001,
11758 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000078, 0x00000040, 0x0000001e,
11759 0x03001062, 0x00101012, 0x00000001, 0x03000862, 0x00101012, 0x00000002, 0x03000065, 0x001020f2,
11760 0x00000000, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x00102072, 0x00000000, 0x00101006,
11761 0x00000001, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x3f800000, 0x05000036, 0x001020f2,
11762 0x00000001, 0x00101006, 0x00000002, 0x0100003e,
11764 static const struct vec4 stream0
[] =
11766 {-1.00f
, 0.0f
, 0.0f
, 1.0f
},
11767 {-1.00f
, 1.0f
, 0.0f
, 1.0f
},
11768 {-0.75f
, 0.0f
, 0.0f
, 1.0f
},
11769 {-0.75f
, 1.0f
, 0.0f
, 1.0f
},
11770 /* indirect draws data */
11771 {-1.00f
, -1.0f
, 0.0f
, 1.0f
},
11772 {-1.00f
, 0.0f
, 0.0f
, 1.0f
},
11773 {-0.75f
, -1.0f
, 0.0f
, 1.0f
},
11774 {-0.75f
, 0.0f
, 0.0f
, 1.0f
},
11776 static const struct
11793 static const D3D11_DRAW_INSTANCED_INDIRECT_ARGS argument_data
[] =
11798 static const struct
11801 unsigned int color
;
11802 unsigned int instance_id
;
11804 expected_results
[] =
11806 {{ 0, 0, 80, 240}, 0xfff0f0f0, 0},
11807 {{ 80, 0, 160, 240}, 0xff808080, 1},
11808 {{160, 0, 240, 240}, 0xff101010, 2},
11809 {{240, 0, 320, 240}, 0xff404040, 3},
11810 {{320, 0, 400, 240}, 0xffaaaaaa, 0},
11811 {{400, 0, 480, 240}, 0xffbbbbbb, 1},
11812 {{480, 0, 560, 240}, 0xffcccccc, 2},
11813 {{560, 0, 640, 240}, 0xff909090, 3},
11814 /* indirect draws results */
11815 {{ 0, 240, 80, 480}, 0xfff0f0f0, 0},
11816 {{ 80, 240, 160, 480}, 0xff808080, 1},
11817 {{160, 240, 240, 480}, 0xff101010, 2},
11818 {{240, 240, 320, 480}, 0xff404040, 3},
11819 {{320, 240, 400, 480}, 0xffaaaaaa, 0},
11820 {{400, 240, 480, 480}, 0xffbbbbbb, 1},
11821 {{480, 240, 560, 480}, 0xffcccccc, 2},
11822 {{560, 240, 640, 480}, 0xff909090, 3},
11824 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
11825 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
11827 if (!init_test_context(&test_context
, &feature_level
))
11829 device
= test_context
.device
;
11830 context
= test_context
.immediate_context
;
11832 rtvs
[0] = test_context
.backbuffer_rtv
;
11834 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
11835 texture_desc
.Format
= DXGI_FORMAT_R32_UINT
;
11836 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &render_target
);
11837 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
11838 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)render_target
, NULL
, &rtvs
[1]);
11839 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
11841 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
11842 vs_code
, sizeof(vs_code
), &input_layout
);
11843 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
11845 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
11846 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
11847 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
11848 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
11850 vb
[0] = create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(stream0
), stream0
);
11851 vb
[1] = create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(stream1
), stream1
);
11853 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
11854 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
11855 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
11856 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
11858 stride
= sizeof(*stream0
);
11859 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
[0], &stride
, &offset
);
11860 stride
= sizeof(*stream1
);
11861 ID3D11DeviceContext_IASetVertexBuffers(context
, 1, 1, &vb
[1], &stride
, &offset
);
11863 ID3D11DeviceContext_ClearRenderTargetView(context
, rtvs
[0], white
);
11864 ID3D11DeviceContext_ClearRenderTargetView(context
, rtvs
[1], white
);
11866 ID3D11DeviceContext_OMSetRenderTargets(context
, ARRAY_SIZE(rtvs
), rtvs
, NULL
);
11867 ID3D11DeviceContext_DrawInstanced(context
, 4, 4, 0, 0);
11868 ID3D11DeviceContext_DrawInstanced(context
, 4, 4, 0, 4);
11870 args_buffer
= create_buffer_misc(device
, 0, D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS
,
11871 sizeof(argument_data
), argument_data
);
11873 ID3D11DeviceContext_DrawInstancedIndirect(context
, args_buffer
, 0);
11874 ID3D11DeviceContext_DrawInstancedIndirect(context
, args_buffer
, sizeof(*argument_data
));
11876 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
11877 for (i
= 0; i
< ARRAY_SIZE(expected_results
); ++i
)
11878 check_readback_data_color(&rb
, &expected_results
[i
].rect
, expected_results
[i
].color
, 1);
11879 release_resource_readback(&rb
);
11881 get_texture_readback(render_target
, 0, &rb
);
11882 for (i
= 0; i
< ARRAY_SIZE(expected_results
); ++i
)
11883 check_readback_data_color(&rb
, &expected_results
[i
].rect
, expected_results
[i
].instance_id
, 0);
11884 release_resource_readback(&rb
);
11886 ID3D11Buffer_Release(vb
[0]);
11887 ID3D11Buffer_Release(vb
[1]);
11888 ID3D11Buffer_Release(args_buffer
);
11889 ID3D11RenderTargetView_Release(rtvs
[1]);
11890 ID3D11Texture2D_Release(render_target
);
11891 ID3D11VertexShader_Release(vs
);
11892 ID3D11PixelShader_Release(ps
);
11893 ID3D11InputLayout_Release(input_layout
);
11894 release_test_context(&test_context
);
11897 static void test_vertex_id(void)
11899 static const DWORD vs_code
[] =
11902 uint4
main(uint id
: ID
, uint instance_id
: SV_InstanceID
, uint vertex_id
: SV_VertexID
) : OUTPUT
11904 return uint4(id
, instance_id
, vertex_id
, 0);
11907 0x43425844, 0x5625197b, 0x588ccf8f, 0x48694905, 0x961d19ca, 0x00000001, 0x00000170, 0x00000003,
11908 0x0000002c, 0x000000a4, 0x000000d4, 0x4e475349, 0x00000070, 0x00000003, 0x00000008, 0x00000050,
11909 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000101, 0x00000053, 0x00000000, 0x00000008,
11910 0x00000001, 0x00000001, 0x00000101, 0x00000061, 0x00000000, 0x00000006, 0x00000001, 0x00000002,
11911 0x00000101, 0x53004449, 0x6e495f56, 0x6e617473, 0x44496563, 0x5f565300, 0x74726556, 0x44497865,
11912 0xababab00, 0x4e47534f, 0x00000028, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
11913 0x00000001, 0x00000000, 0x0000000f, 0x5054554f, 0xab005455, 0x52444853, 0x00000094, 0x00010040,
11914 0x00000025, 0x0300005f, 0x00101012, 0x00000000, 0x04000060, 0x00101012, 0x00000001, 0x00000008,
11915 0x04000060, 0x00101012, 0x00000002, 0x00000006, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
11916 0x00102012, 0x00000000, 0x0010100a, 0x00000000, 0x05000036, 0x00102022, 0x00000000, 0x0010100a,
11917 0x00000001, 0x05000036, 0x00102042, 0x00000000, 0x0010100a, 0x00000002, 0x05000036, 0x00102082,
11918 0x00000000, 0x00004001, 0x00000000, 0x0100003e,
11920 D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
11922 {"ID", 0, DXGI_FORMAT_R32_UINT
, 0, D3D11_APPEND_ALIGNED_ELEMENT
, D3D11_INPUT_PER_VERTEX_DATA
, 0},
11924 static const D3D11_SO_DECLARATION_ENTRY so_declaration
[] =
11926 {0, "OUTPUT", 0, 0, 4, 0},
11928 static const unsigned int vertices
[] =
11946 static const unsigned int indices
[] =
11952 struct uvec4 expected_values
[] =
11977 BOOL found_values
[ARRAY_SIZE(expected_values
)] = {0};
11978 BOOL used_values
[ARRAY_SIZE(expected_values
)] = {0};
11979 struct d3d11_test_context test_context
;
11980 D3D11_QUERY_DATA_SO_STATISTICS data
;
11981 ID3D11Buffer
*vb
, *ib
, *so_buffer
;
11982 ID3D11InputLayout
*input_layout
;
11983 ID3D11DeviceContext
*context
;
11984 D3D11_QUERY_DESC query_desc
;
11985 struct resource_readback rb
;
11986 unsigned int stride
, offset
;
11987 ID3D11Asynchronous
*query
;
11988 ID3D11GeometryShader
*gs
;
11989 ID3D11VertexShader
*vs
;
11990 ID3D11Device
*device
;
11991 unsigned int count
;
11995 if (!init_test_context(&test_context
, NULL
))
11997 device
= test_context
.device
;
11998 context
= test_context
.immediate_context
;
12000 query_desc
.Query
= D3D11_QUERY_SO_STATISTICS
;
12001 query_desc
.MiscFlags
= 0;
12002 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, (ID3D11Query
**)&query
);
12003 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
12005 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
12006 vs_code
, sizeof(vs_code
), &input_layout
);
12007 ok(hr
== S_OK
, "Failed to create input layout, hr %#x.\n", hr
);
12009 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
12010 ok(hr
== S_OK
, "Failed to create vertex shader, hr %#x.\n", hr
);
12013 hr
= ID3D11Device_CreateGeometryShaderWithStreamOutput(device
, vs_code
, sizeof(vs_code
),
12014 so_declaration
, ARRAY_SIZE(so_declaration
), &stride
, 1, 0, NULL
, &gs
);
12015 ok(hr
== S_OK
, "Failed to create geometry shader with stream output, hr %#x.\n", hr
);
12017 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(vertices
), vertices
);
12018 ib
= create_buffer(device
, D3D11_BIND_INDEX_BUFFER
, sizeof(indices
), indices
);
12019 so_buffer
= create_buffer(device
, D3D11_BIND_STREAM_OUTPUT
, 1024, NULL
);
12021 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
12022 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
12023 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
12024 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST
);
12025 ID3D11DeviceContext_IASetIndexBuffer(context
, ib
, DXGI_FORMAT_R32_UINT
, 0);
12027 stride
= sizeof(*vertices
);
12028 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, &stride
, &offset
);
12031 ID3D11DeviceContext_SOSetTargets(context
, 1, &so_buffer
, &offset
);
12033 ID3D11DeviceContext_Begin(context
, query
);
12035 ID3D11DeviceContext_DrawInstanced(context
, 3, 2, 0, 0);
12036 ID3D11DeviceContext_DrawInstanced(context
, 3, 1, 3, 16);
12038 ID3D11DeviceContext_DrawIndexedInstanced(context
, 3, 2, 0, 0, 0);
12039 ID3D11DeviceContext_DrawIndexedInstanced(context
, 3, 1, 3, 9, 7);
12041 ID3D11DeviceContext_End(context
, query
);
12043 get_query_data(context
, query
, &data
, sizeof(data
));
12044 count
= data
.NumPrimitivesWritten
;
12045 ok(count
== ARRAY_SIZE(expected_values
), "Got unexpected value %u.\n", count
);
12047 count
= min(count
, ARRAY_SIZE(used_values
));
12048 get_buffer_readback(so_buffer
, &rb
);
12049 for (i
= 0; i
< ARRAY_SIZE(expected_values
); ++i
)
12051 for (j
= 0; j
< count
; ++j
)
12053 if (!used_values
[j
] && compare_uvec4(get_readback_uvec4(&rb
, j
, 0), &expected_values
[i
]))
12055 found_values
[i
] = TRUE
;
12056 used_values
[j
] = TRUE
;
12062 for (i
= 0; i
< count
; ++i
)
12064 const struct uvec4
*v
= get_readback_uvec4(&rb
, i
, 0);
12065 ok(used_values
[i
], "Found unexpected value {0x%08x, 0x%08x, 0x%08x, 0x%08x}.\n", v
->x
, v
->y
, v
->z
, v
->w
);
12067 release_resource_readback(&rb
);
12069 for (i
= 0; i
< ARRAY_SIZE(expected_values
); ++i
)
12071 ok(found_values
[i
], "Failed to find value {0x%08x, 0x%08x, 0x%08x, 0x%08x}.\n",
12072 expected_values
[i
].x
, expected_values
[i
].y
, expected_values
[i
].z
, expected_values
[i
].w
);
12075 ID3D11Asynchronous_Release(query
);
12076 ID3D11Buffer_Release(so_buffer
);
12077 ID3D11Buffer_Release(vb
);
12078 ID3D11Buffer_Release(ib
);
12079 ID3D11GeometryShader_Release(gs
);
12080 ID3D11VertexShader_Release(vs
);
12081 ID3D11InputLayout_Release(input_layout
);
12082 release_test_context(&test_context
);
12085 static void test_fragment_coords(void)
12087 struct d3d11_test_context test_context
;
12088 ID3D11PixelShader
*ps
, *ps_frac
;
12089 ID3D11DeviceContext
*context
;
12090 ID3D11Device
*device
;
12091 ID3D11Buffer
*ps_cb
;
12095 static const DWORD ps_code
[] =
12100 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
12102 float4 ret
= float4(0.0, 0.0, 0.0, 1.0);
12104 if (position
.x
> cutoff
.x
)
12106 if (position
.y
> cutoff
.y
)
12112 0x43425844, 0x49fc9e51, 0x8068867d, 0xf20cfa39, 0xb8099e6b, 0x00000001, 0x00000144, 0x00000003,
12113 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
12114 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
12115 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
12116 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000a8, 0x00000040,
12117 0x0000002a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04002064, 0x00101032, 0x00000000,
12118 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x08000031, 0x00100032,
12119 0x00000000, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000000, 0x0a000001, 0x00102062,
12120 0x00000000, 0x00100106, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x3f800000, 0x00000000,
12121 0x08000036, 0x00102092, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x3f800000,
12124 static const DWORD ps_frac_code
[] =
12127 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
12129 return float4(frac(position
.xy
), 0.0, 1.0);
12132 0x43425844, 0x86d9d78a, 0x190b72c2, 0x50841fd6, 0xdc24022e, 0x00000001, 0x000000f8, 0x00000003,
12133 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
12134 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
12135 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
12136 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x0000005c, 0x00000040,
12137 0x00000017, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
12138 0x0500001a, 0x00102032, 0x00000000, 0x00101046, 0x00000000, 0x08000036, 0x001020c2, 0x00000000,
12139 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e,
12141 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
12142 struct vec4 cutoff
= {320.0f
, 240.0f
, 0.0f
, 0.0f
};
12144 if (!init_test_context(&test_context
, NULL
))
12147 device
= test_context
.device
;
12148 context
= test_context
.immediate_context
;
12150 ps_cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(cutoff
), &cutoff
);
12152 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
12153 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
12154 hr
= ID3D11Device_CreatePixelShader(device
, ps_frac_code
, sizeof(ps_frac_code
), NULL
, &ps_frac
);
12155 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
12157 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &ps_cb
);
12158 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
12160 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
12162 draw_quad(&test_context
);
12164 color
= get_texture_color(test_context
.backbuffer
, 319, 239);
12165 ok(compare_color(color
, 0xff000000, 1), "Got unexpected color 0x%08x.\n", color
);
12166 color
= get_texture_color(test_context
.backbuffer
, 320, 239);
12167 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
12168 color
= get_texture_color(test_context
.backbuffer
, 319, 240);
12169 ok(compare_color(color
, 0xffff0000, 1), "Got unexpected color 0x%08x.\n", color
);
12170 color
= get_texture_color(test_context
.backbuffer
, 320, 240);
12171 ok(compare_color(color
, 0xffffff00, 1), "Got unexpected color 0x%08x.\n", color
);
12173 ID3D11Buffer_Release(ps_cb
);
12176 ps_cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(cutoff
), &cutoff
);
12177 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &ps_cb
);
12179 draw_quad(&test_context
);
12181 color
= get_texture_color(test_context
.backbuffer
, 14, 14);
12182 ok(compare_color(color
, 0xff000000, 1), "Got unexpected color 0x%08x.\n", color
);
12183 color
= get_texture_color(test_context
.backbuffer
, 18, 14);
12184 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
12185 color
= get_texture_color(test_context
.backbuffer
, 14, 18);
12186 ok(compare_color(color
, 0xffff0000, 1), "Got unexpected color 0x%08x.\n", color
);
12187 color
= get_texture_color(test_context
.backbuffer
, 18, 18);
12188 ok(compare_color(color
, 0xffffff00, 1), "Got unexpected color 0x%08x.\n", color
);
12190 ID3D11DeviceContext_PSSetShader(context
, ps_frac
, NULL
, 0);
12191 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
12193 ID3D11DeviceContext_Draw(context
, 4, 0);
12195 color
= get_texture_color(test_context
.backbuffer
, 14, 14);
12196 ok(compare_color(color
, 0xff008080, 1), "Got unexpected color 0x%08x.\n", color
);
12198 ID3D11Buffer_Release(ps_cb
);
12199 ID3D11PixelShader_Release(ps_frac
);
12200 ID3D11PixelShader_Release(ps
);
12201 release_test_context(&test_context
);
12204 static void test_initial_texture_data(void)
12206 ID3D11Texture2D
*texture
, *staging_texture
;
12207 struct d3d11_test_context test_context
;
12208 D3D11_SUBRESOURCE_DATA resource_data
;
12209 D3D11_TEXTURE2D_DESC texture_desc
;
12210 ID3D11SamplerState
*sampler_state
;
12211 ID3D11ShaderResourceView
*ps_srv
;
12212 D3D11_SAMPLER_DESC sampler_desc
;
12213 ID3D11DeviceContext
*context
;
12214 struct resource_readback rb
;
12215 ID3D11PixelShader
*ps
;
12216 ID3D11Device
*device
;
12221 static const DWORD ps_code
[] =
12227 float4
main(float4 position
: SV_POSITION
) : SV_Target
12231 p
.x
= position
.x
/ 640.0f
;
12232 p
.y
= position
.y
/ 480.0f
;
12233 return t
.Sample(s
, p
);
12236 0x43425844, 0x1ce9b612, 0xc8176faa, 0xd37844af, 0xdb515605, 0x00000001, 0x00000134, 0x00000003,
12237 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
12238 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
12239 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
12240 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
12241 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
12242 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
12243 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
12244 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
12245 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
12247 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
12248 static const DWORD bitmap_data
[] =
12250 0xffffffff, 0xff000000, 0xffffffff, 0xff000000,
12251 0xff00ff00, 0xff0000ff, 0xff00ffff, 0x00000000,
12252 0xffffff00, 0xffff0000, 0xffff00ff, 0x00000000,
12253 0xff000000, 0xff7f7f7f, 0xffffffff, 0x00000000,
12256 if (!init_test_context(&test_context
, NULL
))
12259 device
= test_context
.device
;
12260 context
= test_context
.immediate_context
;
12262 texture_desc
.Width
= 4;
12263 texture_desc
.Height
= 4;
12264 texture_desc
.MipLevels
= 1;
12265 texture_desc
.ArraySize
= 1;
12266 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
12267 texture_desc
.SampleDesc
.Count
= 1;
12268 texture_desc
.SampleDesc
.Quality
= 0;
12269 texture_desc
.Usage
= D3D11_USAGE_STAGING
;
12270 texture_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_WRITE
;
12271 texture_desc
.BindFlags
= 0;
12272 texture_desc
.MiscFlags
= 0;
12274 resource_data
.pSysMem
= bitmap_data
;
12275 resource_data
.SysMemPitch
= texture_desc
.Width
* sizeof(*bitmap_data
);
12276 resource_data
.SysMemSlicePitch
= 0;
12278 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &staging_texture
);
12279 ok(hr
== S_OK
, "Failed to create 2d texture, hr %#x.\n", hr
);
12281 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
12282 texture_desc
.CPUAccessFlags
= 0;
12283 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
12284 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
12285 ok(hr
== S_OK
, "Failed to create 2d texture, hr %#x.\n", hr
);
12287 ID3D11DeviceContext_CopyResource(context
, (ID3D11Resource
*)texture
, (ID3D11Resource
*)staging_texture
);
12289 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &ps_srv
);
12290 ok(hr
== S_OK
, "Failed to create shader resource view, hr %#x.\n", hr
);
12292 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
12293 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
12294 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
12295 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
12296 sampler_desc
.MipLODBias
= 0.0f
;
12297 sampler_desc
.MaxAnisotropy
= 0;
12298 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
12299 sampler_desc
.BorderColor
[0] = 0.0f
;
12300 sampler_desc
.BorderColor
[1] = 0.0f
;
12301 sampler_desc
.BorderColor
[2] = 0.0f
;
12302 sampler_desc
.BorderColor
[3] = 0.0f
;
12303 sampler_desc
.MinLOD
= 0.0f
;
12304 sampler_desc
.MaxLOD
= 0.0f
;
12305 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler_state
);
12306 ok(hr
== S_OK
, "Failed to create sampler state, hr %#x.\n", hr
);
12308 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
12309 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
12311 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &ps_srv
);
12312 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler_state
);
12313 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
12315 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
12316 draw_quad(&test_context
);
12317 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
12318 for (i
= 0; i
< 4; ++i
)
12320 for (j
= 0; j
< 4; ++j
)
12322 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120, 0);
12323 ok(compare_color(color
, bitmap_data
[j
+ i
* 4], 1),
12324 "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
12325 color
, j
, i
, bitmap_data
[j
+ i
* 4]);
12328 release_resource_readback(&rb
);
12330 ID3D11PixelShader_Release(ps
);
12331 ID3D11SamplerState_Release(sampler_state
);
12332 ID3D11ShaderResourceView_Release(ps_srv
);
12333 ID3D11Texture2D_Release(staging_texture
);
12334 ID3D11Texture2D_Release(texture
);
12335 release_test_context(&test_context
);
12338 static void test_update_subresource(void)
12340 struct d3d11_test_context test_context
;
12341 D3D11_SUBRESOURCE_DATA resource_data
;
12342 D3D11_TEXTURE2D_DESC texture_desc
;
12343 ID3D11SamplerState
*sampler_state
;
12344 ID3D11ShaderResourceView
*ps_srv
;
12345 D3D11_SAMPLER_DESC sampler_desc
;
12346 ID3D11DeviceContext
*context
;
12347 struct resource_readback rb
;
12348 ID3D11Texture2D
*texture
;
12349 ID3D11PixelShader
*ps
;
12350 ID3D11Device
*device
;
12356 static const DWORD ps_code
[] =
12362 float4
main(float4 position
: SV_POSITION
) : SV_Target
12366 p
.x
= position
.x
/ 640.0f
;
12367 p
.y
= position
.y
/ 480.0f
;
12368 return t
.Sample(s
, p
);
12371 0x43425844, 0x1ce9b612, 0xc8176faa, 0xd37844af, 0xdb515605, 0x00000001, 0x00000134, 0x00000003,
12372 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
12373 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
12374 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
12375 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
12376 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
12377 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
12378 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
12379 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
12380 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
12382 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
12383 static const DWORD initial_data
[16] = {0};
12384 static const DWORD bitmap_data
[] =
12386 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
12387 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
12388 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
12389 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
12391 static const DWORD expected_colors
[] =
12393 0xffffffff, 0xff000000, 0xffffffff, 0xff000000,
12394 0xff00ff00, 0xff0000ff, 0xff00ffff, 0x00000000,
12395 0xffffff00, 0xffff0000, 0xffff00ff, 0x00000000,
12396 0xff000000, 0xff7f7f7f, 0xffffffff, 0x00000000,
12399 if (!init_test_context(&test_context
, NULL
))
12402 device
= test_context
.device
;
12403 context
= test_context
.immediate_context
;
12405 texture_desc
.Width
= 4;
12406 texture_desc
.Height
= 4;
12407 texture_desc
.MipLevels
= 1;
12408 texture_desc
.ArraySize
= 1;
12409 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
12410 texture_desc
.SampleDesc
.Count
= 1;
12411 texture_desc
.SampleDesc
.Quality
= 0;
12412 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
12413 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
12414 texture_desc
.CPUAccessFlags
= 0;
12415 texture_desc
.MiscFlags
= 0;
12417 resource_data
.pSysMem
= initial_data
;
12418 resource_data
.SysMemPitch
= texture_desc
.Width
* sizeof(*initial_data
);
12419 resource_data
.SysMemSlicePitch
= 0;
12421 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &texture
);
12422 ok(SUCCEEDED(hr
), "Failed to create 2d texture, hr %#x.\n", hr
);
12424 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &ps_srv
);
12425 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
12427 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
12428 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
12429 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
12430 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
12431 sampler_desc
.MipLODBias
= 0.0f
;
12432 sampler_desc
.MaxAnisotropy
= 0;
12433 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
12434 sampler_desc
.BorderColor
[0] = 0.0f
;
12435 sampler_desc
.BorderColor
[1] = 0.0f
;
12436 sampler_desc
.BorderColor
[2] = 0.0f
;
12437 sampler_desc
.BorderColor
[3] = 0.0f
;
12438 sampler_desc
.MinLOD
= 0.0f
;
12439 sampler_desc
.MaxLOD
= 0.0f
;
12441 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler_state
);
12442 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
12444 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
12445 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
12447 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &ps_srv
);
12448 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler_state
);
12449 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
12451 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
12452 check_texture_color(test_context
.backbuffer
, 0x7f0000ff, 1);
12454 draw_quad(&test_context
);
12455 check_texture_color(test_context
.backbuffer
, 0x00000000, 0);
12457 set_box(&box
, 1, 1, 0, 3, 3, 1);
12458 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture
, 0, &box
,
12459 bitmap_data
, 4 * sizeof(*bitmap_data
), 0);
12460 set_box(&box
, 0, 3, 0, 3, 4, 1);
12461 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture
, 0, &box
,
12462 &bitmap_data
[6], 4 * sizeof(*bitmap_data
), 0);
12463 set_box(&box
, 0, 0, 0, 4, 1, 1);
12464 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture
, 0, &box
,
12465 &bitmap_data
[10], 4 * sizeof(*bitmap_data
), 0);
12466 set_box(&box
, 0, 1, 0, 1, 3, 1);
12467 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture
, 0, &box
,
12468 &bitmap_data
[2], sizeof(*bitmap_data
), 0);
12469 set_box(&box
, 4, 4, 0, 3, 1, 1);
12470 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture
, 0, &box
,
12471 bitmap_data
, sizeof(*bitmap_data
), 0);
12472 set_box(&box
, 0, 0, 0, 4, 4, 0);
12473 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture
, 0, &box
,
12474 bitmap_data
, 4 * sizeof(*bitmap_data
), 0);
12475 draw_quad(&test_context
);
12476 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
12477 for (i
= 0; i
< 4; ++i
)
12479 for (j
= 0; j
< 4; ++j
)
12481 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120, 0);
12482 ok(compare_color(color
, expected_colors
[j
+ i
* 4], 1),
12483 "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
12484 color
, j
, i
, expected_colors
[j
+ i
* 4]);
12487 release_resource_readback(&rb
);
12489 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture
, 0, NULL
,
12490 bitmap_data
, 4 * sizeof(*bitmap_data
), 0);
12491 draw_quad(&test_context
);
12492 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
12493 for (i
= 0; i
< 4; ++i
)
12495 for (j
= 0; j
< 4; ++j
)
12497 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120, 0);
12498 ok(compare_color(color
, bitmap_data
[j
+ i
* 4], 1),
12499 "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
12500 color
, j
, i
, bitmap_data
[j
+ i
* 4]);
12503 release_resource_readback(&rb
);
12505 ID3D11PixelShader_Release(ps
);
12506 ID3D11SamplerState_Release(sampler_state
);
12507 ID3D11ShaderResourceView_Release(ps_srv
);
12508 ID3D11Texture2D_Release(texture
);
12509 release_test_context(&test_context
);
12512 static void test_copy_subresource_region(void)
12514 ID3D11Texture2D
*dst_texture
, *src_texture
;
12515 struct d3d11_test_context test_context
;
12516 ID3D11Buffer
*dst_buffer
, *src_buffer
;
12517 D3D11_SUBRESOURCE_DATA resource_data
;
12518 D3D11_TEXTURE2D_DESC texture_desc
;
12519 ID3D11SamplerState
*sampler_state
;
12520 ID3D11ShaderResourceView
*ps_srv
;
12521 D3D11_SAMPLER_DESC sampler_desc
;
12522 ID3D11DeviceContext1
*context1
;
12523 ID3D11DeviceContext
*context
;
12524 struct vec4 float_colors
[16];
12525 struct resource_readback rb
;
12526 ID3D11PixelShader
*ps
;
12527 ID3D11Device
*device
;
12533 static const DWORD ps_code
[] =
12539 float4
main(float4 position
: SV_POSITION
) : SV_Target
12543 p
.x
= position
.x
/ 640.0f
;
12544 p
.y
= position
.y
/ 480.0f
;
12545 return t
.Sample(s
, p
);
12548 0x43425844, 0x1ce9b612, 0xc8176faa, 0xd37844af, 0xdb515605, 0x00000001, 0x00000134, 0x00000003,
12549 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
12550 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
12551 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
12552 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
12553 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
12554 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
12555 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
12556 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
12557 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
12559 static const DWORD ps_buffer_code
[] =
12564 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
12566 float2 p
= (float2
)4;
12567 p
*= float2(position
.x
/ 640.0f
, position
.y
/ 480.0f
);
12568 return buffer
[(int)p
.y
* 4 + (int)p
.x
];
12571 0x43425844, 0x57e7139f, 0x4f0c9e52, 0x598b77e3, 0x5a239132, 0x00000001, 0x0000016c, 0x00000003,
12572 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
12573 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
12574 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
12575 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000d0, 0x00000040,
12576 0x00000034, 0x04000859, 0x00208e46, 0x00000000, 0x00000010, 0x04002064, 0x00101032, 0x00000000,
12577 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0a000038, 0x00100032,
12578 0x00000000, 0x00101516, 0x00000000, 0x00004002, 0x3c088889, 0x3bcccccd, 0x00000000, 0x00000000,
12579 0x0500001b, 0x00100032, 0x00000000, 0x00100046, 0x00000000, 0x07000029, 0x00100012, 0x00000000,
12580 0x0010000a, 0x00000000, 0x00004001, 0x00000002, 0x0700001e, 0x00100012, 0x00000000, 0x0010000a,
12581 0x00000000, 0x0010001a, 0x00000000, 0x07000036, 0x001020f2, 0x00000000, 0x04208e46, 0x00000000,
12582 0x0010000a, 0x00000000, 0x0100003e,
12584 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
12585 static const DWORD initial_data
[16] = {0};
12586 static const DWORD bitmap_data
[] =
12588 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
12589 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
12590 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
12591 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
12593 static const DWORD expected_colors
[] =
12595 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
12596 0xffffff00, 0xff0000ff, 0xff00ffff, 0x00000000,
12597 0xff7f7f7f, 0xffff0000, 0xffff00ff, 0xff7f7f7f,
12598 0xffffffff, 0xffffffff, 0xff000000, 0x00000000,
12601 if (!init_test_context(&test_context
, NULL
))
12604 device
= test_context
.device
;
12605 context
= test_context
.immediate_context
;
12607 texture_desc
.Width
= 4;
12608 texture_desc
.Height
= 4;
12609 texture_desc
.MipLevels
= 1;
12610 texture_desc
.ArraySize
= 1;
12611 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
12612 texture_desc
.SampleDesc
.Count
= 1;
12613 texture_desc
.SampleDesc
.Quality
= 0;
12614 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
12615 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
12616 texture_desc
.CPUAccessFlags
= 0;
12617 texture_desc
.MiscFlags
= 0;
12619 resource_data
.pSysMem
= initial_data
;
12620 resource_data
.SysMemPitch
= texture_desc
.Width
* sizeof(*initial_data
);
12621 resource_data
.SysMemSlicePitch
= 0;
12623 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &dst_texture
);
12624 ok(SUCCEEDED(hr
), "Failed to create 2d texture, hr %#x.\n", hr
);
12626 texture_desc
.Usage
= D3D11_USAGE_IMMUTABLE
;
12628 resource_data
.pSysMem
= bitmap_data
;
12629 resource_data
.SysMemPitch
= texture_desc
.Width
* sizeof(*bitmap_data
);
12630 resource_data
.SysMemSlicePitch
= 0;
12632 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &src_texture
);
12633 ok(SUCCEEDED(hr
), "Failed to create 2d texture, hr %#x.\n", hr
);
12635 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)dst_texture
, NULL
, &ps_srv
);
12636 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
12638 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
12639 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
12640 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
12641 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
12642 sampler_desc
.MipLODBias
= 0.0f
;
12643 sampler_desc
.MaxAnisotropy
= 0;
12644 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
12645 sampler_desc
.BorderColor
[0] = 0.0f
;
12646 sampler_desc
.BorderColor
[1] = 0.0f
;
12647 sampler_desc
.BorderColor
[2] = 0.0f
;
12648 sampler_desc
.BorderColor
[3] = 0.0f
;
12649 sampler_desc
.MinLOD
= 0.0f
;
12650 sampler_desc
.MaxLOD
= 0.0f
;
12652 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler_state
);
12653 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
12655 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
12656 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
12658 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &ps_srv
);
12659 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler_state
);
12660 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
12662 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
12664 set_box(&box
, 0, 0, 0, 2, 2, 1);
12665 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
12666 1, 1, 0, (ID3D11Resource
*)src_texture
, 0, &box
);
12667 set_box(&box
, 1, 2, 0, 4, 3, 1);
12668 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
12669 0, 3, 0, (ID3D11Resource
*)src_texture
, 0, &box
);
12670 set_box(&box
, 0, 3, 0, 4, 4, 1);
12671 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
12672 0, 0, 0, (ID3D11Resource
*)src_texture
, 0, &box
);
12673 set_box(&box
, 3, 0, 0, 4, 2, 1);
12674 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
12675 0, 1, 0, (ID3D11Resource
*)src_texture
, 0, &box
);
12676 set_box(&box
, 3, 1, 0, 4, 2, 1);
12677 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
12678 3, 2, 0, (ID3D11Resource
*)src_texture
, 0, &box
);
12679 set_box(&box
, 0, 0, 0, 4, 4, 0);
12680 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
12681 0, 0, 0, (ID3D11Resource
*)src_texture
, 0, &box
);
12682 draw_quad(&test_context
);
12683 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
12684 for (i
= 0; i
< 4; ++i
)
12686 for (j
= 0; j
< 4; ++j
)
12688 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120, 0);
12689 ok(compare_color(color
, expected_colors
[j
+ i
* 4], 1),
12690 "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
12691 color
, j
, i
, expected_colors
[j
+ i
* 4]);
12694 release_resource_readback(&rb
);
12696 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
12697 0, 0, 0, (ID3D11Resource
*)src_texture
, 0, NULL
);
12698 draw_quad(&test_context
);
12699 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
12700 for (i
= 0; i
< 4; ++i
)
12702 for (j
= 0; j
< 4; ++j
)
12704 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120, 0);
12705 ok(compare_color(color
, bitmap_data
[j
+ i
* 4], 1),
12706 "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
12707 color
, j
, i
, bitmap_data
[j
+ i
* 4]);
12710 release_resource_readback(&rb
);
12712 hr
= ID3D11DeviceContext_QueryInterface(context
, &IID_ID3D11DeviceContext1
, (void **)&context1
);
12713 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
12714 "Failed to query ID3D11DeviceContext1, hr %#x.\n", hr
);
12718 ID3D11DeviceContext1_ClearRenderTargetView(context1
, test_context
.backbuffer_rtv
, red
);
12719 check_texture_color(test_context
.backbuffer
, 0x800000ff, 2);
12721 memset(float_colors
, 0, sizeof(float_colors
));
12722 for (i
= 0; i
< texture_desc
.Width
; ++i
)
12723 ((unsigned int *)float_colors
)[i
] = 0x45454545;
12725 ID3D11DeviceContext1_UpdateSubresource1(context1
, (ID3D11Resource
*)dst_texture
, 0, NULL
,
12726 float_colors
, 0, 0, 0);
12727 draw_quad(&test_context
);
12728 check_texture_color(test_context
.backbuffer
, 0x45454545, 1);
12730 ID3D11DeviceContext1_CopySubresourceRegion1(context1
, (ID3D11Resource
*)dst_texture
, 0,
12731 0, 0, 0, (ID3D11Resource
*)src_texture
, 0, NULL
, 0);
12732 draw_quad(&test_context
);
12734 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
12735 for (i
= 0; i
< 4; ++i
)
12737 for (j
= 0; j
< 4; ++j
)
12739 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120, 0);
12740 ok(compare_color(color
, bitmap_data
[j
+ i
* 4], 1),
12741 "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
12742 color
, j
, i
, bitmap_data
[j
+ i
* 4]);
12745 release_resource_readback(&rb
);
12747 ID3D11DeviceContext1_Release(context1
);
12751 ID3D11PixelShader_Release(ps
);
12752 hr
= ID3D11Device_CreatePixelShader(device
, ps_buffer_code
, sizeof(ps_buffer_code
), NULL
, &ps
);
12753 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
12755 ID3D11ShaderResourceView_Release(ps_srv
);
12758 ID3D11SamplerState_Release(sampler_state
);
12759 sampler_state
= NULL
;
12761 ID3D11Texture2D_Release(dst_texture
);
12762 ID3D11Texture2D_Release(src_texture
);
12764 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &ps_srv
);
12765 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler_state
);
12766 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
12768 memset(float_colors
, 0, sizeof(float_colors
));
12769 dst_buffer
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(float_colors
), float_colors
);
12770 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &dst_buffer
);
12772 src_buffer
= create_buffer(device
, 0, 256 * sizeof(*float_colors
), NULL
);
12774 for (i
= 0; i
< 4; ++i
)
12776 for (j
= 0; j
< 4; ++j
)
12778 float_colors
[j
+ i
* 4].x
= ((bitmap_data
[j
+ i
* 4] >> 0) & 0xff) / 255.0f
;
12779 float_colors
[j
+ i
* 4].y
= ((bitmap_data
[j
+ i
* 4] >> 8) & 0xff) / 255.0f
;
12780 float_colors
[j
+ i
* 4].z
= ((bitmap_data
[j
+ i
* 4] >> 16) & 0xff) / 255.0f
;
12781 float_colors
[j
+ i
* 4].w
= ((bitmap_data
[j
+ i
* 4] >> 24) & 0xff) / 255.0f
;
12784 set_box(&box
, 0, 0, 0, sizeof(float_colors
), 1, 1);
12785 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)src_buffer
, 0, &box
, float_colors
, 0, 0);
12787 set_box(&box
, 0, 0, 0, sizeof(float_colors
), 0, 1);
12788 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_buffer
, 0,
12789 0, 0, 0, (ID3D11Resource
*)src_buffer
, 0, &box
);
12790 draw_quad(&test_context
);
12791 check_texture_color(test_context
.backbuffer
, 0x00000000, 0);
12793 set_box(&box
, 0, 0, 0, sizeof(float_colors
), 1, 0);
12794 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_buffer
, 0,
12795 0, 0, 0, (ID3D11Resource
*)src_buffer
, 0, &box
);
12796 draw_quad(&test_context
);
12797 check_texture_color(test_context
.backbuffer
, 0x00000000, 0);
12799 set_box(&box
, 0, 0, 0, sizeof(float_colors
), 0, 0);
12800 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_buffer
, 0,
12801 0, 0, 0, (ID3D11Resource
*)src_buffer
, 0, &box
);
12802 draw_quad(&test_context
);
12803 check_texture_color(test_context
.backbuffer
, 0x00000000, 0);
12805 set_box(&box
, 0, 0, 0, sizeof(float_colors
), 1, 1);
12806 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_buffer
, 0,
12807 0, 0, 0, (ID3D11Resource
*)src_buffer
, 0, &box
);
12808 draw_quad(&test_context
);
12809 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
12810 for (i
= 0; i
< 4; ++i
)
12812 for (j
= 0; j
< 4; ++j
)
12814 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120, 0);
12815 ok(compare_color(color
, bitmap_data
[j
+ i
* 4], 1),
12816 "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
12817 color
, j
, i
, bitmap_data
[j
+ i
* 4]);
12820 release_resource_readback(&rb
);
12822 ID3D11Buffer_Release(dst_buffer
);
12823 ID3D11Buffer_Release(src_buffer
);
12824 ID3D11PixelShader_Release(ps
);
12825 release_test_context(&test_context
);
12828 static void test_copy_subresource_region_1d(void)
12830 D3D11_SUBRESOURCE_DATA resource_data
[4];
12831 struct d3d11_test_context test_context
;
12832 D3D11_TEXTURE1D_DESC texture1d_desc
;
12833 D3D11_TEXTURE2D_DESC texture2d_desc
;
12834 ID3D11DeviceContext
*context
;
12835 struct resource_readback rb
;
12836 ID3D11Texture1D
*texture1d
;
12837 ID3D11Texture2D
*texture2d
;
12838 ID3D11Device
*device
;
12844 static const DWORD bitmap_data
[] =
12846 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
12847 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
12848 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
12849 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
12852 if (!init_test_context(&test_context
, NULL
))
12854 device
= test_context
.device
;
12855 context
= test_context
.immediate_context
;
12857 texture1d_desc
.Width
= 4;
12858 texture1d_desc
.MipLevels
= 1;
12859 texture1d_desc
.ArraySize
= 4;
12860 texture1d_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
12861 texture1d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
12862 texture1d_desc
.BindFlags
= 0;
12863 texture1d_desc
.CPUAccessFlags
= 0;
12864 texture1d_desc
.MiscFlags
= 0;
12866 for (i
= 0; i
< ARRAY_SIZE(resource_data
); ++i
)
12868 resource_data
[i
].pSysMem
= &bitmap_data
[4 * i
];
12869 resource_data
[i
].SysMemPitch
= texture1d_desc
.Width
* sizeof(bitmap_data
);
12870 resource_data
[i
].SysMemSlicePitch
= 0;
12873 hr
= ID3D11Device_CreateTexture1D(device
, &texture1d_desc
, resource_data
, &texture1d
);
12874 ok(hr
== S_OK
, "Failed to create 1d texture, hr %#x.\n", hr
);
12876 texture2d_desc
.Width
= 4;
12877 texture2d_desc
.Height
= 4;
12878 texture2d_desc
.MipLevels
= 1;
12879 texture2d_desc
.ArraySize
= 1;
12880 texture2d_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
12881 texture2d_desc
.SampleDesc
.Count
= 1;
12882 texture2d_desc
.SampleDesc
.Quality
= 0;
12883 texture2d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
12884 texture2d_desc
.BindFlags
= 0;
12885 texture2d_desc
.CPUAccessFlags
= 0;
12886 texture2d_desc
.MiscFlags
= 0;
12888 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, &texture2d
);
12889 ok(hr
== S_OK
, "Failed to create 2d texture, hr %#x.\n", hr
);
12891 set_box(&box
, 0, 0, 0, 4, 1, 1);
12892 for (i
= 0; i
< ARRAY_SIZE(resource_data
); ++i
)
12894 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)texture2d
, 0,
12895 0, i
, 0, (ID3D11Resource
*)texture1d
, i
, &box
);
12898 get_texture_readback(texture2d
, 0, &rb
);
12899 for (i
= 0; i
< 4; ++i
)
12901 for (j
= 0; j
< 4; ++j
)
12903 color
= get_readback_color(&rb
, j
, i
, 0);
12904 ok(compare_color(color
, bitmap_data
[j
+ i
* 4], 1),
12905 "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
12906 color
, j
, i
, bitmap_data
[j
+ i
* 4]);
12909 release_resource_readback(&rb
);
12911 get_texture1d_readback(texture1d
, 0, &rb
);
12912 for (i
= 0; i
< texture1d_desc
.Width
; ++i
)
12914 color
= get_readback_color(&rb
, i
, 0, 0);
12915 ok(compare_color(color
, bitmap_data
[i
], 1),
12916 "Got color 0x%08x at %u, expected 0x%08x.\n",
12917 color
, i
, bitmap_data
[i
]);
12919 release_resource_readback(&rb
);
12921 ID3D11Texture1D_Release(texture1d
);
12922 ID3D11Texture2D_Release(texture2d
);
12923 release_test_context(&test_context
);
12926 static void test_copy_subresource_region_3d(void)
12928 ID3D11ShaderResourceView
*dst_srv
, *src_srv
;
12929 ID3D11Texture3D
*dst_texture
, *src_texture
;
12930 D3D11_SUBRESOURCE_DATA resource_data
[4];
12931 struct d3d11_test_context test_context
;
12932 D3D11_TEXTURE2D_DESC texture2d_desc
;
12933 D3D11_TEXTURE3D_DESC texture3d_desc
;
12934 ID3D11SamplerState
*sampler_state
;
12935 D3D11_SAMPLER_DESC sampler_desc
;
12936 ID3D11DeviceContext
*context
;
12937 struct resource_readback rb
;
12938 ID3D11Texture2D
*texture2d
;
12939 ID3D11PixelShader
*ps
;
12940 ID3D11Device
*device
;
12947 static const DWORD ps_code
[] =
12953 float4
main(float4 position
: SV_POSITION
) : SV_Target
12955 return t
.Sample(s
, position
.xyz
/ float3(640, 480, 1));
12958 0x43425844, 0x27b15ae8, 0xbebf46f7, 0x6cd88d8d, 0x5118de51, 0x00000001, 0x00000134, 0x00000003,
12959 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
12960 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000070f, 0x505f5653, 0x5449534f, 0x004e4f49,
12961 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
12962 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
12963 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04002858, 0x00107000, 0x00000000, 0x00005555,
12964 0x04002064, 0x00101072, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
12965 0x00000001, 0x0a000038, 0x00100072, 0x00000000, 0x00101246, 0x00000000, 0x00004002, 0x3acccccd,
12966 0x3b088889, 0x3f800000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100246, 0x00000000,
12967 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
12969 static const DWORD bitmap_data
[] =
12971 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
12972 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
12973 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
12974 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
12977 if (!init_test_context(&test_context
, NULL
))
12979 device
= test_context
.device
;
12980 context
= test_context
.immediate_context
;
12982 texture3d_desc
.Width
= 4;
12983 texture3d_desc
.Height
= 4;
12984 texture3d_desc
.Depth
= 4;
12985 texture3d_desc
.MipLevels
= 1;
12986 texture3d_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
12987 texture3d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
12988 texture3d_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
12989 texture3d_desc
.CPUAccessFlags
= 0;
12990 texture3d_desc
.MiscFlags
= 0;
12992 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &src_texture
);
12993 ok(hr
== S_OK
, "Failed to create 3d texture, hr %#x.\n", hr
);
12994 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &dst_texture
);
12995 ok(hr
== S_OK
, "Failed to create 3d texture, hr %#x.\n", hr
);
12997 texture2d_desc
.Width
= 4;
12998 texture2d_desc
.Height
= 4;
12999 texture2d_desc
.MipLevels
= 1;
13000 texture2d_desc
.ArraySize
= 4;
13001 texture2d_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
13002 texture2d_desc
.SampleDesc
.Count
= 1;
13003 texture2d_desc
.SampleDesc
.Quality
= 0;
13004 texture2d_desc
.Usage
= D3D11_USAGE_IMMUTABLE
;
13005 texture2d_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
13006 texture2d_desc
.CPUAccessFlags
= 0;
13007 texture2d_desc
.MiscFlags
= 0;
13009 for (i
= 0; i
< ARRAY_SIZE(*data
); ++i
)
13011 data
[0][i
] = 0xff0000ff;
13012 data
[1][i
] = bitmap_data
[i
];
13013 data
[2][i
] = 0xff00ff00;
13014 data
[3][i
] = 0xffff00ff;
13017 for (i
= 0; i
< ARRAY_SIZE(resource_data
); ++i
)
13019 resource_data
[i
].pSysMem
= data
[i
];
13020 resource_data
[i
].SysMemPitch
= texture2d_desc
.Width
* sizeof(data
[0][0]);
13021 resource_data
[i
].SysMemSlicePitch
= 0;
13024 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, resource_data
, &texture2d
);
13025 ok(hr
== S_OK
, "Failed to create 2d texture, hr %#x.\n", hr
);
13027 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)src_texture
, NULL
, &src_srv
);
13028 ok(hr
== S_OK
, "Failed to create shader resource view, hr %#x.\n", hr
);
13029 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)dst_texture
, NULL
, &dst_srv
);
13030 ok(hr
== S_OK
, "Failed to create shader resource view, hr %#x.\n", hr
);
13032 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
13033 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
13034 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
13035 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
13036 sampler_desc
.MipLODBias
= 0.0f
;
13037 sampler_desc
.MaxAnisotropy
= 0;
13038 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
13039 sampler_desc
.BorderColor
[0] = 0.0f
;
13040 sampler_desc
.BorderColor
[1] = 0.0f
;
13041 sampler_desc
.BorderColor
[2] = 0.0f
;
13042 sampler_desc
.BorderColor
[3] = 0.0f
;
13043 sampler_desc
.MinLOD
= 0.0f
;
13044 sampler_desc
.MaxLOD
= 0.0f
;
13046 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler_state
);
13047 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
13049 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
13050 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
13052 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &src_srv
);
13053 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler_state
);
13054 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
13056 set_box(&box
, 0, 0, 0, 4, 4, 1);
13057 for (i
= 0; i
< ARRAY_SIZE(resource_data
); ++i
)
13059 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)src_texture
, 0,
13060 0, 0, i
, (ID3D11Resource
*)texture2d
, i
, &box
);
13062 draw_quad(&test_context
);
13063 check_texture_color(test_context
.backbuffer
, 0xff0000ff, 1);
13064 draw_quad_z(&test_context
, 0.25f
);
13065 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
13066 for (i
= 0; i
< 4; ++i
)
13068 for (j
= 0; j
< 4; ++j
)
13070 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120, 0);
13071 ok(compare_color(color
, bitmap_data
[j
+ i
* 4], 1),
13072 "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
13073 color
, j
, i
, bitmap_data
[j
+ i
* 4]);
13076 release_resource_readback(&rb
);
13077 draw_quad_z(&test_context
, 0.5f
);
13078 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
13079 draw_quad_z(&test_context
, 1.0f
);
13080 check_texture_color(test_context
.backbuffer
, 0xffff00ff, 1);
13082 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &dst_srv
);
13084 set_box(&box
, 0, 0, 0, 4, 4, 2);
13085 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
13086 0, 0, 2, (ID3D11Resource
*)src_texture
, 0, &box
);
13087 set_box(&box
, 0, 0, 2, 4, 4, 4);
13088 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
13089 0, 0, 0, (ID3D11Resource
*)src_texture
, 0, &box
);
13091 set_box(&box
, 0, 0, 0, 4, 4, 1);
13092 for (i
= 0; i
< ARRAY_SIZE(resource_data
); ++i
)
13094 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)src_texture
, 0,
13095 0, 0, i
, (ID3D11Resource
*)texture2d
, i
, &box
);
13097 draw_quad(&test_context
);
13098 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
13099 draw_quad_z(&test_context
, 0.25f
);
13100 check_texture_color(test_context
.backbuffer
, 0xffff00ff, 1);
13101 draw_quad_z(&test_context
, 0.5f
);
13102 check_texture_color(test_context
.backbuffer
, 0xff0000ff, 1);
13103 draw_quad_z(&test_context
, 1.0f
);
13104 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
13105 for (i
= 0; i
< 4; ++i
)
13107 for (j
= 0; j
< 4; ++j
)
13109 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120, 0);
13110 ok(compare_color(color
, bitmap_data
[j
+ i
* 4], 1),
13111 "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
13112 color
, j
, i
, bitmap_data
[j
+ i
* 4]);
13115 release_resource_readback(&rb
);
13117 ID3D11PixelShader_Release(ps
);
13118 ID3D11SamplerState_Release(sampler_state
);
13119 ID3D11ShaderResourceView_Release(dst_srv
);
13120 ID3D11ShaderResourceView_Release(src_srv
);
13121 ID3D11Texture2D_Release(texture2d
);
13122 ID3D11Texture3D_Release(dst_texture
);
13123 ID3D11Texture3D_Release(src_texture
);
13124 release_test_context(&test_context
);
13127 static void test_resource_map(void)
13129 D3D11_MAPPED_SUBRESOURCE mapped_subresource
;
13130 D3D11_TEXTURE3D_DESC texture3d_desc
;
13131 D3D11_TEXTURE2D_DESC texture2d_desc
;
13132 D3D11_BUFFER_DESC buffer_desc
;
13133 ID3D11DeviceContext
*context
;
13134 ID3D11Texture3D
*texture3d
;
13135 ID3D11Texture2D
*texture2d
;
13136 ID3D11Buffer
*buffer
;
13137 ID3D11Device
*device
;
13142 if (!(device
= create_device(NULL
)))
13144 skip("Failed to create device.\n");
13148 ID3D11Device_GetImmediateContext(device
, &context
);
13150 buffer_desc
.ByteWidth
= 1024;
13151 buffer_desc
.Usage
= D3D11_USAGE_STAGING
;
13152 buffer_desc
.BindFlags
= 0;
13153 buffer_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
| D3D11_CPU_ACCESS_WRITE
;
13154 buffer_desc
.MiscFlags
= 0;
13155 buffer_desc
.StructureByteStride
= 0;
13157 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
13158 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
13160 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)buffer
, 1, D3D11_MAP_READ
, 0, &mapped_subresource
);
13161 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
13163 memset(&mapped_subresource
, 0, sizeof(mapped_subresource
));
13164 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)buffer
, 0, D3D11_MAP_WRITE
, 0, &mapped_subresource
);
13165 ok(SUCCEEDED(hr
), "Failed to map buffer, hr %#x.\n", hr
);
13166 ok(mapped_subresource
.RowPitch
== 1024, "Got unexpected row pitch %u.\n", mapped_subresource
.RowPitch
);
13167 ok(mapped_subresource
.DepthPitch
== 1024, "Got unexpected depth pitch %u.\n", mapped_subresource
.DepthPitch
);
13168 *((DWORD
*)mapped_subresource
.pData
) = 0xdeadbeef;
13169 ID3D11DeviceContext_Unmap(context
, (ID3D11Resource
*)buffer
, 0);
13171 memset(&mapped_subresource
, 0, sizeof(mapped_subresource
));
13172 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)buffer
, 0, D3D11_MAP_READ
, 0, &mapped_subresource
);
13173 ok(SUCCEEDED(hr
), "Failed to map buffer, hr %#x.\n", hr
);
13174 ok(mapped_subresource
.RowPitch
== 1024, "Got unexpected row pitch %u.\n", mapped_subresource
.RowPitch
);
13175 ok(mapped_subresource
.DepthPitch
== 1024, "Got unexpected depth pitch %u.\n", mapped_subresource
.DepthPitch
);
13176 data
= *((DWORD
*)mapped_subresource
.pData
);
13177 ok(data
== 0xdeadbeef, "Got unexpected data %#x.\n", data
);
13178 ID3D11DeviceContext_Unmap(context
, (ID3D11Resource
*)buffer
, 0);
13180 refcount
= ID3D11Buffer_Release(buffer
);
13181 ok(!refcount
, "Buffer has %u references left.\n", refcount
);
13183 texture2d_desc
.Width
= 512;
13184 texture2d_desc
.Height
= 512;
13185 texture2d_desc
.MipLevels
= 1;
13186 texture2d_desc
.ArraySize
= 1;
13187 texture2d_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
13188 texture2d_desc
.SampleDesc
.Count
= 1;
13189 texture2d_desc
.SampleDesc
.Quality
= 0;
13190 texture2d_desc
.Usage
= D3D11_USAGE_STAGING
;
13191 texture2d_desc
.BindFlags
= 0;
13192 texture2d_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
| D3D11_CPU_ACCESS_WRITE
;
13193 texture2d_desc
.MiscFlags
= 0;
13195 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, &texture2d
);
13196 ok(SUCCEEDED(hr
), "Failed to create 2d texture, hr %#x.\n", hr
);
13198 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)texture2d
, 1, D3D11_MAP_READ
, 0, &mapped_subresource
);
13199 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
13201 memset(&mapped_subresource
, 0, sizeof(mapped_subresource
));
13202 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)texture2d
, 0, D3D11_MAP_WRITE
, 0, &mapped_subresource
);
13203 ok(SUCCEEDED(hr
), "Failed to map texture, hr %#x.\n", hr
);
13204 ok(mapped_subresource
.RowPitch
== 4 * 512, "Got unexpected row pitch %u.\n", mapped_subresource
.RowPitch
);
13205 ok(mapped_subresource
.DepthPitch
== 4 * 512 * 512, "Got unexpected depth pitch %u.\n",
13206 mapped_subresource
.DepthPitch
);
13207 *((DWORD
*)mapped_subresource
.pData
) = 0xdeadbeef;
13208 ID3D11DeviceContext_Unmap(context
, (ID3D11Resource
*)texture2d
, 0);
13210 memset(&mapped_subresource
, 0, sizeof(mapped_subresource
));
13211 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)texture2d
, 0, D3D11_MAP_READ
, 0, &mapped_subresource
);
13212 ok(SUCCEEDED(hr
), "Failed to map texture, hr %#x.\n", hr
);
13213 ok(mapped_subresource
.RowPitch
== 4 * 512, "Got unexpected row pitch %u.\n", mapped_subresource
.RowPitch
);
13214 ok(mapped_subresource
.DepthPitch
== 4 * 512 * 512, "Got unexpected depth pitch %u.\n",
13215 mapped_subresource
.DepthPitch
);
13216 data
= *((DWORD
*)mapped_subresource
.pData
);
13217 ok(data
== 0xdeadbeef, "Got unexpected data %#x.\n", data
);
13218 ID3D11DeviceContext_Unmap(context
, (ID3D11Resource
*)texture2d
, 0);
13220 refcount
= ID3D11Texture2D_Release(texture2d
);
13221 ok(!refcount
, "2D texture has %u references left.\n", refcount
);
13223 texture3d_desc
.Width
= 64;
13224 texture3d_desc
.Height
= 64;
13225 texture3d_desc
.Depth
= 64;
13226 texture3d_desc
.MipLevels
= 1;
13227 texture3d_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
13228 texture3d_desc
.Usage
= D3D11_USAGE_STAGING
;
13229 texture3d_desc
.BindFlags
= 0;
13230 texture3d_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
| D3D11_CPU_ACCESS_WRITE
;
13231 texture3d_desc
.MiscFlags
= 0;
13233 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &texture3d
);
13234 ok(SUCCEEDED(hr
), "Failed to create 3d texture, hr %#x.\n", hr
);
13236 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)texture3d
, 1, D3D11_MAP_READ
, 0, &mapped_subresource
);
13237 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
13239 memset(&mapped_subresource
, 0, sizeof(mapped_subresource
));
13240 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)texture3d
, 0, D3D11_MAP_WRITE
, 0, &mapped_subresource
);
13241 ok(SUCCEEDED(hr
), "Failed to map texture, hr %#x.\n", hr
);
13242 ok(mapped_subresource
.RowPitch
== 4 * 64, "Got unexpected row pitch %u.\n", mapped_subresource
.RowPitch
);
13243 ok(mapped_subresource
.DepthPitch
== 4 * 64 * 64, "Got unexpected depth pitch %u.\n",
13244 mapped_subresource
.DepthPitch
);
13245 *((DWORD
*)mapped_subresource
.pData
) = 0xdeadbeef;
13246 ID3D11DeviceContext_Unmap(context
, (ID3D11Resource
*)texture3d
, 0);
13248 memset(&mapped_subresource
, 0, sizeof(mapped_subresource
));
13249 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)texture3d
, 0, D3D11_MAP_READ
, 0, &mapped_subresource
);
13250 ok(SUCCEEDED(hr
), "Failed to map texture, hr %#x.\n", hr
);
13251 ok(mapped_subresource
.RowPitch
== 4 * 64, "Got unexpected row pitch %u.\n", mapped_subresource
.RowPitch
);
13252 ok(mapped_subresource
.DepthPitch
== 4 * 64 * 64, "Got unexpected depth pitch %u.\n",
13253 mapped_subresource
.DepthPitch
);
13254 data
= *((DWORD
*)mapped_subresource
.pData
);
13255 ok(data
== 0xdeadbeef, "Got unexpected data %#x.\n", data
);
13256 ID3D11DeviceContext_Unmap(context
, (ID3D11Resource
*)texture3d
, 0);
13258 refcount
= ID3D11Texture3D_Release(texture3d
);
13259 ok(!refcount
, "3D texture has %u references left.\n", refcount
);
13261 ID3D11DeviceContext_Release(context
);
13263 refcount
= ID3D11Device_Release(device
);
13264 ok(!refcount
, "Device has %u references left.\n", refcount
);
13267 #define check_resource_cpu_access(a, b, c, d, e) check_resource_cpu_access_(__LINE__, a, b, c, d, e)
13268 static void check_resource_cpu_access_(unsigned int line
, ID3D11DeviceContext
*context
,
13269 ID3D11Resource
*resource
, D3D11_USAGE usage
, UINT bind_flags
, UINT cpu_access
)
13271 BOOL cpu_write
= cpu_access
& D3D11_CPU_ACCESS_WRITE
;
13272 BOOL cpu_read
= cpu_access
& D3D11_CPU_ACCESS_READ
;
13273 BOOL dynamic
= usage
== D3D11_USAGE_DYNAMIC
;
13274 D3D11_MAPPED_SUBRESOURCE map_desc
;
13275 HRESULT hr
, expected_hr
;
13276 ID3D11Device
*device
;
13278 expected_hr
= cpu_read
? S_OK
: E_INVALIDARG
;
13279 hr
= ID3D11DeviceContext_Map(context
, resource
, 0, D3D11_MAP_READ
, 0, &map_desc
);
13280 ok_(__FILE__
, line
)(hr
== expected_hr
, "Got hr %#x for READ.\n", hr
);
13282 ID3D11DeviceContext_Unmap(context
, resource
, 0);
13284 /* WRITE_DISCARD and WRITE_NO_OVERWRITE are the only allowed options for dynamic resources. */
13285 expected_hr
= !dynamic
&& cpu_write
? S_OK
: E_INVALIDARG
;
13286 hr
= ID3D11DeviceContext_Map(context
, resource
, 0, D3D11_MAP_WRITE
, 0, &map_desc
);
13287 todo_wine_if(dynamic
&& cpu_write
)
13288 ok_(__FILE__
, line
)(hr
== expected_hr
, "Got hr %#x for WRITE.\n", hr
);
13290 ID3D11DeviceContext_Unmap(context
, resource
, 0);
13292 expected_hr
= cpu_read
&& cpu_write
? S_OK
: E_INVALIDARG
;
13293 hr
= ID3D11DeviceContext_Map(context
, resource
, 0, D3D11_MAP_READ_WRITE
, 0, &map_desc
);
13294 ok_(__FILE__
, line
)(hr
== expected_hr
, "Got hr %#x for READ_WRITE.\n", hr
);
13296 ID3D11DeviceContext_Unmap(context
, resource
, 0);
13298 expected_hr
= dynamic
? S_OK
: E_INVALIDARG
;
13299 hr
= ID3D11DeviceContext_Map(context
, resource
, 0, D3D11_MAP_WRITE_DISCARD
, 0, &map_desc
);
13300 todo_wine_if(!dynamic
&& cpu_write
)
13301 ok_(__FILE__
, line
)(hr
== expected_hr
, "Got hr %#x for WRITE_DISCARD.\n", hr
);
13303 ID3D11DeviceContext_Unmap(context
, resource
, 0);
13308 ID3D11DeviceContext_GetDevice(context
, &device
);
13310 /* WRITE_NO_OVERWRITE is supported only for buffers. */
13311 expected_hr
= is_buffer(resource
) ? S_OK
: E_INVALIDARG
;
13312 hr
= ID3D11DeviceContext_Map(context
, resource
, 0, D3D11_MAP_WRITE_NO_OVERWRITE
, 0, &map_desc
);
13313 /* D3D11.1 is required for constant and shader buffers. */
13314 todo_wine_if(expected_hr
!= S_OK
)
13315 ok_(__FILE__
, line
)(hr
== expected_hr
13316 || broken(bind_flags
& (D3D11_BIND_CONSTANT_BUFFER
| D3D11_BIND_SHADER_RESOURCE
)),
13317 "Got hr %#x for WRITE_NO_OVERWRITE.\n", hr
);
13319 ID3D11DeviceContext_Unmap(context
, resource
, 0);
13321 ID3D11Device_Release(device
);
13324 static void test_resource_access(const D3D_FEATURE_LEVEL feature_level
)
13326 D3D11_TEXTURE2D_DESC texture_desc
;
13327 struct device_desc device_desc
;
13328 D3D11_BUFFER_DESC buffer_desc
;
13329 ID3D11DeviceContext
*context
;
13330 D3D11_SUBRESOURCE_DATA data
;
13331 ID3D11Resource
*resource
;
13332 BOOL required_cpu_access
;
13333 BOOL cpu_write
, cpu_read
;
13334 HRESULT hr
, expected_hr
;
13335 UINT allowed_cpu_access
;
13336 BOOL broken_validation
;
13337 ID3D11Device
*device
;
13341 static const struct
13346 UINT allowed_cpu_access
;
13350 /* Default resources cannot be written by CPU. */
13351 {D3D11_USAGE_DEFAULT
, D3D11_BIND_VERTEX_BUFFER
, TRUE
, 0},
13352 {D3D11_USAGE_DEFAULT
, D3D11_BIND_INDEX_BUFFER
, TRUE
, 0},
13353 {D3D11_USAGE_DEFAULT
, D3D11_BIND_CONSTANT_BUFFER
, TRUE
, 0},
13354 {D3D11_USAGE_DEFAULT
, D3D11_BIND_SHADER_RESOURCE
, TRUE
, 0},
13355 {D3D11_USAGE_DEFAULT
, D3D11_BIND_STREAM_OUTPUT
, TRUE
, 0},
13356 {D3D11_USAGE_DEFAULT
, D3D11_BIND_RENDER_TARGET
, TRUE
, 0},
13357 {D3D11_USAGE_DEFAULT
, D3D11_BIND_DEPTH_STENCIL
, TRUE
, 0},
13358 {D3D11_USAGE_DEFAULT
, D3D11_BIND_UNORDERED_ACCESS
, TRUE
, 0},
13360 /* Immutable resources cannot be written by CPU and GPU. */
13361 {D3D11_USAGE_IMMUTABLE
, 0, FALSE
, 0},
13362 {D3D11_USAGE_IMMUTABLE
, D3D11_BIND_VERTEX_BUFFER
, TRUE
, 0},
13363 {D3D11_USAGE_IMMUTABLE
, D3D11_BIND_INDEX_BUFFER
, TRUE
, 0},
13364 {D3D11_USAGE_IMMUTABLE
, D3D11_BIND_CONSTANT_BUFFER
, TRUE
, 0},
13365 {D3D11_USAGE_IMMUTABLE
, D3D11_BIND_SHADER_RESOURCE
, TRUE
, 0},
13366 {D3D11_USAGE_IMMUTABLE
, D3D11_BIND_STREAM_OUTPUT
, FALSE
, 0},
13367 {D3D11_USAGE_IMMUTABLE
, D3D11_BIND_RENDER_TARGET
, FALSE
, 0},
13368 {D3D11_USAGE_IMMUTABLE
, D3D11_BIND_DEPTH_STENCIL
, FALSE
, 0},
13369 {D3D11_USAGE_IMMUTABLE
, D3D11_BIND_UNORDERED_ACCESS
, FALSE
, 0},
13371 /* Dynamic resources cannot be written by GPU. */
13372 {D3D11_USAGE_DYNAMIC
, 0, FALSE
, D3D11_CPU_ACCESS_WRITE
},
13373 {D3D11_USAGE_DYNAMIC
, D3D11_BIND_VERTEX_BUFFER
, TRUE
, D3D11_CPU_ACCESS_WRITE
},
13374 {D3D11_USAGE_DYNAMIC
, D3D11_BIND_INDEX_BUFFER
, TRUE
, D3D11_CPU_ACCESS_WRITE
},
13375 {D3D11_USAGE_DYNAMIC
, D3D11_BIND_CONSTANT_BUFFER
, TRUE
, D3D11_CPU_ACCESS_WRITE
},
13376 {D3D11_USAGE_DYNAMIC
, D3D11_BIND_SHADER_RESOURCE
, TRUE
, D3D11_CPU_ACCESS_WRITE
},
13377 {D3D11_USAGE_DYNAMIC
, D3D11_BIND_STREAM_OUTPUT
, FALSE
, D3D11_CPU_ACCESS_WRITE
},
13378 {D3D11_USAGE_DYNAMIC
, D3D11_BIND_RENDER_TARGET
, FALSE
, D3D11_CPU_ACCESS_WRITE
},
13379 {D3D11_USAGE_DYNAMIC
, D3D11_BIND_DEPTH_STENCIL
, FALSE
, D3D11_CPU_ACCESS_WRITE
},
13380 {D3D11_USAGE_DYNAMIC
, D3D11_BIND_UNORDERED_ACCESS
, FALSE
, D3D11_CPU_ACCESS_WRITE
},
13382 /* Staging resources support only data transfer. */
13383 {D3D11_USAGE_STAGING
, 0, TRUE
, D3D11_CPU_ACCESS_WRITE
| D3D11_CPU_ACCESS_READ
},
13384 {D3D11_USAGE_STAGING
, D3D11_BIND_VERTEX_BUFFER
, FALSE
, 0},
13385 {D3D11_USAGE_STAGING
, D3D11_BIND_INDEX_BUFFER
, FALSE
, 0},
13386 {D3D11_USAGE_STAGING
, D3D11_BIND_CONSTANT_BUFFER
, FALSE
, 0},
13387 {D3D11_USAGE_STAGING
, D3D11_BIND_SHADER_RESOURCE
, FALSE
, 0},
13388 {D3D11_USAGE_STAGING
, D3D11_BIND_STREAM_OUTPUT
, FALSE
, 0},
13389 {D3D11_USAGE_STAGING
, D3D11_BIND_RENDER_TARGET
, FALSE
, 0},
13390 {D3D11_USAGE_STAGING
, D3D11_BIND_DEPTH_STENCIL
, FALSE
, 0},
13391 {D3D11_USAGE_STAGING
, D3D11_BIND_UNORDERED_ACCESS
, FALSE
, 0},
13394 device_desc
.feature_level
= &feature_level
;
13395 device_desc
.flags
= 0;
13396 if (!(device
= create_device(&device_desc
)))
13398 skip("Failed to create device for feature level %#x.\n", feature_level
);
13401 ID3D11Device_GetImmediateContext(device
, &context
);
13403 data
.SysMemPitch
= 0;
13404 data
.SysMemSlicePitch
= 0;
13405 data
.pSysMem
= heap_alloc(10240);
13406 ok(!!data
.pSysMem
, "Failed to allocate memory.\n");
13408 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
13410 switch (tests
[i
].bind_flags
)
13412 case D3D11_BIND_DEPTH_STENCIL
:
13415 case D3D11_BIND_SHADER_RESOURCE
:
13416 case D3D11_BIND_STREAM_OUTPUT
:
13417 case D3D11_BIND_RENDER_TARGET
:
13418 if (feature_level
< D3D_FEATURE_LEVEL_10_0
)
13422 case D3D11_BIND_UNORDERED_ACCESS
:
13423 if (feature_level
< D3D_FEATURE_LEVEL_11_0
)
13431 allowed_cpu_access
= tests
[i
].allowed_cpu_access
;
13432 if (feature_level
>= D3D_FEATURE_LEVEL_11_0
&& is_d3d11_2_runtime(device
)
13433 && tests
[i
].usage
== D3D11_USAGE_DEFAULT
13434 && (tests
[i
].bind_flags
== D3D11_BIND_SHADER_RESOURCE
13435 || tests
[i
].bind_flags
== D3D11_BIND_UNORDERED_ACCESS
))
13436 allowed_cpu_access
|= D3D11_CPU_ACCESS_WRITE
| D3D11_CPU_ACCESS_READ
;
13438 required_cpu_access
= tests
[i
].usage
== D3D11_USAGE_DYNAMIC
|| tests
[i
].usage
== D3D11_USAGE_STAGING
;
13439 cpu_write
= allowed_cpu_access
& D3D11_CPU_ACCESS_WRITE
;
13440 cpu_read
= allowed_cpu_access
& D3D11_CPU_ACCESS_READ
;
13442 buffer_desc
.ByteWidth
= 1024;
13443 buffer_desc
.Usage
= tests
[i
].usage
;
13444 buffer_desc
.BindFlags
= tests
[i
].bind_flags
;
13445 buffer_desc
.MiscFlags
= 0;
13446 buffer_desc
.StructureByteStride
= 0;
13448 buffer_desc
.CPUAccessFlags
= 0;
13449 expected_hr
= tests
[i
].is_valid
&& !required_cpu_access
? S_OK
: E_INVALIDARG
;
13450 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &data
, (ID3D11Buffer
**)&resource
);
13451 ok(hr
== expected_hr
, "Got hr %#x, expected %#x, test %u.\n", hr
, expected_hr
, i
);
13454 check_resource_cpu_access(context
, resource
,
13455 buffer_desc
.Usage
, buffer_desc
.BindFlags
, buffer_desc
.CPUAccessFlags
);
13456 ID3D11Resource_Release(resource
);
13459 buffer_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_WRITE
;
13460 expected_hr
= tests
[i
].is_valid
&& cpu_write
? S_OK
: E_INVALIDARG
;
13461 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &data
, (ID3D11Buffer
**)&resource
);
13462 ok(hr
== expected_hr
, "Got hr %#x, expected %#x, test %u.\n", hr
, expected_hr
, i
);
13465 check_resource_cpu_access(context
, resource
,
13466 buffer_desc
.Usage
, buffer_desc
.BindFlags
, buffer_desc
.CPUAccessFlags
);
13467 ID3D11Resource_Release(resource
);
13470 buffer_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
;
13471 expected_hr
= tests
[i
].is_valid
&& cpu_read
? S_OK
: E_INVALIDARG
;
13472 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &data
, (ID3D11Buffer
**)&resource
);
13473 ok(hr
== expected_hr
, "Got hr %#x, expected %#x, test %u.\n", hr
, expected_hr
, i
);
13476 check_resource_cpu_access(context
, resource
,
13477 buffer_desc
.Usage
, buffer_desc
.BindFlags
, buffer_desc
.CPUAccessFlags
);
13478 ID3D11Resource_Release(resource
);
13481 buffer_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_WRITE
| D3D11_CPU_ACCESS_READ
;
13482 expected_hr
= tests
[i
].is_valid
&& cpu_write
&& cpu_read
? S_OK
: E_INVALIDARG
;
13483 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &data
, (ID3D11Buffer
**)&resource
);
13484 ok(hr
== expected_hr
, "Got hr %#x, expected %#x, test %u.\n", hr
, expected_hr
, i
);
13487 check_resource_cpu_access(context
, resource
,
13488 buffer_desc
.Usage
, buffer_desc
.BindFlags
, buffer_desc
.CPUAccessFlags
);
13489 ID3D11Resource_Release(resource
);
13493 data
.SysMemPitch
= 16;
13495 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
13497 switch (tests
[i
].bind_flags
)
13499 case D3D11_BIND_VERTEX_BUFFER
:
13500 case D3D11_BIND_INDEX_BUFFER
:
13501 case D3D11_BIND_CONSTANT_BUFFER
:
13502 case D3D11_BIND_STREAM_OUTPUT
:
13505 case D3D11_BIND_UNORDERED_ACCESS
:
13506 if (feature_level
< D3D_FEATURE_LEVEL_11_0
)
13514 broken_validation
= tests
[i
].usage
== D3D11_USAGE_DEFAULT
13515 && (tests
[i
].bind_flags
== D3D11_BIND_SHADER_RESOURCE
13516 || tests
[i
].bind_flags
== D3D11_BIND_RENDER_TARGET
13517 || tests
[i
].bind_flags
== D3D11_BIND_UNORDERED_ACCESS
);
13519 required_cpu_access
= tests
[i
].usage
== D3D11_USAGE_DYNAMIC
|| tests
[i
].usage
== D3D11_USAGE_STAGING
;
13520 cpu_write
= tests
[i
].allowed_cpu_access
& D3D11_CPU_ACCESS_WRITE
;
13521 cpu_read
= tests
[i
].allowed_cpu_access
& D3D11_CPU_ACCESS_READ
;
13523 texture_desc
.Width
= 4;
13524 texture_desc
.Height
= 4;
13525 texture_desc
.MipLevels
= 1;
13526 texture_desc
.ArraySize
= 1;
13527 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
13528 texture_desc
.SampleDesc
.Count
= 1;
13529 texture_desc
.SampleDesc
.Quality
= 0;
13530 texture_desc
.Usage
= tests
[i
].usage
;
13531 texture_desc
.BindFlags
= tests
[i
].bind_flags
;
13532 texture_desc
.MiscFlags
= 0;
13533 if (tests
[i
].bind_flags
== D3D11_BIND_DEPTH_STENCIL
)
13534 texture_desc
.Format
= DXGI_FORMAT_D16_UNORM
;
13536 texture_desc
.CPUAccessFlags
= 0;
13537 expected_hr
= tests
[i
].is_valid
&& !required_cpu_access
? S_OK
: E_INVALIDARG
;
13538 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &data
, (ID3D11Texture2D
**)&resource
);
13539 ok(hr
== expected_hr
, "Got hr %#x, expected %#x, test %u.\n", hr
, expected_hr
, i
);
13542 check_resource_cpu_access(context
, resource
,
13543 texture_desc
.Usage
, texture_desc
.BindFlags
, texture_desc
.CPUAccessFlags
);
13544 ID3D11Resource_Release(resource
);
13547 texture_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_WRITE
;
13548 expected_hr
= tests
[i
].is_valid
&& cpu_write
? S_OK
: E_INVALIDARG
;
13549 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &data
, (ID3D11Texture2D
**)&resource
);
13550 ok(hr
== expected_hr
|| (hr
== S_OK
&& broken_validation
),
13551 "Got hr %#x, expected %#x, test %u.\n", hr
, expected_hr
, i
);
13554 if (broken_validation
)
13555 texture_desc
.CPUAccessFlags
= 0;
13556 check_resource_cpu_access(context
, resource
,
13557 texture_desc
.Usage
, texture_desc
.BindFlags
, texture_desc
.CPUAccessFlags
);
13558 ID3D11Resource_Release(resource
);
13561 texture_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
;
13562 expected_hr
= tests
[i
].is_valid
&& cpu_read
? S_OK
: E_INVALIDARG
;
13563 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &data
, (ID3D11Texture2D
**)&resource
);
13564 ok(hr
== expected_hr
|| (hr
== S_OK
&& broken_validation
),
13565 "Got hr %#x, expected %#x, test %u.\n", hr
, expected_hr
, i
);
13568 if (broken_validation
)
13569 texture_desc
.CPUAccessFlags
= 0;
13570 check_resource_cpu_access(context
, resource
,
13571 texture_desc
.Usage
, texture_desc
.BindFlags
, texture_desc
.CPUAccessFlags
);
13572 ID3D11Resource_Release(resource
);
13575 texture_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_WRITE
| D3D11_CPU_ACCESS_READ
;
13576 expected_hr
= tests
[i
].is_valid
&& cpu_write
&& cpu_read
? S_OK
: E_INVALIDARG
;
13577 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &data
, (ID3D11Texture2D
**)&resource
);
13578 ok(hr
== expected_hr
|| (hr
== S_OK
&& broken_validation
),
13579 "Got hr %#x, expected %#x, test %u.\n", hr
, expected_hr
, i
);
13582 if (broken_validation
)
13583 texture_desc
.CPUAccessFlags
= 0;
13584 check_resource_cpu_access(context
, resource
,
13585 texture_desc
.Usage
, texture_desc
.BindFlags
, texture_desc
.CPUAccessFlags
);
13586 ID3D11Resource_Release(resource
);
13590 heap_free((void *)data
.pSysMem
);
13592 ID3D11DeviceContext_Release(context
);
13593 refcount
= ID3D11Device_Release(device
);
13594 ok(!refcount
, "Device has %u references left.\n", refcount
);
13597 static void test_check_multisample_quality_levels(void)
13599 ID3D11Device
*device
;
13600 UINT quality_levels
;
13604 if (!(device
= create_device(NULL
)))
13606 skip("Failed to create device.\n");
13610 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 2, &quality_levels
);
13611 ok(hr
== S_OK
, "Failed to check multisample quality levels, hr %#x.\n", hr
);
13612 if (!quality_levels
)
13614 skip("Multisampling not supported for DXGI_FORMAT_R8G8B8A8_UNORM, skipping test.\n");
13618 quality_levels
= 0xdeadbeef;
13619 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_UNKNOWN
, 2, &quality_levels
);
13620 todo_wine
ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
13621 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
13622 quality_levels
= 0xdeadbeef;
13623 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, 65536, 2, &quality_levels
);
13624 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
13625 todo_wine
ok(quality_levels
== 0xdeadbeef, "Got unexpected quality_levels %u.\n", quality_levels
);
13627 if (!enable_debug_layer
)
13629 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, NULL
);
13630 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
13631 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 1, NULL
);
13632 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
13633 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 2, NULL
);
13634 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
13637 quality_levels
= 0xdeadbeef;
13638 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, &quality_levels
);
13639 ok(hr
== E_FAIL
, "Got unexpected hr %#x.\n", hr
);
13640 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
13642 quality_levels
= 0xdeadbeef;
13643 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 1, &quality_levels
);
13644 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
13645 ok(quality_levels
== 1, "Got unexpected quality_levels %u.\n", quality_levels
);
13647 quality_levels
= 0xdeadbeef;
13648 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 2, &quality_levels
);
13649 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
13650 ok(quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
13652 /* We assume 15 samples multisampling is never supported in practice. */
13653 quality_levels
= 0xdeadbeef;
13654 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 15, &quality_levels
);
13655 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
13656 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
13657 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 32, &quality_levels
);
13658 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
13659 quality_levels
= 0xdeadbeef;
13660 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 33, &quality_levels
);
13661 ok(hr
== E_FAIL
, "Got unexpected hr %#x.\n", hr
);
13662 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
13663 quality_levels
= 0xdeadbeef;
13664 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 64, &quality_levels
);
13665 ok(hr
== E_FAIL
, "Got unexpected hr %#x.\n", hr
);
13666 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
13668 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_BC3_UNORM
, 2, &quality_levels
);
13669 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
13670 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
13673 refcount
= ID3D11Device_Release(device
);
13674 ok(!refcount
, "Device has %u references left.\n", refcount
);
13677 static void test_swapchain_formats(const D3D_FEATURE_LEVEL feature_level
)
13679 DXGI_SWAP_CHAIN_DESC swapchain_desc
;
13680 struct device_desc device_desc
;
13681 IDXGISwapChain
*swapchain
;
13682 IDXGIDevice
*dxgi_device
;
13683 HRESULT hr
, expected_hr
;
13684 IDXGIAdapter
*adapter
;
13685 IDXGIFactory
*factory
;
13686 ID3D11Device
*device
;
13690 swapchain_desc
.BufferDesc
.Width
= 800;
13691 swapchain_desc
.BufferDesc
.Height
= 600;
13692 swapchain_desc
.BufferDesc
.RefreshRate
.Numerator
= 60;
13693 swapchain_desc
.BufferDesc
.RefreshRate
.Denominator
= 60;
13694 swapchain_desc
.BufferDesc
.ScanlineOrdering
= DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED
;
13695 swapchain_desc
.BufferDesc
.Scaling
= DXGI_MODE_SCALING_UNSPECIFIED
;
13696 swapchain_desc
.SampleDesc
.Count
= 1;
13697 swapchain_desc
.SampleDesc
.Quality
= 0;
13698 swapchain_desc
.BufferUsage
= DXGI_USAGE_RENDER_TARGET_OUTPUT
;
13699 swapchain_desc
.BufferCount
= 1;
13700 swapchain_desc
.OutputWindow
= CreateWindowA("static", "d3d11_test", 0, 0, 0, 0, 0, 0, 0, 0, 0);
13701 swapchain_desc
.Windowed
= TRUE
;
13702 swapchain_desc
.SwapEffect
= DXGI_SWAP_EFFECT_DISCARD
;
13703 swapchain_desc
.Flags
= 0;
13705 device_desc
.feature_level
= &feature_level
;
13706 device_desc
.flags
= 0;
13707 if (!(device
= create_device(&device_desc
)))
13709 skip("Failed to create device for feature level %#x.\n", feature_level
);
13713 hr
= ID3D11Device_QueryInterface(device
, &IID_IDXGIDevice
, (void **)&dxgi_device
);
13714 ok(SUCCEEDED(hr
), "Failed to query IDXGIDevice, hr %#x.\n", hr
);
13715 hr
= IDXGIDevice_GetAdapter(dxgi_device
, &adapter
);
13716 ok(SUCCEEDED(hr
), "GetAdapter failed, hr %#x.\n", hr
);
13717 IDXGIDevice_Release(dxgi_device
);
13718 hr
= IDXGIAdapter_GetParent(adapter
, &IID_IDXGIFactory
, (void **)&factory
);
13719 ok(SUCCEEDED(hr
), "GetParent failed, hr %#x.\n", hr
);
13720 IDXGIAdapter_Release(adapter
);
13722 swapchain_desc
.BufferDesc
.Format
= DXGI_FORMAT_R8G8B8A8_TYPELESS
;
13723 hr
= IDXGIFactory_CreateSwapChain(factory
, (IUnknown
*)device
, &swapchain_desc
, &swapchain
);
13724 todo_wine
ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x for typeless format (feature level %#x).\n",
13725 hr
, feature_level
);
13727 IDXGISwapChain_Release(swapchain
);
13729 for (i
= 0; i
< ARRAY_SIZE(display_format_support
); ++i
)
13731 DXGI_FORMAT format
= display_format_support
[i
].format
;
13734 if (display_format_support
[i
].fl_required
<= feature_level
)
13736 expected_hr
= S_OK
;
13737 if (format
== DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM
)
13740 else if (!display_format_support
[i
].fl_optional
13741 || display_format_support
[i
].fl_optional
> feature_level
)
13743 expected_hr
= E_INVALIDARG
;
13744 if (format
!= DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM
)
13752 swapchain_desc
.BufferDesc
.Format
= format
;
13753 hr
= IDXGIFactory_CreateSwapChain(factory
, (IUnknown
*)device
, &swapchain_desc
, &swapchain
);
13755 ok(hr
== expected_hr
|| broken(hr
== E_OUTOFMEMORY
),
13756 "Got hr %#x, expected %#x (feature level %#x, format %#x).\n",
13757 hr
, expected_hr
, feature_level
, format
);
13760 refcount
= IDXGISwapChain_Release(swapchain
);
13761 ok(!refcount
, "Swapchain has %u references left.\n", refcount
);
13764 refcount
= ID3D11Device_Release(device
);
13765 ok(!refcount
, "Device has %u references left.\n", refcount
);
13766 refcount
= IDXGIFactory_Release(factory
);
13767 ok(!refcount
, "Factory has %u references left.\n", refcount
);
13768 DestroyWindow(swapchain_desc
.OutputWindow
);
13771 static void test_swapchain_views(void)
13773 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
13774 struct d3d11_test_context test_context
;
13775 D3D11_RENDER_TARGET_VIEW_DESC rtv_desc
;
13776 ID3D11ShaderResourceView
*srv
;
13777 ID3D11DeviceContext
*context
;
13778 ID3D11RenderTargetView
*rtv
;
13779 ID3D11Device
*device
;
13783 static const struct vec4 color
= {0.2f
, 0.3f
, 0.5f
, 1.0f
};
13785 if (!init_test_context(&test_context
, NULL
))
13788 device
= test_context
.device
;
13789 context
= test_context
.immediate_context
;
13791 refcount
= get_refcount(test_context
.backbuffer
);
13792 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
13794 draw_color_quad(&test_context
, &color
);
13795 check_texture_color(test_context
.backbuffer
, 0xff7f4c33, 1);
13797 rtv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
;
13798 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_TEXTURE2D
;
13799 U(rtv_desc
).Texture2D
.MipSlice
= 0;
13800 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)test_context
.backbuffer
, &rtv_desc
, &rtv
);
13801 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
13802 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
13804 refcount
= get_refcount(test_context
.backbuffer
);
13805 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
13807 draw_color_quad(&test_context
, &color
);
13808 todo_wine
check_texture_color(test_context
.backbuffer
, 0xffbc957c, 1);
13810 srv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
;
13811 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_TEXTURE2D
;
13812 U(srv_desc
).Texture2D
.MostDetailedMip
= 0;
13813 U(srv_desc
).Texture2D
.MipLevels
= 1;
13814 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)test_context
.backbuffer
, &srv_desc
, &srv
);
13815 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
13817 ID3D11ShaderResourceView_Release(srv
);
13819 ID3D11RenderTargetView_Release(rtv
);
13820 release_test_context(&test_context
);
13823 static void test_swapchain_flip(void)
13825 ID3D11Texture2D
*backbuffer_0
, *backbuffer_1
, *backbuffer_2
, *offscreen
;
13826 ID3D11ShaderResourceView
*backbuffer_0_srv
, *backbuffer_1_srv
;
13827 ID3D11RenderTargetView
*backbuffer_0_rtv
, *offscreen_rtv
;
13828 D3D11_TEXTURE2D_DESC texture_desc
;
13829 ID3D11InputLayout
*input_layout
;
13830 ID3D11DeviceContext
*context
;
13831 unsigned int stride
, offset
;
13832 struct swapchain_desc desc
;
13833 IDXGISwapChain
*swapchain
;
13834 ID3D11VertexShader
*vs
;
13835 ID3D11PixelShader
*ps
;
13836 ID3D11Device
*device
;
13844 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
13846 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
13848 static const DWORD vs_code
[] =
13851 float4
main(float4 position
: POSITION
) : SV_POSITION
13856 0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003,
13857 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
13858 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
13859 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
13860 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
13861 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
13862 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
13865 static const DWORD ps_code
[] =
13871 float4
main(float4 position
: SV_POSITION
) : SV_Target
13877 if (position
.x
< 320)
13878 return t0
.Sample(s
, p
);
13879 return t1
.Sample(s
, p
);
13882 0x43425844, 0xc00961ea, 0x48558efd, 0x5eec7aed, 0xb597e6d1, 0x00000001, 0x00000188, 0x00000003,
13883 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
13884 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000010f, 0x505f5653, 0x5449534f, 0x004e4f49,
13885 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
13886 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000ec, 0x00000040,
13887 0x0000003b, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
13888 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x04002064, 0x00101012, 0x00000000, 0x00000001,
13889 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x07000031, 0x00100012, 0x00000000,
13890 0x0010100a, 0x00000000, 0x00004001, 0x43a00000, 0x0304001f, 0x0010000a, 0x00000000, 0x0c000045,
13891 0x001020f2, 0x00000000, 0x00004002, 0x3f000000, 0x3f000000, 0x00000000, 0x00000000, 0x00107e46,
13892 0x00000000, 0x00106000, 0x00000000, 0x0100003e, 0x01000015, 0x0c000045, 0x001020f2, 0x00000000,
13893 0x00004002, 0x3f000000, 0x3f000000, 0x00000000, 0x00000000, 0x00107e46, 0x00000001, 0x00106000,
13894 0x00000000, 0x0100003e,
13896 static const struct vec2 quad
[] =
13903 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
13904 static const float green
[] = {0.0f
, 1.0f
, 0.0f
, 0.5f
};
13905 static const float blue
[] = {0.0f
, 0.0f
, 1.0f
, 0.5f
};
13907 if (!(device
= create_device(NULL
)))
13909 skip("Failed to create device, skipping tests.\n");
13912 SetRect(&rect
, 0, 0, 640, 480);
13913 AdjustWindowRect(&rect
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
, FALSE
);
13914 window
= CreateWindowA("static", "d3d11_test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
13915 0, 0, rect
.right
- rect
.left
, rect
.bottom
- rect
.top
, NULL
, NULL
, NULL
, NULL
);
13916 desc
.buffer_count
= 3;
13917 desc
.width
= desc
.height
= 0;
13918 desc
.swap_effect
= DXGI_SWAP_EFFECT_SEQUENTIAL
;
13919 desc
.windowed
= TRUE
;
13920 desc
.flags
= SWAPCHAIN_FLAG_SHADER_INPUT
;
13921 swapchain
= create_swapchain(device
, window
, &desc
);
13923 hr
= IDXGISwapChain_GetBuffer(swapchain
, 0, &IID_ID3D11Texture2D
, (void **)&backbuffer_0
);
13924 ok(SUCCEEDED(hr
), "Failed to get buffer, hr %#x.\n", hr
);
13925 hr
= IDXGISwapChain_GetBuffer(swapchain
, 1, &IID_ID3D11Texture2D
, (void **)&backbuffer_1
);
13926 ok(SUCCEEDED(hr
), "Failed to get buffer, hr %#x.\n", hr
);
13927 hr
= IDXGISwapChain_GetBuffer(swapchain
, 2, &IID_ID3D11Texture2D
, (void **)&backbuffer_2
);
13928 ok(SUCCEEDED(hr
), "Failed to get buffer, hr %#x.\n", hr
);
13930 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)backbuffer_0
, NULL
, &backbuffer_0_rtv
);
13931 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
13932 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)backbuffer_0
, NULL
, &backbuffer_0_srv
);
13933 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
13934 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)backbuffer_1
, NULL
, &backbuffer_1_srv
);
13935 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
13937 ID3D11Texture2D_GetDesc(backbuffer_0
, &texture_desc
);
13938 ok((texture_desc
.BindFlags
& (D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
))
13939 == (D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
),
13940 "Got unexpected bind flags %x.\n", texture_desc
.BindFlags
);
13941 ok(texture_desc
.Usage
== D3D11_USAGE_DEFAULT
, "Got unexpected usage %u.\n", texture_desc
.Usage
);
13943 ID3D11Texture2D_GetDesc(backbuffer_1
, &texture_desc
);
13944 ok((texture_desc
.BindFlags
& (D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
))
13945 == (D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
),
13946 "Got unexpected bind flags %x.\n", texture_desc
.BindFlags
);
13947 ok(texture_desc
.Usage
== D3D11_USAGE_DEFAULT
, "Got unexpected usage %u.\n", texture_desc
.Usage
);
13949 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)backbuffer_1
, NULL
, &offscreen_rtv
);
13950 todo_wine
ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
13952 ID3D11RenderTargetView_Release(offscreen_rtv
);
13954 ID3D11Device_GetImmediateContext(device
, &context
);
13956 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &backbuffer_0_srv
);
13957 ID3D11DeviceContext_PSSetShaderResources(context
, 1, 1, &backbuffer_1_srv
);
13959 texture_desc
.Width
= 640;
13960 texture_desc
.Height
= 480;
13961 texture_desc
.MipLevels
= 1;
13962 texture_desc
.ArraySize
= 1;
13963 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
13964 texture_desc
.SampleDesc
.Count
= 1;
13965 texture_desc
.SampleDesc
.Quality
= 0;
13966 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
13967 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
13968 texture_desc
.CPUAccessFlags
= 0;
13969 texture_desc
.MiscFlags
= 0;
13970 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &offscreen
);
13971 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
13972 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)offscreen
, NULL
, &offscreen_rtv
);
13973 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
13974 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &offscreen_rtv
, NULL
);
13975 set_viewport(context
, 0.0f
, 0.0f
, 640.0f
, 480.0f
, 0.0f
, 1.0f
);
13977 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(quad
), quad
);
13979 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
13980 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
13981 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
13982 vs_code
, sizeof(vs_code
), &input_layout
);
13983 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
13984 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
13985 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
13986 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
13987 stride
= sizeof(*quad
);
13989 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, &stride
, &offset
);
13991 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
13992 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
13993 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
13995 ID3D11DeviceContext_ClearRenderTargetView(context
, backbuffer_0_rtv
, red
);
13997 ID3D11DeviceContext_Draw(context
, 4, 0);
13998 color
= get_texture_color(offscreen
, 120, 240);
13999 ok(compare_color(color
, 0x7f0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
14001 /* DXGI moves buffers in the same direction as earlier versions. Buffer 2
14002 * becomes buffer 1, buffer 1 becomes the new buffer 0, and buffer 0
14003 * becomes buffer n - 1. However, only buffer 0 can be rendered to.
14005 * What is this good for? I don't know. Ad-hoc tests suggest that
14006 * Present() always waits for the next V-sync interval, even if there are
14007 * still untouched buffers. Buffer 0 is the buffer that is shown on the
14008 * screen, just like in <= d3d9. Present() also doesn't discard buffers if
14009 * rendering finishes before the V-sync interval is over. I haven't found
14010 * any productive use for more than one buffer. */
14011 IDXGISwapChain_Present(swapchain
, 0, 0);
14013 ID3D11DeviceContext_ClearRenderTargetView(context
, backbuffer_0_rtv
, green
);
14015 ID3D11DeviceContext_Draw(context
, 4, 0);
14016 color
= get_texture_color(offscreen
, 120, 240); /* green, buf 0 */
14017 ok(compare_color(color
, 0x7f00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
14018 /* Buffer 1 is still untouched. */
14020 color
= get_texture_color(backbuffer_0
, 320, 240); /* green */
14021 ok(compare_color(color
, 0x7f00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
14022 color
= get_texture_color(backbuffer_2
, 320, 240); /* red */
14023 ok(compare_color(color
, 0x7f0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
14025 IDXGISwapChain_Present(swapchain
, 0, 0);
14027 ID3D11DeviceContext_ClearRenderTargetView(context
, backbuffer_0_rtv
, blue
);
14029 ID3D11DeviceContext_Draw(context
, 4, 0);
14030 color
= get_texture_color(offscreen
, 120, 240); /* blue, buf 0 */
14031 ok(compare_color(color
, 0x7fff0000, 1), "Got unexpected color 0x%08x.\n", color
);
14032 color
= get_texture_color(offscreen
, 360, 240); /* red, buf 1 */
14033 ok(compare_color(color
, 0x7f0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
14035 color
= get_texture_color(backbuffer_0
, 320, 240); /* blue */
14036 ok(compare_color(color
, 0x7fff0000, 1), "Got unexpected color 0x%08x.\n", color
);
14037 color
= get_texture_color(backbuffer_1
, 320, 240); /* red */
14038 ok(compare_color(color
, 0x7f0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
14039 color
= get_texture_color(backbuffer_2
, 320, 240); /* green */
14040 ok(compare_color(color
, 0x7f00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
14042 ID3D11VertexShader_Release(vs
);
14043 ID3D11PixelShader_Release(ps
);
14044 ID3D11Buffer_Release(vb
);
14045 ID3D11InputLayout_Release(input_layout
);
14046 ID3D11ShaderResourceView_Release(backbuffer_0_srv
);
14047 ID3D11ShaderResourceView_Release(backbuffer_1_srv
);
14048 ID3D11RenderTargetView_Release(backbuffer_0_rtv
);
14049 ID3D11RenderTargetView_Release(offscreen_rtv
);
14050 ID3D11Texture2D_Release(offscreen
);
14051 ID3D11Texture2D_Release(backbuffer_0
);
14052 ID3D11Texture2D_Release(backbuffer_1
);
14053 ID3D11Texture2D_Release(backbuffer_2
);
14054 IDXGISwapChain_Release(swapchain
);
14056 ID3D11DeviceContext_Release(context
);
14057 refcount
= ID3D11Device_Release(device
);
14058 ok(!refcount
, "Device has %u references left.\n", refcount
);
14059 DestroyWindow(window
);
14062 static void test_clear_render_target_view_1d(void)
14064 static const float color
[] = {0.1f
, 0.5f
, 0.3f
, 0.75f
};
14065 static const float green
[] = {0.0f
, 1.0f
, 0.0f
, 0.5f
};
14067 struct d3d11_test_context test_context
;
14068 D3D11_TEXTURE1D_DESC texture_desc
;
14069 ID3D11DeviceContext
*context
;
14070 ID3D11RenderTargetView
*rtv
;
14071 ID3D11Texture1D
*texture
;
14072 ID3D11Device
*device
;
14075 if (!init_test_context(&test_context
, NULL
))
14078 device
= test_context
.device
;
14079 context
= test_context
.immediate_context
;
14081 texture_desc
.Width
= 64;
14082 texture_desc
.MipLevels
= 1;
14083 texture_desc
.ArraySize
= 1;
14084 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
14085 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
14086 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
14087 texture_desc
.CPUAccessFlags
= 0;
14088 texture_desc
.MiscFlags
= 0;
14089 hr
= ID3D11Device_CreateTexture1D(device
, &texture_desc
, NULL
, &texture
);
14090 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
14092 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
14093 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
14095 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, color
);
14096 check_texture1d_color(texture
, 0xbf4c7f19, 1);
14098 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, green
);
14099 check_texture1d_color(texture
, 0x8000ff00, 1);
14101 ID3D11RenderTargetView_Release(rtv
);
14102 ID3D11Texture1D_Release(texture
);
14103 release_test_context(&test_context
);
14106 static void test_clear_render_target_view_2d(void)
14108 static const DWORD expected_color
= 0xbf4c7f19, expected_srgb_color
= 0xbf95bc59;
14109 static const float color
[] = {0.1f
, 0.5f
, 0.3f
, 0.75f
};
14110 static const float green
[] = {0.0f
, 1.0f
, 0.0f
, 0.5f
};
14112 ID3D11Texture2D
*texture
, *srgb_texture
;
14113 struct d3d11_test_context test_context
;
14114 ID3D11RenderTargetView
*rtv
, *srgb_rtv
;
14115 D3D11_RENDER_TARGET_VIEW_DESC rtv_desc
;
14116 D3D11_TEXTURE2D_DESC texture_desc
;
14117 ID3D11DeviceContext
*context
;
14118 struct resource_readback rb
;
14119 ID3D11Device
*device
;
14123 if (!init_test_context(&test_context
, NULL
))
14126 device
= test_context
.device
;
14127 context
= test_context
.immediate_context
;
14129 texture_desc
.Width
= 640;
14130 texture_desc
.Height
= 480;
14131 texture_desc
.MipLevels
= 1;
14132 texture_desc
.ArraySize
= 1;
14133 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
14134 texture_desc
.SampleDesc
.Count
= 1;
14135 texture_desc
.SampleDesc
.Quality
= 0;
14136 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
14137 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
14138 texture_desc
.CPUAccessFlags
= 0;
14139 texture_desc
.MiscFlags
= 0;
14140 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
14141 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
14143 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
;
14144 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &srgb_texture
);
14145 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
14147 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
14148 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
14150 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)srgb_texture
, NULL
, &srgb_rtv
);
14151 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
14153 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, color
);
14154 check_texture_color(test_context
.backbuffer
, expected_color
, 1);
14156 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, color
);
14157 check_texture_color(texture
, expected_color
, 1);
14159 if (!enable_debug_layer
)
14160 ID3D11DeviceContext_ClearRenderTargetView(context
, NULL
, green
);
14161 check_texture_color(texture
, expected_color
, 1);
14163 ID3D11DeviceContext_ClearRenderTargetView(context
, srgb_rtv
, color
);
14164 check_texture_color(srgb_texture
, expected_srgb_color
, 1);
14166 ID3D11RenderTargetView_Release(srgb_rtv
);
14167 ID3D11RenderTargetView_Release(rtv
);
14168 ID3D11Texture2D_Release(srgb_texture
);
14169 ID3D11Texture2D_Release(texture
);
14171 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_TYPELESS
;
14172 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
14173 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
14175 rtv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
;
14176 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_TEXTURE2D
;
14177 U(rtv_desc
).Texture2D
.MipSlice
= 0;
14178 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, &rtv_desc
, &srgb_rtv
);
14179 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
14181 rtv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
14182 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_TEXTURE2D
;
14183 U(rtv_desc
).Texture2D
.MipSlice
= 0;
14184 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, &rtv_desc
, &rtv
);
14185 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
14187 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, color
);
14188 check_texture_color(texture
, expected_color
, 1);
14190 ID3D11DeviceContext_ClearRenderTargetView(context
, srgb_rtv
, color
);
14191 get_texture_readback(texture
, 0, &rb
);
14192 for (i
= 0; i
< 4; ++i
)
14194 for (j
= 0; j
< 4; ++j
)
14196 BOOL broken_device
= is_warp_device(device
) || is_nvidia_device(device
);
14197 DWORD color
= get_readback_color(&rb
, 80 + i
* 160, 60 + j
* 120, 0);
14198 ok(compare_color(color
, expected_srgb_color
, 1)
14199 || broken(compare_color(color
, expected_color
, 1) && broken_device
),
14200 "Got unexpected color 0x%08x.\n", color
);
14203 release_resource_readback(&rb
);
14205 ID3D11RenderTargetView_Release(srgb_rtv
);
14206 ID3D11RenderTargetView_Release(rtv
);
14207 ID3D11Texture2D_Release(texture
);
14208 release_test_context(&test_context
);
14211 static void test_clear_render_target_view_3d(void)
14213 static const float color
[] = {0.1f
, 0.5f
, 0.3f
, 0.75f
};
14214 static const float green
[] = {0.0f
, 1.0f
, 0.0f
, 0.5f
};
14216 struct d3d11_test_context test_context
;
14217 D3D11_RENDER_TARGET_VIEW_DESC rtv_desc
;
14218 D3D11_TEXTURE3D_DESC texture_desc
;
14219 ID3D11DeviceContext
*context
;
14220 ID3D11RenderTargetView
*rtv
;
14221 ID3D11Texture3D
*texture
;
14222 ID3D11Device
*device
;
14225 if (!init_test_context(&test_context
, NULL
))
14227 device
= test_context
.device
;
14228 context
= test_context
.immediate_context
;
14230 texture_desc
.Width
= 8;
14231 texture_desc
.Height
= 8;
14232 texture_desc
.Depth
= 4;
14233 texture_desc
.MipLevels
= 1;
14234 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
14235 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
14236 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
14237 texture_desc
.CPUAccessFlags
= 0;
14238 texture_desc
.MiscFlags
= 0;
14239 hr
= ID3D11Device_CreateTexture3D(device
, &texture_desc
, NULL
, &texture
);
14240 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
14242 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
14243 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
14245 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, color
);
14246 check_texture3d_color(texture
, 0xbf4c7f19, 1);
14247 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, green
);
14248 check_texture3d_color(texture
, 0x8000ff00, 1);
14250 ID3D11RenderTargetView_Release(rtv
);
14251 ID3D11Texture3D_Release(texture
);
14253 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_TYPELESS
;
14254 hr
= ID3D11Device_CreateTexture3D(device
, &texture_desc
, NULL
, &texture
);
14255 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
14257 rtv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
;
14258 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_TEXTURE3D
;
14259 U(rtv_desc
).Texture3D
.MipSlice
= 0;
14260 U(rtv_desc
).Texture3D
.FirstWSlice
= 0;
14261 U(rtv_desc
).Texture3D
.WSize
= ~0u;
14262 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, &rtv_desc
, &rtv
);
14263 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
14265 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, color
);
14266 check_texture3d_color(texture
, 0xbf95bc59, 1);
14267 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, green
);
14268 check_texture3d_color(texture
, 0x8000ff00, 1);
14270 ID3D11RenderTargetView_Release(rtv
);
14271 ID3D11Texture3D_Release(texture
);
14272 release_test_context(&test_context
);
14275 static void test_clear_depth_stencil_view(void)
14277 D3D11_TEXTURE2D_DESC texture_desc
;
14278 ID3D11Texture2D
*depth_texture
;
14279 ID3D11DeviceContext
*context
;
14280 ID3D11DepthStencilView
*dsv
;
14281 ID3D11Device
*device
;
14285 if (!(device
= create_device(NULL
)))
14287 skip("Failed to create device.\n");
14291 ID3D11Device_GetImmediateContext(device
, &context
);
14293 texture_desc
.Width
= 640;
14294 texture_desc
.Height
= 480;
14295 texture_desc
.MipLevels
= 1;
14296 texture_desc
.ArraySize
= 1;
14297 texture_desc
.Format
= DXGI_FORMAT_D32_FLOAT
;
14298 texture_desc
.SampleDesc
.Count
= 1;
14299 texture_desc
.SampleDesc
.Quality
= 0;
14300 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
14301 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
14302 texture_desc
.CPUAccessFlags
= 0;
14303 texture_desc
.MiscFlags
= 0;
14304 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &depth_texture
);
14305 ok(SUCCEEDED(hr
), "Failed to create depth texture, hr %#x.\n", hr
);
14307 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)depth_texture
, NULL
, &dsv
);
14308 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
14310 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
14311 check_texture_float(depth_texture
, 1.0f
, 0);
14313 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 0.25f
, 0);
14314 check_texture_float(depth_texture
, 0.25f
, 0);
14316 if (!enable_debug_layer
)
14317 ID3D11DeviceContext_ClearDepthStencilView(context
, NULL
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
14318 check_texture_float(depth_texture
, 0.25f
, 0);
14320 ID3D11Texture2D_Release(depth_texture
);
14321 ID3D11DepthStencilView_Release(dsv
);
14323 texture_desc
.Format
= DXGI_FORMAT_D24_UNORM_S8_UINT
;
14324 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &depth_texture
);
14325 ok(SUCCEEDED(hr
), "Failed to create depth texture, hr %#x.\n", hr
);
14327 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)depth_texture
, NULL
, &dsv
);
14328 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
14330 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
| D3D11_CLEAR_STENCIL
, 1.0f
, 0);
14331 todo_wine
check_texture_color(depth_texture
, 0x00ffffff, 0);
14333 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
| D3D11_CLEAR_STENCIL
, 0.0f
, 0xff);
14334 todo_wine
check_texture_color(depth_texture
, 0xff000000, 0);
14336 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
| D3D11_CLEAR_STENCIL
, 1.0f
, 0xff);
14337 check_texture_color(depth_texture
, 0xffffffff, 0);
14339 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
| D3D11_CLEAR_STENCIL
, 0.0f
, 0);
14340 check_texture_color(depth_texture
, 0x00000000, 0);
14342 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0xff);
14343 todo_wine
check_texture_color(depth_texture
, 0x00ffffff, 0);
14345 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_STENCIL
, 0.0f
, 0xff);
14346 check_texture_color(depth_texture
, 0xffffffff, 0);
14348 ID3D11Texture2D_Release(depth_texture
);
14349 ID3D11DepthStencilView_Release(dsv
);
14351 ID3D11DeviceContext_Release(context
);
14353 refcount
= ID3D11Device_Release(device
);
14354 ok(!refcount
, "Device has %u references left.\n", refcount
);
14357 static unsigned int to_sint8(unsigned int x
)
14365 return min(max(bits
.s
, -128), 127) & 0xff;
14368 #define check_rgba_sint8(data, uvec) check_rgba_sint8_(__LINE__, data, uvec)
14369 static void check_rgba_sint8_(unsigned int line
, DWORD data
, const struct uvec4
*v
)
14371 unsigned int x
= to_sint8(v
->x
);
14372 unsigned int y
= to_sint8(v
->y
);
14373 unsigned int z
= to_sint8(v
->z
);
14374 unsigned int w
= to_sint8(v
->w
);
14377 /* Windows 7 - Nvidia, WARP */
14378 (v
->x
& 0xff) | (v
->y
& 0xff) << 8 | (v
->z
& 0xff) << 16 | (v
->w
& 0xff) << 24,
14379 /* Windows 10 - AMD */
14380 x
| y
<< 8 | z
<< 16 | w
<< 24,
14381 /* Windows 10 - Intel */
14382 x
| x
<< 8 | x
<< 16 | x
<< 24,
14385 ok_(__FILE__
, line
)(data
== expected
[0] || data
== expected
[1] || broken(data
== expected
[2]),
14386 "Got %#x, expected %#x or %#x at %u, uvec4 %#x, %#x, %#x, %#x.\n",
14387 data
, expected
[0], expected
[1], x
, v
->x
, v
->y
, v
->z
, v
->w
);
14390 static void test_clear_buffer_unordered_access_view(void)
14392 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
14393 ID3D11UnorderedAccessView
*uav
, *uav2
;
14394 struct device_desc device_desc
;
14395 D3D11_BUFFER_DESC buffer_desc
;
14396 ID3D11DeviceContext
*context
;
14397 struct resource_readback rb
;
14398 ID3D11Buffer
*buffer
;
14399 ID3D11Device
*device
;
14400 struct uvec4 uvec4
;
14406 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
14407 static const struct uvec4 fe_uvec4
= {0xfefefefe, 0xfefefefe, 0xfefefefe, 0xfefefefe};
14408 static const struct uvec4 uvec4_data
[] =
14410 {0x00000000, 0x00000000, 0x00000000, 0x00000000},
14412 {0x00000000, 0xffffffff, 0xffffffff, 0xffffffff},
14413 {0xffffffff, 0x00000000, 0x00000000, 0x00000000},
14414 {0x00000000, 0xffffffff, 0x00000000, 0x00000000},
14415 {0x00000000, 0x00000000, 0xffffffff, 0x00000000},
14416 {0x00000000, 0x00000000, 0x00000000, 0xffffffff},
14418 {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff},
14419 {0x80000000, 0x80000000, 0x80000000, 0x80000000},
14420 {0x000000ff, 0x00000080, 0x80000080, 0x00000080},
14421 {0x000000ff, 0x0000007f, 0x000000ef, 0x000000fe},
14422 {0x800000ff, 0x8000007f, 0x800000ef, 0x800000fe},
14423 {0xfefefefe, 0xf0f0f0f0, 0xefefefef, 0x0f0f0f0f},
14424 {0xaaaaaaaa, 0xdeadbeef, 0xdeadbabe, 0xdeadf00d},
14426 {0x00000001, 0x00000002, 0x00000003, 0x00000004},
14427 {0x000000ff, 0x000000fe, 0x000000fd, 0x000000fc},
14428 {0x000000f2, 0x000000f1, 0x000000f0, 0x000000ef},
14429 {0x0000000a, 0x0000000d, 0x0000000e, 0x0000000f},
14430 {0x0000001a, 0x0000002d, 0x0000003e, 0x0000004f},
14431 {0x00000050, 0x00000060, 0x00000070, 0x00000080},
14432 {0x00000090, 0x000000a0, 0x000000b0, 0x000000c0},
14433 {0x000000d0, 0x000000e0, 0x000000f0, 0x000000ff},
14434 {0x00000073, 0x00000077, 0x0000007a, 0x0000007b},
14435 {0x0000007c, 0x0000007d, 0x0000007e, 0x0000007f},
14437 {0x80000001, 0x80000002, 0x80000003, 0x80000004},
14438 {0x800000ff, 0x800000fe, 0x800000fd, 0x800000fc},
14439 {0x800000f2, 0x800000f1, 0x800000f0, 0x800000ef},
14440 {0x8000000a, 0x0000000d, 0x8000000e, 0x8000000f},
14441 {0x8000001a, 0x8000002d, 0x8000003e, 0x8000004f},
14442 {0x80000050, 0x80000060, 0x80000070, 0x00000080},
14443 {0x80000090, 0x800000a0, 0x800000b0, 0x800000c0},
14444 {0x800000d0, 0x800000e0, 0x800000f0, 0x800000ff},
14445 {0x80000073, 0x80000077, 0x8000007a, 0x8000007b},
14446 {0x8000007c, 0x8000007d, 0x8000007e, 0x8000007f},
14448 {0x7fffff01, 0x7fffff02, 0x7fffff03, 0x7fffff04},
14449 {0x7fffffff, 0x7ffffffe, 0x7ffffffd, 0x7ffffffc},
14450 {0x7ffffff2, 0x7ffffff1, 0x7ffffff0, 0x7fffffef},
14451 {0x7fffff0a, 0x7fffff0d, 0x7fffff0e, 0x7fffff0f},
14452 {0x7fffff1a, 0x7fffff2d, 0x7fffff3e, 0x7fffff4f},
14453 {0x7fffff50, 0x7fffff60, 0x7fffff70, 0x7fffff80},
14454 {0x8fffff90, 0x7fffffa0, 0x7fffffb0, 0x7fffffc0},
14455 {0x7fffffd0, 0x7fffffe0, 0x7ffffff0, 0x7fffffff},
14456 {0x7fffff73, 0x7fffff77, 0x7fffff7a, 0x7fffff7b},
14457 {0x7fffff7c, 0x7fffff7d, 0x7fffff7e, 0x7fffff7f},
14459 {0xffffff01, 0xffffff02, 0xffffff03, 0xffffff04},
14460 {0xffffffff, 0xfffffffe, 0xfffffffd, 0xfffffffc},
14461 {0xfffffff2, 0xfffffff1, 0xfffffff0, 0xffffffef},
14462 {0xffffff0a, 0xffffff0d, 0xffffff0e, 0xffffff0f},
14463 {0xffffff1a, 0xffffff2d, 0xffffff3e, 0xffffff4f},
14464 {0xffffff50, 0xffffff60, 0xffffff70, 0xffffff80},
14465 {0xffffff90, 0xffffffa0, 0xffffffb0, 0xffffffc0},
14466 {0xffffffd0, 0xffffffe0, 0xfffffff0, 0xffffffff},
14467 {0xffffff73, 0xffffff77, 0xffffff7a, 0xffffff7b},
14468 {0xffffff7c, 0xffffff7d, 0xffffff7e, 0xffffff7f},
14471 device_desc
.feature_level
= &feature_level
;
14472 device_desc
.flags
= 0;
14473 if (!(device
= create_device(&device_desc
)))
14475 skip("Failed to create device for feature level %#x.\n", feature_level
);
14479 ID3D11Device_GetImmediateContext(device
, &context
);
14481 /* Structured buffer views */
14482 buffer_desc
.ByteWidth
= 64;
14483 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
14484 buffer_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
14485 buffer_desc
.CPUAccessFlags
= 0;
14486 buffer_desc
.MiscFlags
= 0;
14487 buffer_desc
.StructureByteStride
= 0;
14488 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
;
14489 buffer_desc
.StructureByteStride
= 4;
14490 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
14491 ok(hr
== S_OK
, "Failed to create a buffer, hr %#x.\n", hr
);
14493 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, NULL
, &uav
);
14494 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
14496 uav_desc
.Format
= DXGI_FORMAT_UNKNOWN
;
14497 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
14498 U(uav_desc
).Buffer
.FirstElement
= 0;
14499 U(uav_desc
).Buffer
.NumElements
= 4;
14500 U(uav_desc
).Buffer
.Flags
= 0;
14501 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav2
);
14502 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
14504 for (i
= 0; i
< ARRAY_SIZE(uvec4_data
); ++i
)
14506 uvec4
= uvec4_data
[i
];
14507 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, &uvec4
.x
);
14508 get_buffer_readback(buffer
, &rb
);
14509 SetRect(&rect
, 0, 0, buffer_desc
.ByteWidth
/ sizeof(uvec4
.x
), 1);
14510 check_readback_data_color(&rb
, &rect
, uvec4
.x
, 0);
14511 release_resource_readback(&rb
);
14513 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav2
, &fe_uvec4
.x
);
14514 get_buffer_readback(buffer
, &rb
);
14515 SetRect(&rect
, 0, 0, U(uav_desc
).Buffer
.NumElements
, 1);
14516 check_readback_data_color(&rb
, &rect
, fe_uvec4
.x
, 0);
14517 SetRect(&rect
, U(uav_desc
).Buffer
.NumElements
, 0, buffer_desc
.ByteWidth
/ sizeof(uvec4
.x
), 1);
14518 check_readback_data_color(&rb
, &rect
, uvec4
.x
, 0);
14519 release_resource_readback(&rb
);
14522 ID3D11Buffer_Release(buffer
);
14523 ID3D11UnorderedAccessView_Release(uav
);
14524 ID3D11UnorderedAccessView_Release(uav2
);
14526 /* Raw buffer views */
14527 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
;
14528 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
14529 ok(hr
== S_OK
, "Failed to create a buffer, hr %#x.\n", hr
);
14531 uav_desc
.Format
= DXGI_FORMAT_R32_TYPELESS
;
14532 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
14533 U(uav_desc
).Buffer
.FirstElement
= 0;
14534 U(uav_desc
).Buffer
.NumElements
= 16;
14535 U(uav_desc
).Buffer
.Flags
= D3D11_BUFFER_UAV_FLAG_RAW
;
14536 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
14537 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
14538 U(uav_desc
).Buffer
.FirstElement
= 8;
14539 U(uav_desc
).Buffer
.NumElements
= 8;
14540 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav2
);
14541 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
14543 for (i
= 0; i
< ARRAY_SIZE(uvec4_data
); ++i
)
14545 uvec4
= uvec4_data
[i
];
14546 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, &uvec4
.x
);
14547 get_buffer_readback(buffer
, &rb
);
14548 SetRect(&rect
, 0, 0, buffer_desc
.ByteWidth
/ sizeof(uvec4
.x
), 1);
14549 check_readback_data_color(&rb
, &rect
, uvec4
.x
, 0);
14550 release_resource_readback(&rb
);
14552 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav2
, &fe_uvec4
.x
);
14553 get_buffer_readback(buffer
, &rb
);
14554 SetRect(&rect
, 0, 0, U(uav_desc
).Buffer
.FirstElement
, 1);
14555 check_readback_data_color(&rb
, &rect
, uvec4
.x
, 0);
14556 SetRect(&rect
, U(uav_desc
).Buffer
.FirstElement
, 0, buffer_desc
.ByteWidth
/ sizeof(uvec4
.x
), 1);
14557 check_readback_data_color(&rb
, &rect
, fe_uvec4
.x
, 0);
14558 release_resource_readback(&rb
);
14561 ID3D11Buffer_Release(buffer
);
14562 ID3D11UnorderedAccessView_Release(uav
);
14563 ID3D11UnorderedAccessView_Release(uav2
);
14565 /* Typed buffer views */
14566 buffer_desc
.MiscFlags
= 0;
14567 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
14568 ok(hr
== S_OK
, "Failed to create a buffer, hr %#x.\n", hr
);
14570 uav_desc
.Format
= DXGI_FORMAT_R32_SINT
;
14571 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
14572 U(uav_desc
).Buffer
.FirstElement
= 0;
14573 U(uav_desc
).Buffer
.NumElements
= 16;
14574 U(uav_desc
).Buffer
.Flags
= 0;
14575 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
14576 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
14577 U(uav_desc
).Buffer
.FirstElement
= 9;
14578 U(uav_desc
).Buffer
.NumElements
= 7;
14579 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav2
);
14580 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
14582 for (i
= 0; i
< ARRAY_SIZE(uvec4_data
); ++i
)
14584 uvec4
= uvec4_data
[i
];
14585 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, &uvec4
.x
);
14586 get_buffer_readback(buffer
, &rb
);
14587 SetRect(&rect
, 0, 0, buffer_desc
.ByteWidth
/ sizeof(uvec4
.x
), 1);
14588 check_readback_data_color(&rb
, &rect
, uvec4
.x
, 0);
14589 release_resource_readback(&rb
);
14591 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav2
, &fe_uvec4
.x
);
14592 get_buffer_readback(buffer
, &rb
);
14593 SetRect(&rect
, 0, 0, U(uav_desc
).Buffer
.FirstElement
, 1);
14594 check_readback_data_color(&rb
, &rect
, uvec4
.x
, 0);
14595 SetRect(&rect
, U(uav_desc
).Buffer
.FirstElement
, 0, buffer_desc
.ByteWidth
/ sizeof(uvec4
.x
), 1);
14596 check_readback_data_color(&rb
, &rect
, fe_uvec4
.x
, 0);
14597 release_resource_readback(&rb
);
14600 ID3D11UnorderedAccessView_Release(uav
);
14601 ID3D11UnorderedAccessView_Release(uav2
);
14603 uav_desc
.Format
= DXGI_FORMAT_R32G32B32A32_SINT
;
14604 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
14605 U(uav_desc
).Buffer
.FirstElement
= 0;
14606 U(uav_desc
).Buffer
.NumElements
= 4;
14607 U(uav_desc
).Buffer
.Flags
= 0;
14608 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
14609 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
14610 U(uav_desc
).Buffer
.FirstElement
= 2;
14611 U(uav_desc
).Buffer
.NumElements
= 2;
14612 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav2
);
14613 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
14615 for (i
= 0; i
< ARRAY_SIZE(uvec4_data
); ++i
)
14617 const struct uvec4
*data
= NULL
;
14620 uvec4
= uvec4_data
[i
];
14621 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, &uvec4
.x
);
14622 get_buffer_readback(buffer
, &rb
);
14623 for (x
= 0, all_match
= TRUE
; x
< buffer_desc
.ByteWidth
/ sizeof(uvec4
); ++x
)
14625 const struct uvec4 broken_result
= {uvec4
.x
, uvec4
.x
, uvec4
.x
, uvec4
.x
}; /* Intel */
14626 data
= get_readback_uvec4(&rb
, x
, 0);
14627 if (!(compare_uvec4(data
, &uvec4
) || broken(compare_uvec4(data
, &broken_result
))))
14630 ok(all_match
, "Got {%#x, %#x, %#x, %#x}, expected {%#x, %#x, %#x, %#x} at %u.\n",
14631 data
->x
, data
->y
, data
->z
, data
->w
, uvec4
.x
, uvec4
.y
, uvec4
.z
, uvec4
.w
, x
);
14632 release_resource_readback(&rb
);
14634 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav2
, &fe_uvec4
.x
);
14635 get_buffer_readback(buffer
, &rb
);
14636 for (x
= 0, all_match
= TRUE
; x
< buffer_desc
.ByteWidth
/ sizeof(uvec4
); ++x
)
14638 struct uvec4 broken_result
;
14639 data
= get_readback_uvec4(&rb
, x
, 0);
14640 uvec4
= U(uav_desc
).Buffer
.FirstElement
<= x
? fe_uvec4
: uvec4_data
[i
];
14641 broken_result
.x
= broken_result
.y
= broken_result
.z
= broken_result
.w
= uvec4
.x
;
14642 if (!(compare_uvec4(data
, &uvec4
) || broken(compare_uvec4(data
, &broken_result
))))
14645 ok(all_match
, "Got {%#x, %#x, %#x, %#x}, expected {%#x, %#x, %#x, %#x} at %u.\n",
14646 data
->x
, data
->y
, data
->z
, data
->w
, uvec4
.x
, uvec4
.y
, uvec4
.z
, uvec4
.w
, x
);
14647 release_resource_readback(&rb
);
14650 uvec4
.x
= uvec4
.y
= uvec4
.z
= uvec4
.w
= 0xdeadbeef;
14651 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, &uvec4
.x
);
14652 ID3D11UnorderedAccessView_Release(uav
);
14653 ID3D11UnorderedAccessView_Release(uav2
);
14655 uav_desc
.Format
= DXGI_FORMAT_R8G8B8A8_SINT
;
14656 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
14657 U(uav_desc
).Buffer
.FirstElement
= 0;
14658 U(uav_desc
).Buffer
.NumElements
= 16;
14659 U(uav_desc
).Buffer
.Flags
= 0;
14660 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
14661 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
14662 U(uav_desc
).Buffer
.FirstElement
= 8;
14663 U(uav_desc
).Buffer
.NumElements
= 8;
14664 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav2
);
14665 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
14667 for (i
= 0; i
< ARRAY_SIZE(uvec4_data
); ++i
)
14669 uvec4
= uvec4_data
[i
];
14670 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, &uvec4
.x
);
14671 get_buffer_readback(buffer
, &rb
);
14672 todo_wine
check_rgba_sint8(get_readback_color(&rb
, 0, 0, 0), &uvec4
);
14673 todo_wine
check_rgba_sint8(get_readback_color(&rb
, 7, 0, 0), &uvec4
);
14674 todo_wine
check_rgba_sint8(get_readback_color(&rb
, 15, 0, 0), &uvec4
);
14675 release_resource_readback(&rb
);
14677 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav2
, &fe_uvec4
.x
);
14678 get_buffer_readback(buffer
, &rb
);
14679 todo_wine
check_rgba_sint8(get_readback_color(&rb
, 0, 0, 0), &uvec4
);
14680 todo_wine
check_rgba_sint8(get_readback_color(&rb
, U(uav_desc
).Buffer
.FirstElement
- 1, 0, 0), &uvec4
);
14681 todo_wine
check_rgba_sint8(get_readback_color(&rb
, U(uav_desc
).Buffer
.FirstElement
, 0, 0), &fe_uvec4
);
14682 release_resource_readback(&rb
);
14685 ID3D11UnorderedAccessView_Release(uav
);
14686 ID3D11UnorderedAccessView_Release(uav2
);
14688 ID3D11Buffer_Release(buffer
);
14690 ID3D11DeviceContext_Release(context
);
14691 refcount
= ID3D11Device_Release(device
);
14692 ok(!refcount
, "Device has %u references left.\n", refcount
);
14695 static void test_initial_depth_stencil_state(void)
14697 static const struct vec4 green
= {0.0f
, 1.0f
, 0.0f
, 1.0f
};
14698 static const struct vec4 red
= {1.0f
, 0.0f
, 0.0f
, 1.0f
};
14699 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
14700 struct d3d11_test_context test_context
;
14701 D3D11_TEXTURE2D_DESC texture_desc
;
14702 ID3D11DeviceContext
*context
;
14703 ID3D11DepthStencilView
*dsv
;
14704 ID3D11Texture2D
*texture
;
14705 ID3D11Device
*device
;
14706 unsigned int count
;
14710 if (!init_test_context(&test_context
, NULL
))
14713 device
= test_context
.device
;
14714 context
= test_context
.immediate_context
;
14716 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
14717 texture_desc
.Format
= DXGI_FORMAT_D32_FLOAT
;
14718 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
14719 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
14720 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
14722 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, NULL
, &dsv
);
14723 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
14725 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &test_context
.backbuffer_rtv
, dsv
);
14728 ID3D11DeviceContext_RSGetViewports(context
, &count
, &vp
);
14730 /* check if depth function is D3D11_COMPARISON_LESS */
14731 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
14732 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 0.5f
, 0);
14733 set_viewport(context
, vp
.TopLeftX
, vp
.TopLeftY
, vp
.Width
, vp
.Height
, 0.4f
, 0.4f
);
14734 draw_color_quad(&test_context
, &green
);
14735 draw_color_quad(&test_context
, &red
);
14736 set_viewport(context
, vp
.TopLeftX
, vp
.TopLeftY
, vp
.Width
, vp
.Height
, 0.6f
, 0.6f
);
14737 draw_color_quad(&test_context
, &red
);
14738 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
14739 check_texture_float(texture
, 0.4f
, 1);
14741 ID3D11DepthStencilView_Release(dsv
);
14742 ID3D11Texture2D_Release(texture
);
14743 release_test_context(&test_context
);
14746 static void test_draw_depth_only(void)
14748 struct d3d11_test_context test_context
;
14749 ID3D11PixelShader
*ps_color
, *ps_depth
;
14750 D3D11_TEXTURE2D_DESC texture_desc
;
14751 ID3D11DeviceContext
*context
;
14752 ID3D11DepthStencilView
*dsv
;
14753 struct resource_readback rb
;
14754 ID3D11Texture2D
*texture
;
14755 ID3D11Device
*device
;
14761 static const DWORD ps_color_code
[] =
14764 float4
main(float4 position
: SV_POSITION
) : SV_Target
14766 return float4(0.0, 1.0, 0.0, 1.0);
14769 0x43425844, 0x30240e72, 0x012f250c, 0x8673c6ea, 0x392e4cec, 0x00000001, 0x000000d4, 0x00000003,
14770 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
14771 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
14772 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
14773 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000038, 0x00000040,
14774 0x0000000e, 0x03000065, 0x001020f2, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002,
14775 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e,
14777 static const DWORD ps_depth_code
[] =
14782 float main() : SV_Depth
14787 0x43425844, 0x91af6cd0, 0x7e884502, 0xcede4f54, 0x6f2c9326, 0x00000001, 0x000000b0, 0x00000003,
14788 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
14789 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff,
14790 0x00000e01, 0x445f5653, 0x68747065, 0xababab00, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
14791 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x02000065, 0x0000c001, 0x05000036, 0x0000c001,
14792 0x0020800a, 0x00000000, 0x00000000, 0x0100003e,
14795 if (!init_test_context(&test_context
, NULL
))
14798 device
= test_context
.device
;
14799 context
= test_context
.immediate_context
;
14801 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(depth
), NULL
);
14803 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
14804 texture_desc
.Format
= DXGI_FORMAT_D32_FLOAT
;
14805 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
14806 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
14807 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
14809 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, NULL
, &dsv
);
14810 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
14812 hr
= ID3D11Device_CreatePixelShader(device
, ps_color_code
, sizeof(ps_color_code
), NULL
, &ps_color
);
14813 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
14814 hr
= ID3D11Device_CreatePixelShader(device
, ps_depth_code
, sizeof(ps_depth_code
), NULL
, &ps_depth
);
14815 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
14817 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
14818 ID3D11DeviceContext_PSSetShader(context
, ps_color
, NULL
, 0);
14819 ID3D11DeviceContext_OMSetRenderTargets(context
, 0, NULL
, dsv
);
14821 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
14822 check_texture_float(texture
, 1.0f
, 1);
14823 draw_quad(&test_context
);
14824 check_texture_float(texture
, 0.0f
, 1);
14826 ID3D11DeviceContext_PSSetShader(context
, ps_depth
, NULL
, 0);
14829 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &depth
, 0, 0);
14830 draw_quad(&test_context
);
14831 check_texture_float(texture
, 0.0f
, 1);
14832 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
14833 check_texture_float(texture
, 1.0f
, 1);
14834 draw_quad(&test_context
);
14835 check_texture_float(texture
, 0.7f
, 1);
14837 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &depth
, 0, 0);
14838 draw_quad(&test_context
);
14839 check_texture_float(texture
, 0.7f
, 1);
14841 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &depth
, 0, 0);
14842 draw_quad(&test_context
);
14843 check_texture_float(texture
, 0.5f
, 1);
14845 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
14846 for (i
= 0; i
< 4; ++i
)
14848 for (j
= 0; j
< 4; ++j
)
14850 depth
.x
= 1.0f
/ 16.0f
* (j
+ 4 * i
);
14851 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &depth
, 0, 0);
14853 set_viewport(context
, 160.0f
* j
, 120.0f
* i
, 160.0f
, 120.0f
, 0.0f
, 1.0f
);
14855 draw_quad(&test_context
);
14858 get_texture_readback(texture
, 0, &rb
);
14859 for (i
= 0; i
< 4; ++i
)
14861 for (j
= 0; j
< 4; ++j
)
14863 float obtained_depth
, expected_depth
;
14865 obtained_depth
= get_readback_float(&rb
, 80 + j
* 160, 60 + i
* 120);
14866 expected_depth
= 1.0f
/ 16.0f
* (j
+ 4 * i
);
14867 ok(compare_float(obtained_depth
, expected_depth
, 1),
14868 "Got unexpected depth %.8e at (%u, %u), expected %.8e.\n",
14869 obtained_depth
, j
, i
, expected_depth
);
14872 release_resource_readback(&rb
);
14874 ID3D11Buffer_Release(cb
);
14875 ID3D11PixelShader_Release(ps_color
);
14876 ID3D11PixelShader_Release(ps_depth
);
14877 ID3D11DepthStencilView_Release(dsv
);
14878 ID3D11Texture2D_Release(texture
);
14879 release_test_context(&test_context
);
14882 static void test_draw_uav_only(void)
14884 struct d3d11_test_context test_context
;
14885 D3D11_TEXTURE2D_DESC texture_desc
;
14886 ID3D11UnorderedAccessView
*uav
;
14887 ID3D11DeviceContext
*context
;
14888 ID3D11Texture2D
*texture
;
14889 ID3D11PixelShader
*ps
;
14890 ID3D11Device
*device
;
14893 static const DWORD ps_code
[] =
14896 RWTexture2D
<int> u
;
14900 InterlockedAdd(u
[uint2(0, 0)], 1);
14903 0x43425844, 0x237a8398, 0xe7b34c17, 0xa28c91a4, 0xb3614d73, 0x00000001, 0x0000009c, 0x00000003,
14904 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
14905 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000048, 0x00000050, 0x00000012, 0x0100086a,
14906 0x0400189c, 0x0011e000, 0x00000000, 0x00003333, 0x0a0000ad, 0x0011e000, 0x00000000, 0x00004002,
14907 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00004001, 0x00000001, 0x0100003e,
14909 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
14910 static const UINT values
[4] = {0};
14912 if (!init_test_context(&test_context
, &feature_level
))
14915 device
= test_context
.device
;
14916 context
= test_context
.immediate_context
;
14918 texture_desc
.Width
= 1;
14919 texture_desc
.Height
= 1;
14920 texture_desc
.MipLevels
= 1;
14921 texture_desc
.ArraySize
= 1;
14922 texture_desc
.Format
= DXGI_FORMAT_R32_SINT
;
14923 texture_desc
.SampleDesc
.Count
= 1;
14924 texture_desc
.SampleDesc
.Quality
= 0;
14925 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
14926 texture_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
14927 texture_desc
.CPUAccessFlags
= 0;
14928 texture_desc
.MiscFlags
= 0;
14930 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
14931 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
14933 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)texture
, NULL
, &uav
);
14934 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
14936 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
14937 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
14939 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
14940 ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context
, 0, NULL
, NULL
,
14943 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, values
);
14944 set_viewport(context
, 0.0f
, 0.0f
, 10.0f
, 10.0f
, 0.0f
, 0.0f
);
14945 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, values
);
14946 draw_quad(&test_context
);
14947 check_texture_color(texture
, 100, 1);
14949 draw_quad(&test_context
);
14950 draw_quad(&test_context
);
14951 draw_quad(&test_context
);
14952 draw_quad(&test_context
);
14953 check_texture_color(texture
, 500, 1);
14955 ID3D11PixelShader_Release(ps
);
14956 ID3D11Texture2D_Release(texture
);
14957 ID3D11UnorderedAccessView_Release(uav
);
14958 release_test_context(&test_context
);
14961 static void test_cb_relative_addressing(void)
14963 struct d3d11_test_context test_context
;
14964 ID3D11Buffer
*colors_cb
, *index_cb
;
14965 unsigned int i
, index
[4] = {0};
14966 ID3D11DeviceContext
*context
;
14967 ID3D11PixelShader
*ps
;
14968 ID3D11Device
*device
;
14971 static const DWORD vs_code
[] =
14983 float4 position
: POSITION
;
14988 float4 position
: SV_POSITION
;
14989 float4 color
: COLOR
;
14992 vs_out
main(const vs_in v
)
14996 o
.position
= v
.position
;
14997 o
.color
= colors
[color_index
];
15002 0x43425844, 0xc2eb30bf, 0x2868c855, 0xaa34b609, 0x1f4957d4, 0x00000001, 0x00000164, 0x00000003,
15003 0x0000002c, 0x00000060, 0x000000b4, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
15004 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
15005 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
15006 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
15007 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x58454853, 0x000000a8, 0x00010050,
15008 0x0000002a, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04000859, 0x00208e46,
15009 0x00000001, 0x00000008, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000,
15010 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x02000068, 0x00000001, 0x05000036, 0x001020f2,
15011 0x00000000, 0x00101e46, 0x00000000, 0x06000036, 0x00100012, 0x00000000, 0x0020800a, 0x00000000,
15012 0x00000000, 0x07000036, 0x001020f2, 0x00000001, 0x04208e46, 0x00000001, 0x0010000a, 0x00000000,
15015 static const DWORD ps_code
[] =
15020 float4 position
: SV_POSITION
;
15021 float4 color
: COLOR
;
15024 float4
main(const ps_in v
) : SV_TARGET
15029 0x43425844, 0x1a6def50, 0x9c069300, 0x7cce68f0, 0x621239b9, 0x00000001, 0x000000f8, 0x00000003,
15030 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
15031 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
15032 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
15033 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
15034 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x58454853, 0x0000003c, 0x00000050,
15035 0x0000000f, 0x0100086a, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
15036 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
15038 static const struct
15044 {{0.0f
, 0.0f
, 0.0f
, 1.0f
}},
15045 {{0.0f
, 0.0f
, 1.0f
, 0.0f
}},
15046 {{0.0f
, 0.0f
, 1.0f
, 1.0f
}},
15047 {{0.0f
, 1.0f
, 0.0f
, 0.0f
}},
15048 {{0.0f
, 1.0f
, 0.0f
, 1.0f
}},
15049 {{0.0f
, 1.0f
, 1.0f
, 0.0f
}},
15050 {{0.0f
, 1.0f
, 1.0f
, 1.0f
}},
15051 {{1.0f
, 0.0f
, 0.0f
, 0.0f
}},
15052 {{1.0f
, 0.0f
, 0.0f
, 1.0f
}},
15053 {{1.0f
, 0.0f
, 1.0f
, 0.0f
}},
15055 static const struct
15057 unsigned int index
;
15074 static const float white_color
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
15075 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
15077 if (!init_test_context(&test_context
, &feature_level
))
15080 device
= test_context
.device
;
15081 context
= test_context
.immediate_context
;
15083 colors_cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(colors
), &colors
);
15084 index_cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(index
), NULL
);
15086 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
15087 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
15089 ID3D11DeviceContext_VSSetConstantBuffers(context
, 0, 1, &index_cb
);
15090 ID3D11DeviceContext_VSSetConstantBuffers(context
, 1, 1, &colors_cb
);
15091 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
15093 for (i
= 0; i
< ARRAY_SIZE(test_data
); ++i
)
15095 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white_color
);
15097 index
[0] = test_data
[i
].index
;
15098 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)index_cb
, 0, NULL
, &index
, 0, 0);
15100 draw_quad_vs(&test_context
, vs_code
, sizeof(vs_code
));
15101 check_texture_color(test_context
.backbuffer
, test_data
[i
].expected
, 1);
15104 ID3D11Buffer_Release(index_cb
);
15105 ID3D11Buffer_Release(colors_cb
);
15106 ID3D11PixelShader_Release(ps
);
15108 release_test_context(&test_context
);
15111 static void test_vs_input_relative_addressing(void)
15113 struct d3d11_test_context test_context
;
15114 ID3D11DeviceContext
*context
;
15115 unsigned int offset
, stride
;
15116 unsigned int index
[4] = {0};
15117 ID3D11PixelShader
*ps
;
15118 ID3D11Buffer
*vb
, *cb
;
15119 ID3D11Device
*device
;
15123 static const DWORD vs_code
[] =
15128 float4 position
: POSITION
;
15129 float4 colors
[4] : COLOR
;
15134 void main(vertex vin
, out float4 position
: SV_Position
,
15135 out float4 color
: COLOR
)
15137 position
= vin
.position
;
15138 color
= vin
.colors
[index
];
15141 0x43425844, 0x8623dd89, 0xe37fecf5, 0xea3fdfe1, 0xdf36e4e4, 0x00000001, 0x000001f4, 0x00000003,
15142 0x0000002c, 0x000000c4, 0x00000118, 0x4e475349, 0x00000090, 0x00000005, 0x00000008, 0x00000080,
15143 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000089, 0x00000000, 0x00000000,
15144 0x00000003, 0x00000001, 0x00000f0f, 0x00000089, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
15145 0x00000f0f, 0x00000089, 0x00000002, 0x00000000, 0x00000003, 0x00000003, 0x00000f0f, 0x00000089,
15146 0x00000003, 0x00000000, 0x00000003, 0x00000004, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x4c4f4300,
15147 0xab00524f, 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001,
15148 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001,
15149 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x000000d4,
15150 0x00010040, 0x00000035, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005f, 0x001010f2,
15151 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x0300005f, 0x001010f2, 0x00000002, 0x0300005f,
15152 0x001010f2, 0x00000003, 0x0300005f, 0x001010f2, 0x00000004, 0x04000067, 0x001020f2, 0x00000000,
15153 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x02000068, 0x00000001, 0x0400005b, 0x001010f2,
15154 0x00000001, 0x00000004, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x06000036,
15155 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x07000036, 0x001020f2, 0x00000001,
15156 0x00d01e46, 0x00000001, 0x0010000a, 0x00000000, 0x0100003e,
15158 static const DWORD ps_code
[] =
15163 float4 position
: SV_POSITION
;
15164 float4 color
: COLOR
;
15167 float4
main(struct vs_out i
) : SV_TARGET
15172 0x43425844, 0xe2087fa6, 0xa35fbd95, 0x8e585b3f, 0x67890f54, 0x00000001, 0x000000f4, 0x00000003,
15173 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
15174 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
15175 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
15176 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
15177 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040,
15178 0x0000000e, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
15179 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
15181 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
15183 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
15184 {"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM
, 1, 0, D3D11_INPUT_PER_INSTANCE_DATA
, 1},
15185 {"COLOR", 1, DXGI_FORMAT_R8G8B8A8_UNORM
, 1, 4, D3D11_INPUT_PER_INSTANCE_DATA
, 1},
15186 {"COLOR", 2, DXGI_FORMAT_R8G8B8A8_UNORM
, 1, 8, D3D11_INPUT_PER_INSTANCE_DATA
, 1},
15187 {"COLOR", 3, DXGI_FORMAT_R8G8B8A8_UNORM
, 1, 12, D3D11_INPUT_PER_INSTANCE_DATA
, 1},
15189 static const unsigned int colors
[] = {0xff0000ff, 0xff00ff00, 0xffff0000, 0xff0f0f0f};
15190 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
15192 if (!init_test_context(&test_context
, NULL
))
15194 device
= test_context
.device
;
15195 context
= test_context
.immediate_context
;
15197 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
15198 vs_code
, sizeof(vs_code
), &test_context
.input_layout
);
15199 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
15201 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(index
), NULL
);
15202 ID3D11DeviceContext_VSSetConstantBuffers(context
, 0, 1, &cb
);
15204 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(colors
), colors
);
15205 stride
= sizeof(colors
);
15207 ID3D11DeviceContext_IASetVertexBuffers(context
, 1, 1, &vb
, &stride
, &offset
);
15209 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
15210 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
15211 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
15213 for (i
= 0; i
< ARRAY_SIZE(colors
); ++i
)
15216 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, index
, 0, 0);
15217 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
15218 draw_quad_vs(&test_context
, vs_code
, sizeof(vs_code
));
15219 check_texture_color(test_context
.backbuffer
, colors
[i
], 1);
15222 ID3D11Buffer_Release(cb
);
15223 ID3D11Buffer_Release(vb
);
15224 ID3D11PixelShader_Release(ps
);
15225 release_test_context(&test_context
);
15228 static void test_getdc(void)
15230 static const struct
15233 DXGI_FORMAT format
;
15234 BOOL getdc_supported
;
15238 {"B8G8R8A8_UNORM", DXGI_FORMAT_B8G8R8A8_UNORM
, TRUE
},
15239 {"B8G8R8A8_TYPELESS", DXGI_FORMAT_B8G8R8A8_TYPELESS
, TRUE
},
15240 {"B8G8R8A8_UNORM_SRGB", DXGI_FORMAT_B8G8R8A8_UNORM_SRGB
, TRUE
},
15241 {"B8G8R8X8_UNORM", DXGI_FORMAT_B8G8R8X8_UNORM
, FALSE
},
15242 {"B8G8R8X8_TYPELESS", DXGI_FORMAT_B8G8R8X8_TYPELESS
, FALSE
},
15243 {"B8G8R8X8_UNORM_SRGB", DXGI_FORMAT_B8G8R8X8_UNORM_SRGB
, FALSE
},
15245 struct device_desc device_desc
;
15246 D3D11_TEXTURE2D_DESC desc
;
15247 ID3D11Texture2D
*texture
;
15248 IDXGISurface1
*surface
;
15249 ID3D11Device
*device
;
15255 device_desc
.feature_level
= NULL
;
15256 device_desc
.flags
= D3D11_CREATE_DEVICE_BGRA_SUPPORT
;
15257 if (!(device
= create_device(&device_desc
)))
15259 skip("Failed to create device.\n");
15263 /* Without D3D11_RESOURCE_MISC_GDI_COMPATIBLE. */
15266 desc
.MipLevels
= 1;
15267 desc
.ArraySize
= 1;
15268 desc
.Format
= DXGI_FORMAT_B8G8R8A8_UNORM
;
15269 desc
.SampleDesc
.Count
= 1;
15270 desc
.SampleDesc
.Quality
= 0;
15271 desc
.Usage
= D3D11_USAGE_DEFAULT
;
15272 desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
15273 desc
.CPUAccessFlags
= 0;
15274 desc
.MiscFlags
= 0;
15275 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
15276 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
15278 hr
= ID3D11Texture2D_QueryInterface(texture
, &IID_IDXGISurface1
, (void**)&surface
);
15279 ok(SUCCEEDED(hr
), "Failed to get IDXGISurface1 interface, hr %#x.\n", hr
);
15281 hr
= IDXGISurface1_GetDC(surface
, FALSE
, &dc
);
15282 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
15284 IDXGISurface1_Release(surface
);
15285 ID3D11Texture2D_Release(texture
);
15287 desc
.MiscFlags
= D3D11_RESOURCE_MISC_GDI_COMPATIBLE
;
15288 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
15289 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
15291 hr
= ID3D11Texture2D_QueryInterface(texture
, &IID_IDXGISurface1
, (void**)&surface
);
15292 ok(SUCCEEDED(hr
), "Failed to get IDXGISurface1 interface, hr %#x.\n", hr
);
15294 hr
= IDXGISurface1_ReleaseDC(surface
, NULL
);
15295 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
15297 hr
= IDXGISurface1_GetDC(surface
, FALSE
, &dc
);
15298 ok(SUCCEEDED(hr
), "Failed to get DC, hr %#x.\n", hr
);
15300 hr
= IDXGISurface1_ReleaseDC(surface
, NULL
);
15301 ok(SUCCEEDED(hr
), "Failed to release DC, hr %#x.\n", hr
);
15303 IDXGISurface1_Release(surface
);
15304 ID3D11Texture2D_Release(texture
);
15306 for (i
= 0; i
< ARRAY_SIZE(testdata
); ++i
)
15308 static const unsigned int bit_count
= 32;
15309 unsigned int width_bytes
;
15317 desc
.MipLevels
= 1;
15318 desc
.ArraySize
= 1;
15319 desc
.Format
= testdata
[i
].format
;
15320 desc
.SampleDesc
.Count
= 1;
15321 desc
.SampleDesc
.Quality
= 0;
15322 desc
.Usage
= D3D11_USAGE_STAGING
;
15323 desc
.BindFlags
= 0;
15324 desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
;
15325 desc
.MiscFlags
= 0;
15327 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
15328 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
15329 ID3D11Texture2D_Release(texture
);
15331 /* STAGING usage, requesting GDI compatibility mode. */
15332 desc
.MiscFlags
= D3D11_RESOURCE_MISC_GDI_COMPATIBLE
;
15333 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
15334 ok(FAILED(hr
), "Expected CreateTexture2D to fail, hr %#x.\n", hr
);
15336 desc
.Usage
= D3D11_USAGE_DEFAULT
;
15337 desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
15338 desc
.CPUAccessFlags
= 0;
15339 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
15340 if (testdata
[i
].getdc_supported
)
15341 ok(SUCCEEDED(hr
), "Got unexpected hr %#x for format %s.\n", hr
, testdata
[i
].name
);
15343 ok(FAILED(hr
), "Got unexpected hr %#x for format %s.\n", hr
, testdata
[i
].name
);
15348 hr
= ID3D11Texture2D_QueryInterface(texture
, &IID_IDXGISurface1
, (void**)&surface
);
15349 ok(SUCCEEDED(hr
), "Failed to get IDXGISurface1 interface, hr %#x.\n", hr
);
15351 dc
= (void *)0x1234;
15352 hr
= IDXGISurface1_GetDC(surface
, FALSE
, &dc
);
15353 ok(SUCCEEDED(hr
), "Got unexpected hr %#x for format %s.\n", hr
, testdata
[i
].name
);
15357 IDXGISurface1_Release(surface
);
15358 ID3D11Texture2D_Release(texture
);
15362 type
= GetObjectType(dc
);
15363 ok(type
== OBJ_MEMDC
, "Got unexpected object type %#x for format %s.\n", type
, testdata
[i
].name
);
15364 bitmap
= GetCurrentObject(dc
, OBJ_BITMAP
);
15365 type
= GetObjectType(bitmap
);
15366 ok(type
== OBJ_BITMAP
, "Got unexpected object type %#x for format %s.\n", type
, testdata
[i
].name
);
15368 size
= GetObjectA(bitmap
, sizeof(dib
), &dib
);
15369 ok(size
== sizeof(dib
) || broken(size
== sizeof(dib
.dsBm
)),
15370 "Got unexpected size %d for format %s.\n", size
, testdata
[i
].name
);
15372 ok(!dib
.dsBm
.bmType
, "Got unexpected type %#x for format %s.\n",
15373 dib
.dsBm
.bmType
, testdata
[i
].name
);
15374 ok(dib
.dsBm
.bmWidth
== 64, "Got unexpected width %d for format %s.\n",
15375 dib
.dsBm
.bmWidth
, testdata
[i
].name
);
15376 ok(dib
.dsBm
.bmHeight
== 64, "Got unexpected height %d for format %s.\n",
15377 dib
.dsBm
.bmHeight
, testdata
[i
].name
);
15378 width_bytes
= ((dib
.dsBm
.bmWidth
* bit_count
+ 31) >> 3) & ~3;
15379 ok(dib
.dsBm
.bmWidthBytes
== width_bytes
, "Got unexpected width bytes %d for format %s.\n",
15380 dib
.dsBm
.bmWidthBytes
, testdata
[i
].name
);
15381 ok(dib
.dsBm
.bmPlanes
== 1, "Got unexpected plane count %d for format %s.\n",
15382 dib
.dsBm
.bmPlanes
, testdata
[i
].name
);
15383 ok(dib
.dsBm
.bmBitsPixel
== bit_count
, "Got unexpected bit count %d for format %s.\n",
15384 dib
.dsBm
.bmBitsPixel
, testdata
[i
].name
);
15386 if (size
== sizeof(dib
))
15387 ok(!!dib
.dsBm
.bmBits
, "Got unexpected bits %p for format %s.\n",
15388 dib
.dsBm
.bmBits
, testdata
[i
].name
);
15390 ok(!dib
.dsBm
.bmBits
, "Got unexpected bits %p for format %s.\n",
15391 dib
.dsBm
.bmBits
, testdata
[i
].name
);
15393 if (size
== sizeof(dib
))
15395 ok(dib
.dsBmih
.biSize
== sizeof(dib
.dsBmih
), "Got unexpected size %u for format %s.\n",
15396 dib
.dsBmih
.biSize
, testdata
[i
].name
);
15397 ok(dib
.dsBmih
.biWidth
== 64, "Got unexpected width %d for format %s.\n",
15398 dib
.dsBmih
.biHeight
, testdata
[i
].name
);
15399 ok(dib
.dsBmih
.biHeight
== 64, "Got unexpected height %d for format %s.\n",
15400 dib
.dsBmih
.biHeight
, testdata
[i
].name
);
15401 ok(dib
.dsBmih
.biPlanes
== 1, "Got unexpected plane count %u for format %s.\n",
15402 dib
.dsBmih
.biPlanes
, testdata
[i
].name
);
15403 ok(dib
.dsBmih
.biBitCount
== bit_count
, "Got unexpected bit count %u for format %s.\n",
15404 dib
.dsBmih
.biBitCount
, testdata
[i
].name
);
15405 ok(dib
.dsBmih
.biCompression
== BI_RGB
, "Got unexpected compression %#x for format %s.\n",
15406 dib
.dsBmih
.biCompression
, testdata
[i
].name
);
15407 ok(!dib
.dsBmih
.biSizeImage
, "Got unexpected image size %u for format %s.\n",
15408 dib
.dsBmih
.biSizeImage
, testdata
[i
].name
);
15409 ok(!dib
.dsBmih
.biXPelsPerMeter
, "Got unexpected horizontal resolution %d for format %s.\n",
15410 dib
.dsBmih
.biXPelsPerMeter
, testdata
[i
].name
);
15411 ok(!dib
.dsBmih
.biYPelsPerMeter
, "Got unexpected vertical resolution %d for format %s.\n",
15412 dib
.dsBmih
.biYPelsPerMeter
, testdata
[i
].name
);
15413 ok(!dib
.dsBmih
.biClrUsed
, "Got unexpected used colour count %u for format %s.\n",
15414 dib
.dsBmih
.biClrUsed
, testdata
[i
].name
);
15415 ok(!dib
.dsBmih
.biClrImportant
, "Got unexpected important colour count %u for format %s.\n",
15416 dib
.dsBmih
.biClrImportant
, testdata
[i
].name
);
15417 ok(!dib
.dsBitfields
[0] && !dib
.dsBitfields
[1] && !dib
.dsBitfields
[2],
15418 "Got unexpected colour masks 0x%08x 0x%08x 0x%08x for format %s.\n",
15419 dib
.dsBitfields
[0], dib
.dsBitfields
[1], dib
.dsBitfields
[2], testdata
[i
].name
);
15420 ok(!dib
.dshSection
, "Got unexpected section %p for format %s.\n", dib
.dshSection
, testdata
[i
].name
);
15421 ok(!dib
.dsOffset
, "Got unexpected offset %u for format %s.\n", dib
.dsOffset
, testdata
[i
].name
);
15424 hr
= IDXGISurface1_ReleaseDC(surface
, NULL
);
15425 ok(hr
== S_OK
, "Failed to release DC, hr %#x.\n", hr
);
15427 IDXGISurface1_Release(surface
);
15428 ID3D11Texture2D_Release(texture
);
15431 refcount
= ID3D11Device_Release(device
);
15432 ok(!refcount
, "Device has %u references left.\n", refcount
);
15435 static void test_shader_stage_input_output_matching(void)
15437 struct d3d11_test_context test_context
;
15438 D3D11_TEXTURE2D_DESC texture_desc
;
15439 ID3D11Texture2D
*render_target
;
15440 ID3D11RenderTargetView
*rtv
[2];
15441 ID3D11DeviceContext
*context
;
15442 ID3D11VertexShader
*vs
;
15443 ID3D11PixelShader
*ps
;
15444 ID3D11Device
*device
;
15447 static const DWORD vs_code
[] =
15452 float4 position
: SV_PoSiTion
;
15453 float4 color0
: COLOR0
;
15454 float4 color1
: COLOR1
;
15457 void main(uint id
: SV_VertexID
, out output o
)
15459 float2 coords
= float2((id
<< 1) & 2, id
& 2);
15460 o
.position
= float4(coords
* float2(2, -2) + float2(-1, 1), 0, 1);
15461 o
.color0
= float4(1.0f
, 0.0f
, 0.0f
, 1.0f
);
15462 o
.color1
= float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
15465 0x43425844, 0x93c216a1, 0xbaa7e8d4, 0xd5368c6a, 0x4e889e07, 0x00000001, 0x00000224, 0x00000003,
15466 0x0000002c, 0x00000060, 0x000000cc, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
15467 0x00000000, 0x00000006, 0x00000001, 0x00000000, 0x00000101, 0x565f5653, 0x65747265, 0x00444978,
15468 0x4e47534f, 0x00000064, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003,
15469 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
15470 0x0000005c, 0x00000001, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x505f5653, 0x5469536f,
15471 0x006e6f69, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000150, 0x00010040, 0x00000054, 0x04000060,
15472 0x00101012, 0x00000000, 0x00000006, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065,
15473 0x001020f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068, 0x00000001, 0x07000029,
15474 0x00100012, 0x00000000, 0x0010100a, 0x00000000, 0x00004001, 0x00000001, 0x07000001, 0x00100012,
15475 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000002, 0x07000001, 0x00100042, 0x00000000,
15476 0x0010100a, 0x00000000, 0x00004001, 0x00000002, 0x05000056, 0x00100032, 0x00000000, 0x00100086,
15477 0x00000000, 0x0f000032, 0x00102032, 0x00000000, 0x00100046, 0x00000000, 0x00004002, 0x40000000,
15478 0xc0000000, 0x00000000, 0x00000000, 0x00004002, 0xbf800000, 0x3f800000, 0x00000000, 0x00000000,
15479 0x08000036, 0x001020c2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x3f800000,
15480 0x08000036, 0x001020f2, 0x00000001, 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000,
15481 0x08000036, 0x001020f2, 0x00000002, 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x3f800000,
15484 static const DWORD ps_code
[] =
15489 float4 position
: SV_PoSiTiOn
;
15490 float4 color1
: COLOR1
;
15491 float4 color0
: COLOR0
;
15496 float4 target0
: SV_Target0
;
15497 float4 target1
: SV_Target1
;
15500 void main(const in input i
, out output o
)
15502 o
.target0
= i
.color0
;
15503 o
.target1
= i
.color1
;
15506 0x43425844, 0x620ef963, 0xed8f19fe, 0x7b3a0a53, 0x126ce021, 0x00000001, 0x00000150, 0x00000003,
15507 0x0000002c, 0x00000098, 0x000000e4, 0x4e475349, 0x00000064, 0x00000003, 0x00000008, 0x00000050,
15508 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000001, 0x00000000,
15509 0x00000003, 0x00000001, 0x00000f0f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000002,
15510 0x00000f0f, 0x505f5653, 0x5469536f, 0x006e4f69, 0x4f4c4f43, 0xabab0052, 0x4e47534f, 0x00000044,
15511 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f,
15512 0x00000038, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x545f5653, 0x65677261,
15513 0xabab0074, 0x52444853, 0x00000064, 0x00000040, 0x00000019, 0x03001062, 0x001010f2, 0x00000001,
15514 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x001020f2,
15515 0x00000001, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000002, 0x05000036, 0x001020f2,
15516 0x00000001, 0x00101e46, 0x00000001, 0x0100003e,
15519 if (!init_test_context(&test_context
, NULL
))
15522 device
= test_context
.device
;
15523 context
= test_context
.immediate_context
;
15525 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
15526 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
15527 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
15528 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
15530 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
15531 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &render_target
);
15532 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
15534 rtv
[0] = test_context
.backbuffer_rtv
;
15535 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)render_target
, NULL
, &rtv
[1]);
15536 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
15538 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
15539 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
15540 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST
);
15541 ID3D11DeviceContext_OMSetRenderTargets(context
, 2, rtv
, NULL
);
15542 ID3D11DeviceContext_Draw(context
, 3, 0);
15544 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
15545 check_texture_color(render_target
, 0xff0000ff, 0);
15547 ID3D11RenderTargetView_Release(rtv
[1]);
15548 ID3D11Texture2D_Release(render_target
);
15549 ID3D11PixelShader_Release(ps
);
15550 ID3D11VertexShader_Release(vs
);
15551 release_test_context(&test_context
);
15554 static void test_shader_interstage_interface(void)
15556 struct d3d11_test_context test_context
;
15557 D3D11_TEXTURE2D_DESC texture_desc
;
15558 ID3D11InputLayout
*input_layout
;
15559 ID3D11Texture2D
*render_target
;
15560 ID3D11DeviceContext
*context
;
15561 ID3D11RenderTargetView
*rtv
;
15562 ID3D11VertexShader
*vs
;
15563 ID3D11PixelShader
*ps
;
15564 ID3D11Device
*device
;
15565 UINT stride
, offset
;
15570 static const DWORD vs_code
[] =
15575 float4 position
: SV_Position
;
15576 float2 t0
: TEXCOORD0
;
15577 nointerpolation
float t1
: TEXCOORD1
;
15578 uint t2
: TEXCOORD2
;
15579 uint t3
: TEXCOORD3
;
15580 float t4
: TEXCOORD4
;
15583 void main(in vertex vin
, out vertex vout
)
15588 0x43425844, 0xd55780bf, 0x76866b06, 0x45d697a2, 0xafac2ecd, 0x00000001, 0x000002bc, 0x00000003,
15589 0x0000002c, 0x000000e4, 0x0000019c, 0x4e475349, 0x000000b0, 0x00000006, 0x00000008, 0x00000098,
15590 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x000000a4, 0x00000000, 0x00000000,
15591 0x00000003, 0x00000001, 0x00000303, 0x000000a4, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
15592 0x00000101, 0x000000a4, 0x00000002, 0x00000000, 0x00000001, 0x00000003, 0x00000101, 0x000000a4,
15593 0x00000003, 0x00000000, 0x00000001, 0x00000004, 0x00000101, 0x000000a4, 0x00000004, 0x00000000,
15594 0x00000003, 0x00000005, 0x00000101, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f,
15595 0xababab00, 0x4e47534f, 0x000000b0, 0x00000006, 0x00000008, 0x00000098, 0x00000000, 0x00000001,
15596 0x00000003, 0x00000000, 0x0000000f, 0x000000a4, 0x00000000, 0x00000000, 0x00000003, 0x00000001,
15597 0x00000c03, 0x000000a4, 0x00000004, 0x00000000, 0x00000003, 0x00000001, 0x00000b04, 0x000000a4,
15598 0x00000001, 0x00000000, 0x00000003, 0x00000002, 0x00000e01, 0x000000a4, 0x00000002, 0x00000000,
15599 0x00000001, 0x00000002, 0x00000d02, 0x000000a4, 0x00000003, 0x00000000, 0x00000001, 0x00000002,
15600 0x00000b04, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f, 0xababab00, 0x52444853,
15601 0x00000118, 0x00010040, 0x00000046, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x00101032,
15602 0x00000001, 0x0300005f, 0x00101012, 0x00000002, 0x0300005f, 0x00101012, 0x00000003, 0x0300005f,
15603 0x00101012, 0x00000004, 0x0300005f, 0x00101012, 0x00000005, 0x04000067, 0x001020f2, 0x00000000,
15604 0x00000001, 0x03000065, 0x00102032, 0x00000001, 0x03000065, 0x00102042, 0x00000001, 0x03000065,
15605 0x00102012, 0x00000002, 0x03000065, 0x00102022, 0x00000002, 0x03000065, 0x00102042, 0x00000002,
15606 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x00102032, 0x00000001,
15607 0x00101046, 0x00000001, 0x05000036, 0x00102042, 0x00000001, 0x0010100a, 0x00000005, 0x05000036,
15608 0x00102012, 0x00000002, 0x0010100a, 0x00000002, 0x05000036, 0x00102022, 0x00000002, 0x0010100a,
15609 0x00000003, 0x05000036, 0x00102042, 0x00000002, 0x0010100a, 0x00000004, 0x0100003e,
15611 static const DWORD ps_code
[] =
15614 void main(float4 position
: SV_Position
, float2 t0
: TEXCOORD0
,
15615 nointerpolation
float t1
: TEXCOORD1
, uint t2
: TEXCOORD2
,
15616 uint t3
: TEXCOORD3
, float t4
: TEXCOORD4
, out float4 o
: SV_Target
)
15624 0x43425844, 0x8a7ef706, 0xc8f2cbf1, 0x83a05df1, 0xfab8e613, 0x00000001, 0x000001dc, 0x00000003,
15625 0x0000002c, 0x000000e4, 0x00000118, 0x4e475349, 0x000000b0, 0x00000006, 0x00000008, 0x00000098,
15626 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x000000a4, 0x00000000, 0x00000000,
15627 0x00000003, 0x00000001, 0x00000303, 0x000000a4, 0x00000004, 0x00000000, 0x00000003, 0x00000001,
15628 0x00000404, 0x000000a4, 0x00000001, 0x00000000, 0x00000003, 0x00000002, 0x00000101, 0x000000a4,
15629 0x00000002, 0x00000000, 0x00000001, 0x00000002, 0x00000202, 0x000000a4, 0x00000003, 0x00000000,
15630 0x00000001, 0x00000002, 0x00000404, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f,
15631 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
15632 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000bc,
15633 0x00000040, 0x0000002f, 0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x00101042, 0x00000001,
15634 0x03000862, 0x00101012, 0x00000002, 0x03000862, 0x00101022, 0x00000002, 0x03000862, 0x00101042,
15635 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0700001e, 0x00100012,
15636 0x00000000, 0x0010101a, 0x00000002, 0x0010102a, 0x00000002, 0x05000056, 0x00102022, 0x00000000,
15637 0x0010000a, 0x00000000, 0x07000000, 0x00102012, 0x00000000, 0x0010101a, 0x00000001, 0x0010100a,
15638 0x00000002, 0x05000036, 0x001020c2, 0x00000000, 0x001012a6, 0x00000001, 0x0100003e,
15640 static const DWORD ps_partial_input_code
[] =
15643 void main(float4 position
: SV_Position
, float2 t0
: TEXCOORD0
,
15644 nointerpolation
float t1
: TEXCOORD1
, uint t2
: TEXCOORD2
,
15645 uint t3
: TEXCOORD3
, out float4 o
: SV_Target
)
15653 0x43425844, 0x5b1db356, 0xaa5a5e9d, 0xb916a081, 0x61e6dcb1, 0x00000001, 0x000001cc, 0x00000003,
15654 0x0000002c, 0x000000cc, 0x00000100, 0x4e475349, 0x00000098, 0x00000005, 0x00000008, 0x00000080,
15655 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000008c, 0x00000000, 0x00000000,
15656 0x00000003, 0x00000001, 0x00000303, 0x0000008c, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
15657 0x00000101, 0x0000008c, 0x00000002, 0x00000000, 0x00000001, 0x00000002, 0x00000202, 0x0000008c,
15658 0x00000003, 0x00000000, 0x00000001, 0x00000002, 0x00000404, 0x505f5653, 0x7469736f, 0x006e6f69,
15659 0x43584554, 0x44524f4f, 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
15660 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074,
15661 0x52444853, 0x000000c4, 0x00000040, 0x00000031, 0x03001062, 0x00101032, 0x00000001, 0x03000862,
15662 0x00101012, 0x00000002, 0x03000862, 0x00101022, 0x00000002, 0x03000862, 0x00101042, 0x00000002,
15663 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0700001e, 0x00100012, 0x00000000,
15664 0x0010102a, 0x00000002, 0x0010101a, 0x00000002, 0x05000056, 0x00102022, 0x00000000, 0x0010000a,
15665 0x00000000, 0x07000000, 0x00102012, 0x00000000, 0x0010101a, 0x00000001, 0x0010100a, 0x00000002,
15666 0x05000036, 0x00102042, 0x00000000, 0x00004001, 0x00000000, 0x05000036, 0x00102082, 0x00000000,
15667 0x0010100a, 0x00000001, 0x0100003e,
15669 static const DWORD ps_single_input_code
[] =
15672 void main(float4 position
: SV_Position
, float2 t0
: TEXCOORD0
, out float4 o
: SV_Target
)
15680 0x43425844, 0x7cc601b6, 0xc65b8bdb, 0x54d0f606, 0x9cc74d3d, 0x00000001, 0x00000118, 0x00000003,
15681 0x0000002c, 0x00000084, 0x000000b8, 0x4e475349, 0x00000050, 0x00000002, 0x00000008, 0x00000038,
15682 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
15683 0x00000003, 0x00000001, 0x00000303, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f,
15684 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
15685 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000058,
15686 0x00000040, 0x00000016, 0x03001062, 0x00101032, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
15687 0x05000036, 0x00102032, 0x00000000, 0x00101046, 0x00000001, 0x08000036, 0x001020c2, 0x00000000,
15688 0x00004002, 0x00000000, 0x00000000, 0x3f800000, 0x40000000, 0x0100003e,
15690 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
15692 {"SV_POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
15693 {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 8, D3D11_INPUT_PER_VERTEX_DATA
, 0},
15694 {"TEXCOORD", 1, DXGI_FORMAT_R32_FLOAT
, 0, 16, D3D11_INPUT_PER_VERTEX_DATA
, 0},
15695 {"TEXCOORD", 2, DXGI_FORMAT_R32_UINT
, 0, 20, D3D11_INPUT_PER_VERTEX_DATA
, 0},
15696 {"TEXCOORD", 3, DXGI_FORMAT_R32_UINT
, 0, 24, D3D11_INPUT_PER_VERTEX_DATA
, 0},
15697 {"TEXCOORD", 4, DXGI_FORMAT_R32_FLOAT
, 0, 28, D3D11_INPUT_PER_VERTEX_DATA
, 0},
15699 static const struct
15701 struct vec2 position
;
15710 {{-1.0f
, -1.0f
}, {3.0f
, 5.0f
}, 5.0f
, 2, 6, 7.0f
},
15711 {{-1.0f
, 1.0f
}, {3.0f
, 5.0f
}, 5.0f
, 2, 6, 7.0f
},
15712 {{ 1.0f
, -1.0f
}, {3.0f
, 5.0f
}, 5.0f
, 2, 6, 7.0f
},
15713 {{ 1.0f
, 1.0f
}, {3.0f
, 5.0f
}, 5.0f
, 2, 6, 7.0f
},
15715 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
15716 static const struct
15718 const DWORD
*ps_code
;
15720 struct vec4 expected_result
;
15724 {ps_code
, sizeof(ps_code
), {10.0f
, 8.0f
, 7.0f
, 3.0f
}},
15725 {ps_partial_input_code
, sizeof(ps_partial_input_code
), {10.0f
, 8.0f
, 0.0f
, 3.0f
}},
15726 {ps_single_input_code
, sizeof(ps_single_input_code
), {3.0f
, 5.0f
, 1.0f
, 2.0f
}},
15729 if (!init_test_context(&test_context
, NULL
))
15732 device
= test_context
.device
;
15733 context
= test_context
.immediate_context
;
15735 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
15736 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
15738 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
15739 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
15740 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &render_target
);
15741 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
15743 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)render_target
, NULL
, &rtv
);
15744 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
15746 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
15747 vs_code
, sizeof(vs_code
), &input_layout
);
15748 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
15750 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(quad
), quad
);
15752 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, white
);
15754 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
15755 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
15756 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
15757 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
15759 stride
= sizeof(*quad
);
15760 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, &stride
, &offset
);
15762 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
15764 hr
= ID3D11Device_CreatePixelShader(device
, tests
[i
].ps_code
, tests
[i
].ps_size
, NULL
, &ps
);
15765 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
15766 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
15767 ID3D11DeviceContext_Draw(context
, 4, 0);
15768 check_texture_vec4(render_target
, &tests
[i
].expected_result
, 0);
15769 ID3D11PixelShader_Release(ps
);
15772 ID3D11InputLayout_Release(input_layout
);
15773 ID3D11RenderTargetView_Release(rtv
);
15774 ID3D11Texture2D_Release(render_target
);
15775 ID3D11VertexShader_Release(vs
);
15776 ID3D11Buffer_Release(vb
);
15777 release_test_context(&test_context
);
15780 static void test_sm4_if_instruction(void)
15782 struct d3d11_test_context test_context
;
15783 ID3D11PixelShader
*ps_if_nz
, *ps_if_z
;
15784 ID3D11DeviceContext
*context
;
15785 ID3D11Device
*device
;
15786 unsigned int bits
[4];
15787 DWORD expected_color
;
15792 static const DWORD ps_if_nz_code
[] =
15797 float4
main() : SV_TARGET
15800 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
15802 return float4(1.0f
, 0.0f
, 0.0f
, 1.0f
);
15805 0x43425844, 0x2a94f6f1, 0xdbe88943, 0x3426a708, 0x09cec990, 0x00000001, 0x00000100, 0x00000003,
15806 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
15807 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
15808 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000088, 0x00000040, 0x00000022,
15809 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x0404001f,
15810 0x0020800a, 0x00000000, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000,
15811 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000012, 0x08000036, 0x001020f2, 0x00000000,
15812 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000015, 0x0100003e,
15814 static const DWORD ps_if_z_code
[] =
15819 float4
main() : SV_TARGET
15822 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
15824 return float4(1.0f
, 0.0f
, 0.0f
, 1.0f
);
15827 0x43425844, 0x2e3030ca, 0x94c8610c, 0xdf0c1b1f, 0x80f2ca2c, 0x00000001, 0x00000100, 0x00000003,
15828 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
15829 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
15830 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000088, 0x00000040, 0x00000022,
15831 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x0400001f,
15832 0x0020800a, 0x00000000, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000,
15833 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000012, 0x08000036, 0x001020f2, 0x00000000,
15834 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000015, 0x0100003e,
15836 static unsigned int bit_patterns
[] =
15838 0x00000000, 0x00000001, 0x10010001, 0x10000000, 0x80000000, 0xffff0000, 0x0000ffff, 0xffffffff,
15841 if (!init_test_context(&test_context
, NULL
))
15844 device
= test_context
.device
;
15845 context
= test_context
.immediate_context
;
15847 hr
= ID3D11Device_CreatePixelShader(device
, ps_if_nz_code
, sizeof(ps_if_nz_code
), NULL
, &ps_if_nz
);
15848 ok(SUCCEEDED(hr
), "Failed to create if_nz pixel shader, hr %#x.\n", hr
);
15849 hr
= ID3D11Device_CreatePixelShader(device
, ps_if_z_code
, sizeof(ps_if_z_code
), NULL
, &ps_if_z
);
15850 ok(SUCCEEDED(hr
), "Failed to create if_z pixel shader, hr %#x.\n", hr
);
15852 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(bits
), NULL
);
15853 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
15855 for (i
= 0; i
< ARRAY_SIZE(bit_patterns
); ++i
)
15857 *bits
= bit_patterns
[i
];
15858 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, bits
, 0, 0);
15860 ID3D11DeviceContext_PSSetShader(context
, ps_if_nz
, NULL
, 0);
15861 expected_color
= *bits
? 0xff00ff00 : 0xff0000ff;
15862 draw_quad(&test_context
);
15863 check_texture_color(test_context
.backbuffer
, expected_color
, 0);
15865 ID3D11DeviceContext_PSSetShader(context
, ps_if_z
, NULL
, 0);
15866 expected_color
= *bits
? 0xff0000ff : 0xff00ff00;
15867 draw_quad(&test_context
);
15868 check_texture_color(test_context
.backbuffer
, expected_color
, 0);
15871 ID3D11Buffer_Release(cb
);
15872 ID3D11PixelShader_Release(ps_if_z
);
15873 ID3D11PixelShader_Release(ps_if_nz
);
15874 release_test_context(&test_context
);
15877 static void test_sm4_breakc_instruction(void)
15879 struct d3d11_test_context test_context
;
15880 ID3D11DeviceContext
*context
;
15881 ID3D11PixelShader
*ps
;
15882 ID3D11Device
*device
;
15885 static const DWORD ps_breakc_nz_code
[] =
15888 float4
main() : SV_TARGET
15892 for (uint i
= 0; i
< 255; ++i
)
15895 if (counter
== 255)
15896 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
15898 return float4(1.0f
, 0.0f
, 0.0f
, 1.0f
);
15901 0x43425844, 0x065ac80a, 0x24369e7e, 0x218d5dc1, 0x3532868c, 0x00000001, 0x00000188, 0x00000003,
15902 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
15903 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
15904 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000110, 0x00000040, 0x00000044,
15905 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x08000036, 0x00100032, 0x00000000,
15906 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01000030, 0x07000050, 0x00100042,
15907 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0x000000ff, 0x03040003, 0x0010002a, 0x00000000,
15908 0x0a00001e, 0x00100032, 0x00000000, 0x00100046, 0x00000000, 0x00004002, 0x00000001, 0x00000001,
15909 0x00000000, 0x00000000, 0x01000016, 0x07000020, 0x00100012, 0x00000000, 0x0010000a, 0x00000000,
15910 0x00004001, 0x000000ff, 0x0304001f, 0x0010000a, 0x00000000, 0x08000036, 0x001020f2, 0x00000000,
15911 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000012, 0x08000036,
15912 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e,
15913 0x01000015, 0x0100003e,
15915 static const DWORD ps_breakc_z_code
[] =
15918 float4
main() : SV_TARGET
15922 for (int i
= 0, j
= 254; i
< 255 && j
>= 0; ++i
, --j
)
15925 if (counter
== 255)
15926 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
15928 return float4(1.0f
, 0.0f
, 0.0f
, 1.0f
);
15931 0x43425844, 0x687406ef, 0x7bdeb7d1, 0xb3282292, 0x934a9101, 0x00000001, 0x000001c0, 0x00000003,
15932 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
15933 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
15934 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000148, 0x00000040, 0x00000052,
15935 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x08000036, 0x00100072, 0x00000000,
15936 0x00004002, 0x00000000, 0x00000000, 0x000000fe, 0x00000000, 0x01000030, 0x07000022, 0x00100082,
15937 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0x000000ff, 0x07000021, 0x00100012, 0x00000001,
15938 0x0010002a, 0x00000000, 0x00004001, 0x00000000, 0x07000001, 0x00100082, 0x00000000, 0x0010003a,
15939 0x00000000, 0x0010000a, 0x00000001, 0x03000003, 0x0010003a, 0x00000000, 0x0a00001e, 0x00100072,
15940 0x00000000, 0x00100246, 0x00000000, 0x00004002, 0x00000001, 0x00000001, 0xffffffff, 0x00000000,
15941 0x01000016, 0x07000020, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x000000ff,
15942 0x0304001f, 0x0010000a, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000,
15943 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000012, 0x08000036, 0x001020f2, 0x00000000,
15944 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000015, 0x0100003e,
15947 if (!init_test_context(&test_context
, NULL
))
15950 device
= test_context
.device
;
15951 context
= test_context
.immediate_context
;
15953 hr
= ID3D11Device_CreatePixelShader(device
, ps_breakc_nz_code
, sizeof(ps_breakc_nz_code
), NULL
, &ps
);
15954 ok(SUCCEEDED(hr
), "Failed to create breakc_nz pixel shader, hr %#x.\n", hr
);
15955 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
15956 draw_quad(&test_context
);
15957 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
15958 ID3D11PixelShader_Release(ps
);
15960 hr
= ID3D11Device_CreatePixelShader(device
, ps_breakc_z_code
, sizeof(ps_breakc_z_code
), NULL
, &ps
);
15961 ok(SUCCEEDED(hr
), "Failed to create breakc_z pixel shader, hr %#x.\n", hr
);
15962 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
15963 draw_quad(&test_context
);
15964 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
15965 ID3D11PixelShader_Release(ps
);
15967 release_test_context(&test_context
);
15970 static void test_sm4_continuec_instruction(void)
15972 struct d3d11_test_context test_context
;
15973 ID3D11DeviceContext
*context
;
15974 ID3D11PixelShader
*ps
;
15975 ID3D11Device
*device
;
15978 /* To get fxc to output continuec_z/continuec_nz instead of an if-block
15979 * with a normal continue inside, the shaders have been compiled with
15980 * the /Gfa flag. */
15981 static const DWORD ps_continuec_nz_code
[] =
15984 float4
main() : SV_TARGET
15999 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
16001 return float4(1.0f
, 0.0f
, 0.0f
, 1.0f
);
16004 0x43425844, 0xaadaac96, 0xbe00fdfb, 0x29356be0, 0x47e79bd6, 0x00000001, 0x00000208, 0x00000003,
16005 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
16006 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
16007 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000190, 0x00000040, 0x00000064,
16008 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000003, 0x08000036, 0x00100032, 0x00000000,
16009 0x00004002, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x01000030, 0x07000021, 0x00100042,
16010 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0x000000ff, 0x03040003, 0x0010002a, 0x00000000,
16011 0x0700001e, 0x00100022, 0x00000001, 0x0010001a, 0x00000000, 0x00004001, 0x00000001, 0x09000037,
16012 0x00100022, 0x00000002, 0x0010001a, 0x00000001, 0x0010001a, 0x00000001, 0x00004001, 0x00000000,
16013 0x05000036, 0x00100012, 0x00000002, 0x0010000a, 0x00000000, 0x05000036, 0x00100032, 0x00000000,
16014 0x00100046, 0x00000002, 0x05000036, 0x00100042, 0x00000000, 0x0010001a, 0x00000001, 0x03040008,
16015 0x0010002a, 0x00000000, 0x0700001e, 0x00100012, 0x00000001, 0x0010000a, 0x00000000, 0x00004001,
16016 0x00000001, 0x05000036, 0x00100032, 0x00000000, 0x00100046, 0x00000001, 0x01000016, 0x07000020,
16017 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000001, 0x08000036, 0x001020f2,
16018 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x0304003f, 0x0010000a,
16019 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x00000000, 0x00000000,
16020 0x3f800000, 0x0100003e,
16023 static const DWORD ps_continuec_z_code
[] =
16026 float4
main() : SV_TARGET
16040 if (counter
== 255)
16041 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
16043 return float4(1.0f
, 0.0f
, 0.0f
, 1.0f
);
16046 0x43425844, 0x0322b23d, 0x52b25dc8, 0xa625f5f1, 0x271e3f46, 0x00000001, 0x000001d0, 0x00000003,
16047 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
16048 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
16049 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000158, 0x00000040, 0x00000056,
16050 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x08000036, 0x00100032, 0x00000000,
16051 0x00004002, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x01000030, 0x07000021, 0x00100042,
16052 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0x000000ff, 0x03040003, 0x0010002a, 0x00000000,
16053 0x0700001e, 0x00100022, 0x00000001, 0x0010001a, 0x00000000, 0x00004001, 0x00000001, 0x05000036,
16054 0x00100042, 0x00000001, 0x0010000a, 0x00000000, 0x05000036, 0x00100072, 0x00000000, 0x00100966,
16055 0x00000001, 0x03000008, 0x0010002a, 0x00000000, 0x0700001e, 0x00100012, 0x00000001, 0x0010000a,
16056 0x00000000, 0x00004001, 0x00000001, 0x05000036, 0x00100032, 0x00000000, 0x00100046, 0x00000001,
16057 0x01000016, 0x07000020, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x000000ff,
16058 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x3f800000,
16059 0x0304003f, 0x0010000a, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000,
16060 0x00000000, 0x00000000, 0x3f800000, 0x0100003e,
16063 if (!init_test_context(&test_context
, NULL
))
16066 device
= test_context
.device
;
16067 context
= test_context
.immediate_context
;
16069 hr
= ID3D11Device_CreatePixelShader(device
, ps_continuec_nz_code
, sizeof(ps_continuec_nz_code
), NULL
, &ps
);
16070 ok(SUCCEEDED(hr
), "Failed to create continuec_nz pixel shader, hr %#x.\n", hr
);
16071 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
16072 draw_quad(&test_context
);
16073 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
16074 ID3D11PixelShader_Release(ps
);
16076 hr
= ID3D11Device_CreatePixelShader(device
, ps_continuec_z_code
, sizeof(ps_continuec_z_code
), NULL
, &ps
);
16077 ok(SUCCEEDED(hr
), "Failed to create continuec_z pixel shader, hr %#x.\n", hr
);
16078 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
16079 draw_quad(&test_context
);
16080 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
16081 ID3D11PixelShader_Release(ps
);
16083 release_test_context(&test_context
);
16086 static void test_sm4_discard_instruction(void)
16088 ID3D11PixelShader
*ps_discard_nz
, *ps_discard_z
;
16089 struct d3d11_test_context test_context
;
16090 ID3D11DeviceContext
*context
;
16091 ID3D11Device
*device
;
16096 static const DWORD ps_discard_nz_code
[] =
16101 float4
main() : SV_Target
16105 return float4(0.0f
, 0.5f
, 0.0f
, 1.0f
);
16108 0x43425844, 0xfa7e5758, 0xd8716ffc, 0x5ad6a940, 0x2b99bba2, 0x00000001, 0x000000d0, 0x00000003,
16109 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
16110 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
16111 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000058, 0x00000040, 0x00000016,
16112 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x0404000d,
16113 0x0020800a, 0x00000000, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000,
16114 0x3f000000, 0x00000000, 0x3f800000, 0x0100003e,
16116 static const DWORD ps_discard_z_code
[] =
16121 float4
main() : SV_Target
16125 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
16128 0x43425844, 0x5c4dd108, 0x1eb43558, 0x7c02c98c, 0xd81eb34c, 0x00000001, 0x000000d0, 0x00000003,
16129 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
16130 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
16131 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000058, 0x00000040, 0x00000016,
16132 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x0400000d,
16133 0x0020800a, 0x00000000, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000,
16134 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e,
16136 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
16137 static const struct uvec4 values
[] =
16145 if (!init_test_context(&test_context
, NULL
))
16148 device
= test_context
.device
;
16149 context
= test_context
.immediate_context
;
16151 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(*values
), NULL
);
16152 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
16154 hr
= ID3D11Device_CreatePixelShader(device
, ps_discard_nz_code
, sizeof(ps_discard_nz_code
),
16155 NULL
, &ps_discard_nz
);
16156 ok(SUCCEEDED(hr
), "Failed to create discard_nz pixel shader, hr %#x.\n", hr
);
16157 hr
= ID3D11Device_CreatePixelShader(device
, ps_discard_z_code
, sizeof(ps_discard_z_code
),
16158 NULL
, &ps_discard_z
);
16159 ok(SUCCEEDED(hr
), "Failed to create discard_z pixel shader, hr %#x.\n", hr
);
16161 for (i
= 0; i
< ARRAY_SIZE(values
); ++i
)
16163 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &values
[i
], 0, 0);
16165 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
16166 ID3D11DeviceContext_PSSetShader(context
, ps_discard_nz
, NULL
, 0);
16167 draw_quad(&test_context
);
16168 check_texture_color(test_context
.backbuffer
, values
[i
].x
? 0xffffffff : 0xff007f00, 1);
16170 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
16171 ID3D11DeviceContext_PSSetShader(context
, ps_discard_z
, NULL
, 0);
16172 draw_quad(&test_context
);
16173 check_texture_color(test_context
.backbuffer
, values
[i
].x
? 0xff00ff00 : 0xffffffff, 1);
16176 ID3D11Buffer_Release(cb
);
16177 ID3D11PixelShader_Release(ps_discard_nz
);
16178 ID3D11PixelShader_Release(ps_discard_z
);
16179 release_test_context(&test_context
);
16182 static void test_sm5_swapc_instruction(void)
16191 struct d3d11_test_context test_context
;
16192 D3D11_TEXTURE2D_DESC texture_desc
;
16193 ID3D11DeviceContext
*context
;
16194 ID3D11RenderTargetView
*rtv
;
16195 ID3D11Texture2D
*texture
;
16196 ID3D11PixelShader
*ps
[6];
16197 ID3D11Device
*device
;
16202 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
16203 static const DWORD ps_swapc0_code
[] =
16207 dcl_globalFlags refactoringAllowed
16208 dcl_constantbuffer cb0
[3], immediateIndexed
16211 swapc r0
.xyzw
, r1
.xyzw
, cb0
[0].xyzw
, cb0
[1].xyzw
, cb0
[2].xyzw
16212 mov o0
.xyzw
, r0
.xyzw
16215 0x43425844, 0x9e089246, 0x9f8b5cbe, 0xbac66faf, 0xaef23488, 0x00000001, 0x000000f8, 0x00000003,
16216 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
16217 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
16218 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000080, 0x00000050, 0x00000020,
16219 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000003, 0x03000065, 0x001020f2, 0x00000000,
16220 0x02000068, 0x00000002, 0x0e00008e, 0x001000f2, 0x00000000, 0x001000f2, 0x00000001, 0x00208e46,
16221 0x00000000, 0x00000000, 0x00208e46, 0x00000000, 0x00000001, 0x00208e46, 0x00000000, 0x00000002,
16222 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x0100003e,
16224 static const DWORD ps_swapc1_code
[] =
16228 dcl_globalFlags refactoringAllowed
16229 dcl_constantbuffer cb0
[3], immediateIndexed
16232 swapc r0
.xyzw
, r1
.xyzw
, cb0
[0].xyzw
, cb0
[1].xyzw
, cb0
[2].xyzw
16233 mov o0
.xyzw
, r1
.xyzw
16236 0x43425844, 0xf2daed61, 0xede211f7, 0x7300dbea, 0x573ed49f, 0x00000001, 0x000000f8, 0x00000003,
16237 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
16238 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
16239 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000080, 0x00000050, 0x00000020,
16240 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000003, 0x03000065, 0x001020f2, 0x00000000,
16241 0x02000068, 0x00000002, 0x0e00008e, 0x001000f2, 0x00000000, 0x001000f2, 0x00000001, 0x00208e46,
16242 0x00000000, 0x00000000, 0x00208e46, 0x00000000, 0x00000001, 0x00208e46, 0x00000000, 0x00000002,
16243 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x0100003e,
16245 static const DWORD ps_swapc2_code
[] =
16249 dcl_globalFlags refactoringAllowed
16250 dcl_constantbuffer cb0
[3], immediateIndexed
16253 mov r0
.xyzw
, cb0
[1].xyzw
16254 mov r1
.xyzw
, cb0
[2].xyzw
16255 swapc r0
.xyzw
, r1
.xyzw
, cb0
[0].xyzw
, r0
.xyzw
, r1
.xyzw
16256 mov o0
.xyzw
, r0
.xyzw
16259 0x43425844, 0x230fcb22, 0x70d99148, 0x65814d89, 0x97473498, 0x00000001, 0x00000120, 0x00000003,
16260 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
16261 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
16262 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000a8, 0x00000050, 0x0000002a,
16263 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000003, 0x03000065, 0x001020f2, 0x00000000,
16264 0x02000068, 0x00000002, 0x06000036, 0x001000f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000001,
16265 0x06000036, 0x001000f2, 0x00000001, 0x00208e46, 0x00000000, 0x00000002, 0x0c00008e, 0x001000f2,
16266 0x00000000, 0x001000f2, 0x00000001, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000,
16267 0x00100e46, 0x00000001, 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x0100003e,
16269 static const DWORD ps_swapc3_code
[] =
16273 dcl_globalFlags refactoringAllowed
16274 dcl_constantbuffer cb0
[3], immediateIndexed
16277 mov r0
.xyzw
, cb0
[1].xyzw
16278 mov r1
.xyzw
, cb0
[2].xyzw
16279 swapc r0
.xyzw
, r1
.xyzw
, cb0
[0].xyzw
, r0
.xyzw
, r1
.xyzw
16280 mov o0
.xyzw
, r1
.xyzw
16283 0x43425844, 0xce595d62, 0x98305541, 0xb04e74c8, 0xfc010f3a, 0x00000001, 0x00000120, 0x00000003,
16284 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
16285 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
16286 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000a8, 0x00000050, 0x0000002a,
16287 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000003, 0x03000065, 0x001020f2, 0x00000000,
16288 0x02000068, 0x00000002, 0x06000036, 0x001000f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000001,
16289 0x06000036, 0x001000f2, 0x00000001, 0x00208e46, 0x00000000, 0x00000002, 0x0c00008e, 0x001000f2,
16290 0x00000000, 0x001000f2, 0x00000001, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000,
16291 0x00100e46, 0x00000001, 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x0100003e,
16293 static const DWORD ps_swapc4_code
[] =
16297 dcl_globalFlags refactoringAllowed
16298 dcl_constantbuffer cb0
[3], immediateIndexed
16301 mov r0
.xyzw
, cb0
[0].xyzw
16302 swapc r0
.xyzw
, r1
.xyzw
, r0
.xyzw
, cb0
[1].xyzw
, cb0
[2].xyzw
16303 mov o0
.xyzw
, r0
.xyzw
16306 0x43425844, 0x72067c48, 0xb53572a0, 0x9dd9e0fd, 0x903e37e3, 0x00000001, 0x0000010c, 0x00000003,
16307 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
16308 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
16309 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000094, 0x00000050, 0x00000025,
16310 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000003, 0x03000065, 0x001020f2, 0x00000000,
16311 0x02000068, 0x00000002, 0x06000036, 0x001000f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000000,
16312 0x0d00008e, 0x001000f2, 0x00000000, 0x001000f2, 0x00000001, 0x00100e46, 0x00000000, 0x00208e46,
16313 0x00000000, 0x00000001, 0x00208e46, 0x00000000, 0x00000002, 0x05000036, 0x001020f2, 0x00000000,
16314 0x00100e46, 0x00000000, 0x0100003e,
16316 static const DWORD ps_swapc5_code
[] =
16320 dcl_globalFlags refactoringAllowed
16321 dcl_constantbuffer cb0
[3], immediateIndexed
16324 mov r1
.xyzw
, cb0
[0].xyzw
16325 swapc r0
.xyzw
, r1
.xyzw
, r1
.xyzw
, cb0
[1].xyzw
, cb0
[2].xyzw
16326 mov o0
.xyzw
, r1
.xyzw
16329 0x43425844, 0x7078fb08, 0xdd24cd44, 0x469d3258, 0x9e33a0bc, 0x00000001, 0x0000010c, 0x00000003,
16330 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
16331 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
16332 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000094, 0x00000050, 0x00000025,
16333 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000003, 0x03000065, 0x001020f2, 0x00000000,
16334 0x02000068, 0x00000002, 0x06000036, 0x001000f2, 0x00000001, 0x00208e46, 0x00000000, 0x00000000,
16335 0x0d00008e, 0x001000f2, 0x00000000, 0x001000f2, 0x00000001, 0x00100e46, 0x00000001, 0x00208e46,
16336 0x00000000, 0x00000001, 0x00208e46, 0x00000000, 0x00000002, 0x05000036, 0x001020f2, 0x00000000,
16337 0x00100e46, 0x00000001, 0x0100003e,
16339 static const struct
16341 struct input input
;
16348 {{0, 0, 0, 0}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
16349 {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}
16352 {{1, 1, 1, 1}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
16353 {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}, {0xdead, 0xc0de, 0xffff, 0xeeee},
16356 {{0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff},
16357 {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
16358 {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}, {0xdead, 0xc0de, 0xffff, 0xeeee},
16361 {{1, 0, 1, 0}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
16362 {0xaaaa, 0xc0de, 0xcccc, 0xeeee}, {0xdead, 0xbbbb, 0xffff, 0xdddd},
16365 {{1, 0, 0, 1}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
16366 {0xaaaa, 0xc0de, 0xffff, 0xdddd}, {0xdead, 0xbbbb, 0xcccc, 0xeeee},
16369 {{1, 0, 0, 0}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
16370 {0xaaaa, 0xc0de, 0xffff, 0xeeee}, {0xdead, 0xbbbb, 0xcccc, 0xdddd}
16373 {{0, 1, 0, 0}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
16374 {0xdead, 0xbbbb, 0xffff, 0xeeee}, {0xaaaa, 0xc0de, 0xcccc, 0xdddd}
16377 {{0, 0, 1, 0}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
16378 {0xdead, 0xc0de, 0xcccc, 0xeeee}, {0xaaaa, 0xbbbb, 0xffff, 0xdddd}
16381 {{0, 0, 0, 1}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
16382 {0xdead, 0xc0de, 0xffff, 0xdddd}, {0xaaaa, 0xbbbb, 0xcccc, 0xeeee},
16386 if (!init_test_context(&test_context
, &feature_level
))
16389 device
= test_context
.device
;
16390 context
= test_context
.immediate_context
;
16392 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
16393 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_UINT
;
16394 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
16395 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
16397 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
16398 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
16400 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
16402 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(struct input
), NULL
);
16403 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
16405 hr
= ID3D11Device_CreatePixelShader(device
, ps_swapc0_code
, sizeof(ps_swapc0_code
), NULL
, &ps
[0]);
16406 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
16407 hr
= ID3D11Device_CreatePixelShader(device
, ps_swapc1_code
, sizeof(ps_swapc1_code
), NULL
, &ps
[1]);
16408 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
16409 hr
= ID3D11Device_CreatePixelShader(device
, ps_swapc2_code
, sizeof(ps_swapc2_code
), NULL
, &ps
[2]);
16410 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
16411 hr
= ID3D11Device_CreatePixelShader(device
, ps_swapc3_code
, sizeof(ps_swapc3_code
), NULL
, &ps
[3]);
16412 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
16413 hr
= ID3D11Device_CreatePixelShader(device
, ps_swapc4_code
, sizeof(ps_swapc4_code
), NULL
, &ps
[4]);
16414 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
16415 hr
= ID3D11Device_CreatePixelShader(device
, ps_swapc5_code
, sizeof(ps_swapc5_code
), NULL
, &ps
[5]);
16416 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
16418 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
16420 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &tests
[i
].input
, 0, 0);
16422 ID3D11DeviceContext_PSSetShader(context
, ps
[0], NULL
, 0);
16423 draw_quad(&test_context
);
16424 check_texture_uvec4(texture
, &tests
[i
].dst0
);
16426 ID3D11DeviceContext_PSSetShader(context
, ps
[1], NULL
, 0);
16427 draw_quad(&test_context
);
16428 check_texture_uvec4(texture
, &tests
[i
].dst1
);
16430 ID3D11DeviceContext_PSSetShader(context
, ps
[2], NULL
, 0);
16431 draw_quad(&test_context
);
16432 check_texture_uvec4(texture
, &tests
[i
].dst0
);
16434 ID3D11DeviceContext_PSSetShader(context
, ps
[3], NULL
, 0);
16435 draw_quad(&test_context
);
16436 check_texture_uvec4(texture
, &tests
[i
].dst1
);
16438 ID3D11DeviceContext_PSSetShader(context
, ps
[4], NULL
, 0);
16439 draw_quad(&test_context
);
16440 check_texture_uvec4(texture
, &tests
[i
].dst0
);
16442 ID3D11DeviceContext_PSSetShader(context
, ps
[5], NULL
, 0);
16443 draw_quad(&test_context
);
16444 check_texture_uvec4(texture
, &tests
[i
].dst1
);
16447 for (i
= 0; i
< ARRAY_SIZE(ps
); ++i
)
16448 ID3D11PixelShader_Release(ps
[i
]);
16449 ID3D11RenderTargetView_Release(rtv
);
16450 ID3D11Texture2D_Release(texture
);
16451 ID3D11Buffer_Release(cb
);
16452 release_test_context(&test_context
);
16455 static void test_create_input_layout(void)
16457 D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
16459 {"POSITION", 0, DXGI_FORMAT_UNKNOWN
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
16461 ULONG refcount
, expected_refcount
;
16462 ID3D11InputLayout
*input_layout
;
16463 ID3D11Device
*device
;
16467 static const DWORD vs_code
[] =
16470 float4
main(float4 position
: POSITION
) : SV_POSITION
16475 0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003,
16476 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
16477 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
16478 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
16479 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
16480 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
16481 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
16483 static const DXGI_FORMAT vertex_formats
[] =
16485 DXGI_FORMAT_R32G32_FLOAT
,
16486 DXGI_FORMAT_R32G32_UINT
,
16487 DXGI_FORMAT_R32G32_SINT
,
16488 DXGI_FORMAT_R16G16_FLOAT
,
16489 DXGI_FORMAT_R16G16_UINT
,
16490 DXGI_FORMAT_R16G16_SINT
,
16491 DXGI_FORMAT_R32_FLOAT
,
16492 DXGI_FORMAT_R32_UINT
,
16493 DXGI_FORMAT_R32_SINT
,
16494 DXGI_FORMAT_R16_UINT
,
16495 DXGI_FORMAT_R16_SINT
,
16496 DXGI_FORMAT_R8G8_UNORM
,
16497 DXGI_FORMAT_R8_UINT
,
16498 DXGI_FORMAT_R8_SINT
,
16501 if (!(device
= create_device(NULL
)))
16503 skip("Failed to create device.\n");
16507 for (i
= 0; i
< ARRAY_SIZE(vertex_formats
); ++i
)
16509 expected_refcount
= get_refcount(device
) + 1;
16510 layout_desc
->Format
= vertex_formats
[i
];
16511 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
16512 vs_code
, sizeof(vs_code
), &input_layout
);
16513 ok(hr
== S_OK
, "Failed to create input layout for format %#x, hr %#x.\n",
16514 vertex_formats
[i
], hr
);
16515 refcount
= get_refcount(device
);
16516 ok(refcount
== expected_refcount
, "Got refcount %u, expected %u.\n",
16517 refcount
, expected_refcount
);
16518 ID3D11InputLayout_Release(input_layout
);
16521 refcount
= ID3D11Device_Release(device
);
16522 ok(!refcount
, "Device has %u references left.\n", refcount
);
16525 static void test_input_assembler(void)
16544 D3D11_INPUT_ELEMENT_DESC input_layout_desc
[] =
16546 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
16547 {"ATTRIBUTE", 0, DXGI_FORMAT_UNKNOWN
, 1, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
16549 ID3D11VertexShader
*vs_float
, *vs_uint
, *vs_sint
;
16550 ID3D11InputLayout
*input_layout
[LAYOUT_COUNT
];
16551 ID3D11Buffer
*vb_position
, *vb_attribute
;
16552 struct d3d11_test_context test_context
;
16553 D3D11_TEXTURE2D_DESC texture_desc
;
16554 unsigned int i
, j
, stride
, offset
;
16555 ID3D11Texture2D
*render_target
;
16556 ID3D11DeviceContext
*context
;
16557 ID3D11RenderTargetView
*rtv
;
16558 ID3D11PixelShader
*ps
;
16559 ID3D11Device
*device
;
16562 static const DXGI_FORMAT layout_formats
[LAYOUT_COUNT
] =
16564 DXGI_FORMAT_R32G32B32A32_FLOAT
,
16565 DXGI_FORMAT_R16G16B16A16_UINT
,
16566 DXGI_FORMAT_R16G16B16A16_SINT
,
16567 DXGI_FORMAT_R16G16B16A16_UNORM
,
16568 DXGI_FORMAT_R16G16B16A16_SNORM
,
16569 DXGI_FORMAT_R8G8B8A8_UINT
,
16570 DXGI_FORMAT_R8G8B8A8_SINT
,
16571 DXGI_FORMAT_R8G8B8A8_UNORM
,
16572 DXGI_FORMAT_R8G8B8A8_SNORM
,
16573 DXGI_FORMAT_R10G10B10A2_UNORM
,
16574 DXGI_FORMAT_R10G10B10A2_UINT
,
16576 static const struct vec2 quad
[] =
16583 static const DWORD ps_code
[] =
16586 float4
main(float4 position
: POSITION
, float4 color
: COLOR
) : SV_Target
16591 0x43425844, 0xa9150342, 0x70e18d2e, 0xf7769835, 0x4c3a7f02, 0x00000001, 0x000000f0, 0x00000003,
16592 0x0000002c, 0x0000007c, 0x000000b0, 0x4e475349, 0x00000048, 0x00000002, 0x00000008, 0x00000038,
16593 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x00000041, 0x00000000, 0x00000000,
16594 0x00000003, 0x00000001, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x4e47534f,
16595 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
16596 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
16597 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036, 0x001020f2,
16598 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
16600 static const DWORD vs_float_code
[] =
16605 float4 position
: SV_Position
;
16606 float4 color
: COLOR
;
16609 void main(float4 position
: POSITION
, float4 color
: ATTRIBUTE
, out output o
)
16611 o
.position
= position
;
16615 0x43425844, 0xf6051ffd, 0xd9e49503, 0x171ad197, 0x3764fe47, 0x00000001, 0x00000144, 0x00000003,
16616 0x0000002c, 0x00000080, 0x000000d4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
16617 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
16618 0x00000003, 0x00000001, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x54544100, 0x55424952, 0xab004554,
16619 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
16620 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
16621 0x505f5653, 0x7469736f, 0x006e6f69, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000068, 0x00010040,
16622 0x0000001a, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067,
16623 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2,
16624 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001,
16627 static const DWORD vs_uint_code
[] =
16632 float4 position
: SV_Position
;
16633 float4 color
: COLOR
;
16636 void main(float4 position
: POSITION
, uint4 color
: ATTRIBUTE
, out output o
)
16638 o
.position
= position
;
16642 0x43425844, 0x0bae0bc0, 0xf6473aa5, 0x4ecf4a25, 0x414fac23, 0x00000001, 0x00000144, 0x00000003,
16643 0x0000002c, 0x00000080, 0x000000d4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
16644 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
16645 0x00000001, 0x00000001, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x54544100, 0x55424952, 0xab004554,
16646 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
16647 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
16648 0x505f5653, 0x7469736f, 0x006e6f69, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000068, 0x00010040,
16649 0x0000001a, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067,
16650 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2,
16651 0x00000000, 0x00101e46, 0x00000000, 0x05000056, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001,
16654 static const DWORD vs_sint_code
[] =
16659 float4 position
: SV_Position
;
16660 float4 color
: COLOR
;
16663 void main(float4 position
: POSITION
, int4 color
: ATTRIBUTE
, out output o
)
16665 o
.position
= position
;
16669 0x43425844, 0xaf60aad9, 0xba91f3a4, 0x2015d384, 0xf746fdf5, 0x00000001, 0x00000144, 0x00000003,
16670 0x0000002c, 0x00000080, 0x000000d4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
16671 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
16672 0x00000002, 0x00000001, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x54544100, 0x55424952, 0xab004554,
16673 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
16674 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
16675 0x505f5653, 0x7469736f, 0x006e6f69, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000068, 0x00010040,
16676 0x0000001a, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067,
16677 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2,
16678 0x00000000, 0x00101e46, 0x00000000, 0x0500002b, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001,
16681 static const float float32_data
[] = {1.0f
, 2.0f
, 3.0f
, 4.0f
};
16682 static const unsigned short uint16_data
[] = {6, 8, 55, 777};
16683 static const short sint16_data
[] = {-1, 33, 8, -77};
16684 static const unsigned short unorm16_data
[] = {0, 16383, 32767, 65535};
16685 static const short snorm16_data
[] = {-32768, 0, 32767, 0};
16686 static const unsigned char uint8_data
[] = {0, 64, 128, 255};
16687 static const signed char sint8_data
[] = {-128, 0, 127, 64};
16688 static const unsigned int uint32_zero
= 0;
16689 static const unsigned int uint32_max
= 0xffffffff;
16690 static const unsigned int unorm10_2_data
= 0xa00003ff;
16691 static const unsigned int g10_data
= 0x000ffc00;
16692 static const unsigned int a2_data
= 0xc0000000;
16693 static const struct
16695 enum layout_id layout_id
;
16696 unsigned int stride
;
16698 struct vec4 expected_color
;
16703 {LAYOUT_FLOAT32
, sizeof(float32_data
), float32_data
,
16704 {1.0f
, 2.0f
, 3.0f
, 4.0f
}},
16705 {LAYOUT_UINT16
, sizeof(uint16_data
), uint16_data
,
16706 {6.0f
, 8.0f
, 55.0f
, 777.0f
}, TRUE
},
16707 {LAYOUT_SINT16
, sizeof(sint16_data
), sint16_data
,
16708 {-1.0f
, 33.0f
, 8.0f
, -77.0f
}, TRUE
},
16709 {LAYOUT_UNORM16
, sizeof(unorm16_data
), unorm16_data
,
16710 {0.0f
, 16383.0f
/ 65535.0f
, 32767.0f
/ 65535.0f
, 1.0f
}},
16711 {LAYOUT_SNORM16
, sizeof(snorm16_data
), snorm16_data
,
16712 {-1.0f
, 0.0f
, 1.0f
, 0.0f
}},
16713 {LAYOUT_UINT8
, sizeof(uint32_zero
), &uint32_zero
,
16714 {0.0f
, 0.0f
, 0.0f
, 0.0f
}},
16715 {LAYOUT_UINT8
, sizeof(uint32_max
), &uint32_max
,
16716 {255.0f
, 255.0f
, 255.0f
, 255.0f
}},
16717 {LAYOUT_UINT8
, sizeof(uint8_data
), uint8_data
,
16718 {0.0f
, 64.0f
, 128.0f
, 255.0f
}},
16719 {LAYOUT_SINT8
, sizeof(uint32_zero
), &uint32_zero
,
16720 {0.0f
, 0.0f
, 0.0f
, 0.0f
}},
16721 {LAYOUT_SINT8
, sizeof(uint32_max
), &uint32_max
,
16722 {-1.0f
, -1.0f
, -1.0f
, -1.0f
}},
16723 {LAYOUT_SINT8
, sizeof(sint8_data
), sint8_data
,
16724 {-128.0f
, 0.0f
, 127.0f
, 64.0f
}},
16725 {LAYOUT_UNORM8
, sizeof(uint32_zero
), &uint32_zero
,
16726 {0.0f
, 0.0f
, 0.0f
, 0.0f
}},
16727 {LAYOUT_UNORM8
, sizeof(uint32_max
), &uint32_max
,
16728 {1.0f
, 1.0f
, 1.0f
, 1.0f
}},
16729 {LAYOUT_UNORM8
, sizeof(uint8_data
), uint8_data
,
16730 {0.0f
, 64.0f
/ 255.0f
, 128.0f
/ 255.0f
, 1.0f
}},
16731 {LAYOUT_SNORM8
, sizeof(uint32_zero
), &uint32_zero
,
16732 {0.0f
, 0.0f
, 0.0f
, 0.0f
}},
16733 {LAYOUT_SNORM8
, sizeof(sint8_data
), sint8_data
,
16734 {-1.0f
, 0.0f
, 1.0f
, 64.0f
/ 127.0f
}},
16735 {LAYOUT_UNORM10_2
, sizeof(uint32_zero
), &uint32_zero
,
16736 {0.0f
, 0.0f
, 0.0f
, 0.0f
}},
16737 {LAYOUT_UNORM10_2
, sizeof(uint32_max
), &uint32_max
,
16738 {1.0f
, 1.0f
, 1.0f
, 1.0f
}},
16739 {LAYOUT_UNORM10_2
, sizeof(g10_data
), &g10_data
,
16740 {0.0f
, 1.0f
, 0.0f
, 0.0f
}},
16741 {LAYOUT_UNORM10_2
, sizeof(a2_data
), &a2_data
,
16742 {0.0f
, 0.0f
, 0.0f
, 1.0f
}},
16743 {LAYOUT_UNORM10_2
, sizeof(unorm10_2_data
), &unorm10_2_data
,
16744 {1.0f
, 0.0f
, 512.0f
/ 1023.0f
, 2.0f
/ 3.0f
}},
16745 {LAYOUT_UINT10_2
, sizeof(uint32_zero
), &uint32_zero
,
16746 {0.0f
, 0.0f
, 0.0f
, 0.0f
}},
16747 {LAYOUT_UINT10_2
, sizeof(uint32_max
), &uint32_max
,
16748 {1023.0f
, 1023.0f
, 1023.0f
, 3.0f
}},
16749 {LAYOUT_UINT10_2
, sizeof(g10_data
), &g10_data
,
16750 {0.0f
, 1023.0f
, 0.0f
, 0.0f
}},
16751 {LAYOUT_UINT10_2
, sizeof(a2_data
), &a2_data
,
16752 {0.0f
, 0.0f
, 0.0f
, 3.0f
}},
16753 {LAYOUT_UINT10_2
, sizeof(unorm10_2_data
), &unorm10_2_data
,
16754 {1023.0f
, 0.0f
, 512.0f
, 2.0f
}},
16757 if (!init_test_context(&test_context
, NULL
))
16760 device
= test_context
.device
;
16761 context
= test_context
.immediate_context
;
16763 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
16764 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
16766 hr
= ID3D11Device_CreateVertexShader(device
, vs_float_code
, sizeof(vs_float_code
), NULL
, &vs_float
);
16767 ok(SUCCEEDED(hr
), "Failed to create float vertex shader, hr %#x.\n", hr
);
16768 hr
= ID3D11Device_CreateVertexShader(device
, vs_uint_code
, sizeof(vs_uint_code
), NULL
, &vs_uint
);
16769 ok(SUCCEEDED(hr
), "Failed to create uint vertex shader, hr %#x.\n", hr
);
16770 hr
= ID3D11Device_CreateVertexShader(device
, vs_sint_code
, sizeof(vs_sint_code
), NULL
, &vs_sint
);
16771 ok(SUCCEEDED(hr
), "Failed to create sint vertex shader, hr %#x.\n", hr
);
16773 for (i
= 0; i
< LAYOUT_COUNT
; ++i
)
16775 input_layout_desc
[1].Format
= layout_formats
[i
];
16776 input_layout
[i
] = NULL
;
16777 hr
= ID3D11Device_CreateInputLayout(device
, input_layout_desc
, ARRAY_SIZE(input_layout_desc
),
16778 vs_float_code
, sizeof(vs_float_code
), &input_layout
[i
]);
16779 todo_wine_if(input_layout_desc
[1].Format
== DXGI_FORMAT_R10G10B10A2_UINT
)
16780 ok(SUCCEEDED(hr
), "Failed to create input layout for format %#x, hr %#x.\n", layout_formats
[i
], hr
);
16783 vb_position
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(quad
), quad
);
16784 vb_attribute
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, 1024, NULL
);
16786 texture_desc
.Width
= 640;
16787 texture_desc
.Height
= 480;
16788 texture_desc
.MipLevels
= 1;
16789 texture_desc
.ArraySize
= 1;
16790 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
16791 texture_desc
.SampleDesc
.Count
= 1;
16792 texture_desc
.SampleDesc
.Quality
= 0;
16793 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
16794 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
16795 texture_desc
.CPUAccessFlags
= 0;
16796 texture_desc
.MiscFlags
= 0;
16798 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &render_target
);
16799 ok(SUCCEEDED(hr
), "Failed to create 2d texture, hr %#x.\n", hr
);
16801 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)render_target
, NULL
, &rtv
);
16802 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
16804 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
16806 stride
= sizeof(*quad
);
16807 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb_position
, &stride
, &offset
);
16808 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
16809 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
16811 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
16813 D3D11_BOX box
= {0, 0, 0, 1, 1, 1};
16815 if (tests
[i
].layout_id
== LAYOUT_UINT10_2
)
16818 assert(tests
[i
].layout_id
< LAYOUT_COUNT
);
16819 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
[tests
[i
].layout_id
]);
16821 assert(4 * tests
[i
].stride
<= 1024);
16822 box
.right
= tests
[i
].stride
;
16823 for (j
= 0; j
< 4; ++j
)
16825 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb_attribute
, 0,
16826 &box
, tests
[i
].data
, 0, 0);
16827 box
.left
+= tests
[i
].stride
;
16828 box
.right
+= tests
[i
].stride
;
16831 stride
= tests
[i
].stride
;
16832 ID3D11DeviceContext_IASetVertexBuffers(context
, 1, 1, &vb_attribute
, &stride
, &offset
);
16834 switch (layout_formats
[tests
[i
].layout_id
])
16836 case DXGI_FORMAT_R16G16B16A16_UINT
:
16837 case DXGI_FORMAT_R10G10B10A2_UINT
:
16838 case DXGI_FORMAT_R8G8B8A8_UINT
:
16839 ID3D11DeviceContext_VSSetShader(context
, vs_uint
, NULL
, 0);
16841 case DXGI_FORMAT_R16G16B16A16_SINT
:
16842 case DXGI_FORMAT_R8G8B8A8_SINT
:
16843 ID3D11DeviceContext_VSSetShader(context
, vs_sint
, NULL
, 0);
16847 trace("Unhandled format %#x.\n", layout_formats
[tests
[i
].layout_id
]);
16848 /* Fall through. */
16849 case DXGI_FORMAT_R32G32B32A32_FLOAT
:
16850 case DXGI_FORMAT_R16G16B16A16_UNORM
:
16851 case DXGI_FORMAT_R16G16B16A16_SNORM
:
16852 case DXGI_FORMAT_R10G10B10A2_UNORM
:
16853 case DXGI_FORMAT_R8G8B8A8_UNORM
:
16854 case DXGI_FORMAT_R8G8B8A8_SNORM
:
16855 ID3D11DeviceContext_VSSetShader(context
, vs_float
, NULL
, 0);
16859 ID3D11DeviceContext_Draw(context
, 4, 0);
16860 check_texture_vec4(render_target
, &tests
[i
].expected_color
, 2);
16863 ID3D11Texture2D_Release(render_target
);
16864 ID3D11RenderTargetView_Release(rtv
);
16865 ID3D11Buffer_Release(vb_attribute
);
16866 ID3D11Buffer_Release(vb_position
);
16867 for (i
= 0; i
< LAYOUT_COUNT
; ++i
)
16869 if (input_layout
[i
])
16870 ID3D11InputLayout_Release(input_layout
[i
]);
16872 ID3D11PixelShader_Release(ps
);
16873 ID3D11VertexShader_Release(vs_float
);
16874 ID3D11VertexShader_Release(vs_uint
);
16875 ID3D11VertexShader_Release(vs_sint
);
16876 release_test_context(&test_context
);
16879 static void test_null_sampler(void)
16881 struct d3d11_test_context test_context
;
16882 D3D11_TEXTURE2D_DESC texture_desc
;
16883 ID3D11ShaderResourceView
*srv
;
16884 ID3D11DeviceContext
*context
;
16885 ID3D11RenderTargetView
*rtv
;
16886 ID3D11SamplerState
*sampler
;
16887 ID3D11Texture2D
*texture
;
16888 ID3D11PixelShader
*ps
;
16889 ID3D11Device
*device
;
16892 static const DWORD ps_code
[] =
16898 float4
main(float4 position
: SV_POSITION
) : SV_Target
16900 return t
.Sample(s
, float2(position
.x
/ 640.0f
, position
.y
/ 480.0f
));
16903 0x43425844, 0x1ce9b612, 0xc8176faa, 0xd37844af, 0xdb515605, 0x00000001, 0x00000134, 0x00000003,
16904 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
16905 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
16906 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
16907 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
16908 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
16909 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
16910 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
16911 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
16912 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
16914 static const float blue
[] = {0.0f
, 0.0f
, 1.0f
, 1.0f
};
16916 if (!init_test_context(&test_context
, NULL
))
16919 device
= test_context
.device
;
16920 context
= test_context
.immediate_context
;
16922 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
16923 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
16925 texture_desc
.Width
= 64;
16926 texture_desc
.Height
= 64;
16927 texture_desc
.MipLevels
= 1;
16928 texture_desc
.ArraySize
= 1;
16929 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
16930 texture_desc
.SampleDesc
.Count
= 1;
16931 texture_desc
.SampleDesc
.Quality
= 0;
16932 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
16933 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
;
16934 texture_desc
.CPUAccessFlags
= 0;
16935 texture_desc
.MiscFlags
= 0;
16937 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
16938 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
16940 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
16941 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
16943 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
16944 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
16946 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, blue
);
16948 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
16949 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
16951 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler
);
16952 draw_quad(&test_context
);
16953 check_texture_color(test_context
.backbuffer
, 0xffff0000, 0);
16955 ID3D11ShaderResourceView_Release(srv
);
16956 ID3D11RenderTargetView_Release(rtv
);
16957 ID3D11Texture2D_Release(texture
);
16958 ID3D11PixelShader_Release(ps
);
16959 release_test_context(&test_context
);
16962 static void test_check_feature_support(void)
16964 D3D11_FEATURE_DATA_THREADING threading
[2];
16965 D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS hwopts
;
16966 D3D11_FEATURE_DATA_ARCHITECTURE_INFO archinfo
;
16967 ID3D11Device
*device
;
16971 if (!(device
= create_device(NULL
)))
16973 skip("Failed to create device.\n");
16977 memset(threading
, 0xef, sizeof(threading
));
16979 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_THREADING
, NULL
, 0);
16980 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
16981 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_THREADING
, threading
, 0);
16982 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
16983 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_THREADING
, threading
, sizeof(*threading
) - 1);
16984 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
16985 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_THREADING
, threading
, sizeof(*threading
) / 2);
16986 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
16987 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_THREADING
, threading
, sizeof(*threading
) + 1);
16988 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
16989 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_THREADING
, threading
, sizeof(*threading
) * 2);
16990 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
16992 ok(threading
[0].DriverConcurrentCreates
== 0xefefefef,
16993 "Got unexpected concurrent creates %#x.\n", threading
[0].DriverConcurrentCreates
);
16994 ok(threading
[0].DriverCommandLists
== 0xefefefef,
16995 "Got unexpected command lists %#x.\n", threading
[0].DriverCommandLists
);
16996 ok(threading
[1].DriverConcurrentCreates
== 0xefefefef,
16997 "Got unexpected concurrent creates %#x.\n", threading
[1].DriverConcurrentCreates
);
16998 ok(threading
[1].DriverCommandLists
== 0xefefefef,
16999 "Got unexpected command lists %#x.\n", threading
[1].DriverCommandLists
);
17001 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_THREADING
, threading
, sizeof(*threading
));
17002 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
17003 ok(threading
->DriverConcurrentCreates
== TRUE
|| threading
->DriverConcurrentCreates
== FALSE
,
17004 "Got unexpected concurrent creates %#x.\n", threading
->DriverConcurrentCreates
);
17005 ok(threading
->DriverCommandLists
== TRUE
|| threading
->DriverCommandLists
== FALSE
,
17006 "Got unexpected command lists %#x.\n", threading
->DriverCommandLists
);
17008 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
, NULL
, 0);
17009 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
17010 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
, &hwopts
, 0);
17011 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
17012 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
, &hwopts
, sizeof(hwopts
) - 1);
17013 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
17014 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
, &hwopts
, sizeof(hwopts
) / 2);
17015 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
17016 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
, &hwopts
, sizeof(hwopts
) + 1);
17017 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
17018 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
, &hwopts
, sizeof(hwopts
) * 2);
17019 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
17021 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
, &hwopts
, sizeof(hwopts
));
17022 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
17023 trace("Compute shader support via SM4 %#x.\n", hwopts
.ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x
);
17025 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_ARCHITECTURE_INFO
, &archinfo
, sizeof(archinfo
));
17026 ok(hr
== S_OK
|| broken(hr
== E_INVALIDARG
) /* Not available on all Windows versions. */,
17027 "Got unexpected hr %#x.\n", hr
);
17028 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_ARCHITECTURE_INFO
, &archinfo
, sizeof(archinfo
)*2);
17029 ok(hr
== E_INVALIDARG
/* Not available on all Windows versions but they will return E_INVALIDARG anyways. */,
17030 "Got unexpected hr %#x.\n", hr
);
17032 refcount
= ID3D11Device_Release(device
);
17033 ok(!refcount
, "Device has %u references left.\n", refcount
);
17036 static void test_create_unordered_access_view(void)
17038 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
17039 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
17040 D3D11_TEXTURE3D_DESC texture3d_desc
;
17041 D3D11_TEXTURE2D_DESC texture2d_desc
;
17042 ULONG refcount
, expected_refcount
;
17043 D3D11_SUBRESOURCE_DATA data
= {0};
17044 ID3D11UnorderedAccessView
*uav
;
17045 struct device_desc device_desc
;
17046 D3D11_BUFFER_DESC buffer_desc
;
17047 ID3D11Device
*device
, *tmp
;
17048 ID3D11Texture3D
*texture3d
;
17049 ID3D11Texture2D
*texture2d
;
17050 ID3D11Resource
*texture
;
17051 ID3D11Buffer
*buffer
;
17055 #define FMT_UNKNOWN DXGI_FORMAT_UNKNOWN
17056 #define RGBA8_UNORM DXGI_FORMAT_R8G8B8A8_UNORM
17057 #define RGBA8_SRGB DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
17058 #define RGBA8_UINT DXGI_FORMAT_R8G8B8A8_UINT
17059 #define RGBA8_TL DXGI_FORMAT_R8G8B8A8_TYPELESS
17060 #define DIM_UNKNOWN D3D11_UAV_DIMENSION_UNKNOWN
17061 #define TEX_1D D3D11_UAV_DIMENSION_TEXTURE1D
17062 #define TEX_1D_ARRAY D3D11_UAV_DIMENSION_TEXTURE1DARRAY
17063 #define TEX_2D D3D11_UAV_DIMENSION_TEXTURE2D
17064 #define TEX_2D_ARRAY D3D11_UAV_DIMENSION_TEXTURE2DARRAY
17065 #define TEX_3D D3D11_UAV_DIMENSION_TEXTURE3D
17066 static const struct
17070 unsigned int miplevel_count
;
17071 unsigned int depth_or_array_size
;
17072 DXGI_FORMAT format
;
17074 struct uav_desc uav_desc
;
17075 struct uav_desc expected_uav_desc
;
17079 {{ 1, 1, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D
, 0}},
17080 {{10, 1, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D
, 0}},
17081 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D
, 0}, {RGBA8_UNORM
, TEX_2D
, 0}},
17082 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D
, 1}, {RGBA8_UNORM
, TEX_2D
, 1}},
17083 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D
, 9}, {RGBA8_UNORM
, TEX_2D
, 9}},
17084 {{ 1, 1, RGBA8_TL
}, {RGBA8_UNORM
, TEX_2D
, 0}, {RGBA8_UNORM
, TEX_2D
, 0}},
17085 {{10, 1, RGBA8_TL
}, {RGBA8_UNORM
, TEX_2D
, 0}, {RGBA8_UNORM
, TEX_2D
, 0}},
17086 {{ 1, 1, RGBA8_UINT
}, {0}, {RGBA8_UINT
, TEX_2D
, 0, 0, 1}},
17087 {{ 1, 1, RGBA8_TL
}, {RGBA8_UINT
, TEX_2D
, 0, 0, ~0u}, {RGBA8_UINT
, TEX_2D
, 0, 0, 1}},
17088 {{ 1, 4, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 4}},
17089 {{10, 4, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 4}},
17090 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 4}},
17091 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 1, 0, 4}},
17092 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 3, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 3, 0, 4}},
17093 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 5, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 5, 0, 4}},
17094 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 9, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 9, 0, 4}},
17095 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 1, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 3}},
17096 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 2, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 2, 2}},
17097 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 3, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 3, 1}},
17098 {{ 1, 6, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 6}},
17099 {{ 2, 6, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 6}},
17100 {{ 2, 6, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 6}},
17101 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 2}},
17102 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 2}},
17103 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 1, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 1, 3}},
17104 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 2, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 2, 2}},
17105 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 3, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 3, 1}},
17106 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 1, 1}, {RGBA8_UNORM
, TEX_3D
, 0, 1, 1}},
17107 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 1, 1}, {RGBA8_UNORM
, TEX_3D
, 1, 1, 1}},
17108 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 1, ~0u}, {RGBA8_UNORM
, TEX_3D
, 1, 1, 1}},
17109 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 8}},
17110 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 4}},
17111 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 2, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 2, 0, 2}},
17112 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 3, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 3, 0, 1}},
17113 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 4, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 4, 0, 1}},
17114 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 5, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 5, 0, 1}},
17116 static const struct
17120 D3D11_UAV_DIMENSION dimension
;
17121 unsigned int miplevel_count
;
17122 unsigned int depth_or_array_size
;
17123 DXGI_FORMAT format
;
17125 struct uav_desc uav_desc
;
17127 invalid_desc_tests
[] =
17129 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, DIM_UNKNOWN
}},
17130 {{TEX_2D
, 6, 4, RGBA8_UNORM
}, {RGBA8_UNORM
, DIM_UNKNOWN
}},
17131 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0}},
17132 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 0, 1}},
17133 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 1}},
17134 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, ~0u}},
17135 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_2D
, 0}},
17136 {{TEX_2D
, 1, 1, RGBA8_TL
}, {FMT_UNKNOWN
, TEX_2D
, 0}},
17137 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 1}},
17138 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 0}},
17139 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 1, 0, 1}},
17140 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 2}},
17141 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 1}},
17142 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UINT
, TEX_2D
, 0, 0, 1}},
17143 {{TEX_2D
, 1, 1, RGBA8_UINT
}, {RGBA8_UNORM
, TEX_2D
, 0, 0, 1}},
17144 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_SRGB
, TEX_2D
, 0, 0, 1}},
17145 {{TEX_2D
, 1, 1, RGBA8_SRGB
}, {RGBA8_UNORM
, TEX_2D
, 0, 0, 1}},
17146 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0}},
17147 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 0, 1}},
17148 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0}},
17149 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 1}},
17150 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0}},
17151 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 0, 1}},
17152 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0}},
17153 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 1}},
17154 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 0}},
17155 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 1}},
17156 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_3D
, 0, 0, 1}},
17157 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_TL
, TEX_3D
, 0, 0, 1}},
17158 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 9}},
17159 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 3, 0, 2}},
17160 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 2, 0, 4}},
17161 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 8}},
17162 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 8, ~0u}},
17163 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 4, ~0u}},
17164 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 2, 2, ~0u}},
17165 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 3, 1, ~0u}},
17174 #undef TEX_1D_ARRAY
17176 #undef TEX_2D_ARRAY
17179 device_desc
.feature_level
= &feature_level
;
17180 device_desc
.flags
= 0;
17181 if (!(device
= create_device(&device_desc
)))
17183 skip("Failed to create device.\n");
17187 buffer_desc
.ByteWidth
= 1024;
17188 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
17189 buffer_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
17190 buffer_desc
.CPUAccessFlags
= 0;
17191 buffer_desc
.MiscFlags
= 0;
17192 buffer_desc
.StructureByteStride
= 0;
17194 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &data
, &buffer
);
17195 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
17197 expected_refcount
= get_refcount(device
) + 1;
17198 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
17199 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
17200 refcount
= get_refcount(device
);
17201 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
17203 expected_refcount
= refcount
+ 1;
17204 ID3D11Buffer_GetDevice(buffer
, &tmp
);
17205 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
17206 refcount
= get_refcount(device
);
17207 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
17208 ID3D11Device_Release(tmp
);
17210 uav_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
17211 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
17212 U(uav_desc
).Buffer
.FirstElement
= 0;
17213 U(uav_desc
).Buffer
.NumElements
= 64;
17214 U(uav_desc
).Buffer
.Flags
= 0;
17216 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, NULL
, &uav
);
17217 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
17219 expected_refcount
= get_refcount(device
) + 1;
17220 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
17221 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
17222 refcount
= get_refcount(device
);
17223 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
17225 expected_refcount
= refcount
+ 1;
17226 ID3D11UnorderedAccessView_GetDevice(uav
, &tmp
);
17227 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
17228 refcount
= get_refcount(device
);
17229 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
17230 ID3D11Device_Release(tmp
);
17232 ID3D11UnorderedAccessView_Release(uav
);
17233 ID3D11Buffer_Release(buffer
);
17235 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
;
17236 buffer_desc
.StructureByteStride
= 4;
17238 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
17239 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
17241 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, NULL
, &uav
);
17242 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
17244 memset(&uav_desc
, 0, sizeof(uav_desc
));
17245 ID3D11UnorderedAccessView_GetDesc(uav
, &uav_desc
);
17247 ok(uav_desc
.Format
== DXGI_FORMAT_UNKNOWN
, "Got unexpected format %#x.\n", uav_desc
.Format
);
17248 ok(uav_desc
.ViewDimension
== D3D11_UAV_DIMENSION_BUFFER
, "Got unexpected view dimension %#x.\n",
17249 uav_desc
.ViewDimension
);
17250 ok(!U(uav_desc
).Buffer
.FirstElement
, "Got unexpected first element %u.\n", U(uav_desc
).Buffer
.FirstElement
);
17251 ok(U(uav_desc
).Buffer
.NumElements
== 256, "Got unexpected num elements %u.\n", U(uav_desc
).Buffer
.NumElements
);
17252 ok(!U(uav_desc
).Buffer
.Flags
, "Got unexpected flags %u.\n", U(uav_desc
).Buffer
.Flags
);
17254 ID3D11UnorderedAccessView_Release(uav
);
17255 ID3D11Buffer_Release(buffer
);
17257 texture2d_desc
.Width
= 512;
17258 texture2d_desc
.Height
= 512;
17259 texture2d_desc
.SampleDesc
.Count
= 1;
17260 texture2d_desc
.SampleDesc
.Quality
= 0;
17261 texture2d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
17262 texture2d_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
17263 texture2d_desc
.CPUAccessFlags
= 0;
17264 texture2d_desc
.MiscFlags
= 0;
17266 texture3d_desc
.Width
= 64;
17267 texture3d_desc
.Height
= 64;
17268 texture3d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
17269 texture3d_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
17270 texture3d_desc
.CPUAccessFlags
= 0;
17271 texture3d_desc
.MiscFlags
= 0;
17273 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
17275 D3D11_UNORDERED_ACCESS_VIEW_DESC
*current_desc
;
17277 if (tests
[i
].expected_uav_desc
.dimension
!= D3D11_UAV_DIMENSION_TEXTURE3D
)
17279 texture2d_desc
.MipLevels
= tests
[i
].texture
.miplevel_count
;
17280 texture2d_desc
.ArraySize
= tests
[i
].texture
.depth_or_array_size
;
17281 texture2d_desc
.Format
= tests
[i
].texture
.format
;
17283 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, &texture2d
);
17284 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
17285 texture
= (ID3D11Resource
*)texture2d
;
17289 texture3d_desc
.MipLevels
= tests
[i
].texture
.miplevel_count
;
17290 texture3d_desc
.Depth
= tests
[i
].texture
.depth_or_array_size
;
17291 texture3d_desc
.Format
= tests
[i
].texture
.format
;
17293 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &texture3d
);
17294 ok(SUCCEEDED(hr
), "Test %u: Failed to create 3d texture, hr %#x.\n", i
, hr
);
17295 texture
= (ID3D11Resource
*)texture3d
;
17298 if (tests
[i
].uav_desc
.dimension
== D3D11_UAV_DIMENSION_UNKNOWN
)
17300 current_desc
= NULL
;
17304 current_desc
= &uav_desc
;
17305 get_uav_desc(current_desc
, &tests
[i
].uav_desc
);
17308 expected_refcount
= get_refcount(texture
);
17309 hr
= ID3D11Device_CreateUnorderedAccessView(device
, texture
, current_desc
, &uav
);
17310 ok(SUCCEEDED(hr
), "Test %u: Failed to create unordered access view, hr %#x.\n", i
, hr
);
17311 refcount
= get_refcount(texture
);
17312 ok(refcount
== expected_refcount
, "Got refcount %u, expected %u.\n", refcount
, expected_refcount
);
17314 memset(&uav_desc
, 0, sizeof(uav_desc
));
17315 ID3D11UnorderedAccessView_GetDesc(uav
, &uav_desc
);
17316 check_uav_desc(&uav_desc
, &tests
[i
].expected_uav_desc
);
17318 ID3D11UnorderedAccessView_Release(uav
);
17319 ID3D11Resource_Release(texture
);
17322 for (i
= 0; i
< ARRAY_SIZE(invalid_desc_tests
); ++i
)
17324 assert(invalid_desc_tests
[i
].texture
.dimension
== D3D11_UAV_DIMENSION_TEXTURE2D
17325 || invalid_desc_tests
[i
].texture
.dimension
== D3D11_UAV_DIMENSION_TEXTURE3D
);
17327 if (invalid_desc_tests
[i
].texture
.dimension
!= D3D11_UAV_DIMENSION_TEXTURE3D
)
17329 texture2d_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
17330 texture2d_desc
.ArraySize
= invalid_desc_tests
[i
].texture
.depth_or_array_size
;
17331 texture2d_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
17333 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, &texture2d
);
17334 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
17335 texture
= (ID3D11Resource
*)texture2d
;
17339 texture3d_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
17340 texture3d_desc
.Depth
= invalid_desc_tests
[i
].texture
.depth_or_array_size
;
17341 texture3d_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
17343 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &texture3d
);
17344 ok(SUCCEEDED(hr
), "Test %u: Failed to create 3d texture, hr %#x.\n", i
, hr
);
17345 texture
= (ID3D11Resource
*)texture3d
;
17348 get_uav_desc(&uav_desc
, &invalid_desc_tests
[i
].uav_desc
);
17349 hr
= ID3D11Device_CreateUnorderedAccessView(device
, texture
, &uav_desc
, &uav
);
17350 ok(hr
== E_INVALIDARG
, "Test %u: Got unexpected hr %#x.\n", i
, hr
);
17352 ID3D11Resource_Release(texture
);
17355 refcount
= ID3D11Device_Release(device
);
17356 ok(!refcount
, "Device has %u references left.\n", refcount
);
17359 static void test_immediate_constant_buffer(void)
17361 struct d3d11_test_context test_context
;
17362 D3D11_TEXTURE2D_DESC texture_desc
;
17363 ID3D11DeviceContext
*context
;
17364 ID3D11RenderTargetView
*rtv
;
17365 unsigned int index
[4] = {0};
17366 ID3D11Texture2D
*texture
;
17367 ID3D11PixelShader
*ps
;
17368 ID3D11Device
*device
;
17373 static const DWORD ps_code
[] =
17378 static const int int_array
[6] =
17380 310, 111, 212, -513, -318, 0,
17383 static const uint uint_array
[6] =
17385 2, 7, 0x7f800000, 0xff800000, 0x7fc00000, 0
17388 static const float float_array
[6] =
17390 76, 83.5f
, 0.5f
, 0.75f
, -0.5f
, 0.0f
,
17393 float4
main() : SV_Target
17395 return float4(int_array
[index
], uint_array
[index
], float_array
[index
], 1.0f
);
17398 0x43425844, 0xbad068da, 0xd631ea3c, 0x41648374, 0x3ccd0120, 0x00000001, 0x00000184, 0x00000003,
17399 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17400 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
17401 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x0000010c, 0x00000040, 0x00000043,
17402 0x00001835, 0x0000001a, 0x00000136, 0x00000002, 0x42980000, 0x00000000, 0x0000006f, 0x00000007,
17403 0x42a70000, 0x00000000, 0x000000d4, 0x7f800000, 0x3f000000, 0x00000000, 0xfffffdff, 0xff800000,
17404 0x3f400000, 0x00000000, 0xfffffec2, 0x7fc00000, 0xbf000000, 0x00000000, 0x00000000, 0x00000000,
17405 0x00000000, 0x00000000, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2,
17406 0x00000000, 0x02000068, 0x00000001, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x3f800000,
17407 0x06000036, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x06000056, 0x00102022,
17408 0x00000000, 0x0090901a, 0x0010000a, 0x00000000, 0x0600002b, 0x00102012, 0x00000000, 0x0090900a,
17409 0x0010000a, 0x00000000, 0x06000036, 0x00102042, 0x00000000, 0x0090902a, 0x0010000a, 0x00000000,
17412 static struct vec4 expected_result
[] =
17414 { 310.0f
, 2.0f
, 76.00f
, 1.0f
},
17415 { 111.0f
, 7.0f
, 83.50f
, 1.0f
},
17416 { 212.0f
, 2139095040.0f
, 0.50f
, 1.0f
},
17417 {-513.0f
, 4286578688.0f
, 0.75f
, 1.0f
},
17418 {-318.0f
, 2143289344.0f
, -0.50f
, 1.0f
},
17419 { 0.0f
, 0.0f
, 0.0f
, 1.0f
},
17422 if (!init_test_context(&test_context
, NULL
))
17425 device
= test_context
.device
;
17426 context
= test_context
.immediate_context
;
17428 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
17429 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
17430 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
17432 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(index
), NULL
);
17433 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
17435 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
17436 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
17437 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
17438 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
17440 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
17441 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
17442 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
17444 for (i
= 0; i
< ARRAY_SIZE(expected_result
); ++i
)
17447 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, index
, 0, 0);
17449 draw_quad(&test_context
);
17450 check_texture_vec4(texture
, &expected_result
[i
], 0);
17453 ID3D11Buffer_Release(cb
);
17454 ID3D11PixelShader_Release(ps
);
17455 ID3D11Texture2D_Release(texture
);
17456 ID3D11RenderTargetView_Release(rtv
);
17457 release_test_context(&test_context
);
17460 static void test_fp_specials(void)
17462 struct d3d11_test_context test_context
;
17463 D3D11_TEXTURE2D_DESC texture_desc
;
17464 ID3D11DeviceContext
*context
;
17465 ID3D11RenderTargetView
*rtv
;
17466 ID3D11Texture2D
*texture
;
17467 ID3D11PixelShader
*ps
;
17468 ID3D11Device
*device
;
17471 static const DWORD ps_code
[] =
17474 float4
main() : SV_Target
17476 return float4(0.0f
/ 0.0f
, 1.0f
/ 0.0f
, -1.0f
/ 0.0f
, 1.0f
);
17479 0x43425844, 0x86d7f319, 0x14cde598, 0xe7ce83a8, 0x0e06f3f0, 0x00000001, 0x000000b0, 0x00000003,
17480 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17481 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
17482 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
17483 0x03000065, 0x001020f2, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0xffc00000,
17484 0x7f800000, 0xff800000, 0x3f800000, 0x0100003e,
17486 static const struct uvec4 expected_result
= {BITS_NNAN
, BITS_INF
, BITS_NINF
, BITS_1_0
};
17488 if (!init_test_context(&test_context
, NULL
))
17491 device
= test_context
.device
;
17492 context
= test_context
.immediate_context
;
17494 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
17495 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
17496 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
17498 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
17499 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
17500 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
17501 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
17503 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
17504 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
17506 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
17508 draw_quad(&test_context
);
17509 check_texture_uvec4(texture
, &expected_result
);
17511 ID3D11PixelShader_Release(ps
);
17512 ID3D11Texture2D_Release(texture
);
17513 ID3D11RenderTargetView_Release(rtv
);
17514 release_test_context(&test_context
);
17517 static void test_uint_shader_instructions(void)
17523 D3D_FEATURE_LEVEL required_feature_level
;
17526 struct d3d11_test_context test_context
;
17527 D3D11_TEXTURE2D_DESC texture_desc
;
17528 D3D_FEATURE_LEVEL feature_level
;
17529 ID3D11DeviceContext
*context
;
17530 ID3D11RenderTargetView
*rtv
;
17531 ID3D11Texture2D
*texture
;
17532 ID3D11PixelShader
*ps
;
17533 ID3D11Device
*device
;
17538 static const DWORD ps_bfi_code
[] =
17541 uint bits
, offset
, insert
, base
;
17543 uint4
main() : SV_Target
17545 uint mask
= ((1 << bits
) - 1) << offset
;
17546 return ((insert
<< offset
) & mask
) | (base
& ~mask
);
17549 0x43425844, 0xbe9af688, 0xf5caec6f, 0x63ed2522, 0x5f91f209, 0x00000001, 0x000000e0, 0x00000003,
17550 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17551 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
17552 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000068, 0x00000050, 0x0000001a,
17553 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
17554 0x0f00008c, 0x001020f2, 0x00000000, 0x00208006, 0x00000000, 0x00000000, 0x00208556, 0x00000000,
17555 0x00000000, 0x00208aa6, 0x00000000, 0x00000000, 0x00208ff6, 0x00000000, 0x00000000, 0x0100003e,
17557 static const DWORD ps_bfi2_code
[] =
17561 dcl_globalFlags refactoringAllowed
17562 dcl_constantbuffer cb0
[1], immediateIndexed
17565 mov r0
.xyzw
, cb0
[0].xyzw
17566 bfi r0
.xyzw
, r0
.xxxx
, r0
.yyyy
, r0
.zzzz
, r0
.wwww
17567 mov o0
.xyzw
, r0
.xyzw
17570 0x43425844, 0x900f86b6, 0x73f4dabf, 0xea1b1106, 0x591ac790, 0x00000001, 0x00000104, 0x00000003,
17571 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17572 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
17573 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000008c, 0x00000050, 0x00000023,
17574 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
17575 0x02000068, 0x00000001, 0x06000036, 0x001000f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000000,
17576 0x0b00008c, 0x001000f2, 0x00000000, 0x00100006, 0x00000000, 0x00100556, 0x00000000, 0x00100aa6,
17577 0x00000000, 0x00100ff6, 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
17580 static const DWORD ps_ibfe_code
[] =
17584 dcl_globalFlags refactoringAllowed
17585 dcl_constantbuffer cb0
[1], immediateIndexed
17587 ibfe o0
.xyzw
, cb0
[0].xxxx
, cb0
[0].yyyy
, cb0
[0].zzzz
17590 0x43425844, 0x4b2225f7, 0xd0860f66, 0xe38775bb, 0x6d23d1d2, 0x00000001, 0x000000d4, 0x00000003,
17591 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17592 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
17593 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000005c, 0x00000050, 0x00000017,
17594 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
17595 0x0c00008b, 0x001020f2, 0x00000000, 0x00208006, 0x00000000, 0x00000000, 0x00208556, 0x00000000,
17596 0x00000000, 0x00208aa6, 0x00000000, 0x00000000, 0x0100003e,
17598 static const DWORD ps_ibfe2_code
[] =
17602 dcl_globalFlags refactoringAllowed
17603 dcl_constantbuffer cb0
[1], immediateIndexed
17606 mov r0
.xyzw
, cb0
[0].xyzw
17607 ibfe r0
.xyzw
, r0
.xxxx
, r0
.yyyy
, r0
.zzzz
17608 mov o0
.xyzw
, r0
.xyzw
17611 0x43425844, 0x347a9c0e, 0x3eff39a4, 0x3dd41cc5, 0xff87ec8d, 0x00000001, 0x000000fc, 0x00000003,
17612 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17613 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
17614 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000084, 0x00000050, 0x00000021,
17615 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
17616 0x02000068, 0x00000001, 0x06000036, 0x001000f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000000,
17617 0x0900008b, 0x001000f2, 0x00000000, 0x00100006, 0x00000000, 0x00100556, 0x00000000, 0x00100aa6,
17618 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x0100003e,
17620 static const DWORD ps_ubfe_code
[] =
17625 uint4
main() : SV_Target
17627 return uint4((u
& 0xf0) >> 4, (u
& 0x7fffff00) >> 8, (u
& 0xfe) >> 1, (u
& 0x7fffffff) >> 1);
17630 0x43425844, 0xc4ac0509, 0xaea83154, 0xf1fb3b80, 0x4c22e3cc, 0x00000001, 0x000000e4, 0x00000003,
17631 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17632 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
17633 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000006c, 0x00000050, 0x0000001b,
17634 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
17635 0x1000008a, 0x001020f2, 0x00000000, 0x00004002, 0x00000004, 0x00000017, 0x00000007, 0x0000001e,
17636 0x00004002, 0x00000004, 0x00000008, 0x00000001, 0x00000001, 0x00208006, 0x00000000, 0x00000000,
17639 static const DWORD ps_ubfe2_code
[] =
17643 dcl_globalFlags refactoringAllowed
17644 dcl_constantbuffer cb0
[1], immediateIndexed
17647 mov r0
.xyzw
, cb0
[0].xyzw
17648 ubfe r0
.xyzw
, r0
.xxxx
, r0
.yyyy
, r0
.zzzz
17649 mov o0
.xyzw
, r0
.xyzw
17652 0x43425844, 0xf377b7fc, 0x1e4cb9e7, 0xb9b1020d, 0xde484388, 0x00000001, 0x000000fc, 0x00000003,
17653 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17654 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
17655 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000084, 0x00000050, 0x00000021,
17656 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
17657 0x02000068, 0x00000001, 0x06000036, 0x001000f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000000,
17658 0x0900008a, 0x001000f2, 0x00000000, 0x00100006, 0x00000000, 0x00100556, 0x00000000, 0x00100aa6,
17659 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x0100003e,
17661 static const DWORD ps_bfrev_code
[] =
17666 uint4
main() : SV_Target
17668 return uint4(reversebits(bits
), reversebits(reversebits(bits
)),
17669 reversebits(bits
& 0xFFFF), reversebits(bits
>> 16));
17672 0x43425844, 0x73daef82, 0xe52befa3, 0x8504d5f0, 0xebdb321d, 0x00000001, 0x00000154, 0x00000003,
17673 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17674 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
17675 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000dc, 0x00000050, 0x00000037,
17676 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
17677 0x02000068, 0x00000001, 0x08000001, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000,
17678 0x00004001, 0x0000ffff, 0x0500008d, 0x00102042, 0x00000000, 0x0010000a, 0x00000000, 0x08000055,
17679 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x00004001, 0x00000010, 0x0500008d,
17680 0x00102082, 0x00000000, 0x0010000a, 0x00000000, 0x0600008d, 0x00100012, 0x00000000, 0x0020800a,
17681 0x00000000, 0x00000000, 0x0500008d, 0x00102022, 0x00000000, 0x0010000a, 0x00000000, 0x05000036,
17682 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0100003e,
17684 static const DWORD ps_bits_code
[] =
17690 uint4
main() : SV_Target
17692 return uint4(countbits(u
), firstbitlow(u
), firstbithigh(u
), firstbithigh(i
));
17695 0x43425844, 0x23fee911, 0x145287d1, 0xea904419, 0x8aa59a6a, 0x00000001, 0x000001b4, 0x00000003,
17696 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17697 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
17698 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000013c, 0x00000050, 0x0000004f,
17699 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
17700 0x02000068, 0x00000001, 0x06000089, 0x00100012, 0x00000000, 0x0020801a, 0x00000000, 0x00000000,
17701 0x07000020, 0x00100022, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0xffffffff, 0x0800001e,
17702 0x00100012, 0x00000000, 0x00004001, 0x0000001f, 0x8010000a, 0x00000041, 0x00000000, 0x09000037,
17703 0x00102082, 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0xffffffff, 0x0010000a, 0x00000000,
17704 0x06000087, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x0800001e, 0x00100012,
17705 0x00000000, 0x00004001, 0x0000001f, 0x8010000a, 0x00000041, 0x00000000, 0x0a000037, 0x00102042,
17706 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0xffffffff,
17707 0x06000086, 0x00102012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x06000088, 0x00102022,
17708 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x0100003e,
17710 static const DWORD ps_ftou_code
[] =
17715 uint4
main() : SV_Target
17717 return uint4(f
, -f
, 0, 0);
17720 0x43425844, 0xfde0ee2d, 0x812b339a, 0xb9fc36d2, 0x5820bec6, 0x00000001, 0x000000f4, 0x00000003,
17721 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17722 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
17723 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x0000007c, 0x00000040, 0x0000001f,
17724 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x0600001c,
17725 0x00102012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x0700001c, 0x00102022, 0x00000000,
17726 0x8020800a, 0x00000041, 0x00000000, 0x00000000, 0x08000036, 0x001020c2, 0x00000000, 0x00004002,
17727 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0100003e,
17729 static const DWORD ps_f16tof32_code
[] =
17734 uint4
main() : SV_Target
17736 return f16tof32(hf
);
17739 0x43425844, 0xc1816e6e, 0x27562d96, 0x56980fa2, 0x421e6640, 0x00000001, 0x000000d8, 0x00000003,
17740 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17741 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
17742 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000060, 0x00000050, 0x00000018,
17743 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
17744 0x02000068, 0x00000001, 0x06000083, 0x001000f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000000,
17745 0x0500001c, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x0100003e,
17747 static const DWORD ps_f32tof16_code
[] =
17752 uint4
main() : SV_Target
17754 return f32tof16(f
);
17757 0x43425844, 0x523a765c, 0x1a5be3a9, 0xaed69c80, 0xd26fe296, 0x00000001, 0x000000bc, 0x00000003,
17758 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17759 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
17760 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000044, 0x00000050, 0x00000011,
17761 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
17762 0x06000082, 0x001020f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x0100003e,
17764 static const DWORD ps_not_code
[] =
17769 uint4
main() : SV_Target
17771 return uint4(~bits
.x
, ~(bits
.x
^ ~0u), ~bits
.y
, ~(bits
.y
^ ~0u));
17774 0x43425844, 0xaed0fd26, 0xf719a878, 0xc832efd6, 0xba03c264, 0x00000001, 0x00000100, 0x00000003,
17775 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17776 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
17777 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000088, 0x00000040, 0x00000022,
17778 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
17779 0x00000001, 0x0b000057, 0x00100032, 0x00000000, 0x00208046, 0x00000000, 0x00000000, 0x00004002,
17780 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x0500003b, 0x001020a2, 0x00000000, 0x00100406,
17781 0x00000000, 0x0600003b, 0x00102052, 0x00000000, 0x00208106, 0x00000000, 0x00000000, 0x0100003e,
17783 static const struct shader ps_bfi
= {ps_bfi_code
, sizeof(ps_bfi_code
), D3D_FEATURE_LEVEL_11_0
};
17784 static const struct shader ps_bfi2
= {ps_bfi2_code
, sizeof(ps_bfi2_code
), D3D_FEATURE_LEVEL_11_0
};
17785 static const struct shader ps_ibfe
= {ps_ibfe_code
, sizeof(ps_ibfe_code
), D3D_FEATURE_LEVEL_11_0
};
17786 static const struct shader ps_ibfe2
= {ps_ibfe2_code
, sizeof(ps_ibfe2_code
), D3D_FEATURE_LEVEL_11_0
};
17787 static const struct shader ps_ubfe
= {ps_ubfe_code
, sizeof(ps_ubfe_code
), D3D_FEATURE_LEVEL_11_0
};
17788 static const struct shader ps_ubfe2
= {ps_ubfe2_code
, sizeof(ps_ubfe2_code
), D3D_FEATURE_LEVEL_11_0
};
17789 static const struct shader ps_bfrev
= {ps_bfrev_code
, sizeof(ps_bfrev_code
), D3D_FEATURE_LEVEL_11_0
};
17790 static const struct shader ps_bits
= {ps_bits_code
, sizeof(ps_bits_code
), D3D_FEATURE_LEVEL_11_0
};
17791 static const struct shader ps_ftou
= {ps_ftou_code
, sizeof(ps_ftou_code
), D3D_FEATURE_LEVEL_10_0
};
17792 static const struct shader ps_f16tof32
= {ps_f16tof32_code
, sizeof(ps_f16tof32_code
), D3D_FEATURE_LEVEL_11_0
};
17793 static const struct shader ps_f32tof16
= {ps_f32tof16_code
, sizeof(ps_f32tof16_code
), D3D_FEATURE_LEVEL_11_0
};
17794 static const struct shader ps_not
= {ps_not_code
, sizeof(ps_not_code
), D3D_FEATURE_LEVEL_10_0
};
17795 static const struct
17797 const struct shader
*ps
;
17798 unsigned int bits
[4];
17799 struct uvec4 expected_result
;
17803 {&ps_bfi
, { 0, 0, 0, 0}, { 0, 0, 0, 0}},
17804 {&ps_bfi
, { 0, 0, 0, 1}, { 1, 1, 1, 1}},
17805 {&ps_bfi
, { ~0u, 0, ~0u, 0}, {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff}},
17806 {&ps_bfi
, { ~0u, ~0u, ~0u, 0}, {0x80000000, 0x80000000, 0x80000000, 0x80000000}},
17807 {&ps_bfi
, { ~0u, 0x1fu
, ~0u, 0}, {0x80000000, 0x80000000, 0x80000000, 0x80000000}},
17808 {&ps_bfi
, { ~0u, ~0x1fu
, ~0u, 0}, {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff}},
17809 {&ps_bfi
, { 0, 0, 0xff, 1}, { 1, 1, 1, 1}},
17810 {&ps_bfi
, { 0, 0, 0xff, 2}, { 2, 2, 2, 2}},
17811 {&ps_bfi
, { 16, 16, 0xff, 0xff}, {0x00ff00ff, 0x00ff00ff, 0x00ff00ff, 0x00ff00ff}},
17812 {&ps_bfi
, { 0, 0, ~0u, ~0u}, { ~0u, ~0u, ~0u, ~0u}},
17813 {&ps_bfi
, {~0x1fu
, 0, ~0u, 0}, { 0, 0, 0, 0}},
17814 {&ps_bfi
, {~0x1fu
, 0, ~0u, 1}, { 1, 1, 1, 1}},
17815 {&ps_bfi
, {~0x1fu
, 0, ~0u, 2}, { 2, 2, 2, 2}},
17816 {&ps_bfi
, { 0, ~0x1fu
, ~0u, 0}, { 0, 0, 0, 0}},
17817 {&ps_bfi
, { 0, ~0x1fu
, ~0u, 1}, { 1, 1, 1, 1}},
17818 {&ps_bfi
, { 0, ~0x1fu
, ~0u, 2}, { 2, 2, 2, 2}},
17819 {&ps_bfi
, {~0x1fu
, ~0x1fu
, ~0u, 0}, { 0, 0, 0, 0}},
17820 {&ps_bfi
, {~0x1fu
, ~0x1fu
, ~0u, 1}, { 1, 1, 1, 1}},
17821 {&ps_bfi
, {~0x1fu
, ~0x1fu
, ~0u, 2}, { 2, 2, 2, 2}},
17823 {&ps_bfi2
, { ~0u, 0, ~0u, 0}, {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff}},
17824 {&ps_bfi2
, { ~0u, ~0u, ~0u, 0}, {0x80000000, 0x80000000, 0x80000000, 0x80000000}},
17825 {&ps_bfi2
, { ~0u, 0x1fu
, ~0u, 0}, {0x80000000, 0x80000000, 0x80000000, 0x80000000}},
17826 {&ps_bfi2
, { ~0u, ~0x1fu
, ~0u, 0}, {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff}},
17828 {&ps_ibfe
, { 0, 4, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}},
17829 {&ps_ibfe
, { 0, 4, 0xffffffff}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}},
17830 {&ps_ibfe
, { 0, 4, 0x7fffffff}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}},
17831 {&ps_ibfe
, { 4, 0, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}},
17832 {&ps_ibfe
, { 4, 0, 0xfffffffa}, {0xfffffffa, 0xfffffffa, 0xfffffffa, 0xfffffffa}},
17833 {&ps_ibfe
, { 4, 0, 0x7ffffffc}, {0xfffffffc, 0xfffffffc, 0xfffffffc, 0xfffffffc}},
17834 {&ps_ibfe
, { 4, 4, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}},
17835 {&ps_ibfe
, { 4, 4, 0xffffffff}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
17836 {&ps_ibfe
, { 4, 4, 0xffffff1f}, {0x00000001, 0x00000001, 0x00000001, 0x00000001}},
17837 {&ps_ibfe
, { 4, 4, 0x7fffffff}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
17838 {&ps_ibfe
, {23, 8, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}},
17839 {&ps_ibfe
, {23, 8, 0xffffffff}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
17840 {&ps_ibfe
, {23, 8, 0x7fffffff}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
17841 {&ps_ibfe
, {30, 1, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}},
17842 {&ps_ibfe
, {30, 1, 0xffffffff}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
17843 {&ps_ibfe
, {30, 1, 0x7fffffff}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
17844 {&ps_ibfe
, {15, 15, 0x7fffffff}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
17845 {&ps_ibfe
, {15, 15, 0x3fffffff}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
17846 {&ps_ibfe
, {15, 15, 0x1fffffff}, {0x00003fff, 0x00003fff, 0x00003fff, 0x00003fff}},
17847 {&ps_ibfe
, {15, 15, 0xffff00ff}, {0xfffffffe, 0xfffffffe, 0xfffffffe, 0xfffffffe}},
17848 {&ps_ibfe
, {16, 15, 0xffffffff}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
17849 {&ps_ibfe
, {16, 15, 0x3fffffff}, {0x00007fff, 0x00007fff, 0x00007fff, 0x00007fff}},
17850 {&ps_ibfe
, {20, 15, 0xffffffff}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
17851 {&ps_ibfe
, {31, 31, 0xffffffff}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
17852 {&ps_ibfe
, {31, 31, 0x80000000}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
17853 {&ps_ibfe
, {31, 31, 0x7fffffff}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}},
17855 {&ps_ibfe2
, {16, 15, 0x3fffffff}, {0x00007fff, 0x00007fff, 0x00007fff, 0x00007fff}},
17857 {&ps_ubfe
, {0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}},
17858 {&ps_ubfe
, {0xffffffff}, {0x0000000f, 0x007fffff, 0x0000007f, 0x3fffffff}},
17859 {&ps_ubfe
, {0xff000000}, {0x00000000, 0x007f0000, 0x00000000, 0x3f800000}},
17860 {&ps_ubfe
, {0x00ff0000}, {0x00000000, 0x0000ff00, 0x00000000, 0x007f8000}},
17861 {&ps_ubfe
, {0x000000ff}, {0x0000000f, 0x00000000, 0x0000007f, 0x0000007f}},
17862 {&ps_ubfe
, {0x80000001}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}},
17863 {&ps_ubfe
, {0xc0000003}, {0x00000000, 0x00400000, 0x00000001, 0x20000001}},
17865 {&ps_ubfe2
, { 4, 4, 0x7fffffff}, {0x0000000f, 0x0000000f, 0x0000000f, 0x0000000f}},
17866 {&ps_ubfe2
, {23, 8, 0xffffffff}, {0x007fffff, 0x007fffff, 0x007fffff, 0x007fffff}},
17867 {&ps_ubfe2
, {30, 1, 0xffffffff}, {0x3fffffff, 0x3fffffff, 0x3fffffff, 0x3fffffff}},
17868 {&ps_ubfe2
, {15, 15, 0x7fffffff}, {0x00007fff, 0x00007fff, 0x00007fff, 0x00007fff}},
17869 {&ps_ubfe2
, {15, 15, 0xffff00ff}, {0x00007ffe, 0x00007ffe, 0x00007ffe, 0x00007ffe}},
17870 {&ps_ubfe2
, {16, 15, 0xffffffff}, {0x0000ffff, 0x0000ffff, 0x0000ffff, 0x0000ffff}},
17871 {&ps_ubfe2
, {16, 15, 0x3fffffff}, {0x00007fff, 0x00007fff, 0x00007fff, 0x00007fff}},
17872 {&ps_ubfe2
, {20, 15, 0xffffffff}, {0x0001ffff, 0x0001ffff, 0x0001ffff, 0x0001ffff}},
17873 {&ps_ubfe2
, {31, 31, 0xffffffff}, {0x00000001, 0x00000001, 0x00000001, 0x00000001}},
17874 {&ps_ubfe2
, {31, 31, 0x80000000}, {0x00000001, 0x00000001, 0x00000001, 0x00000001}},
17875 {&ps_ubfe2
, {31, 31, 0x7fffffff}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}},
17877 {&ps_bfrev
, {0x12345678}, {0x1e6a2c48, 0x12345678, 0x1e6a0000, 0x2c480000}},
17878 {&ps_bfrev
, {0xffff0000}, {0x0000ffff, 0xffff0000, 0x00000000, 0xffff0000}},
17879 {&ps_bfrev
, {0xffffffff}, {0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000}},
17881 {&ps_bits
, { 0, 0}, { 0, ~0u, ~0u, ~0u}},
17882 {&ps_bits
, { ~0u, ~0u}, {32, 0, 31, ~0u}},
17883 {&ps_bits
, {0x7fffffff, 0x7fffffff}, {31, 0, 30, 30}},
17884 {&ps_bits
, {0x80000000, 0x80000000}, { 1, 31, 31, 30}},
17885 {&ps_bits
, {0x00000001, 0x00000001}, { 1, 0, 0, 0}},
17886 {&ps_bits
, {0x80000001, 0x80000001}, { 2, 0, 31, 30}},
17887 {&ps_bits
, {0x88888888, 0x88888888}, { 8, 3, 31, 30}},
17888 {&ps_bits
, {0xcccccccc, 0xcccccccc}, {16, 2, 31, 29}},
17889 {&ps_bits
, {0x11111111, 0x11111c11}, { 8, 0, 28, 28}},
17890 {&ps_bits
, {0x0000000f, 0x0000000f}, { 4, 0, 3, 3}},
17891 {&ps_bits
, {0x8000000f, 0x8000000f}, { 5, 0, 31, 30}},
17892 {&ps_bits
, {0x00080000, 0x00080000}, { 1, 19, 19, 19}},
17894 {&ps_ftou
, {BITS_NNAN
}, { 0, 0}},
17895 {&ps_ftou
, {BITS_NAN
}, { 0, 0}},
17896 {&ps_ftou
, {BITS_NINF
}, { 0, ~0u}},
17897 {&ps_ftou
, {BITS_INF
}, {~0u, 0}},
17898 {&ps_ftou
, {BITS_N1_0
}, { 0, 1}},
17899 {&ps_ftou
, {BITS_1_0
}, { 1, 0}},
17901 {&ps_f16tof32
, {0x00000000, 0x00003c00, 0x00005640, 0x00005bd0}, {0, 1, 100, 250}},
17902 {&ps_f16tof32
, {0x00010000, 0x00013c00, 0x00015640, 0x00015bd0}, {0, 1, 100, 250}},
17903 {&ps_f16tof32
, {0x000f0000, 0x000f3c00, 0x000f5640, 0x000f5bd0}, {0, 1, 100, 250}},
17904 {&ps_f16tof32
, {0xffff0000, 0xffff3c00, 0xffff5640, 0xffff5bd0}, {0, 1, 100, 250}},
17906 {&ps_f32tof16
, {0, BITS_1_0
, BITS_N1_0
, 0x44268000}, {0, 0x3c00, 0xbc00, 0x6134}},
17908 {&ps_not
, {0x00000000, 0xffffffff}, {0xffffffff, 0x00000000, 0x00000000, 0xffffffff}},
17909 {&ps_not
, {0xf0f0f0f0, 0x0f0f0f0f}, {0x0f0f0f0f, 0xf0f0f0f0, 0xf0f0f0f0, 0x0f0f0f0f}},
17912 if (!init_test_context(&test_context
, NULL
))
17915 device
= test_context
.device
;
17916 context
= test_context
.immediate_context
;
17917 feature_level
= ID3D11Device_GetFeatureLevel(device
);
17919 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(tests
[0].bits
), NULL
);
17920 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
17922 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
17923 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_UINT
;
17924 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
17925 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
17927 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
17928 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
17930 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
17932 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
17934 if (feature_level
< tests
[i
].ps
->required_feature_level
)
17937 hr
= ID3D11Device_CreatePixelShader(device
, tests
[i
].ps
->code
, tests
[i
].ps
->size
, NULL
, &ps
);
17938 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
17939 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
17941 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, tests
[i
].bits
, 0, 0);
17943 draw_quad(&test_context
);
17944 check_texture_uvec4(texture
, &tests
[i
].expected_result
);
17946 ID3D11PixelShader_Release(ps
);
17949 ID3D11Buffer_Release(cb
);
17950 ID3D11Texture2D_Release(texture
);
17951 ID3D11RenderTargetView_Release(rtv
);
17952 release_test_context(&test_context
);
17955 static void test_index_buffer_offset(void)
17957 ID3D11Buffer
*vb
, *ib
, *so_buffer
, *args_buffer
;
17958 struct d3d11_test_context test_context
;
17959 ID3D11InputLayout
*input_layout
;
17960 ID3D11DeviceContext
*context
;
17961 struct resource_readback rb
;
17962 ID3D11GeometryShader
*gs
;
17963 const struct vec4
*data
;
17964 ID3D11VertexShader
*vs
;
17965 ID3D11Device
*device
;
17966 UINT stride
, offset
;
17970 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
17971 static const DWORD vs_code
[] =
17974 void main(float4 position
: SV_POSITION
, float4 attrib
: ATTRIB
,
17975 out float4 out_position
: SV_Position
, out float4 out_attrib
: ATTRIB
)
17977 out_position
= position
;
17978 out_attrib
= attrib
;
17981 0x43425844, 0xd7716716, 0xe23207f3, 0xc8af57c0, 0x585e2919, 0x00000001, 0x00000144, 0x00000003,
17982 0x0000002c, 0x00000080, 0x000000d4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
17983 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000044, 0x00000000, 0x00000000,
17984 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52545441, 0xab004249,
17985 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
17986 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
17987 0x505f5653, 0x7469736f, 0x006e6f69, 0x52545441, 0xab004249, 0x52444853, 0x00000068, 0x00010040,
17988 0x0000001a, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067,
17989 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2,
17990 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001,
17993 static const DWORD gs_code
[] =
17998 float4 position
: SV_POSITION
;
17999 float4 attrib
: ATTRIB
;
18002 [maxvertexcount(1)]
18003 void main(point vertex input
[1], inout PointStream
<vertex
> output
)
18005 output
.Append(input
[0]);
18006 output
.RestartStrip();
18009 0x43425844, 0x3d1dc497, 0xdf450406, 0x284ab03b, 0xa4ec0fd6, 0x00000001, 0x00000170, 0x00000003,
18010 0x0000002c, 0x00000080, 0x000000d4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
18011 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x00000044, 0x00000000, 0x00000000,
18012 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52545441, 0xab004249,
18013 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
18014 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
18015 0x505f5653, 0x5449534f, 0x004e4f49, 0x52545441, 0xab004249, 0x52444853, 0x00000094, 0x00020040,
18016 0x00000025, 0x05000061, 0x002010f2, 0x00000001, 0x00000000, 0x00000001, 0x0400005f, 0x002010f2,
18017 0x00000001, 0x00000001, 0x0100085d, 0x0100085c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
18018 0x03000065, 0x001020f2, 0x00000001, 0x0200005e, 0x00000001, 0x06000036, 0x001020f2, 0x00000000,
18019 0x00201e46, 0x00000000, 0x00000000, 0x06000036, 0x001020f2, 0x00000001, 0x00201e46, 0x00000000,
18020 0x00000001, 0x01000013, 0x01000009, 0x0100003e,
18022 static const D3D11_INPUT_ELEMENT_DESC input_desc
[] =
18024 {"SV_POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18025 {"ATTRIB", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 16, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18027 static const D3D11_SO_DECLARATION_ENTRY so_declaration
[] =
18029 {0, "SV_Position", 0, 0, 4, 0},
18030 {0, "ATTRIB", 0, 0, 4, 0},
18032 static const struct
18034 struct vec4 position
;
18035 struct vec4 attrib
;
18039 {{-1.0f
, -1.0f
, 0.0f
, 1.0f
}, {1.0f
}},
18040 {{-1.0f
, 1.0f
, 0.0f
, 1.0f
}, {2.0f
}},
18041 {{ 1.0f
, -1.0f
, 0.0f
, 1.0f
}, {3.0f
}},
18042 {{ 1.0f
, 1.0f
, 0.0f
, 1.0f
}, {4.0f
}},
18044 static const unsigned int indices
[] =
18050 static const struct vec4 expected_data
[] =
18052 {-1.0f
, -1.0f
, 0.0f
, 1.0f
}, {1.0f
},
18053 {-1.0f
, 1.0f
, 0.0f
, 1.0f
}, {2.0f
},
18054 { 1.0f
, -1.0f
, 0.0f
, 1.0f
}, {3.0f
},
18055 { 1.0f
, 1.0f
, 0.0f
, 1.0f
}, {4.0f
},
18057 { 1.0f
, 1.0f
, 0.0f
, 1.0f
}, {4.0f
},
18058 { 1.0f
, -1.0f
, 0.0f
, 1.0f
}, {3.0f
},
18059 {-1.0f
, 1.0f
, 0.0f
, 1.0f
}, {2.0f
},
18060 {-1.0f
, -1.0f
, 0.0f
, 1.0f
}, {1.0f
},
18062 {-1.0f
, 1.0f
, 0.0f
, 1.0f
}, {2.0f
},
18063 { 1.0f
, 1.0f
, 0.0f
, 1.0f
}, {4.0f
},
18064 { 1.0f
, -1.0f
, 0.0f
, 1.0f
}, {3.0f
},
18065 {-1.0f
, -1.0f
, 0.0f
, 1.0f
}, {1.0f
},
18067 static const struct vec4 broken_result
= {0.0f
, 0.0f
, 0.0f
, 1.0f
};
18068 static const D3D11_DRAW_INDEXED_INSTANCED_INDIRECT_ARGS argument_data
[] =
18073 if (!init_test_context(&test_context
, &feature_level
))
18076 device
= test_context
.device
;
18077 context
= test_context
.immediate_context
;
18079 hr
= ID3D11Device_CreateInputLayout(device
, input_desc
, ARRAY_SIZE(input_desc
),
18080 vs_code
, sizeof(vs_code
), &input_layout
);
18081 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
18084 hr
= ID3D11Device_CreateGeometryShaderWithStreamOutput(device
, gs_code
, sizeof(gs_code
),
18085 so_declaration
, ARRAY_SIZE(so_declaration
),
18086 &stride
, 1, D3D11_SO_NO_RASTERIZED_STREAM
, NULL
, &gs
);
18087 ok(SUCCEEDED(hr
), "Failed to create geometry shader with stream output, hr %#x.\n", hr
);
18089 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
18090 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
18092 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(vertices
), vertices
);
18093 ib
= create_buffer(device
, D3D11_BIND_INDEX_BUFFER
, sizeof(indices
), indices
);
18094 so_buffer
= create_buffer(device
, D3D11_BIND_STREAM_OUTPUT
, 1024, NULL
);
18096 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
18097 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
18099 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
18100 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST
);
18101 stride
= sizeof(*vertices
);
18103 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, &stride
, &offset
);
18106 ID3D11DeviceContext_SOSetTargets(context
, 1, &so_buffer
, &offset
);
18108 ID3D11DeviceContext_IASetIndexBuffer(context
, ib
, DXGI_FORMAT_R32_UINT
, 0);
18109 ID3D11DeviceContext_DrawIndexed(context
, 4, 0, 0);
18111 ID3D11DeviceContext_IASetIndexBuffer(context
, ib
, DXGI_FORMAT_R32_UINT
, 4 * sizeof(*indices
));
18112 ID3D11DeviceContext_DrawIndexed(context
, 4, 0, 0);
18114 ID3D11DeviceContext_IASetIndexBuffer(context
, ib
, DXGI_FORMAT_R32_UINT
, 8 * sizeof(*indices
));
18115 ID3D11DeviceContext_DrawIndexed(context
, 4, 0, 0);
18117 get_buffer_readback(so_buffer
, &rb
);
18118 for (i
= 0; i
< ARRAY_SIZE(expected_data
); ++i
)
18120 data
= get_readback_vec4(&rb
, i
, 0);
18121 ok(compare_vec4(data
, &expected_data
[i
], 0)
18122 || broken(is_nvidia_device(device
) && !(i
% 2) && compare_vec4(data
, &broken_result
, 0)),
18123 "Got unexpected result {%.8e, %.8e, %.8e, %.8e} at %u.\n",
18124 data
->x
, data
->y
, data
->z
, data
->w
, i
);
18126 release_resource_readback(&rb
);
18128 /* indirect draws */
18129 args_buffer
= create_buffer_misc(device
, 0, D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS
,
18130 sizeof(argument_data
), argument_data
);
18133 ID3D11DeviceContext_SOSetTargets(context
, 1, &so_buffer
, &offset
);
18135 ID3D11DeviceContext_IASetIndexBuffer(context
, ib
, DXGI_FORMAT_R32_UINT
, 0);
18136 ID3D11DeviceContext_DrawIndexedInstancedIndirect(context
, args_buffer
, 0);
18138 ID3D11DeviceContext_IASetIndexBuffer(context
, ib
, DXGI_FORMAT_R32_UINT
, 4 * sizeof(*indices
));
18139 ID3D11DeviceContext_DrawIndexedInstancedIndirect(context
, args_buffer
, 0);
18141 ID3D11DeviceContext_IASetIndexBuffer(context
, ib
, DXGI_FORMAT_R32_UINT
, 8 * sizeof(*indices
));
18142 ID3D11DeviceContext_DrawIndexedInstancedIndirect(context
, args_buffer
, 0);
18144 get_buffer_readback(so_buffer
, &rb
);
18145 for (i
= 0; i
< ARRAY_SIZE(expected_data
); ++i
)
18147 data
= get_readback_vec4(&rb
, i
, 0);
18148 todo_wine_if(i
>= 8 && i
!= 20 && i
!= 21)
18149 ok(compare_vec4(data
, &expected_data
[i
], 0)
18150 || broken(is_nvidia_device(device
) && !(i
% 2) && compare_vec4(data
, &broken_result
, 0)),
18151 "Got unexpected result {%.8e, %.8e, %.8e, %.8e} at %u.\n",
18152 data
->x
, data
->y
, data
->z
, data
->w
, i
);
18154 release_resource_readback(&rb
);
18156 ID3D11Buffer_Release(so_buffer
);
18157 ID3D11Buffer_Release(args_buffer
);
18158 ID3D11Buffer_Release(ib
);
18159 ID3D11Buffer_Release(vb
);
18160 ID3D11VertexShader_Release(vs
);
18161 ID3D11GeometryShader_Release(gs
);
18162 ID3D11InputLayout_Release(input_layout
);
18163 release_test_context(&test_context
);
18166 static void test_face_culling(void)
18168 struct d3d11_test_context test_context
;
18169 D3D11_RASTERIZER_DESC rasterizer_desc
;
18170 ID3D11RasterizerState
*state
;
18171 ID3D11DeviceContext
*context
;
18172 ID3D11Buffer
*cw_vb
, *ccw_vb
;
18173 ID3D11Device
*device
;
18178 static const struct vec4 red
= {1.0f
, 0.0f
, 0.0f
, 1.0f
};
18179 static const struct vec4 green
= {0.0f
, 1.0f
, 0.0f
, 1.0f
};
18180 static const DWORD ps_code
[] =
18183 float4
main(uint front
: SV_IsFrontFace
) : SV_Target
18185 return (front
== ~0u) ? float4(0.0f
, 1.0f
, 0.0f
, 1.0f
) : float4(0.0f
, 0.0f
, 1.0f
, 1.0f
);
18188 0x43425844, 0x92002fad, 0xc5c620b9, 0xe7a154fb, 0x78b54e63, 0x00000001, 0x00000128, 0x00000003,
18189 0x0000002c, 0x00000064, 0x00000098, 0x4e475349, 0x00000030, 0x00000001, 0x00000008, 0x00000020,
18190 0x00000000, 0x00000009, 0x00000001, 0x00000000, 0x00000101, 0x495f5653, 0x6f724673, 0x6146746e,
18191 0xab006563, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
18192 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000088,
18193 0x00000040, 0x00000022, 0x04000863, 0x00101012, 0x00000000, 0x00000009, 0x03000065, 0x001020f2,
18194 0x00000000, 0x02000068, 0x00000001, 0x07000020, 0x00100012, 0x00000000, 0x0010100a, 0x00000000,
18195 0x00004001, 0xffffffff, 0x0f000037, 0x001020f2, 0x00000000, 0x00100006, 0x00000000, 0x00004002,
18196 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x00004002, 0x00000000, 0x00000000, 0x3f800000,
18197 0x3f800000, 0x0100003e,
18199 static const struct vec3 ccw_quad
[] =
18201 {-1.0f
, 1.0f
, 0.0f
},
18202 {-1.0f
, -1.0f
, 0.0f
},
18203 { 1.0f
, 1.0f
, 0.0f
},
18204 { 1.0f
, -1.0f
, 0.0f
},
18206 static const struct
18208 D3D11_CULL_MODE cull_mode
;
18215 {D3D11_CULL_NONE
, FALSE
, TRUE
, TRUE
},
18216 {D3D11_CULL_NONE
, TRUE
, TRUE
, TRUE
},
18217 {D3D11_CULL_FRONT
, FALSE
, FALSE
, TRUE
},
18218 {D3D11_CULL_FRONT
, TRUE
, TRUE
, FALSE
},
18219 {D3D11_CULL_BACK
, FALSE
, TRUE
, FALSE
},
18220 {D3D11_CULL_BACK
, TRUE
, FALSE
, TRUE
},
18223 if (!init_test_context(&test_context
, NULL
))
18226 device
= test_context
.device
;
18227 context
= test_context
.immediate_context
;
18229 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &red
.x
);
18230 draw_color_quad(&test_context
, &green
);
18231 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
18233 cw_vb
= test_context
.vb
;
18234 ccw_vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(ccw_quad
), ccw_quad
);
18236 test_context
.vb
= ccw_vb
;
18237 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &red
.x
);
18238 draw_color_quad(&test_context
, &green
);
18239 check_texture_color(test_context
.backbuffer
, 0xff0000ff, 0);
18241 rasterizer_desc
.FillMode
= D3D11_FILL_SOLID
;
18242 rasterizer_desc
.CullMode
= D3D11_CULL_BACK
;
18243 rasterizer_desc
.FrontCounterClockwise
= FALSE
;
18244 rasterizer_desc
.DepthBias
= 0;
18245 rasterizer_desc
.DepthBiasClamp
= 0.0f
;
18246 rasterizer_desc
.SlopeScaledDepthBias
= 0.0f
;
18247 rasterizer_desc
.DepthClipEnable
= TRUE
;
18248 rasterizer_desc
.ScissorEnable
= FALSE
;
18249 rasterizer_desc
.MultisampleEnable
= FALSE
;
18250 rasterizer_desc
.AntialiasedLineEnable
= FALSE
;
18252 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
18254 rasterizer_desc
.CullMode
= tests
[i
].cull_mode
;
18255 rasterizer_desc
.FrontCounterClockwise
= tests
[i
].front_ccw
;
18256 hr
= ID3D11Device_CreateRasterizerState(device
, &rasterizer_desc
, &state
);
18257 ok(SUCCEEDED(hr
), "Test %u: Failed to create rasterizer state, hr %#x.\n", i
, hr
);
18259 ID3D11DeviceContext_RSSetState(context
, state
);
18261 test_context
.vb
= cw_vb
;
18262 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &red
.x
);
18263 draw_color_quad(&test_context
, &green
);
18264 check_texture_color(test_context
.backbuffer
, tests
[i
].expected_cw
? 0xff00ff00 : 0xff0000ff, 0);
18266 test_context
.vb
= ccw_vb
;
18267 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &red
.x
);
18268 draw_color_quad(&test_context
, &green
);
18269 check_texture_color(test_context
.backbuffer
, tests
[i
].expected_ccw
? 0xff00ff00 : 0xff0000ff, 0);
18271 ID3D11RasterizerState_Release(state
);
18274 broken_warp
= is_warp_device(device
) && ID3D11Device_GetFeatureLevel(device
) < D3D_FEATURE_LEVEL_11_0
;
18276 /* Test SV_IsFrontFace. */
18277 ID3D11PixelShader_Release(test_context
.ps
);
18278 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &test_context
.ps
);
18279 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
18281 rasterizer_desc
.CullMode
= D3D11_CULL_NONE
;
18282 rasterizer_desc
.FrontCounterClockwise
= FALSE
;
18283 hr
= ID3D11Device_CreateRasterizerState(device
, &rasterizer_desc
, &state
);
18284 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
18285 ID3D11DeviceContext_RSSetState(context
, state
);
18287 test_context
.vb
= cw_vb
;
18288 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &red
.x
);
18289 draw_color_quad(&test_context
, &green
);
18290 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
18291 test_context
.vb
= ccw_vb
;
18292 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &red
.x
);
18293 draw_color_quad(&test_context
, &green
);
18295 check_texture_color(test_context
.backbuffer
, 0xffff0000, 0);
18297 win_skip("Broken WARP.\n");
18299 ID3D11RasterizerState_Release(state
);
18301 rasterizer_desc
.CullMode
= D3D11_CULL_NONE
;
18302 rasterizer_desc
.FrontCounterClockwise
= TRUE
;
18303 hr
= ID3D11Device_CreateRasterizerState(device
, &rasterizer_desc
, &state
);
18304 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
18305 ID3D11DeviceContext_RSSetState(context
, state
);
18307 test_context
.vb
= cw_vb
;
18308 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &red
.x
);
18309 draw_color_quad(&test_context
, &green
);
18311 check_texture_color(test_context
.backbuffer
, 0xffff0000 , 0);
18313 win_skip("Broken WARP.\n");
18314 test_context
.vb
= ccw_vb
;
18315 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &red
.x
);
18316 draw_color_quad(&test_context
, &green
);
18317 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
18319 ID3D11RasterizerState_Release(state
);
18321 test_context
.vb
= cw_vb
;
18322 ID3D11Buffer_Release(ccw_vb
);
18323 release_test_context(&test_context
);
18326 static void test_line_antialiasing_blending(void)
18328 ID3D11RasterizerState
*rasterizer_state
;
18329 struct d3d11_test_context test_context
;
18330 D3D11_RASTERIZER_DESC rasterizer_desc
;
18331 ID3D11BlendState
*blend_state
;
18332 ID3D11DeviceContext
*context
;
18333 D3D11_BLEND_DESC blend_desc
;
18334 ID3D11Device
*device
;
18337 static const struct vec4 red
= {1.0f
, 0.0f
, 0.0f
, 0.8f
};
18338 static const struct vec4 green
= {0.0f
, 1.0f
, 0.0f
, 0.5f
};
18340 if (!init_test_context(&test_context
, NULL
))
18343 device
= test_context
.device
;
18344 context
= test_context
.immediate_context
;
18346 memset(&blend_desc
, 0, sizeof(blend_desc
));
18347 blend_desc
.AlphaToCoverageEnable
= FALSE
;
18348 blend_desc
.IndependentBlendEnable
= FALSE
;
18349 blend_desc
.RenderTarget
[0].BlendEnable
= TRUE
;
18350 blend_desc
.RenderTarget
[0].SrcBlend
= D3D11_BLEND_SRC_ALPHA
;
18351 blend_desc
.RenderTarget
[0].DestBlend
= D3D11_BLEND_DEST_ALPHA
;
18352 blend_desc
.RenderTarget
[0].BlendOp
= D3D11_BLEND_OP_ADD
;
18353 blend_desc
.RenderTarget
[0].SrcBlendAlpha
= D3D11_BLEND_SRC_ALPHA
;
18354 blend_desc
.RenderTarget
[0].DestBlendAlpha
= D3D11_BLEND_DEST_ALPHA
;
18355 blend_desc
.RenderTarget
[0].BlendOpAlpha
= D3D11_BLEND_OP_ADD
;
18356 blend_desc
.RenderTarget
[0].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_ALL
;
18358 hr
= ID3D11Device_CreateBlendState(device
, &blend_desc
, &blend_state
);
18359 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
18360 ID3D11DeviceContext_OMSetBlendState(context
, blend_state
, NULL
, D3D11_DEFAULT_SAMPLE_MASK
);
18362 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &red
.x
);
18363 draw_color_quad(&test_context
, &green
);
18364 check_texture_color(test_context
.backbuffer
, 0xe2007fcc, 1);
18366 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &green
.x
);
18367 draw_color_quad(&test_context
, &red
);
18368 check_texture_color(test_context
.backbuffer
, 0xe2007fcc, 1);
18370 ID3D11DeviceContext_OMSetBlendState(context
, NULL
, NULL
, D3D11_DEFAULT_SAMPLE_MASK
);
18371 ID3D11BlendState_Release(blend_state
);
18373 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &red
.x
);
18374 draw_color_quad(&test_context
, &green
);
18375 check_texture_color(test_context
.backbuffer
, 0x7f00ff00, 1);
18377 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &green
.x
);
18378 draw_color_quad(&test_context
, &red
);
18379 check_texture_color(test_context
.backbuffer
, 0xcc0000ff, 1);
18381 rasterizer_desc
.FillMode
= D3D11_FILL_SOLID
;
18382 rasterizer_desc
.CullMode
= D3D11_CULL_BACK
;
18383 rasterizer_desc
.FrontCounterClockwise
= FALSE
;
18384 rasterizer_desc
.DepthBias
= 0;
18385 rasterizer_desc
.DepthBiasClamp
= 0.0f
;
18386 rasterizer_desc
.SlopeScaledDepthBias
= 0.0f
;
18387 rasterizer_desc
.DepthClipEnable
= TRUE
;
18388 rasterizer_desc
.ScissorEnable
= FALSE
;
18389 rasterizer_desc
.MultisampleEnable
= FALSE
;
18390 rasterizer_desc
.AntialiasedLineEnable
= TRUE
;
18392 hr
= ID3D11Device_CreateRasterizerState(device
, &rasterizer_desc
, &rasterizer_state
);
18393 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
18394 ID3D11DeviceContext_RSSetState(context
, rasterizer_state
);
18396 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &red
.x
);
18397 draw_color_quad(&test_context
, &green
);
18398 check_texture_color(test_context
.backbuffer
, 0x7f00ff00, 1);
18400 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &green
.x
);
18401 draw_color_quad(&test_context
, &red
);
18402 check_texture_color(test_context
.backbuffer
, 0xcc0000ff, 1);
18404 ID3D11RasterizerState_Release(rasterizer_state
);
18405 release_test_context(&test_context
);
18408 static void check_format_support(const unsigned int *format_support
, D3D_FEATURE_LEVEL feature_level
,
18409 const struct format_support
*formats
, unsigned int format_count
, unsigned int feature_flag
,
18410 const char *feature_name
)
18414 for (i
= 0; i
< format_count
; ++i
)
18416 DXGI_FORMAT format
= formats
[i
].format
;
18417 unsigned int supported
= format_support
[format
] & feature_flag
;
18419 if (formats
[i
].fl_required
<= feature_level
)
18421 todo_wine
ok(supported
, "Format %#x - %s not supported, feature_level %#x, format support %#x.\n",
18422 format
, feature_name
, feature_level
, format_support
[format
]);
18426 if (formats
[i
].fl_optional
&& formats
[i
].fl_optional
<= feature_level
)
18429 trace("Optional format %#x - %s supported, feature level %#x.\n",
18430 format
, feature_name
, feature_level
);
18434 ok(!supported
, "Format %#x - %s supported, feature level %#x, format support %#x.\n",
18435 format
, feature_name
, feature_level
, format_support
[format
]);
18439 static void test_format_support(const D3D_FEATURE_LEVEL feature_level
)
18441 unsigned int format_support
[DXGI_FORMAT_B4G4R4A4_UNORM
+ 1];
18442 struct device_desc device_desc
;
18443 ID3D11Device
*device
;
18444 DXGI_FORMAT format
;
18449 static const struct format_support index_buffers
[] =
18451 {DXGI_FORMAT_R32_UINT
, D3D_FEATURE_LEVEL_9_2
},
18452 {DXGI_FORMAT_R16_UINT
, D3D_FEATURE_LEVEL_9_1
},
18455 device_desc
.feature_level
= &feature_level
;
18456 device_desc
.flags
= 0;
18457 if (!(device
= create_device(&device_desc
)))
18459 skip("Failed to create device for feature level %#x.\n", feature_level
);
18463 support
= 0xdeadbeef;
18464 hr
= ID3D11Device_CheckFormatSupport(device
, ~0u, &support
);
18465 ok(hr
== E_FAIL
, "Got unexpected hr %#x.\n", hr
);
18466 ok(!support
, "Got unexpected format support %#x.\n", support
);
18468 memset(format_support
, 0, sizeof(format_support
));
18469 for (format
= DXGI_FORMAT_UNKNOWN
; format
<= DXGI_FORMAT_B4G4R4A4_UNORM
; ++format
)
18471 hr
= ID3D11Device_CheckFormatSupport(device
, format
, &format_support
[format
]);
18472 ok(hr
== S_OK
|| (hr
== E_FAIL
&& !format_support
[format
]),
18473 "Got unexpected result for format %#x: hr %#x, format_support %#x.\n",
18474 format
, hr
, format_support
[format
]);
18477 for (format
= DXGI_FORMAT_UNKNOWN
; format
<= DXGI_FORMAT_B4G4R4A4_UNORM
; ++format
)
18479 if (feature_level
< D3D_FEATURE_LEVEL_10_0
)
18481 /* SHADER_SAMPLE_COMPARISON is never advertised as supported on feature level 9. */
18482 ok(!(format_support
[format
] & D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON
),
18483 "Unexpected SHADER_SAMPLE_COMPARISON for format %#x, feature level %#x.\n",
18484 format
, feature_level
);
18486 if (feature_level
< D3D_FEATURE_LEVEL_10_1
)
18488 ok(!(format_support
[format
] & D3D11_FORMAT_SUPPORT_SHADER_GATHER
),
18489 "Unexpected SHADER_GATHER for format %#x, feature level %#x.\n",
18490 format
, feature_level
);
18491 ok(!(format_support
[format
] & D3D11_FORMAT_SUPPORT_SHADER_GATHER_COMPARISON
),
18492 "Unexpected SHADER_GATHER_COMPARISON for format %#x, feature level %#x.\n",
18493 format
, feature_level
);
18497 ok(format_support
[DXGI_FORMAT_R8G8B8A8_UNORM
] & D3D11_FORMAT_SUPPORT_SHADER_SAMPLE
,
18498 "SHADER_SAMPLE is not supported for R8G8B8A8_UNORM.\n");
18500 ok(!(format_support
[DXGI_FORMAT_R32G32B32A32_UINT
] & D3D11_FORMAT_SUPPORT_SHADER_SAMPLE
),
18501 "SHADER_SAMPLE is supported for R32G32B32A32_UINT.\n");
18502 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
18504 ok(format_support
[DXGI_FORMAT_R32G32B32A32_UINT
] & D3D11_FORMAT_SUPPORT_SHADER_LOAD
,
18505 "SHADER_LOAD is not supported for R32G32B32A32_UINT.\n");
18508 check_format_support(format_support
, feature_level
,
18509 index_buffers
, ARRAY_SIZE(index_buffers
),
18510 D3D11_FORMAT_SUPPORT_IA_INDEX_BUFFER
, "index buffer");
18512 check_format_support(format_support
, feature_level
,
18513 display_format_support
, ARRAY_SIZE(display_format_support
),
18514 D3D11_FORMAT_SUPPORT_DISPLAY
, "display");
18516 refcount
= ID3D11Device_Release(device
);
18517 ok(!refcount
, "Device has %u references left.\n", refcount
);
18520 static void test_fl9_draw(const D3D_FEATURE_LEVEL feature_level
)
18522 struct d3d11_test_context test_context
;
18523 D3D11_SUBRESOURCE_DATA resource_data
;
18524 D3D11_TEXTURE2D_DESC texture_desc
;
18525 ID3D11ShaderResourceView
*srv
;
18526 ID3D11DeviceContext
*context
;
18527 ID3D11Texture2D
*texture
;
18528 ID3D11PixelShader
*ps
;
18529 ID3D11Device
*device
;
18532 static const struct vec4 color
= {0.2f
, 0.3f
, 0.0f
, 1.0f
};
18533 static const DWORD ps_code
[] =
18536 float4
main() : SV_TARGET
18538 return float4(1.0f
, 0.0f
, 0.0f
, 0.5f
);
18541 0x43425844, 0xb70eda74, 0xc9a7f982, 0xebc31bbf, 0x952a1360, 0x00000001, 0x00000168, 0x00000005,
18542 0x00000034, 0x0000008c, 0x000000e4, 0x00000124, 0x00000134, 0x53414e58, 0x00000050, 0x00000050,
18543 0xffff0200, 0x0000002c, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0x00240000,
18544 0xffff0200, 0x05000051, 0xa00f0000, 0x3f800000, 0x00000000, 0x00000000, 0x3f000000, 0x02000001,
18545 0x800f0800, 0xa0e40000, 0x0000ffff, 0x396e6f41, 0x00000050, 0x00000050, 0xffff0200, 0x0000002c,
18546 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0xffff0200, 0x05000051,
18547 0xa00f0000, 0x3f800000, 0x00000000, 0x00000000, 0x3f000000, 0x02000001, 0x800f0800, 0xa0e40000,
18548 0x0000ffff, 0x52444853, 0x00000038, 0x00000040, 0x0000000e, 0x03000065, 0x001020f2, 0x00000000,
18549 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f000000,
18550 0x0100003e, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, 0x0000002c, 0x00000001,
18551 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653,
18552 0x45475241, 0xabab0054,
18554 static const DWORD ps_texture_code
[] =
18560 float4
main() : SV_TARGET
18562 return t
.Sample(s
, (float2
)0);
18565 0x43425844, 0xf876c2db, 0x13725f1f, 0xcb6d3d65, 0x9994473f, 0x00000001, 0x000001d4, 0x00000005,
18566 0x00000034, 0x000000a0, 0x00000124, 0x00000190, 0x000001a0, 0x53414e58, 0x00000064, 0x00000064,
18567 0xffff0200, 0x0000003c, 0x00000028, 0x00280000, 0x00280000, 0x00280000, 0x00240001, 0x00280000,
18568 0x00000000, 0xffff0200, 0x05000051, 0xa00f0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
18569 0x0200001f, 0x90000000, 0xa00f0800, 0x03000042, 0x800f0800, 0xa0000000, 0xa0e40800, 0x0000ffff,
18570 0x396e6f41, 0x0000007c, 0x0000007c, 0xffff0200, 0x00000054, 0x00000028, 0x00280000, 0x00280000,
18571 0x00280000, 0x00240001, 0x00280000, 0x00000000, 0xffff0200, 0x05000051, 0xa00f0000, 0x00000000,
18572 0x00000000, 0x00000000, 0x00000000, 0x0200001f, 0x90000000, 0xa00f0800, 0x02000001, 0x80030000,
18573 0xa0000000, 0x03000042, 0x800f0000, 0x80e40000, 0xa0e40800, 0x02000001, 0x800f0800, 0x80e40000,
18574 0x0000ffff, 0x52444853, 0x00000064, 0x00000040, 0x00000019, 0x0300005a, 0x00106000, 0x00000000,
18575 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x03000065, 0x001020f2, 0x00000000, 0x0c000045,
18576 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00107e46,
18577 0x00000000, 0x00106000, 0x00000000, 0x0100003e, 0x4e475349, 0x00000008, 0x00000000, 0x00000008,
18578 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
18579 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054,
18581 static const DWORD texture_data
[] = {0xffffff00};
18583 if (!init_test_context(&test_context
, &feature_level
))
18586 device
= test_context
.device
;
18587 context
= test_context
.immediate_context
;
18589 texture_desc
.Width
= 1;
18590 texture_desc
.Height
= 1;
18591 texture_desc
.MipLevels
= 0;
18592 texture_desc
.ArraySize
= 1;
18593 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
18594 texture_desc
.SampleDesc
.Count
= 1;
18595 texture_desc
.SampleDesc
.Quality
= 0;
18596 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
18597 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
18598 texture_desc
.CPUAccessFlags
= 0;
18599 texture_desc
.MiscFlags
= 0;
18600 resource_data
.pSysMem
= texture_data
;
18601 resource_data
.SysMemPitch
= sizeof(texture_data
);
18602 resource_data
.SysMemSlicePitch
= 0;
18603 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &texture
);
18604 ok(SUCCEEDED(hr
), "Failed to create 2d texture, hr %#x.\n", hr
);
18605 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
18606 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
18608 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
18609 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
18610 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
18611 draw_quad(&test_context
);
18612 check_texture_color(test_context
.backbuffer
, 0x7f0000ff, 1);
18613 ID3D11PixelShader_Release(ps
);
18615 draw_color_quad(&test_context
, &color
);
18616 todo_wine
check_texture_color(test_context
.backbuffer
, 0xff004c33, 1);
18618 hr
= ID3D11Device_CreatePixelShader(device
, ps_texture_code
, sizeof(ps_texture_code
), NULL
, &ps
);
18619 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
18620 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
18621 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
18622 draw_quad(&test_context
);
18623 check_texture_color(test_context
.backbuffer
, 0xffffff00, 1);
18624 ID3D11PixelShader_Release(ps
);
18626 ID3D11ShaderResourceView_Release(srv
);
18627 ID3D11Texture2D_Release(texture
);
18628 release_test_context(&test_context
);
18631 static void queue_for_each_feature_level_in_range(D3D_FEATURE_LEVEL begin
,
18632 D3D_FEATURE_LEVEL end
, void (*test_func
)(const D3D_FEATURE_LEVEL fl
))
18634 static const D3D_FEATURE_LEVEL feature_levels
[] =
18636 D3D_FEATURE_LEVEL_11_1
,
18637 D3D_FEATURE_LEVEL_11_0
,
18638 D3D_FEATURE_LEVEL_10_1
,
18639 D3D_FEATURE_LEVEL_10_0
,
18640 D3D_FEATURE_LEVEL_9_3
,
18641 D3D_FEATURE_LEVEL_9_2
,
18642 D3D_FEATURE_LEVEL_9_1
18646 assert(begin
<= end
);
18647 for (i
= 0; i
< ARRAY_SIZE(feature_levels
); ++i
)
18649 if (begin
<= feature_levels
[i
] && feature_levels
[i
] <= end
)
18650 queue_test_fl(test_func
, feature_levels
[i
]);
18654 static void queue_for_each_feature_level(void (*test_func
)(const D3D_FEATURE_LEVEL fl
))
18656 queue_for_each_feature_level_in_range(D3D_FEATURE_LEVEL_9_1
,
18657 D3D_FEATURE_LEVEL_11_1
, test_func
);
18660 static void queue_for_each_9_x_feature_level(void (*test_func
)(const D3D_FEATURE_LEVEL fl
))
18662 queue_for_each_feature_level_in_range(D3D_FEATURE_LEVEL_9_1
,
18663 D3D_FEATURE_LEVEL_9_3
, test_func
);
18666 static void test_ddy(void)
18668 static const struct
18670 struct vec4 position
;
18671 unsigned int color
;
18675 {{-1.0f
, -1.0f
, 0.0f
, 1.0f
}, 0x00ff0000},
18676 {{-1.0f
, 1.0f
, 0.0f
, 1.0f
}, 0x0000ff00},
18677 {{ 1.0f
, -1.0f
, 0.0f
, 1.0f
}, 0x00ff0000},
18678 {{ 1.0f
, 1.0f
, 0.0f
, 1.0f
}, 0x0000ff00},
18680 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
18682 {"SV_POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18683 {"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, 16, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18688 float4 pos
: SV_POSITION
;
18689 float4 color
: COLOR
;
18692 void main(in
struct vs_data vs_input
, out
struct vs_data vs_output
)
18694 vs_output
.pos
= vs_input
.pos
;
18695 vs_output
.color
= vs_input
.color
;
18698 static const DWORD vs_code
[] =
18700 0x43425844, 0xd5b32785, 0x35332906, 0x4d05e031, 0xf66a58af, 0x00000001, 0x00000144, 0x00000003,
18701 0x0000002c, 0x00000080, 0x000000d4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
18702 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000044, 0x00000000, 0x00000000,
18703 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
18704 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
18705 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
18706 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000068, 0x00010040,
18707 0x0000001a, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067,
18708 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2,
18709 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001,
18715 float4 pos
: SV_POSITION
;
18716 float4 color
: COLOR
;
18719 float4
main(struct ps_data ps_input
) : SV_Target
18721 return ddy(ps_input
.color
) * 240.0 + 0.5;
18724 static const DWORD ps_code_ddy
[] =
18726 0x43425844, 0x423712f6, 0x786c59c2, 0xa6023c60, 0xb79faad2, 0x00000001, 0x00000138, 0x00000003,
18727 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
18728 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
18729 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
18730 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
18731 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x0000007c, 0x00000040,
18732 0x0000001f, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
18733 0x00000001, 0x0500000c, 0x001000f2, 0x00000000, 0x00101e46, 0x00000001, 0x0f000032, 0x001020f2,
18734 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x43700000, 0x43700000, 0x43700000, 0x43700000,
18735 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, 0x0100003e,
18740 float4 pos
: SV_POSITION
;
18741 float4 color
: COLOR
;
18744 float4
main(struct ps_data ps_input
) : SV_Target
18746 return ddy_coarse(ps_input
.color
) * 240.0 + 0.5;
18749 static const DWORD ps_code_ddy_coarse
[] =
18751 0x43425844, 0xbf9a31cb, 0xb42695b6, 0x629119b8, 0x6962d5dd, 0x00000001, 0x0000013c, 0x00000003,
18752 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
18753 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
18754 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
18755 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
18756 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000080, 0x00000050,
18757 0x00000020, 0x0100086a, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
18758 0x02000068, 0x00000001, 0x0500007c, 0x001000f2, 0x00000000, 0x00101e46, 0x00000001, 0x0f000032,
18759 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x43700000, 0x43700000, 0x43700000,
18760 0x43700000, 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, 0x0100003e,
18765 float4 pos
: SV_POSITION
;
18766 float4 color
: COLOR
;
18769 float4
main(struct ps_data ps_input
) : SV_Target
18771 return ddy_fine(ps_input
.color
) * 240.0 + 0.5;
18774 static const DWORD ps_code_ddy_fine
[] =
18776 0x43425844, 0xea6563ae, 0x3ee0da50, 0x4c2b3ef3, 0xa69a4077, 0x00000001, 0x0000013c, 0x00000003,
18777 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
18778 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
18779 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
18780 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
18781 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000080, 0x00000050,
18782 0x00000020, 0x0100086a, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
18783 0x02000068, 0x00000001, 0x0500007d, 0x001000f2, 0x00000000, 0x00101e46, 0x00000001, 0x0f000032,
18784 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x43700000, 0x43700000, 0x43700000,
18785 0x43700000, 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, 0x0100003e,
18787 static const struct
18789 D3D_FEATURE_LEVEL min_feature_level
;
18790 const DWORD
*ps_code
;
18791 unsigned int ps_code_size
;
18795 {D3D_FEATURE_LEVEL_10_0
, ps_code_ddy
, sizeof(ps_code_ddy
)},
18796 {D3D_FEATURE_LEVEL_11_0
, ps_code_ddy_coarse
, sizeof(ps_code_ddy_coarse
)},
18797 {D3D_FEATURE_LEVEL_11_0
, ps_code_ddy_fine
, sizeof(ps_code_ddy_fine
)},
18799 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 1.0f
};
18800 struct d3d11_test_context test_context
;
18801 D3D11_TEXTURE2D_DESC texture_desc
;
18802 D3D_FEATURE_LEVEL feature_level
;
18803 ID3D11InputLayout
*input_layout
;
18804 ID3D11DeviceContext
*context
;
18805 unsigned int stride
, offset
;
18806 struct resource_readback rb
;
18807 ID3D11RenderTargetView
*rtv
;
18808 ID3D11Texture2D
*texture
;
18809 ID3D11VertexShader
*vs
;
18810 ID3D11PixelShader
*ps
;
18811 ID3D11Device
*device
;
18817 if (!init_test_context(&test_context
, NULL
))
18820 device
= test_context
.device
;
18821 context
= test_context
.immediate_context
;
18822 feature_level
= ID3D11Device_GetFeatureLevel(device
);
18824 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
18825 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
18826 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
18828 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
18829 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
18831 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
18832 vs_code
, sizeof(vs_code
), &input_layout
);
18833 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
18835 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(quad
), quad
);
18837 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
18838 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
18840 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
18841 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
18842 stride
= sizeof(*quad
);
18844 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, &stride
, &offset
);
18845 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
18847 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
18849 if (feature_level
< tests
[i
].min_feature_level
)
18851 skip("Skipping test %u, feature_level %#x lower than minimum required %#x.\n", i
,
18852 feature_level
, tests
[i
].min_feature_level
);
18856 hr
= ID3D11Device_CreatePixelShader(device
, tests
[i
].ps_code
, tests
[i
].ps_code_size
, NULL
, &ps
);
18857 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
18859 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
18861 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
18862 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, red
);
18863 ID3D11DeviceContext_Draw(context
, 4, 0);
18865 get_texture_readback(texture
, 0, &rb
);
18866 color
= get_readback_color(&rb
, 320, 190, 0);
18867 ok(compare_color(color
, 0x7fff007f, 1), "Got unexpected color 0x%08x.\n", color
);
18868 color
= get_readback_color(&rb
, 255, 240, 0);
18869 ok(compare_color(color
, 0x7fff007f, 1), "Got unexpected color 0x%08x.\n", color
);
18870 color
= get_readback_color(&rb
, 320, 240, 0);
18871 ok(compare_color(color
, 0x7fff007f, 1), "Got unexpected color 0x%08x.\n", color
);
18872 color
= get_readback_color(&rb
, 385, 240, 0);
18873 ok(compare_color(color
, 0x7fff007f, 1), "Got unexpected color 0x%08x.\n", color
);
18874 color
= get_readback_color(&rb
, 320, 290, 0);
18875 ok(compare_color(color
, 0x7fff007f, 1), "Got unexpected color 0x%08x.\n", color
);
18876 release_resource_readback(&rb
);
18878 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &test_context
.backbuffer_rtv
, NULL
);
18879 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
18880 ID3D11DeviceContext_Draw(context
, 4, 0);
18882 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
18883 color
= get_readback_color(&rb
, 320, 190, 0);
18884 ok(compare_color(color
, 0x7fff007f, 1), "Got unexpected color 0x%08x.\n", color
);
18885 color
= get_readback_color(&rb
, 255, 240, 0);
18886 ok(compare_color(color
, 0x7fff007f, 1), "Got unexpected color 0x%08x.\n", color
);
18887 color
= get_readback_color(&rb
, 320, 240, 0);
18888 ok(compare_color(color
, 0x7fff007f, 1), "Got unexpected color 0x%08x.\n", color
);
18889 color
= get_readback_color(&rb
, 385, 240, 0);
18890 ok(compare_color(color
, 0x7fff007f, 1), "Got unexpected color 0x%08x.\n", color
);
18891 color
= get_readback_color(&rb
, 320, 290, 0);
18892 ok(compare_color(color
, 0x7fff007f, 1), "Got unexpected color 0x%08x.\n", color
);
18893 release_resource_readback(&rb
);
18895 ID3D11PixelShader_Release(ps
);
18898 ID3D11VertexShader_Release(vs
);
18899 ID3D11Buffer_Release(vb
);
18900 ID3D11InputLayout_Release(input_layout
);
18901 ID3D11Texture2D_Release(texture
);
18902 ID3D11RenderTargetView_Release(rtv
);
18903 release_test_context(&test_context
);
18906 static void test_shader_input_registers_limits(void)
18908 struct d3d11_test_context test_context
;
18909 D3D11_SUBRESOURCE_DATA resource_data
;
18910 D3D11_TEXTURE2D_DESC texture_desc
;
18911 D3D11_SAMPLER_DESC sampler_desc
;
18912 ID3D11ShaderResourceView
*srv
;
18913 ID3D11DeviceContext
*context
;
18914 ID3D11SamplerState
*sampler
;
18915 ID3D11Texture2D
*texture
;
18916 ID3D11PixelShader
*ps
;
18917 ID3D11Device
*device
;
18920 static const DWORD ps_last_register_code
[] =
18923 Texture2D t
: register(t127
);
18924 SamplerState s
: register(s15
);
18926 void main(out float4 target
: SV_Target
)
18928 target
= t
.Sample(s
, float2(0, 0));
18931 0x43425844, 0xd81ff2f8, 0x8c704b9c, 0x8c6f4857, 0xd02949ac, 0x00000001, 0x000000dc, 0x00000003,
18932 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
18933 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
18934 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000064, 0x00000040, 0x00000019,
18935 0x0300005a, 0x00106000, 0x0000000f, 0x04001858, 0x00107000, 0x0000007f, 0x00005555, 0x03000065,
18936 0x001020f2, 0x00000000, 0x0c000045, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000,
18937 0x00000000, 0x00000000, 0x00107e46, 0x0000007f, 0x00106000, 0x0000000f, 0x0100003e,
18939 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
18940 static const DWORD texture_data
[] = {0xff00ff00};
18942 if (!init_test_context(&test_context
, NULL
))
18945 device
= test_context
.device
;
18946 context
= test_context
.immediate_context
;
18948 texture_desc
.Width
= 1;
18949 texture_desc
.Height
= 1;
18950 texture_desc
.MipLevels
= 0;
18951 texture_desc
.ArraySize
= 1;
18952 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
18953 texture_desc
.SampleDesc
.Count
= 1;
18954 texture_desc
.SampleDesc
.Quality
= 0;
18955 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
18956 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
18957 texture_desc
.CPUAccessFlags
= 0;
18958 texture_desc
.MiscFlags
= 0;
18960 resource_data
.pSysMem
= texture_data
;
18961 resource_data
.SysMemPitch
= sizeof(texture_data
);
18962 resource_data
.SysMemSlicePitch
= 0;
18964 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &texture
);
18965 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
18967 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
18968 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
18970 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
18971 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
18972 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
18973 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
18974 sampler_desc
.MipLODBias
= 0.0f
;
18975 sampler_desc
.MaxAnisotropy
= 0;
18976 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
18977 sampler_desc
.BorderColor
[0] = 0.0f
;
18978 sampler_desc
.BorderColor
[1] = 0.0f
;
18979 sampler_desc
.BorderColor
[2] = 0.0f
;
18980 sampler_desc
.BorderColor
[3] = 0.0f
;
18981 sampler_desc
.MinLOD
= 0.0f
;
18982 sampler_desc
.MaxLOD
= 0.0f
;
18984 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler
);
18985 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
18987 hr
= ID3D11Device_CreatePixelShader(device
, ps_last_register_code
, sizeof(ps_last_register_code
), NULL
, &ps
);
18988 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
18989 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
18991 ID3D11DeviceContext_PSSetShaderResources(context
,
18992 D3D11_COMMONSHADER_INPUT_RESOURCE_REGISTER_COUNT
- 1, 1, &srv
);
18993 ID3D11DeviceContext_PSSetSamplers(context
, D3D11_COMMONSHADER_SAMPLER_REGISTER_COUNT
- 1, 1, &sampler
);
18994 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
18995 draw_quad(&test_context
);
18996 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
18998 ID3D11PixelShader_Release(ps
);
18999 ID3D11SamplerState_Release(sampler
);
19000 ID3D11ShaderResourceView_Release(srv
);
19001 ID3D11Texture2D_Release(texture
);
19002 release_test_context(&test_context
);
19005 static void test_unbind_shader_resource_view(void)
19007 struct d3d11_test_context test_context
;
19008 D3D11_SUBRESOURCE_DATA resource_data
;
19009 ID3D11ShaderResourceView
*srv
, *srv2
;
19010 D3D11_TEXTURE2D_DESC texture_desc
;
19011 ID3D11DeviceContext
*context
;
19012 ID3D11Texture2D
*texture
;
19013 ID3D11PixelShader
*ps
;
19014 ID3D11Device
*device
;
19017 static const DWORD ps_code
[] =
19024 float4
main() : SV_Target
19026 return min(t0
.Sample(s
, float2(0, 0)) + t1
.Sample(s
, float2(0, 0)), 1.0f
);
19029 0x43425844, 0x698dc0cb, 0x0bf322b8, 0xee127418, 0xfe9214ce, 0x00000001, 0x00000168, 0x00000003,
19030 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19031 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
19032 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000f0, 0x00000040, 0x0000003c,
19033 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858,
19034 0x00107000, 0x00000001, 0x00005555, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002,
19035 0x0c000045, 0x001000f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
19036 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0c000045, 0x001000f2, 0x00000001, 0x00004002,
19037 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00107e46, 0x00000001, 0x00106000, 0x00000000,
19038 0x07000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00100e46, 0x00000001, 0x0a000033,
19039 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3f800000, 0x3f800000, 0x3f800000,
19040 0x3f800000, 0x0100003e,
19042 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
19043 static const DWORD texture_data
[] = {0xff00ff00};
19045 if (!init_test_context(&test_context
, NULL
))
19048 device
= test_context
.device
;
19049 context
= test_context
.immediate_context
;
19051 texture_desc
.Width
= 1;
19052 texture_desc
.Height
= 1;
19053 texture_desc
.MipLevels
= 0;
19054 texture_desc
.ArraySize
= 1;
19055 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
19056 texture_desc
.SampleDesc
.Count
= 1;
19057 texture_desc
.SampleDesc
.Quality
= 0;
19058 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
19059 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
19060 texture_desc
.CPUAccessFlags
= 0;
19061 texture_desc
.MiscFlags
= 0;
19063 resource_data
.pSysMem
= texture_data
;
19064 resource_data
.SysMemPitch
= sizeof(texture_data
);
19065 resource_data
.SysMemSlicePitch
= 0;
19067 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &texture
);
19068 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
19069 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
19070 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
19071 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
19072 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
19073 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
19075 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
19076 ID3D11DeviceContext_PSSetShaderResources(context
, 1, 1, &srv
);
19077 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
19078 draw_quad(&test_context
);
19079 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
19082 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv2
);
19083 ID3D11DeviceContext_PSSetShaderResources(context
, 1, 1, &srv2
);
19084 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
19085 draw_quad(&test_context
);
19086 todo_wine
check_texture_color(test_context
.backbuffer
, 0x00000000, 1);
19088 ID3D11PixelShader_Release(ps
);
19089 ID3D11ShaderResourceView_Release(srv
);
19090 ID3D11Texture2D_Release(texture
);
19091 release_test_context(&test_context
);
19094 static void test_stencil_separate(void)
19096 struct d3d11_test_context test_context
;
19097 D3D11_TEXTURE2D_DESC texture_desc
;
19098 D3D11_DEPTH_STENCIL_DESC ds_desc
;
19099 ID3D11DepthStencilState
*ds_state
;
19100 ID3D11DepthStencilView
*ds_view
;
19101 D3D11_RASTERIZER_DESC rs_desc
;
19102 ID3D11DeviceContext
*context
;
19103 ID3D11RasterizerState
*rs
;
19104 ID3D11Texture2D
*texture
;
19105 ID3D11Device
*device
;
19108 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 1.0f
};
19109 static const struct vec4 green
= {0.0f
, 1.0f
, 0.0f
, 1.0f
};
19110 static const struct vec3 ccw_quad
[] =
19112 {-1.0f
, -1.0f
, 0.0f
},
19113 { 1.0f
, -1.0f
, 0.0f
},
19114 {-1.0f
, 1.0f
, 0.0f
},
19115 { 1.0f
, 1.0f
, 0.0f
},
19118 if (!init_test_context(&test_context
, NULL
))
19121 device
= test_context
.device
;
19122 context
= test_context
.immediate_context
;
19124 texture_desc
.Width
= 640;
19125 texture_desc
.Height
= 480;
19126 texture_desc
.MipLevels
= 1;
19127 texture_desc
.ArraySize
= 1;
19128 texture_desc
.Format
= DXGI_FORMAT_D24_UNORM_S8_UINT
;
19129 texture_desc
.SampleDesc
.Count
= 1;
19130 texture_desc
.SampleDesc
.Quality
= 0;
19131 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
19132 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
19133 texture_desc
.CPUAccessFlags
= 0;
19134 texture_desc
.MiscFlags
= 0;
19135 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
19136 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
19137 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, NULL
, &ds_view
);
19138 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
19140 ds_desc
.DepthEnable
= TRUE
;
19141 ds_desc
.DepthWriteMask
= D3D11_DEPTH_WRITE_MASK_ALL
;
19142 ds_desc
.DepthFunc
= D3D11_COMPARISON_LESS
;
19143 ds_desc
.StencilEnable
= TRUE
;
19144 ds_desc
.StencilReadMask
= D3D11_DEFAULT_STENCIL_READ_MASK
;
19145 ds_desc
.StencilWriteMask
= D3D11_DEFAULT_STENCIL_WRITE_MASK
;
19146 ds_desc
.FrontFace
.StencilFailOp
= D3D11_STENCIL_OP_ZERO
;
19147 ds_desc
.FrontFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_ZERO
;
19148 ds_desc
.FrontFace
.StencilPassOp
= D3D11_STENCIL_OP_ZERO
;
19149 ds_desc
.FrontFace
.StencilFunc
= D3D11_COMPARISON_NEVER
;
19150 ds_desc
.BackFace
.StencilFailOp
= D3D11_STENCIL_OP_ZERO
;
19151 ds_desc
.BackFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_ZERO
;
19152 ds_desc
.BackFace
.StencilPassOp
= D3D11_STENCIL_OP_ZERO
;
19153 ds_desc
.BackFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
19154 hr
= ID3D11Device_CreateDepthStencilState(device
, &ds_desc
, &ds_state
);
19155 ok(SUCCEEDED(hr
), "Failed to create depth stencil state, hr %#x.\n", hr
);
19157 rs_desc
.FillMode
= D3D11_FILL_SOLID
;
19158 rs_desc
.CullMode
= D3D11_CULL_NONE
;
19159 rs_desc
.FrontCounterClockwise
= FALSE
;
19160 rs_desc
.DepthBias
= 0;
19161 rs_desc
.DepthBiasClamp
= 0.0f
;
19162 rs_desc
.SlopeScaledDepthBias
= 0.0f
;
19163 rs_desc
.DepthClipEnable
= TRUE
;
19164 rs_desc
.ScissorEnable
= FALSE
;
19165 rs_desc
.MultisampleEnable
= FALSE
;
19166 rs_desc
.AntialiasedLineEnable
= FALSE
;
19167 ID3D11Device_CreateRasterizerState(device
, &rs_desc
, &rs
);
19168 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
19170 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
19171 ID3D11DeviceContext_ClearDepthStencilView(context
, ds_view
, D3D11_CLEAR_DEPTH
| D3D11_CLEAR_STENCIL
, 1.0f
, 0);
19172 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &test_context
.backbuffer_rtv
, ds_view
);
19173 ID3D11DeviceContext_OMSetDepthStencilState(context
, ds_state
, 0);
19174 ID3D11DeviceContext_RSSetState(context
, rs
);
19176 draw_color_quad(&test_context
, &green
);
19177 check_texture_color(test_context
.backbuffer
, 0xff0000ff, 1);
19179 ID3D11Buffer_Release(test_context
.vb
);
19180 test_context
.vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(ccw_quad
), ccw_quad
);
19182 draw_color_quad(&test_context
, &green
);
19183 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
19185 ID3D11RasterizerState_Release(rs
);
19186 rs_desc
.FrontCounterClockwise
= TRUE
;
19187 ID3D11Device_CreateRasterizerState(device
, &rs_desc
, &rs
);
19188 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
19189 ID3D11DeviceContext_RSSetState(context
, rs
);
19191 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
19192 draw_color_quad(&test_context
, &green
);
19193 check_texture_color(test_context
.backbuffer
, 0xff0000ff, 1);
19195 ID3D11DepthStencilState_Release(ds_state
);
19196 ID3D11DepthStencilView_Release(ds_view
);
19197 ID3D11RasterizerState_Release(rs
);
19198 ID3D11Texture2D_Release(texture
);
19199 release_test_context(&test_context
);
19202 static void test_uav_load(void)
19213 UINT miplevel_count
;
19215 DXGI_FORMAT format
;
19216 D3D11_SUBRESOURCE_DATA data
[3];
19219 ID3D11RenderTargetView
*rtv_float
, *rtv_uint
, *rtv_sint
;
19220 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
19221 D3D11_RENDER_TARGET_VIEW_DESC rtv_desc
;
19222 struct d3d11_test_context test_context
;
19223 const struct texture
*current_texture
;
19224 ID3D11Texture2D
*texture
, *rt_texture
;
19225 D3D11_TEXTURE2D_DESC texture_desc
;
19226 const struct shader
*current_ps
;
19227 ID3D11UnorderedAccessView
*uav
;
19228 ID3D11DeviceContext
*context
;
19229 struct resource_readback rb
;
19230 ID3D11PixelShader
*ps
;
19231 ID3D11Device
*device
;
19232 unsigned int i
, x
, y
;
19236 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
19237 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
19238 static const DWORD ps_ld_2d_float_code
[] =
19241 RWTexture2D
<float> u
;
19243 float main(float4 position
: SV_Position
) : SV_Target
19246 u
.GetDimensions(s
.x
, s
.y
);
19247 return u
[s
* float2(position
.x
/ 640.0f
, position
.y
/ 480.0f
)];
19250 0x43425844, 0xd5996e04, 0x6bede909, 0x0a7ad18e, 0x5eb277fb, 0x00000001, 0x00000194, 0x00000003,
19251 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
19252 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
19253 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
19254 0x00000000, 0x00000e01, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000f8, 0x00000050,
19255 0x0000003e, 0x0100086a, 0x0400189c, 0x0011e000, 0x00000001, 0x00005555, 0x04002064, 0x00101032,
19256 0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000000, 0x02000068, 0x00000001, 0x8900003d,
19257 0x800000c2, 0x00155543, 0x00100032, 0x00000000, 0x00004001, 0x00000000, 0x0011ee46, 0x00000001,
19258 0x07000038, 0x001000f2, 0x00000000, 0x00100546, 0x00000000, 0x00101546, 0x00000000, 0x0a000038,
19259 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x3b088889,
19260 0x3b088889, 0x0500001c, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x890000a3, 0x800000c2,
19261 0x00155543, 0x00100012, 0x00000000, 0x00100e46, 0x00000000, 0x0011ee46, 0x00000001, 0x05000036,
19262 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0100003e,
19264 static const struct shader ps_ld_2d_float
= {ps_ld_2d_float_code
, sizeof(ps_ld_2d_float_code
)};
19265 static const DWORD ps_ld_2d_uint_code
[] =
19268 RWTexture2D
<uint
> u
;
19270 uint
main(float4 position
: SV_Position
) : SV_Target
19273 u
.GetDimensions(s
.x
, s
.y
);
19274 return u
[s
* float2(position
.x
/ 640.0f
, position
.y
/ 480.0f
)];
19277 0x43425844, 0x2cc0af18, 0xb28eca73, 0x9651215b, 0xebe3f361, 0x00000001, 0x00000194, 0x00000003,
19278 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
19279 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
19280 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001,
19281 0x00000000, 0x00000e01, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000f8, 0x00000050,
19282 0x0000003e, 0x0100086a, 0x0400189c, 0x0011e000, 0x00000001, 0x00004444, 0x04002064, 0x00101032,
19283 0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000000, 0x02000068, 0x00000001, 0x8900003d,
19284 0x800000c2, 0x00111103, 0x00100032, 0x00000000, 0x00004001, 0x00000000, 0x0011ee46, 0x00000001,
19285 0x07000038, 0x001000f2, 0x00000000, 0x00100546, 0x00000000, 0x00101546, 0x00000000, 0x0a000038,
19286 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x3b088889,
19287 0x3b088889, 0x0500001c, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x890000a3, 0x800000c2,
19288 0x00111103, 0x00100012, 0x00000000, 0x00100e46, 0x00000000, 0x0011ee46, 0x00000001, 0x05000036,
19289 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0100003e,
19291 static const struct shader ps_ld_2d_uint
= {ps_ld_2d_uint_code
, sizeof(ps_ld_2d_uint_code
)};
19292 static const DWORD ps_ld_2d_int_code
[] =
19295 RWTexture2D
<int> u
;
19297 int main(float4 position
: SV_Position
) : SV_Target
19300 u
.GetDimensions(s
.x
, s
.y
);
19301 return u
[s
* float2(position
.x
/ 640.0f
, position
.y
/ 480.0f
)];
19304 0x43425844, 0x7deee248, 0xe7c48698, 0x9454db00, 0x921810e7, 0x00000001, 0x00000194, 0x00000003,
19305 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
19306 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
19307 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000002,
19308 0x00000000, 0x00000e01, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000f8, 0x00000050,
19309 0x0000003e, 0x0100086a, 0x0400189c, 0x0011e000, 0x00000001, 0x00003333, 0x04002064, 0x00101032,
19310 0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000000, 0x02000068, 0x00000001, 0x8900003d,
19311 0x800000c2, 0x000cccc3, 0x00100032, 0x00000000, 0x00004001, 0x00000000, 0x0011ee46, 0x00000001,
19312 0x07000038, 0x001000f2, 0x00000000, 0x00100546, 0x00000000, 0x00101546, 0x00000000, 0x0a000038,
19313 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x3b088889,
19314 0x3b088889, 0x0500001c, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x890000a3, 0x800000c2,
19315 0x000cccc3, 0x00100012, 0x00000000, 0x00100e46, 0x00000000, 0x0011ee46, 0x00000001, 0x05000036,
19316 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0100003e,
19318 static const struct shader ps_ld_2d_int
= {ps_ld_2d_int_code
, sizeof(ps_ld_2d_int_code
)};
19319 static const DWORD ps_ld_2d_uint_arr_code
[] =
19322 RWTexture2DArray
<uint
> u
;
19326 uint
main(float4 position
: SV_Position
) : SV_Target
19329 u
.GetDimensions(s
.x
, s
.y
, s
.z
);
19331 return u
[s
* float3(position
.x
/ 640.0f
, position
.y
/ 480.0f
, 1.0f
)];
19334 0x43425844, 0xa7630358, 0xd7e7228f, 0xa9f1be03, 0x838554f1, 0x00000001, 0x000001bc, 0x00000003,
19335 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
19336 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
19337 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001,
19338 0x00000000, 0x00000e01, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000120, 0x00000050,
19339 0x00000048, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0400409c, 0x0011e000,
19340 0x00000001, 0x00004444, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x00102012,
19341 0x00000000, 0x02000068, 0x00000001, 0x8900003d, 0x80000202, 0x00111103, 0x00100032, 0x00000000,
19342 0x00004001, 0x00000000, 0x0011ee46, 0x00000001, 0x07000038, 0x00100032, 0x00000000, 0x00100046,
19343 0x00000000, 0x00101046, 0x00000000, 0x06000056, 0x001000c2, 0x00000000, 0x00208006, 0x00000000,
19344 0x00000000, 0x0a000038, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3acccccd,
19345 0x3b088889, 0x3f800000, 0x3f800000, 0x0500001c, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
19346 0x890000a3, 0x80000202, 0x00111103, 0x00100012, 0x00000000, 0x00100e46, 0x00000000, 0x0011ee46,
19347 0x00000001, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0100003e,
19349 static const struct shader ps_ld_2d_uint_arr
= {ps_ld_2d_uint_arr_code
, sizeof(ps_ld_2d_uint_arr_code
)};
19350 static const float float_data
[] =
19352 0.50f
, 0.25f
, 1.00f
, 0.00f
,
19353 -1.00f
, -2.00f
, -3.00f
, -4.00f
,
19354 -0.50f
, -0.25f
, -1.00f
, -0.00f
,
19355 1.00f
, 2.00f
, 3.00f
, 4.00f
,
19357 static const unsigned int uint_data
[] =
19359 0x00, 0x10, 0x20, 0x30,
19360 0x40, 0x50, 0x60, 0x70,
19361 0x80, 0x90, 0xa0, 0xb0,
19362 0xc0, 0xd0, 0xe0, 0xf0,
19364 static const unsigned int uint_data2
[] =
19366 0xffff, 0xffff, 0xffff, 0xffff,
19367 0xffff, 0xc000, 0xc000, 0xffff,
19368 0xffff, 0xc000, 0xc000, 0xffff,
19369 0xffff, 0xffff, 0xffff, 0xffff,
19371 static const unsigned int uint_data3
[] =
19373 0xaa, 0xaa, 0xcc, 0xcc,
19374 0xaa, 0xaa, 0xdd, 0xdd,
19375 0xbb, 0xbb, 0xee, 0xee,
19376 0xbb, 0xbb, 0xff, 0xff,
19378 static const int int_data
[] =
19380 -1, 0x10, 0x20, 0x30,
19381 0x40, 0x50, 0x60, -777,
19382 -666, 0x90, -555, 0xb0,
19383 0xc0, 0xd0, 0xe0, -101,
19385 static const struct texture float_2d
= {4, 4, 1, 1, DXGI_FORMAT_R32_FLOAT
,
19386 {{float_data
, 4 * sizeof(*float_data
), 0}}};
19387 static const struct texture uint_2d
= {4, 4, 1, 1, DXGI_FORMAT_R32_UINT
,
19388 {{uint_data
, 4 * sizeof(*uint_data
), 0}}};
19389 static const struct texture uint2d_arr
= {4, 4, 1, 3, DXGI_FORMAT_R32_UINT
,
19390 {{uint_data
, 4 * sizeof(*uint_data
), 0},
19391 {uint_data2
, 4 * sizeof(*uint_data2
), 0},
19392 {uint_data3
, 4 * sizeof(*uint_data3
), 0}}};
19393 static const struct texture int_2d
= {4, 4, 1, 1, DXGI_FORMAT_R32_SINT
,
19394 {{int_data
, 4 * sizeof(*int_data
), 0}}};
19396 static const struct test
19398 const struct shader
*ps
;
19399 const struct texture
*texture
;
19400 struct uav_desc uav_desc
;
19401 struct uvec4 constant
;
19402 const DWORD
*expected_colors
;
19406 #define TEX_2D D3D11_UAV_DIMENSION_TEXTURE2D
19407 #define TEX_2D_ARRAY D3D11_UAV_DIMENSION_TEXTURE2DARRAY
19408 #define R32_FLOAT DXGI_FORMAT_R32_FLOAT
19409 #define R32_UINT DXGI_FORMAT_R32_UINT
19410 #define R32_SINT DXGI_FORMAT_R32_SINT
19411 {&ps_ld_2d_float
, &float_2d
, {R32_FLOAT
, TEX_2D
, 0}, {}, (const DWORD
*)float_data
},
19412 {&ps_ld_2d_uint
, &uint_2d
, {R32_UINT
, TEX_2D
, 0}, {}, (const DWORD
*)uint_data
},
19413 {&ps_ld_2d_int
, &int_2d
, {R32_SINT
, TEX_2D
, 0}, {}, (const DWORD
*)int_data
},
19414 {&ps_ld_2d_uint_arr
, &uint2d_arr
, {R32_UINT
, TEX_2D_ARRAY
, 0, 0, ~0u}, {0}, (const DWORD
*)uint_data
},
19415 {&ps_ld_2d_uint_arr
, &uint2d_arr
, {R32_UINT
, TEX_2D_ARRAY
, 0, 0, ~0u}, {1}, (const DWORD
*)uint_data2
},
19416 {&ps_ld_2d_uint_arr
, &uint2d_arr
, {R32_UINT
, TEX_2D_ARRAY
, 0, 0, ~0u}, {2}, (const DWORD
*)uint_data3
},
19417 {&ps_ld_2d_uint_arr
, &uint2d_arr
, {R32_UINT
, TEX_2D_ARRAY
, 0, 1, ~0u}, {0}, (const DWORD
*)uint_data2
},
19418 {&ps_ld_2d_uint_arr
, &uint2d_arr
, {R32_UINT
, TEX_2D_ARRAY
, 0, 1, ~0u}, {1}, (const DWORD
*)uint_data3
},
19419 {&ps_ld_2d_uint_arr
, &uint2d_arr
, {R32_UINT
, TEX_2D_ARRAY
, 0, 2, ~0u}, {0}, (const DWORD
*)uint_data3
},
19421 #undef TEX_2D_ARRAY
19427 if (!init_test_context(&test_context
, &feature_level
))
19430 device
= test_context
.device
;
19431 context
= test_context
.immediate_context
;
19433 texture_desc
.Width
= 640;
19434 texture_desc
.Height
= 480;
19435 texture_desc
.MipLevels
= 1;
19436 texture_desc
.ArraySize
= 1;
19437 texture_desc
.Format
= DXGI_FORMAT_R32_TYPELESS
;
19438 texture_desc
.SampleDesc
.Count
= 1;
19439 texture_desc
.SampleDesc
.Quality
= 0;
19440 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
19441 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
19442 texture_desc
.CPUAccessFlags
= 0;
19443 texture_desc
.MiscFlags
= 0;
19444 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rt_texture
);
19445 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
19447 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_TEXTURE2D
;
19448 U(rtv_desc
).Texture2D
.MipSlice
= 0;
19450 rtv_desc
.Format
= DXGI_FORMAT_R32_FLOAT
;
19451 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rt_texture
, &rtv_desc
, &rtv_float
);
19452 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
19454 rtv_desc
.Format
= DXGI_FORMAT_R32_UINT
;
19455 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rt_texture
, &rtv_desc
, &rtv_uint
);
19456 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
19458 rtv_desc
.Format
= DXGI_FORMAT_R32_SINT
;
19459 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rt_texture
, &rtv_desc
, &rtv_sint
);
19460 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
19462 texture_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
19464 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(struct uvec4
), NULL
);
19465 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
19471 current_texture
= NULL
;
19472 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
19474 const struct test
*test
= &tests
[i
];
19475 ID3D11RenderTargetView
*current_rtv
;
19477 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
19478 NULL
, &test
->constant
, 0, 0);
19480 if (current_ps
!= test
->ps
)
19483 ID3D11PixelShader_Release(ps
);
19485 current_ps
= test
->ps
;
19487 hr
= ID3D11Device_CreatePixelShader(device
, current_ps
->code
, current_ps
->size
, NULL
, &ps
);
19488 ok(SUCCEEDED(hr
), "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
19490 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
19493 if (current_texture
!= test
->texture
)
19496 ID3D11Texture2D_Release(texture
);
19498 current_texture
= test
->texture
;
19500 texture_desc
.Width
= current_texture
->width
;
19501 texture_desc
.Height
= current_texture
->height
;
19502 texture_desc
.MipLevels
= current_texture
->miplevel_count
;
19503 texture_desc
.ArraySize
= current_texture
->array_size
;
19504 texture_desc
.Format
= current_texture
->format
;
19506 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, current_texture
->data
, &texture
);
19507 ok(SUCCEEDED(hr
), "Test %u: Failed to create texture, hr %#x.\n", i
, hr
);
19511 ID3D11UnorderedAccessView_Release(uav
);
19513 get_uav_desc(&uav_desc
, &test
->uav_desc
);
19514 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)texture
, &uav_desc
, &uav
);
19515 ok(SUCCEEDED(hr
), "Test %u: Failed to create unordered access view, hr %#x.\n", i
, hr
);
19517 switch (uav_desc
.Format
)
19519 case DXGI_FORMAT_R32_FLOAT
:
19520 current_rtv
= rtv_float
;
19522 case DXGI_FORMAT_R32_UINT
:
19523 current_rtv
= rtv_uint
;
19525 case DXGI_FORMAT_R32_SINT
:
19526 current_rtv
= rtv_sint
;
19529 trace("Unhandled format %#x.\n", uav_desc
.Format
);
19530 current_rtv
= NULL
;
19534 ID3D11DeviceContext_ClearRenderTargetView(context
, current_rtv
, white
);
19536 ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context
, 1, ¤t_rtv
, NULL
,
19539 draw_quad(&test_context
);
19541 get_texture_readback(rt_texture
, 0, &rb
);
19542 for (y
= 0; y
< 4; ++y
)
19544 for (x
= 0; x
< 4; ++x
)
19546 DWORD expected
= test
->expected_colors
[y
* 4 + x
];
19547 DWORD color
= get_readback_color(&rb
, 80 + x
* 160, 60 + y
* 120, 0);
19548 ok(compare_color(color
, expected
, 0),
19549 "Test %u: Got 0x%08x, expected 0x%08x at (%u, %u).\n",
19550 i
, color
, expected
, x
, y
);
19553 release_resource_readback(&rb
);
19555 ID3D11PixelShader_Release(ps
);
19556 ID3D11Texture2D_Release(texture
);
19557 ID3D11UnorderedAccessView_Release(uav
);
19559 ID3D11Buffer_Release(cb
);
19560 ID3D11RenderTargetView_Release(rtv_float
);
19561 ID3D11RenderTargetView_Release(rtv_sint
);
19562 ID3D11RenderTargetView_Release(rtv_uint
);
19563 ID3D11Texture2D_Release(rt_texture
);
19564 release_test_context(&test_context
);
19567 static void test_cs_uav_store(void)
19569 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
19570 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
19571 static const float zero
[4] = {0.0f
};
19572 D3D11_TEXTURE2D_DESC texture_desc
;
19573 ID3D11UnorderedAccessView
*uav
;
19574 struct device_desc device_desc
;
19575 ID3D11DeviceContext
*context
;
19576 struct vec4 input
= {1.0f
};
19577 ID3D11Texture2D
*texture
;
19578 ID3D11ComputeShader
*cs
;
19579 ID3D11Device
*device
;
19585 static const DWORD cs_1_thread_code
[] =
19588 RWTexture2D
<float> u
;
19592 [numthreads(1, 1, 1)]
19595 uint x
, y
, width
, height
;
19596 u
.GetDimensions(width
, height
);
19597 for (y
= 0; y
< height
; ++y
)
19599 for (x
= 0; x
< width
; ++x
)
19600 u
[uint2(x
, y
)] = value
;
19604 0x43425844, 0x6503503a, 0x4cd524e6, 0x2473915d, 0x93cf1201, 0x00000001, 0x000001c8, 0x00000003,
19605 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19606 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000174, 0x00050050, 0x0000005d, 0x0100086a,
19607 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0400189c, 0x0011e000, 0x00000000, 0x00005555,
19608 0x02000068, 0x00000003, 0x0400009b, 0x00000001, 0x00000001, 0x00000001, 0x8900103d, 0x800000c2,
19609 0x00155543, 0x00100032, 0x00000000, 0x00004001, 0x00000000, 0x0011ee46, 0x00000000, 0x05000036,
19610 0x00100042, 0x00000000, 0x00004001, 0x00000000, 0x01000030, 0x07000050, 0x00100082, 0x00000000,
19611 0x0010002a, 0x00000000, 0x0010001a, 0x00000000, 0x03040003, 0x0010003a, 0x00000000, 0x05000036,
19612 0x001000e2, 0x00000001, 0x00100aa6, 0x00000000, 0x05000036, 0x00100082, 0x00000000, 0x00004001,
19613 0x00000000, 0x01000030, 0x07000050, 0x00100012, 0x00000002, 0x0010003a, 0x00000000, 0x0010000a,
19614 0x00000000, 0x03040003, 0x0010000a, 0x00000002, 0x05000036, 0x00100012, 0x00000001, 0x0010003a,
19615 0x00000000, 0x080000a4, 0x0011e0f2, 0x00000000, 0x00100e46, 0x00000001, 0x00208006, 0x00000000,
19616 0x00000000, 0x0700001e, 0x00100082, 0x00000000, 0x0010003a, 0x00000000, 0x00004001, 0x00000001,
19617 0x01000016, 0x0700001e, 0x00100042, 0x00000000, 0x0010002a, 0x00000000, 0x00004001, 0x00000001,
19618 0x01000016, 0x0100003e,
19620 static const DWORD cs_1_group_code
[] =
19623 RWTexture2D
<float> u
;
19627 [numthreads(16, 16, 1)]
19628 void main(uint3 threadID
: SV_GroupThreadID
)
19630 uint2 count
, size
;
19631 u
.GetDimensions(size
.x
, size
.y
);
19632 count
= size
/ (uint2
)16;
19633 for (uint y
= 0; y
< count
.y
; ++y
)
19634 for (uint x
= 0; x
< count
.x
; ++x
)
19635 u
[count
* threadID
.xy
+ uint2(x
, y
)] = value
;
19638 0x43425844, 0x9fb86044, 0x352c196d, 0x92e14094, 0x46bb95a7, 0x00000001, 0x00000218, 0x00000003,
19639 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19640 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x000001c4, 0x00050050, 0x00000071, 0x0100086a,
19641 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0400189c, 0x0011e000, 0x00000000, 0x00005555,
19642 0x0200005f, 0x00022032, 0x02000068, 0x00000004, 0x0400009b, 0x00000010, 0x00000010, 0x00000001,
19643 0x8900103d, 0x800000c2, 0x00155543, 0x00100032, 0x00000000, 0x00004001, 0x00000000, 0x0011ee46,
19644 0x00000000, 0x0a000055, 0x001000f2, 0x00000000, 0x00100546, 0x00000000, 0x00004002, 0x00000004,
19645 0x00000004, 0x00000004, 0x00000004, 0x05000036, 0x00100012, 0x00000001, 0x00004001, 0x00000000,
19646 0x01000030, 0x07000050, 0x00100022, 0x00000001, 0x0010000a, 0x00000001, 0x0010003a, 0x00000000,
19647 0x03040003, 0x0010001a, 0x00000001, 0x05000036, 0x001000e2, 0x00000002, 0x00100006, 0x00000001,
19648 0x05000036, 0x00100022, 0x00000001, 0x00004001, 0x00000000, 0x01000030, 0x07000050, 0x00100042,
19649 0x00000001, 0x0010001a, 0x00000001, 0x0010000a, 0x00000000, 0x03040003, 0x0010002a, 0x00000001,
19650 0x05000036, 0x00100012, 0x00000002, 0x0010001a, 0x00000001, 0x08000023, 0x001000f2, 0x00000003,
19651 0x00100e46, 0x00000000, 0x00022546, 0x00100e46, 0x00000002, 0x080000a4, 0x0011e0f2, 0x00000000,
19652 0x00100e46, 0x00000003, 0x00208006, 0x00000000, 0x00000000, 0x0700001e, 0x00100022, 0x00000001,
19653 0x0010001a, 0x00000001, 0x00004001, 0x00000001, 0x01000016, 0x0700001e, 0x00100012, 0x00000001,
19654 0x0010000a, 0x00000001, 0x00004001, 0x00000001, 0x01000016, 0x0100003e,
19656 static const DWORD cs_1_store_code
[] =
19659 RWTexture2D
<float> u
;
19663 [numthreads(1, 1, 1)]
19664 void main(uint3 groupID
: SV_GroupID
)
19666 u
[groupID
.xy
] = value
;
19669 0x43425844, 0xc3add41b, 0x67df51b1, 0x2b887930, 0xcb1ee991, 0x00000001, 0x000000b8, 0x00000003,
19670 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19671 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000064, 0x00050050, 0x00000019, 0x0100086a,
19672 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0400189c, 0x0011e000, 0x00000000, 0x00005555,
19673 0x0200005f, 0x00021032, 0x0400009b, 0x00000001, 0x00000001, 0x00000001, 0x070000a4, 0x0011e0f2,
19674 0x00000000, 0x00021546, 0x00208006, 0x00000000, 0x00000000, 0x0100003e,
19676 static const DWORD cs_dispatch_id_code
[] =
19679 RWTexture2D
<float> u
;
19683 [numthreads(4, 4, 1)]
19684 void main(uint3 id
: SV_DispatchThreadID
)
19689 0x43425844, 0x60166991, 0x4b595266, 0x7fb67d79, 0x485c4f0d, 0x00000001, 0x000000b8, 0x00000003,
19690 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19691 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000064, 0x00050050, 0x00000019, 0x0100086a,
19692 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0400189c, 0x0011e000, 0x00000000, 0x00005555,
19693 0x0200005f, 0x00020032, 0x0400009b, 0x00000004, 0x00000004, 0x00000001, 0x070000a4, 0x0011e0f2,
19694 0x00000000, 0x00020546, 0x00208006, 0x00000000, 0x00000000, 0x0100003e,
19696 static const DWORD cs_group_index_code
[] =
19699 RWTexture2D
<float> u
;
19703 [numthreads(32, 1, 1)]
19704 void main(uint index
: SV_GroupIndex
)
19707 u
.GetDimensions(size
.x
, size
.y
);
19708 uint count
= size
.x
* size
.y
/ 32;
19710 for (uint i
= 0; i
< count
; ++i
, ++index
)
19711 u
[uint2(index
% size
.x
, index
/ size
.x
)] = value
;
19714 0x43425844, 0xb685a70f, 0x94c2f263, 0x4f1d8eaa, 0xeab65731, 0x00000001, 0x000001f8, 0x00000003,
19715 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19716 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x000001a4, 0x00050050, 0x00000069, 0x0100086a,
19717 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0400189c, 0x0011e000, 0x00000000, 0x00005555,
19718 0x0200005f, 0x00024000, 0x02000068, 0x00000004, 0x0400009b, 0x00000020, 0x00000001, 0x00000001,
19719 0x8900103d, 0x800000c2, 0x00155543, 0x00100032, 0x00000000, 0x00004001, 0x00000000, 0x0011ee46,
19720 0x00000000, 0x08000026, 0x0000d000, 0x00100022, 0x00000000, 0x0010000a, 0x00000000, 0x0010001a,
19721 0x00000000, 0x07000055, 0x00100022, 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0x00000005,
19722 0x07000026, 0x0000d000, 0x00100042, 0x00000000, 0x0002400a, 0x0010001a, 0x00000000, 0x05000036,
19723 0x00100012, 0x00000001, 0x0010002a, 0x00000000, 0x05000036, 0x00100022, 0x00000001, 0x00004001,
19724 0x00000000, 0x01000030, 0x07000050, 0x00100082, 0x00000000, 0x0010001a, 0x00000001, 0x0010001a,
19725 0x00000000, 0x03040003, 0x0010003a, 0x00000000, 0x0900004e, 0x00100012, 0x00000002, 0x00100012,
19726 0x00000003, 0x0010000a, 0x00000001, 0x0010000a, 0x00000000, 0x05000036, 0x001000e2, 0x00000003,
19727 0x00100006, 0x00000002, 0x080000a4, 0x0011e0f2, 0x00000000, 0x00100e46, 0x00000003, 0x00208006,
19728 0x00000000, 0x00000000, 0x0a00001e, 0x00100032, 0x00000001, 0x00100046, 0x00000001, 0x00004002,
19729 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x01000016, 0x0100003e,
19732 device_desc
.feature_level
= &feature_level
;
19733 device_desc
.flags
= 0;
19734 if (!(device
= create_device(&device_desc
)))
19736 skip("Failed to create device for feature level %#x.\n", feature_level
);
19740 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(input
), &input
.x
);
19742 texture_desc
.Width
= 64;
19743 texture_desc
.Height
= 64;
19744 texture_desc
.MipLevels
= 1;
19745 texture_desc
.ArraySize
= 1;
19746 texture_desc
.Format
= DXGI_FORMAT_R32_FLOAT
;
19747 texture_desc
.SampleDesc
.Count
= 1;
19748 texture_desc
.SampleDesc
.Quality
= 0;
19749 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
19750 texture_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
19751 texture_desc
.CPUAccessFlags
= 0;
19752 texture_desc
.MiscFlags
= 0;
19754 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
19755 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
19757 uav_desc
.Format
= texture_desc
.Format
;
19758 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_TEXTURE2D
;
19759 U(uav_desc
).Texture2D
.MipSlice
= 0;
19761 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)texture
, &uav_desc
, &uav
);
19762 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
19764 ID3D11Device_GetImmediateContext(device
, &context
);
19766 ID3D11DeviceContext_CSSetConstantBuffers(context
, 0, 1, &cb
);
19767 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
19769 ID3D11DeviceContext_ClearUnorderedAccessViewFloat(context
, uav
, zero
);
19770 check_texture_float(texture
, 0.0f
, 2);
19772 hr
= ID3D11Device_CreateComputeShader(device
, cs_1_thread_code
, sizeof(cs_1_thread_code
), NULL
, &cs
);
19773 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
19774 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
19776 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
19777 check_texture_float(texture
, 1.0f
, 2);
19780 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &input
, 0, 0);
19781 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
19782 check_texture_float(texture
, 0.5f
, 2);
19784 ID3D11ComputeShader_Release(cs
);
19787 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &input
, 0, 0);
19788 ID3D11DeviceContext_CSSetShader(context
, NULL
, NULL
, 0);
19789 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
19790 check_texture_float(texture
, 0.5f
, 2);
19792 hr
= ID3D11Device_CreateComputeShader(device
, cs_1_group_code
, sizeof(cs_1_group_code
), NULL
, &cs
);
19793 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
19794 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
19796 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
19797 check_texture_float(texture
, 2.0f
, 2);
19800 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &input
, 0, 0);
19801 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
19802 check_texture_float(texture
, 4.0f
, 2);
19804 ID3D11ComputeShader_Release(cs
);
19806 hr
= ID3D11Device_CreateComputeShader(device
, cs_1_store_code
, sizeof(cs_1_store_code
), NULL
, &cs
);
19807 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
19808 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
19811 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &input
, 0, 0);
19812 ID3D11DeviceContext_Dispatch(context
, texture_desc
.Width
, texture_desc
.Height
, 1);
19813 check_texture_float(texture
, 1.0f
, 2);
19816 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &input
, 0, 0);
19817 ID3D11DeviceContext_Dispatch(context
, 16, 32, 1);
19818 SetRect(&rect
, 0, 0, 16, 32);
19819 check_texture_sub_resource_float(texture
, 0, &rect
, 0.5f
, 2);
19820 SetRect(&rect
, 0, 32, texture_desc
.Width
, texture_desc
.Height
);
19821 check_texture_sub_resource_float(texture
, 0, &rect
, 1.0f
, 2);
19822 SetRect(&rect
, 16, 0, texture_desc
.Width
, texture_desc
.Height
);
19823 check_texture_sub_resource_float(texture
, 0, &rect
, 1.0f
, 2);
19825 ID3D11ComputeShader_Release(cs
);
19827 hr
= ID3D11Device_CreateComputeShader(device
, cs_dispatch_id_code
, sizeof(cs_dispatch_id_code
), NULL
, &cs
);
19828 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
19829 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
19832 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &input
, 0, 0);
19833 ID3D11DeviceContext_Dispatch(context
, 15, 15, 1);
19834 SetRect(&rect
, 0, 0, 60, 60);
19835 check_texture_sub_resource_float(texture
, 0, &rect
, 0.6f
, 2);
19836 SetRect(&rect
, 0, 60, texture_desc
.Width
, texture_desc
.Height
);
19837 check_texture_sub_resource_float(texture
, 0, &rect
, 1.0f
, 2);
19838 SetRect(&rect
, 60, 0, texture_desc
.Width
, texture_desc
.Height
);
19839 check_texture_sub_resource_float(texture
, 0, &rect
, 1.0f
, 2);
19842 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &input
, 0, 0);
19843 ID3D11DeviceContext_Dispatch(context
, 16, 16, 1);
19844 check_texture_float(texture
, 0.7f
, 2);
19846 ID3D11ComputeShader_Release(cs
);
19848 hr
= ID3D11Device_CreateComputeShader(device
, cs_group_index_code
, sizeof(cs_group_index_code
), NULL
, &cs
);
19849 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
19850 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
19853 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &input
, 0, 0);
19854 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
19855 check_texture_float(texture
, 0.3f
, 2);
19858 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &input
, 0, 0);
19859 ID3D11DeviceContext_Dispatch(context
, 2, 2, 2);
19860 check_texture_float(texture
, 0.1f
, 2);
19862 ID3D11ComputeShader_Release(cs
);
19864 ID3D11Buffer_Release(cb
);
19865 ID3D11Texture2D_Release(texture
);
19866 ID3D11UnorderedAccessView_Release(uav
);
19867 ID3D11DeviceContext_Release(context
);
19868 refcount
= ID3D11Device_Release(device
);
19869 ok(!refcount
, "Device has %u references left.\n", refcount
);
19872 static void test_uav_store_immediate_constant(void)
19874 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
19875 struct d3d11_test_context test_context
;
19876 D3D11_TEXTURE2D_DESC texture_desc
;
19877 ID3D11UnorderedAccessView
*uav
;
19878 ID3D11DeviceContext
*context
;
19879 struct resource_readback rb
;
19880 ID3D11Texture2D
*texture
;
19881 ID3D11ComputeShader
*cs
;
19882 unsigned int uint_data
;
19883 ID3D11Device
*device
;
19884 ID3D11Buffer
*buffer
;
19889 static const DWORD cs_store_int_code
[] =
19894 [numthreads(1, 1, 1)]
19900 0x43425844, 0x7246d785, 0x3f4ccbd6, 0x6a7cdbc0, 0xe2b58c72, 0x00000001, 0x000000b8, 0x00000003,
19901 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19902 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000064, 0x00050050, 0x00000019, 0x0100086a,
19903 0x0400089c, 0x0011e000, 0x00000000, 0x00003333, 0x0400009b, 0x00000001, 0x00000001, 0x00000001,
19904 0x0d0000a4, 0x0011e0f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
19905 0x00004002, 0x0000002a, 0x0000002a, 0x0000002a, 0x0000002a, 0x0100003e,
19907 static const DWORD cs_store_float_code
[] =
19912 [numthreads(1, 1, 1)]
19918 0x43425844, 0x525eea68, 0xc4cd5716, 0xc588f9c4, 0x0da27c5a, 0x00000001, 0x000000b8, 0x00000003,
19919 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19920 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000064, 0x00050050, 0x00000019, 0x0100086a,
19921 0x0400089c, 0x0011e000, 0x00000000, 0x00005555, 0x0400009b, 0x00000001, 0x00000001, 0x00000001,
19922 0x0d0000a4, 0x0011e0f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
19923 0x00004002, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000, 0x0100003e,
19925 static const DWORD cs_store_unorm_code
[] =
19928 RWTexture2D
<unorm
float> u
;
19930 [numthreads(1, 1, 1)]
19933 u
[uint2(0, 0)] = 0.5f
;
19936 0x43425844, 0x3623f1de, 0xe847109e, 0x8e3da13f, 0xb6787b06, 0x00000001, 0x000000b8, 0x00000003,
19937 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19938 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000064, 0x00050050, 0x00000019, 0x0100086a,
19939 0x0400189c, 0x0011e000, 0x00000000, 0x00001111, 0x0400009b, 0x00000001, 0x00000001, 0x00000001,
19940 0x0d0000a4, 0x0011e0f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
19941 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, 0x0100003e,
19943 static const DWORD cs_store_snorm_code
[] =
19946 RWTexture2D
<snorm
float> u
;
19948 [numthreads(1, 1, 1)]
19951 u
[uint2(0, 0)] = -0.5f
;
19954 0x43425844, 0xce5397fc, 0x7464bc06, 0xc79aa56c, 0x881bd7ef, 0x00000001, 0x000000b8, 0x00000003,
19955 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19956 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000064, 0x00050050, 0x00000019, 0x0100086a,
19957 0x0400189c, 0x0011e000, 0x00000000, 0x00002222, 0x0400009b, 0x00000001, 0x00000001, 0x00000001,
19958 0x0d0000a4, 0x0011e0f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
19959 0x00004002, 0xbf000000, 0xbf000000, 0xbf000000, 0xbf000000, 0x0100003e,
19961 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
19962 static const unsigned int zero
[4] = {0};
19964 if (!init_test_context(&test_context
, &feature_level
))
19967 device
= test_context
.device
;
19968 context
= test_context
.immediate_context
;
19970 buffer
= create_buffer(device
, D3D11_BIND_UNORDERED_ACCESS
, 1024, NULL
);
19972 uav_desc
.Format
= DXGI_FORMAT_R32_SINT
;
19973 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
19974 U(uav_desc
).Buffer
.FirstElement
= 0;
19975 U(uav_desc
).Buffer
.NumElements
= 1;
19976 U(uav_desc
).Buffer
.Flags
= 0;
19977 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
19978 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
19979 hr
= ID3D11Device_CreateComputeShader(device
, cs_store_int_code
, sizeof(cs_store_int_code
), NULL
, &cs
);
19980 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
19982 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, zero
);
19983 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
19984 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
19985 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
19986 get_buffer_readback(buffer
, &rb
);
19987 int_data
= get_readback_color(&rb
, 0, 0, 0);
19988 ok(int_data
== 42, "Got unexpected value %u.\n", int_data
);
19989 release_resource_readback(&rb
);
19991 ID3D11ComputeShader_Release(cs
);
19992 ID3D11UnorderedAccessView_Release(uav
);
19993 uav_desc
.Format
= DXGI_FORMAT_R32_FLOAT
;
19994 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
19995 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
19996 hr
= ID3D11Device_CreateComputeShader(device
, cs_store_float_code
, sizeof(cs_store_float_code
), NULL
, &cs
);
19997 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
19999 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, zero
);
20000 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
20001 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
20002 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
20003 get_buffer_readback(buffer
, &rb
);
20004 float_data
= get_readback_float(&rb
, 0, 0);
20005 ok(float_data
== 1.0f
, "Got unexpected value %.8e.\n", float_data
);
20006 release_resource_readback(&rb
);
20008 texture_desc
.Width
= 64;
20009 texture_desc
.Height
= 64;
20010 texture_desc
.MipLevels
= 1;
20011 texture_desc
.ArraySize
= 1;
20012 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
20013 texture_desc
.SampleDesc
.Count
= 1;
20014 texture_desc
.SampleDesc
.Quality
= 0;
20015 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
20016 texture_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
20017 texture_desc
.CPUAccessFlags
= 0;
20018 texture_desc
.MiscFlags
= 0;
20019 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
20020 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
20021 ID3D11UnorderedAccessView_Release(uav
);
20022 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)texture
, NULL
, &uav
);
20023 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
20025 ID3D11ComputeShader_Release(cs
);
20026 hr
= ID3D11Device_CreateComputeShader(device
, cs_store_unorm_code
, sizeof(cs_store_unorm_code
), NULL
, &cs
);
20027 ok(hr
== S_OK
, "Failed to create compute shader, hr %#x.\n", hr
);
20028 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, zero
);
20029 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
20030 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
20031 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
20032 get_texture_readback(texture
, 0, &rb
);
20033 uint_data
= get_readback_color(&rb
, 0, 0, 0);
20034 ok(compare_color(uint_data
, 0x80808080, 1), "Got unexpected color 0x%08x.\n", uint_data
);
20035 release_resource_readback(&rb
);
20037 ID3D11Texture2D_Release(texture
);
20038 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_SNORM
;
20039 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
20040 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
20041 ID3D11UnorderedAccessView_Release(uav
);
20042 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)texture
, NULL
, &uav
);
20043 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
20045 ID3D11ComputeShader_Release(cs
);
20046 hr
= ID3D11Device_CreateComputeShader(device
, cs_store_snorm_code
, sizeof(cs_store_snorm_code
), NULL
, &cs
);
20047 ok(hr
== S_OK
, "Failed to create compute shader, hr %#x.\n", hr
);
20048 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, zero
);
20049 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
20050 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
20051 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
20052 get_texture_readback(texture
, 0, &rb
);
20053 uint_data
= get_readback_color(&rb
, 0, 0, 0);
20054 ok(compare_color(uint_data
, 0xc0c0c0c0, 1), "Got unexpected color 0x%08x.\n", uint_data
);
20055 release_resource_readback(&rb
);
20057 ID3D11Buffer_Release(buffer
);
20058 ID3D11Texture2D_Release(texture
);
20059 ID3D11ComputeShader_Release(cs
);
20060 ID3D11UnorderedAccessView_Release(uav
);
20061 release_test_context(&test_context
);
20064 static void test_ps_cs_uav_binding(void)
20066 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
20067 ID3D11UnorderedAccessView
*cs_uav
, *ps_uav
;
20068 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
20069 ID3D11Texture2D
*cs_texture
, *ps_texture
;
20070 struct d3d11_test_context test_context
;
20071 static const float zero
[4] = {0.0f
};
20072 D3D11_TEXTURE2D_DESC texture_desc
;
20073 ID3D11DeviceContext
*context
;
20074 ID3D11Buffer
*cs_cb
, *ps_cb
;
20075 struct vec4 input
= {1.0f
};
20076 ID3D11ComputeShader
*cs
;
20077 ID3D11PixelShader
*ps
;
20078 ID3D11Device
*device
;
20081 static const DWORD cs_code
[] =
20084 RWTexture2D
<float> u
;
20088 [numthreads(1, 1, 1)]
20091 uint x
, y
, width
, height
;
20092 u
.GetDimensions(width
, height
);
20093 for (y
= 0; y
< height
; ++y
)
20095 for (x
= 0; x
< width
; ++x
)
20096 u
[uint2(x
, y
)] = value
;
20100 0x43425844, 0x6503503a, 0x4cd524e6, 0x2473915d, 0x93cf1201, 0x00000001, 0x000001c8, 0x00000003,
20101 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
20102 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000174, 0x00050050, 0x0000005d, 0x0100086a,
20103 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0400189c, 0x0011e000, 0x00000000, 0x00005555,
20104 0x02000068, 0x00000003, 0x0400009b, 0x00000001, 0x00000001, 0x00000001, 0x8900103d, 0x800000c2,
20105 0x00155543, 0x00100032, 0x00000000, 0x00004001, 0x00000000, 0x0011ee46, 0x00000000, 0x05000036,
20106 0x00100042, 0x00000000, 0x00004001, 0x00000000, 0x01000030, 0x07000050, 0x00100082, 0x00000000,
20107 0x0010002a, 0x00000000, 0x0010001a, 0x00000000, 0x03040003, 0x0010003a, 0x00000000, 0x05000036,
20108 0x001000e2, 0x00000001, 0x00100aa6, 0x00000000, 0x05000036, 0x00100082, 0x00000000, 0x00004001,
20109 0x00000000, 0x01000030, 0x07000050, 0x00100012, 0x00000002, 0x0010003a, 0x00000000, 0x0010000a,
20110 0x00000000, 0x03040003, 0x0010000a, 0x00000002, 0x05000036, 0x00100012, 0x00000001, 0x0010003a,
20111 0x00000000, 0x080000a4, 0x0011e0f2, 0x00000000, 0x00100e46, 0x00000001, 0x00208006, 0x00000000,
20112 0x00000000, 0x0700001e, 0x00100082, 0x00000000, 0x0010003a, 0x00000000, 0x00004001, 0x00000001,
20113 0x01000016, 0x0700001e, 0x00100042, 0x00000000, 0x0010002a, 0x00000000, 0x00004001, 0x00000001,
20114 0x01000016, 0x0100003e,
20116 static const DWORD ps_code
[] =
20119 RWTexture2D
<float> u
: register(u1
);
20125 uint x
, y
, width
, height
;
20126 u
.GetDimensions(width
, height
);
20127 for (y
= 0; y
< height
; ++y
)
20129 for (x
= 0; x
< width
; ++x
)
20130 u
[uint2(x
, y
)] = value
;
20134 0x43425844, 0x2e14423b, 0x62c015c8, 0x5ea5ab9f, 0x514f1e22, 0x00000001, 0x000001b8, 0x00000003,
20135 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
20136 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000164, 0x00000050, 0x00000059, 0x0100086a,
20137 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0400189c, 0x0011e000, 0x00000001, 0x00005555,
20138 0x02000068, 0x00000003, 0x8900103d, 0x800000c2, 0x00155543, 0x00100032, 0x00000000, 0x00004001,
20139 0x00000000, 0x0011ee46, 0x00000001, 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0x00000000,
20140 0x01000030, 0x07000050, 0x00100082, 0x00000000, 0x0010002a, 0x00000000, 0x0010001a, 0x00000000,
20141 0x03040003, 0x0010003a, 0x00000000, 0x05000036, 0x001000e2, 0x00000001, 0x00100aa6, 0x00000000,
20142 0x05000036, 0x00100082, 0x00000000, 0x00004001, 0x00000000, 0x01000030, 0x07000050, 0x00100012,
20143 0x00000002, 0x0010003a, 0x00000000, 0x0010000a, 0x00000000, 0x03040003, 0x0010000a, 0x00000002,
20144 0x05000036, 0x00100012, 0x00000001, 0x0010003a, 0x00000000, 0x080000a4, 0x0011e0f2, 0x00000001,
20145 0x00100e46, 0x00000001, 0x00208006, 0x00000000, 0x00000000, 0x0700001e, 0x00100082, 0x00000000,
20146 0x0010003a, 0x00000000, 0x00004001, 0x00000001, 0x01000016, 0x0700001e, 0x00100042, 0x00000000,
20147 0x0010002a, 0x00000000, 0x00004001, 0x00000001, 0x01000016, 0x0100003e,
20150 if (!init_test_context(&test_context
, &feature_level
))
20153 device
= test_context
.device
;
20154 context
= test_context
.immediate_context
;
20156 ps_cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(input
), &input
.x
);
20157 cs_cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(input
), &input
.x
);
20159 texture_desc
.Width
= 64;
20160 texture_desc
.Height
= 64;
20161 texture_desc
.MipLevels
= 1;
20162 texture_desc
.ArraySize
= 1;
20163 texture_desc
.Format
= DXGI_FORMAT_R32_FLOAT
;
20164 texture_desc
.SampleDesc
.Count
= 1;
20165 texture_desc
.SampleDesc
.Quality
= 0;
20166 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
20167 texture_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
20168 texture_desc
.CPUAccessFlags
= 0;
20169 texture_desc
.MiscFlags
= 0;
20170 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &cs_texture
);
20171 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
20172 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &ps_texture
);
20173 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
20175 uav_desc
.Format
= texture_desc
.Format
;
20176 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_TEXTURE2D
;
20177 U(uav_desc
).Texture2D
.MipSlice
= 0;
20178 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)cs_texture
, &uav_desc
, &cs_uav
);
20179 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
20180 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)ps_texture
, &uav_desc
, &ps_uav
);
20181 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
20183 ID3D11Device_GetImmediateContext(device
, &context
);
20185 ID3D11DeviceContext_CSSetConstantBuffers(context
, 0, 1, &cs_cb
);
20186 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &cs_uav
, NULL
);
20187 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &ps_cb
);
20188 ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context
,
20189 0, NULL
, NULL
, 1, 1, &ps_uav
, NULL
);
20191 ID3D11DeviceContext_ClearUnorderedAccessViewFloat(context
, cs_uav
, zero
);
20192 check_texture_float(cs_texture
, 0.0f
, 2);
20193 ID3D11DeviceContext_ClearUnorderedAccessViewFloat(context
, ps_uav
, zero
);
20194 check_texture_float(ps_texture
, 0.0f
, 2);
20196 hr
= ID3D11Device_CreateComputeShader(device
, cs_code
, sizeof(cs_code
), NULL
, &cs
);
20197 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
20198 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
20199 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
20200 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
20201 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
20203 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
20204 check_texture_float(cs_texture
, 1.0f
, 2);
20205 check_texture_float(ps_texture
, 0.0f
, 2);
20206 draw_quad(&test_context
);
20207 check_texture_float(cs_texture
, 1.0f
, 2);
20208 check_texture_float(ps_texture
, 1.0f
, 2);
20211 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cs_cb
, 0, NULL
, &input
, 0, 0);
20212 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
20213 check_texture_float(cs_texture
, 0.5f
, 2);
20214 check_texture_float(ps_texture
, 1.0f
, 2);
20216 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)ps_cb
, 0, NULL
, &input
, 0, 0);
20217 draw_quad(&test_context
);
20218 check_texture_float(cs_texture
, 0.5f
, 2);
20219 check_texture_float(ps_texture
, 2.0f
, 2);
20222 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cs_cb
, 0, NULL
, &input
, 0, 0);
20224 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)ps_cb
, 0, NULL
, &input
, 0, 0);
20225 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
20226 check_texture_float(cs_texture
, 8.0f
, 2);
20227 check_texture_float(ps_texture
, 2.0f
, 2);
20228 draw_quad(&test_context
);
20229 check_texture_float(cs_texture
, 8.0f
, 2);
20230 check_texture_float(ps_texture
, 4.0f
, 2);
20232 ID3D11ComputeShader_Release(cs
);
20233 ID3D11PixelShader_Release(ps
);
20234 ID3D11Buffer_Release(cs_cb
);
20235 ID3D11Buffer_Release(ps_cb
);
20236 ID3D11Texture2D_Release(cs_texture
);
20237 ID3D11Texture2D_Release(ps_texture
);
20238 ID3D11UnorderedAccessView_Release(cs_uav
);
20239 ID3D11UnorderedAccessView_Release(ps_uav
);
20240 ID3D11DeviceContext_Release(context
);
20241 release_test_context(&test_context
);
20244 static void test_atomic_instructions(void)
20246 ID3D11UnorderedAccessView
*in_uav
, *out_uav
;
20247 ID3D11Buffer
*cb
, *in_buffer
, *out_buffer
;
20248 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
20249 struct d3d11_test_context test_context
;
20250 struct resource_readback rb
, out_rb
;
20251 D3D11_BUFFER_DESC buffer_desc
;
20252 ID3D11DeviceContext
*context
;
20253 ID3D11ComputeShader
*cs
;
20254 ID3D11PixelShader
*ps
;
20255 ID3D11Device
*device
;
20259 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
20260 static const unsigned int zero
[4] = {0, 0, 0, 0};
20261 static const DWORD ps_atomics_code
[] =
20264 RWByteAddressBuffer u
;
20271 u
.InterlockedAnd(0 * 4, v
.x
);
20272 u
.InterlockedCompareStore(1 * 4, v
.y
, v
.x
);
20273 u
.InterlockedAdd(2 * 4, v
.x
);
20274 u
.InterlockedOr(3 * 4, v
.x
);
20275 u
.InterlockedMax(4 * 4, i
.x
);
20276 u
.InterlockedMin(5 * 4, i
.x
);
20277 u
.InterlockedMax(6 * 4, v
.x
);
20278 u
.InterlockedMin(7 * 4, v
.x
);
20279 u
.InterlockedXor(8 * 4, v
.x
);
20282 0x43425844, 0x24c6a30c, 0x2ce4437d, 0xdee8a0df, 0xd18cb4bc, 0x00000001, 0x000001ac, 0x00000003,
20283 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
20284 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000158, 0x00000050, 0x00000056, 0x0100086a,
20285 0x04000059, 0x00208e46, 0x00000000, 0x00000002, 0x0300009d, 0x0011e000, 0x00000000, 0x080000a9,
20286 0x0011e000, 0x00000000, 0x00004001, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x0b0000ac,
20287 0x0011e000, 0x00000000, 0x00004001, 0x00000004, 0x0020801a, 0x00000000, 0x00000000, 0x0020800a,
20288 0x00000000, 0x00000000, 0x080000ad, 0x0011e000, 0x00000000, 0x00004001, 0x00000008, 0x0020800a,
20289 0x00000000, 0x00000000, 0x080000aa, 0x0011e000, 0x00000000, 0x00004001, 0x0000000c, 0x0020800a,
20290 0x00000000, 0x00000000, 0x080000ae, 0x0011e000, 0x00000000, 0x00004001, 0x00000010, 0x0020800a,
20291 0x00000000, 0x00000001, 0x080000af, 0x0011e000, 0x00000000, 0x00004001, 0x00000014, 0x0020800a,
20292 0x00000000, 0x00000001, 0x080000b0, 0x0011e000, 0x00000000, 0x00004001, 0x00000018, 0x0020800a,
20293 0x00000000, 0x00000000, 0x080000b1, 0x0011e000, 0x00000000, 0x00004001, 0x0000001c, 0x0020800a,
20294 0x00000000, 0x00000000, 0x080000ab, 0x0011e000, 0x00000000, 0x00004001, 0x00000020, 0x0020800a,
20295 0x00000000, 0x00000000, 0x0100003e,
20297 static const DWORD cs_atomics_code
[] =
20300 RWByteAddressBuffer u
;
20301 RWByteAddressBuffer u2
;
20306 [numthreads(1, 1, 1)]
20310 u
.InterlockedAnd(0 * 4, v
.x
, r
);
20311 u2
.Store(0 * 4, r
);
20312 u
.InterlockedCompareExchange(1 * 4, v
.y
, v
.x
, r
);
20313 u2
.Store(1 * 4, r
);
20314 u
.InterlockedAdd(2 * 4, v
.x
, r
);
20315 u2
.Store(2 * 4, r
);
20316 u
.InterlockedOr(3 * 4, v
.x
, r
);
20317 u2
.Store(3 * 4, r
);
20318 u
.InterlockedMax(4 * 4, i
.x
, r
);
20319 u2
.Store(4 * 4, r
);
20320 u
.InterlockedMin(5 * 4, i
.x
, r
);
20321 u2
.Store(5 * 4, r
);
20322 u
.InterlockedMax(6 * 4, v
.x
, r
);
20323 u2
.Store(6 * 4, r
);
20324 u
.InterlockedMin(7 * 4, v
.x
, r
);
20325 u2
.Store(7 * 4, r
);
20326 u
.InterlockedXor(8 * 4, v
.x
, r
);
20327 u2
.Store(8 * 4, r
);
20330 0x43425844, 0x859a96e3, 0x1a35e463, 0x1e89ce58, 0x5cfe430a, 0x00000001, 0x0000026c, 0x00000003,
20331 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
20332 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000218, 0x00050050, 0x00000086, 0x0100086a,
20333 0x04000059, 0x00208e46, 0x00000000, 0x00000002, 0x0300009d, 0x0011e000, 0x00000000, 0x0300009d,
20334 0x0011e000, 0x00000001, 0x02000068, 0x00000001, 0x0400009b, 0x00000001, 0x00000001, 0x00000001,
20335 0x0a0000b5, 0x00100012, 0x00000000, 0x0011e000, 0x00000000, 0x00004001, 0x00000000, 0x0020800a,
20336 0x00000000, 0x00000000, 0x0d0000b9, 0x00100022, 0x00000000, 0x0011e000, 0x00000000, 0x00004001,
20337 0x00000004, 0x0020801a, 0x00000000, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x0a0000b4,
20338 0x00100042, 0x00000000, 0x0011e000, 0x00000000, 0x00004001, 0x00000008, 0x0020800a, 0x00000000,
20339 0x00000000, 0x0a0000b6, 0x00100082, 0x00000000, 0x0011e000, 0x00000000, 0x00004001, 0x0000000c,
20340 0x0020800a, 0x00000000, 0x00000000, 0x070000a6, 0x0011e0f2, 0x00000001, 0x00004001, 0x00000000,
20341 0x00100e46, 0x00000000, 0x0a0000ba, 0x00100012, 0x00000000, 0x0011e000, 0x00000000, 0x00004001,
20342 0x00000010, 0x0020800a, 0x00000000, 0x00000001, 0x0a0000bb, 0x00100022, 0x00000000, 0x0011e000,
20343 0x00000000, 0x00004001, 0x00000014, 0x0020800a, 0x00000000, 0x00000001, 0x0a0000bc, 0x00100042,
20344 0x00000000, 0x0011e000, 0x00000000, 0x00004001, 0x00000018, 0x0020800a, 0x00000000, 0x00000000,
20345 0x0a0000bd, 0x00100082, 0x00000000, 0x0011e000, 0x00000000, 0x00004001, 0x0000001c, 0x0020800a,
20346 0x00000000, 0x00000000, 0x070000a6, 0x0011e0f2, 0x00000001, 0x00004001, 0x00000010, 0x00100e46,
20347 0x00000000, 0x0a0000b7, 0x00100012, 0x00000000, 0x0011e000, 0x00000000, 0x00004001, 0x00000020,
20348 0x0020800a, 0x00000000, 0x00000000, 0x070000a6, 0x0011e012, 0x00000001, 0x00004001, 0x00000020,
20349 0x0010000a, 0x00000000, 0x0100003e,
20352 static const char * const instructions
[] =
20354 "atomic_and", "atomic_cmp_store", "atomic_iadd", "atomic_or",
20355 "atomic_imax", "atomic_imin", "atomic_umax", "atomic_umin", "atomic_xor",
20357 static const char * const imm_instructions
[] =
20359 "imm_atomic_and", "imm_atomic_cmp_exch", "imm_atomic_iadd", "imm_atomic_or",
20360 "imm_atomic_imax", "imm_atomic_imin", "imm_atomic_umax", "imm_atomic_umin", "imm_atomic_xor",
20362 static const struct test
20366 unsigned int input
[ARRAY_SIZE(instructions
)];
20367 unsigned int expected_result
[ARRAY_SIZE(instructions
)];
20371 {{1, 0}, {-1}, {0xffff, 0, 1, 0, 0, 0, 0, 0, 0xff}, { 1, 1, 2, 1, 0, ~0u, 1, 0, 0xfe}},
20372 {{~0u, ~0u}, { 0}, {0xffff, 0xf, 1, 0, 0, 0, 0, 9, ~0u}, {0xffff, 0xf, 0, ~0u, 0, 0, ~0u, 9, 0}},
20375 if (!init_test_context(&test_context
, &feature_level
))
20378 device
= test_context
.device
;
20379 context
= test_context
.immediate_context
;
20381 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, 2 * sizeof(struct uvec4
), NULL
);
20382 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
20383 ID3D11DeviceContext_CSSetConstantBuffers(context
, 0, 1, &cb
);
20385 buffer_desc
.ByteWidth
= sizeof(tests
->input
);
20386 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
20387 buffer_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
20388 buffer_desc
.CPUAccessFlags
= 0;
20389 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
;
20390 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &in_buffer
);
20391 ok(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
20392 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &out_buffer
);
20393 ok(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
20395 uav_desc
.Format
= DXGI_FORMAT_R32_TYPELESS
;
20396 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
20397 U(uav_desc
).Buffer
.FirstElement
= 0;
20398 U(uav_desc
).Buffer
.NumElements
= buffer_desc
.ByteWidth
/ sizeof(*tests
->input
);
20399 U(uav_desc
).Buffer
.Flags
= D3D11_BUFFER_UAV_FLAG_RAW
;
20400 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)in_buffer
, &uav_desc
, &in_uav
);
20401 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
20402 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)out_buffer
, &uav_desc
, &out_uav
);
20403 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
20405 set_viewport(context
, 0.0f
, 0.0f
, 1.0f
, 1.0f
, 0.0f
, 1.0f
);
20407 hr
= ID3D11Device_CreatePixelShader(device
, ps_atomics_code
, sizeof(ps_atomics_code
), NULL
, &ps
);
20408 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
20409 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
20411 hr
= ID3D11Device_CreateComputeShader(device
, cs_atomics_code
, sizeof(cs_atomics_code
), NULL
, &cs
);
20412 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
20413 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
20415 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
20417 const struct test
*test
= &tests
[i
];
20419 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
20420 NULL
, &test
->v
, 0, 0);
20422 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)in_buffer
, 0,
20423 NULL
, test
->input
, 0, 0);
20425 ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context
, 0, NULL
, NULL
,
20426 0, 1, &in_uav
, NULL
);
20428 draw_quad(&test_context
);
20429 get_buffer_readback(in_buffer
, &rb
);
20430 for (j
= 0; j
< ARRAY_SIZE(instructions
); ++j
)
20432 unsigned int value
= get_readback_color(&rb
, j
, 0, 0);
20433 unsigned int expected
= test
->expected_result
[j
];
20435 todo_wine_if(expected
!= test
->input
[j
]
20436 && (!strcmp(instructions
[j
], "atomic_imax")
20437 || !strcmp(instructions
[j
], "atomic_imin")))
20438 ok(value
== expected
, "Test %u: Got %#x (%d), expected %#x (%d) for '%s' "
20439 "with inputs (%u, %u), (%d), %#x (%d).\n",
20440 i
, value
, value
, expected
, expected
, instructions
[j
],
20441 test
->v
.x
, test
->v
.y
, test
->i
.x
, test
->input
[j
], test
->input
[j
]);
20443 release_resource_readback(&rb
);
20445 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)in_buffer
, 0,
20446 NULL
, test
->input
, 0, 0);
20447 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, out_uav
, zero
);
20449 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &in_uav
, NULL
);
20450 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 1, 1, &out_uav
, NULL
);
20452 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
20453 get_buffer_readback(in_buffer
, &rb
);
20454 get_buffer_readback(out_buffer
, &out_rb
);
20455 for (j
= 0; j
< ARRAY_SIZE(instructions
); ++j
)
20457 BOOL todo_instruction
= !strcmp(imm_instructions
[j
], "imm_atomic_imax")
20458 || !strcmp(imm_instructions
[j
], "imm_atomic_imin");
20459 unsigned int out_value
= get_readback_color(&out_rb
, j
, 0, 0);
20460 unsigned int value
= get_readback_color(&rb
, j
, 0, 0);
20461 unsigned int expected
= test
->expected_result
[j
];
20463 todo_wine_if(expected
!= test
->input
[j
] && todo_instruction
)
20464 ok(value
== expected
, "Test %u: Got %#x (%d), expected %#x (%d) for '%s' "
20465 "with inputs (%u, %u), (%d), %#x (%d).\n",
20466 i
, value
, value
, expected
, expected
, imm_instructions
[j
],
20467 test
->v
.x
, test
->v
.y
, test
->i
.x
, test
->input
[j
], test
->input
[j
]);
20469 todo_wine_if(todo_instruction
&& out_value
!= test
->input
[j
])
20470 ok(out_value
== test
->input
[j
], "Got original value %u, expected %u for '%s'.\n",
20471 out_value
, test
->input
[j
], imm_instructions
[j
]);
20473 release_resource_readback(&out_rb
);
20474 release_resource_readback(&rb
);
20477 ID3D11Buffer_Release(cb
);
20478 ID3D11Buffer_Release(in_buffer
);
20479 ID3D11Buffer_Release(out_buffer
);
20480 ID3D11ComputeShader_Release(cs
);
20481 ID3D11PixelShader_Release(ps
);
20482 ID3D11UnorderedAccessView_Release(in_uav
);
20483 ID3D11UnorderedAccessView_Release(out_uav
);
20484 release_test_context(&test_context
);
20487 static void test_sm4_ret_instruction(void)
20489 struct d3d11_test_context test_context
;
20490 ID3D11DeviceContext
*context
;
20491 ID3D11PixelShader
*ps
;
20492 struct uvec4 constant
;
20493 ID3D11Device
*device
;
20497 static const DWORD ps_code
[] =
20502 float4
main() : SV_TARGET
20505 return float4(1, 0, 0, 1);
20507 return float4(0, 1, 0, 1);
20509 return float4(0, 0, 1, 1);
20510 return float4(1, 1, 1, 1);
20513 0x43425844, 0x9ee6f808, 0xe74009f3, 0xbb1adaf2, 0x432e97b5, 0x00000001, 0x000001c4, 0x00000003,
20514 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
20515 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
20516 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x0000014c, 0x00000040, 0x00000053,
20517 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
20518 0x00000001, 0x08000020, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x00004001,
20519 0x00000001, 0x0304001f, 0x0010000a, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002,
20520 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000015, 0x08000020, 0x00100012,
20521 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x00004001, 0x00000002, 0x0304001f, 0x0010000a,
20522 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x00000000,
20523 0x3f800000, 0x0100003e, 0x01000015, 0x08000020, 0x00100012, 0x00000000, 0x0020800a, 0x00000000,
20524 0x00000000, 0x00004001, 0x00000003, 0x0304001f, 0x0010000a, 0x00000000, 0x08000036, 0x001020f2,
20525 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x3f800000, 0x3f800000, 0x0100003e, 0x01000015,
20526 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000,
20530 if (!init_test_context(&test_context
, NULL
))
20533 device
= test_context
.device
;
20534 context
= test_context
.immediate_context
;
20536 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
20537 ok(SUCCEEDED(hr
), "Failed to create shader, hr %#x.\n", hr
);
20538 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
20539 memset(&constant
, 0, sizeof(constant
));
20540 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(constant
), &constant
);
20541 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
20543 draw_quad(&test_context
);
20544 check_texture_color(test_context
.backbuffer
, 0xffffffff, 0);
20547 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
20548 draw_quad(&test_context
);
20549 check_texture_color(test_context
.backbuffer
, 0xff0000ff, 0);
20552 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
20553 draw_quad(&test_context
);
20554 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
20557 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
20558 draw_quad(&test_context
);
20559 check_texture_color(test_context
.backbuffer
, 0xffff0000, 0);
20562 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
20563 draw_quad(&test_context
);
20564 check_texture_color(test_context
.backbuffer
, 0xffffffff, 0);
20566 ID3D11Buffer_Release(cb
);
20567 ID3D11PixelShader_Release(ps
);
20568 release_test_context(&test_context
);
20571 static void test_primitive_restart(void)
20573 struct d3d11_test_context test_context
;
20574 ID3D11Buffer
*ib32
, *ib16
, *vb
;
20575 ID3D11DeviceContext
*context
;
20576 unsigned int stride
, offset
;
20577 ID3D11InputLayout
*layout
;
20578 ID3D11VertexShader
*vs
;
20579 ID3D11PixelShader
*ps
;
20580 ID3D11Device
*device
;
20585 static const DWORD ps_code
[] =
20590 float4 position
: SV_Position
;
20591 float4 color
: color
;
20594 float4
main(vs_out input
) : SV_TARGET
20596 return input
.color
;
20599 0x43425844, 0x119e48d1, 0x468aecb3, 0x0a405be5, 0x4e203b82, 0x00000001, 0x000000f4, 0x00000003,
20600 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
20601 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
20602 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x7469736f, 0x006e6f69, 0x6f6c6f63, 0xabab0072,
20603 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
20604 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040,
20605 0x0000000e, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
20606 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
20608 static const DWORD vs_code
[] =
20613 float4 position
: SV_Position
;
20614 float4 color
: color
;
20617 void main(float4 position
: POSITION
, uint vertex_id
: SV_VertexID
, out vs_out output
)
20619 output
.position
= position
;
20620 output
.color
= vertex_id
< 4 ? float4(0.0, 1.0, 1.0, 1.0) : float4(1.0, 0.0, 0.0, 1.0);
20623 0x43425844, 0x2fa57573, 0xdb71c15f, 0x2641b028, 0xa8f87ccc, 0x00000001, 0x00000198, 0x00000003,
20624 0x0000002c, 0x00000084, 0x000000d8, 0x4e475349, 0x00000050, 0x00000002, 0x00000008, 0x00000038,
20625 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000006,
20626 0x00000001, 0x00000001, 0x00000101, 0x49534f50, 0x4e4f4954, 0x5f565300, 0x74726556, 0x44497865,
20627 0xababab00, 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001,
20628 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001,
20629 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69, 0x6f6c6f63, 0xabab0072, 0x52444853, 0x000000b8,
20630 0x00010040, 0x0000002e, 0x0300005f, 0x001010f2, 0x00000000, 0x04000060, 0x00101012, 0x00000001,
20631 0x00000006, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001,
20632 0x02000068, 0x00000001, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0700004f,
20633 0x00100012, 0x00000000, 0x0010100a, 0x00000001, 0x00004001, 0x00000004, 0x0f000037, 0x001020f2,
20634 0x00000001, 0x00100006, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x3f800000, 0x3f800000,
20635 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e,
20637 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
20639 {"position", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
20641 static const struct vec2 vertices
[] =
20652 static const float black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
20653 static const unsigned short indices16
[] =
20655 0, 1, 2, 3, 0xffff, 4, 5, 6, 7
20657 static const unsigned int indices32
[] =
20659 0, 1, 2, 3, 0xffffffff, 4, 5, 6, 7
20662 if (!init_test_context(&test_context
, NULL
))
20665 device
= test_context
.device
;
20666 context
= test_context
.immediate_context
;
20668 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
20669 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
20670 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
20671 ok(SUCCEEDED(hr
), "Failed to create return pixel shader, hr %#x.\n", hr
);
20673 ib16
= create_buffer(device
, D3D11_BIND_INDEX_BUFFER
, sizeof(indices16
), indices16
);
20674 ib32
= create_buffer(device
, D3D11_BIND_INDEX_BUFFER
, sizeof(indices32
), indices32
);
20676 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
20677 vs_code
, sizeof(vs_code
), &layout
);
20678 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
20680 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(vertices
), vertices
);
20682 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
20683 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
20685 ID3D11DeviceContext_IASetInputLayout(context
, layout
);
20686 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
20687 stride
= sizeof(*vertices
);
20689 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, &stride
, &offset
);
20691 for (i
= 0; i
< 2; ++i
)
20694 ID3D11DeviceContext_IASetIndexBuffer(context
, ib32
, DXGI_FORMAT_R32_UINT
, 0);
20696 ID3D11DeviceContext_IASetIndexBuffer(context
, ib16
, DXGI_FORMAT_R16_UINT
, 0);
20698 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, black
);
20699 ID3D11DeviceContext_DrawIndexed(context
, 9, 0, 0);
20700 SetRect(&rect
, 0, 0, 240, 480);
20701 check_texture_sub_resource_color(test_context
.backbuffer
, 0, &rect
, 0xffffff00, 1);
20702 SetRect(&rect
, 240, 0, 400, 480);
20703 check_texture_sub_resource_color(test_context
.backbuffer
, 0, &rect
, 0x00000000, 1);
20704 SetRect(&rect
, 400, 0, 640, 480);
20705 check_texture_sub_resource_color(test_context
.backbuffer
, 0, &rect
, 0xff0000ff, 1);
20708 ID3D11Buffer_Release(ib16
);
20709 ID3D11Buffer_Release(ib32
);
20710 ID3D11Buffer_Release(vb
);
20711 ID3D11InputLayout_Release(layout
);
20712 ID3D11PixelShader_Release(ps
);
20713 ID3D11VertexShader_Release(vs
);
20714 release_test_context(&test_context
);
20717 static void test_resinfo_instruction(void)
20725 struct d3d11_test_context test_context
;
20726 D3D11_TEXTURE3D_DESC texture3d_desc
;
20727 D3D11_TEXTURE2D_DESC texture_desc
;
20728 const struct shader
*current_ps
;
20729 D3D_FEATURE_LEVEL feature_level
;
20730 ID3D11ShaderResourceView
*srv
;
20731 ID3D11DeviceContext
*context
;
20732 ID3D11Texture2D
*rtv_texture
;
20733 ID3D11RenderTargetView
*rtv
;
20734 ID3D11Resource
*texture
;
20735 struct uvec4 constant
;
20736 ID3D11PixelShader
*ps
;
20737 ID3D11Device
*device
;
20738 unsigned int i
, type
;
20742 static const DWORD ps_2d_code
[] =
20750 float4
main() : SV_TARGET
20754 float width
, height
, miplevels
;
20755 t
.GetDimensions(level
, width
, height
, miplevels
);
20756 return float4(width
, height
, miplevels
, 0);
20760 uint width
, height
, miplevels
;
20761 t
.GetDimensions(level
, width
, height
, miplevels
);
20762 return float4(width
, height
, miplevels
, 0);
20766 0x43425844, 0x9c2db58d, 0x7218d757, 0x23255414, 0xaa86938e, 0x00000001, 0x00000168, 0x00000003,
20767 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
20768 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
20769 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000f0, 0x00000040, 0x0000003c,
20770 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
20771 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0400001f, 0x0020800a, 0x00000000,
20772 0x00000000, 0x0800003d, 0x001000f2, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x00107e46,
20773 0x00000000, 0x05000036, 0x00102072, 0x00000000, 0x00100346, 0x00000000, 0x05000036, 0x00102082,
20774 0x00000000, 0x00004001, 0x00000000, 0x0100003e, 0x01000012, 0x0800103d, 0x001000f2, 0x00000000,
20775 0x0020801a, 0x00000000, 0x00000000, 0x00107e46, 0x00000000, 0x05000056, 0x00102072, 0x00000000,
20776 0x00100346, 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x00000000, 0x0100003e,
20777 0x01000015, 0x0100003e,
20779 static const struct shader ps_2d
= {ps_2d_code
, sizeof(ps_2d_code
)};
20780 static const DWORD ps_2d_array_code
[] =
20788 float4
main() : SV_TARGET
20792 float width
, height
, elements
, miplevels
;
20793 t
.GetDimensions(level
, width
, height
, elements
, miplevels
);
20794 return float4(width
, height
, elements
, miplevels
);
20798 uint width
, height
, elements
, miplevels
;
20799 t
.GetDimensions(level
, width
, height
, elements
, miplevels
);
20800 return float4(width
, height
, elements
, miplevels
);
20804 0x43425844, 0x92cd8789, 0x38e359ac, 0xd65ab502, 0xa018a5ae, 0x00000001, 0x0000012c, 0x00000003,
20805 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
20806 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
20807 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000b4, 0x00000040, 0x0000002d,
20808 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04004058, 0x00107000, 0x00000000, 0x00005555,
20809 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0400001f, 0x0020800a, 0x00000000,
20810 0x00000000, 0x0800003d, 0x001020f2, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x00107e46,
20811 0x00000000, 0x0100003e, 0x01000012, 0x0800103d, 0x001000f2, 0x00000000, 0x0020801a, 0x00000000,
20812 0x00000000, 0x00107e46, 0x00000000, 0x05000056, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
20813 0x0100003e, 0x01000015, 0x0100003e,
20815 static const struct shader ps_2d_array
= {ps_2d_array_code
, sizeof(ps_2d_array_code
)};
20816 static const DWORD ps_3d_code
[] =
20824 float4
main() : SV_TARGET
20828 float width
, height
, depth
, miplevels
;
20829 t
.GetDimensions(level
, width
, height
, depth
, miplevels
);
20830 return float4(width
, height
, depth
, miplevels
);
20834 uint width
, height
, depth
, miplevels
;
20835 t
.GetDimensions(level
, width
, height
, depth
, miplevels
);
20836 return float4(width
, height
, depth
, miplevels
);
20840 0x43425844, 0xac1f73b9, 0x2bce1322, 0x82c599e6, 0xbff0d681, 0x00000001, 0x0000012c, 0x00000003,
20841 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
20842 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
20843 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000b4, 0x00000040, 0x0000002d,
20844 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04002858, 0x00107000, 0x00000000, 0x00005555,
20845 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0400001f, 0x0020800a, 0x00000000,
20846 0x00000000, 0x0800003d, 0x001020f2, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x00107e46,
20847 0x00000000, 0x0100003e, 0x01000012, 0x0800103d, 0x001000f2, 0x00000000, 0x0020801a, 0x00000000,
20848 0x00000000, 0x00107e46, 0x00000000, 0x05000056, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
20849 0x0100003e, 0x01000015, 0x0100003e,
20851 static const struct shader ps_3d
= {ps_3d_code
, sizeof(ps_3d_code
)};
20852 static const DWORD ps_cube_code
[] =
20860 float4
main() : SV_TARGET
20864 float width
, height
, miplevels
;
20865 t
.GetDimensions(level
, width
, height
, miplevels
);
20866 return float4(width
, height
, miplevels
, 0);
20870 uint width
, height
, miplevels
;
20871 t
.GetDimensions(level
, width
, height
, miplevels
);
20872 return float4(width
, height
, miplevels
, 0);
20876 0x43425844, 0x795eb161, 0xb8291400, 0xcc531086, 0x2a8143ce, 0x00000001, 0x00000168, 0x00000003,
20877 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
20878 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
20879 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000f0, 0x00000040, 0x0000003c,
20880 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04003058, 0x00107000, 0x00000000, 0x00005555,
20881 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0400001f, 0x0020800a, 0x00000000,
20882 0x00000000, 0x0800003d, 0x001000f2, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x00107e46,
20883 0x00000000, 0x05000036, 0x00102072, 0x00000000, 0x00100346, 0x00000000, 0x05000036, 0x00102082,
20884 0x00000000, 0x00004001, 0x00000000, 0x0100003e, 0x01000012, 0x0800103d, 0x001000f2, 0x00000000,
20885 0x0020801a, 0x00000000, 0x00000000, 0x00107e46, 0x00000000, 0x05000056, 0x00102072, 0x00000000,
20886 0x00100346, 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x00000000, 0x0100003e,
20887 0x01000015, 0x0100003e,
20889 static const struct shader ps_cube
= {ps_cube_code
, sizeof(ps_cube_code
)};
20890 static const DWORD ps_cube_array_code
[] =
20893 TextureCubeArray t
;
20898 float4
main() : SV_TARGET
20902 float width
, height
, elements
, miplevels
;
20903 t
.GetDimensions(level
, width
, height
, elements
, miplevels
);
20904 return float4(width
, height
, miplevels
, 0);
20908 uint width
, height
, elements
, miplevels
;
20909 t
.GetDimensions(level
, width
, height
, elements
, miplevels
);
20910 return float4(width
, height
, miplevels
, 0);
20914 0x43425844, 0x894d136f, 0xa1f5c746, 0xd771ac09, 0x6914e044, 0x00000001, 0x0000016c, 0x00000003,
20915 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
20916 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
20917 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000f4, 0x00000041, 0x0000003d,
20918 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04005058, 0x00107000, 0x00000000,
20919 0x00005555, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0400001f, 0x0020800a,
20920 0x00000000, 0x00000000, 0x0800003d, 0x00100072, 0x00000000, 0x0020801a, 0x00000000, 0x00000000,
20921 0x00107b46, 0x00000000, 0x05000036, 0x00102072, 0x00000000, 0x00100246, 0x00000000, 0x05000036,
20922 0x00102082, 0x00000000, 0x00004001, 0x00000000, 0x0100003e, 0x01000012, 0x0800103d, 0x00100072,
20923 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x00107b46, 0x00000000, 0x05000056, 0x00102072,
20924 0x00000000, 0x00100246, 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x00000000,
20925 0x0100003e, 0x01000015, 0x0100003e,
20927 static const struct shader ps_cube_array
= {ps_cube_array_code
, sizeof(ps_cube_array_code
)};
20928 static const struct ps_test
20930 const struct shader
*ps
;
20933 unsigned int width
;
20934 unsigned int height
;
20935 unsigned int depth
;
20936 unsigned int miplevel_count
;
20937 unsigned int array_size
;
20938 unsigned int cube_count
;
20940 unsigned int miplevel
;
20941 struct vec4 expected_result
;
20945 {&ps_2d
, {64, 64, 1, 1, 1, 0}, 0, {64.0f
, 64.0f
, 1.0f
, 0.0f
}},
20946 {&ps_2d
, {32, 16, 1, 3, 1, 0}, 0, {32.0f
, 16.0f
, 3.0f
, 0.0f
}},
20947 {&ps_2d
, {32, 16, 1, 3, 1, 0}, 1, {16.0f
, 8.0f
, 3.0f
, 0.0f
}},
20948 {&ps_2d
, {32, 16, 1, 3, 1, 0}, 2, { 8.0f
, 4.0f
, 3.0f
, 0.0f
}},
20950 {&ps_2d_array
, {64, 64, 1, 1, 6, 0}, 0, {64.0f
, 64.0f
, 6.0f
, 1.0f
}},
20951 {&ps_2d_array
, {32, 16, 1, 3, 9, 0}, 0, {32.0f
, 16.0f
, 9.0f
, 3.0f
}},
20952 {&ps_2d_array
, {32, 16, 1, 3, 7, 0}, 1, {16.0f
, 8.0f
, 7.0f
, 3.0f
}},
20953 {&ps_2d_array
, {32, 16, 1, 3, 3, 0}, 2, { 8.0f
, 4.0f
, 3.0f
, 3.0f
}},
20955 {&ps_3d
, {64, 64, 2, 1, 1, 0}, 0, {64.0f
, 64.0f
, 2.0f
, 1.0f
}},
20956 {&ps_3d
, {64, 64, 2, 2, 1, 0}, 1, {32.0f
, 32.0f
, 1.0f
, 2.0f
}},
20957 {&ps_3d
, {64, 64, 4, 1, 1, 0}, 0, {64.0f
, 64.0f
, 4.0f
, 1.0f
}},
20958 {&ps_3d
, {64, 64, 4, 2, 1, 0}, 1, {32.0f
, 32.0f
, 2.0f
, 2.0f
}},
20959 {&ps_3d
, { 8, 8, 8, 1, 1, 0}, 0, { 8.0f
, 8.0f
, 8.0f
, 1.0f
}},
20960 {&ps_3d
, { 8, 8, 8, 4, 1, 0}, 0, { 8.0f
, 8.0f
, 8.0f
, 4.0f
}},
20961 {&ps_3d
, { 8, 8, 8, 4, 1, 0}, 1, { 4.0f
, 4.0f
, 4.0f
, 4.0f
}},
20962 {&ps_3d
, { 8, 8, 8, 4, 1, 0}, 2, { 2.0f
, 2.0f
, 2.0f
, 4.0f
}},
20963 {&ps_3d
, { 8, 8, 8, 4, 1, 0}, 3, { 1.0f
, 1.0f
, 1.0f
, 4.0f
}},
20965 {&ps_cube
, { 4, 4, 1, 1, 6, 1}, 0, { 4.0f
, 4.0f
, 1.0f
, 0.0f
}},
20966 {&ps_cube
, {32, 32, 1, 1, 6, 1}, 0, {32.0f
, 32.0f
, 1.0f
, 0.0f
}},
20967 {&ps_cube
, {32, 32, 1, 3, 6, 1}, 0, {32.0f
, 32.0f
, 3.0f
, 0.0f
}},
20968 {&ps_cube
, {32, 32, 1, 3, 6, 1}, 1, {16.0f
, 16.0f
, 3.0f
, 0.0f
}},
20969 {&ps_cube
, {32, 32, 1, 3, 6, 1}, 2, { 8.0f
, 8.0f
, 3.0f
, 0.0f
}},
20971 {&ps_cube_array
, { 4, 4, 1, 1, 12, 2}, 0, { 4.0f
, 4.0f
, 1.0f
, 0.0f
}},
20972 {&ps_cube_array
, {32, 32, 1, 1, 12, 2}, 0, {32.0f
, 32.0f
, 1.0f
, 0.0f
}},
20973 {&ps_cube_array
, {32, 32, 1, 3, 12, 2}, 0, {32.0f
, 32.0f
, 3.0f
, 0.0f
}},
20976 if (!init_test_context(&test_context
, NULL
))
20979 device
= test_context
.device
;
20980 context
= test_context
.immediate_context
;
20981 feature_level
= ID3D11Device_GetFeatureLevel(device
);
20983 texture_desc
.Width
= 64;
20984 texture_desc
.Height
= 64;
20985 texture_desc
.MipLevels
= 1;
20986 texture_desc
.ArraySize
= 1;
20987 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
20988 texture_desc
.SampleDesc
.Count
= 1;
20989 texture_desc
.SampleDesc
.Quality
= 0;
20990 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
20991 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
20992 texture_desc
.CPUAccessFlags
= 0;
20993 texture_desc
.MiscFlags
= 0;
20994 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rtv_texture
);
20995 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
20996 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rtv_texture
, NULL
, &rtv
);
20997 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
20999 memset(&constant
, 0, sizeof(constant
));
21000 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(constant
), &constant
);
21002 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
21003 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
21007 for (i
= 0; i
< ARRAY_SIZE(ps_tests
); ++i
)
21009 const struct ps_test
*test
= &ps_tests
[i
];
21011 if (test
->texture_desc
.cube_count
> 1 && feature_level
< D3D_FEATURE_LEVEL_10_1
)
21013 skip("Test %u: Cube map array textures require feature level 10_1.\n", i
);
21017 if (current_ps
!= test
->ps
)
21020 ID3D11PixelShader_Release(ps
);
21022 current_ps
= test
->ps
;
21024 hr
= ID3D11Device_CreatePixelShader(device
, current_ps
->code
, current_ps
->size
, NULL
, &ps
);
21025 ok(SUCCEEDED(hr
), "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
21026 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
21029 if (test
->texture_desc
.depth
!= 1)
21031 texture3d_desc
.Width
= test
->texture_desc
.width
;
21032 texture3d_desc
.Height
= test
->texture_desc
.height
;
21033 texture3d_desc
.Depth
= test
->texture_desc
.depth
;
21034 texture3d_desc
.MipLevels
= test
->texture_desc
.miplevel_count
;
21035 texture3d_desc
.Format
= DXGI_FORMAT_R8_UNORM
;
21036 texture3d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
21037 texture3d_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
21038 texture3d_desc
.CPUAccessFlags
= 0;
21039 texture3d_desc
.MiscFlags
= 0;
21040 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, (ID3D11Texture3D
**)&texture
);
21041 ok(SUCCEEDED(hr
), "Test %u: Failed to create 3d texture, hr %#x.\n", i
, hr
);
21045 texture_desc
.Width
= test
->texture_desc
.width
;
21046 texture_desc
.Height
= test
->texture_desc
.height
;
21047 texture_desc
.MipLevels
= test
->texture_desc
.miplevel_count
;
21048 texture_desc
.ArraySize
= test
->texture_desc
.array_size
;
21049 texture_desc
.Format
= DXGI_FORMAT_R8_UNORM
;
21050 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
21051 texture_desc
.MiscFlags
= 0;
21052 if (test
->texture_desc
.cube_count
)
21053 texture_desc
.MiscFlags
|= D3D11_RESOURCE_MISC_TEXTURECUBE
;
21054 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, (ID3D11Texture2D
**)&texture
);
21055 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
21058 hr
= ID3D11Device_CreateShaderResourceView(device
, texture
, NULL
, &srv
);
21059 ok(SUCCEEDED(hr
), "Test %u: Failed to create shader resource view, hr %#x.\n", i
, hr
);
21060 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
21062 for (type
= 0; type
< 2; ++type
)
21065 constant
.y
= test
->miplevel
;
21066 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
21068 draw_quad(&test_context
);
21069 check_texture_vec4(rtv_texture
, &test
->expected_result
, 0);
21072 ID3D11Resource_Release(texture
);
21073 ID3D11ShaderResourceView_Release(srv
);
21075 ID3D11PixelShader_Release(ps
);
21077 ID3D11Buffer_Release(cb
);
21078 ID3D11RenderTargetView_Release(rtv
);
21079 ID3D11Texture2D_Release(rtv_texture
);
21080 release_test_context(&test_context
);
21083 static void test_sm5_bufinfo_instruction(void)
21091 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
21092 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
21093 struct d3d11_test_context test_context
;
21094 D3D11_TEXTURE2D_DESC texture_desc
;
21095 const struct shader
*current_ps
;
21096 ID3D11UnorderedAccessView
*uav
;
21097 ID3D11ShaderResourceView
*srv
;
21098 D3D11_BUFFER_DESC buffer_desc
;
21099 ID3D11DeviceContext
*context
;
21100 ID3D11RenderTargetView
*rtv
;
21101 ID3D11Texture2D
*texture
;
21102 ID3D11PixelShader
*ps
;
21103 ID3D11Buffer
*buffer
;
21104 ID3D11Device
*device
;
21108 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
21109 static const DWORD ps_uav_structured_code
[] =
21118 RWStructuredBuffer
<s
> b
;
21120 uint4
main(void) : SV_Target
21122 uint count
, stride
;
21123 b
.GetDimensions(count
, stride
);
21124 return uint4(count
, stride
, 0, 1);
21127 0x43425844, 0xe1900f85, 0x13c1f338, 0xbb19865e, 0x366df28f, 0x00000001, 0x000000fc, 0x00000003,
21128 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
21129 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
21130 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000084, 0x00000050, 0x00000021,
21131 0x0100086a, 0x0400009e, 0x0011e000, 0x00000001, 0x00000014, 0x03000065, 0x001020f2, 0x00000000,
21132 0x02000068, 0x00000001, 0x87000079, 0x8000a302, 0x00199983, 0x00100012, 0x00000000, 0x0011ee46,
21133 0x00000001, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x08000036, 0x001020e2,
21134 0x00000000, 0x00004002, 0x00000000, 0x00000014, 0x00000000, 0x00000001, 0x0100003e,
21136 static const struct shader ps_uav_structured
= {ps_uav_structured_code
, sizeof(ps_uav_structured_code
)};
21137 static const DWORD ps_uav_structured32_code
[] =
21146 RWStructuredBuffer
<s
> b
;
21148 uint4
main(void) : SV_Target
21150 uint count
, stride
;
21151 b
.GetDimensions(count
, stride
);
21152 return uint4(count
, stride
, 0, 1);
21155 0x43425844, 0xdd87a805, 0x28090470, 0xe4fa7c4d, 0x57963f52, 0x00000001, 0x000000fc, 0x00000003,
21156 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
21157 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
21158 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000084, 0x00000050, 0x00000021,
21159 0x0100086a, 0x0400009e, 0x0011e000, 0x00000001, 0x00000020, 0x03000065, 0x001020f2, 0x00000000,
21160 0x02000068, 0x00000001, 0x87000079, 0x80010302, 0x00199983, 0x00100012, 0x00000000, 0x0011ee46,
21161 0x00000001, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x08000036, 0x001020e2,
21162 0x00000000, 0x00004002, 0x00000000, 0x00000020, 0x00000000, 0x00000001, 0x0100003e,
21164 static const struct shader ps_uav_structured32
= {ps_uav_structured32_code
, sizeof(ps_uav_structured32_code
)};
21165 static const DWORD ps_srv_structured_code
[] =
21168 StructuredBuffer
<bool> b
;
21170 uint4
main(void) : SV_Target
21172 uint count
, stride
;
21173 b
.GetDimensions(count
, stride
);
21174 return uint4(count
, stride
, 0, 1);
21177 0x43425844, 0x313f910c, 0x2f60c646, 0x2d87455c, 0xb9988c2c, 0x00000001, 0x000000fc, 0x00000003,
21178 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
21179 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
21180 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000084, 0x00000050, 0x00000021,
21181 0x0100086a, 0x040000a2, 0x00107000, 0x00000000, 0x00000004, 0x03000065, 0x001020f2, 0x00000000,
21182 0x02000068, 0x00000001, 0x87000079, 0x80002302, 0x00199983, 0x00100012, 0x00000000, 0x00107e46,
21183 0x00000000, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x08000036, 0x001020e2,
21184 0x00000000, 0x00004002, 0x00000000, 0x00000004, 0x00000000, 0x00000001, 0x0100003e,
21186 static const struct shader ps_srv_structured
= {ps_srv_structured_code
, sizeof(ps_srv_structured_code
)};
21187 static const DWORD ps_uav_raw_code
[] =
21190 RWByteAddressBuffer b
;
21192 uint4
main(void) : SV_Target
21195 b
.GetDimensions(width
);
21199 0x43425844, 0xb06e9715, 0x99733b00, 0xaa536550, 0x703a01c5, 0x00000001, 0x000000d8, 0x00000003,
21200 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
21201 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
21202 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000060, 0x00000050, 0x00000018,
21203 0x0100086a, 0x0300009d, 0x0011e000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
21204 0x00000001, 0x87000079, 0x800002c2, 0x00199983, 0x00100012, 0x00000000, 0x0011ee46, 0x00000001,
21205 0x05000036, 0x001020f2, 0x00000000, 0x00100006, 0x00000000, 0x0100003e,
21207 static const struct shader ps_uav_raw
= {ps_uav_raw_code
, sizeof(ps_uav_raw_code
)};
21208 static const DWORD ps_srv_raw_code
[] =
21211 ByteAddressBuffer b
;
21213 uint4
main(void) : SV_Target
21216 b
.GetDimensions(width
);
21220 0x43425844, 0x934bc27a, 0x3251cc9d, 0xa129bdd3, 0xf7cedcc4, 0x00000001, 0x000000d8, 0x00000003,
21221 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
21222 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
21223 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000060, 0x00000050, 0x00000018,
21224 0x0100086a, 0x030000a1, 0x00107000, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
21225 0x00000001, 0x87000079, 0x800002c2, 0x00199983, 0x00100012, 0x00000000, 0x00107e46, 0x00000000,
21226 0x05000036, 0x001020f2, 0x00000000, 0x00100006, 0x00000000, 0x0100003e,
21228 static const struct shader ps_srv_raw
= {ps_srv_raw_code
, sizeof(ps_srv_raw_code
)};
21229 static const DWORD ps_uav_typed_code
[] =
21234 uint4
main(void) : SV_Target
21237 b
.GetDimensions(width
);
21241 0x43425844, 0x96b39f5f, 0x5fef24c7, 0xed404a41, 0x01c9d4fe, 0x00000001, 0x000000dc, 0x00000003,
21242 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
21243 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
21244 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000064, 0x00000050, 0x00000019,
21245 0x0100086a, 0x0400089c, 0x0011e000, 0x00000001, 0x00005555, 0x03000065, 0x001020f2, 0x00000000,
21246 0x02000068, 0x00000001, 0x87000079, 0x80000042, 0x00155543, 0x00100012, 0x00000000, 0x0011ee46,
21247 0x00000001, 0x05000036, 0x001020f2, 0x00000000, 0x00100006, 0x00000000, 0x0100003e,
21249 static const struct shader ps_uav_typed
= {ps_uav_typed_code
, sizeof(ps_uav_typed_code
)};
21250 static const DWORD ps_srv_typed_code
[] =
21255 uint4
main(void) : SV_Target
21258 b
.GetDimensions(width
);
21262 0x43425844, 0x6ae6dbb0, 0x6289d227, 0xaf4e708e, 0x111efed1, 0x00000001, 0x000000dc, 0x00000003,
21263 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
21264 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
21265 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000064, 0x00000050, 0x00000019,
21266 0x0100086a, 0x04000858, 0x00107000, 0x00000000, 0x00005555, 0x03000065, 0x001020f2, 0x00000000,
21267 0x02000068, 0x00000001, 0x87000079, 0x80000042, 0x00155543, 0x00100012, 0x00000000, 0x00107e46,
21268 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100006, 0x00000000, 0x0100003e,
21270 static const struct shader ps_srv_typed
= {ps_srv_typed_code
, sizeof(ps_srv_typed_code
)};
21271 static const struct test
21273 const struct shader
*ps
;
21275 unsigned int buffer_size
;
21276 unsigned int buffer_misc_flags
;
21277 unsigned int buffer_structure_byte_stride
;
21278 DXGI_FORMAT view_format
;
21279 unsigned int view_element_idx
;
21280 unsigned int view_element_count
;
21281 struct uvec4 expected_result
;
21285 #define RAW D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
21286 #define STRUCTURED D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
21287 {&ps_uav_raw
, TRUE
, 100, RAW
, 0, DXGI_FORMAT_R32_TYPELESS
, 0, 25, {100, 100, 100, 100}},
21288 {&ps_uav_raw
, TRUE
, 512, RAW
, 0, DXGI_FORMAT_R32_TYPELESS
, 64, 64, {256, 256, 256, 256}},
21289 {&ps_srv_raw
, FALSE
, 100, RAW
, 0, DXGI_FORMAT_R32_TYPELESS
, 0, 25, {100, 100, 100, 100}},
21290 {&ps_srv_raw
, FALSE
, 500, RAW
, 0, DXGI_FORMAT_R32_TYPELESS
, 64, 4, { 16, 16, 16, 16}},
21291 {&ps_uav_structured
, TRUE
, 100, STRUCTURED
, 20, DXGI_FORMAT_UNKNOWN
, 0, 5, { 5, 20, 0, 1}},
21292 {&ps_uav_structured
, TRUE
, 100, STRUCTURED
, 20, DXGI_FORMAT_UNKNOWN
, 0, 2, { 2, 20, 0, 1}},
21293 {&ps_uav_structured32
, TRUE
, 320, STRUCTURED
, 32, DXGI_FORMAT_UNKNOWN
, 8, 2, { 2, 32, 0, 1}},
21294 {&ps_srv_structured
, FALSE
, 100, STRUCTURED
, 4, DXGI_FORMAT_UNKNOWN
, 0, 5, { 5, 4, 0, 1}},
21295 {&ps_srv_structured
, FALSE
, 100, STRUCTURED
, 4, DXGI_FORMAT_UNKNOWN
, 0, 2, { 2, 4, 0, 1}},
21296 {&ps_srv_structured
, FALSE
, 400, STRUCTURED
, 4, DXGI_FORMAT_UNKNOWN
, 64, 2, { 2, 4, 0, 1}},
21297 {&ps_uav_typed
, TRUE
, 200, 0, 0, DXGI_FORMAT_R32_FLOAT
, 0, 50, { 50, 50, 50, 50}},
21298 {&ps_uav_typed
, TRUE
, 400, 0, 0, DXGI_FORMAT_R32_FLOAT
, 64, 1, { 1, 1, 1, 1}},
21299 {&ps_uav_typed
, TRUE
, 100, 0, 0, DXGI_FORMAT_R16_FLOAT
, 0, 50, { 50, 50, 50, 50}},
21300 {&ps_uav_typed
, TRUE
, 400, 0, 0, DXGI_FORMAT_R16_FLOAT
, 128, 1, { 1, 1, 1, 1}},
21301 {&ps_srv_typed
, FALSE
, 200, 0, 0, DXGI_FORMAT_R32_FLOAT
, 0, 50, { 50, 50, 50, 50}},
21302 {&ps_srv_typed
, FALSE
, 400, 0, 0, DXGI_FORMAT_R32_FLOAT
, 64, 1, { 1, 1, 1, 1}},
21303 {&ps_srv_typed
, FALSE
, 100, 0, 0, DXGI_FORMAT_R16_FLOAT
, 0, 50, { 50, 50, 50, 50}},
21304 {&ps_srv_typed
, FALSE
, 400, 0, 0, DXGI_FORMAT_R16_FLOAT
, 128, 2, { 2, 2, 2, 2}},
21309 if (!init_test_context(&test_context
, &feature_level
))
21312 device
= test_context
.device
;
21313 context
= test_context
.immediate_context
;
21315 texture_desc
.Width
= 64;
21316 texture_desc
.Height
= 64;
21317 texture_desc
.MipLevels
= 1;
21318 texture_desc
.ArraySize
= 1;
21319 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_UINT
;
21320 texture_desc
.SampleDesc
.Count
= 1;
21321 texture_desc
.SampleDesc
.Quality
= 0;
21322 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
21323 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
21324 texture_desc
.CPUAccessFlags
= 0;
21325 texture_desc
.MiscFlags
= 0;
21326 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
21327 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
21328 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
21329 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
21333 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
21335 const struct test
*test
= &tests
[i
];
21337 if (current_ps
!= test
->ps
)
21340 ID3D11PixelShader_Release(ps
);
21342 current_ps
= test
->ps
;
21344 hr
= ID3D11Device_CreatePixelShader(device
, current_ps
->code
, current_ps
->size
, NULL
, &ps
);
21345 ok(SUCCEEDED(hr
), "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
21346 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
21349 buffer_desc
.ByteWidth
= test
->buffer_size
;
21350 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
21351 buffer_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
| D3D11_BIND_UNORDERED_ACCESS
;
21352 buffer_desc
.CPUAccessFlags
= 0;
21353 buffer_desc
.MiscFlags
= test
->buffer_misc_flags
;
21354 buffer_desc
.StructureByteStride
= test
->buffer_structure_byte_stride
;
21355 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
21356 ok(SUCCEEDED(hr
), "Test %u: Failed to create buffer, hr %#x.\n", i
, hr
);
21360 uav_desc
.Format
= test
->view_format
;
21361 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
21362 U(uav_desc
).Buffer
.FirstElement
= test
->view_element_idx
;
21363 U(uav_desc
).Buffer
.NumElements
= test
->view_element_count
;
21364 U(uav_desc
).Buffer
.Flags
= 0;
21365 if (buffer_desc
.MiscFlags
& D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
)
21366 U(uav_desc
).Buffer
.Flags
|= D3D11_BUFFER_UAV_FLAG_RAW
;
21367 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
21368 ok(SUCCEEDED(hr
), "Test %u: Failed to create unordered access view, hr %#x.\n", i
, hr
);
21371 ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context
, 1, &rtv
, NULL
,
21376 srv_desc
.Format
= test
->view_format
;
21377 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_BUFFEREX
;
21378 U(srv_desc
).BufferEx
.FirstElement
= test
->view_element_idx
;
21379 U(srv_desc
).BufferEx
.NumElements
= test
->view_element_count
;
21380 U(srv_desc
).BufferEx
.Flags
= 0;
21381 if (buffer_desc
.MiscFlags
& D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
)
21382 U(srv_desc
).BufferEx
.Flags
|= D3D11_BUFFEREX_SRV_FLAG_RAW
;
21383 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)buffer
, &srv_desc
, &srv
);
21384 ok(SUCCEEDED(hr
), "Test %u: Failed to create shader resource view, hr %#x.\n", i
, hr
);
21387 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
21388 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
21391 draw_quad(&test_context
);
21392 check_texture_uvec4(texture
, &test
->expected_result
);
21395 ID3D11ShaderResourceView_Release(srv
);
21397 ID3D11UnorderedAccessView_Release(uav
);
21398 ID3D11Buffer_Release(buffer
);
21400 ID3D11PixelShader_Release(ps
);
21402 ID3D11RenderTargetView_Release(rtv
);
21403 ID3D11Texture2D_Release(texture
);
21404 release_test_context(&test_context
);
21407 static void test_sampleinfo_instruction(void)
21409 ID3D11Texture2D
*float_rt_texture
, *uint_rt_texture
;
21410 ID3D11RenderTargetView
*float_rtv
, *uint_rtv
, *rtv
;
21411 ID3D11PixelShader
*ps_float
, *ps_uint
, *ps_rt
;
21412 ID3D11Texture2D
*texture
, *readback_texture
;
21413 struct d3d11_test_context test_context
;
21414 unsigned int sample_count
, quality
;
21415 D3D11_TEXTURE2D_DESC texture_desc
;
21416 ID3D11RenderTargetView
*rtvs
[2];
21417 ID3D11ShaderResourceView
*srv
;
21418 ID3D11DeviceContext
*context
;
21419 struct uvec4 expected_uint
;
21420 struct vec4 expected_float
;
21421 ID3D11Device
*device
;
21424 static const DWORD ps_uint_code
[] =
21427 Texture2DMS
<float> t
;
21429 uint4
main() : SV_Target1
21431 uint width
, height
, sample_count
;
21432 t
.GetDimensions(width
, height
, sample_count
);
21433 return sample_count
;
21436 0x43425844, 0x4342ad12, 0x19addd8c, 0x5cb87c48, 0xe604a242, 0x00000001, 0x000000d4, 0x00000003,
21437 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
21438 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000001, 0x00000000, 0x00000001, 0x00000001,
21439 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000005c, 0x00000050, 0x00000017,
21440 0x0100086a, 0x04002058, 0x00107000, 0x00000000, 0x00005555, 0x03000065, 0x001020f2, 0x00000001,
21441 0x02000068, 0x00000001, 0x0500086f, 0x00100012, 0x00000000, 0x0010700a, 0x00000000, 0x05000036,
21442 0x001020f2, 0x00000001, 0x00100006, 0x00000000, 0x0100003e,
21444 static const DWORD ps_float_code
[] =
21447 Texture2DMS
<float> t
;
21449 float4
main() : SV_Target
21451 uint width
, height
, sample_count
;
21452 t
.GetDimensions(width
, height
, sample_count
);
21453 return sample_count
;
21456 0x43425844, 0x2b8aea46, 0x34ceda6f, 0xf98d222b, 0x235ebc0b, 0x00000001, 0x000000b8, 0x00000003,
21457 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
21458 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
21459 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000040, 0x00000050, 0x00000010,
21460 0x0100086a, 0x04002058, 0x00107000, 0x00000000, 0x00005555, 0x03000065, 0x001020f2, 0x00000000,
21461 0x0500006f, 0x001020f2, 0x00000000, 0x0010700a, 0x00000000, 0x0100003e,
21463 static const DWORD ps_rt_code
[] =
21466 float4
main() : SV_Target
21468 return GetRenderTargetSampleCount();
21471 0x43425844, 0x74404d37, 0xad6f88e4, 0xb006ea57, 0xf07d9e2a, 0x00000001, 0x000000a4, 0x00000003,
21472 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
21473 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
21474 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000002c, 0x00000050, 0x0000000b,
21475 0x0100086a, 0x03000065, 0x001020f2, 0x00000000, 0x0400006f, 0x001020f2, 0x00000000, 0x0000e00a,
21478 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
21480 if (!init_test_context(&test_context
, &feature_level
))
21483 device
= test_context
.device
;
21484 context
= test_context
.immediate_context
;
21486 texture_desc
.Width
= 64;
21487 texture_desc
.Height
= 64;
21488 texture_desc
.MipLevels
= 1;
21489 texture_desc
.ArraySize
= 1;
21490 texture_desc
.SampleDesc
.Count
= 1;
21491 texture_desc
.SampleDesc
.Quality
= 0;
21492 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
21493 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
21494 texture_desc
.CPUAccessFlags
= 0;
21495 texture_desc
.MiscFlags
= 0;
21497 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
21498 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &float_rt_texture
);
21499 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
21500 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)float_rt_texture
, NULL
, &float_rtv
);
21501 ok(hr
== S_OK
, "Failed to create rendertarget view, hr %#x.\n", hr
);
21502 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_UINT
;
21503 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &uint_rt_texture
);
21504 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
21505 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)uint_rt_texture
, NULL
, &uint_rtv
);
21506 ok(hr
== S_OK
, "Failed to create rendertarget view, hr %#x.\n", hr
);
21508 rtvs
[0] = float_rtv
;
21509 rtvs
[1] = uint_rtv
;
21510 ID3D11DeviceContext_OMSetRenderTargets(context
, ARRAY_SIZE(rtvs
), rtvs
, NULL
);
21512 hr
= ID3D11Device_CreatePixelShader(device
, ps_float_code
, sizeof(ps_float_code
), NULL
, &ps_float
);
21513 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
21514 hr
= ID3D11Device_CreatePixelShader(device
, ps_uint_code
, sizeof(ps_uint_code
), NULL
, &ps_uint
);
21515 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
21517 for (sample_count
= 2; sample_count
<= 8; sample_count
*= 2)
21519 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
21520 texture_desc
.SampleDesc
.Count
= sample_count
;
21521 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
| D3D11_BIND_RENDER_TARGET
;
21523 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, texture_desc
.Format
, sample_count
, &quality
);
21524 ok(hr
== S_OK
, "Failed to check multisample quality levels, hr %#x.\n", hr
);
21527 skip("Sample count %u not supported.\n", sample_count
);
21531 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
21532 ok(hr
== S_OK
, "Failed to create texture, hr %#x, sample count %u.\n", hr
, sample_count
);
21533 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
21534 ok(hr
== S_OK
, "Failed to create shader resource view, hr %#x.\n", hr
);
21535 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
21537 ID3D11DeviceContext_PSSetShader(context
, ps_float
, NULL
, 0);
21538 draw_quad(&test_context
);
21539 ID3D11DeviceContext_PSSetShader(context
, ps_uint
, NULL
, 0);
21540 draw_quad(&test_context
);
21542 expected_float
.x
= expected_float
.y
= expected_float
.z
= expected_float
.w
= sample_count
;
21543 check_texture_vec4(float_rt_texture
, &expected_float
, 0);
21544 expected_uint
.x
= expected_uint
.y
= expected_uint
.z
= expected_uint
.w
= sample_count
;
21545 check_texture_uvec4(uint_rt_texture
, &expected_uint
);
21547 ID3D11Texture2D_Release(texture
);
21548 ID3D11ShaderResourceView_Release(srv
);
21551 hr
= ID3D11Device_CreatePixelShader(device
, ps_rt_code
, sizeof(ps_rt_code
), NULL
, &ps_rt
);
21552 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
21553 for (sample_count
= 1; sample_count
<= 8; sample_count
*= 2)
21555 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
21556 texture_desc
.SampleDesc
.Count
= sample_count
;
21557 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
21559 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, texture_desc
.Format
, sample_count
, &quality
);
21560 ok(hr
== S_OK
, "Failed to check multisample quality levels, hr %#x.\n", hr
);
21563 skip("Sample count %u not supported.\n", sample_count
);
21567 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
21568 ok(hr
== S_OK
, "Failed to create texture, hr %#x, sample count %u.\n", hr
, sample_count
);
21569 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
21570 ok(hr
== S_OK
, "Failed to create render target view, hr %#x.\n", hr
);
21571 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
21573 /* Some drivers (AMD Radeon HD 6310) return stale sample counts if we
21574 * don't rebind the pixel shader between runs with different sample
21576 ID3D11DeviceContext_PSSetShader(context
, NULL
, NULL
, 0);
21577 ID3D11DeviceContext_PSSetShader(context
, ps_rt
, NULL
, 0);
21578 draw_quad(&test_context
);
21580 if (sample_count
!= 1)
21582 texture_desc
.SampleDesc
.Count
= 1;
21583 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &readback_texture
);
21584 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
21585 ID3D11DeviceContext_ResolveSubresource(context
, (ID3D11Resource
*)readback_texture
, 0,
21586 (ID3D11Resource
*)texture
, 0, texture_desc
.Format
);
21590 readback_texture
= texture
;
21591 ID3D11Texture2D_AddRef(readback_texture
);
21594 expected_float
.x
= expected_float
.y
= expected_float
.z
= expected_float
.w
= sample_count
;
21595 check_texture_vec4(readback_texture
, &expected_float
, 0);
21597 ID3D11Texture2D_Release(readback_texture
);
21598 ID3D11Texture2D_Release(texture
);
21599 ID3D11RenderTargetView_Release(rtv
);
21602 ID3D11RenderTargetView_Release(float_rtv
);
21603 ID3D11RenderTargetView_Release(uint_rtv
);
21604 ID3D11Texture2D_Release(float_rt_texture
);
21605 ID3D11Texture2D_Release(uint_rt_texture
);
21606 ID3D11PixelShader_Release(ps_float
);
21607 ID3D11PixelShader_Release(ps_uint
);
21608 ID3D11PixelShader_Release(ps_rt
);
21609 release_test_context(&test_context
);
21612 static void test_render_target_device_mismatch(void)
21614 struct d3d11_test_context test_context
;
21615 struct device_desc device_desc
= {0};
21616 ID3D11DeviceContext
*context
;
21617 ID3D11RenderTargetView
*rtv
;
21618 ID3D11Device
*device
;
21621 if (!init_test_context(&test_context
, NULL
))
21624 device
= create_device(&device_desc
);
21625 ok(!!device
, "Failed to create device.\n");
21627 ID3D11Device_GetImmediateContext(device
, &context
);
21629 rtv
= (ID3D11RenderTargetView
*)0xdeadbeef;
21630 ID3D11DeviceContext_OMGetRenderTargets(context
, 1, &rtv
, NULL
);
21631 ok(!rtv
, "Got unexpected render target view %p.\n", rtv
);
21632 if (!enable_debug_layer
)
21634 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &test_context
.backbuffer_rtv
, NULL
);
21635 ID3D11DeviceContext_OMGetRenderTargets(context
, 1, &rtv
, NULL
);
21636 ok(rtv
== test_context
.backbuffer_rtv
, "Got unexpected render target view %p.\n", rtv
);
21637 ID3D11RenderTargetView_Release(rtv
);
21641 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
21643 ID3D11DeviceContext_Release(context
);
21644 refcount
= ID3D11Device_Release(device
);
21645 ok(!refcount
, "Device has %u references left.\n", refcount
);
21646 release_test_context(&test_context
);
21649 static void test_buffer_srv(void)
21655 BOOL requires_raw_and_structured_buffers
;
21659 unsigned int byte_count
;
21660 unsigned int data_offset
;
21662 unsigned int structure_byte_stride
;
21665 BOOL raw_and_structured_buffers_supported
;
21666 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
21667 struct d3d11_test_context test_context
;
21668 D3D11_SUBRESOURCE_DATA resource_data
;
21669 const struct buffer
*current_buffer
;
21670 const struct shader
*current_shader
;
21671 ID3D11ShaderResourceView
*srv
;
21672 D3D11_BUFFER_DESC buffer_desc
;
21673 ID3D11DeviceContext
*context
;
21674 DWORD color
, expected_color
;
21675 struct resource_readback rb
;
21676 ID3D11Buffer
*cb
, *buffer
;
21677 ID3D11PixelShader
*ps
;
21678 ID3D11Device
*device
;
21679 unsigned int i
, x
, y
;
21680 struct vec4 cb_size
;
21683 static const DWORD ps_float4_code
[] =
21690 float4
main(float4 position
: SV_POSITION
) : SV_Target
21694 p
.x
= position
.x
/ 640.0f
;
21695 p
.y
= position
.y
/ 480.0f
;
21696 coords
= int2(p
.x
* size
.x
, p
.y
* size
.y
);
21697 return b
.Load(coords
.y
* size
.x
+ coords
.x
);
21700 0x43425844, 0xf10ea650, 0x311f5c38, 0x3a888b7f, 0x58230334, 0x00000001, 0x000001a0, 0x00000003,
21701 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
21702 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
21703 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
21704 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000104, 0x00000040,
21705 0x00000041, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04000858, 0x00107000, 0x00000000,
21706 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
21707 0x02000068, 0x00000001, 0x08000038, 0x00100032, 0x00000000, 0x00101516, 0x00000000, 0x00208516,
21708 0x00000000, 0x00000000, 0x0a000038, 0x00100032, 0x00000000, 0x00100046, 0x00000000, 0x00004002,
21709 0x3b088889, 0x3acccccd, 0x00000000, 0x00000000, 0x05000043, 0x00100032, 0x00000000, 0x00100046,
21710 0x00000000, 0x0a000032, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x0020800a, 0x00000000,
21711 0x00000000, 0x0010001a, 0x00000000, 0x0500001b, 0x00100012, 0x00000000, 0x0010000a, 0x00000000,
21712 0x0700002d, 0x001020f2, 0x00000000, 0x00100006, 0x00000000, 0x00107e46, 0x00000000, 0x0100003e,
21714 static const struct shader ps_float4
= {ps_float4_code
, sizeof(ps_float4_code
)};
21715 static const DWORD ps_structured_code
[] =
21718 StructuredBuffer
<float4
> b
;
21722 float4
main(float4 position
: SV_POSITION
) : SV_Target
21726 p
.x
= position
.x
/ 640.0f
;
21727 p
.y
= position
.y
/ 480.0f
;
21728 coords
= int2(p
.x
* size
.x
, p
.y
* size
.y
);
21729 return b
[coords
.y
* size
.x
+ coords
.x
];
21732 0x43425844, 0x246caabb, 0xf1e7d6b9, 0xcbe720dc, 0xcdc23036, 0x00000001, 0x000001c0, 0x00000004,
21733 0x00000030, 0x00000064, 0x00000098, 0x000001b0, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008,
21734 0x00000020, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f,
21735 0x004e4f49, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
21736 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000110,
21737 0x00000040, 0x00000044, 0x0100486a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x040000a2,
21738 0x00107000, 0x00000000, 0x00000010, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065,
21739 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x08000038, 0x00100032, 0x00000000, 0x00101516,
21740 0x00000000, 0x00208516, 0x00000000, 0x00000000, 0x0a000038, 0x00100032, 0x00000000, 0x00100046,
21741 0x00000000, 0x00004002, 0x3b088889, 0x3acccccd, 0x00000000, 0x00000000, 0x05000043, 0x00100032,
21742 0x00000000, 0x00100046, 0x00000000, 0x0a000032, 0x00100012, 0x00000000, 0x0010000a, 0x00000000,
21743 0x0020800a, 0x00000000, 0x00000000, 0x0010001a, 0x00000000, 0x0500001c, 0x00100012, 0x00000000,
21744 0x0010000a, 0x00000000, 0x090000a7, 0x001020f2, 0x00000000, 0x0010000a, 0x00000000, 0x00004001,
21745 0x00000000, 0x00107e46, 0x00000000, 0x0100003e, 0x30494653, 0x00000008, 0x00000002, 0x00000000,
21747 static const struct shader ps_structured
= {ps_structured_code
, sizeof(ps_structured_code
), TRUE
};
21748 static const DWORD rgba16
[] =
21750 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
21751 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
21752 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
21753 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
21755 static const DWORD rgba4
[] =
21757 0xffffffff, 0xff0000ff,
21758 0xff000000, 0xff00ff00,
21760 static const BYTE r4
[] =
21765 static const struct vec4 rgba_float
[] =
21767 {1.0f
, 1.0f
, 1.0f
, 1.0f
}, {1.0f
, 0.0f
, 0.0f
, 1.0f
},
21768 {0.0f
, 0.0f
, 0.0f
, 1.0f
}, {0.0f
, 1.0f
, 0.0f
, 1.0f
},
21770 static const struct buffer rgba16_buffer
= {sizeof(rgba16
), 0, &rgba16
};
21771 static const struct buffer rgba16_offset_buffer
= {256 + sizeof(rgba16
), 256, &rgba16
};
21772 static const struct buffer rgba4_buffer
= {sizeof(rgba4
), 0, &rgba4
};
21773 static const struct buffer r4_buffer
= {sizeof(r4
), 0, &r4
};
21774 static const struct buffer r4_offset_buffer
= {256 + sizeof(r4
), 256, &r4
};
21775 static const struct buffer float_buffer
= {sizeof(rgba_float
), 0, &rgba_float
, sizeof(*rgba_float
)};
21776 static const struct buffer float_offset_buffer
= {256 + sizeof(rgba_float
), 256,
21777 &rgba_float
, sizeof(*rgba_float
)};
21778 static const DWORD rgba16_colors2x2
[] =
21780 0xff0000ff, 0xff0000ff, 0xff00ffff, 0xff00ffff,
21781 0xff0000ff, 0xff0000ff, 0xff00ffff, 0xff00ffff,
21782 0xff00ff00, 0xff00ff00, 0xffffff00, 0xffffff00,
21783 0xff00ff00, 0xff00ff00, 0xffffff00, 0xffffff00,
21785 static const DWORD rgba16_colors1x1
[] =
21787 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff,
21788 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff,
21789 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff,
21790 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff,
21792 static const DWORD rgba4_colors
[] =
21794 0xffffffff, 0xffffffff, 0xff0000ff, 0xff0000ff,
21795 0xffffffff, 0xffffffff, 0xff0000ff, 0xff0000ff,
21796 0xff000000, 0xff000000, 0xff00ff00, 0xff00ff00,
21797 0xff000000, 0xff000000, 0xff00ff00, 0xff00ff00,
21799 static const DWORD r4_colors
[] =
21801 0xff0000de, 0xff0000de, 0xff0000ad, 0xff0000ad,
21802 0xff0000de, 0xff0000de, 0xff0000ad, 0xff0000ad,
21803 0xff0000ba, 0xff0000ba, 0xff0000be, 0xff0000be,
21804 0xff0000ba, 0xff0000ba, 0xff0000be, 0xff0000be,
21806 static const DWORD zero_colors
[16] = {0};
21807 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
21809 static const struct test
21811 const struct shader
*shader
;
21812 const struct buffer
*buffer
;
21813 DXGI_FORMAT srv_format
;
21814 unsigned int srv_first_element
;
21815 unsigned int srv_element_count
;
21817 const DWORD
*expected_colors
;
21821 {&ps_float4
, &rgba16_buffer
, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, 16, {4.0f
, 4.0f
}, rgba16
},
21822 {&ps_float4
, &rgba16_offset_buffer
, DXGI_FORMAT_R8G8B8A8_UNORM
, 64, 16, {4.0f
, 4.0f
}, rgba16
},
21823 {&ps_float4
, &rgba16_buffer
, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, 4, {2.0f
, 2.0f
}, rgba16_colors2x2
},
21824 {&ps_float4
, &rgba16_buffer
, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, 1, {1.0f
, 1.0f
}, rgba16_colors1x1
},
21825 {&ps_float4
, &rgba4_buffer
, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, 4, {2.0f
, 2.0f
}, rgba4_colors
},
21826 {&ps_float4
, &r4_buffer
, DXGI_FORMAT_R8_UNORM
, 0, 4, {2.0f
, 2.0f
}, r4_colors
},
21827 {&ps_float4
, &r4_offset_buffer
, DXGI_FORMAT_R8_UNORM
, 256, 4, {2.0f
, 2.0f
}, r4_colors
},
21828 {&ps_structured
, &float_buffer
, DXGI_FORMAT_UNKNOWN
, 0, 4, {2.0f
, 2.0f
}, rgba4_colors
},
21829 {&ps_structured
, &float_offset_buffer
, DXGI_FORMAT_UNKNOWN
, 16, 4, {2.0f
, 2.0f
}, rgba4_colors
},
21830 {&ps_float4
, NULL
, 0, 0, 0, {2.0f
, 2.0f
}, zero_colors
},
21831 {&ps_float4
, NULL
, 0, 0, 0, {1.0f
, 1.0f
}, zero_colors
},
21834 if (!init_test_context(&test_context
, NULL
))
21837 device
= test_context
.device
;
21838 context
= test_context
.immediate_context
;
21839 raw_and_structured_buffers_supported
= ID3D11Device_GetFeatureLevel(device
) >= D3D_FEATURE_LEVEL_11_0
21840 || check_compute_shaders_via_sm4_support(device
);
21842 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(cb_size
), NULL
);
21843 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
21845 buffer_desc
.ByteWidth
= 256;
21846 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
21847 buffer_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
21848 buffer_desc
.CPUAccessFlags
= 0;
21849 buffer_desc
.MiscFlags
= 0;
21850 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
21851 ok(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
21852 srv_desc
.Format
= DXGI_FORMAT_R8_UNORM
;
21853 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_BUFFER
;
21854 U(srv_desc
).Buffer
.FirstElement
= 0;
21855 U(srv_desc
).Buffer
.NumElements
= 0;
21856 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)buffer
, &srv_desc
, &srv
);
21857 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
21858 ID3D11Buffer_Release(buffer
);
21863 current_shader
= NULL
;
21864 current_buffer
= NULL
;
21865 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
21867 const struct test
*test
= &tests
[i
];
21869 if (test
->shader
->requires_raw_and_structured_buffers
&& !raw_and_structured_buffers_supported
)
21871 skip("Test %u: Raw and structured buffers are not supported.\n", i
);
21874 /* Structured buffer views with an offset don't seem to work on WARP. */
21875 if (test
->srv_format
== DXGI_FORMAT_UNKNOWN
&& test
->srv_first_element
21876 && is_warp_device(device
))
21878 skip("Test %u: Broken WARP.\n", i
);
21882 if (current_shader
!= test
->shader
)
21885 ID3D11PixelShader_Release(ps
);
21887 current_shader
= test
->shader
;
21889 hr
= ID3D11Device_CreatePixelShader(device
, current_shader
->code
, current_shader
->size
, NULL
, &ps
);
21890 ok(SUCCEEDED(hr
), "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
21891 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
21894 if (current_buffer
!= test
->buffer
)
21897 ID3D11Buffer_Release(buffer
);
21899 current_buffer
= test
->buffer
;
21900 if (current_buffer
)
21904 buffer_desc
.ByteWidth
= current_buffer
->byte_count
;
21905 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
21906 buffer_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
21907 buffer_desc
.CPUAccessFlags
= 0;
21908 buffer_desc
.MiscFlags
= 0;
21909 if ((buffer_desc
.StructureByteStride
= current_buffer
->structure_byte_stride
))
21910 buffer_desc
.MiscFlags
|= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
;
21911 resource_data
.SysMemPitch
= 0;
21912 resource_data
.SysMemSlicePitch
= 0;
21913 if (current_buffer
->data_offset
)
21915 data
= heap_alloc_zero(current_buffer
->byte_count
);
21916 ok(!!data
, "Failed to allocate memory.\n");
21917 memcpy(data
+ current_buffer
->data_offset
, current_buffer
->data
,
21918 current_buffer
->byte_count
- current_buffer
->data_offset
);
21919 resource_data
.pSysMem
= data
;
21923 resource_data
.pSysMem
= current_buffer
->data
;
21925 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &resource_data
, &buffer
);
21926 ok(SUCCEEDED(hr
), "Test %u: Failed to create buffer, hr %#x.\n", i
, hr
);
21936 ID3D11ShaderResourceView_Release(srv
);
21937 if (current_buffer
)
21939 srv_desc
.Format
= test
->srv_format
;
21940 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_BUFFER
;
21941 U(srv_desc
).Buffer
.FirstElement
= test
->srv_first_element
;
21942 U(srv_desc
).Buffer
.NumElements
= test
->srv_element_count
;
21943 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)buffer
, &srv_desc
, &srv
);
21944 ok(SUCCEEDED(hr
), "Test %u: Failed to create shader resource view, hr %#x.\n", i
, hr
);
21950 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
21952 cb_size
.x
= test
->size
.x
;
21953 cb_size
.y
= test
->size
.y
;
21954 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &cb_size
, 0, 0);
21956 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
21957 draw_quad(&test_context
);
21959 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
21960 for (y
= 0; y
< 4; ++y
)
21962 for (x
= 0; x
< 4; ++x
)
21964 color
= get_readback_color(&rb
, 80 + x
* 160, 60 + y
* 120, 0);
21965 expected_color
= test
->expected_colors
[y
* 4 + x
];
21966 ok(compare_color(color
, expected_color
, 1),
21967 "Test %u: Got 0x%08x, expected 0x%08x at (%u, %u).\n",
21968 i
, color
, expected_color
, x
, y
);
21971 release_resource_readback(&rb
);
21974 ID3D11ShaderResourceView_Release(srv
);
21976 ID3D11Buffer_Release(buffer
);
21978 ID3D11Buffer_Release(cb
);
21979 ID3D11PixelShader_Release(ps
);
21980 release_test_context(&test_context
);
21983 static void test_unaligned_raw_buffer_access(const D3D_FEATURE_LEVEL feature_level
)
21985 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
21986 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
21987 struct d3d11_test_context test_context
;
21988 D3D11_SUBRESOURCE_DATA resource_data
;
21989 D3D11_TEXTURE2D_DESC texture_desc
;
21990 ID3D11UnorderedAccessView
*uav
;
21991 ID3D11ShaderResourceView
*srv
;
21992 D3D11_BUFFER_DESC buffer_desc
;
21993 ID3D11Buffer
*cb
, *raw_buffer
;
21994 ID3D11DeviceContext
*context
;
21995 struct resource_readback rb
;
21996 ID3D11RenderTargetView
*rtv
;
21997 ID3D11Texture2D
*texture
;
21998 ID3D11ComputeShader
*cs
;
21999 ID3D11PixelShader
*ps
;
22000 ID3D11Device
*device
;
22001 unsigned int i
, data
;
22002 struct uvec4 offset
;
22005 static const unsigned int buffer_data
[] =
22007 0xffffffff, 0x00000000,
22009 static const DWORD ps_code
[] =
22012 ByteAddressBuffer buffer
;
22016 uint
main() : SV_Target0
22018 return buffer
.Load(offset
);
22021 0x43425844, 0xda171175, 0xb001721f, 0x60ef80eb, 0xe1fa7e75, 0x00000001, 0x000000e4, 0x00000004,
22022 0x00000030, 0x00000040, 0x00000074, 0x000000d4, 0x4e475349, 0x00000008, 0x00000000, 0x00000008,
22023 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001,
22024 0x00000000, 0x00000e01, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000058, 0x00000040,
22025 0x00000016, 0x0100486a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x030000a1, 0x00107000,
22026 0x00000000, 0x03000065, 0x00102012, 0x00000000, 0x080000a5, 0x00102012, 0x00000000, 0x0020800a,
22027 0x00000000, 0x00000000, 0x00107006, 0x00000000, 0x0100003e, 0x30494653, 0x00000008, 0x00000002,
22030 static const DWORD cs_code
[] =
22033 RWByteAddressBuffer buffer
;
22037 [numthreads(1, 1, 1)]
22040 buffer
.Store(input
.x
, input
.y
);
22043 0x43425844, 0x3c7103b0, 0xe6313979, 0xbcfb0c11, 0x3958af0c, 0x00000001, 0x000000b4, 0x00000003,
22044 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22045 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000060, 0x00050050, 0x00000018, 0x0100086a,
22046 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300009d, 0x0011e000, 0x00000000, 0x0400009b,
22047 0x00000001, 0x00000001, 0x00000001, 0x090000a6, 0x0011e012, 0x00000000, 0x0020800a, 0x00000000,
22048 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0100003e,
22050 static const float black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
22052 if (!init_test_context(&test_context
, &feature_level
))
22055 device
= test_context
.device
;
22056 context
= test_context
.immediate_context
;
22058 if (feature_level
< D3D_FEATURE_LEVEL_11_0
&& !check_compute_shaders_via_sm4_support(device
))
22060 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
22061 todo_wine
ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
22063 ID3D11PixelShader_Release(ps
);
22064 skip("Raw buffers are not supported.\n");
22065 release_test_context(&test_context
);
22069 if (is_intel_device(device
))
22071 /* Offsets for raw buffer reads and writes should be 4 bytes aligned.
22072 * This test checks what happens when offsets are not properly aligned.
22073 * The behavior seems to be undefined on Intel hardware. */
22074 win_skip("Skipping the test on Intel hardware.\n");
22075 release_test_context(&test_context
);
22079 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
22080 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
22082 memset(&offset
, 0, sizeof(offset
));
22083 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(offset
), &offset
.x
);
22085 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
22086 texture_desc
.Format
= DXGI_FORMAT_R32_UINT
;
22087 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
22088 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
22089 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
22090 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
22092 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
22094 buffer_desc
.ByteWidth
= sizeof(buffer_data
);
22095 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
22096 buffer_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
22097 buffer_desc
.CPUAccessFlags
= 0;
22098 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
;
22099 resource_data
.pSysMem
= buffer_data
;
22100 resource_data
.SysMemPitch
= 0;
22101 resource_data
.SysMemSlicePitch
= 0;
22102 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &resource_data
, &raw_buffer
);
22103 ok(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
22105 srv_desc
.Format
= DXGI_FORMAT_R32_TYPELESS
;
22106 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_BUFFEREX
;
22107 U(srv_desc
).BufferEx
.FirstElement
= 0;
22108 U(srv_desc
).BufferEx
.NumElements
= buffer_desc
.ByteWidth
/ sizeof(unsigned int);
22109 U(srv_desc
).BufferEx
.Flags
= D3D11_BUFFEREX_SRV_FLAG_RAW
;
22110 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)raw_buffer
, &srv_desc
, &srv
);
22111 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
22113 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
22114 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
22115 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
22118 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
22119 NULL
, &offset
, 0, 0);
22120 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, black
);
22121 draw_quad(&test_context
);
22122 check_texture_color(texture
, buffer_data
[0], 0);
22124 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
22125 NULL
, &offset
, 0, 0);
22126 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, black
);
22127 draw_quad(&test_context
);
22128 check_texture_color(texture
, buffer_data
[0], 0);
22130 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
22131 NULL
, &offset
, 0, 0);
22132 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, black
);
22133 draw_quad(&test_context
);
22134 check_texture_color(texture
, buffer_data
[0], 0);
22136 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
22137 NULL
, &offset
, 0, 0);
22138 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, black
);
22139 draw_quad(&test_context
);
22140 check_texture_color(texture
, buffer_data
[0], 0);
22143 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
22144 NULL
, &offset
, 0, 0);
22145 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, black
);
22146 draw_quad(&test_context
);
22147 check_texture_color(texture
, buffer_data
[1], 0);
22149 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
22150 NULL
, &offset
, 0, 0);
22151 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, black
);
22152 draw_quad(&test_context
);
22153 check_texture_color(texture
, buffer_data
[1], 0);
22155 if (feature_level
< D3D_FEATURE_LEVEL_11_0
)
22157 skip("Feature level 11_0 required for unaligned UAV test.\n");
22161 ID3D11Buffer_Release(raw_buffer
);
22162 buffer_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
22163 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &raw_buffer
);
22164 ok(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
22166 uav_desc
.Format
= DXGI_FORMAT_R32_TYPELESS
;
22167 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
22168 U(uav_desc
).Buffer
.FirstElement
= 0;
22169 U(uav_desc
).Buffer
.NumElements
= buffer_desc
.ByteWidth
/ sizeof(unsigned int);
22170 U(uav_desc
).Buffer
.Flags
= D3D11_BUFFER_UAV_FLAG_RAW
;
22171 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)raw_buffer
, &uav_desc
, &uav
);
22172 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
22174 hr
= ID3D11Device_CreateComputeShader(device
, cs_code
, sizeof(cs_code
), NULL
, &cs
);
22175 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
22177 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
22178 ID3D11DeviceContext_CSSetConstantBuffers(context
, 0, 1, &cb
);
22179 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
22182 offset
.y
= 0xffffffff;
22183 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
22184 NULL
, &offset
, 0, 0);
22185 ID3D11DeviceContext_ClearUnorderedAccessViewFloat(context
, uav
, black
);
22186 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
22187 get_buffer_readback(raw_buffer
, &rb
);
22188 for (i
= 0; i
< ARRAY_SIZE(buffer_data
); ++i
)
22190 data
= get_readback_color(&rb
, i
, 0, 0);
22191 ok(data
== buffer_data
[i
], "Got unexpected result %#x at %u.\n", data
, i
);
22193 release_resource_readback(&rb
);
22196 offset
.y
= 0xffffffff;
22197 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
22198 NULL
, &offset
, 0, 0);
22199 ID3D11DeviceContext_ClearUnorderedAccessViewFloat(context
, uav
, black
);
22200 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
22201 get_buffer_readback(raw_buffer
, &rb
);
22202 for (i
= 0; i
< ARRAY_SIZE(buffer_data
); ++i
)
22204 data
= get_readback_color(&rb
, i
, 0, 0);
22205 ok(data
== buffer_data
[i
], "Got unexpected result %#x at %u.\n", data
, i
);
22207 release_resource_readback(&rb
);
22210 offset
.y
= 0xffffffff;
22211 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
22212 NULL
, &offset
, 0, 0);
22213 ID3D11DeviceContext_ClearUnorderedAccessViewFloat(context
, uav
, black
);
22214 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
22215 get_buffer_readback(raw_buffer
, &rb
);
22216 for (i
= 0; i
< ARRAY_SIZE(buffer_data
); ++i
)
22218 data
= get_readback_color(&rb
, i
, 0, 0);
22219 ok(data
== buffer_data
[i
], "Got unexpected result %#x at %u.\n", data
, i
);
22221 release_resource_readback(&rb
);
22224 offset
.y
= 0xffffffff;
22225 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
22226 NULL
, &offset
, 0, 0);
22227 ID3D11DeviceContext_ClearUnorderedAccessViewFloat(context
, uav
, black
);
22228 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
22229 get_buffer_readback(raw_buffer
, &rb
);
22230 for (i
= 0; i
< ARRAY_SIZE(buffer_data
); ++i
)
22232 data
= get_readback_color(&rb
, i
, 0, 0);
22233 ok(data
== buffer_data
[i
], "Got unexpected result %#x at %u.\n", data
, i
);
22235 release_resource_readback(&rb
);
22237 ID3D11DeviceContext_ClearUnorderedAccessViewFloat(context
, uav
, black
);
22240 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
22241 NULL
, &offset
, 0, 0);
22242 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
22245 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
22246 NULL
, &offset
, 0, 0);
22247 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
22248 get_buffer_readback(raw_buffer
, &rb
);
22249 data
= get_readback_color(&rb
, 0, 0, 0);
22250 ok(data
== 0xffff, "Got unexpected result %#x.\n", data
);
22251 data
= get_readback_color(&rb
, 1, 0, 0);
22252 ok(data
== 0xa, "Got unexpected result %#x.\n", data
);
22253 release_resource_readback(&rb
);
22255 ID3D11ComputeShader_Release(cs
);
22256 ID3D11UnorderedAccessView_Release(uav
);
22259 ID3D11Buffer_Release(cb
);
22260 ID3D11Buffer_Release(raw_buffer
);
22261 ID3D11PixelShader_Release(ps
);
22262 ID3D11RenderTargetView_Release(rtv
);
22263 ID3D11ShaderResourceView_Release(srv
);
22264 ID3D11Texture2D_Release(texture
);
22265 release_test_context(&test_context
);
22268 static unsigned int read_uav_counter(ID3D11DeviceContext
*context
,
22269 ID3D11Buffer
*staging_buffer
, ID3D11UnorderedAccessView
*uav
)
22271 D3D11_MAPPED_SUBRESOURCE map_desc
;
22272 unsigned int counter
;
22274 ID3D11DeviceContext_CopyStructureCount(context
, staging_buffer
, 0, uav
);
22276 if (FAILED(ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)staging_buffer
, 0,
22277 D3D11_MAP_READ
, 0, &map_desc
)))
22279 counter
= *(unsigned int *)map_desc
.pData
;
22280 ID3D11DeviceContext_Unmap(context
, (ID3D11Resource
*)staging_buffer
, 0);
22284 static int compare_id(const void *a
, const void *b
)
22286 return *(int *)a
- *(int *)b
;
22289 static void test_uav_counters(void)
22291 ID3D11Buffer
*buffer
, *buffer2
, *staging_buffer
;
22292 ID3D11ComputeShader
*cs_producer
, *cs_consumer
;
22293 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
22294 struct d3d11_test_context test_context
;
22295 ID3D11UnorderedAccessView
*uav
, *uav2
;
22296 unsigned int data
, id
[128], i
;
22297 D3D11_BUFFER_DESC buffer_desc
;
22298 ID3D11DeviceContext
*context
;
22299 struct resource_readback rb
;
22300 ID3D11Device
*device
;
22304 static const DWORD cs_producer_code
[] =
22307 RWStructuredBuffer
<uint
> u
;
22309 [numthreads(4, 1, 1)]
22310 void main(uint3 dispatch_id
: SV_DispatchThreadID
)
22312 uint counter
= u
.IncrementCounter();
22313 u
[counter
] = dispatch_id
.x
;
22316 0x43425844, 0x013163a8, 0xe7d371b8, 0x4f71e39a, 0xd479e584, 0x00000001, 0x000000c8, 0x00000003,
22317 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22318 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000074, 0x00050050, 0x0000001d, 0x0100086a,
22319 0x0480009e, 0x0011e000, 0x00000000, 0x00000004, 0x0200005f, 0x00020012, 0x02000068, 0x00000001,
22320 0x0400009b, 0x00000004, 0x00000001, 0x00000001, 0x050000b2, 0x00100012, 0x00000000, 0x0011e000,
22321 0x00000000, 0x080000a8, 0x0011e012, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000000,
22322 0x0002000a, 0x0100003e,
22324 static const DWORD cs_consumer_code
[] =
22327 RWStructuredBuffer
<uint
> u
;
22328 RWStructuredBuffer
<uint
> u2
;
22330 [numthreads(4, 1, 1)]
22333 uint counter
= u
.DecrementCounter();
22334 u2
[counter
] = u
[counter
];
22337 0x43425844, 0x957ef3dd, 0x9f317559, 0x09c8f12d, 0xdbfd98c8, 0x00000001, 0x00000100, 0x00000003,
22338 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22339 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x000000ac, 0x00050050, 0x0000002b, 0x0100086a,
22340 0x0480009e, 0x0011e000, 0x00000000, 0x00000004, 0x0400009e, 0x0011e000, 0x00000001, 0x00000004,
22341 0x02000068, 0x00000001, 0x0400009b, 0x00000004, 0x00000001, 0x00000001, 0x050000b3, 0x00100012,
22342 0x00000000, 0x0011e000, 0x00000000, 0x8b0000a7, 0x80002302, 0x00199983, 0x00100022, 0x00000000,
22343 0x0010000a, 0x00000000, 0x00004001, 0x00000000, 0x0011e006, 0x00000000, 0x090000a8, 0x0011e012,
22344 0x00000001, 0x0010000a, 0x00000000, 0x00004001, 0x00000000, 0x0010001a, 0x00000000, 0x0100003e,
22346 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
22348 if (!init_test_context(&test_context
, &feature_level
))
22351 device
= test_context
.device
;
22352 context
= test_context
.immediate_context
;
22354 hr
= ID3D11Device_CreateComputeShader(device
, cs_producer_code
, sizeof(cs_producer_code
), NULL
, &cs_producer
);
22355 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
22356 hr
= ID3D11Device_CreateComputeShader(device
, cs_consumer_code
, sizeof(cs_consumer_code
), NULL
, &cs_consumer
);
22357 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
22359 memset(&buffer_desc
, 0, sizeof(buffer_desc
));
22360 buffer_desc
.ByteWidth
= sizeof(unsigned int);
22361 buffer_desc
.Usage
= D3D11_USAGE_STAGING
;
22362 buffer_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
;
22363 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &staging_buffer
);
22364 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
22366 buffer_desc
.ByteWidth
= 1024;
22367 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
22368 buffer_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
22369 buffer_desc
.CPUAccessFlags
= 0;
22370 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
;
22371 buffer_desc
.StructureByteStride
= sizeof(unsigned int);
22372 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
22373 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
22374 uav_desc
.Format
= DXGI_FORMAT_UNKNOWN
;
22375 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
22376 U(uav_desc
).Buffer
.FirstElement
= 0;
22377 U(uav_desc
).Buffer
.NumElements
= buffer_desc
.ByteWidth
/ sizeof(unsigned int);
22378 U(uav_desc
).Buffer
.Flags
= D3D11_BUFFER_UAV_FLAG_COUNTER
;
22379 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
22380 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
22381 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer2
);
22382 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
22383 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer2
, NULL
, &uav2
);
22384 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
22386 data
= read_uav_counter(context
, staging_buffer
, uav
);
22387 ok(!data
, "Got unexpected initial value %u.\n", data
);
22389 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, &data
);
22390 data
= read_uav_counter(context
, staging_buffer
, uav
);
22391 ok(data
== 8, "Got unexpected value %u.\n", data
);
22393 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, &data
);
22394 data
= read_uav_counter(context
, staging_buffer
, uav
);
22395 ok(data
== 8, "Got unexpected value %u.\n", data
);
22396 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
22397 data
= read_uav_counter(context
, staging_buffer
, uav
);
22398 ok(data
== 8, "Got unexpected value %u.\n", data
);
22400 ID3D11DeviceContext_CSSetShader(context
, cs_producer
, NULL
, 0);
22402 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, &data
);
22403 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 1, 1, &uav2
, NULL
);
22404 data
= read_uav_counter(context
, staging_buffer
, uav
);
22405 ok(!data
, "Got unexpected value %u.\n", data
);
22408 ID3D11DeviceContext_Dispatch(context
, 16, 1, 1);
22409 data
= read_uav_counter(context
, staging_buffer
, uav
);
22410 ok(data
== 64, "Got unexpected value %u.\n", data
);
22411 get_buffer_readback(buffer
, &rb
);
22412 memcpy(id
, rb
.map_desc
.pData
, 64 * sizeof(*id
));
22413 release_resource_readback(&rb
);
22414 qsort(id
, 64, sizeof(*id
), compare_id
);
22415 for (i
= 0; i
< 64; ++i
)
22420 ok(i
== 64, "Got unexpected id %u at %u.\n", id
[i
], i
);
22423 ID3D11DeviceContext_CSSetShader(context
, cs_consumer
, NULL
, 0);
22424 ID3D11DeviceContext_Dispatch(context
, 16, 1, 1);
22425 data
= read_uav_counter(context
, staging_buffer
, uav
);
22426 ok(!data
, "Got unexpected value %u.\n", data
);
22427 get_buffer_readback(buffer2
, &rb
);
22428 memcpy(id
, rb
.map_desc
.pData
, 64 * sizeof(*id
));
22429 release_resource_readback(&rb
);
22430 qsort(id
, 64, sizeof(*id
), compare_id
);
22431 for (i
= 0; i
< 64; ++i
)
22436 ok(i
== 64, "Got unexpected id %u at %u.\n", id
[i
], i
);
22438 /* produce on CPU */
22439 for (i
= 0; i
< 8; ++i
)
22440 id
[i
] = 0xdeadbeef;
22441 set_box(&box
, 0, 0, 0, 8 * sizeof(*id
), 1, 1);
22442 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)buffer
, 0, &box
, id
, 0, 0);
22444 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, &data
);
22445 data
= read_uav_counter(context
, staging_buffer
, uav
);
22446 ok(data
== 8, "Got unexpected value %u.\n", data
);
22449 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
22450 data
= read_uav_counter(context
, staging_buffer
, uav
);
22451 ok(data
== 4, "Got unexpected value %u.\n", data
);
22452 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
22453 data
= read_uav_counter(context
, staging_buffer
, uav
);
22454 ok(!data
, "Got unexpected value %u.\n", data
);
22455 get_buffer_readback(buffer2
, &rb
);
22456 for (i
= 0; i
< 8; ++i
)
22458 data
= get_readback_color(&rb
, i
, 0, 0);
22459 ok(data
== 0xdeadbeef, "Got data %u at %u.\n", data
, i
);
22461 release_resource_readback(&rb
);
22463 ID3D11Buffer_Release(buffer
);
22464 ID3D11Buffer_Release(buffer2
);
22465 ID3D11Buffer_Release(staging_buffer
);
22466 ID3D11ComputeShader_Release(cs_producer
);
22467 ID3D11ComputeShader_Release(cs_consumer
);
22468 ID3D11UnorderedAccessView_Release(uav
);
22469 ID3D11UnorderedAccessView_Release(uav2
);
22470 release_test_context(&test_context
);
22473 static void test_dispatch_indirect(void)
22477 unsigned int dispatch_count
;
22478 unsigned int thread_count
;
22479 unsigned int max_x
;
22480 unsigned int max_y
;
22481 unsigned int max_z
;
22484 ID3D11Buffer
*append_buffer
, *stats_buffer
, *args_buffer
, *staging_buffer
;
22485 ID3D11UnorderedAccessView
*uav
, *stats_uav
;
22486 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
22487 ID3D11ComputeShader
*cs_append
, *cs_stats
;
22488 struct d3d11_test_context test_context
;
22489 D3D11_BUFFER_DESC buffer_desc
;
22490 ID3D11DeviceContext
*context
;
22491 struct resource_readback rb
;
22492 ID3D11Device
*device
;
22493 unsigned int data
, i
;
22494 struct stats
*stats
;
22497 static const DWORD cs_append_code
[] =
22500 struct dispatch_args
22505 AppendStructuredBuffer
<dispatch_args
> u
;
22507 [numthreads(1, 1, 1)]
22510 dispatch_args args
= {4, 2, 1};
22518 0x43425844, 0x954de75a, 0x8bb1b78b, 0x84ded464, 0x9d9532b7, 0x00000001, 0x00000158, 0x00000003,
22519 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22520 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000104, 0x00050050, 0x00000041, 0x0100086a,
22521 0x0400009e, 0x0011e000, 0x00000000, 0x0000000c, 0x02000068, 0x00000001, 0x0400009b, 0x00000001,
22522 0x00000001, 0x00000001, 0x050000b2, 0x00100012, 0x00000000, 0x0011e000, 0x00000000, 0x0c0000a8,
22523 0x0011e072, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000000, 0x00004002, 0x00000004,
22524 0x00000002, 0x00000001, 0x00000000, 0x050000b2, 0x00100012, 0x00000000, 0x0011e000, 0x00000000,
22525 0x0c0000a8, 0x0011e072, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000000, 0x00004002,
22526 0x00000004, 0x00000001, 0x00000001, 0x00000000, 0x050000b2, 0x00100012, 0x00000000, 0x0011e000,
22527 0x00000000, 0x0c0000a8, 0x0011e072, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000000,
22528 0x00004002, 0x00000003, 0x00000001, 0x00000001, 0x00000000, 0x0100003e,
22530 static const DWORD cs_stats_code
[] =
22535 uint dispatch_count
;
22542 RWStructuredBuffer
<stats
> u
;
22544 [numthreads(1, 1, 1)]
22545 void main(uint3 id
: SV_DispatchThreadID
)
22548 InterlockedAdd(u
[0].dispatch_count
, 1);
22549 InterlockedAdd(u
[0].thread_count
, 1);
22550 InterlockedMax(u
[0].max_x
, id
.x
);
22551 InterlockedMax(u
[0].max_y
, id
.y
);
22552 InterlockedMax(u
[0].max_z
, id
.z
);
22555 0x43425844, 0xbd3f2e4e, 0xb0f61ff7, 0xa8e10584, 0x2f61aec9, 0x00000001, 0x000001bc, 0x00000003,
22556 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22557 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000168, 0x00050050, 0x0000005a, 0x0100086a,
22558 0x0400009e, 0x0011e000, 0x00000000, 0x00000014, 0x0200005f, 0x00020072, 0x02000068, 0x00000001,
22559 0x0400009b, 0x00000001, 0x00000001, 0x00000001, 0x09000020, 0x00100072, 0x00000000, 0x00020246,
22560 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07000001, 0x00100012, 0x00000000,
22561 0x0010001a, 0x00000000, 0x0010000a, 0x00000000, 0x07000001, 0x00100012, 0x00000000, 0x0010002a,
22562 0x00000000, 0x0010000a, 0x00000000, 0x0304001f, 0x0010000a, 0x00000000, 0x0a0000ad, 0x0011e000,
22563 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00004001, 0x00000001,
22564 0x01000015, 0x0a0000ad, 0x0011e000, 0x00000000, 0x00004002, 0x00000000, 0x00000004, 0x00000000,
22565 0x00000000, 0x00004001, 0x00000001, 0x090000b0, 0x0011e000, 0x00000000, 0x00004002, 0x00000000,
22566 0x00000008, 0x00000000, 0x00000000, 0x0002000a, 0x090000b0, 0x0011e000, 0x00000000, 0x00004002,
22567 0x00000000, 0x0000000c, 0x00000000, 0x00000000, 0x0002001a, 0x090000b0, 0x0011e000, 0x00000000,
22568 0x00004002, 0x00000000, 0x00000010, 0x00000000, 0x00000000, 0x0002002a, 0x0100003e,
22570 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
22571 static const unsigned int zero
[4] = {0, 0, 0, 0};
22573 if (!init_test_context(&test_context
, &feature_level
))
22576 device
= test_context
.device
;
22577 context
= test_context
.immediate_context
;
22579 hr
= ID3D11Device_CreateComputeShader(device
, cs_append_code
, sizeof(cs_append_code
), NULL
, &cs_append
);
22580 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
22581 hr
= ID3D11Device_CreateComputeShader(device
, cs_stats_code
, sizeof(cs_stats_code
), NULL
, &cs_stats
);
22582 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
22584 memset(&buffer_desc
, 0, sizeof(buffer_desc
));
22585 buffer_desc
.ByteWidth
= sizeof(unsigned int);
22586 buffer_desc
.Usage
= D3D11_USAGE_STAGING
;
22587 buffer_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
;
22588 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &staging_buffer
);
22589 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
22591 buffer_desc
.ByteWidth
= 60;
22592 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
22593 buffer_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
22594 buffer_desc
.CPUAccessFlags
= 0;
22595 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
;
22596 buffer_desc
.StructureByteStride
= 3 * sizeof(unsigned int);
22597 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &append_buffer
);
22598 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
22599 uav_desc
.Format
= DXGI_FORMAT_UNKNOWN
;
22600 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
22601 U(uav_desc
).Buffer
.FirstElement
= 0;
22602 U(uav_desc
).Buffer
.NumElements
= 5;
22603 U(uav_desc
).Buffer
.Flags
= D3D11_BUFFER_UAV_FLAG_APPEND
;
22604 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)append_buffer
, &uav_desc
, &uav
);
22605 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
22607 /* We use a separate buffer because D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS
22608 * and D3D11_RESOURCE_MISC_BUFFER_STRUCTURED are mutually exclusive flags.
22610 buffer_desc
.BindFlags
= 0;
22611 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS
;
22612 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &args_buffer
);
22613 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
22615 buffer_desc
.ByteWidth
= sizeof(*stats
);
22616 buffer_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
22617 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
;
22618 buffer_desc
.StructureByteStride
= sizeof(*stats
);
22619 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &stats_buffer
);
22620 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
22621 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)stats_buffer
, NULL
, &stats_uav
);
22622 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
22624 data
= read_uav_counter(context
, staging_buffer
, uav
);
22625 ok(!data
, "Got unexpected initial value %u.\n", data
);
22627 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, &data
);
22628 data
= read_uav_counter(context
, staging_buffer
, uav
);
22629 ok(data
== 8, "Got unexpected value %u.\n", data
);
22631 ID3D11DeviceContext_CSSetShader(context
, cs_append
, NULL
, 0);
22633 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, &data
);
22634 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
22635 data
= read_uav_counter(context
, staging_buffer
, uav
);
22636 ok(data
== 3, "Got unexpected value %u.\n", data
);
22637 ID3D11DeviceContext_CopyResource(context
, (ID3D11Resource
*)args_buffer
, (ID3D11Resource
*)append_buffer
);
22639 ID3D11DeviceContext_CSSetShader(context
, cs_stats
, NULL
, 0);
22640 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, stats_uav
, zero
);
22641 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &stats_uav
, NULL
);
22642 data
= read_uav_counter(context
, staging_buffer
, uav
);
22643 for (i
= 0; i
< data
; ++i
)
22644 ID3D11DeviceContext_DispatchIndirect(context
, args_buffer
, i
* 3 * sizeof(unsigned int));
22645 get_buffer_readback(stats_buffer
, &rb
);
22646 stats
= rb
.map_desc
.pData
;
22647 ok(stats
->dispatch_count
== 3, "Got unexpected dispatch count %u.\n", stats
->dispatch_count
);
22648 ok(stats
->thread_count
== 15, "Got unexpected thread count %u.\n", stats
->thread_count
);
22649 ok(stats
->max_x
== 3, "Got unexpected max x %u.\n", stats
->max_x
);
22650 ok(stats
->max_y
== 1, "Got unexpected max y %u.\n", stats
->max_y
);
22651 ok(stats
->max_z
== 0, "Got unexpected max z %u.\n", stats
->max_z
);
22652 release_resource_readback(&rb
);
22654 ID3D11Buffer_Release(append_buffer
);
22655 ID3D11Buffer_Release(args_buffer
);
22656 ID3D11Buffer_Release(staging_buffer
);
22657 ID3D11Buffer_Release(stats_buffer
);
22658 ID3D11ComputeShader_Release(cs_append
);
22659 ID3D11ComputeShader_Release(cs_stats
);
22660 ID3D11UnorderedAccessView_Release(uav
);
22661 ID3D11UnorderedAccessView_Release(stats_uav
);
22662 release_test_context(&test_context
);
22665 static void test_compute_shader_registers(void)
22669 unsigned int group_id
[3];
22670 unsigned int group_index
;
22671 unsigned int dispatch_id
[3];
22672 unsigned int thread_id
[3];
22675 struct d3d11_test_context test_context
;
22676 unsigned int i
, x
, y
, group_x
, group_y
;
22677 ID3D11UnorderedAccessView
*uav
;
22678 D3D11_BUFFER_DESC buffer_desc
;
22679 ID3D11DeviceContext
*context
;
22680 struct resource_readback rb
;
22681 ID3D11Buffer
*cb
, *buffer
;
22682 struct uvec4 dimensions
;
22683 ID3D11ComputeShader
*cs
;
22684 const struct data
*data
;
22685 ID3D11Device
*device
;
22688 static const DWORD cs_code
[] =
22696 uint3 group_thread_id
;
22699 RWStructuredBuffer
<data
> u
;
22703 [numthreads(3, 2, 1)]
22704 void main(uint3 group_id
: SV_GroupID
,
22705 uint group_index
: SV_GroupIndex
,
22706 uint3 dispatch_id
: SV_DispatchThreadID
,
22707 uint3 group_thread_id
: SV_GroupThreadID
)
22709 uint i
= dispatch_id
.x
+ dispatch_id
.y
* 3 * dim
.x
;
22710 u
[i
].group_id
= group_id
;
22711 u
[i
].group_index
= group_index
;
22712 u
[i
].dispatch_id
= dispatch_id
;
22713 u
[i
].group_thread_id
= group_thread_id
;
22716 0x43425844, 0xf0bce218, 0xfc1e8267, 0xe6d57544, 0x342df592, 0x00000001, 0x000001a4, 0x00000003,
22717 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22718 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000150, 0x00050050, 0x00000054, 0x0100086a,
22719 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0400009e, 0x0011e000, 0x00000000, 0x00000028,
22720 0x0200005f, 0x00024000, 0x0200005f, 0x00021072, 0x0200005f, 0x00022072, 0x0200005f, 0x00020072,
22721 0x02000068, 0x00000002, 0x0400009b, 0x00000003, 0x00000002, 0x00000001, 0x04000036, 0x00100072,
22722 0x00000000, 0x00021246, 0x04000036, 0x00100082, 0x00000000, 0x0002400a, 0x08000026, 0x0000d000,
22723 0x00100012, 0x00000001, 0x0002001a, 0x0020800a, 0x00000000, 0x00000000, 0x08000023, 0x00100012,
22724 0x00000001, 0x0010000a, 0x00000001, 0x00004001, 0x00000003, 0x0002000a, 0x090000a8, 0x0011e0f2,
22725 0x00000000, 0x0010000a, 0x00000001, 0x00004001, 0x00000000, 0x00100e46, 0x00000000, 0x04000036,
22726 0x00100072, 0x00000000, 0x00020246, 0x04000036, 0x00100082, 0x00000000, 0x0002200a, 0x090000a8,
22727 0x0011e0f2, 0x00000000, 0x0010000a, 0x00000001, 0x00004001, 0x00000010, 0x00100e46, 0x00000000,
22728 0x080000a8, 0x0011e032, 0x00000000, 0x0010000a, 0x00000001, 0x00004001, 0x00000020, 0x00022596,
22731 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
22733 if (!init_test_context(&test_context
, &feature_level
))
22736 device
= test_context
.device
;
22737 context
= test_context
.immediate_context
;
22739 buffer_desc
.ByteWidth
= 10240;
22740 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
22741 buffer_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
22742 buffer_desc
.CPUAccessFlags
= 0;
22743 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
;
22744 buffer_desc
.StructureByteStride
= 40;
22745 assert(sizeof(struct data
) == buffer_desc
.StructureByteStride
);
22746 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
22747 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
22748 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, NULL
, &uav
);
22749 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
22751 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(dimensions
), NULL
);
22753 hr
= ID3D11Device_CreateComputeShader(device
, cs_code
, sizeof(cs_code
), NULL
, &cs
);
22754 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
22756 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
22757 ID3D11DeviceContext_CSSetConstantBuffers(context
, 0, 1, &cb
);
22758 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
22764 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
22765 NULL
, &dimensions
, 0, 0);
22766 ID3D11DeviceContext_Dispatch(context
, dimensions
.x
, dimensions
.y
, dimensions
.z
);
22768 get_buffer_readback(buffer
, &rb
);
22770 data
= rb
.map_desc
.pData
;
22771 for (y
= 0; y
< dimensions
.y
; ++y
)
22773 for (group_y
= 0; group_y
< 2; ++group_y
)
22775 for (x
= 0; x
< dimensions
.x
; ++x
)
22777 for (group_x
= 0; group_x
< 3; ++group_x
)
22779 const unsigned int dispatch_id
[2] = {x
* 3 + group_x
, y
* 2 + group_y
};
22780 const unsigned int group_index
= group_y
* 3 + group_x
;
22781 const struct data
*d
= &data
[i
];
22783 ok(d
->group_id
[0] == x
&& d
->group_id
[1] == y
&& !d
->group_id
[2],
22784 "Got group id (%u, %u, %u), expected (%u, %u, %u) at %u (%u, %u, %u, %u).\n",
22785 d
->group_id
[0], d
->group_id
[1], d
->group_id
[2], x
, y
, 0,
22786 i
, x
, y
, group_x
, group_y
);
22787 ok(d
->group_index
== group_index
,
22788 "Got group index %u, expected %u at %u (%u, %u, %u, %u).\n",
22789 d
->group_index
, group_index
, i
, x
, y
, group_x
, group_y
);
22790 ok(d
->dispatch_id
[0] == dispatch_id
[0] && d
->dispatch_id
[1] == dispatch_id
[1]
22791 && !d
->dispatch_id
[2],
22792 "Got dispatch id (%u, %u, %u), expected (%u, %u, %u) "
22793 "at %u (%u, %u, %u, %u).\n",
22794 d
->dispatch_id
[0], d
->dispatch_id
[1], d
->dispatch_id
[2],
22795 dispatch_id
[0], dispatch_id
[1], 0,
22796 i
, x
, y
, group_x
, group_y
);
22797 ok(d
->thread_id
[0] == group_x
&& d
->thread_id
[1] == group_y
&& !d
->thread_id
[2],
22798 "Got group thread id (%u, %u, %u), expected (%u, %u, %u) "
22799 "at %u (%u, %u, %u, %u).\n",
22800 d
->thread_id
[0], d
->thread_id
[1], d
->thread_id
[2], group_x
, group_y
, 0,
22801 i
, x
, y
, group_x
, group_y
);
22807 release_resource_readback(&rb
);
22809 ID3D11Buffer_Release(cb
);
22810 ID3D11Buffer_Release(buffer
);
22811 ID3D11ComputeShader_Release(cs
);
22812 ID3D11UnorderedAccessView_Release(uav
);
22813 release_test_context(&test_context
);
22816 static void test_tgsm(void)
22818 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
22819 struct d3d11_test_context test_context
;
22820 ID3D11UnorderedAccessView
*uav
, *uav2
;
22821 struct resource_readback rb
, rb2
;
22822 unsigned int i
, data
, expected
;
22823 ID3D11Buffer
*buffer
, *buffer2
;
22824 D3D11_BUFFER_DESC buffer_desc
;
22825 ID3D11DeviceContext
*context
;
22826 ID3D11ComputeShader
*cs
;
22827 ID3D11Device
*device
;
22831 static const DWORD raw_tgsm_code
[] =
22834 RWByteAddressBuffer u
;
22835 groupshared uint m
;
22837 [numthreads(32, 1, 1)]
22838 void main(uint local_idx
: SV_GroupIndex
, uint group_id
: SV_GroupID
)
22842 GroupMemoryBarrierWithGroupSync();
22843 InterlockedAdd(m
, group_id
.x
);
22844 GroupMemoryBarrierWithGroupSync();
22846 u
.Store(4 * group_id
.x
, m
);
22849 0x43425844, 0x467df6d9, 0x5f56edda, 0x5c96b787, 0x60c91fb8, 0x00000001, 0x00000148, 0x00000003,
22850 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22851 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x000000f4, 0x00050050, 0x0000003d, 0x0100086a,
22852 0x0300009d, 0x0011e000, 0x00000000, 0x0200005f, 0x00024000, 0x0200005f, 0x00021012, 0x02000068,
22853 0x00000001, 0x0400009f, 0x0011f000, 0x00000000, 0x00000004, 0x0400009b, 0x00000020, 0x00000001,
22854 0x00000001, 0x0200001f, 0x0002400a, 0x060000a6, 0x0011f012, 0x00000000, 0x00004001, 0x00000000,
22855 0x0002100a, 0x01000015, 0x010018be, 0x060000ad, 0x0011f000, 0x00000000, 0x00004001, 0x00000000,
22856 0x0002100a, 0x010018be, 0x0200001f, 0x0002400a, 0x06000029, 0x00100012, 0x00000000, 0x0002100a,
22857 0x00004001, 0x00000002, 0x070000a5, 0x00100022, 0x00000000, 0x00004001, 0x00000000, 0x0011f006,
22858 0x00000000, 0x070000a6, 0x0011e012, 0x00000000, 0x0010000a, 0x00000000, 0x0010001a, 0x00000000,
22859 0x01000015, 0x0100003e,
22861 static const DWORD structured_tgsm_code
[] =
22864 #define GROUP_SIZE 32
22866 RWByteAddressBuffer u
;
22867 RWByteAddressBuffer u2
;
22868 groupshared uint m
[GROUP_SIZE
];
22870 [numthreads(GROUP_SIZE
, 1, 1)]
22871 void main(uint local_idx
: SV_GroupIndex
, uint group_id
: SV_GroupID
)
22873 uint sum
, original
, i
;
22877 for (i
= 0; i
< GROUP_SIZE
; ++i
)
22878 m
[i
] = 2 * group_id
.x
;
22880 GroupMemoryBarrierWithGroupSync();
22881 InterlockedAdd(m
[local_idx
], 1);
22882 GroupMemoryBarrierWithGroupSync();
22883 for (i
= 0, sum
= 0; i
< GROUP_SIZE
; sum
+= m
[i
++]);
22884 u
.InterlockedExchange(4 * group_id
.x
, sum
, original
);
22885 u2
.Store(4 * group_id
.x
, original
);
22888 0x43425844, 0x9d906c94, 0x81f5ad92, 0x11e860b2, 0x3623c824, 0x00000001, 0x000002c0, 0x00000003,
22889 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22890 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x0000026c, 0x00050050, 0x0000009b, 0x0100086a,
22891 0x0300009d, 0x0011e000, 0x00000000, 0x0300009d, 0x0011e000, 0x00000001, 0x0200005f, 0x00024000,
22892 0x0200005f, 0x00021012, 0x02000068, 0x00000002, 0x050000a0, 0x0011f000, 0x00000000, 0x00000004,
22893 0x00000020, 0x0400009b, 0x00000020, 0x00000001, 0x00000001, 0x0200001f, 0x0002400a, 0x06000029,
22894 0x00100012, 0x00000000, 0x0002100a, 0x00004001, 0x00000001, 0x05000036, 0x00100022, 0x00000000,
22895 0x00004001, 0x00000000, 0x01000030, 0x07000050, 0x00100042, 0x00000000, 0x0010001a, 0x00000000,
22896 0x00004001, 0x00000020, 0x03040003, 0x0010002a, 0x00000000, 0x090000a8, 0x0011f012, 0x00000000,
22897 0x0010001a, 0x00000000, 0x00004001, 0x00000000, 0x0010000a, 0x00000000, 0x0700001e, 0x00100022,
22898 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0x00000001, 0x01000016, 0x01000015, 0x010018be,
22899 0x04000036, 0x00100012, 0x00000000, 0x0002400a, 0x05000036, 0x00100022, 0x00000000, 0x00004001,
22900 0x00000000, 0x070000ad, 0x0011f000, 0x00000000, 0x00100046, 0x00000000, 0x00004001, 0x00000001,
22901 0x010018be, 0x08000036, 0x00100032, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000,
22902 0x00000000, 0x01000030, 0x07000050, 0x00100042, 0x00000000, 0x0010001a, 0x00000000, 0x00004001,
22903 0x00000020, 0x03040003, 0x0010002a, 0x00000000, 0x0700001e, 0x00100022, 0x00000001, 0x0010001a,
22904 0x00000000, 0x00004001, 0x00000001, 0x090000a7, 0x00100042, 0x00000000, 0x0010001a, 0x00000000,
22905 0x00004001, 0x00000000, 0x0011f006, 0x00000000, 0x0700001e, 0x00100012, 0x00000001, 0x0010000a,
22906 0x00000000, 0x0010002a, 0x00000000, 0x05000036, 0x00100032, 0x00000000, 0x00100046, 0x00000001,
22907 0x01000016, 0x06000029, 0x00100022, 0x00000000, 0x0002100a, 0x00004001, 0x00000002, 0x090000b8,
22908 0x00100012, 0x00000001, 0x0011e000, 0x00000000, 0x0010001a, 0x00000000, 0x0010000a, 0x00000000,
22909 0x070000a6, 0x0011e012, 0x00000001, 0x0010001a, 0x00000000, 0x0010000a, 0x00000001, 0x0100003e,
22911 static const DWORD structured_tgsm_float_code
[] =
22914 #define GROUP_SIZE 32
22924 groupshared data m
[GROUP_SIZE
];
22926 [numthreads(GROUP_SIZE
, 1, 1)]
22927 void main(uint local_idx
: SV_GroupIndex
, uint group_id
: SV_GroupID
,
22928 uint thread_id
: SV_DispatchThreadID
)
22933 for (i
= 0; i
< GROUP_SIZE
; ++i
)
22935 m
[i
].f
= group_id
.x
;
22936 m
[i
].u
= group_id
.x
;
22939 GroupMemoryBarrierWithGroupSync();
22940 for (i
= 0; i
< local_idx
; ++i
)
22942 m
[local_idx
].f
+= group_id
.x
;
22943 m
[local_idx
].u
+= group_id
.x
;
22945 u
[thread_id
.x
] = m
[local_idx
].f
;
22946 u2
[thread_id
.x
] = m
[local_idx
].u
;
22949 0x43425844, 0xaadf1a71, 0x16f60224, 0x89b6ce76, 0xb66fb96f, 0x00000001, 0x000002ac, 0x00000003,
22950 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22951 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000258, 0x00050050, 0x00000096, 0x0100086a,
22952 0x0400089c, 0x0011e000, 0x00000000, 0x00005555, 0x0400089c, 0x0011e000, 0x00000001, 0x00004444,
22953 0x0200005f, 0x00024000, 0x0200005f, 0x00021012, 0x0200005f, 0x00020012, 0x02000068, 0x00000002,
22954 0x050000a0, 0x0011f000, 0x00000000, 0x00000008, 0x00000020, 0x0400009b, 0x00000020, 0x00000001,
22955 0x00000001, 0x0200001f, 0x0002400a, 0x04000056, 0x00100012, 0x00000000, 0x0002100a, 0x04000036,
22956 0x00100022, 0x00000000, 0x0002100a, 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0x00000000,
22957 0x01000030, 0x07000050, 0x00100082, 0x00000000, 0x0010002a, 0x00000000, 0x00004001, 0x00000020,
22958 0x03040003, 0x0010003a, 0x00000000, 0x090000a8, 0x0011f032, 0x00000000, 0x0010002a, 0x00000000,
22959 0x00004001, 0x00000000, 0x00100046, 0x00000000, 0x0700001e, 0x00100042, 0x00000000, 0x0010002a,
22960 0x00000000, 0x00004001, 0x00000001, 0x01000016, 0x01000015, 0x010018be, 0x04000056, 0x00100012,
22961 0x00000000, 0x0002100a, 0x05000036, 0x00100022, 0x00000000, 0x00004001, 0x00000000, 0x01000030,
22962 0x06000050, 0x00100042, 0x00000000, 0x0010001a, 0x00000000, 0x0002400a, 0x03040003, 0x0010002a,
22963 0x00000000, 0x080000a7, 0x001000c2, 0x00000000, 0x0002400a, 0x00004001, 0x00000000, 0x0011f406,
22964 0x00000000, 0x07000000, 0x00100012, 0x00000001, 0x0010000a, 0x00000000, 0x0010002a, 0x00000000,
22965 0x0600001e, 0x00100022, 0x00000001, 0x0010003a, 0x00000000, 0x0002100a, 0x080000a8, 0x0011f032,
22966 0x00000000, 0x0002400a, 0x00004001, 0x00000000, 0x00100046, 0x00000001, 0x0700001e, 0x00100022,
22967 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0x00000001, 0x01000016, 0x080000a7, 0x00100032,
22968 0x00000000, 0x0002400a, 0x00004001, 0x00000000, 0x0011f046, 0x00000000, 0x060000a4, 0x0011e0f2,
22969 0x00000000, 0x00020006, 0x00100006, 0x00000000, 0x060000a4, 0x0011e0f2, 0x00000001, 0x00020006,
22970 0x00100556, 0x00000000, 0x0100003e,
22972 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
22973 static const unsigned int zero
[4] = {0};
22975 if (!init_test_context(&test_context
, &feature_level
))
22978 device
= test_context
.device
;
22979 context
= test_context
.immediate_context
;
22981 buffer_desc
.ByteWidth
= 1024;
22982 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
22983 buffer_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
22984 buffer_desc
.CPUAccessFlags
= 0;
22985 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
;
22986 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
22987 ok(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
22989 uav_desc
.Format
= DXGI_FORMAT_R32_TYPELESS
;
22990 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
22991 U(uav_desc
).Buffer
.FirstElement
= 0;
22992 U(uav_desc
).Buffer
.NumElements
= buffer_desc
.ByteWidth
/ sizeof(unsigned int);
22993 U(uav_desc
).Buffer
.Flags
= D3D11_BUFFER_UAV_FLAG_RAW
;
22994 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
22995 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
22997 hr
= ID3D11Device_CreateComputeShader(device
, raw_tgsm_code
, sizeof(raw_tgsm_code
), NULL
, &cs
);
22998 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
23000 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
23001 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
23003 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, zero
);
23004 ID3D11DeviceContext_Dispatch(context
, 64, 1, 1);
23005 get_buffer_readback(buffer
, &rb
);
23006 for (i
= 0; i
< 64; ++i
)
23008 data
= get_readback_color(&rb
, i
, 0, 0);
23010 ok(data
== expected
, "Got %u, expected %u (index %u).\n", data
, expected
, i
);
23012 release_resource_readback(&rb
);
23014 ID3D11Buffer_Release(buffer
);
23015 ID3D11ComputeShader_Release(cs
);
23016 ID3D11UnorderedAccessView_Release(uav
);
23018 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
23019 ok(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
23020 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
23021 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
23022 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer2
);
23023 ok(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
23024 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer2
, &uav_desc
, &uav2
);
23025 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
23026 hr
= ID3D11Device_CreateComputeShader(device
, structured_tgsm_code
, sizeof(structured_tgsm_code
), NULL
, &cs
);
23027 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
23029 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
23030 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
23031 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 1, 1, &uav2
, NULL
);
23033 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, zero
);
23034 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav2
, zero
);
23035 ID3D11DeviceContext_Dispatch(context
, 32, 1, 1);
23036 get_buffer_readback(buffer
, &rb
);
23037 get_buffer_readback(buffer2
, &rb2
);
23038 for (i
= 0; i
< 32; ++i
)
23040 expected
= 64 * i
+ 32;
23041 data
= get_readback_color(&rb
, i
, 0, 0);
23042 ok(data
== expected
, "Got %u, expected %u (index %u).\n", data
, expected
, i
);
23043 data
= get_readback_color(&rb2
, i
, 0, 0);
23044 ok(data
== expected
|| !data
, "Got %u, expected %u (index %u).\n", data
, expected
, i
);
23046 release_resource_readback(&rb
);
23047 release_resource_readback(&rb2
);
23049 ID3D11Buffer_Release(buffer
);
23050 ID3D11Buffer_Release(buffer2
);
23051 ID3D11ComputeShader_Release(cs
);
23052 ID3D11UnorderedAccessView_Release(uav
);
23053 ID3D11UnorderedAccessView_Release(uav2
);
23055 buffer_desc
.MiscFlags
= 0;
23056 U(uav_desc
).Buffer
.Flags
= 0;
23057 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
23058 ok(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
23059 uav_desc
.Format
= DXGI_FORMAT_R32_FLOAT
;
23060 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
23061 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
23062 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer2
);
23063 ok(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
23064 uav_desc
.Format
= DXGI_FORMAT_R32_UINT
;
23065 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer2
, &uav_desc
, &uav2
);
23066 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
23067 hr
= ID3D11Device_CreateComputeShader(device
, structured_tgsm_float_code
,
23068 sizeof(structured_tgsm_float_code
), NULL
, &cs
);
23069 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
23071 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
23072 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
23073 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 1, 1, &uav2
, NULL
);
23075 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, zero
);
23076 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav2
, zero
);
23077 ID3D11DeviceContext_Dispatch(context
, 3, 1, 1);
23078 get_buffer_readback(buffer
, &rb
);
23079 get_buffer_readback(buffer2
, &rb2
);
23080 for (i
= 0; i
< 96; ++i
)
23082 expected
= (i
% 32 + 1) * (i
/ 32);
23083 float_data
= get_readback_float(&rb
, i
, 0);
23084 ok(float_data
== expected
, "Got %.8e, expected %u (index %u).\n", float_data
, expected
, i
);
23085 data
= get_readback_color(&rb2
, i
, 0, 0);
23086 ok(data
== expected
, "Got %u, expected %u (index %u).\n", data
, expected
, i
);
23088 release_resource_readback(&rb
);
23089 release_resource_readback(&rb2
);
23091 ID3D11Buffer_Release(buffer
);
23092 ID3D11Buffer_Release(buffer2
);
23093 ID3D11ComputeShader_Release(cs
);
23094 ID3D11UnorderedAccessView_Release(uav
);
23095 ID3D11UnorderedAccessView_Release(uav2
);
23096 release_test_context(&test_context
);
23099 static void test_geometry_shader(void)
23101 static const struct
23103 struct vec4 position
;
23104 unsigned int color
;
23108 {{0.0f
, 0.0f
, 1.0f
, 1.0f
}, 0xffffff00},
23110 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
23112 {"SV_POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
23113 {"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, 16, D3D11_INPUT_PER_VERTEX_DATA
, 0},
23118 float4 pos
: SV_POSITION
;
23119 float4 color
: COLOR
;
23122 void main(in
struct vs_data vs_input
, out
struct vs_data vs_output
)
23124 vs_output
.pos
= vs_input
.pos
;
23125 vs_output
.color
= vs_input
.color
;
23128 static const DWORD vs_code
[] =
23130 0x43425844, 0xd5b32785, 0x35332906, 0x4d05e031, 0xf66a58af, 0x00000001, 0x00000144, 0x00000003,
23131 0x0000002c, 0x00000080, 0x000000d4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
23132 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000044, 0x00000000, 0x00000000,
23133 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
23134 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
23135 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
23136 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000068, 0x00010040,
23137 0x0000001a, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067,
23138 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2,
23139 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001,
23145 float4 pos
: SV_POSITION
;
23146 float4 color
: COLOR
;
23149 [maxvertexcount(4)]
23150 void main(point
struct gs_data vin
[1], inout TriangleStream
<gs_data
> vout
)
23152 float offset
= 0.2 * vin
[0].pos
.w
;
23155 v
.color
= vin
[0].color
;
23157 v
.pos
= float4(vin
[0].pos
.x
- offset
, vin
[0].pos
.y
- offset
, vin
[0].pos
.z
, 1.0);
23159 v
.pos
= float4(vin
[0].pos
.x
- offset
, vin
[0].pos
.y
+ offset
, vin
[0].pos
.z
, 1.0);
23161 v
.pos
= float4(vin
[0].pos
.x
+ offset
, vin
[0].pos
.y
- offset
, vin
[0].pos
.z
, 1.0);
23163 v
.pos
= float4(vin
[0].pos
.x
+ offset
, vin
[0].pos
.y
+ offset
, vin
[0].pos
.z
, 1.0);
23167 static const DWORD gs_code
[] =
23169 0x43425844, 0x70616045, 0x96756e1f, 0x1caeecb8, 0x3749528c, 0x00000001, 0x0000034c, 0x00000003,
23170 0x0000002c, 0x00000080, 0x000000d4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
23171 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x00000044, 0x00000000, 0x00000000,
23172 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
23173 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
23174 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
23175 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000270, 0x00020040,
23176 0x0000009c, 0x05000061, 0x002010f2, 0x00000001, 0x00000000, 0x00000001, 0x0400005f, 0x002010f2,
23177 0x00000001, 0x00000001, 0x02000068, 0x00000001, 0x0100085d, 0x0100285c, 0x04000067, 0x001020f2,
23178 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x0200005e, 0x00000004, 0x0f000032,
23179 0x00100032, 0x00000000, 0x80201ff6, 0x00000041, 0x00000000, 0x00000000, 0x00004002, 0x3e4ccccd,
23180 0x3e4ccccd, 0x00000000, 0x00000000, 0x00201046, 0x00000000, 0x00000000, 0x05000036, 0x00102032,
23181 0x00000000, 0x00100046, 0x00000000, 0x06000036, 0x00102042, 0x00000000, 0x0020102a, 0x00000000,
23182 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x3f800000, 0x06000036, 0x001020f2,
23183 0x00000001, 0x00201e46, 0x00000000, 0x00000001, 0x01000013, 0x05000036, 0x00102012, 0x00000000,
23184 0x0010000a, 0x00000000, 0x0e000032, 0x00100052, 0x00000000, 0x00201ff6, 0x00000000, 0x00000000,
23185 0x00004002, 0x3e4ccccd, 0x00000000, 0x3e4ccccd, 0x00000000, 0x00201106, 0x00000000, 0x00000000,
23186 0x05000036, 0x00102022, 0x00000000, 0x0010002a, 0x00000000, 0x06000036, 0x00102042, 0x00000000,
23187 0x0020102a, 0x00000000, 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x3f800000,
23188 0x06000036, 0x001020f2, 0x00000001, 0x00201e46, 0x00000000, 0x00000001, 0x01000013, 0x05000036,
23189 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x05000036, 0x00102022, 0x00000000, 0x0010001a,
23190 0x00000000, 0x06000036, 0x00102042, 0x00000000, 0x0020102a, 0x00000000, 0x00000000, 0x05000036,
23191 0x00102082, 0x00000000, 0x00004001, 0x3f800000, 0x06000036, 0x001020f2, 0x00000001, 0x00201e46,
23192 0x00000000, 0x00000001, 0x01000013, 0x05000036, 0x00102032, 0x00000000, 0x00100086, 0x00000000,
23193 0x06000036, 0x00102042, 0x00000000, 0x0020102a, 0x00000000, 0x00000000, 0x05000036, 0x00102082,
23194 0x00000000, 0x00004001, 0x3f800000, 0x06000036, 0x001020f2, 0x00000001, 0x00201e46, 0x00000000,
23195 0x00000001, 0x01000013, 0x0100003e,
23197 static const DWORD gs_5_0_code
[] =
23199 0x43425844, 0x57251c23, 0x4971d115, 0x8fee0b13, 0xba149ea1, 0x00000001, 0x00000384, 0x00000003,
23200 0x0000002c, 0x00000080, 0x000000dc, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
23201 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x00000044, 0x00000000, 0x00000000,
23202 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
23203 0x3547534f, 0x00000054, 0x00000002, 0x00000008, 0x00000000, 0x00000040, 0x00000000, 0x00000001,
23204 0x00000003, 0x00000000, 0x0000000f, 0x00000000, 0x0000004c, 0x00000000, 0x00000000, 0x00000003,
23205 0x00000001, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x58454853,
23206 0x000002a0, 0x00020050, 0x000000a8, 0x0100086a, 0x05000061, 0x002010f2, 0x00000001, 0x00000000,
23207 0x00000001, 0x0400005f, 0x002010f2, 0x00000001, 0x00000001, 0x02000068, 0x00000001, 0x0100085d,
23208 0x0300008f, 0x00110000, 0x00000000, 0x0100285c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
23209 0x03000065, 0x001020f2, 0x00000001, 0x0200005e, 0x00000004, 0x0f000032, 0x00100032, 0x00000000,
23210 0x80201ff6, 0x00000041, 0x00000000, 0x00000000, 0x00004002, 0x3e4ccccd, 0x3e4ccccd, 0x00000000,
23211 0x00000000, 0x00201046, 0x00000000, 0x00000000, 0x05000036, 0x00102032, 0x00000000, 0x00100046,
23212 0x00000000, 0x06000036, 0x00102042, 0x00000000, 0x0020102a, 0x00000000, 0x00000000, 0x05000036,
23213 0x00102082, 0x00000000, 0x00004001, 0x3f800000, 0x06000036, 0x001020f2, 0x00000001, 0x00201e46,
23214 0x00000000, 0x00000001, 0x03000075, 0x00110000, 0x00000000, 0x05000036, 0x00102012, 0x00000000,
23215 0x0010000a, 0x00000000, 0x0e000032, 0x00100052, 0x00000000, 0x00201ff6, 0x00000000, 0x00000000,
23216 0x00004002, 0x3e4ccccd, 0x00000000, 0x3e4ccccd, 0x00000000, 0x00201106, 0x00000000, 0x00000000,
23217 0x05000036, 0x00102022, 0x00000000, 0x0010002a, 0x00000000, 0x06000036, 0x00102042, 0x00000000,
23218 0x0020102a, 0x00000000, 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x3f800000,
23219 0x06000036, 0x001020f2, 0x00000001, 0x00201e46, 0x00000000, 0x00000001, 0x03000075, 0x00110000,
23220 0x00000000, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x05000036, 0x00102022,
23221 0x00000000, 0x0010001a, 0x00000000, 0x06000036, 0x00102042, 0x00000000, 0x0020102a, 0x00000000,
23222 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x3f800000, 0x06000036, 0x001020f2,
23223 0x00000001, 0x00201e46, 0x00000000, 0x00000001, 0x03000075, 0x00110000, 0x00000000, 0x05000036,
23224 0x00102032, 0x00000000, 0x00100086, 0x00000000, 0x06000036, 0x00102042, 0x00000000, 0x0020102a,
23225 0x00000000, 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x3f800000, 0x06000036,
23226 0x001020f2, 0x00000001, 0x00201e46, 0x00000000, 0x00000001, 0x03000075, 0x00110000, 0x00000000,
23232 float4 pos
: SV_POSITION
;
23233 float4 color
: COLOR
;
23236 float4
main(struct ps_data ps_input
) : SV_Target
23238 return ps_input
.color
;
23241 static const DWORD ps_code
[] =
23243 0x43425844, 0x89803e59, 0x3f798934, 0xf99181df, 0xf5556512, 0x00000001, 0x000000f4, 0x00000003,
23244 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
23245 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
23246 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
23247 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
23248 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000038, 0x00000040,
23249 0x0000000e, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
23250 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
23252 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 1.0f
};
23253 struct d3d11_test_context test_context
;
23254 ID3D11InputLayout
*input_layout
;
23255 ID3D11DeviceContext
*context
;
23256 unsigned int stride
, offset
;
23257 struct resource_readback rb
;
23258 ID3D11GeometryShader
*gs
;
23259 ID3D11VertexShader
*vs
;
23260 ID3D11PixelShader
*ps
;
23261 ID3D11Device
*device
;
23266 if (!init_test_context(&test_context
, NULL
))
23269 device
= test_context
.device
;
23270 context
= test_context
.immediate_context
;
23272 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
23273 vs_code
, sizeof(vs_code
), &input_layout
);
23274 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
23276 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(vertex
), vertex
);
23278 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
23279 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
23280 if (ID3D11Device_GetFeatureLevel(device
) >= D3D_FEATURE_LEVEL_11_0
)
23281 hr
= ID3D11Device_CreateGeometryShader(device
, gs_5_0_code
, sizeof(gs_5_0_code
), NULL
, &gs
);
23283 hr
= ID3D11Device_CreateGeometryShader(device
, gs_code
, sizeof(gs_code
), NULL
, &gs
);
23284 ok(SUCCEEDED(hr
), "Failed to create geometry shader, hr %#x.\n", hr
);
23285 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
23286 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
23288 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
23289 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST
);
23290 stride
= sizeof(*vertex
);
23292 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, &stride
, &offset
);
23293 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
23294 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
23295 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
23297 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
23298 ID3D11DeviceContext_Draw(context
, 1, 0);
23300 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
23301 color
= get_readback_color(&rb
, 320, 190, 0);
23302 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
23303 color
= get_readback_color(&rb
, 255, 240, 0);
23304 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
23305 color
= get_readback_color(&rb
, 320, 240, 0);
23306 ok(compare_color(color
, 0xffffff00, 1), "Got unexpected color 0x%08x.\n", color
);
23307 color
= get_readback_color(&rb
, 385, 240, 0);
23308 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
23309 color
= get_readback_color(&rb
, 320, 290, 0);
23310 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
23311 release_resource_readback(&rb
);
23313 ID3D11PixelShader_Release(ps
);
23314 ID3D11GeometryShader_Release(gs
);
23315 ID3D11VertexShader_Release(vs
);
23316 ID3D11Buffer_Release(vb
);
23317 ID3D11InputLayout_Release(input_layout
);
23318 release_test_context(&test_context
);
23326 #define check_triangles(buffer, triangles, count) check_triangles_(__LINE__, buffer, triangles, count)
23327 static void check_triangles_(unsigned int line
, ID3D11Buffer
*buffer
,
23328 const struct triangle
*triangles
, unsigned int triangle_count
)
23330 const struct triangle
*current
, *expected
;
23331 struct resource_readback rb
;
23332 unsigned int i
, j
, offset
;
23333 BOOL all_match
= TRUE
;
23335 get_buffer_readback(buffer
, &rb
);
23337 for (i
= 0; i
< triangle_count
; ++i
)
23339 current
= get_readback_data(&rb
, i
, 0, 0, sizeof(*current
));
23340 expected
= &triangles
[i
];
23343 for (j
= 0; j
< ARRAY_SIZE(expected
->v
); ++j
)
23345 if (compare_vec4(¤t
->v
[0], &expected
->v
[j
], 0))
23358 for (j
= 0; j
< ARRAY_SIZE(expected
->v
); ++j
)
23360 if (!compare_vec4(¤t
->v
[j
], &expected
->v
[(j
+ offset
) % 3], 0))
23370 ok_(__FILE__
, line
)(all_match
, "Triangle %u vertices {%.8e, %.8e, %.8e, %.8e}, "
23371 "{%.8e, %.8e, %.8e, %.8e}, {%.8e, %.8e, %.8e, %.8e} "
23372 "do not match {%.8e, %.8e, %.8e, %.8e}, {%.8e, %.8e, %.8e, %.8e}, "
23373 "{%.8e, %.8e, %.8e, %.8e}.\n", i
,
23374 current
->v
[0].x
, current
->v
[0].y
, current
->v
[0].z
, current
->v
[0].w
,
23375 current
->v
[1].x
, current
->v
[1].y
, current
->v
[1].z
, current
->v
[1].w
,
23376 current
->v
[2].x
, current
->v
[2].y
, current
->v
[2].z
, current
->v
[2].w
,
23377 expected
->v
[0].x
, expected
->v
[0].y
, expected
->v
[0].z
, expected
->v
[0].w
,
23378 expected
->v
[1].x
, expected
->v
[1].y
, expected
->v
[1].z
, expected
->v
[1].w
,
23379 expected
->v
[2].x
, expected
->v
[2].y
, expected
->v
[2].z
, expected
->v
[2].w
);
23381 release_resource_readback(&rb
);
23384 static void test_quad_tessellation(void)
23389 float4 position
: SV_POSITION
;
23392 struct patch_constant_data
23394 float edges
[4] : SV_TessFactor
;
23395 float inside
[2] : SV_InsideTessFactor
;
23398 float4 tess_factors
;
23399 float2 inside_tess_factors
;
23401 patch_constant_data
patch_constant(InputPatch
<point_data
, 4> input
)
23403 patch_constant_data output
;
23405 output
.edges
[0] = tess_factors
.x
;
23406 output
.edges
[1] = tess_factors
.y
;
23407 output
.edges
[2] = tess_factors
.z
;
23408 output
.edges
[3] = tess_factors
.w
;
23409 output
.inside
[0] = inside_tess_factors
.x
;
23410 output
.inside
[1] = inside_tess_factors
.y
;
23416 [outputcontrolpoints(4)]
23417 [outputtopology("triangle_ccw")]
23418 [partitioning("integer")]
23419 [patchconstantfunc("patch_constant")]
23420 point_data
hs_main(InputPatch
<point_data
, 4> input
,
23421 uint i
: SV_OutputControlPointID
)
23427 point_data
ds_main(patch_constant_data input
,
23428 float2 tess_coord
: SV_DomainLocation
,
23429 const OutputPatch
<point_data
, 4> patch
)
23433 float4 a
= lerp(patch
[0].position
, patch
[1].position
, tess_coord
.x
);
23434 float4 b
= lerp(patch
[2].position
, patch
[3].position
, tess_coord
.x
);
23435 output
.position
= lerp(a
, b
, tess_coord
.y
);
23440 static const DWORD hs_quad_ccw_code
[] =
23442 0x43425844, 0xdf8df700, 0x58b08fb1, 0xbd23d2c3, 0xcf884094, 0x00000001, 0x000002b8, 0x00000004,
23443 0x00000030, 0x00000064, 0x00000098, 0x0000015c, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008,
23444 0x00000020, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x5449534f,
23445 0x004e4f49, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
23446 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x47534350, 0x000000bc,
23447 0x00000006, 0x00000008, 0x00000098, 0x00000000, 0x0000000b, 0x00000003, 0x00000000, 0x00000e01,
23448 0x00000098, 0x00000001, 0x0000000b, 0x00000003, 0x00000001, 0x00000e01, 0x00000098, 0x00000002,
23449 0x0000000b, 0x00000003, 0x00000002, 0x00000e01, 0x00000098, 0x00000003, 0x0000000b, 0x00000003,
23450 0x00000003, 0x00000e01, 0x000000a6, 0x00000000, 0x0000000c, 0x00000003, 0x00000004, 0x00000e01,
23451 0x000000a6, 0x00000001, 0x0000000c, 0x00000003, 0x00000005, 0x00000e01, 0x545f5653, 0x46737365,
23452 0x6f746361, 0x56530072, 0x736e495f, 0x54656469, 0x46737365, 0x6f746361, 0xabab0072, 0x58454853,
23453 0x00000154, 0x00030050, 0x00000055, 0x01000071, 0x01002093, 0x01002094, 0x01001895, 0x01000896,
23454 0x01002097, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000002, 0x01000073, 0x04000067,
23455 0x00102012, 0x00000000, 0x0000000b, 0x06000036, 0x00102012, 0x00000000, 0x0020800a, 0x00000000,
23456 0x00000000, 0x0100003e, 0x01000073, 0x04000067, 0x00102012, 0x00000001, 0x0000000c, 0x06000036,
23457 0x00102012, 0x00000001, 0x0020801a, 0x00000000, 0x00000000, 0x0100003e, 0x01000073, 0x04000067,
23458 0x00102012, 0x00000002, 0x0000000d, 0x06000036, 0x00102012, 0x00000002, 0x0020802a, 0x00000000,
23459 0x00000000, 0x0100003e, 0x01000073, 0x04000067, 0x00102012, 0x00000003, 0x0000000e, 0x06000036,
23460 0x00102012, 0x00000003, 0x0020803a, 0x00000000, 0x00000000, 0x0100003e, 0x01000073, 0x04000067,
23461 0x00102012, 0x00000004, 0x0000000f, 0x06000036, 0x00102012, 0x00000004, 0x0020800a, 0x00000000,
23462 0x00000001, 0x0100003e, 0x01000073, 0x04000067, 0x00102012, 0x00000005, 0x00000010, 0x06000036,
23463 0x00102012, 0x00000005, 0x0020801a, 0x00000000, 0x00000001, 0x0100003e,
23465 static const DWORD ds_quad_code
[] =
23467 0x43425844, 0xeb6b7631, 0x07f5469e, 0xed0cbf4a, 0x7158b3a6, 0x00000001, 0x00000284, 0x00000004,
23468 0x00000030, 0x00000064, 0x00000128, 0x0000015c, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008,
23469 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x5449534f,
23470 0x004e4f49, 0x47534350, 0x000000bc, 0x00000006, 0x00000008, 0x00000098, 0x00000000, 0x0000000b,
23471 0x00000003, 0x00000000, 0x00000001, 0x00000098, 0x00000001, 0x0000000b, 0x00000003, 0x00000001,
23472 0x00000001, 0x00000098, 0x00000002, 0x0000000b, 0x00000003, 0x00000002, 0x00000001, 0x00000098,
23473 0x00000003, 0x0000000b, 0x00000003, 0x00000003, 0x00000001, 0x000000a6, 0x00000000, 0x0000000c,
23474 0x00000003, 0x00000004, 0x00000001, 0x000000a6, 0x00000001, 0x0000000c, 0x00000003, 0x00000005,
23475 0x00000001, 0x545f5653, 0x46737365, 0x6f746361, 0x56530072, 0x736e495f, 0x54656469, 0x46737365,
23476 0x6f746361, 0xabab0072, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000,
23477 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x58454853,
23478 0x00000120, 0x00040050, 0x00000048, 0x01002093, 0x01001895, 0x0100086a, 0x0200005f, 0x0001c032,
23479 0x0400005f, 0x002190f2, 0x00000004, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
23480 0x02000068, 0x00000002, 0x0a000000, 0x001000f2, 0x00000000, 0x80219e46, 0x00000041, 0x00000002,
23481 0x00000000, 0x00219e46, 0x00000003, 0x00000000, 0x09000032, 0x001000f2, 0x00000000, 0x0001c006,
23482 0x00100e46, 0x00000000, 0x00219e46, 0x00000002, 0x00000000, 0x0a000000, 0x001000f2, 0x00000001,
23483 0x80219e46, 0x00000041, 0x00000000, 0x00000000, 0x00219e46, 0x00000001, 0x00000000, 0x09000032,
23484 0x001000f2, 0x00000001, 0x0001c006, 0x00100e46, 0x00000001, 0x00219e46, 0x00000000, 0x00000000,
23485 0x08000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x80100e46, 0x00000041, 0x00000001,
23486 0x08000032, 0x001020f2, 0x00000000, 0x0001c556, 0x00100e46, 0x00000000, 0x00100e46, 0x00000001,
23491 [outputtopology("triangle_cw")]
23494 static const DWORD hs_quad_cw_code
[] =
23496 0x43425844, 0x1ab30cc8, 0x94174771, 0x61f4cdd0, 0xa287f62c, 0x00000001, 0x000002b8, 0x00000004,
23497 0x00000030, 0x00000064, 0x00000098, 0x0000015c, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008,
23498 0x00000020, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x5449534f,
23499 0x004e4f49, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
23500 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x47534350, 0x000000bc,
23501 0x00000006, 0x00000008, 0x00000098, 0x00000000, 0x0000000b, 0x00000003, 0x00000000, 0x00000e01,
23502 0x00000098, 0x00000001, 0x0000000b, 0x00000003, 0x00000001, 0x00000e01, 0x00000098, 0x00000002,
23503 0x0000000b, 0x00000003, 0x00000002, 0x00000e01, 0x00000098, 0x00000003, 0x0000000b, 0x00000003,
23504 0x00000003, 0x00000e01, 0x000000a6, 0x00000000, 0x0000000c, 0x00000003, 0x00000004, 0x00000e01,
23505 0x000000a6, 0x00000001, 0x0000000c, 0x00000003, 0x00000005, 0x00000e01, 0x545f5653, 0x46737365,
23506 0x6f746361, 0x56530072, 0x736e495f, 0x54656469, 0x46737365, 0x6f746361, 0xabab0072, 0x58454853,
23507 0x00000154, 0x00030050, 0x00000055, 0x01000071, 0x01002093, 0x01002094, 0x01001895, 0x01000896,
23508 0x01001897, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000002, 0x01000073, 0x04000067,
23509 0x00102012, 0x00000000, 0x0000000b, 0x06000036, 0x00102012, 0x00000000, 0x0020800a, 0x00000000,
23510 0x00000000, 0x0100003e, 0x01000073, 0x04000067, 0x00102012, 0x00000001, 0x0000000c, 0x06000036,
23511 0x00102012, 0x00000001, 0x0020801a, 0x00000000, 0x00000000, 0x0100003e, 0x01000073, 0x04000067,
23512 0x00102012, 0x00000002, 0x0000000d, 0x06000036, 0x00102012, 0x00000002, 0x0020802a, 0x00000000,
23513 0x00000000, 0x0100003e, 0x01000073, 0x04000067, 0x00102012, 0x00000003, 0x0000000e, 0x06000036,
23514 0x00102012, 0x00000003, 0x0020803a, 0x00000000, 0x00000000, 0x0100003e, 0x01000073, 0x04000067,
23515 0x00102012, 0x00000004, 0x0000000f, 0x06000036, 0x00102012, 0x00000004, 0x0020800a, 0x00000000,
23516 0x00000001, 0x0100003e, 0x01000073, 0x04000067, 0x00102012, 0x00000005, 0x00000010, 0x06000036,
23517 0x00102012, 0x00000005, 0x0020801a, 0x00000000, 0x00000001, 0x0100003e,
23522 float4 pos
: SV_POSITION
;
23525 [maxvertexcount(3)]
23526 void main(triangle point_data vin
[3], inout TriangleStream
<point_data
> vout
)
23528 for (uint i
= 0; i
< 3; ++i
)
23529 vout
.Append(vin
[i
]);
23532 static const DWORD gs_code
[] =
23534 0x43425844, 0x8e49d18d, 0x6d08d6e5, 0xb7015628, 0xf9351fdd, 0x00000001, 0x00000164, 0x00000003,
23535 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
23536 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49,
23537 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
23538 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x000000c8, 0x00020040,
23539 0x00000032, 0x05000061, 0x002010f2, 0x00000003, 0x00000000, 0x00000001, 0x02000068, 0x00000001,
23540 0x0100185d, 0x0100285c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x0200005e, 0x00000003,
23541 0x05000036, 0x00100012, 0x00000000, 0x00004001, 0x00000000, 0x01000030, 0x07000050, 0x00100022,
23542 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000003, 0x03040003, 0x0010001a, 0x00000000,
23543 0x07000036, 0x001020f2, 0x00000000, 0x00a01e46, 0x0010000a, 0x00000000, 0x00000000, 0x01000013,
23544 0x0700001e, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000001, 0x01000016,
23547 static const D3D11_SO_DECLARATION_ENTRY so_declaration
[] =
23549 {0, "SV_POSITION", 0, 0, 4, 0},
23551 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
23552 static const struct vec4 green
= {0.0f
, 1.0f
, 0.0f
, 1.0f
};
23553 static const struct vec4 white
= {1.0f
, 1.0f
, 1.0f
, 1.0f
};
23554 static const BYTE zero_data
[1024];
23555 static const struct triangle expected_quad_ccw
[] =
23557 {{{-1.0f
, -1.0f
, 0.0f
, 1.0f
},
23558 { 1.0f
, -1.0f
, 0.0f
, 1.0f
},
23559 {-1.0f
, 1.0f
, 0.0f
, 1.0f
}}},
23560 {{{-1.0f
, 1.0f
, 0.0f
, 1.0f
},
23561 { 1.0f
, -1.0f
, 0.0f
, 1.0f
},
23562 { 1.0f
, 1.0f
, 0.0f
, 1.0f
}}},
23563 {{{ 0.0f
, 0.0f
, 0.0f
, 0.0f
},
23564 { 0.0f
, 0.0f
, 0.0f
, 0.0f
},
23565 { 0.0f
, 0.0f
, 0.0f
, 0.0f
}}},
23567 static const struct triangle expected_quad_cw
[] =
23569 {{{-1.0f
, -1.0f
, 0.0f
, 1.0f
},
23570 {-1.0f
, 1.0f
, 0.0f
, 1.0f
},
23571 { 1.0f
, -1.0f
, 0.0f
, 1.0f
}}},
23572 {{{-1.0f
, 1.0f
, 0.0f
, 1.0f
},
23573 { 1.0f
, 1.0f
, 0.0f
, 1.0f
},
23574 { 1.0f
, -1.0f
, 0.0f
, 1.0f
}}},
23575 {{{ 0.0f
, 0.0f
, 0.0f
, 0.0f
},
23576 { 0.0f
, 0.0f
, 0.0f
, 0.0f
},
23577 { 0.0f
, 0.0f
, 0.0f
, 0.0f
}}},
23581 float tess_factors
[4];
23582 float inside_tess_factors
[2];
23586 D3D11_QUERY_DATA_SO_STATISTICS so_statistics
;
23587 struct d3d11_test_context test_context
;
23588 ID3D11DeviceContext
*context
;
23589 ID3D11Buffer
*cb
, *so_buffer
;
23590 D3D11_QUERY_DESC query_desc
;
23591 ID3D11Asynchronous
*query
;
23592 ID3D11GeometryShader
*gs
;
23593 ID3D11DomainShader
*ds
;
23594 const UINT offset
= 0;
23595 ID3D11HullShader
*hs
;
23596 ID3D11Device
*device
;
23600 if (!init_test_context(&test_context
, &feature_level
))
23603 device
= test_context
.device
;
23604 context
= test_context
.immediate_context
;
23606 draw_color_quad(&test_context
, &white
);
23607 check_texture_color(test_context
.backbuffer
, 0xffffffff, 0);
23609 set_quad_color(&test_context
, &green
);
23610 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST
);
23612 so_buffer
= create_buffer(device
, D3D11_BIND_STREAM_OUTPUT
, sizeof(zero_data
), zero_data
);
23613 hr
= ID3D11Device_CreateGeometryShaderWithStreamOutput(device
, gs_code
, sizeof(gs_code
),
23614 so_declaration
, ARRAY_SIZE(so_declaration
), NULL
, 0, 0, NULL
, &gs
);
23615 ok(SUCCEEDED(hr
), "Failed to create geometry shader with stream output, hr %#x.\n", hr
);
23616 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
23618 for (i
= 0; i
< ARRAY_SIZE(constant
.tess_factors
); ++i
)
23619 constant
.tess_factors
[i
] = 1.0f
;
23620 for (i
= 0; i
< ARRAY_SIZE(constant
.inside_tess_factors
); ++i
)
23621 constant
.inside_tess_factors
[i
] = 1.0f
;
23622 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(constant
), &constant
);
23623 ID3D11DeviceContext_HSSetConstantBuffers(context
, 0, 1, &cb
);
23624 hr
= ID3D11Device_CreateHullShader(device
, hs_quad_ccw_code
, sizeof(hs_quad_ccw_code
), NULL
, &hs
);
23625 ok(SUCCEEDED(hr
), "Failed to create hull shader, hr %#x.\n", hr
);
23626 ID3D11DeviceContext_HSSetShader(context
, hs
, NULL
, 0);
23627 hr
= ID3D11Device_CreateDomainShader(device
, ds_quad_code
, sizeof(ds_quad_code
), NULL
, &ds
);
23628 ok(SUCCEEDED(hr
), "Failed to create domain shader, hr %#x.\n", hr
);
23629 ID3D11DeviceContext_DSSetShader(context
, ds
, NULL
, 0);
23631 ID3D11DeviceContext_SOSetTargets(context
, 1, &so_buffer
, &offset
);
23632 ID3D11DeviceContext_Draw(context
, 4, 0);
23633 check_texture_color(test_context
.backbuffer
, 0xffffffff, 0);
23634 ID3D11DeviceContext_SOSetTargets(context
, 0, NULL
, NULL
);
23635 check_triangles(so_buffer
, expected_quad_ccw
, ARRAY_SIZE(expected_quad_ccw
));
23637 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)so_buffer
, 0, NULL
, zero_data
, 0, 0);
23639 ID3D11HullShader_Release(hs
);
23640 hr
= ID3D11Device_CreateHullShader(device
, hs_quad_cw_code
, sizeof(hs_quad_cw_code
), NULL
, &hs
);
23641 ok(SUCCEEDED(hr
), "Failed to create hull shader, hr %#x.\n", hr
);
23642 ID3D11DeviceContext_HSSetShader(context
, hs
, NULL
, 0);
23644 ID3D11DeviceContext_SOSetTargets(context
, 1, &so_buffer
, &offset
);
23645 ID3D11DeviceContext_Draw(context
, 4, 0);
23646 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
23647 ID3D11DeviceContext_SOSetTargets(context
, 0, NULL
, NULL
);
23648 check_triangles(so_buffer
, expected_quad_cw
, ARRAY_SIZE(expected_quad_cw
));
23650 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)so_buffer
, 0, NULL
, zero_data
, 0, 0);
23652 ID3D11DeviceContext_SOSetTargets(context
, 1, &so_buffer
, &offset
);
23653 query_desc
.Query
= D3D11_QUERY_SO_STATISTICS_STREAM0
;
23654 query_desc
.MiscFlags
= 0;
23655 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, (ID3D11Query
**)&query
);
23656 ok(hr
== S_OK
, "Failed to create query, hr %#x.\n", hr
);
23657 ID3D11DeviceContext_Begin(context
, query
);
23659 set_quad_color(&test_context
, &white
);
23660 for (i
= 0; i
< ARRAY_SIZE(constant
.tess_factors
); ++i
)
23661 constant
.tess_factors
[i
] = 2.0f
;
23662 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
23663 ID3D11DeviceContext_Draw(context
, 4, 0);
23664 check_texture_color(test_context
.backbuffer
, 0xffffffff, 0);
23666 set_quad_color(&test_context
, &green
);
23667 constant
.tess_factors
[0] = 0.0f
; /* A patch is discarded. */
23668 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
23669 ID3D11DeviceContext_Draw(context
, 4, 0);
23670 check_texture_color(test_context
.backbuffer
, 0xffffffff, 0);
23672 ID3D11DeviceContext_End(context
, query
);
23673 get_query_data(context
, query
, &so_statistics
, sizeof(so_statistics
));
23674 ok(so_statistics
.NumPrimitivesWritten
== 8, "Got unexpected primitives written %u.\n",
23675 (unsigned int)so_statistics
.NumPrimitivesWritten
);
23676 ok(so_statistics
.PrimitivesStorageNeeded
== 8, "Got unexpected primitives storage needed %u.\n",
23677 (unsigned int)so_statistics
.PrimitivesStorageNeeded
);
23678 ID3D11DeviceContext_Begin(context
, query
);
23680 constant
.tess_factors
[0] = 5.0f
;
23681 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
23682 ID3D11DeviceContext_Draw(context
, 4, 0);
23683 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
23685 ID3D11DeviceContext_End(context
, query
);
23686 get_query_data(context
, query
, &so_statistics
, sizeof(so_statistics
));
23687 ok(so_statistics
.NumPrimitivesWritten
== 11, "Got unexpected primitives written %u.\n",
23688 (unsigned int)so_statistics
.NumPrimitivesWritten
);
23689 ok(so_statistics
.PrimitivesStorageNeeded
== 11, "Got unexpected primitives storage needed %u.\n",
23690 (unsigned int)so_statistics
.PrimitivesStorageNeeded
);
23691 ID3D11Asynchronous_Release(query
);
23693 ID3D11Buffer_Release(so_buffer
);
23694 ID3D11GeometryShader_Release(gs
);
23695 ID3D11DomainShader_Release(ds
);
23696 ID3D11HullShader_Release(hs
);
23697 ID3D11Buffer_Release(cb
);
23698 release_test_context(&test_context
);
23701 #define check_so_desc(a, b, c, d, e, f, g, h) check_so_desc_(__LINE__, a, b, c, d, e, f, g, h)
23702 static void check_so_desc_(unsigned int line
, ID3D11Device
*device
,
23703 const DWORD
*code
, size_t code_size
, const D3D11_SO_DECLARATION_ENTRY
*entry
,
23704 unsigned int entry_count
, unsigned int *strides
, unsigned int stride_count
,
23705 unsigned int rasterizer_stream
)
23707 ID3D11GeometryShader
*gs
;
23710 hr
= ID3D11Device_CreateGeometryShaderWithStreamOutput(device
, code
, code_size
,
23711 entry
, entry_count
, strides
, stride_count
, rasterizer_stream
, NULL
, &gs
);
23712 ok_(__FILE__
, line
)(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
23714 ID3D11GeometryShader_Release(gs
);
23717 #define check_invalid_so_desc(a, b, c, d, e, f, g, h) check_invalid_so_desc_(__LINE__, a, b, c, d, e, f, g, h)
23718 static void check_invalid_so_desc_(unsigned int line
, ID3D11Device
*device
,
23719 const DWORD
*code
, size_t code_size
, const D3D11_SO_DECLARATION_ENTRY
*entry
,
23720 unsigned int entry_count
, unsigned int *strides
, unsigned int stride_count
,
23721 unsigned int rasterizer_stream
)
23723 ID3D11GeometryShader
*gs
= (ID3D11GeometryShader
*)0xdeadbeef;
23726 hr
= ID3D11Device_CreateGeometryShaderWithStreamOutput(device
, code
, code_size
,
23727 entry
, entry_count
, strides
, stride_count
, rasterizer_stream
, NULL
, &gs
);
23728 ok_(__FILE__
, line
)(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
23729 ok_(__FILE__
, line
)(!gs
, "Got unexpected geometry shader %p.\n", gs
);
23731 ID3D11GeometryShader_Release(gs
);
23734 static void test_stream_output(void)
23736 UINT stride
[D3D11_SO_BUFFER_SLOT_COUNT
];
23737 struct d3d11_test_context test_context
;
23738 unsigned int i
, count
;
23739 ID3D11Device
*device
;
23741 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
23742 static const DWORD vs_code
[] =
23747 float4 position
: SV_Position
;
23748 float4 attrib1
: ATTRIB1
;
23749 float3 attrib2
: attrib2
;
23750 float2 attrib3
: ATTriB3
;
23751 float attrib4
: ATTRIB4
;
23754 void main(in data i
, out data o
)
23759 0x43425844, 0x3f5b621f, 0x8f390786, 0x7235c8d6, 0xc1181ad3, 0x00000001, 0x00000278, 0x00000003,
23760 0x0000002c, 0x000000d8, 0x00000184, 0x4e475349, 0x000000a4, 0x00000005, 0x00000008, 0x00000080,
23761 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x0000008c, 0x00000001, 0x00000000,
23762 0x00000003, 0x00000001, 0x00000f0f, 0x00000093, 0x00000002, 0x00000000, 0x00000003, 0x00000002,
23763 0x00000707, 0x0000009a, 0x00000003, 0x00000000, 0x00000003, 0x00000003, 0x00000303, 0x0000008c,
23764 0x00000004, 0x00000000, 0x00000003, 0x00000004, 0x00000101, 0x505f5653, 0x7469736f, 0x006e6f69,
23765 0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254, 0xababab00, 0x4e47534f, 0x000000a4,
23766 0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
23767 0x0000008c, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x00000093, 0x00000002,
23768 0x00000000, 0x00000003, 0x00000002, 0x00000807, 0x0000009a, 0x00000003, 0x00000000, 0x00000003,
23769 0x00000003, 0x00000c03, 0x0000008c, 0x00000004, 0x00000000, 0x00000003, 0x00000003, 0x00000b04,
23770 0x505f5653, 0x7469736f, 0x006e6f69, 0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254,
23771 0xababab00, 0x52444853, 0x000000ec, 0x00010040, 0x0000003b, 0x0300005f, 0x001010f2, 0x00000000,
23772 0x0300005f, 0x001010f2, 0x00000001, 0x0300005f, 0x00101072, 0x00000002, 0x0300005f, 0x00101032,
23773 0x00000003, 0x0300005f, 0x00101012, 0x00000004, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
23774 0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x00102072, 0x00000002, 0x03000065, 0x00102032,
23775 0x00000003, 0x03000065, 0x00102042, 0x00000003, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46,
23776 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001, 0x05000036, 0x00102072,
23777 0x00000002, 0x00101246, 0x00000002, 0x05000036, 0x00102032, 0x00000003, 0x00101046, 0x00000003,
23778 0x05000036, 0x00102042, 0x00000003, 0x0010100a, 0x00000004, 0x0100003e,
23780 static const DWORD gs_code
[] =
23785 float4 position
: SV_Position
;
23786 float4 attrib1
: ATTRIB1
;
23787 float3 attrib2
: attrib2
;
23788 float2 attrib3
: ATTriB3
;
23789 float attrib4
: ATTRIB4
;
23792 [maxvertexcount(1)]
23793 void main(point data i
[1], inout PointStream
<data
> o
)
23798 0x43425844, 0x59c61884, 0x3eef167b, 0x82618c33, 0x243cb630, 0x00000001, 0x000002a0, 0x00000003,
23799 0x0000002c, 0x000000d8, 0x00000184, 0x4e475349, 0x000000a4, 0x00000005, 0x00000008, 0x00000080,
23800 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x0000008c, 0x00000001, 0x00000000,
23801 0x00000003, 0x00000001, 0x00000f0f, 0x00000093, 0x00000002, 0x00000000, 0x00000003, 0x00000002,
23802 0x00000707, 0x0000009a, 0x00000003, 0x00000000, 0x00000003, 0x00000003, 0x00000303, 0x0000008c,
23803 0x00000004, 0x00000000, 0x00000003, 0x00000003, 0x00000404, 0x505f5653, 0x7469736f, 0x006e6f69,
23804 0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254, 0xababab00, 0x4e47534f, 0x000000a4,
23805 0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
23806 0x0000008c, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x00000093, 0x00000002,
23807 0x00000000, 0x00000003, 0x00000002, 0x00000807, 0x0000009a, 0x00000003, 0x00000000, 0x00000003,
23808 0x00000003, 0x00000c03, 0x0000008c, 0x00000004, 0x00000000, 0x00000003, 0x00000003, 0x00000b04,
23809 0x505f5653, 0x7469736f, 0x006e6f69, 0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254,
23810 0xababab00, 0x52444853, 0x00000114, 0x00020040, 0x00000045, 0x05000061, 0x002010f2, 0x00000001,
23811 0x00000000, 0x00000001, 0x0400005f, 0x002010f2, 0x00000001, 0x00000001, 0x0400005f, 0x00201072,
23812 0x00000001, 0x00000002, 0x0400005f, 0x00201032, 0x00000001, 0x00000003, 0x0400005f, 0x00201042,
23813 0x00000001, 0x00000003, 0x0100085d, 0x0100085c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
23814 0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x00102072, 0x00000002, 0x03000065, 0x00102032,
23815 0x00000003, 0x03000065, 0x00102042, 0x00000003, 0x0200005e, 0x00000001, 0x06000036, 0x001020f2,
23816 0x00000000, 0x00201e46, 0x00000000, 0x00000000, 0x06000036, 0x001020f2, 0x00000001, 0x00201e46,
23817 0x00000000, 0x00000001, 0x06000036, 0x00102072, 0x00000002, 0x00201246, 0x00000000, 0x00000002,
23818 0x06000036, 0x00102072, 0x00000003, 0x00201246, 0x00000000, 0x00000003, 0x01000013, 0x0100003e,
23820 static const D3D11_SO_DECLARATION_ENTRY so_declaration
[] =
23822 {0, "SV_Position", 0, 0, 4, 0},
23824 static const D3D11_SO_DECLARATION_ENTRY invalid_gap_declaration
[] =
23826 {0, "SV_Position", 0, 0, 4, 0},
23827 {0, NULL
, 0, 0, 0, 0},
23829 static const D3D11_SO_DECLARATION_ENTRY valid_so_declarations
[][12] =
23831 /* SemanticName and SemanticIndex */
23833 {0, "sv_position", 0, 0, 4, 0},
23834 {0, "attrib", 1, 0, 4, 0},
23837 {0, "sv_position", 0, 0, 4, 0},
23838 {0, "ATTRIB", 1, 0, 4, 0},
23842 {0, "SV_POSITION", 0, 0, 4, 0},
23843 {0, NULL
, 0, 0, 8, 0},
23844 {0, "ATTRIB", 1, 0, 4, 0},
23847 {0, "SV_POSITION", 0, 0, 4, 0},
23848 {0, NULL
, 0, 0, 4, 0},
23849 {0, NULL
, 0, 0, 4, 0},
23850 {0, "ATTRIB", 1, 0, 4, 0},
23852 /* ComponentCount */
23854 {0, "ATTRIB", 1, 0, 4, 0},
23857 {0, "ATTRIB", 2, 0, 3, 0},
23860 {0, "ATTRIB", 3, 0, 2, 0},
23863 {0, "ATTRIB", 4, 0, 1, 0},
23865 /* ComponentIndex */
23867 {0, "ATTRIB", 1, 1, 3, 0},
23870 {0, "ATTRIB", 1, 2, 2, 0},
23873 {0, "ATTRIB", 1, 3, 1, 0},
23876 {0, "ATTRIB", 3, 1, 1, 0},
23880 {0, "attrib", 1, 0, 4, 0},
23883 {0, "attrib", 1, 0, 4, 1},
23886 {0, "attrib", 1, 0, 4, 2},
23889 {0, "attrib", 1, 0, 4, 3},
23892 {0, "attrib", 1, 0, 4, 0},
23893 {0, "attrib", 2, 0, 3, 1},
23894 {0, NULL
, 0, 0, 1, 1},
23895 {0, "attrib", 3, 0, 2, 2},
23896 {0, NULL
, 0, 0, 2, 2},
23897 {0, "attrib", 4, 0, 1, 3},
23898 {0, NULL
, 0, 0, 7, 3},
23901 {0, "attrib", 1, 0, 4, 0},
23902 {0, "attrib", 2, 0, 3, 1},
23903 {0, NULL
, 0, 0, 1, 1},
23904 {0, "attrib", 3, 0, 2, 2},
23905 {0, NULL
, 0, 0, 1, 2},
23906 {0, NULL
, 0, 0, 1, 2},
23907 {0, "attrib", 4, 0, 1, 3},
23908 {0, NULL
, 0, 0, 3, 3},
23909 {0, NULL
, 0, 0, 1, 3},
23910 {0, NULL
, 0, 0, 1, 3},
23911 {0, NULL
, 0, 0, 1, 3},
23912 {0, NULL
, 0, 0, 1, 3},
23915 {0, "attrib", 1, 0, 4, 0},
23916 {0, "attrib", 2, 0, 3, 0},
23917 {0, "attrib", 3, 0, 2, 0},
23918 {0, NULL
, 0, 0, 1, 0},
23919 {0, "attrib", 4, 0, 1, 0},
23922 {0, "attrib", 1, 0, 4, 0},
23923 {0, "attrib", 2, 0, 3, 0},
23924 {0, "attrib", 3, 0, 2, 3},
23925 {0, NULL
, 0, 0, 1, 3},
23926 {0, "attrib", 4, 0, 1, 3},
23928 /* Multiple occurrences of the same output */
23930 {0, "ATTRIB", 1, 0, 2, 0},
23931 {0, "ATTRIB", 1, 2, 2, 1},
23934 {0, "ATTRIB", 1, 0, 1, 0},
23935 {0, "ATTRIB", 1, 1, 3, 0},
23938 static const D3D11_SO_DECLARATION_ENTRY invalid_so_declarations
[][12] =
23940 /* SemanticName and SemanticIndex */
23942 {0, "SV_Position", 0, 0, 4, 0},
23943 {0, "ATTRIB", 0, 0, 4, 0},
23946 {0, "sv_position", 0, 0, 4, 0},
23947 {0, "ATTRIB_", 1, 0, 4, 0},
23951 {0, "SV_POSITION", 0, 0, 4, 0},
23952 {0, NULL
, 0, 1, 8, 0},
23953 {0, "ATTRIB", 1, 0, 4, 0},
23956 {0, "SV_POSITION", 0, 0, 4, 0},
23957 {0, NULL
, 1, 0, 8, 0},
23958 {0, "ATTRIB", 1, 0, 4, 0},
23960 /* Buffer stride */
23962 {0, "SV_POSITION", 0, 0, 4, 0},
23963 {0, NULL
, 0, 0, 8, 0},
23964 {0, NULL
, 0, 0, 8, 0},
23965 {0, "ATTRIB", 1, 0, 4, 0},
23967 /* ComponentCount */
23969 {0, "ATTRIB", 2, 0, 5, 0},
23972 {0, "ATTRIB", 2, 0, 4, 0},
23975 {0, "ATTRIB", 3, 0, 3, 0},
23978 {0, "ATTRIB", 4, 0, 2, 0},
23980 /* ComponentIndex */
23982 {0, "ATTRIB", 1, 1, 4, 0},
23985 {0, "ATTRIB", 1, 2, 3, 0},
23988 {0, "ATTRIB", 1, 3, 2, 0},
23991 {0, "ATTRIB", 1, 4, 0, 0},
23994 {0, "ATTRIB", 1, 4, 1, 0},
23997 {0, "ATTRIB", 3, 2, 1, 0},
24000 {0, "ATTRIB", 3, 2, 0, 0},
24004 {0, "attrib", 1, 0, 4, 4},
24007 {0, "attrib", 1, 0, 4, 4},
24010 {0, "attrib", 1, 0, 4, 4},
24013 {0, "attrib", 1, 0, 4, 4},
24016 {0, "attrib", 1, 0, 4, 0},
24017 {0, "attrib", 2, 0, 3, 1},
24018 {0, NULL
, 0, 0, 1, 1},
24019 {0, "attrib", 3, 0, 2, 2},
24020 {0, NULL
, 0, 0, 2, 2},
24021 {0, "attrib", 4, 0, 1, 3},
24022 {0, NULL
, 0, 0, 3, 4},
24025 {0, "attrib", 1, 0, 4, 0},
24026 {0, "attrib", 2, 0, 3, 0},
24027 {0, "attrib", 3, 0, 2, 0},
24028 {0, NULL
, 0, 0, 1, 0},
24029 {0, "attrib", 4, 0, 1, 0},
24030 {0, NULL
, 0, 0, 3, 3},
24031 {0, NULL
, 0, 0, 1, 3},
24032 {0, NULL
, 0, 0, 1, 3},
24033 {0, NULL
, 0, 0, 1, 3},
24034 {0, NULL
, 0, 0, 1, 3},
24037 {0, "attrib", 1, 0, 4, 0},
24038 {0, NULL
, 0, 0, 3, 1},
24039 {0, NULL
, 0, 0, 1, 1},
24040 {0, NULL
, 0, 0, 1, 2},
24041 {0, "attrib", 2, 0, 3, 3},
24042 {0, NULL
, 0, 0, 1, 3},
24045 {0, "attrib", 2, 0, 3, 3},
24046 {0, NULL
, 0, 0, 3, 1},
24047 {0, NULL
, 0, 0, 1, 3},
24048 {0, "attrib", 1, 0, 4, 0},
24049 {0, NULL
, 0, 0, 1, 2},
24050 {0, NULL
, 0, 0, 1, 1},
24054 {1, "attrib", 1, 0, 4, 0},
24057 {4, "attrib", 1, 0, 4, 0},
24059 /* Multiple occurrences of the same output */
24061 {0, "ATTRIB", 1, 0, 4, 0},
24062 {0, "ATTRIB", 1, 0, 4, 1},
24065 {0, "ATTRIB", 1, 0, 4, 0},
24066 {0, "ATTRIB", 1, 0, 3, 0},
24070 if (!init_test_context(&test_context
, &feature_level
))
24073 device
= test_context
.device
;
24075 for (i
= 0; i
< ARRAY_SIZE(stride
); ++i
)
24078 check_so_desc(device
, gs_code
, sizeof(gs_code
), NULL
, 0, NULL
, 0, D3D11_SO_NO_RASTERIZED_STREAM
);
24079 check_so_desc(device
, gs_code
, sizeof(gs_code
), NULL
, 0, stride
, 1, D3D11_SO_NO_RASTERIZED_STREAM
);
24080 check_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
24081 NULL
, 0, D3D11_SO_NO_RASTERIZED_STREAM
);
24082 check_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
24083 stride
, 1, D3D11_SO_NO_RASTERIZED_STREAM
);
24085 check_so_desc(device
, vs_code
, sizeof(vs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
24086 NULL
, 0, D3D11_SO_NO_RASTERIZED_STREAM
);
24087 check_so_desc(device
, vs_code
, sizeof(vs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
24088 stride
, 1, D3D11_SO_NO_RASTERIZED_STREAM
);
24090 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, 0,
24091 stride
, 1, D3D11_SO_NO_RASTERIZED_STREAM
);
24092 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
),
24093 invalid_gap_declaration
, ARRAY_SIZE(invalid_gap_declaration
),
24094 stride
, 1, D3D11_SO_NO_RASTERIZED_STREAM
);
24096 check_invalid_so_desc(device
, vs_code
, sizeof(vs_code
), so_declaration
, 0,
24097 NULL
, 0, D3D11_SO_NO_RASTERIZED_STREAM
);
24098 check_invalid_so_desc(device
, vs_code
, sizeof(vs_code
), NULL
, 0,
24099 NULL
, 0, D3D11_SO_NO_RASTERIZED_STREAM
);
24101 for (i
= 0; i
< ARRAY_SIZE(valid_so_declarations
); ++i
)
24103 unsigned int max_output_slot
= 0;
24104 for (count
= 0; count
< ARRAY_SIZE(valid_so_declarations
[i
]); ++count
)
24106 const D3D11_SO_DECLARATION_ENTRY
*e
= &valid_so_declarations
[i
][count
];
24107 max_output_slot
= max(max_output_slot
, e
->OutputSlot
);
24108 if (!e
->Stream
&& !e
->SemanticName
&& !e
->SemanticIndex
&& !e
->ComponentCount
)
24112 /* Buffer strides are required for all buffers. */
24113 if (!max_output_slot
)
24115 check_so_desc(device
, gs_code
, sizeof(gs_code
), valid_so_declarations
[i
], count
,
24116 NULL
, 0, D3D11_SO_NO_RASTERIZED_STREAM
);
24117 check_so_desc(device
, gs_code
, sizeof(gs_code
), valid_so_declarations
[i
], count
,
24118 stride
, 1, D3D11_SO_NO_RASTERIZED_STREAM
);
24119 check_so_desc(device
, gs_code
, sizeof(gs_code
), valid_so_declarations
[i
], count
,
24120 stride
, 2, D3D11_SO_NO_RASTERIZED_STREAM
);
24121 check_so_desc(device
, gs_code
, sizeof(gs_code
), valid_so_declarations
[i
], count
,
24122 stride
, 3, D3D11_SO_NO_RASTERIZED_STREAM
);
24123 check_so_desc(device
, gs_code
, sizeof(gs_code
), valid_so_declarations
[i
], count
,
24124 stride
, 4, D3D11_SO_NO_RASTERIZED_STREAM
);
24128 check_so_desc(device
, gs_code
, sizeof(gs_code
), valid_so_declarations
[i
], count
,
24129 NULL
, 0, D3D11_SO_NO_RASTERIZED_STREAM
);
24130 check_so_desc(device
, gs_code
, sizeof(gs_code
), valid_so_declarations
[i
], count
,
24131 stride
, max_output_slot
+ 1, D3D11_SO_NO_RASTERIZED_STREAM
);
24135 for (i
= 0; i
< ARRAY_SIZE(invalid_so_declarations
); ++i
)
24137 for (count
= 0; count
< ARRAY_SIZE(invalid_so_declarations
[i
]); ++count
)
24139 const D3D11_SO_DECLARATION_ENTRY
*e
= &invalid_so_declarations
[i
][count
];
24140 if (!e
->Stream
&& !e
->SemanticName
&& !e
->SemanticIndex
&& !e
->ComponentCount
)
24144 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), invalid_so_declarations
[i
], count
,
24145 stride
, 1, D3D11_SO_NO_RASTERIZED_STREAM
);
24146 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), invalid_so_declarations
[i
], count
,
24147 stride
, 2, D3D11_SO_NO_RASTERIZED_STREAM
);
24148 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), invalid_so_declarations
[i
], count
,
24149 stride
, 3, D3D11_SO_NO_RASTERIZED_STREAM
);
24150 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), invalid_so_declarations
[i
], count
,
24151 stride
, 4, D3D11_SO_NO_RASTERIZED_STREAM
);
24154 /* Buffer strides */
24156 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
24157 &stride
[1], 1, D3D11_SO_NO_RASTERIZED_STREAM
);
24158 check_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
24159 stride
, 2, D3D11_SO_NO_RASTERIZED_STREAM
);
24161 check_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
24162 stride
, 2, D3D11_SO_NO_RASTERIZED_STREAM
);
24164 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
24165 stride
, 1, D3D11_SO_NO_RASTERIZED_STREAM
);
24167 /* Rasterizer stream */
24168 for (i
= 0; i
< D3D11_SO_STREAM_COUNT
; ++i
)
24169 check_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
), NULL
, 0, i
);
24170 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
24171 NULL
, 0, D3D11_SO_STREAM_COUNT
);
24173 release_test_context(&test_context
);
24176 static void test_fl10_stream_output_desc(void)
24178 UINT stride
[D3D11_SO_BUFFER_SLOT_COUNT
];
24179 struct d3d11_test_context test_context
;
24180 unsigned int i
, count
;
24181 ID3D11Device
*device
;
24183 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_10_0
;
24184 static const DWORD vs_code
[] =
24189 float4 position
: SV_Position
;
24190 float4 attrib1
: ATTRIB1
;
24191 float3 attrib2
: attrib2
;
24192 float2 attrib3
: ATTriB3
;
24193 float attrib4
: ATTRIB4
;
24196 void main(in data i
, out data o
)
24201 0x43425844, 0x3f5b621f, 0x8f390786, 0x7235c8d6, 0xc1181ad3, 0x00000001, 0x00000278, 0x00000003,
24202 0x0000002c, 0x000000d8, 0x00000184, 0x4e475349, 0x000000a4, 0x00000005, 0x00000008, 0x00000080,
24203 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x0000008c, 0x00000001, 0x00000000,
24204 0x00000003, 0x00000001, 0x00000f0f, 0x00000093, 0x00000002, 0x00000000, 0x00000003, 0x00000002,
24205 0x00000707, 0x0000009a, 0x00000003, 0x00000000, 0x00000003, 0x00000003, 0x00000303, 0x0000008c,
24206 0x00000004, 0x00000000, 0x00000003, 0x00000004, 0x00000101, 0x505f5653, 0x7469736f, 0x006e6f69,
24207 0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254, 0xababab00, 0x4e47534f, 0x000000a4,
24208 0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
24209 0x0000008c, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x00000093, 0x00000002,
24210 0x00000000, 0x00000003, 0x00000002, 0x00000807, 0x0000009a, 0x00000003, 0x00000000, 0x00000003,
24211 0x00000003, 0x00000c03, 0x0000008c, 0x00000004, 0x00000000, 0x00000003, 0x00000003, 0x00000b04,
24212 0x505f5653, 0x7469736f, 0x006e6f69, 0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254,
24213 0xababab00, 0x52444853, 0x000000ec, 0x00010040, 0x0000003b, 0x0300005f, 0x001010f2, 0x00000000,
24214 0x0300005f, 0x001010f2, 0x00000001, 0x0300005f, 0x00101072, 0x00000002, 0x0300005f, 0x00101032,
24215 0x00000003, 0x0300005f, 0x00101012, 0x00000004, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
24216 0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x00102072, 0x00000002, 0x03000065, 0x00102032,
24217 0x00000003, 0x03000065, 0x00102042, 0x00000003, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46,
24218 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001, 0x05000036, 0x00102072,
24219 0x00000002, 0x00101246, 0x00000002, 0x05000036, 0x00102032, 0x00000003, 0x00101046, 0x00000003,
24220 0x05000036, 0x00102042, 0x00000003, 0x0010100a, 0x00000004, 0x0100003e,
24222 static const DWORD gs_code
[] =
24227 float4 position
: SV_Position
;
24228 float4 attrib1
: ATTRIB1
;
24229 float3 attrib2
: attrib2
;
24230 float2 attrib3
: ATTriB3
;
24231 float attrib4
: ATTRIB4
;
24234 [maxvertexcount(1)]
24235 void main(point data i
[1], inout PointStream
<data
> o
)
24240 0x43425844, 0x59c61884, 0x3eef167b, 0x82618c33, 0x243cb630, 0x00000001, 0x000002a0, 0x00000003,
24241 0x0000002c, 0x000000d8, 0x00000184, 0x4e475349, 0x000000a4, 0x00000005, 0x00000008, 0x00000080,
24242 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x0000008c, 0x00000001, 0x00000000,
24243 0x00000003, 0x00000001, 0x00000f0f, 0x00000093, 0x00000002, 0x00000000, 0x00000003, 0x00000002,
24244 0x00000707, 0x0000009a, 0x00000003, 0x00000000, 0x00000003, 0x00000003, 0x00000303, 0x0000008c,
24245 0x00000004, 0x00000000, 0x00000003, 0x00000003, 0x00000404, 0x505f5653, 0x7469736f, 0x006e6f69,
24246 0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254, 0xababab00, 0x4e47534f, 0x000000a4,
24247 0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
24248 0x0000008c, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x00000093, 0x00000002,
24249 0x00000000, 0x00000003, 0x00000002, 0x00000807, 0x0000009a, 0x00000003, 0x00000000, 0x00000003,
24250 0x00000003, 0x00000c03, 0x0000008c, 0x00000004, 0x00000000, 0x00000003, 0x00000003, 0x00000b04,
24251 0x505f5653, 0x7469736f, 0x006e6f69, 0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254,
24252 0xababab00, 0x52444853, 0x00000114, 0x00020040, 0x00000045, 0x05000061, 0x002010f2, 0x00000001,
24253 0x00000000, 0x00000001, 0x0400005f, 0x002010f2, 0x00000001, 0x00000001, 0x0400005f, 0x00201072,
24254 0x00000001, 0x00000002, 0x0400005f, 0x00201032, 0x00000001, 0x00000003, 0x0400005f, 0x00201042,
24255 0x00000001, 0x00000003, 0x0100085d, 0x0100085c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
24256 0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x00102072, 0x00000002, 0x03000065, 0x00102032,
24257 0x00000003, 0x03000065, 0x00102042, 0x00000003, 0x0200005e, 0x00000001, 0x06000036, 0x001020f2,
24258 0x00000000, 0x00201e46, 0x00000000, 0x00000000, 0x06000036, 0x001020f2, 0x00000001, 0x00201e46,
24259 0x00000000, 0x00000001, 0x06000036, 0x00102072, 0x00000002, 0x00201246, 0x00000000, 0x00000002,
24260 0x06000036, 0x00102072, 0x00000003, 0x00201246, 0x00000000, 0x00000003, 0x01000013, 0x0100003e,
24262 static const D3D11_SO_DECLARATION_ENTRY so_declaration
[] =
24264 {0, "SV_Position", 0, 0, 4, 0},
24266 static const D3D11_SO_DECLARATION_ENTRY invalid_gap_declaration
[] =
24268 {0, "SV_Position", 0, 0, 4, 0},
24269 {0, NULL
, 0, 0, 0, 0},
24271 static const D3D11_SO_DECLARATION_ENTRY valid_so_declarations
[][12] =
24275 {0, "SV_POSITION", 0, 0, 4, 0},
24276 {0, NULL
, 0, 0, 8, 0},
24277 {0, "ATTRIB", 1, 0, 4, 0},
24280 {0, "SV_POSITION", 0, 0, 4, 0},
24281 {0, NULL
, 0, 0, 4, 0},
24282 {0, NULL
, 0, 0, 4, 0},
24283 {0, "ATTRIB", 1, 0, 4, 0},
24287 {0, "attrib", 1, 0, 4, 0},
24288 {0, "attrib", 2, 0, 3, 0},
24289 {0, "attrib", 3, 0, 2, 0},
24290 {0, "attrib", 4, 0, 1, 0},
24293 {0, "attrib", 1, 0, 4, 0},
24294 {0, "attrib", 2, 0, 3, 1},
24295 {0, "attrib", 3, 0, 2, 2},
24296 {0, "attrib", 4, 0, 1, 3},
24299 {0, "attrib", 1, 0, 4, 0},
24300 {0, "attrib", 2, 0, 3, 3},
24303 {0, "attrib", 1, 0, 4, 0},
24304 {0, "attrib", 2, 0, 3, 0},
24305 {0, "attrib", 3, 0, 2, 0},
24306 {0, NULL
, 0, 0, 1, 0},
24307 {0, "attrib", 4, 0, 1, 0},
24309 /* Multiple occurrences of the same output */
24311 {0, "ATTRIB", 1, 0, 2, 0},
24312 {0, "ATTRIB", 1, 2, 2, 1},
24315 {0, "ATTRIB", 1, 0, 1, 0},
24316 {0, "ATTRIB", 1, 1, 3, 0},
24319 static const D3D11_SO_DECLARATION_ENTRY invalid_so_declarations
[][12] =
24323 {0, "attrib", 1, 0, 4, 0},
24324 {0, NULL
, 0, 0, 4, 0},
24325 {0, "attrib", 4, 0, 1, 3},
24328 {0, "attrib", 1, 0, 4, 0},
24329 {0, NULL
, 0, 0, 4, 0},
24330 {0, NULL
, 0, 0, 4, 0},
24331 {0, "attrib", 4, 0, 1, 3},
24334 {0, "attrib", 1, 0, 4, 0},
24335 {0, "attrib", 2, 0, 3, 0},
24336 {0, "attrib", 3, 0, 2, 0},
24337 {0, "attrib", 4, 0, 1, 1},
24340 {0, "attrib", 1, 0, 4, 0},
24341 {0, "attrib", 2, 0, 3, 0},
24342 {0, "attrib", 3, 0, 2, 3},
24343 {0, NULL
, 0, 0, 1, 3},
24344 {0, "attrib", 4, 0, 1, 3},
24347 {0, "attrib", 1, 0, 4, 0},
24348 {0, "attrib", 1, 0, 3, 1},
24349 {0, "attrib", 1, 0, 2, 2},
24350 {0, "attrib", 1, 0, 1, 3},
24351 {0, NULL
, 0, 0, 3, 3},
24355 if (!init_test_context(&test_context
, &feature_level
))
24358 device
= test_context
.device
;
24360 for (i
= 0; i
< ARRAY_SIZE(stride
); ++i
)
24363 check_so_desc(device
, gs_code
, sizeof(gs_code
), NULL
, 0, NULL
, 0, 0);
24364 todo_wine
check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), NULL
, 0, stride
, 1, 0);
24365 check_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
), NULL
, 0, 0);
24366 check_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
), stride
, 1, 0);
24368 check_so_desc(device
, vs_code
, sizeof(vs_code
), so_declaration
, ARRAY_SIZE(so_declaration
), NULL
, 0, 0);
24369 check_so_desc(device
, vs_code
, sizeof(vs_code
), so_declaration
, ARRAY_SIZE(so_declaration
), stride
, 1, 0);
24371 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, 0, stride
, 1, 0);
24372 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
),
24373 invalid_gap_declaration
, ARRAY_SIZE(invalid_gap_declaration
), stride
, 1, 0);
24374 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
),
24375 invalid_gap_declaration
, ARRAY_SIZE(invalid_gap_declaration
), NULL
, 0, 0);
24377 check_invalid_so_desc(device
, vs_code
, sizeof(vs_code
), so_declaration
, 0, NULL
, 0, 0);
24378 check_invalid_so_desc(device
, vs_code
, sizeof(vs_code
), NULL
, 0, NULL
, 0, 0);
24380 for (i
= 0; i
< ARRAY_SIZE(valid_so_declarations
); ++i
)
24382 for (count
= 0; count
< ARRAY_SIZE(valid_so_declarations
[i
]); ++count
)
24384 const D3D11_SO_DECLARATION_ENTRY
*e
= &valid_so_declarations
[i
][count
];
24385 if (!e
->Stream
&& !e
->SemanticName
&& !e
->SemanticIndex
&& !e
->ComponentCount
)
24389 check_so_desc(device
, gs_code
, sizeof(gs_code
), valid_so_declarations
[i
], count
, NULL
, 0, 0);
24392 for (i
= 0; i
< ARRAY_SIZE(invalid_so_declarations
); ++i
)
24394 for (count
= 0; count
< ARRAY_SIZE(invalid_so_declarations
[i
]); ++count
)
24396 const D3D11_SO_DECLARATION_ENTRY
*e
= &invalid_so_declarations
[i
][count
];
24397 if (!e
->Stream
&& !e
->SemanticName
&& !e
->SemanticIndex
&& !e
->ComponentCount
)
24401 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), invalid_so_declarations
[i
], count
,
24403 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), invalid_so_declarations
[i
], count
,
24405 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), invalid_so_declarations
[i
], count
,
24407 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), invalid_so_declarations
[i
], count
,
24411 /* Buffer strides */
24413 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
24415 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
24418 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
24421 /* Rasterizer stream */
24422 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
24423 NULL
, 0, D3D11_SO_NO_RASTERIZED_STREAM
);
24424 for (i
= 1; i
< D3D11_SO_STREAM_COUNT
; ++i
)
24425 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
24427 check_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
), NULL
, 0, 0);
24429 release_test_context(&test_context
);
24432 static void test_stream_output_resume(void)
24434 struct d3d11_test_context test_context
;
24435 ID3D11Buffer
*cb
, *so_buffer
, *buffer
;
24436 unsigned int i
, j
, idx
, offset
;
24437 ID3D11DeviceContext
*context
;
24438 struct resource_readback rb
;
24439 ID3D11GeometryShader
*gs
;
24440 const struct vec4
*data
;
24441 ID3D11Device
*device
;
24444 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
24445 static const DWORD gs_code
[] =
24452 float4 position
: SV_POSITION
;
24457 float4 position
: SV_POSITION
;
24458 float4 so_output
: so_output
;
24461 [maxvertexcount(3)]
24462 void main(triangle vertex input
[3], inout PointStream
<element
> output
)
24465 o
.so_output
= constant
;
24466 o
.position
= input
[0].position
;
24468 o
.position
= input
[1].position
;
24470 o
.position
= input
[2].position
;
24474 0x43425844, 0x4c16e500, 0xa0dc6126, 0x261156f3, 0xf01eedc8, 0x00000001, 0x000001b8, 0x00000003,
24475 0x0000002c, 0x00000060, 0x000000b8, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
24476 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49,
24477 0x4e47534f, 0x00000050, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
24478 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
24479 0x505f5653, 0x5449534f, 0x004e4f49, 0x6f5f6f73, 0x75707475, 0xabab0074, 0x52444853, 0x000000f8,
24480 0x00020040, 0x0000003e, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x05000061, 0x002010f2,
24481 0x00000003, 0x00000000, 0x00000001, 0x0100185d, 0x0100085c, 0x04000067, 0x001020f2, 0x00000000,
24482 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x0200005e, 0x00000003, 0x06000036, 0x001020f2,
24483 0x00000000, 0x00201e46, 0x00000000, 0x00000000, 0x06000036, 0x001020f2, 0x00000001, 0x00208e46,
24484 0x00000000, 0x00000000, 0x01000013, 0x06000036, 0x001020f2, 0x00000000, 0x00201e46, 0x00000001,
24485 0x00000000, 0x06000036, 0x001020f2, 0x00000001, 0x00208e46, 0x00000000, 0x00000000, 0x01000013,
24486 0x06000036, 0x001020f2, 0x00000000, 0x00201e46, 0x00000002, 0x00000000, 0x06000036, 0x001020f2,
24487 0x00000001, 0x00208e46, 0x00000000, 0x00000000, 0x01000013, 0x0100003e,
24489 static const D3D11_SO_DECLARATION_ENTRY so_declaration
[] =
24491 {0, "so_output", 0, 0, 4, 0},
24493 static const struct vec4 constants
[] =
24495 {0.5f
, 0.250f
, 0.0f
, 0.0f
},
24496 {0.0f
, 0.125f
, 0.0f
, 1.0f
},
24497 {1.0f
, 1.000f
, 1.0f
, 0.0f
}
24499 static const struct vec4 green
= {0.0f
, 1.0f
, 0.0f
, 1.0f
};
24500 static const struct vec4 white
= {1.0f
, 1.0f
, 1.0f
, 1.0f
};
24501 static const struct vec4 red
= {1.0f
, 0.0f
, 0.0f
, 1.0f
};
24503 if (!init_test_context(&test_context
, &feature_level
))
24506 device
= test_context
.device
;
24507 context
= test_context
.immediate_context
;
24509 hr
= ID3D11Device_CreateGeometryShaderWithStreamOutput(device
, gs_code
, sizeof(gs_code
),
24510 so_declaration
, ARRAY_SIZE(so_declaration
), NULL
, 0, D3D11_SO_NO_RASTERIZED_STREAM
, NULL
, &gs
);
24511 ok(SUCCEEDED(hr
), "Failed to create geometry shader with stream output, hr %#x.\n", hr
);
24513 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(constants
[0]), &constants
[0]);
24514 so_buffer
= create_buffer(device
, D3D11_BIND_STREAM_OUTPUT
, 1024, NULL
);
24516 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
24517 ID3D11DeviceContext_GSSetConstantBuffers(context
, 0, 1, &cb
);
24520 ID3D11DeviceContext_SOSetTargets(context
, 1, &so_buffer
, &offset
);
24522 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &white
.x
);
24523 check_texture_color(test_context
.backbuffer
, 0xffffffff, 0);
24525 draw_color_quad(&test_context
, &red
);
24526 check_texture_color(test_context
.backbuffer
, 0xffffffff, 0);
24528 ID3D11DeviceContext_GSSetShader(context
, NULL
, NULL
, 0);
24529 draw_color_quad(&test_context
, &green
);
24530 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
24532 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constants
[1], 0, 0);
24533 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
24534 draw_color_quad(&test_context
, &red
);
24535 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
24537 ID3D11DeviceContext_GSSetShader(context
, NULL
, NULL
, 0);
24538 draw_color_quad(&test_context
, &red
);
24539 check_texture_color(test_context
.backbuffer
, 0xff0000ff, 0);
24541 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constants
[2], 0, 0);
24542 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
24543 draw_color_quad(&test_context
, &white
);
24544 check_texture_color(test_context
.backbuffer
, 0xff0000ff, 0);
24546 ID3D11DeviceContext_GSSetShader(context
, NULL
, NULL
, 0);
24547 draw_color_quad(&test_context
, &green
);
24548 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
24551 ID3D11DeviceContext_SOSetTargets(context
, 1, &buffer
, &offset
);
24552 ID3D11DeviceContext_GSSetShader(context
, NULL
, NULL
, 0);
24553 draw_color_quad(&test_context
, &white
);
24554 check_texture_color(test_context
.backbuffer
, 0xffffffff, 0);
24557 get_buffer_readback(so_buffer
, &rb
);
24558 for (i
= 0; i
< ARRAY_SIZE(constants
); ++i
)
24560 for (j
= 0; j
< 6; ++j
) /* 2 triangles */
24562 data
= get_readback_vec4(&rb
, idx
++, 0);
24563 ok(compare_vec4(data
, &constants
[i
], 0),
24564 "Got unexpected result {%.8e, %.8e, %.8e, %.8e} at %u (%u, %u).\n",
24565 data
->x
, data
->y
, data
->z
, data
->w
, idx
, i
, j
);
24568 release_resource_readback(&rb
);
24570 ID3D11Buffer_Release(cb
);
24571 ID3D11Buffer_Release(so_buffer
);
24572 ID3D11GeometryShader_Release(gs
);
24573 release_test_context(&test_context
);
24576 static void test_stream_output_components(void)
24578 const D3D11_SO_DECLARATION_ENTRY
*current_so_declaration
;
24579 struct d3d11_test_context test_context
;
24580 ID3D11InputLayout
*input_layout
[2];
24581 ID3D11Buffer
*vb
[2], *so_buffer
;
24582 ID3D11DeviceContext
*context
;
24583 struct resource_readback rb
;
24584 unsigned int stride
, offset
;
24585 ID3D11GeometryShader
*gs
;
24586 ID3D11VertexShader
*vs
;
24587 ID3D11PixelShader
*ps
;
24588 ID3D11Device
*device
;
24589 const float *result
;
24593 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
24594 static const DWORD vs_code
[] =
24599 float4 position
: POSITION
;
24600 float4 color
: COLOR
;
24601 float4 color2
: COLOR2
;
24604 void main(in vertex i
, out vertex o
)
24609 0x43425844, 0x95991b76, 0x4898640b, 0xe36ad9d6, 0xfbfe78b4, 0x00000001, 0x00000194, 0x00000003,
24610 0x0000002c, 0x00000094, 0x000000fc, 0x4e475349, 0x00000060, 0x00000003, 0x00000008, 0x00000050,
24611 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000059, 0x00000000, 0x00000000,
24612 0x00000003, 0x00000001, 0x00000f0f, 0x00000059, 0x00000002, 0x00000000, 0x00000003, 0x00000002,
24613 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x00000060, 0x00000003,
24614 0x00000008, 0x00000050, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x00000059,
24615 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x00000059, 0x00000002, 0x00000000,
24616 0x00000003, 0x00000002, 0x0000000f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x52444853,
24617 0x00000090, 0x00010040, 0x00000024, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2,
24618 0x00000001, 0x0300005f, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x03000065,
24619 0x001020f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x05000036, 0x001020f2, 0x00000000,
24620 0x00101e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001, 0x05000036,
24621 0x001020f2, 0x00000002, 0x00101e46, 0x00000002, 0x0100003e,
24623 static const DWORD gs_code
[] =
24628 float4 position
: POSITION
;
24629 float4 color
: COLOR
;
24630 float4 color2
: COLOR2
;
24633 [maxvertexcount(1)]
24634 void main(point vertex input
[1], inout PointStream
<vertex
> output
)
24636 output
.Append(input
[0]);
24639 0x43425844, 0x218f7d27, 0x555fa7f1, 0x282c545f, 0x3989c843, 0x00000001, 0x000001c0, 0x00000003,
24640 0x0000002c, 0x00000094, 0x000000fc, 0x4e475349, 0x00000060, 0x00000003, 0x00000008, 0x00000050,
24641 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000059, 0x00000000, 0x00000000,
24642 0x00000003, 0x00000001, 0x00000f0f, 0x00000059, 0x00000002, 0x00000000, 0x00000003, 0x00000002,
24643 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x00000060, 0x00000003,
24644 0x00000008, 0x00000050, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x00000059,
24645 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x00000059, 0x00000002, 0x00000000,
24646 0x00000003, 0x00000002, 0x0000000f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x52444853,
24647 0x000000bc, 0x00020040, 0x0000002f, 0x0400005f, 0x002010f2, 0x00000001, 0x00000000, 0x0400005f,
24648 0x002010f2, 0x00000001, 0x00000001, 0x0400005f, 0x002010f2, 0x00000001, 0x00000002, 0x0100085d,
24649 0x0100085c, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000001, 0x03000065,
24650 0x001020f2, 0x00000002, 0x0200005e, 0x00000001, 0x06000036, 0x001020f2, 0x00000000, 0x00201e46,
24651 0x00000000, 0x00000000, 0x06000036, 0x001020f2, 0x00000001, 0x00201e46, 0x00000000, 0x00000001,
24652 0x06000036, 0x001020f2, 0x00000002, 0x00201e46, 0x00000000, 0x00000002, 0x01000013, 0x0100003e,
24654 static const DWORD ps_code
[] =
24657 float4
main(float4 position
: SV_Position
,
24658 float2 texcoord
: TEXCOORD
) : SV_Target
24660 return float4(position
.xy
, texcoord
);
24663 0x43425844, 0xa15616bc, 0x6862ab1c, 0x28b915c0, 0xdb0df67c, 0x00000001, 0x0000011c, 0x00000003,
24664 0x0000002c, 0x00000084, 0x000000b8, 0x4e475349, 0x00000050, 0x00000002, 0x00000008, 0x00000038,
24665 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x00000044, 0x00000000, 0x00000000,
24666 0x00000003, 0x00000001, 0x00000303, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f,
24667 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
24668 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x0000005c,
24669 0x00000040, 0x00000017, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03001062, 0x00101032,
24670 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036, 0x00102032, 0x00000000, 0x00101046,
24671 0x00000000, 0x05000036, 0x001020c2, 0x00000000, 0x00101406, 0x00000001, 0x0100003e,
24673 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
24675 {"POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
24676 {"COLOR", 0, DXGI_FORMAT_R32G32B32_FLOAT
, 0, 16, D3D11_INPUT_PER_VERTEX_DATA
, 0},
24677 {"COLOR", 2, DXGI_FORMAT_R32G32_FLOAT
, 0, 28, D3D11_INPUT_PER_VERTEX_DATA
, 0},
24679 static const D3D11_INPUT_ELEMENT_DESC layout_desc2
[] =
24681 {"POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
24682 {"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 16, D3D11_INPUT_PER_VERTEX_DATA
, 0},
24683 {"COLOR", 2, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 32, D3D11_INPUT_PER_VERTEX_DATA
, 0},
24685 static const D3D11_SO_DECLARATION_ENTRY so_declaration
[] =
24687 {0, "POSITION", 0, 0, 4, 0},
24688 {0, "COLOR", 0, 0, 3, 0},
24689 {0, "COLOR", 2, 0, 2, 0},
24691 static const D3D11_SO_DECLARATION_ENTRY so_declaration2
[] =
24693 {0, "POSITION", 0, 0, 1, 0},
24694 {0, "POSITION", 0, 1, 1, 0},
24695 {0, "POSITION", 0, 2, 1, 0},
24696 {0, "POSITION", 0, 3, 1, 0},
24697 {0, "COLOR", 0, 0, 1, 0},
24698 {0, "COLOR", 0, 1, 1, 0},
24699 {0, "COLOR", 0, 2, 1, 0},
24700 {0, "COLOR", 2, 0, 1, 0},
24701 {0, "COLOR", 2, 1, 1, 0},
24703 static const D3D11_SO_DECLARATION_ENTRY so_declaration3
[] =
24705 {0, "COLOR", 0, 2, 2, 0},
24706 {0, "COLOR", 2, 3, 1, 0},
24708 static const struct
24710 struct vec4 position
;
24712 struct vec2 color2
;
24716 {{-1.0f
, -1.0f
, 0.0f
, 1.0f
}, {1.0f
, 0.0f
, 0.0f
}, {0.5f
, 1.0f
}},
24717 {{-1.0f
, 1.0f
, 0.0f
, 1.0f
}, {0.0f
, 1.0f
, 0.0f
}, {0.0f
, 0.0f
}},
24718 {{ 1.0f
, -1.0f
, 0.0f
, 1.0f
}, {1.0f
, 0.0f
, 1.0f
}, {0.5f
, 0.4f
}},
24719 {{ 1.0f
, 1.0f
, 0.0f
, 1.0f
}, {1.0f
, 1.0f
, 0.0f
}, {0.1f
, 0.6f
}},
24721 static const struct
24723 struct vec4 position
;
24725 struct vec4 color2
;
24729 {{-1.0f
, -1.0f
, 0.0f
, 1.0f
}, {1.0f
, 2.0f
, 3.0f
, 4.0f
}, {5.0f
, 6.0f
, 7.0f
, 8.0f
}},
24730 {{-1.0f
, 1.0f
, 0.0f
, 1.0f
}, {9.0f
, 1.1f
, 1.2f
, 1.3f
}, {1.4f
, 1.5f
, 1.6f
, 1.7f
}},
24731 {{ 1.0f
, -1.0f
, 0.0f
, 1.0f
}, {1.8f
, 1.9f
, 2.0f
, 2.1f
}, {2.2f
, 2.3f
, 2.4f
, 2.5f
}},
24732 {{ 1.0f
, 1.0f
, 0.0f
, 1.0f
}, {2.5f
, 2.6f
, 2.7f
, 2.8f
}, {2.9f
, 3.0f
, 3.1f
, 3.2f
}},
24734 static const unsigned int vb_stride
[] = {sizeof(*vb_data
), sizeof(*vb_data2
)};
24735 static const float expected_data
[] =
24737 -1.0f
, -1.0f
, 0.0f
, 1.0f
, 1.0f
, 0.0f
, 0.0f
, 0.5f
, 1.0f
,
24738 -1.0f
, 1.0f
, 0.0f
, 1.0f
, 0.0f
, 1.0f
, 0.0f
, 0.0f
, 0.0f
,
24739 1.0f
, -1.0f
, 0.0f
, 1.0f
, 1.0f
, 0.0f
, 1.0f
, 0.5f
, 0.4f
,
24740 1.0f
, 1.0f
, 0.0f
, 1.0f
, 1.0f
, 1.0f
, 0.0f
, 0.1f
, 0.6f
,
24742 static const float expected_data2
[] =
24744 -1.0f
, -1.0f
, 0.0f
, 1.0f
, 1.0f
, 2.0f
, 3.0f
, 5.0f
, 6.0f
,
24745 -1.0f
, 1.0f
, 0.0f
, 1.0f
, 9.0f
, 1.1f
, 1.2f
, 1.4f
, 1.5f
,
24746 1.0f
, -1.0f
, 0.0f
, 1.0f
, 1.8f
, 1.9f
, 2.0f
, 2.2f
, 2.3f
,
24747 1.0f
, 1.0f
, 0.0f
, 1.0f
, 2.5f
, 2.6f
, 2.7f
, 2.9f
, 3.0f
,
24749 static const float expected_data3
[] =
24751 3.0f
, 4.0f
, 8.0f
, 1.2f
, 1.3f
, 1.7f
, 2.0f
, 2.1f
, 2.5f
, 2.7f
, 2.8f
, 3.2f
,
24753 static const struct
24756 unsigned int vb_idx
;
24757 const D3D11_SO_DECLARATION_ENTRY
*so_declaration
;
24758 unsigned int so_entry_count
;
24759 const float *expected_data
;
24760 unsigned int expected_data_size
;
24764 {TRUE
, 0, so_declaration
, ARRAY_SIZE(so_declaration
), expected_data
, ARRAY_SIZE(expected_data
)},
24765 {TRUE
, 1, so_declaration
, ARRAY_SIZE(so_declaration
), expected_data2
, ARRAY_SIZE(expected_data2
)},
24766 {TRUE
, 0, so_declaration2
, ARRAY_SIZE(so_declaration2
), expected_data
, ARRAY_SIZE(expected_data
)},
24767 {TRUE
, 1, so_declaration2
, ARRAY_SIZE(so_declaration2
), expected_data2
, ARRAY_SIZE(expected_data2
)},
24768 {TRUE
, 1, so_declaration3
, ARRAY_SIZE(so_declaration3
), expected_data3
, ARRAY_SIZE(expected_data3
)},
24770 {FALSE
, 0, so_declaration
, ARRAY_SIZE(so_declaration
), expected_data
, ARRAY_SIZE(expected_data
)},
24771 {FALSE
, 1, so_declaration
, ARRAY_SIZE(so_declaration
), expected_data2
, ARRAY_SIZE(expected_data2
)},
24772 {FALSE
, 0, so_declaration2
, ARRAY_SIZE(so_declaration2
), expected_data
, ARRAY_SIZE(expected_data
)},
24773 {FALSE
, 1, so_declaration2
, ARRAY_SIZE(so_declaration2
), expected_data2
, ARRAY_SIZE(expected_data2
)},
24774 {FALSE
, 1, so_declaration3
, ARRAY_SIZE(so_declaration3
), expected_data3
, ARRAY_SIZE(expected_data3
)},
24777 if (!init_test_context(&test_context
, &feature_level
))
24780 device
= test_context
.device
;
24781 context
= test_context
.immediate_context
;
24783 vb
[0] = create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(vb_data
), vb_data
);
24784 vb
[1] = create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(vb_data2
), vb_data2
);
24786 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
24787 vs_code
, sizeof(vs_code
), &input_layout
[0]);
24788 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
24789 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc2
, ARRAY_SIZE(layout_desc2
),
24790 vs_code
, sizeof(vs_code
), &input_layout
[1]);
24791 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
24793 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
24794 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
24795 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
24796 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
24798 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
24799 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST
);
24801 so_buffer
= create_buffer(device
, D3D11_BIND_STREAM_OUTPUT
, 1024, NULL
);
24804 current_so_declaration
= NULL
;
24805 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
24807 ID3D11DeviceContext_PSSetShader(context
, tests
[i
].with_ps
? ps
: NULL
, NULL
, 0);
24809 if (current_so_declaration
!= tests
[i
].so_declaration
)
24812 ID3D11GeometryShader_Release(gs
);
24814 hr
= ID3D11Device_CreateGeometryShaderWithStreamOutput(device
, gs_code
, sizeof(gs_code
),
24815 tests
[i
].so_declaration
, tests
[i
].so_entry_count
, NULL
, 0,
24816 D3D11_SO_NO_RASTERIZED_STREAM
, NULL
, &gs
);
24817 ok(SUCCEEDED(hr
), "Failed to create geometry shader with stream output, hr %#x.\n", hr
);
24818 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
24819 current_so_declaration
= tests
[i
].so_declaration
;
24822 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
[tests
[i
].vb_idx
]);
24823 stride
= vb_stride
[tests
[i
].vb_idx
];
24825 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
[tests
[i
].vb_idx
], &stride
, &offset
);
24828 ID3D11DeviceContext_SOSetTargets(context
, 1, &so_buffer
, &offset
);
24830 ID3D11DeviceContext_Draw(context
, 4, 0);
24832 get_buffer_readback(so_buffer
, &rb
);
24833 result
= rb
.map_desc
.pData
;
24834 for (j
= 0; j
< tests
[i
].expected_data_size
; ++j
)
24836 float expected_value
= tests
[i
].expected_data
[j
];
24837 ok(compare_float(result
[j
], expected_value
, 2),
24838 "Test %u: Got %.8e, expected %.8e at %u.\n",
24839 i
, result
[j
], expected_value
, j
);
24841 release_resource_readback(&rb
);
24844 for (i
= 0; i
< ARRAY_SIZE(vb
); ++i
)
24845 ID3D11Buffer_Release(vb
[i
]);
24846 ID3D11Buffer_Release(so_buffer
);
24847 ID3D11VertexShader_Release(vs
);
24848 ID3D11GeometryShader_Release(gs
);
24849 ID3D11PixelShader_Release(ps
);
24850 for (i
= 0; i
< ARRAY_SIZE(input_layout
); ++i
)
24851 ID3D11InputLayout_Release(input_layout
[i
]);
24852 release_test_context(&test_context
);
24855 static void test_stream_output_vs(void)
24857 const D3D11_SO_DECLARATION_ENTRY
*current_so_declaration
;
24858 struct d3d11_test_context test_context
;
24859 ID3D11InputLayout
*input_layout
;
24860 ID3D11Buffer
*vb
, *so_buffer
;
24861 ID3D11DeviceContext
*context
;
24862 struct resource_readback rb
;
24863 ID3D11GeometryShader
*gs
;
24864 ID3D11VertexShader
*vs
;
24865 ID3D11Device
*device
;
24866 const float *result
;
24867 unsigned int offset
;
24871 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
24872 static const DWORD vs_code
[] =
24877 float4 position
: POSITION
;
24878 float4 color0
: COLOR0
;
24879 float4 color1
: COLOR1
;
24882 vertex
main(in vertex i
)
24887 0x43425844, 0xa67e993e, 0x1632c139, 0x02a7725f, 0xfb0221cd, 0x00000001, 0x00000194, 0x00000003,
24888 0x0000002c, 0x00000094, 0x000000fc, 0x4e475349, 0x00000060, 0x00000003, 0x00000008, 0x00000050,
24889 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000059, 0x00000000, 0x00000000,
24890 0x00000003, 0x00000001, 0x00000f0f, 0x00000059, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
24891 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x00000060, 0x00000003,
24892 0x00000008, 0x00000050, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x00000059,
24893 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x00000059, 0x00000001, 0x00000000,
24894 0x00000003, 0x00000002, 0x0000000f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x52444853,
24895 0x00000090, 0x00010040, 0x00000024, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2,
24896 0x00000001, 0x0300005f, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x03000065,
24897 0x001020f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x05000036, 0x001020f2, 0x00000000,
24898 0x00101e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001, 0x05000036,
24899 0x001020f2, 0x00000002, 0x00101e46, 0x00000002, 0x0100003e,
24901 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
24903 {"POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
24904 {"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 16, D3D11_INPUT_PER_VERTEX_DATA
, 0},
24905 {"COLOR", 1, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 32, D3D11_INPUT_PER_VERTEX_DATA
, 0},
24907 static const D3D11_SO_DECLARATION_ENTRY all_so_decl
[] =
24909 {0, "POSITION", 0, 0, 4, 0},
24910 {0, "COLOR", 0, 0, 3, 0},
24911 {0, "COLOR", 1, 0, 2, 0},
24913 static const D3D11_SO_DECLARATION_ENTRY position_so_decl
[] =
24915 {0, "POSITION", 0, 0, 4, 0},
24917 static const D3D11_SO_DECLARATION_ENTRY position2_so_decl
[] =
24919 {0, "POSITION", 0, 0, 2, 0},
24921 static const struct
24923 struct vec4 position
;
24924 struct vec4 color0
;
24925 struct vec4 color1
;
24929 {{-1.0f
, -1.0f
, 0.0f
, 1.0f
}, {1.0f
, 2.0f
, 3.0f
, 4.0f
}, {5.0f
, 6.0f
, 7.0f
, 8.0f
}},
24930 {{-1.0f
, 1.0f
, 0.0f
, 1.0f
}, {9.0f
, 1.1f
, 1.2f
, 1.3f
}, {1.4f
, 1.5f
, 1.6f
, 1.7f
}},
24931 {{ 1.0f
, -1.0f
, 0.0f
, 1.0f
}, {1.8f
, 1.9f
, 2.0f
, 2.1f
}, {2.2f
, 2.3f
, 2.4f
, 2.5f
}},
24932 {{ 1.0f
, 1.0f
, 0.0f
, 1.0f
}, {2.5f
, 2.6f
, 2.7f
, 2.8f
}, {2.9f
, 3.0f
, 3.1f
, 3.2f
}},
24934 static const unsigned int vb_stride
[] = {sizeof(*vb_data
)};
24935 static const float expected_data
[] =
24937 -1.0f
, -1.0f
, 0.0f
, 1.0f
, 1.0f
, 2.0f
, 3.0f
, 5.0f
, 6.0f
,
24938 -1.0f
, 1.0f
, 0.0f
, 1.0f
, 9.0f
, 1.1f
, 1.2f
, 1.4f
, 1.5f
,
24939 1.0f
, -1.0f
, 0.0f
, 1.0f
, 1.8f
, 1.9f
, 2.0f
, 2.2f
, 2.3f
,
24940 1.0f
, 1.0f
, 0.0f
, 1.0f
, 2.5f
, 2.6f
, 2.7f
, 2.9f
, 3.0f
,
24942 static const float expected_data2
[] =
24944 -1.0f
, -1.0f
, 0.0f
, 1.0f
,
24945 -1.0f
, 1.0f
, 0.0f
, 1.0f
,
24946 1.0f
, -1.0f
, 0.0f
, 1.0f
,
24947 1.0f
, 1.0f
, 0.0f
, 1.0f
,
24949 static const float expected_data3
[] =
24956 static const struct
24958 const D3D11_SO_DECLARATION_ENTRY
*so_declaration
;
24959 unsigned int so_entry_count
;
24960 const float *expected_data
;
24961 unsigned int expected_data_size
;
24965 {all_so_decl
, ARRAY_SIZE(all_so_decl
), expected_data
, ARRAY_SIZE(expected_data
)},
24966 {position_so_decl
, ARRAY_SIZE(position_so_decl
), expected_data2
, ARRAY_SIZE(expected_data2
)},
24967 {position2_so_decl
, ARRAY_SIZE(position2_so_decl
), expected_data3
, ARRAY_SIZE(expected_data3
)},
24970 if (!init_test_context(&test_context
, &feature_level
))
24973 device
= test_context
.device
;
24974 context
= test_context
.immediate_context
;
24976 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(vb_data
), vb_data
);
24978 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
24979 vs_code
, sizeof(vs_code
), &input_layout
);
24980 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
24982 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
24983 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
24985 so_buffer
= create_buffer(device
, D3D11_BIND_STREAM_OUTPUT
, 1024, NULL
);
24987 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
24989 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, vb_stride
, &offset
);
24990 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
24992 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST
);
24995 current_so_declaration
= NULL
;
24996 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
24998 if (current_so_declaration
!= tests
[i
].so_declaration
)
25001 ID3D11GeometryShader_Release(gs
);
25003 hr
= ID3D11Device_CreateGeometryShaderWithStreamOutput(device
, vs_code
, sizeof(vs_code
),
25004 tests
[i
].so_declaration
, tests
[i
].so_entry_count
, NULL
, 0,
25005 D3D11_SO_NO_RASTERIZED_STREAM
, NULL
, &gs
);
25006 ok(hr
== S_OK
, "Failed to create geometry shader with stream output, hr %#x.\n", hr
);
25007 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
25008 current_so_declaration
= tests
[i
].so_declaration
;
25012 ID3D11DeviceContext_SOSetTargets(context
, 1, &so_buffer
, &offset
);
25014 ID3D11DeviceContext_Draw(context
, 4, 0);
25016 get_buffer_readback(so_buffer
, &rb
);
25017 result
= rb
.map_desc
.pData
;
25018 for (j
= 0; j
< tests
[i
].expected_data_size
; ++j
)
25020 float expected_value
= tests
[i
].expected_data
[j
];
25021 ok(compare_float(result
[j
], expected_value
, 2),
25022 "Test %u: Got %.8e, expected %.8e at %u.\n",
25023 i
, result
[j
], expected_value
, j
);
25025 release_resource_readback(&rb
);
25028 ID3D11Buffer_Release(vb
);
25029 ID3D11Buffer_Release(so_buffer
);
25030 ID3D11VertexShader_Release(vs
);
25031 ID3D11GeometryShader_Release(gs
);
25032 ID3D11InputLayout_Release(input_layout
);
25033 release_test_context(&test_context
);
25036 static void test_gather(void)
25041 int offset_x
, offset_y
;
25043 struct d3d11_test_context test_context
;
25044 D3D11_TEXTURE2D_DESC texture_desc
;
25045 ID3D11ShaderResourceView
*srv
;
25046 ID3D11Texture2D
*texture
, *rt
;
25047 ID3D11DeviceContext
*context
;
25048 ID3D11RenderTargetView
*rtv
;
25049 struct resource_readback rb
;
25050 ID3D11PixelShader
*ps
;
25051 ID3D11Device
*device
;
25056 static const DWORD gather4_code
[] =
25060 Texture2D
<float4
> t
;
25064 float4
main(float4 position
: SV_Position
) : SV_Target
25066 return t
.Gather(s
, position
.xy
/ size
);
25069 0x43425844, 0xca1ee692, 0xb122f477, 0x8c467d38, 0x0f5a233a, 0x00000001, 0x00000154, 0x00000003,
25070 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
25071 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
25072 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
25073 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000b8, 0x00000041,
25074 0x0000002e, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000,
25075 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000,
25076 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0600002b, 0x00100032,
25077 0x00000000, 0x00208046, 0x00000000, 0x00000000, 0x0700000e, 0x00100032, 0x00000000, 0x00101046,
25078 0x00000000, 0x00100046, 0x00000000, 0x0900006d, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
25079 0x00107e46, 0x00000000, 0x0010600a, 0x00000000, 0x0100003e,
25081 static const DWORD gather4_offset_code
[] =
25085 Texture2D
<float4
> t
;
25089 float4
main(float4 position
: SV_Position
) : SV_Target
25091 return t
.Gather(s
, position
.xy
/ size
, int2(1, 1));
25094 0x43425844, 0xe5ab2216, 0x90748ece, 0x7ccf2123, 0x4edbba7c, 0x00000001, 0x00000158, 0x00000003,
25095 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
25096 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
25097 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
25098 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000bc, 0x00000041,
25099 0x0000002f, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000,
25100 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000,
25101 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0600002b, 0x00100032,
25102 0x00000000, 0x00208046, 0x00000000, 0x00000000, 0x0700000e, 0x00100032, 0x00000000, 0x00101046,
25103 0x00000000, 0x00100046, 0x00000000, 0x8a00006d, 0x00002201, 0x001020f2, 0x00000000, 0x00100046,
25104 0x00000000, 0x00107e46, 0x00000000, 0x0010600a, 0x00000000, 0x0100003e,
25106 static const DWORD gather4_green_code
[] =
25110 Texture2D
<float4
> t
;
25114 float4
main(float4 position
: SV_Position
) : SV_Target
25116 return t
.GatherGreen(s
, position
.xy
/ size
);
25119 0x43425844, 0x2b0ad2d9, 0x8ad30b52, 0xc418477f, 0xe5211693, 0x00000001, 0x0000015c, 0x00000003,
25120 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
25121 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
25122 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
25123 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000c0, 0x00000050,
25124 0x00000030, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000,
25125 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000,
25126 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0600002b, 0x00100032,
25127 0x00000000, 0x00208046, 0x00000000, 0x00000000, 0x0700000e, 0x00100032, 0x00000000, 0x00101046,
25128 0x00000000, 0x00100046, 0x00000000, 0x8b00006d, 0x800000c2, 0x00155543, 0x001020f2, 0x00000000,
25129 0x00100046, 0x00000000, 0x00107e46, 0x00000000, 0x0010601a, 0x00000000, 0x0100003e,
25131 static const DWORD gather4_po_code
[] =
25135 Texture2D
<float4
> t
;
25140 float4
main(float4 position
: SV_Position
) : SV_Target
25142 return t
.Gather(s
, position
.xy
/ size
, offset
);
25145 0x43425844, 0xe19bdd35, 0x44514fb3, 0xfaa8727f, 0xc1092da0, 0x00000001, 0x00000168, 0x00000003,
25146 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
25147 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
25148 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
25149 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000cc, 0x00000050,
25150 0x00000033, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000,
25151 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000,
25152 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0600002b, 0x00100032,
25153 0x00000000, 0x00208046, 0x00000000, 0x00000000, 0x0700000e, 0x00100032, 0x00000000, 0x00101046,
25154 0x00000000, 0x00100046, 0x00000000, 0x8e00007f, 0x800000c2, 0x00155543, 0x001020f2, 0x00000000,
25155 0x00100046, 0x00000000, 0x00208ae6, 0x00000000, 0x00000000, 0x00107e46, 0x00000000, 0x0010600a,
25156 0x00000000, 0x0100003e,
25158 static const struct vec4 texture_data
[] =
25160 {0.0f
, 0.0f
}, {1.0f
, 1.0f
}, {2.0f
, 2.0f
}, {3.0f
, 3.0f
},
25161 {4.0f
, 0.1f
}, {5.0f
, 1.1f
}, {6.0f
, 2.1f
}, {7.0f
, 3.1f
},
25162 {8.0f
, 0.2f
}, {9.0f
, 1.2f
}, {0.5f
, 2.2f
}, {1.5f
, 3.2f
},
25163 {2.5f
, 0.3f
}, {3.5f
, 1.3f
}, {4.5f
, 2.3f
}, {5.5f
, 3.3f
},
25165 static const struct vec4 expected_gather4
[] =
25167 {4.0f
, 5.0f
, 1.0f
, 0.0f
}, {5.0f
, 6.0f
, 2.0f
, 1.0f
}, {6.0f
, 7.0f
, 3.0f
, 2.0f
}, {7.0f
, 7.0f
, 3.0f
, 3.0f
},
25168 {8.0f
, 9.0f
, 5.0f
, 4.0f
}, {9.0f
, 0.5f
, 6.0f
, 5.0f
}, {0.5f
, 1.5f
, 7.0f
, 6.0f
}, {1.5f
, 1.5f
, 7.0f
, 7.0f
},
25169 {2.5f
, 3.5f
, 9.0f
, 8.0f
}, {3.5f
, 4.5f
, 0.5f
, 9.0f
}, {4.5f
, 5.5f
, 1.5f
, 0.5f
}, {5.5f
, 5.5f
, 1.5f
, 1.5f
},
25170 {2.5f
, 3.5f
, 3.5f
, 2.5f
}, {3.5f
, 4.5f
, 4.5f
, 3.5f
}, {4.5f
, 5.5f
, 5.5f
, 4.5f
}, {5.5f
, 5.5f
, 5.5f
, 5.5f
},
25172 static const struct vec4 expected_gather4_offset
[] =
25174 {9.0f
, 0.5f
, 6.0f
, 5.0f
}, {0.5f
, 1.5f
, 7.0f
, 6.0f
}, {1.5f
, 1.5f
, 7.0f
, 7.0f
}, {1.5f
, 1.5f
, 7.0f
, 7.0f
},
25175 {3.5f
, 4.5f
, 0.5f
, 9.0f
}, {4.5f
, 5.5f
, 1.5f
, 0.5f
}, {5.5f
, 5.5f
, 1.5f
, 1.5f
}, {5.5f
, 5.5f
, 1.5f
, 1.5f
},
25176 {3.5f
, 4.5f
, 4.5f
, 3.5f
}, {4.5f
, 5.5f
, 5.5f
, 4.5f
}, {5.5f
, 5.5f
, 5.5f
, 5.5f
}, {5.5f
, 5.5f
, 5.5f
, 5.5f
},
25177 {3.5f
, 4.5f
, 4.5f
, 3.5f
}, {4.5f
, 5.5f
, 5.5f
, 4.5f
}, {5.5f
, 5.5f
, 5.5f
, 5.5f
}, {5.5f
, 5.5f
, 5.5f
, 5.5f
},
25179 static const struct vec4 expected_gather4_green
[] =
25181 {0.1f
, 1.1f
, 1.0f
, 0.0f
}, {1.1f
, 2.1f
, 2.0f
, 1.0f
}, {2.1f
, 3.1f
, 3.0f
, 2.0f
}, {3.1f
, 3.1f
, 3.0f
, 3.0f
},
25182 {0.2f
, 1.2f
, 1.1f
, 0.1f
}, {1.2f
, 2.2f
, 2.1f
, 1.1f
}, {2.2f
, 3.2f
, 3.1f
, 2.1f
}, {3.2f
, 3.2f
, 3.1f
, 3.1f
},
25183 {0.3f
, 1.3f
, 1.2f
, 0.2f
}, {1.3f
, 2.3f
, 2.2f
, 1.2f
}, {2.3f
, 3.3f
, 3.2f
, 2.2f
}, {3.3f
, 3.3f
, 3.2f
, 3.2f
},
25184 {0.3f
, 1.3f
, 1.3f
, 0.3f
}, {1.3f
, 2.3f
, 2.3f
, 1.3f
}, {2.3f
, 3.3f
, 3.3f
, 2.3f
}, {3.3f
, 3.3f
, 3.3f
, 3.3f
},
25186 static const struct vec4 white
= {1.0f
, 1.0f
, 1.0f
, 1.0f
};
25187 static const D3D11_SUBRESOURCE_DATA resource_data
= {&texture_data
, sizeof(texture_data
) / 4};
25189 if (!init_test_context(&test_context
, NULL
))
25192 device
= test_context
.device
;
25193 context
= test_context
.immediate_context
;
25195 if (ID3D11Device_GetFeatureLevel(device
) < D3D_FEATURE_LEVEL_10_1
)
25197 skip("Shader model 4.1 required for gather4 instruction.\n");
25198 release_test_context(&test_context
);
25202 texture_desc
.Width
= 4;
25203 texture_desc
.Height
= 4;
25204 texture_desc
.MipLevels
= 1;
25205 texture_desc
.ArraySize
= 1;
25206 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
25207 texture_desc
.SampleDesc
.Count
= 1;
25208 texture_desc
.SampleDesc
.Quality
= 0;
25209 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
25210 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
25211 texture_desc
.CPUAccessFlags
= 0;
25212 texture_desc
.MiscFlags
= 0;
25213 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rt
);
25214 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
25215 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rt
, NULL
, &rtv
);
25216 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
25217 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
25219 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
25220 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &texture
);
25221 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
25222 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
25223 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
25224 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
25226 constant
.width
= texture_desc
.Width
;
25227 constant
.height
= texture_desc
.Height
;
25228 constant
.offset_x
= 1;
25229 constant
.offset_y
= 1;
25230 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(constant
), &constant
);
25231 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
25233 hr
= ID3D11Device_CreatePixelShader(device
, gather4_code
, sizeof(gather4_code
), NULL
, &ps
);
25234 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
25235 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
25237 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, &white
.x
);
25238 draw_quad(&test_context
);
25239 get_texture_readback(rt
, 0, &rb
);
25240 for (y
= 0; y
< texture_desc
.Height
; ++y
)
25242 for (x
= 0; x
< texture_desc
.Width
; ++x
)
25244 const struct vec4
*expected
= &expected_gather4
[y
* texture_desc
.Width
+ x
];
25245 const struct vec4
*got
= get_readback_vec4(&rb
, x
, y
);
25246 ok(compare_vec4(got
, expected
, 0),
25247 "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
25248 got
->x
, got
->y
, got
->z
, got
->w
, expected
->x
, expected
->y
, expected
->z
, expected
->w
);
25251 release_resource_readback(&rb
);
25253 ID3D11PixelShader_Release(ps
);
25254 hr
= ID3D11Device_CreatePixelShader(device
, gather4_offset_code
, sizeof(gather4_offset_code
), NULL
, &ps
);
25255 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
25256 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
25258 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, &white
.x
);
25259 draw_quad(&test_context
);
25260 get_texture_readback(rt
, 0, &rb
);
25261 for (y
= 0; y
< texture_desc
.Height
; ++y
)
25263 for (x
= 0; x
< texture_desc
.Width
; ++x
)
25265 const struct vec4
*expected
= &expected_gather4_offset
[y
* texture_desc
.Width
+ x
];
25266 const struct vec4
*got
= get_readback_vec4(&rb
, x
, y
);
25267 ok(compare_vec4(got
, expected
, 0),
25268 "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
25269 got
->x
, got
->y
, got
->z
, got
->w
, expected
->x
, expected
->y
, expected
->z
, expected
->w
);
25272 release_resource_readback(&rb
);
25274 ID3D11PixelShader_Release(ps
);
25276 if (ID3D11Device_GetFeatureLevel(device
) < D3D_FEATURE_LEVEL_11_0
)
25278 skip("Shader model 5 required for GatherGreen()/gather4_po.\n");
25282 hr
= ID3D11Device_CreatePixelShader(device
, gather4_green_code
, sizeof(gather4_green_code
), NULL
, &ps
);
25283 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
25284 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
25286 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, &white
.x
);
25287 draw_quad(&test_context
);
25288 get_texture_readback(rt
, 0, &rb
);
25289 for (y
= 0; y
< texture_desc
.Height
; ++y
)
25291 for (x
= 0; x
< texture_desc
.Width
; ++x
)
25293 const struct vec4
*expected
= &expected_gather4_green
[y
* texture_desc
.Width
+ x
];
25294 const struct vec4
*got
= get_readback_vec4(&rb
, x
, y
);
25295 ok(compare_vec4(got
, expected
, 0),
25296 "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
25297 got
->x
, got
->y
, got
->z
, got
->w
, expected
->x
, expected
->y
, expected
->z
, expected
->w
);
25300 release_resource_readback(&rb
);
25302 ID3D11PixelShader_Release(ps
);
25303 hr
= ID3D11Device_CreatePixelShader(device
, gather4_po_code
, sizeof(gather4_po_code
), NULL
, &ps
);
25304 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
25305 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
25307 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, &white
.x
);
25308 draw_quad(&test_context
);
25309 get_texture_readback(rt
, 0, &rb
);
25310 for (y
= 0; y
< texture_desc
.Height
; ++y
)
25312 for (x
= 0; x
< texture_desc
.Width
; ++x
)
25314 const struct vec4
*expected
= &expected_gather4_offset
[y
* texture_desc
.Width
+ x
];
25315 const struct vec4
*got
= get_readback_vec4(&rb
, x
, y
);
25316 ok(compare_vec4(got
, expected
, 0),
25317 "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
25318 got
->x
, got
->y
, got
->z
, got
->w
, expected
->x
, expected
->y
, expected
->z
, expected
->w
);
25321 release_resource_readback(&rb
);
25323 constant
.offset_x
= 0;
25324 constant
.offset_y
= 0;
25325 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
25326 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, &white
.x
);
25327 draw_quad(&test_context
);
25328 get_texture_readback(rt
, 0, &rb
);
25329 for (y
= 0; y
< texture_desc
.Height
; ++y
)
25331 for (x
= 0; x
< texture_desc
.Width
; ++x
)
25333 const struct vec4
*expected
= &expected_gather4
[y
* texture_desc
.Width
+ x
];
25334 const struct vec4
*got
= get_readback_vec4(&rb
, x
, y
);
25335 ok(compare_vec4(got
, expected
, 0),
25336 "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
25337 got
->x
, got
->y
, got
->z
, got
->w
, expected
->x
, expected
->y
, expected
->z
, expected
->w
);
25340 release_resource_readback(&rb
);
25342 ID3D11PixelShader_Release(ps
);
25345 ID3D11Buffer_Release(cb
);
25346 ID3D11Texture2D_Release(rt
);
25347 ID3D11Texture2D_Release(texture
);
25348 ID3D11RenderTargetView_Release(rtv
);
25349 ID3D11ShaderResourceView_Release(srv
);
25350 release_test_context(&test_context
);
25353 static void test_gather_c(void)
25358 int offset_x
, offset_y
;
25359 float compare_value
;
25362 struct d3d11_test_context test_context
;
25363 D3D11_TEXTURE2D_DESC texture_desc
;
25364 D3D11_SAMPLER_DESC sampler_desc
;
25365 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
25366 ID3D11ShaderResourceView
*srv
;
25367 ID3D11Texture2D
*texture
, *rt
;
25368 ID3D11DeviceContext
*context
;
25369 ID3D11SamplerState
*sampler
;
25370 ID3D11RenderTargetView
*rtv
;
25371 struct resource_readback rb
;
25372 ID3D11PixelShader
*ps
;
25373 ID3D11Device
*device
;
25378 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
25379 static const DWORD gather4_c_code
[] =
25382 SamplerComparisonState s
;
25383 Texture2D
<float4
> t
;
25389 float4
main(float4 position
: SV_Position
) : SV_Target
25391 return t
.GatherCmp(s
, position
.xy
/ size
, compare
);
25394 0x43425844, 0xd3d04479, 0x901e9208, 0x7074fd0c, 0xbcadb2da, 0x00000001, 0x00000168, 0x00000003,
25395 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
25396 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
25397 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
25398 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000cc, 0x00000050,
25399 0x00000033, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000002, 0x0300085a, 0x00106000,
25400 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000,
25401 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0600002b, 0x00100032,
25402 0x00000000, 0x00208046, 0x00000000, 0x00000000, 0x0700000e, 0x00100032, 0x00000000, 0x00101046,
25403 0x00000000, 0x00100046, 0x00000000, 0x8e00007e, 0x800000c2, 0x00155543, 0x001020f2, 0x00000000,
25404 0x00100046, 0x00000000, 0x00107e46, 0x00000000, 0x0010600a, 0x00000000, 0x0020800a, 0x00000000,
25405 0x00000001, 0x0100003e,
25407 static const DWORD gather4_po_c_code
[] =
25410 SamplerComparisonState s
;
25411 Texture2D
<float4
> t
;
25417 float4
main(float4 position
: SV_Position
) : SV_Target
25419 return t
.GatherCmp(s
, position
.xy
/ size
, compare
, offset
);
25422 0x43425844, 0x501de13e, 0x472d2d20, 0x6df0fee4, 0xef27d9e6, 0x00000001, 0x00000174, 0x00000003,
25423 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
25424 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
25425 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
25426 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000d8, 0x00000050,
25427 0x00000036, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000002, 0x0300085a, 0x00106000,
25428 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000,
25429 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0600002b, 0x00100032,
25430 0x00000000, 0x00208046, 0x00000000, 0x00000000, 0x0700000e, 0x00100032, 0x00000000, 0x00101046,
25431 0x00000000, 0x00100046, 0x00000000, 0x91000080, 0x800000c2, 0x00155543, 0x001020f2, 0x00000000,
25432 0x00100046, 0x00000000, 0x00208ae6, 0x00000000, 0x00000000, 0x00107e46, 0x00000000, 0x0010600a,
25433 0x00000000, 0x0020800a, 0x00000000, 0x00000001, 0x0100003e,
25435 static const float texture_data
[] =
25437 0.00f
, 0.10f
, 0.20f
, 0.30f
,
25438 0.40f
, 0.50f
, 0.60f
, 0.70f
,
25439 0.80f
, 0.90f
, 0.05f
, 0.15f
,
25440 0.25f
, 0.35f
, 0.45f
, 0.55f
,
25442 static const struct vec4 expected_gather4_c
[] =
25444 {0.0f
, 1.00, 0.00, 0.0f
}, {1.0f
, 1.00, 0.00, 0.0f
}, {1.0f
, 1.00, 0.00, 0.0f
}, {1.0f
, 1.00, 0.00, 0.0f
},
25445 {1.0f
, 1.00, 1.00, 0.0f
}, {1.0f
, 0.00, 1.00, 1.0f
}, {0.0f
, 0.00, 1.00, 1.0f
}, {0.0f
, 0.00, 1.00, 1.0f
},
25446 {0.0f
, 0.00, 1.00, 1.0f
}, {0.0f
, 0.00, 0.00, 1.0f
}, {0.0f
, 1.00, 0.00, 0.0f
}, {1.0f
, 1.00, 0.00, 0.0f
},
25447 {0.0f
, 0.00, 0.00, 0.0f
}, {0.0f
, 0.00, 0.00, 0.0f
}, {0.0f
, 1.00, 1.00, 0.0f
}, {1.0f
, 1.00, 1.00, 1.0f
},
25449 static const struct vec4 expected_gather4_po_c
[] =
25451 {1.0f
, 0.0f
, 1.0f
, 1.0f
}, {0.0f
, 0.0f
, 1.0f
, 1.0f
}, {0.0f
, 0.0f
, 1.0f
, 1.0f
}, {0.0f
, 0.0f
, 1.0f
, 1.0f
},
25452 {0.0f
, 0.0f
, 0.0f
, 1.0f
}, {0.0f
, 1.0f
, 0.0f
, 0.0f
}, {1.0f
, 1.0f
, 0.0f
, 0.0f
}, {1.0f
, 1.0f
, 0.0f
, 0.0f
},
25453 {0.0f
, 0.0f
, 0.0f
, 0.0f
}, {0.0f
, 1.0f
, 1.0f
, 0.0f
}, {1.0f
, 1.0f
, 1.0f
, 1.0f
}, {1.0f
, 1.0f
, 1.0f
, 1.0f
},
25454 {0.0f
, 0.0f
, 0.0f
, 0.0f
}, {0.0f
, 1.0f
, 1.0f
, 0.0f
}, {1.0f
, 1.0f
, 1.0f
, 1.0f
}, {1.0f
, 1.0f
, 1.0f
, 1.0f
},
25456 static const struct vec4 white
= {1.0f
, 1.0f
, 1.0f
, 1.0f
};
25457 static const D3D11_SUBRESOURCE_DATA resource_data
= {&texture_data
, sizeof(texture_data
) / 4};
25459 if (!init_test_context(&test_context
, &feature_level
))
25462 device
= test_context
.device
;
25463 context
= test_context
.immediate_context
;
25465 sampler_desc
.Filter
= D3D11_FILTER_COMPARISON_MIN_MAG_MIP_POINT
;
25466 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
25467 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
25468 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
25469 sampler_desc
.MipLODBias
= 0.0f
;
25470 sampler_desc
.MaxAnisotropy
= 0;
25471 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_LESS_EQUAL
;
25472 sampler_desc
.BorderColor
[0] = 0.0f
;
25473 sampler_desc
.BorderColor
[1] = 0.0f
;
25474 sampler_desc
.BorderColor
[2] = 0.0f
;
25475 sampler_desc
.BorderColor
[3] = 0.0f
;
25476 sampler_desc
.MinLOD
= 0.0f
;
25477 sampler_desc
.MaxLOD
= D3D11_FLOAT32_MAX
;
25479 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler
);
25480 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
25481 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler
);
25483 texture_desc
.Width
= 4;
25484 texture_desc
.Height
= 4;
25485 texture_desc
.MipLevels
= 1;
25486 texture_desc
.ArraySize
= 1;
25487 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
25488 texture_desc
.SampleDesc
.Count
= 1;
25489 texture_desc
.SampleDesc
.Quality
= 0;
25490 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
25491 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
25492 texture_desc
.CPUAccessFlags
= 0;
25493 texture_desc
.MiscFlags
= 0;
25494 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rt
);
25495 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
25496 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rt
, NULL
, &rtv
);
25497 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
25498 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
25500 constant
.width
= texture_desc
.Width
;
25501 constant
.height
= texture_desc
.Height
;
25502 constant
.offset_x
= 1;
25503 constant
.offset_y
= 1;
25504 constant
.compare_value
= 0.5f
;
25505 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(constant
), &constant
);
25506 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
25508 texture_desc
.Format
= DXGI_FORMAT_R32_TYPELESS
;
25509 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
| D3D11_BIND_DEPTH_STENCIL
;
25510 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &texture
);
25511 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
25513 srv_desc
.Format
= DXGI_FORMAT_R32_FLOAT
;
25514 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_TEXTURE2D
;
25515 U(srv_desc
).Texture2D
.MostDetailedMip
= 0;
25516 U(srv_desc
).Texture2D
.MipLevels
= 1;
25517 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, &srv_desc
, &srv
);
25518 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
25519 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
25521 hr
= ID3D11Device_CreatePixelShader(device
, gather4_c_code
, sizeof(gather4_c_code
), NULL
, &ps
);
25522 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
25523 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
25525 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, &white
.x
);
25526 draw_quad(&test_context
);
25527 get_texture_readback(rt
, 0, &rb
);
25528 for (y
= 0; y
< texture_desc
.Height
; ++y
)
25530 for (x
= 0; x
< texture_desc
.Width
; ++x
)
25532 const struct vec4
*expected
= &expected_gather4_c
[y
* texture_desc
.Width
+ x
];
25533 const struct vec4
*got
= get_readback_vec4(&rb
, x
, y
);
25534 ok(compare_vec4(got
, expected
, 0),
25535 "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
25536 got
->x
, got
->y
, got
->z
, got
->w
, expected
->x
, expected
->y
, expected
->z
, expected
->w
);
25539 release_resource_readback(&rb
);
25540 ID3D11PixelShader_Release(ps
);
25542 hr
= ID3D11Device_CreatePixelShader(device
, gather4_po_c_code
, sizeof(gather4_po_c_code
), NULL
, &ps
);
25543 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
25544 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
25546 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, &white
.x
);
25547 draw_quad(&test_context
);
25548 get_texture_readback(rt
, 0, &rb
);
25549 for (y
= 0; y
< texture_desc
.Height
; ++y
)
25551 for (x
= 0; x
< texture_desc
.Width
; ++x
)
25553 const struct vec4
*expected
= &expected_gather4_po_c
[y
* texture_desc
.Width
+ x
];
25554 const struct vec4
*got
= get_readback_vec4(&rb
, x
, y
);
25555 ok(compare_vec4(got
, expected
, 0),
25556 "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
25557 got
->x
, got
->y
, got
->z
, got
->w
, expected
->x
, expected
->y
, expected
->z
, expected
->w
);
25560 release_resource_readback(&rb
);
25561 ID3D11PixelShader_Release(ps
);
25563 ID3D11ShaderResourceView_Release(srv
);
25564 ID3D11Texture2D_Release(texture
);
25566 ID3D11Buffer_Release(cb
);
25567 ID3D11Texture2D_Release(rt
);
25568 ID3D11RenderTargetView_Release(rtv
);
25569 ID3D11SamplerState_Release(sampler
);
25570 release_test_context(&test_context
);
25573 static float clamp_depth_bias(float bias
, float clamp
)
25576 return min(bias
, clamp
);
25578 return max(bias
, clamp
);
25582 static void test_depth_bias(void)
25584 struct vec3 vertices
[] =
25586 {-1.0f
, -1.0f
, 0.5f
},
25587 {-1.0f
, 1.0f
, 0.5f
},
25588 { 1.0f
, -1.0f
, 0.5f
},
25589 { 1.0f
, 1.0f
, 0.5f
},
25591 struct d3d11_test_context test_context
;
25592 D3D11_RASTERIZER_DESC rasterizer_desc
;
25593 struct swapchain_desc swapchain_desc
;
25594 D3D11_TEXTURE2D_DESC texture_desc
;
25595 ID3D11DeviceContext
*context
;
25596 double m
, bias
, depth
, data
;
25597 struct resource_readback rb
;
25598 ID3D11DepthStencilView
*dsv
;
25599 unsigned int expected_value
;
25600 ID3D11RasterizerState
*rs
;
25601 ID3D11Texture2D
*texture
;
25602 unsigned int format_idx
;
25603 unsigned int y
, i
, j
, k
;
25604 unsigned int shift
= 0;
25605 ID3D11Device
*device
;
25606 float *depth_values
;
25607 DXGI_FORMAT format
;
25613 static const struct
25625 static const int bias_tests
[] =
25627 -10000, -1000, -100, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
25628 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 50, 100, 200, 500, 1000, 10000,
25630 static const float bias_clamp_tests
[] =
25632 0.0f
, -1e-5f
, 1e-5f
,
25634 static const float quad_slopes
[] =
25638 static const float slope_scaled_bias_tests
[] =
25640 0.0f
, 0.5f
, 1.0f
, 2.0f
, 128.0f
, 1000.0f
, 10000.0f
,
25642 static const DXGI_FORMAT formats
[] =
25644 DXGI_FORMAT_D32_FLOAT
,
25645 DXGI_FORMAT_D24_UNORM_S8_UINT
,
25646 DXGI_FORMAT_D16_UNORM
,
25649 swapchain_desc
.windowed
= TRUE
;
25650 swapchain_desc
.buffer_count
= 1;
25651 swapchain_desc
.width
= 200;
25652 swapchain_desc
.height
= 200;
25653 swapchain_desc
.swap_effect
= DXGI_SWAP_EFFECT_DISCARD
;
25654 swapchain_desc
.flags
= 0;
25655 if (!init_test_context_ext(&test_context
, NULL
, &swapchain_desc
))
25658 device
= test_context
.device
;
25659 context
= test_context
.immediate_context
;
25661 memset(&rasterizer_desc
, 0, sizeof(rasterizer_desc
));
25662 rasterizer_desc
.FillMode
= D3D11_FILL_SOLID
;
25663 rasterizer_desc
.CullMode
= D3D11_CULL_NONE
;
25664 rasterizer_desc
.FrontCounterClockwise
= FALSE
;
25665 rasterizer_desc
.DepthBias
= 0;
25666 rasterizer_desc
.DepthBiasClamp
= 0.0f
;
25667 rasterizer_desc
.SlopeScaledDepthBias
= 0.0f
;
25668 rasterizer_desc
.DepthClipEnable
= TRUE
;
25670 depth_values
= heap_calloc(swapchain_desc
.height
, sizeof(*depth_values
));
25671 ok(!!depth_values
, "Failed to allocate memory.\n");
25673 for (format_idx
= 0; format_idx
< ARRAY_SIZE(formats
); ++format_idx
)
25675 format
= formats
[format_idx
];
25677 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
25678 texture_desc
.Format
= format
;
25679 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
25680 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
25681 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
25682 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, NULL
, &dsv
);
25683 ok(SUCCEEDED(hr
), "Failed to create render depth stencil view, hr %#x.\n", hr
);
25684 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &test_context
.backbuffer_rtv
, dsv
);
25685 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
| D3D11_CLEAR_STENCIL
, 1.0f
, 0);
25686 draw_quad_z(&test_context
, 1.0f
);
25689 case DXGI_FORMAT_D32_FLOAT
:
25690 check_texture_float(texture
, 1.0f
, 0);
25692 case DXGI_FORMAT_D24_UNORM_S8_UINT
:
25693 /* FIXME: Depth/stencil byte order is reversed in wined3d. */
25694 shift
= get_texture_color(texture
, 0, 0) == 0xffffff ? 0 : 8;
25696 check_texture_color(texture
, 0xffffff, 1);
25698 case DXGI_FORMAT_D16_UNORM
:
25699 get_texture_readback(texture
, 0, &rb
);
25700 check_readback_data_u16(&rb
, NULL
, 0xffffu
, 0);
25701 release_resource_readback(&rb
);
25704 trace("Unhandled format %#x.\n", format
);
25707 draw_quad(&test_context
);
25710 for (i
= 0; i
< ARRAY_SIZE(quads
); ++i
)
25712 for (j
= 0; j
< ARRAY_SIZE(vertices
); ++j
)
25713 vertices
[j
].z
= quads
[i
].z
;
25714 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)test_context
.vb
,
25715 0, NULL
, vertices
, 0, 0);
25717 for (j
= 0; j
< ARRAY_SIZE(bias_tests
); ++j
)
25719 rasterizer_desc
.DepthBias
= bias_tests
[j
];
25721 for (k
= 0; k
< ARRAY_SIZE(bias_clamp_tests
); ++k
)
25723 rasterizer_desc
.DepthBiasClamp
= bias_clamp_tests
[k
];
25724 ID3D11Device_CreateRasterizerState(device
, &rasterizer_desc
, &rs
);
25725 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
25726 ID3D11DeviceContext_RSSetState(context
, rs
);
25727 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
25728 draw_quad(&test_context
);
25731 case DXGI_FORMAT_D32_FLOAT
:
25732 bias
= rasterizer_desc
.DepthBias
* pow(2.0f
, quads
[i
].exponent
- 23.0f
);
25733 bias
= clamp_depth_bias(bias
, rasterizer_desc
.DepthBiasClamp
);
25734 depth
= min(max(0.0f
, quads
[i
].z
+ bias
), 1.0f
);
25736 check_texture_float(texture
, depth
, 2);
25738 case DXGI_FORMAT_D24_UNORM_S8_UINT
:
25739 bias
= clamp_depth_bias(rasterizer_desc
.DepthBias
/ 16777215.0f
,
25740 rasterizer_desc
.DepthBiasClamp
);
25741 depth
= min(max(0.0f
, quads
[i
].z
+ bias
), 1.0f
);
25743 get_texture_readback(texture
, 0, &rb
);
25744 check_readback_data_u24(&rb
, NULL
, shift
, depth
* 16777215.0f
+ 0.5f
, 1);
25745 release_resource_readback(&rb
);
25747 case DXGI_FORMAT_D16_UNORM
:
25748 bias
= clamp_depth_bias(rasterizer_desc
.DepthBias
/ 65535.0f
,
25749 rasterizer_desc
.DepthBiasClamp
);
25750 depth
= min(max(0.0f
, quads
[i
].z
+ bias
), 1.0f
);
25752 get_texture_readback(texture
, 0, &rb
);
25753 check_readback_data_u16(&rb
, NULL
, depth
* 65535.0f
+ 0.5f
, 1);
25754 release_resource_readback(&rb
);
25759 ID3D11RasterizerState_Release(rs
);
25764 /* SlopeScaledDepthBias */
25765 rasterizer_desc
.DepthBias
= 0;
25766 for (i
= 0; i
< ARRAY_SIZE(quad_slopes
); ++i
)
25768 for (j
= 0; j
< ARRAY_SIZE(vertices
); ++j
)
25769 vertices
[j
].z
= j
== 1 || j
== 3 ? 0.0f
: quad_slopes
[i
];
25770 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)test_context
.vb
,
25771 0, NULL
, vertices
, 0, 0);
25773 ID3D11DeviceContext_RSSetState(context
, NULL
);
25774 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
25775 draw_quad(&test_context
);
25776 get_texture_readback(texture
, 0, &rb
);
25777 for (y
= 0; y
< texture_desc
.Height
; ++y
)
25781 case DXGI_FORMAT_D32_FLOAT
:
25782 depth_values
[y
] = get_readback_float(&rb
, 0, y
);
25784 case DXGI_FORMAT_D24_UNORM_S8_UINT
:
25785 u32
= get_readback_data(&rb
, 0, y
, 0, sizeof(*u32
));
25786 u32_value
= *u32
>> shift
;
25787 depth_values
[y
] = u32_value
/ 16777215.0f
;
25789 case DXGI_FORMAT_D16_UNORM
:
25790 u16
= get_readback_data(&rb
, 0, y
, 0, sizeof(*u16
));
25791 depth_values
[y
] = *u16
/ 65535.0f
;
25797 release_resource_readback(&rb
);
25799 for (j
= 0; j
< ARRAY_SIZE(slope_scaled_bias_tests
); ++j
)
25801 rasterizer_desc
.SlopeScaledDepthBias
= slope_scaled_bias_tests
[j
];
25803 for (k
= 0; k
< ARRAY_SIZE(bias_clamp_tests
); ++k
)
25805 BOOL all_match
= TRUE
;
25806 rasterizer_desc
.DepthBiasClamp
= bias_clamp_tests
[k
];
25807 ID3D11Device_CreateRasterizerState(device
, &rasterizer_desc
, &rs
);
25808 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
25809 ID3D11DeviceContext_RSSetState(context
, rs
);
25810 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
25811 draw_quad(&test_context
);
25813 m
= quad_slopes
[i
] / texture_desc
.Height
;
25814 bias
= clamp_depth_bias(rasterizer_desc
.SlopeScaledDepthBias
* m
, rasterizer_desc
.DepthBiasClamp
);
25815 get_texture_readback(texture
, 0, &rb
);
25816 for (y
= 0; y
< texture_desc
.Height
&& all_match
; ++y
)
25818 depth
= min(max(0.0f
, depth_values
[y
] + bias
), 1.0f
);
25821 case DXGI_FORMAT_D32_FLOAT
:
25822 data
= get_readback_float(&rb
, 0, y
);
25823 all_match
= compare_float(data
, depth
, 64);
25825 "Got depth %.8e, expected %.8e.\n", data
, depth
);
25827 case DXGI_FORMAT_D24_UNORM_S8_UINT
:
25828 u32
= get_readback_data(&rb
, 0, y
, 0, sizeof(*u32
));
25829 u32_value
= *u32
>> shift
;
25830 expected_value
= depth
* 16777215.0f
+ 0.5f
;
25831 all_match
= abs(u32_value
- expected_value
) <= 3;
25833 "Got value %#x (%.8e), expected %#x (%.8e).\n",
25834 u32_value
, u32_value
/ 16777215.0f
,
25835 expected_value
, expected_value
/ 16777215.0f
);
25837 case DXGI_FORMAT_D16_UNORM
:
25838 u16
= get_readback_data(&rb
, 0, y
, 0, sizeof(*u16
));
25839 expected_value
= depth
* 65535.0f
+ 0.5f
;
25840 all_match
= abs(*u16
- expected_value
) <= 1;
25842 "Got value %#x (%.8e), expected %#x (%.8e).\n",
25843 *u16
, *u16
/ 65535.0f
, expected_value
, expected_value
/ 65535.0f
);
25849 release_resource_readback(&rb
);
25850 ID3D11RasterizerState_Release(rs
);
25855 ID3D11Texture2D_Release(texture
);
25856 ID3D11DepthStencilView_Release(dsv
);
25859 heap_free(depth_values
);
25860 release_test_context(&test_context
);
25863 static void test_fractional_viewports(void)
25865 struct d3d11_test_context test_context
;
25866 D3D11_TEXTURE2D_DESC texture_desc
;
25867 ID3D11InputLayout
*input_layout
;
25868 ID3D11DeviceContext
*context
;
25869 struct resource_readback rb
;
25870 ID3D11RenderTargetView
*rtv
;
25871 ID3D11VertexShader
*vs
;
25872 ID3D11PixelShader
*ps
;
25873 unsigned int i
, x
, y
;
25874 ID3D11Device
*device
;
25875 ID3D11Texture2D
*rt
;
25876 UINT offset
, stride
;
25880 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
25881 static const DWORD vs_code
[] =
25884 void main(in float4 in_position
: POSITION
,
25885 in float2 in_texcoord
: TEXCOORD
,
25886 out float4 position
: SV_Position
,
25887 out float2 texcoord
: TEXCOORD
)
25889 position
= in_position
;
25890 texcoord
= in_texcoord
;
25893 0x43425844, 0x4df282ca, 0x85c8bbfc, 0xd44ad19f, 0x1158be97, 0x00000001, 0x00000148, 0x00000003,
25894 0x0000002c, 0x00000080, 0x000000d8, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
25895 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
25896 0x00000003, 0x00000001, 0x00000303, 0x49534f50, 0x4e4f4954, 0x58455400, 0x524f4f43, 0xabab0044,
25897 0x4e47534f, 0x00000050, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
25898 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000c03,
25899 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f, 0xababab00, 0x52444853, 0x00000068,
25900 0x00010040, 0x0000001a, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x00101032, 0x00000001,
25901 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102032, 0x00000001, 0x05000036,
25902 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x00102032, 0x00000001, 0x00101046,
25903 0x00000001, 0x0100003e,
25905 static const DWORD ps_code
[] =
25908 float4
main(float4 position
: SV_Position
,
25909 float2 texcoord
: TEXCOORD
) : SV_Target
25911 return float4(position
.xy
, texcoord
);
25914 0x43425844, 0xa15616bc, 0x6862ab1c, 0x28b915c0, 0xdb0df67c, 0x00000001, 0x0000011c, 0x00000003,
25915 0x0000002c, 0x00000084, 0x000000b8, 0x4e475349, 0x00000050, 0x00000002, 0x00000008, 0x00000038,
25916 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x00000044, 0x00000000, 0x00000000,
25917 0x00000003, 0x00000001, 0x00000303, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f,
25918 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
25919 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x0000005c,
25920 0x00000040, 0x00000017, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03001062, 0x00101032,
25921 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036, 0x00102032, 0x00000000, 0x00101046,
25922 0x00000000, 0x05000036, 0x001020c2, 0x00000000, 0x00101406, 0x00000001, 0x0100003e,
25924 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
25926 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
25927 {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 8, D3D11_INPUT_PER_VERTEX_DATA
, 0},
25929 static const struct
25931 struct vec2 position
;
25932 struct vec2 texcoord
;
25936 {{-1.0f
, -1.0f
}, {0.0f
, 0.0f
}},
25937 {{-1.0f
, 1.0f
}, {0.0f
, 1.0f
}},
25938 {{ 1.0f
, -1.0f
}, {1.0f
, 0.0f
}},
25939 {{ 1.0f
, 1.0f
}, {1.0f
, 1.0f
}},
25941 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
25942 static const float viewport_offsets
[] =
25944 0.0f
, 1.0f
/ 2.0f
, 1.0f
/ 4.0f
, 1.0f
/ 8.0f
, 1.0f
/ 16.0f
, 1.0f
/ 32.0f
,
25945 1.0f
/ 64.0f
, 1.0f
/ 128.0f
, 1.0f
/ 256.0f
, 63.0f
/ 128.0f
,
25948 if (!init_test_context(&test_context
, &feature_level
))
25950 device
= test_context
.device
;
25951 context
= test_context
.immediate_context
;
25953 texture_desc
.Width
= 4;
25954 texture_desc
.Height
= 4;
25955 texture_desc
.MipLevels
= 1;
25956 texture_desc
.ArraySize
= 1;
25957 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
25958 texture_desc
.SampleDesc
.Count
= 1;
25959 texture_desc
.SampleDesc
.Quality
= 0;
25960 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
25961 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
25962 texture_desc
.CPUAccessFlags
= 0;
25963 texture_desc
.MiscFlags
= 0;
25964 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rt
);
25965 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
25966 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rt
, NULL
, &rtv
);
25967 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
25968 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
25970 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
25971 vs_code
, sizeof(vs_code
), &input_layout
);
25972 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
25973 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(quad
), quad
);
25975 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
25976 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
25977 stride
= sizeof(*quad
);
25979 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, &stride
, &offset
);
25981 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
25982 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
25983 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
25985 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
25986 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
25987 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
25989 for (i
= 0; i
< ARRAY_SIZE(viewport_offsets
); ++i
)
25991 set_viewport(context
, viewport_offsets
[i
], viewport_offsets
[i
],
25992 texture_desc
.Width
, texture_desc
.Height
, 0.0f
, 1.0f
);
25993 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, white
);
25994 ID3D11DeviceContext_Draw(context
, 4, 0);
25995 get_texture_readback(rt
, 0, &rb
);
25996 for (y
= 0; y
< texture_desc
.Height
; ++y
)
25998 for (x
= 0; x
< texture_desc
.Width
; ++x
)
26000 const struct vec4
*v
= get_readback_vec4(&rb
, x
, y
);
26001 struct vec4 expected
= {x
+ 0.5f
, y
+ 0.5f
,
26002 (x
+ 0.5f
- viewport_offsets
[i
]) / texture_desc
.Width
,
26003 1.0f
- (y
+ 0.5f
- viewport_offsets
[i
]) / texture_desc
.Height
};
26004 ok(compare_float(v
->x
, expected
.x
, 0) && compare_float(v
->y
, expected
.y
, 0),
26005 "Got fragcoord {%.8e, %.8e}, expected {%.8e, %.8e} at (%u, %u), offset %.8e.\n",
26006 v
->x
, v
->y
, expected
.x
, expected
.y
, x
, y
, viewport_offsets
[i
]);
26008 ok(compare_float(v
->z
, expected
.z
, 2) && compare_float(v
->w
, expected
.w
, 2),
26009 "Got texcoord {%.8e, %.8e}, expected {%.8e, %.8e} at (%u, %u), offset %.8e.\n",
26010 v
->z
, v
->w
, expected
.z
, expected
.w
, x
, y
, viewport_offsets
[i
]);
26013 release_resource_readback(&rb
);
26016 ID3D11InputLayout_Release(input_layout
);
26017 ID3D11Buffer_Release(vb
);
26018 ID3D11VertexShader_Release(vs
);
26019 ID3D11PixelShader_Release(ps
);
26020 ID3D11RenderTargetView_Release(rtv
);
26021 ID3D11Texture2D_Release(rt
);
26022 release_test_context(&test_context
);
26025 static void test_negative_viewports(const D3D_FEATURE_LEVEL feature_level
)
26027 struct d3d11_test_context test_context
;
26028 ID3D11DeviceContext
*context
;
26032 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
26033 static const struct vec4 green
= {0.0f
, 1.0f
, 0.0f
, 1.0f
};
26035 if (!init_test_context(&test_context
, &feature_level
))
26037 context
= test_context
.immediate_context
;
26039 set_viewport(context
, 0.0f
, 0.0f
, 640.0f
, 480.0f
, 0.0f
, 1.0f
);
26040 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
26041 draw_color_quad(&test_context
, &green
);
26042 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
26044 set_viewport(context
, -0.0f
, -0.0f
, 640.0f
, 480.0f
, 0.0f
, 1.0f
);
26045 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
26046 draw_color_quad(&test_context
, &green
);
26047 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
26049 /* For feature levels greater than or equal to 11_0, a negative top left
26050 * corner shifts the bottom right corner by a whole integer. It seems that
26051 * floor() is used to round viewport corners to integers.
26053 quirk
= feature_level
>= D3D_FEATURE_LEVEL_11_0
;
26055 set_viewport(context
, -0.4f
, -0.4f
, 640.0f
, 480.0f
, 0.0f
, 1.0f
);
26056 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
26057 draw_color_quad(&test_context
, &green
);
26058 SetRect(&rect
, 0, 0, 639, 479);
26059 check_texture_sub_resource_color(test_context
.backbuffer
, 0, &rect
, 0xff00ff00, 1);
26060 SetRect(&rect
, 639, 479, 640, 480);
26061 todo_wine_if(quirk
)
26062 check_texture_sub_resource_color(test_context
.backbuffer
, 0, &rect
, quirk
? 0xffffffff : 0xff00ff00, 1);
26064 set_viewport(context
, -1.0f
/ 128.0f
, -1.0 / 128.0f
, 640.0f
, 480.0f
, 0.0f
, 1.0f
);
26065 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
26066 draw_color_quad(&test_context
, &green
);
26067 SetRect(&rect
, 0, 0, 639, 479);
26068 check_texture_sub_resource_color(test_context
.backbuffer
, 0, &rect
, 0xff00ff00, 1);
26069 SetRect(&rect
, 639, 479, 640, 480);
26070 todo_wine_if(quirk
)
26071 check_texture_sub_resource_color(test_context
.backbuffer
, 0, &rect
, quirk
? 0xffffffff : 0xff00ff00, 1);
26073 release_test_context(&test_context
);
26076 static void test_early_depth_stencil(void)
26078 ID3D11DepthStencilState
*depth_stencil_state
;
26079 D3D11_DEPTH_STENCIL_DESC depth_stencil_desc
;
26080 ID3D11Texture2D
*texture
, *depth_texture
;
26081 struct d3d11_test_context test_context
;
26082 D3D11_TEXTURE2D_DESC texture_desc
;
26083 ID3D11UnorderedAccessView
*uav
;
26084 ID3D11DeviceContext
*context
;
26085 ID3D11DepthStencilView
*dsv
;
26086 ID3D11PixelShader
*ps
;
26087 ID3D11Device
*device
;
26090 static const DWORD ps_code
[] =
26093 RWTexture2D
<int> u
;
26095 [earlydepthstencil
]
26096 float4
main() : SV_Target
26098 InterlockedAdd(u
[uint2(0, 0)], 1);
26099 return float4(1.0f
, 1.0f
, 1.0f
, 1.0f
);
26102 0x43425844, 0xda4325ad, 0xc01d3815, 0xfd610cc9, 0x8ed1e351, 0x00000001, 0x000000ec, 0x00000003,
26103 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
26104 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
26105 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000074, 0x00000050, 0x0000001d,
26106 0x0100286a, 0x0400189c, 0x0011e000, 0x00000001, 0x00003333, 0x03000065, 0x001020f2, 0x00000000,
26107 0x0a0000ad, 0x0011e000, 0x00000001, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
26108 0x00004001, 0x00000001, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x3f800000,
26109 0x3f800000, 0x3f800000, 0x0100003e,
26111 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
26112 static const UINT values
[4] = {0};
26114 if (!init_test_context(&test_context
, &feature_level
))
26117 device
= test_context
.device
;
26118 context
= test_context
.immediate_context
;
26120 depth_stencil_desc
.DepthEnable
= TRUE
;
26121 depth_stencil_desc
.DepthWriteMask
= D3D11_DEPTH_WRITE_MASK_ZERO
;
26122 depth_stencil_desc
.DepthFunc
= D3D11_COMPARISON_LESS_EQUAL
;
26123 depth_stencil_desc
.StencilEnable
= FALSE
;
26124 hr
= ID3D11Device_CreateDepthStencilState(device
, &depth_stencil_desc
, &depth_stencil_state
);
26125 ok(SUCCEEDED(hr
), "Failed to create depth stencil state, hr %#x.\n", hr
);
26127 texture_desc
.Width
= 1;
26128 texture_desc
.Height
= 1;
26129 texture_desc
.MipLevels
= 1;
26130 texture_desc
.ArraySize
= 1;
26131 texture_desc
.Format
= DXGI_FORMAT_R32_SINT
;
26132 texture_desc
.SampleDesc
.Count
= 1;
26133 texture_desc
.SampleDesc
.Quality
= 0;
26134 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
26135 texture_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
26136 texture_desc
.CPUAccessFlags
= 0;
26137 texture_desc
.MiscFlags
= 0;
26138 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
26139 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
26140 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)texture
, NULL
, &uav
);
26141 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
26143 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
26144 texture_desc
.Format
= DXGI_FORMAT_D32_FLOAT
;
26145 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
26146 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
26147 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &depth_texture
);
26148 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
26149 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)depth_texture
, NULL
, &dsv
);
26150 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
26152 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
26153 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
26154 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
26156 set_viewport(context
, 0.0f
, 0.0f
, 1.0f
, 100.0f
, 0.5f
, 0.5f
);
26157 ID3D11DeviceContext_OMSetDepthStencilState(context
, depth_stencil_state
, 0);
26158 ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context
,
26159 1, &test_context
.backbuffer_rtv
, dsv
, 1, 1, &uav
, NULL
);
26161 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, values
);
26163 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 0.6f
, 0);
26164 draw_quad(&test_context
);
26165 check_texture_color(texture
, 100, 1);
26166 draw_quad(&test_context
);
26167 check_texture_color(texture
, 200, 1);
26168 check_texture_float(depth_texture
, 0.6f
, 1);
26170 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 0.3f
, 0);
26171 draw_quad(&test_context
);
26172 draw_quad(&test_context
);
26173 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 0.55f
, 0);
26174 draw_quad(&test_context
);
26175 check_texture_color(texture
, 300, 1);
26177 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 0.5f
, 0);
26178 draw_quad(&test_context
);
26179 check_texture_color(texture
, 400, 1);
26180 check_texture_float(depth_texture
, 0.5f
, 1);
26182 ID3D11Texture2D_Release(depth_texture
);
26183 ID3D11DepthStencilView_Release(dsv
);
26184 ID3D11DepthStencilState_Release(depth_stencil_state
);
26185 ID3D11PixelShader_Release(ps
);
26186 ID3D11Texture2D_Release(texture
);
26187 ID3D11UnorderedAccessView_Release(uav
);
26188 release_test_context(&test_context
);
26191 static void test_conservative_depth_output(void)
26199 ID3D11DepthStencilState
*depth_stencil_state
;
26200 D3D11_DEPTH_STENCIL_DESC depth_stencil_desc
;
26201 struct d3d11_test_context test_context
;
26202 const struct shader
*current_shader
;
26203 D3D11_TEXTURE2D_DESC texture_desc
;
26204 ID3D11DeviceContext
*context
;
26205 ID3D11DepthStencilView
*dsv
;
26206 ID3D11Texture2D
*texture
;
26207 ID3D11PixelShader
*ps
;
26208 DWORD expected_color
;
26209 float expected_depth
;
26210 ID3D11Device
*device
;
26211 struct vec4 ps_depth
;
26216 static const DWORD ps_depth_le_code
[] =
26221 float4
main(out
float out_depth
: SV_DepthLessEqual
) : SV_Target0
26224 return float4(0.0f
, 1.0f
, 0.f
, 1.0f
);
26227 0x43425844, 0x045c8d00, 0xc49e2ebe, 0x76f6022a, 0xf6996ecc, 0x00000001, 0x00000108, 0x00000003,
26228 0x0000002c, 0x0000003c, 0x00000098, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
26229 0x00000054, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
26230 0x0000000f, 0x00000042, 0x00000000, 0x00000000, 0x00000003, 0xffffffff, 0x00000e01, 0x545f5653,
26231 0x65677261, 0x56530074, 0x7065445f, 0x654c6874, 0x71457373, 0x006c6175, 0x58454853, 0x00000068,
26232 0x00000050, 0x0000001a, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065,
26233 0x001020f2, 0x00000000, 0x02000065, 0x00027001, 0x08000036, 0x001020f2, 0x00000000, 0x00004002,
26234 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x05000036, 0x00027001, 0x0020800a, 0x00000000,
26235 0x00000000, 0x0100003e,
26237 static const struct shader ps_depth_le
= {ps_depth_le_code
, sizeof(ps_depth_le_code
)};
26238 static const DWORD ps_depth_ge_code
[] =
26243 float4
main(out
float out_depth
: SV_DepthGreaterEqual
) : SV_Target0
26246 return float4(0.0f
, 1.0f
, 0.f
, 1.0f
);
26249 0x43425844, 0xd17af83e, 0xa32c01cc, 0x0d8e9665, 0xe6dc17c2, 0x00000001, 0x0000010c, 0x00000003,
26250 0x0000002c, 0x0000003c, 0x0000009c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
26251 0x00000058, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
26252 0x0000000f, 0x00000042, 0x00000000, 0x00000000, 0x00000003, 0xffffffff, 0x00000e01, 0x545f5653,
26253 0x65677261, 0x56530074, 0x7065445f, 0x72476874, 0x65746165, 0x75714572, 0xab006c61, 0x58454853,
26254 0x00000068, 0x00000050, 0x0000001a, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001,
26255 0x03000065, 0x001020f2, 0x00000000, 0x02000065, 0x00026001, 0x08000036, 0x001020f2, 0x00000000,
26256 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x05000036, 0x00026001, 0x0020800a,
26257 0x00000000, 0x00000000, 0x0100003e,
26259 static const struct shader ps_depth_ge
= {ps_depth_ge_code
, sizeof(ps_depth_ge_code
)};
26260 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
26261 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
26262 static const struct
26264 const struct shader
*ps
;
26267 BOOL passes_depth_test
;
26271 {&ps_depth_le
, 0.7f
, 0.7f
, TRUE
},
26272 {&ps_depth_le
, 0.7f
, 0.4f
, FALSE
},
26273 {&ps_depth_le
, 0.4f
, 0.4f
, FALSE
},
26274 /* {&ps_depth_le, 0.4f, 0.6f, FALSE}, undefined result */
26275 {&ps_depth_ge
, 0.7f
, 0.7f
, TRUE
},
26276 /* {&ps_depth_ge, 0.7f, 0.4f, TRUE}, undefined result */
26277 {&ps_depth_ge
, 0.4f
, 0.4f
, FALSE
},
26278 {&ps_depth_ge
, 0.4f
, 0.6f
, TRUE
},
26281 if (!init_test_context(&test_context
, &feature_level
))
26284 device
= test_context
.device
;
26285 context
= test_context
.immediate_context
;
26287 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(ps_depth
), NULL
);
26289 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
26290 texture_desc
.Format
= DXGI_FORMAT_D32_FLOAT
;
26291 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
26292 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
26293 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
26294 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
26295 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, NULL
, &dsv
);
26296 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
26298 depth_stencil_desc
.DepthEnable
= TRUE
;
26299 depth_stencil_desc
.DepthWriteMask
= D3D11_DEPTH_WRITE_MASK_ALL
;
26300 depth_stencil_desc
.DepthFunc
= D3D11_COMPARISON_GREATER_EQUAL
;
26301 depth_stencil_desc
.StencilEnable
= FALSE
;
26302 hr
= ID3D11Device_CreateDepthStencilState(device
, &depth_stencil_desc
, &depth_stencil_state
);
26303 ok(SUCCEEDED(hr
), "Failed to create depth stencil state, hr %#x.\n", hr
);
26305 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
26306 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &test_context
.backbuffer_rtv
, dsv
);
26307 ID3D11DeviceContext_OMSetDepthStencilState(context
, depth_stencil_state
, 0);
26310 current_shader
= NULL
;
26311 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
26313 if (current_shader
!= tests
[i
].ps
)
26316 ID3D11PixelShader_Release(ps
);
26318 current_shader
= tests
[i
].ps
;
26319 hr
= ID3D11Device_CreatePixelShader(device
, current_shader
->code
, current_shader
->size
, NULL
, &ps
);
26320 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
26321 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
26324 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
26325 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 0.5f
, 0);
26326 ps_depth
.x
= tests
[i
].ps_depth
;
26327 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &ps_depth
, 0, 0);
26328 draw_quad_z(&test_context
, tests
[i
].vs_depth
);
26330 expected_color
= tests
[i
].passes_depth_test
? 0xff00ff00 : 0xffffffff;
26331 expected_depth
= tests
[i
].passes_depth_test
? max(tests
[i
].vs_depth
, tests
[i
].ps_depth
) : 0.5f
;
26332 check_texture_color(test_context
.backbuffer
, expected_color
, 0);
26333 check_texture_float(texture
, expected_depth
, 1);
26336 ID3D11Buffer_Release(cb
);
26337 ID3D11PixelShader_Release(ps
);
26338 ID3D11DepthStencilView_Release(dsv
);
26339 ID3D11DepthStencilState_Release(depth_stencil_state
);
26340 ID3D11Texture2D_Release(texture
);
26341 release_test_context(&test_context
);
26344 static void test_format_compatibility(void)
26346 ID3D11Texture2D
*dst_texture
, *src_texture
;
26347 D3D11_SUBRESOURCE_DATA resource_data
;
26348 D3D11_TEXTURE2D_DESC texture_desc
;
26349 ID3D11DeviceContext
*context
;
26350 struct resource_readback rb
;
26351 DWORD colour
, expected
;
26352 ID3D11Device
*device
;
26357 static const struct
26359 DXGI_FORMAT src_format
;
26360 DXGI_FORMAT dst_format
;
26366 {DXGI_FORMAT_R8G8B8A8_TYPELESS
, DXGI_FORMAT_R8G8B8A8_UNORM
, 4, TRUE
},
26367 {DXGI_FORMAT_R8G8B8A8_UNORM
, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
, 4, TRUE
},
26368 {DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
, DXGI_FORMAT_R8G8B8A8_UINT
, 4, TRUE
},
26369 {DXGI_FORMAT_R8G8B8A8_UINT
, DXGI_FORMAT_R8G8B8A8_SNORM
, 4, TRUE
},
26370 {DXGI_FORMAT_R8G8B8A8_SNORM
, DXGI_FORMAT_R8G8B8A8_SINT
, 4, TRUE
},
26371 {DXGI_FORMAT_R8G8B8A8_SINT
, DXGI_FORMAT_R8G8B8A8_TYPELESS
, 4, TRUE
},
26372 {DXGI_FORMAT_R8G8B8A8_UNORM
, DXGI_FORMAT_B8G8R8A8_UNORM
, 4, FALSE
},
26373 {DXGI_FORMAT_R8G8B8A8_UINT
, DXGI_FORMAT_R16G16_UINT
, 4, FALSE
},
26374 {DXGI_FORMAT_R16G16_TYPELESS
, DXGI_FORMAT_R16G16_FLOAT
, 4, TRUE
},
26375 {DXGI_FORMAT_R16G16_FLOAT
, DXGI_FORMAT_R16G16_UNORM
, 4, TRUE
},
26376 {DXGI_FORMAT_R16G16_UNORM
, DXGI_FORMAT_R16G16_UINT
, 4, TRUE
},
26377 {DXGI_FORMAT_R16G16_UINT
, DXGI_FORMAT_R16G16_SNORM
, 4, TRUE
},
26378 {DXGI_FORMAT_R16G16_SNORM
, DXGI_FORMAT_R16G16_SINT
, 4, TRUE
},
26379 {DXGI_FORMAT_R16G16_SINT
, DXGI_FORMAT_R16G16_TYPELESS
, 4, TRUE
},
26380 {DXGI_FORMAT_R16G16_TYPELESS
, DXGI_FORMAT_R32_TYPELESS
, 4, FALSE
},
26381 {DXGI_FORMAT_R32G32_TYPELESS
, DXGI_FORMAT_R32G32_FLOAT
, 8, TRUE
},
26382 {DXGI_FORMAT_R32G32_FLOAT
, DXGI_FORMAT_R32G32_UINT
, 8, TRUE
},
26383 {DXGI_FORMAT_R32G32_UINT
, DXGI_FORMAT_R32G32_SINT
, 8, TRUE
},
26384 {DXGI_FORMAT_R32G32_SINT
, DXGI_FORMAT_R32G32_TYPELESS
, 8, TRUE
},
26386 static const DWORD initial_data
[16] = {0};
26387 static const DWORD bitmap_data
[] =
26389 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
26390 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
26391 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
26392 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
26395 if (!(device
= create_device(NULL
)))
26397 skip("Failed to create device.\n");
26400 ID3D11Device_GetImmediateContext(device
, &context
);
26402 texture_desc
.Height
= 4;
26403 texture_desc
.MipLevels
= 1;
26404 texture_desc
.ArraySize
= 1;
26405 texture_desc
.SampleDesc
.Count
= 1;
26406 texture_desc
.SampleDesc
.Quality
= 0;
26407 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
26408 texture_desc
.CPUAccessFlags
= 0;
26409 texture_desc
.MiscFlags
= 0;
26411 for (i
= 0; i
< ARRAY_SIZE(test_data
); ++i
)
26413 unsigned int x
, y
, texel_dwords
;
26416 texture_desc
.Width
= sizeof(bitmap_data
) / (texture_desc
.Height
* test_data
[i
].texel_size
);
26417 texture_desc
.Format
= test_data
[i
].src_format
;
26418 texture_desc
.Usage
= D3D11_USAGE_IMMUTABLE
;
26420 resource_data
.pSysMem
= bitmap_data
;
26421 resource_data
.SysMemPitch
= texture_desc
.Width
* test_data
[i
].texel_size
;
26422 resource_data
.SysMemSlicePitch
= 0;
26424 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &src_texture
);
26425 ok(SUCCEEDED(hr
), "Failed to create source texture, hr %#x.\n", hr
);
26427 texture_desc
.Format
= test_data
[i
].dst_format
;
26428 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
26430 resource_data
.pSysMem
= initial_data
;
26432 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &dst_texture
);
26433 ok(SUCCEEDED(hr
), "Failed to create destination texture, hr %#x.\n", hr
);
26435 set_box(&box
, 0, 0, 0, texture_desc
.Width
- 1, texture_desc
.Height
- 1, 1);
26436 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0, 1, 1, 0,
26437 (ID3D11Resource
*)src_texture
, 0, &box
);
26439 texel_dwords
= test_data
[i
].texel_size
/ sizeof(DWORD
);
26440 get_texture_readback(dst_texture
, 0, &rb
);
26441 for (j
= 0; j
< ARRAY_SIZE(bitmap_data
); ++j
)
26445 colour
= get_readback_color(&rb
, x
, y
, 0);
26446 expected
= test_data
[i
].success
&& x
>= texel_dwords
&& y
26447 ? bitmap_data
[j
- (4 + texel_dwords
)] : initial_data
[j
];
26448 ok(colour
== expected
, "Test %u: Got unexpected colour 0x%08x at (%u, %u), expected 0x%08x.\n",
26449 i
, colour
, x
, y
, expected
);
26451 release_resource_readback(&rb
);
26453 ID3D11DeviceContext_CopyResource(context
, (ID3D11Resource
*)dst_texture
, (ID3D11Resource
*)src_texture
);
26455 get_texture_readback(dst_texture
, 0, &rb
);
26456 for (j
= 0; j
< ARRAY_SIZE(bitmap_data
); ++j
)
26460 colour
= get_readback_color(&rb
, x
, y
, 0);
26461 expected
= test_data
[i
].success
? bitmap_data
[j
] : initial_data
[j
];
26462 ok(colour
== expected
, "Test %u: Got unexpected colour 0x%08x at (%u, %u), expected 0x%08x.\n",
26463 i
, colour
, x
, y
, expected
);
26465 release_resource_readback(&rb
);
26467 ID3D11Texture2D_Release(dst_texture
);
26468 ID3D11Texture2D_Release(src_texture
);
26471 ID3D11DeviceContext_Release(context
);
26472 refcount
= ID3D11Device_Release(device
);
26473 ok(!refcount
, "Device has %u references left.\n", refcount
);
26476 static void check_clip_distance(struct d3d11_test_context
*test_context
, ID3D11Buffer
*vb
)
26478 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
26481 float clip_distance0
;
26482 float clip_distance1
;
26485 ID3D11DeviceContext
*context
= test_context
->immediate_context
;
26486 struct resource_readback rb
;
26487 struct vertex vertices
[4];
26491 for (i
= 0; i
< ARRAY_SIZE(vertices
); ++i
)
26492 vertices
[i
].clip_distance0
= 1.0f
;
26493 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb
, 0, NULL
, vertices
, 0, 0);
26494 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
->backbuffer_rtv
, white
);
26495 ID3D11DeviceContext_Draw(context
, 4, 0);
26496 check_texture_color(test_context
->backbuffer
, 0xff00ff00, 1);
26498 for (i
= 0; i
< ARRAY_SIZE(vertices
); ++i
)
26499 vertices
[i
].clip_distance0
= 0.0f
;
26500 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb
, 0, NULL
, vertices
, 0, 0);
26501 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
->backbuffer_rtv
, white
);
26502 ID3D11DeviceContext_Draw(context
, 4, 0);
26503 check_texture_color(test_context
->backbuffer
, 0xff00ff00, 1);
26505 for (i
= 0; i
< ARRAY_SIZE(vertices
); ++i
)
26506 vertices
[i
].clip_distance0
= -1.0f
;
26507 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb
, 0, NULL
, vertices
, 0, 0);
26508 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
->backbuffer_rtv
, white
);
26509 ID3D11DeviceContext_Draw(context
, 4, 0);
26510 check_texture_color(test_context
->backbuffer
, 0xffffffff, 1);
26512 for (i
= 0; i
< ARRAY_SIZE(vertices
); ++i
)
26513 vertices
[i
].clip_distance0
= i
< 2 ? 1.0f
: -1.0f
;
26514 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb
, 0, NULL
, vertices
, 0, 0);
26515 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
->backbuffer_rtv
, white
);
26516 ID3D11DeviceContext_Draw(context
, 4, 0);
26517 get_texture_readback(test_context
->backbuffer
, 0, &rb
);
26518 SetRect(&rect
, 0, 0, 320, 480);
26519 check_readback_data_color(&rb
, &rect
, 0xff00ff00, 1);
26520 SetRect(&rect
, 320, 0, 320, 480);
26521 check_readback_data_color(&rb
, &rect
, 0xffffffff, 1);
26522 release_resource_readback(&rb
);
26524 for (i
= 0; i
< ARRAY_SIZE(vertices
); ++i
)
26525 vertices
[i
].clip_distance0
= i
% 2 ? 1.0f
: -1.0f
;
26526 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb
, 0, NULL
, vertices
, 0, 0);
26527 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
->backbuffer_rtv
, white
);
26528 ID3D11DeviceContext_Draw(context
, 4, 0);
26529 get_texture_readback(test_context
->backbuffer
, 0, &rb
);
26530 SetRect(&rect
, 0, 0, 640, 240);
26531 check_readback_data_color(&rb
, &rect
, 0xff00ff00, 1);
26532 SetRect(&rect
, 0, 240, 640, 240);
26533 check_readback_data_color(&rb
, &rect
, 0xffffffff, 1);
26534 release_resource_readback(&rb
);
26537 static void test_clip_distance(void)
26539 struct d3d11_test_context test_context
;
26540 ID3D11Buffer
*vs_cb
, *tess_cb
, *gs_cb
;
26541 D3D_FEATURE_LEVEL feature_level
;
26542 ID3D11DomainShader
*ds
= NULL
;
26543 ID3D11DeviceContext
*context
;
26544 struct resource_readback rb
;
26545 unsigned int offset
, stride
;
26546 ID3D11HullShader
*hs
= NULL
;
26547 ID3D11GeometryShader
*gs
;
26548 ID3D11Device
*device
;
26554 static const DWORD vs_code
[] =
26558 float clip_distance
;
26562 float4 position
: POSITION
;
26563 float distance0
: CLIP_DISTANCE0
;
26564 float distance1
: CLIP_DISTANCE1
;
26569 float4 position
: SV_POSITION
;
26570 float user_clip
: CLIP_DISTANCE
;
26571 float clip
: SV_ClipDistance
;
26574 void main(input vin
, out vertex vertex
)
26576 vertex
.position
= vin
.position
;
26577 vertex
.user_clip
= vin
.distance0
;
26578 vertex
.clip
= vin
.distance0
;
26580 vertex
.clip
= clip_distance
;
26583 0x43425844, 0x09dfef58, 0x88570f2e, 0x1ebcf953, 0x9f97e22a, 0x00000001, 0x000001dc, 0x00000003,
26584 0x0000002c, 0x0000009c, 0x00000120, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050,
26585 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000059, 0x00000000, 0x00000000,
26586 0x00000003, 0x00000001, 0x00000101, 0x00000059, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
26587 0x00000001, 0x49534f50, 0x4e4f4954, 0x494c4300, 0x49445f50, 0x4e415453, 0xab004543, 0x4e47534f,
26588 0x0000007c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000,
26589 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000e01, 0x0000006a,
26590 0x00000000, 0x00000002, 0x00000003, 0x00000002, 0x00000e01, 0x505f5653, 0x5449534f, 0x004e4f49,
26591 0x50494c43, 0x5349445f, 0x434e4154, 0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065,
26592 0x52444853, 0x000000b4, 0x00010040, 0x0000002d, 0x04000059, 0x00208e46, 0x00000000, 0x00000001,
26593 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x00101012, 0x00000001, 0x04000067, 0x001020f2,
26594 0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000001, 0x04000067, 0x00102012, 0x00000002,
26595 0x00000002, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x00102012,
26596 0x00000001, 0x0010100a, 0x00000001, 0x0b000037, 0x00102012, 0x00000002, 0x0020800a, 0x00000000,
26597 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0010100a, 0x00000001, 0x0100003e,
26599 static const DWORD vs_multiple_code
[] =
26603 float clip_distance0
;
26604 float clip_distance1
;
26608 float4 position
: POSITION
;
26609 float distance0
: CLIP_DISTANCE0
;
26610 float distance1
: CLIP_DISTANCE1
;
26615 float4 position
: SV_POSITION
;
26616 float user_clip
: CLIP_DISTANCE
;
26617 float2 clip
: SV_ClipDistance
;
26620 void main(input vin
, out vertex vertex
)
26622 vertex
.position
= vin
.position
;
26623 vertex
.user_clip
= vin
.distance0
;
26624 vertex
.clip
.x
= vin
.distance0
;
26626 vertex
.clip
.x
= clip_distance0
;
26627 vertex
.clip
.y
= vin
.distance1
;
26629 vertex
.clip
.y
= clip_distance1
;
26632 0x43425844, 0xef5cc236, 0xe2fbfa69, 0x560b6591, 0x23037999, 0x00000001, 0x00000214, 0x00000003,
26633 0x0000002c, 0x0000009c, 0x00000120, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050,
26634 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000059, 0x00000000, 0x00000000,
26635 0x00000003, 0x00000001, 0x00000101, 0x00000059, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
26636 0x00000101, 0x49534f50, 0x4e4f4954, 0x494c4300, 0x49445f50, 0x4e415453, 0xab004543, 0x4e47534f,
26637 0x0000007c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000,
26638 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000e01, 0x0000006a,
26639 0x00000000, 0x00000002, 0x00000003, 0x00000002, 0x00000c03, 0x505f5653, 0x5449534f, 0x004e4f49,
26640 0x50494c43, 0x5349445f, 0x434e4154, 0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065,
26641 0x52444853, 0x000000ec, 0x00010040, 0x0000003b, 0x04000059, 0x00208e46, 0x00000000, 0x00000001,
26642 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x00101012, 0x00000001, 0x0300005f, 0x00101012,
26643 0x00000002, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000001,
26644 0x04000067, 0x00102032, 0x00000002, 0x00000002, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46,
26645 0x00000000, 0x05000036, 0x00102012, 0x00000001, 0x0010100a, 0x00000001, 0x0b000037, 0x00102012,
26646 0x00000002, 0x0020800a, 0x00000000, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0010100a,
26647 0x00000001, 0x0b000037, 0x00102022, 0x00000002, 0x0020800a, 0x00000000, 0x00000000, 0x0020802a,
26648 0x00000000, 0x00000000, 0x0010100a, 0x00000002, 0x0100003e,
26652 float clip_distance0
;
26653 float clip_distance1
;
26654 float tessellation_factor
;
26658 float4 position
: SV_POSITION
;
26659 float user_clip
: CLIP_DISTANCE
;
26660 float clip
: SV_ClipDistance
;
26663 struct patch_constant_data
26665 float edges
[4] : SV_TessFactor
;
26666 float inside
[2] : SV_InsideTessFactor
;
26669 patch_constant_data
patch_constant()
26671 patch_constant_data output
;
26673 output
.edges
[0] = tessellation_factor
;
26674 output
.edges
[1] = tessellation_factor
;
26675 output
.edges
[2] = tessellation_factor
;
26676 output
.edges
[3] = tessellation_factor
;
26677 output
.inside
[0] = tessellation_factor
;
26678 output
.inside
[1] = tessellation_factor
;
26684 [outputcontrolpoints(4)]
26685 [outputtopology("triangle_cw")]
26686 [partitioning("pow2")]
26687 [patchconstantfunc("patch_constant")]
26688 vertex
hs_main(InputPatch
<vertex
, 4> input
,
26689 uint i
: SV_OutputControlPointID
)
26692 o
.position
= input
[i
].position
;
26693 o
.user_clip
= input
[i
].user_clip
;
26694 o
.clip
= input
[i
].user_clip
;
26698 float4
interpolate_vec(float4 a
, float4 b
, float4 c
, float4 d
, float2 tess_coord
)
26700 float4 e
= lerp(a
, b
, tess_coord
.x
);
26701 float4 f
= lerp(c
, d
, tess_coord
.x
);
26702 return lerp(e
, f
, tess_coord
.y
);
26705 float interpolate(float a
, float b
, float c
, float d
, float2 tess_coord
)
26707 float e
= lerp(a
, b
, tess_coord
.x
);
26708 float f
= lerp(c
, d
, tess_coord
.x
);
26709 return lerp(e
, f
, tess_coord
.y
);
26713 vertex
ds_main(patch_constant_data input
,
26714 float2 tess_coord
: SV_DomainLocation
,
26715 const OutputPatch
<vertex
, 4> patch
)
26719 output
.position
= interpolate_vec(patch
[0].position
, patch
[1].position
,
26720 patch
[2].position
, patch
[3].position
, tess_coord
);
26721 output
.user_clip
= interpolate(patch
[0].user_clip
, patch
[1].user_clip
,
26722 patch
[2].user_clip
, patch
[3].user_clip
, tess_coord
);
26723 output
.clip
= interpolate(patch
[0].clip
, patch
[1].clip
,
26724 patch
[2].clip
, patch
[3].clip
, tess_coord
);
26726 output
.clip
= clip_distance0
;
26731 static const DWORD hs_code
[] =
26733 0x43425844, 0x5a6d7564, 0x5f30a6c9, 0x2cf3b848, 0x5b4c6dca, 0x00000001, 0x00000414, 0x00000004,
26734 0x00000030, 0x000000b4, 0x00000138, 0x000001fc, 0x4e475349, 0x0000007c, 0x00000003, 0x00000008,
26735 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x0000005c, 0x00000000,
26736 0x00000000, 0x00000003, 0x00000001, 0x00000101, 0x0000006a, 0x00000000, 0x00000002, 0x00000003,
26737 0x00000002, 0x00000001, 0x505f5653, 0x5449534f, 0x004e4f49, 0x50494c43, 0x5349445f, 0x434e4154,
26738 0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065, 0x4e47534f, 0x0000007c, 0x00000003,
26739 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c,
26740 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000e01, 0x0000006a, 0x00000000, 0x00000002,
26741 0x00000003, 0x00000002, 0x00000e01, 0x505f5653, 0x5449534f, 0x004e4f49, 0x50494c43, 0x5349445f,
26742 0x434e4154, 0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065, 0x47534350, 0x000000bc,
26743 0x00000006, 0x00000008, 0x00000098, 0x00000000, 0x0000000b, 0x00000003, 0x00000000, 0x00000e01,
26744 0x00000098, 0x00000001, 0x0000000b, 0x00000003, 0x00000001, 0x00000e01, 0x00000098, 0x00000002,
26745 0x0000000b, 0x00000003, 0x00000002, 0x00000e01, 0x00000098, 0x00000003, 0x0000000b, 0x00000003,
26746 0x00000003, 0x00000e01, 0x000000a6, 0x00000000, 0x0000000c, 0x00000003, 0x00000004, 0x00000e01,
26747 0x000000a6, 0x00000001, 0x0000000c, 0x00000003, 0x00000005, 0x00000e01, 0x545f5653, 0x46737365,
26748 0x6f746361, 0x56530072, 0x736e495f, 0x54656469, 0x46737365, 0x6f746361, 0xabab0072, 0x58454853,
26749 0x00000210, 0x00030050, 0x00000084, 0x01000071, 0x01002093, 0x01002094, 0x01001895, 0x01001096,
26750 0x01001897, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x01000072, 0x0200005f,
26751 0x00016000, 0x0400005f, 0x002010f2, 0x00000004, 0x00000000, 0x0400005f, 0x00201012, 0x00000004,
26752 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x00102012, 0x00000001, 0x03000065,
26753 0x00102012, 0x00000002, 0x02000068, 0x00000001, 0x04000036, 0x00100012, 0x00000000, 0x00016001,
26754 0x07000036, 0x001020f2, 0x00000000, 0x00a01e46, 0x0010000a, 0x00000000, 0x00000000, 0x07000036,
26755 0x00102012, 0x00000001, 0x00a0100a, 0x0010000a, 0x00000000, 0x00000001, 0x07000036, 0x00102012,
26756 0x00000002, 0x00a0100a, 0x0010000a, 0x00000000, 0x00000001, 0x0100003e, 0x01000073, 0x02000099,
26757 0x00000004, 0x0200005f, 0x00017000, 0x04000067, 0x00102012, 0x00000000, 0x0000000b, 0x04000067,
26758 0x00102012, 0x00000001, 0x0000000c, 0x04000067, 0x00102012, 0x00000002, 0x0000000d, 0x04000067,
26759 0x00102012, 0x00000003, 0x0000000e, 0x02000068, 0x00000001, 0x0400005b, 0x00102012, 0x00000000,
26760 0x00000004, 0x04000036, 0x00100012, 0x00000000, 0x0001700a, 0x07000036, 0x00902012, 0x0010000a,
26761 0x00000000, 0x0020803a, 0x00000000, 0x00000000, 0x0100003e, 0x01000073, 0x02000099, 0x00000002,
26762 0x0200005f, 0x00017000, 0x04000067, 0x00102012, 0x00000004, 0x0000000f, 0x04000067, 0x00102012,
26763 0x00000005, 0x00000010, 0x02000068, 0x00000001, 0x0400005b, 0x00102012, 0x00000004, 0x00000002,
26764 0x04000036, 0x00100012, 0x00000000, 0x0001700a, 0x08000036, 0x00d02012, 0x00000004, 0x0010000a,
26765 0x00000000, 0x0020803a, 0x00000000, 0x00000000, 0x0100003e,
26767 static const DWORD ds_code
[] =
26769 0x43425844, 0xc54dc020, 0x063a9622, 0x6f649eb9, 0xceb1dd36, 0x00000001, 0x0000054c, 0x00000004,
26770 0x00000030, 0x000000b4, 0x00000178, 0x000001fc, 0x4e475349, 0x0000007c, 0x00000003, 0x00000008,
26771 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x0000005c, 0x00000000,
26772 0x00000000, 0x00000003, 0x00000001, 0x00000101, 0x0000006a, 0x00000000, 0x00000002, 0x00000003,
26773 0x00000002, 0x00000101, 0x505f5653, 0x5449534f, 0x004e4f49, 0x50494c43, 0x5349445f, 0x434e4154,
26774 0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065, 0x47534350, 0x000000bc, 0x00000006,
26775 0x00000008, 0x00000098, 0x00000000, 0x0000000b, 0x00000003, 0x00000000, 0x00000001, 0x00000098,
26776 0x00000001, 0x0000000b, 0x00000003, 0x00000001, 0x00000001, 0x00000098, 0x00000002, 0x0000000b,
26777 0x00000003, 0x00000002, 0x00000001, 0x00000098, 0x00000003, 0x0000000b, 0x00000003, 0x00000003,
26778 0x00000001, 0x000000a6, 0x00000000, 0x0000000c, 0x00000003, 0x00000004, 0x00000001, 0x000000a6,
26779 0x00000001, 0x0000000c, 0x00000003, 0x00000005, 0x00000001, 0x545f5653, 0x46737365, 0x6f746361,
26780 0x56530072, 0x736e495f, 0x54656469, 0x46737365, 0x6f746361, 0xabab0072, 0x4e47534f, 0x0000007c,
26781 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
26782 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000e01, 0x0000006a, 0x00000000,
26783 0x00000002, 0x00000003, 0x00000002, 0x00000e01, 0x505f5653, 0x5449534f, 0x004e4f49, 0x50494c43,
26784 0x5349445f, 0x434e4154, 0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065, 0x58454853,
26785 0x00000348, 0x00040050, 0x000000d2, 0x01002093, 0x01001895, 0x0100086a, 0x04000059, 0x00208e46,
26786 0x00000000, 0x00000001, 0x0200005f, 0x0001c032, 0x0400005f, 0x002190f2, 0x00000004, 0x00000000,
26787 0x0400005f, 0x00219012, 0x00000004, 0x00000001, 0x0400005f, 0x00219012, 0x00000004, 0x00000002,
26788 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000001, 0x04000067,
26789 0x00102012, 0x00000002, 0x00000002, 0x02000068, 0x00000002, 0x0a000000, 0x001000f2, 0x00000000,
26790 0x80219e46, 0x00000041, 0x00000002, 0x00000000, 0x00219e46, 0x00000003, 0x00000000, 0x09000032,
26791 0x001000f2, 0x00000000, 0x0001c006, 0x00100e46, 0x00000000, 0x00219e46, 0x00000002, 0x00000000,
26792 0x0a000000, 0x001000f2, 0x00000001, 0x80219e46, 0x00000041, 0x00000000, 0x00000000, 0x00219e46,
26793 0x00000001, 0x00000000, 0x09000032, 0x001000f2, 0x00000001, 0x0001c006, 0x00100e46, 0x00000001,
26794 0x00219e46, 0x00000000, 0x00000000, 0x08000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
26795 0x80100e46, 0x00000041, 0x00000001, 0x08000032, 0x001020f2, 0x00000000, 0x0001c556, 0x00100e46,
26796 0x00000000, 0x00100e46, 0x00000001, 0x0a000000, 0x00100012, 0x00000000, 0x8021900a, 0x00000041,
26797 0x00000002, 0x00000001, 0x0021900a, 0x00000003, 0x00000001, 0x09000032, 0x00100012, 0x00000000,
26798 0x0001c00a, 0x0010000a, 0x00000000, 0x0021900a, 0x00000002, 0x00000001, 0x0a000000, 0x00100022,
26799 0x00000000, 0x8021900a, 0x00000041, 0x00000000, 0x00000001, 0x0021900a, 0x00000001, 0x00000001,
26800 0x09000032, 0x00100022, 0x00000000, 0x0001c00a, 0x0010001a, 0x00000000, 0x0021900a, 0x00000000,
26801 0x00000001, 0x08000000, 0x00100012, 0x00000000, 0x8010001a, 0x00000041, 0x00000000, 0x0010000a,
26802 0x00000000, 0x08000032, 0x00102012, 0x00000001, 0x0001c01a, 0x0010000a, 0x00000000, 0x0010001a,
26803 0x00000000, 0x0a000000, 0x00100012, 0x00000000, 0x8021900a, 0x00000041, 0x00000002, 0x00000002,
26804 0x0021900a, 0x00000003, 0x00000002, 0x09000032, 0x00100012, 0x00000000, 0x0001c00a, 0x0010000a,
26805 0x00000000, 0x0021900a, 0x00000002, 0x00000002, 0x0a000000, 0x00100022, 0x00000000, 0x8021900a,
26806 0x00000041, 0x00000000, 0x00000002, 0x0021900a, 0x00000001, 0x00000002, 0x09000032, 0x00100022,
26807 0x00000000, 0x0001c00a, 0x0010001a, 0x00000000, 0x0021900a, 0x00000000, 0x00000002, 0x08000000,
26808 0x00100012, 0x00000000, 0x8010001a, 0x00000041, 0x00000000, 0x0010000a, 0x00000000, 0x08000032,
26809 0x00100012, 0x00000000, 0x0001c01a, 0x0010000a, 0x00000000, 0x0010001a, 0x00000000, 0x0b000037,
26810 0x00102012, 0x00000002, 0x0020800a, 0x00000000, 0x00000000, 0x0020801a, 0x00000000, 0x00000000,
26811 0x0010000a, 0x00000000, 0x0100003e,
26813 static const DWORD gs_code
[] =
26817 float clip_distance
;
26821 float4 position
: SV_POSITION
;
26822 float user_clip
: CLIP_DISTANCE
;
26823 float clip
: SV_ClipDistance
;
26826 [maxvertexcount(3)]
26827 void main(triangle vertex input
[3], inout TriangleStream
<vertex
> output
)
26831 o
.clip
= input
[0].user_clip
;
26833 o
.clip
= clip_distance
;
26836 o
.clip
= input
[1].user_clip
;
26838 o
.clip
= clip_distance
;
26841 o
.clip
= input
[2].user_clip
;
26843 o
.clip
= clip_distance
;
26847 0x43425844, 0x9b0823e9, 0xab3ed100, 0xba0ff618, 0x1bbd1cb8, 0x00000001, 0x00000338, 0x00000003,
26848 0x0000002c, 0x000000b0, 0x00000134, 0x4e475349, 0x0000007c, 0x00000003, 0x00000008, 0x00000050,
26849 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x0000005c, 0x00000000, 0x00000000,
26850 0x00000003, 0x00000001, 0x00000101, 0x0000006a, 0x00000000, 0x00000002, 0x00000003, 0x00000002,
26851 0x00000001, 0x505f5653, 0x5449534f, 0x004e4f49, 0x50494c43, 0x5349445f, 0x434e4154, 0x56530045,
26852 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065, 0x4e47534f, 0x0000007c, 0x00000003, 0x00000008,
26853 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
26854 0x00000000, 0x00000003, 0x00000001, 0x00000e01, 0x0000006a, 0x00000000, 0x00000002, 0x00000003,
26855 0x00000002, 0x00000e01, 0x505f5653, 0x5449534f, 0x004e4f49, 0x50494c43, 0x5349445f, 0x434e4154,
26856 0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065, 0x52444853, 0x000001fc, 0x00020040,
26857 0x0000007f, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x05000061, 0x002010f2, 0x00000003,
26858 0x00000000, 0x00000001, 0x0400005f, 0x00201012, 0x00000003, 0x00000001, 0x0400005f, 0x00201012,
26859 0x00000003, 0x00000002, 0x02000068, 0x00000001, 0x0100185d, 0x0100285c, 0x04000067, 0x001020f2,
26860 0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000001, 0x04000067, 0x00102012, 0x00000002,
26861 0x00000002, 0x0200005e, 0x00000003, 0x06000036, 0x001020f2, 0x00000000, 0x00201e46, 0x00000000,
26862 0x00000000, 0x06000036, 0x00102012, 0x00000001, 0x0020100a, 0x00000000, 0x00000001, 0x0c000037,
26863 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x0020801a, 0x00000000, 0x00000000,
26864 0x0020100a, 0x00000000, 0x00000001, 0x05000036, 0x00102012, 0x00000002, 0x0010000a, 0x00000000,
26865 0x01000013, 0x06000036, 0x001020f2, 0x00000000, 0x00201e46, 0x00000001, 0x00000000, 0x06000036,
26866 0x00102012, 0x00000001, 0x0020100a, 0x00000001, 0x00000001, 0x0c000037, 0x00100012, 0x00000000,
26867 0x0020800a, 0x00000000, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0020100a, 0x00000001,
26868 0x00000001, 0x05000036, 0x00102012, 0x00000002, 0x0010000a, 0x00000000, 0x01000013, 0x06000036,
26869 0x001020f2, 0x00000000, 0x00201e46, 0x00000002, 0x00000000, 0x06000036, 0x00102012, 0x00000001,
26870 0x0020100a, 0x00000002, 0x00000001, 0x0c000037, 0x00100012, 0x00000000, 0x0020800a, 0x00000000,
26871 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0020100a, 0x00000002, 0x00000001, 0x05000036,
26872 0x00102012, 0x00000002, 0x0010000a, 0x00000000, 0x01000013, 0x0100003e,
26874 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
26876 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
26877 {"CLIP_DISTANCE", 0, DXGI_FORMAT_R32_FLOAT
, 1, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
26878 {"CLIP_DISTANCE", 1, DXGI_FORMAT_R32_FLOAT
, 1, 4, D3D11_INPUT_PER_VERTEX_DATA
, 0},
26882 float clip_distance0
;
26883 float clip_distance1
;
26892 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
26893 static const struct vec4 green
= {0.0f
, 1.0f
, 0.0f
, 1.0f
};
26897 float clip_distance0
;
26898 float clip_distance1
;
26899 float tessellation_factor
;
26902 if (!init_test_context(&test_context
, NULL
))
26904 device
= test_context
.device
;
26905 context
= test_context
.immediate_context
;
26906 feature_level
= ID3D11Device_GetFeatureLevel(device
);
26908 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
26909 vs_code
, sizeof(vs_code
), &test_context
.input_layout
);
26910 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
26912 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(vertices
), vertices
);
26913 stride
= sizeof(*vertices
);
26915 ID3D11DeviceContext_IASetVertexBuffers(context
, 1, 1, &vb
, &stride
, &offset
);
26917 memset(&cb_data
, 0, sizeof(cb_data
));
26918 cb_data
.tessellation_factor
= 1.0f
;
26919 vs_cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(cb_data
), &cb_data
);
26920 ID3D11DeviceContext_VSSetConstantBuffers(context
, 0, 1, &vs_cb
);
26921 tess_cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(cb_data
), &cb_data
);
26922 ID3D11DeviceContext_HSSetConstantBuffers(context
, 0, 1, &tess_cb
);
26923 ID3D11DeviceContext_DSSetConstantBuffers(context
, 0, 1, &tess_cb
);
26924 gs_cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(cb_data
), &cb_data
);
26925 ID3D11DeviceContext_GSSetConstantBuffers(context
, 0, 1, &gs_cb
);
26927 /* vertex shader */
26928 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
26929 draw_color_quad_vs(&test_context
, &green
, vs_code
, sizeof(vs_code
));
26930 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
26932 check_clip_distance(&test_context
, vb
);
26934 cb_data
.use_constant
= TRUE
;
26935 cb_data
.clip_distance0
= -1.0f
;
26936 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vs_cb
, 0, NULL
, &cb_data
, 0, 0);
26938 /* tessellation shaders */
26939 if (feature_level
>= D3D_FEATURE_LEVEL_11_0
)
26941 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST
);
26943 hr
= ID3D11Device_CreateHullShader(device
, hs_code
, sizeof(hs_code
), NULL
, &hs
);
26944 ok(SUCCEEDED(hr
), "Failed to create hull shader, hr %#x.\n", hr
);
26945 ID3D11DeviceContext_HSSetShader(context
, hs
, NULL
, 0);
26946 hr
= ID3D11Device_CreateDomainShader(device
, ds_code
, sizeof(ds_code
), NULL
, &ds
);
26947 ok(SUCCEEDED(hr
), "Failed to create domain shader, hr %#x.\n", hr
);
26948 ID3D11DeviceContext_DSSetShader(context
, ds
, NULL
, 0);
26950 check_clip_distance(&test_context
, vb
);
26952 cb_data
.use_constant
= FALSE
;
26953 cb_data
.tessellation_factor
= 2.0f
;
26954 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)tess_cb
, 0, NULL
, &cb_data
, 0, 0);
26956 for (i
= 0; i
< ARRAY_SIZE(vertices
); ++i
)
26957 vertices
[i
].clip_distance0
= 1.0f
;
26958 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb
, 0, NULL
, vertices
, 0, 0);
26959 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
26960 ID3D11DeviceContext_Draw(context
, 4, 0);
26961 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
26963 cb_data
.use_constant
= TRUE
;
26964 cb_data
.clip_distance0
= -1.0f
;
26965 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)tess_cb
, 0, NULL
, &cb_data
, 0, 0);
26969 skip("Tessellation shaders are not supported.\n");
26972 /* geometry shader */
26973 hr
= ID3D11Device_CreateGeometryShader(device
, gs_code
, sizeof(gs_code
), NULL
, &gs
);
26974 ok(SUCCEEDED(hr
), "Failed to create geometry shader, hr %#x.\n", hr
);
26975 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
26977 check_clip_distance(&test_context
, vb
);
26979 cb_data
.use_constant
= TRUE
;
26980 cb_data
.clip_distance0
= 1.0f
;
26981 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)gs_cb
, 0, NULL
, &cb_data
, 0, 0);
26982 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
26983 ID3D11DeviceContext_Draw(context
, 4, 0);
26984 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
26986 /* multiple clip distances */
26987 ID3D11DeviceContext_HSSetShader(context
, NULL
, NULL
, 0);
26988 ID3D11DeviceContext_DSSetShader(context
, NULL
, NULL
, 0);
26989 ID3D11DeviceContext_GSSetShader(context
, NULL
, NULL
, 0);
26991 cb_data
.use_constant
= FALSE
;
26992 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vs_cb
, 0, NULL
, &cb_data
, 0, 0);
26994 for (i
= 0; i
< ARRAY_SIZE(vertices
); ++i
)
26995 vertices
[i
].clip_distance0
= 1.0f
;
26996 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb
, 0, NULL
, vertices
, 0, 0);
26997 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
26998 draw_color_quad_vs(&test_context
, &green
, vs_multiple_code
, sizeof(vs_multiple_code
));
26999 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
27001 for (i
= 0; i
< ARRAY_SIZE(vertices
); ++i
)
27003 vertices
[i
].clip_distance0
= i
< 2 ? 1.0f
: -1.0f
;
27004 vertices
[i
].clip_distance1
= i
% 2 ? 1.0f
: -1.0f
;
27006 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb
, 0, NULL
, vertices
, 0, 0);
27007 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
27008 draw_color_quad_vs(&test_context
, &green
, vs_multiple_code
, sizeof(vs_multiple_code
));
27009 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
27010 SetRect(&rect
, 0, 0, 320, 240);
27011 check_readback_data_color(&rb
, &rect
, 0xff00ff00, 1);
27012 SetRect(&rect
, 0, 240, 320, 480);
27013 check_readback_data_color(&rb
, &rect
, 0xffffffff, 1);
27014 SetRect(&rect
, 320, 0, 640, 480);
27015 check_readback_data_color(&rb
, &rect
, 0xffffffff, 1);
27016 release_resource_readback(&rb
);
27018 cb_data
.use_constant
= TRUE
;
27019 cb_data
.clip_distance0
= 0.0f
;
27020 cb_data
.clip_distance1
= 0.0f
;
27021 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vs_cb
, 0, NULL
, &cb_data
, 0, 0);
27022 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
27023 draw_color_quad_vs(&test_context
, &green
, vs_multiple_code
, sizeof(vs_multiple_code
));
27024 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
27027 ID3D11HullShader_Release(hs
);
27029 ID3D11DomainShader_Release(ds
);
27030 ID3D11GeometryShader_Release(gs
);
27031 ID3D11Buffer_Release(vb
);
27032 ID3D11Buffer_Release(vs_cb
);
27033 ID3D11Buffer_Release(tess_cb
);
27034 ID3D11Buffer_Release(gs_cb
);
27035 release_test_context(&test_context
);
27038 static void test_combined_clip_and_cull_distances(void)
27040 struct d3d11_test_context test_context
;
27041 ID3D11DeviceContext
*context
;
27042 struct resource_readback rb
;
27043 unsigned int offset
, stride
;
27044 ID3D11Device
*device
;
27045 unsigned int i
, j
, k
;
27049 static const DWORD vs_code
[] =
27054 float4 position
: POSITION
;
27055 float clip0
: CLIP_DISTANCE0
;
27056 float clip1
: CLIP_DISTANCE1
;
27057 float clip2
: CLIP_DISTANCE2
;
27058 float clip3
: CLIP_DISTANCE3
;
27059 float cull0
: CULL_DISTANCE0
;
27060 float cull1
: CULL_DISTANCE1
;
27061 float cull2
: CULL_DISTANCE2
;
27062 float cull3
: CULL_DISTANCE3
;
27067 float4 position
: SV_Position
;
27068 float3 clip0
: SV_ClipDistance1
;
27069 float3 cull0
: SV_CullDistance1
;
27070 float clip1
: SV_ClipDistance2
;
27071 float cull1
: SV_CullDistance2
;
27074 void main(input vin
, out vertex vertex
)
27076 vertex
.position
= vin
.position
;
27077 vertex
.clip0
= float3(vin
.clip0
, vin
.clip1
, vin
.clip2
);
27078 vertex
.cull0
= float3(vin
.cull0
, vin
.cull1
, vin
.cull2
);
27079 vertex
.clip1
= vin
.clip3
;
27080 vertex
.cull1
= vin
.cull3
;
27083 0x43425844, 0xa24fb3ea, 0x92e2c2b0, 0xb599b1b9, 0xd671f830, 0x00000001, 0x00000374, 0x00000003,
27084 0x0000002c, 0x0000013c, 0x000001f0, 0x4e475349, 0x00000108, 0x00000009, 0x00000008, 0x000000e0,
27085 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x000000e9, 0x00000000, 0x00000000,
27086 0x00000003, 0x00000001, 0x00000101, 0x000000e9, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
27087 0x00000101, 0x000000e9, 0x00000002, 0x00000000, 0x00000003, 0x00000003, 0x00000101, 0x000000e9,
27088 0x00000003, 0x00000000, 0x00000003, 0x00000004, 0x00000101, 0x000000f7, 0x00000000, 0x00000000,
27089 0x00000003, 0x00000005, 0x00000101, 0x000000f7, 0x00000001, 0x00000000, 0x00000003, 0x00000006,
27090 0x00000101, 0x000000f7, 0x00000002, 0x00000000, 0x00000003, 0x00000007, 0x00000101, 0x000000f7,
27091 0x00000003, 0x00000000, 0x00000003, 0x00000008, 0x00000101, 0x49534f50, 0x4e4f4954, 0x494c4300,
27092 0x49445f50, 0x4e415453, 0x43004543, 0x5f4c4c55, 0x54534944, 0x45434e41, 0xababab00, 0x4e47534f,
27093 0x000000ac, 0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000001, 0x00000003, 0x00000000,
27094 0x0000000f, 0x0000008c, 0x00000000, 0x00000002, 0x00000003, 0x00000001, 0x00000807, 0x0000008c,
27095 0x00000001, 0x00000002, 0x00000003, 0x00000001, 0x00000708, 0x0000009c, 0x00000000, 0x00000003,
27096 0x00000003, 0x00000002, 0x00000807, 0x0000009c, 0x00000001, 0x00000003, 0x00000003, 0x00000002,
27097 0x00000708, 0x505f5653, 0x7469736f, 0x006e6f69, 0x435f5653, 0x4470696c, 0x61747369, 0x0065636e,
27098 0x435f5653, 0x446c6c75, 0x61747369, 0x0065636e, 0x52444853, 0x0000017c, 0x00010040, 0x0000005f,
27099 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x00101012, 0x00000001, 0x0300005f, 0x00101012,
27100 0x00000002, 0x0300005f, 0x00101012, 0x00000003, 0x0300005f, 0x00101012, 0x00000004, 0x0300005f,
27101 0x00101012, 0x00000005, 0x0300005f, 0x00101012, 0x00000006, 0x0300005f, 0x00101012, 0x00000007,
27102 0x0300005f, 0x00101012, 0x00000008, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x04000067,
27103 0x00102072, 0x00000001, 0x00000002, 0x04000067, 0x00102082, 0x00000001, 0x00000002, 0x04000067,
27104 0x00102072, 0x00000002, 0x00000003, 0x04000067, 0x00102082, 0x00000002, 0x00000003, 0x05000036,
27105 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x00102012, 0x00000001, 0x0010100a,
27106 0x00000001, 0x05000036, 0x00102022, 0x00000001, 0x0010100a, 0x00000002, 0x05000036, 0x00102042,
27107 0x00000001, 0x0010100a, 0x00000003, 0x05000036, 0x00102082, 0x00000001, 0x0010100a, 0x00000004,
27108 0x05000036, 0x00102012, 0x00000002, 0x0010100a, 0x00000005, 0x05000036, 0x00102022, 0x00000002,
27109 0x0010100a, 0x00000006, 0x05000036, 0x00102042, 0x00000002, 0x0010100a, 0x00000007, 0x05000036,
27110 0x00102082, 0x00000002, 0x0010100a, 0x00000008, 0x0100003e,
27112 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
27114 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
27115 {"CLIP_DISTANCE", 0, DXGI_FORMAT_R32_FLOAT
, 1, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
27116 {"CLIP_DISTANCE", 1, DXGI_FORMAT_R32_FLOAT
, 1, 4, D3D11_INPUT_PER_VERTEX_DATA
, 0},
27117 {"CLIP_DISTANCE", 2, DXGI_FORMAT_R32_FLOAT
, 1, 8, D3D11_INPUT_PER_VERTEX_DATA
, 0},
27118 {"CLIP_DISTANCE", 3, DXGI_FORMAT_R32_FLOAT
, 1, 12, D3D11_INPUT_PER_VERTEX_DATA
, 0},
27119 {"CULL_DISTANCE", 0, DXGI_FORMAT_R32_FLOAT
, 1, 16, D3D11_INPUT_PER_VERTEX_DATA
, 0},
27120 {"CULL_DISTANCE", 1, DXGI_FORMAT_R32_FLOAT
, 1, 20, D3D11_INPUT_PER_VERTEX_DATA
, 0},
27121 {"CULL_DISTANCE", 2, DXGI_FORMAT_R32_FLOAT
, 1, 24, D3D11_INPUT_PER_VERTEX_DATA
, 0},
27122 {"CULL_DISTANCE", 3, DXGI_FORMAT_R32_FLOAT
, 1, 28, D3D11_INPUT_PER_VERTEX_DATA
, 0},
27126 float clip_distance
[4];
27127 float cull_distance
[4];
27131 {{1.0f
, 1.0f
, 1.0f
, 1.0f
}, {1.0f
, 1.0f
, 1.0f
, 1.0f
}},
27132 {{1.0f
, 1.0f
, 1.0f
, 1.0f
}, {1.0f
, 1.0f
, 1.0f
, 1.0f
}},
27133 {{1.0f
, 1.0f
, 1.0f
, 1.0f
}, {1.0f
, 1.0f
, 1.0f
, 1.0f
}},
27134 {{1.0f
, 1.0f
, 1.0f
, 1.0f
}, {1.0f
, 1.0f
, 1.0f
, 1.0f
}},
27136 static const struct test
27139 BOOL triangle_visible
[2];
27141 cull_distance_tests
[] =
27143 {{-1.0f
, 1.0f
, 1.0f
, 1.0f
}, {TRUE
, TRUE
}},
27144 {{ 1.0f
, -1.0f
, 1.0f
, 1.0f
}, {TRUE
, TRUE
}},
27145 {{ 1.0f
, 1.0f
, 1.0f
, -1.0f
}, {TRUE
, TRUE
}},
27146 {{-1.0f
, -1.0f
, 1.0f
, 1.0f
}, {TRUE
, TRUE
}},
27147 {{-1.0f
, 1.0f
, -1.0f
, 1.0f
}, {TRUE
, TRUE
}},
27148 {{-1.0f
, 1.0f
, 1.0f
, -1.0f
}, {TRUE
, TRUE
}},
27149 {{ 1.0f
, -1.0f
, -1.0f
, 1.0f
}, {TRUE
, TRUE
}},
27150 {{ 1.0f
, -1.0f
, 1.0f
, -1.0f
}, {TRUE
, TRUE
}},
27151 {{ 1.0f
, 1.0f
, -1.0f
, -1.0f
}, {TRUE
, TRUE
}},
27153 {{-1.0f
, -1.0f
, -1.0f
, 1.0f
}, {FALSE
, TRUE
}},
27154 {{-1.0f
, -1.0f
, 1.0f
, -1.0f
}, {TRUE
, TRUE
}},
27155 {{-1.0f
, -1.0f
, 1.0f
, -1.0f
}, {TRUE
, TRUE
}},
27156 {{-1.0f
, 1.0f
, -1.0f
, -1.0f
}, {TRUE
, TRUE
}},
27157 {{ 1.0f
, -1.0f
, -1.0f
, -1.0f
}, {TRUE
, FALSE
}},
27159 {{-1.0f
, -1.0f
, -1.0f
, -1.0f
}, {FALSE
, FALSE
}},
27161 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
27162 static const struct vec4 green
= {0.0f
, 1.0f
, 0.0f
, 1.0f
};
27164 if (!init_test_context(&test_context
, NULL
))
27166 device
= test_context
.device
;
27167 context
= test_context
.immediate_context
;
27169 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
27170 vs_code
, sizeof(vs_code
), &test_context
.input_layout
);
27171 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
27173 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(vertices
), vertices
);
27174 stride
= sizeof(*vertices
);
27176 ID3D11DeviceContext_IASetVertexBuffers(context
, 1, 1, &vb
, &stride
, &offset
);
27178 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
27179 draw_color_quad(&test_context
, &green
);
27180 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
27182 for (i
= 0; i
< ARRAY_SIZE(vertices
->cull_distance
); ++i
)
27184 for (j
= 0; j
< ARRAY_SIZE(cull_distance_tests
); ++j
)
27186 const struct test
*test
= &cull_distance_tests
[j
];
27187 unsigned int expected_color
[ARRAY_SIZE(test
->triangle_visible
)];
27188 unsigned int color
;
27190 for (k
= 0; k
< ARRAY_SIZE(vertices
); ++k
)
27191 vertices
[k
].cull_distance
[i
] = test
->vertices
[k
];
27192 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb
, 0, NULL
, vertices
, 0, 0);
27194 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
27195 draw_color_quad_vs(&test_context
, &green
, vs_code
, sizeof(vs_code
));
27197 for (k
= 0; k
< ARRAY_SIZE(expected_color
); ++k
)
27198 expected_color
[k
] = test
->triangle_visible
[k
] ? 0xff00ff00 : 0xffffffff;
27200 if (expected_color
[0] == expected_color
[1])
27202 check_texture_color(test_context
.backbuffer
, *expected_color
, 1);
27206 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
27207 color
= get_readback_color(&rb
, 160, 240, 0);
27208 ok(color
== expected_color
[0], "Got unexpected color 0x%08x.\n", color
);
27209 color
= get_readback_color(&rb
, 480, 240, 0);
27210 ok(color
== expected_color
[1], "Got unexpected color 0x%08x.\n", color
);
27211 release_resource_readback(&rb
);
27215 for (j
= 0; j
< ARRAY_SIZE(vertices
); ++j
)
27216 vertices
[j
].cull_distance
[i
] = 1.0f
;
27219 for (i
= 0; i
< ARRAY_SIZE(vertices
->clip_distance
); ++i
)
27221 for (j
= 0; j
< ARRAY_SIZE(vertices
); ++j
)
27222 vertices
[j
].clip_distance
[i
] = -1.0f
;
27223 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb
, 0, NULL
, vertices
, 0, 0);
27225 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
27226 draw_color_quad_vs(&test_context
, &green
, vs_code
, sizeof(vs_code
));
27227 check_texture_color(test_context
.backbuffer
, 0xffffffff, 1);
27229 for (j
= 0; j
< ARRAY_SIZE(vertices
); ++j
)
27230 vertices
[j
].clip_distance
[i
] = 1.0f
;
27233 memset(vertices
, 0, sizeof(vertices
));
27234 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb
, 0, NULL
, vertices
, 0, 0);
27235 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
27236 draw_color_quad_vs(&test_context
, &green
, vs_code
, sizeof(vs_code
));
27237 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
27239 ID3D11Buffer_Release(vb
);
27240 release_test_context(&test_context
);
27243 static void test_generate_mips(void)
27245 static const DWORD ps_code
[] =
27251 float4
main(float4 position
: SV_POSITION
) : SV_Target
27255 p
.x
= position
.x
/ 640.0f
;
27256 p
.y
= position
.y
/ 480.0f
;
27257 return t
.Sample(s
, p
);
27260 0x43425844, 0x1ce9b612, 0xc8176faa, 0xd37844af, 0xdb515605, 0x00000001, 0x00000134, 0x00000003,
27261 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
27262 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
27263 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
27264 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
27265 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
27266 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
27267 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
27268 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
27269 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
27271 static const DWORD ps_code_3d
[] =
27277 float4
main(float4 position
: SV_POSITION
) : SV_Target
27281 p
.x
= position
.x
/ 640.0f
;
27282 p
.y
= position
.y
/ 480.0f
;
27284 return t
.Sample(s
, p
);
27287 0x43425844, 0xa1e26083, 0xeb45763e, 0x1e5a5089, 0xdfbbe0df, 0x00000001, 0x00000148, 0x00000003,
27288 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
27289 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
27290 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
27291 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000ac, 0x00000040,
27292 0x0000002b, 0x0300005a, 0x00106000, 0x00000000, 0x04002858, 0x00107000, 0x00000000, 0x00005555,
27293 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
27294 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
27295 0x3b088889, 0x00000000, 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0x3f000000,
27296 0x09000045, 0x001020f2, 0x00000000, 0x00100246, 0x00000000, 0x00107e46, 0x00000000, 0x00106000,
27297 0x00000000, 0x0100003e,
27299 static const struct
27301 D3D11_RESOURCE_DIMENSION dim
;
27302 D3D11_SRV_DIMENSION srv_dim
;
27303 unsigned int array_size
;
27307 {D3D11_RESOURCE_DIMENSION_BUFFER
, D3D11_SRV_DIMENSION_BUFFER
, 1},
27308 {D3D11_RESOURCE_DIMENSION_TEXTURE2D
, D3D11_SRV_DIMENSION_TEXTURE2D
, 1},
27309 {D3D11_RESOURCE_DIMENSION_TEXTURE2D
, D3D11_SRV_DIMENSION_TEXTURE2DARRAY
, 4},
27310 {D3D11_RESOURCE_DIMENSION_TEXTURE3D
, D3D11_SRV_DIMENSION_TEXTURE3D
, 1},
27312 static const struct
27314 DXGI_FORMAT texture_format
;
27319 BOOL expected_creation
;
27320 BOOL expected_mips
;
27324 {DXGI_FORMAT_R8G8B8A8_UNORM
, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
,
27326 {DXGI_FORMAT_R8G8B8A8_UNORM
, D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
,
27328 {DXGI_FORMAT_R8G8B8A8_UNORM
, D3D11_BIND_SHADER_RESOURCE
, 0, FALSE
,
27330 {DXGI_FORMAT_R8G8B8A8_UNORM
, D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
, 0, FALSE
,
27332 {DXGI_FORMAT_R8G8B8A8_UNORM
, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_GENERATE_MIPS
, FALSE
,
27334 {DXGI_FORMAT_R8G8B8A8_UNORM
, D3D11_BIND_RENDER_TARGET
, D3D11_RESOURCE_MISC_GENERATE_MIPS
, FALSE
,
27336 {DXGI_FORMAT_R8G8B8A8_UNORM
, D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_GENERATE_MIPS
, FALSE
,
27338 {DXGI_FORMAT_R8G8B8A8_UNORM
, D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_GENERATE_MIPS
, FALSE
,
27340 {DXGI_FORMAT_R8G8B8A8_TYPELESS
, D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_GENERATE_MIPS
, FALSE
,
27342 {DXGI_FORMAT_R8G8B8A8_UINT
, D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_GENERATE_MIPS
, TRUE
,
27345 static const struct
27352 {{200, 200}, 0xffff0000},
27353 {{280, 200}, 0xffff0000},
27354 {{360, 200}, 0xff00ff00},
27355 {{440, 200}, 0xff00ff00},
27356 {{200, 270}, 0xff0000ff},
27357 {{280, 270}, 0xff0000ff},
27358 {{360, 270}, 0xff000000},
27359 {{440, 270}, 0xff000000},
27361 static const struct vec4 white
= {1.0f
, 1.0f
, 1.0f
, 1.0f
};
27362 static const RECT r1
= {8, 8, 16, 16};
27363 static const RECT r2
= {16, 8, 24, 16};
27364 static const RECT r3
= {8, 16, 16, 24};
27365 static const RECT r4
= {16, 16, 24, 24};
27366 DWORD
*data
, *zero_data
, color
, expected_color
;
27367 ID3D11ShaderResourceView
*srv
, *srv_sampling
;
27368 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
27369 struct d3d11_test_context test_context
;
27370 D3D11_TEXTURE2D_DESC texture2d_desc
;
27371 D3D11_TEXTURE3D_DESC texture3d_desc
;
27372 ID3D11SamplerState
*sampler_state
;
27373 D3D11_SAMPLER_DESC sampler_desc
;
27374 D3D11_BUFFER_DESC buffer_desc
;
27375 unsigned int i
, j
, k
, x
, y
, z
;
27376 ID3D11PixelShader
*ps
, *ps_3d
;
27377 ID3D11DeviceContext
*context
;
27378 struct resource_readback rb
;
27379 ID3D11Resource
*resource
;
27380 ID3D11Device
*device
;
27383 if (!init_test_context(&test_context
, NULL
))
27386 device
= test_context
.device
;
27387 context
= test_context
.immediate_context
;
27389 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
27390 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
27392 hr
= ID3D11Device_CreatePixelShader(device
, ps_code_3d
, sizeof(ps_code_3d
), NULL
, &ps_3d
);
27393 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
27395 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
27396 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
27397 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
27398 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
27399 sampler_desc
.MipLODBias
= 0.0f
;
27400 sampler_desc
.MaxAnisotropy
= 0;
27401 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
27402 sampler_desc
.BorderColor
[0] = 0.0f
;
27403 sampler_desc
.BorderColor
[1] = 0.0f
;
27404 sampler_desc
.BorderColor
[2] = 0.0f
;
27405 sampler_desc
.BorderColor
[3] = 0.0f
;
27406 sampler_desc
.MinLOD
= 0.0f
;
27407 sampler_desc
.MaxLOD
= D3D11_FLOAT32_MAX
;
27409 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler_state
);
27410 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
27411 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler_state
);
27413 data
= heap_alloc(sizeof(*data
) * 32 * 32 * 32);
27415 for (z
= 0; z
< 32; ++z
)
27417 for (y
= 0; y
< 32; ++y
)
27419 for (x
= 0; x
< 32; ++x
)
27421 DWORD
*dst
= &data
[z
* 32 * 32 + y
* 32 + x
];
27426 if (PtInRect(&r1
, pt
))
27428 else if (PtInRect(&r2
, pt
))
27430 else if (PtInRect(&r3
, pt
))
27432 else if (PtInRect(&r4
, pt
))
27440 zero_data
= heap_alloc_zero(sizeof(*zero_data
) * 16 * 16 * 16);
27442 for (i
= 0; i
< ARRAY_SIZE(resource_types
); ++i
)
27444 for (j
= 0; j
< ARRAY_SIZE(tests
); ++j
)
27446 unsigned int base_multiplier
= 1u << tests
[j
].base_level
;
27448 if (is_warp_device(device
) && tests
[j
].texture_format
== DXGI_FORMAT_R8G8B8A8_UINT
)
27450 /* Testing this format seems to break the WARP device. */
27451 skip("Skipping test with DXGI_FORMAT_R8G8B8A8_UINT on WARP.\n");
27455 switch (resource_types
[i
].dim
)
27457 case D3D11_RESOURCE_DIMENSION_BUFFER
:
27458 buffer_desc
.ByteWidth
= 32 * base_multiplier
;
27459 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
27460 buffer_desc
.BindFlags
= tests
[j
].bind_flags
;
27461 buffer_desc
.CPUAccessFlags
= 0;
27462 buffer_desc
.MiscFlags
= tests
[j
].misc_flags
;
27463 buffer_desc
.StructureByteStride
= 0;
27465 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
,
27466 (ID3D11Buffer
**)&resource
);
27468 case D3D11_RESOURCE_DIMENSION_TEXTURE2D
:
27469 texture2d_desc
.Width
= 32 * base_multiplier
;
27470 texture2d_desc
.Height
= 32 * base_multiplier
;
27471 texture2d_desc
.MipLevels
= 0;
27472 texture2d_desc
.ArraySize
= resource_types
[i
].array_size
;
27473 texture2d_desc
.Format
= tests
[j
].texture_format
;
27474 texture2d_desc
.SampleDesc
.Count
= 1;
27475 texture2d_desc
.SampleDesc
.Quality
= 0;
27476 texture2d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
27477 texture2d_desc
.BindFlags
= tests
[j
].bind_flags
;
27478 texture2d_desc
.CPUAccessFlags
= 0;
27479 texture2d_desc
.MiscFlags
= tests
[j
].misc_flags
;
27481 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, NULL
,
27482 (ID3D11Texture2D
**)&resource
);
27484 case D3D11_RESOURCE_DIMENSION_TEXTURE3D
:
27485 texture3d_desc
.Width
= 32 * base_multiplier
;
27486 texture3d_desc
.Height
= 32 * base_multiplier
;
27487 texture3d_desc
.Depth
= 32 * base_multiplier
;
27488 texture3d_desc
.MipLevels
= 0;
27489 texture3d_desc
.Format
= tests
[j
].texture_format
;
27490 texture3d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
27491 texture3d_desc
.BindFlags
= tests
[j
].bind_flags
;
27492 texture3d_desc
.CPUAccessFlags
= 0;
27493 texture3d_desc
.MiscFlags
= tests
[j
].misc_flags
;
27495 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
,
27496 (ID3D11Texture3D
**)&resource
);
27501 if (tests
[j
].expected_creation
&& (resource_types
[i
].dim
!= D3D11_RESOURCE_DIMENSION_BUFFER
27502 || !(tests
[j
].misc_flags
& D3D11_RESOURCE_MISC_GENERATE_MIPS
)))
27504 ok(SUCCEEDED(hr
), "Resource type %u, test %u: failed to create resource, hr %#x.\n", i
, j
, hr
);
27508 ok(hr
== E_INVALIDARG
, "Resource type %u, test %u: unexpectedly succeeded "
27509 "to create resource, hr %#x.\n", i
, j
, hr
);
27513 if (tests
[j
].null_srv
)
27515 hr
= ID3D11Device_CreateShaderResourceView(device
, resource
, NULL
, &srv
);
27519 srv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
27520 srv_desc
.ViewDimension
= resource_types
[i
].srv_dim
;
27521 switch (resource_types
[i
].srv_dim
)
27523 case D3D11_SRV_DIMENSION_BUFFER
:
27524 srv_desc
.Buffer
.ElementOffset
= 0;
27525 srv_desc
.Buffer
.ElementWidth
= 0;
27527 case D3D11_SRV_DIMENSION_TEXTURE2D
:
27528 srv_desc
.Texture2D
.MostDetailedMip
= tests
[j
].base_level
;
27529 srv_desc
.Texture2D
.MipLevels
= ~0u;
27531 case D3D11_SRV_DIMENSION_TEXTURE2DARRAY
:
27532 srv_desc
.Texture2DArray
.MostDetailedMip
= tests
[j
].base_level
;
27533 srv_desc
.Texture2DArray
.MipLevels
= ~0u;
27534 srv_desc
.Texture2DArray
.FirstArraySlice
= 0;
27535 srv_desc
.Texture2DArray
.ArraySize
= resource_types
[i
].array_size
;
27537 case D3D11_SRV_DIMENSION_TEXTURE3D
:
27538 srv_desc
.Texture3D
.MostDetailedMip
= tests
[j
].base_level
;
27539 srv_desc
.Texture3D
.MipLevels
= ~0u;
27544 hr
= ID3D11Device_CreateShaderResourceView(device
, resource
, &srv_desc
, &srv
);
27546 if (resource_types
[i
].dim
== D3D11_RESOURCE_DIMENSION_BUFFER
)
27548 ok(FAILED(hr
), "Test %u: unexpectedly succeeded to create shader resource view, "
27549 "hr %#x.\n", j
, hr
);
27550 ID3D11Resource_Release(resource
);
27555 ok(SUCCEEDED(hr
), "Resource type %u, test %u: failed to create "
27556 "shader resource view, hr %#x.\n", i
, j
, hr
);
27559 ID3D11DeviceContext_UpdateSubresource(context
, resource
, tests
[j
].base_level
,
27560 NULL
, data
, sizeof(*data
) * 32, sizeof(*data
) * 32 * 32);
27561 ID3D11DeviceContext_UpdateSubresource(context
, resource
, tests
[j
].base_level
+ 1,
27562 NULL
, zero_data
, sizeof(*zero_data
) * 16, sizeof(*zero_data
) * 16 * 16);
27564 ID3D11DeviceContext_GenerateMips(context
, srv
);
27566 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &white
.x
);
27568 srv_desc
.Format
= tests
[j
].texture_format
== DXGI_FORMAT_R8G8B8A8_UINT
27569 ? DXGI_FORMAT_R8G8B8A8_UINT
: DXGI_FORMAT_R8G8B8A8_UNORM
;
27570 srv_desc
.ViewDimension
= resource_types
[i
].dim
== D3D11_RESOURCE_DIMENSION_TEXTURE3D
27571 ? D3D11_SRV_DIMENSION_TEXTURE3D
: D3D11_SRV_DIMENSION_TEXTURE2D
;
27572 srv_desc
.Texture2D
.MostDetailedMip
= tests
[j
].base_level
+ 1;
27573 srv_desc
.Texture2D
.MipLevels
= ~0u;
27574 hr
= ID3D11Device_CreateShaderResourceView(device
, resource
, &srv_desc
, &srv_sampling
);
27575 ok(SUCCEEDED(hr
), "Resource type %u, test %u: failed to create shader resource view, "
27576 "hr %#x.\n", i
, j
, hr
);
27577 ID3D11DeviceContext_PSSetShader(context
, resource_types
[i
].dim
27578 == D3D11_RESOURCE_DIMENSION_TEXTURE3D
? ps_3d
: ps
, NULL
, 0);
27579 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv_sampling
);
27581 draw_quad(&test_context
);
27583 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
27584 for (k
= 0; k
< ARRAY_SIZE(expected
); ++k
)
27586 color
= get_readback_color(&rb
, expected
[k
].pos
.x
, expected
[k
].pos
.y
, 0);
27587 expected_color
= tests
[j
].expected_mips
? expected
[k
].color
: 0;
27588 ok(color
== expected_color
, "Resource type %u, test %u: pixel (%u, %u) "
27589 "has color %08x, expected %08x.\n",
27590 i
, j
, expected
[k
].pos
.x
, expected
[k
].pos
.y
, color
, expected_color
);
27592 release_resource_readback(&rb
);
27594 ID3D11ShaderResourceView_Release(srv_sampling
);
27595 ID3D11ShaderResourceView_Release(srv
);
27596 ID3D11Resource_Release(resource
);
27600 /* Test the effect of sRGB views. */
27601 for (y
= 0; y
< 32; ++y
)
27603 for (x
= 0; x
< 32; ++x
)
27605 DWORD
*dst
= &data
[y
* 32 + x
];
27607 *dst
= (x
+ y
) % 2 * 0xffffffff;
27610 texture2d_desc
.Width
= 32;
27611 texture2d_desc
.Height
= 32;
27612 texture2d_desc
.MipLevels
= 0;
27613 texture2d_desc
.ArraySize
= 1;
27614 texture2d_desc
.Format
= DXGI_FORMAT_R8G8B8A8_TYPELESS
;
27615 texture2d_desc
.SampleDesc
.Count
= 1;
27616 texture2d_desc
.SampleDesc
.Quality
= 0;
27617 texture2d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
27618 texture2d_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
;
27619 texture2d_desc
.CPUAccessFlags
= 0;
27620 texture2d_desc
.MiscFlags
= D3D11_RESOURCE_MISC_GENERATE_MIPS
;
27622 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, (ID3D11Texture2D
**)&resource
);
27623 ok(SUCCEEDED(hr
), "Failed to create resource, hr %#x.\n", hr
);
27624 hr
= ID3D11Device_CreateShaderResourceView(device
, resource
, NULL
, &srv
);
27625 ok(hr
== E_INVALIDARG
, "Unexpected hr %#x.\n", hr
);
27626 srv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
;
27627 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_TEXTURE2D
;
27628 srv_desc
.Texture2D
.MostDetailedMip
= 0;
27629 srv_desc
.Texture2D
.MipLevels
= ~0u;
27630 hr
= ID3D11Device_CreateShaderResourceView(device
, resource
, &srv_desc
, &srv
);
27631 ID3D11DeviceContext_UpdateSubresource(context
, resource
,
27632 0, NULL
, data
, sizeof(*data
) * 32, sizeof(*data
) * 32 * 32);
27634 ID3D11DeviceContext_GenerateMips(context
, srv
);
27636 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &white
.w
);
27638 srv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
27639 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_TEXTURE2D
;
27640 srv_desc
.Texture2D
.MostDetailedMip
= 1;
27641 srv_desc
.Texture2D
.MipLevels
= ~0u;
27642 hr
= ID3D11Device_CreateShaderResourceView(device
, resource
, &srv_desc
, &srv_sampling
);
27643 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
27644 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
27645 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv_sampling
);
27647 draw_quad(&test_context
);
27649 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
27650 color
= get_readback_color(&rb
, 320, 240, 0);
27651 ok(compare_color(color
, 0x7fbcbcbc, 1) || broken(compare_color(color
, 0x7f7f7f7f, 1)), /* AMD */
27652 "Unexpected color %08x.\n", color
);
27653 release_resource_readback(&rb
);
27655 ID3D11ShaderResourceView_Release(srv_sampling
);
27656 ID3D11ShaderResourceView_Release(srv
);
27658 srv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
27659 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_TEXTURE2D
;
27660 srv_desc
.Texture2D
.MostDetailedMip
= 0;
27661 srv_desc
.Texture2D
.MipLevels
= ~0u;
27662 hr
= ID3D11Device_CreateShaderResourceView(device
, resource
, &srv_desc
, &srv
);
27663 ID3D11DeviceContext_UpdateSubresource(context
, resource
,
27664 0, NULL
, data
, sizeof(*data
) * 32, sizeof(*data
) * 32 * 32);
27666 ID3D11DeviceContext_GenerateMips(context
, srv
);
27668 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &white
.w
);
27670 srv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
27671 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_TEXTURE2D
;
27672 srv_desc
.Texture2D
.MostDetailedMip
= 1;
27673 srv_desc
.Texture2D
.MipLevels
= ~0u;
27674 hr
= ID3D11Device_CreateShaderResourceView(device
, resource
, &srv_desc
, &srv_sampling
);
27675 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
27676 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
27677 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv_sampling
);
27679 draw_quad(&test_context
);
27681 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
27682 check_readback_data_color(&rb
, NULL
, 0x7f7f7f7f, 1);
27683 release_resource_readback(&rb
);
27685 ID3D11ShaderResourceView_Release(srv_sampling
);
27686 ID3D11ShaderResourceView_Release(srv
);
27688 ID3D11Resource_Release(resource
);
27690 heap_free(zero_data
);
27693 ID3D11SamplerState_Release(sampler_state
);
27694 ID3D11PixelShader_Release(ps_3d
);
27695 ID3D11PixelShader_Release(ps
);
27696 release_test_context(&test_context
);
27699 static void test_alpha_to_coverage(void)
27704 struct vec2 bottom
;
27709 struct d3d11_test_context test_context
;
27710 ID3D11Texture2D
*render_targets
[3];
27711 D3D11_TEXTURE2D_DESC texture_desc
;
27712 ID3D11Texture2D
*readback_texture
;
27713 ID3D11RenderTargetView
*rtvs
[3];
27714 ID3D11BlendState
*blend_state
;
27715 ID3D11DeviceContext
*context
;
27716 D3D11_BLEND_DESC blend_desc
;
27717 struct resource_readback rb
;
27718 UINT quality_level_count
;
27719 ID3D11PixelShader
*ps
;
27720 struct ps_cb cb_data
;
27721 ID3D11Device
*device
;
27727 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
27728 static const DWORD ps_code
[] =
27736 void main(float4 position
: SV_Position
,
27737 out float4 target0
: SV_Target0
,
27738 out float4 target1
: SV_Target1
,
27739 out float4 target2
: SV_Target2
)
27741 float alpha
= all(top
<= position
.xy
) && all(position
.xy
<= bottom
) ? 1.0f
: 0.0f
;
27742 target0
= float4(0.0f
, 1.0f
, 0.0f
, alpha
);
27743 target1
= float4(0.0f
, 0.0f
, 1.0f
, alpha1
);
27744 target2
= float4(0.0f
, 1.0f
, 0.0f
, alpha2
);
27747 0x43425844, 0x771ff802, 0xca927279, 0x5bdd75ae, 0xf53cb31b, 0x00000001, 0x00000264, 0x00000003,
27748 0x0000002c, 0x00000060, 0x000000c4, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
27749 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
27750 0x4e47534f, 0x0000005c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000000, 0x00000003,
27751 0x00000000, 0x0000000f, 0x00000050, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
27752 0x00000050, 0x00000002, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x545f5653, 0x65677261,
27753 0xabab0074, 0x52444853, 0x00000198, 0x00000040, 0x00000066, 0x04000059, 0x00208e46, 0x00000000,
27754 0x00000002, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
27755 0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068, 0x00000001,
27756 0x0800001d, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00208046, 0x00000000, 0x00000000,
27757 0x07000001, 0x00100012, 0x00000000, 0x0010001a, 0x00000000, 0x0010000a, 0x00000000, 0x0800001d,
27758 0x00100062, 0x00000000, 0x00208ba6, 0x00000000, 0x00000000, 0x00101106, 0x00000000, 0x07000001,
27759 0x00100022, 0x00000000, 0x0010002a, 0x00000000, 0x0010001a, 0x00000000, 0x07000001, 0x00100012,
27760 0x00000000, 0x0010001a, 0x00000000, 0x0010000a, 0x00000000, 0x07000001, 0x00102082, 0x00000000,
27761 0x0010000a, 0x00000000, 0x00004001, 0x3f800000, 0x08000036, 0x00102072, 0x00000000, 0x00004002,
27762 0x00000000, 0x3f800000, 0x00000000, 0x00000000, 0x08000036, 0x00102072, 0x00000001, 0x00004002,
27763 0x00000000, 0x00000000, 0x3f800000, 0x00000000, 0x06000036, 0x00102082, 0x00000001, 0x0020800a,
27764 0x00000000, 0x00000001, 0x08000036, 0x00102072, 0x00000002, 0x00004002, 0x00000000, 0x3f800000,
27765 0x00000000, 0x00000000, 0x06000036, 0x00102082, 0x00000002, 0x0020801a, 0x00000000, 0x00000001,
27768 static const DWORD colors
[] = {0xff00ff00, 0xbfff0000, 0x8000ff00};
27770 if (!init_test_context(&test_context
, NULL
))
27772 device
= test_context
.device
;
27773 context
= test_context
.immediate_context
;
27775 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
27776 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
27777 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
27779 memset(&blend_desc
, 0, sizeof(blend_desc
));
27780 blend_desc
.AlphaToCoverageEnable
= TRUE
;
27781 blend_desc
.RenderTarget
[0].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_ALL
;
27782 hr
= ID3D11Device_CreateBlendState(device
, &blend_desc
, &blend_state
);
27783 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
27784 ID3D11DeviceContext_OMSetBlendState(context
, blend_state
, NULL
, D3D11_DEFAULT_SAMPLE_MASK
);
27786 render_targets
[0] = test_context
.backbuffer
;
27787 rtvs
[0] = test_context
.backbuffer_rtv
;
27788 for (i
= 1; i
< ARRAY_SIZE(render_targets
); ++i
)
27790 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
27791 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &render_targets
[i
]);
27792 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
27793 hr
= ID3D11Device_CreateRenderTargetView(device
,
27794 (ID3D11Resource
*)render_targets
[i
], NULL
, &rtvs
[i
]);
27795 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
27797 ID3D11DeviceContext_OMSetRenderTargets(context
, ARRAY_SIZE(rtvs
), rtvs
, NULL
);
27799 cb_data
.top
.x
= cb_data
.top
.y
= 0.0f
;
27800 cb_data
.bottom
.x
= cb_data
.bottom
.y
= 200.0f
;
27801 cb_data
.alpha
[0] = 0.75;
27802 cb_data
.alpha
[1] = 0.5f
;
27803 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(cb_data
), &cb_data
);
27804 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
27806 for (i
= 0; i
< ARRAY_SIZE(rtvs
); ++i
)
27807 ID3D11DeviceContext_ClearRenderTargetView(context
, rtvs
[i
], white
);
27808 draw_quad(&test_context
);
27809 for (i
= 0; i
< ARRAY_SIZE(render_targets
); ++i
)
27811 DWORD expected_color
;
27813 assert(i
< ARRAY_SIZE(colors
));
27814 expected_color
= colors
[i
];
27815 get_texture_readback(render_targets
[i
], 0, &rb
);
27816 SetRect(&rect
, 0, 0, 200, 200);
27817 check_readback_data_color(&rb
, &rect
, expected_color
, 1);
27818 SetRect(&rect
, 200, 0, 640, 200);
27820 check_readback_data_color(&rb
, &rect
, 0xffffffff, 1);
27821 SetRect(&rect
, 0, 200, 640, 480);
27823 check_readback_data_color(&rb
, &rect
, 0xffffffff, 1);
27824 release_resource_readback(&rb
);
27827 ID3D11Texture2D_Release(render_targets
[i
]);
27828 render_targets
[i
] = NULL
;
27831 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
27832 texture_desc
.Format
= DXGI_FORMAT_R16G16_UNORM
;
27833 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &render_targets
[0]);
27834 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
27835 hr
= ID3D11Device_CreateRenderTargetView(device
,
27836 (ID3D11Resource
*)render_targets
[0], NULL
, &rtvs
[0]);
27837 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
27838 ID3D11DeviceContext_OMSetRenderTargets(context
, ARRAY_SIZE(rtvs
), rtvs
, NULL
);
27840 ID3D11DeviceContext_ClearRenderTargetView(context
, rtvs
[0], white
);
27841 draw_quad(&test_context
);
27842 get_texture_readback(render_targets
[0], 0, &rb
);
27843 SetRect(&rect
, 0, 0, 200, 200);
27844 check_readback_data_color(&rb
, &rect
, 0xffff0000, 1);
27845 SetRect(&rect
, 200, 0, 640, 200);
27847 check_readback_data_color(&rb
, &rect
, 0xffffffff, 1);
27848 SetRect(&rect
, 0, 200, 640, 480);
27850 check_readback_data_color(&rb
, &rect
, 0xffffffff, 1);
27851 release_resource_readback(&rb
);
27853 ID3D11Texture2D_Release(render_targets
[0]);
27854 for (i
= 0; i
< ARRAY_SIZE(rtvs
); ++i
)
27855 ID3D11RenderTargetView_Release(rtvs
[i
]);
27857 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
27858 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
,
27859 texture_desc
.Format
, 4, &quality_level_count
);
27860 ok(hr
== S_OK
, "Failed to check multisample quality levels, hr %#x.\n", hr
);
27861 if (!quality_level_count
)
27863 skip("4xMSAA not supported.\n");
27866 texture_desc
.SampleDesc
.Count
= 4;
27867 texture_desc
.SampleDesc
.Quality
= 0;
27869 for (i
= 0; i
< ARRAY_SIZE(render_targets
); ++i
)
27871 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &render_targets
[i
]);
27872 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
27873 hr
= ID3D11Device_CreateRenderTargetView(device
,
27874 (ID3D11Resource
*)render_targets
[i
], NULL
, &rtvs
[i
]);
27875 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
27877 ID3D11DeviceContext_OMSetRenderTargets(context
, ARRAY_SIZE(rtvs
), rtvs
, NULL
);
27879 for (i
= 0; i
< ARRAY_SIZE(rtvs
); ++i
)
27880 ID3D11DeviceContext_ClearRenderTargetView(context
, rtvs
[i
], white
);
27881 draw_quad(&test_context
);
27882 texture_desc
.SampleDesc
.Count
= 1;
27883 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &readback_texture
);
27884 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
27885 for (i
= 0; i
< ARRAY_SIZE(render_targets
); ++i
)
27887 DWORD expected_color
;
27889 assert(i
< ARRAY_SIZE(colors
));
27890 expected_color
= colors
[i
];
27892 ID3D11DeviceContext_ResolveSubresource(context
, (ID3D11Resource
*)readback_texture
, 0,
27893 (ID3D11Resource
*)render_targets
[i
], 0, texture_desc
.Format
);
27895 get_texture_readback(readback_texture
, 0, &rb
);
27896 SetRect(&rect
, 0, 0, 200, 200);
27897 check_readback_data_color(&rb
, &rect
, expected_color
, 1);
27898 SetRect(&rect
, 200, 0, 640, 200);
27899 check_readback_data_color(&rb
, &rect
, 0xffffffff, 1);
27900 SetRect(&rect
, 0, 200, 640, 480);
27901 check_readback_data_color(&rb
, &rect
, 0xffffffff, 1);
27902 release_resource_readback(&rb
);
27904 ID3D11Texture2D_Release(readback_texture
);
27906 for (i
= 0; i
< ARRAY_SIZE(render_targets
); ++i
)
27908 ID3D11Texture2D_Release(render_targets
[i
]);
27909 ID3D11RenderTargetView_Release(rtvs
[i
]);
27913 ID3D11Buffer_Release(cb
);
27914 ID3D11PixelShader_Release(ps
);
27915 ID3D11BlendState_Release(blend_state
);
27916 release_test_context(&test_context
);
27919 static void test_unbound_multisample_texture(void)
27921 struct d3d11_test_context test_context
;
27922 ID3D11DeviceContext
*context
;
27923 ID3D11PixelShader
*ps
;
27924 struct uvec4 cb_data
;
27925 ID3D11Device
*device
;
27930 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
27931 static const DWORD ps_code
[] =
27934 Texture2DMS
<float4
, 4> t
;
27938 float4
main(float4 position
: SV_Position
) : SV_Target
27941 t
.GetDimensions(p
.x
, p
.y
, p
.z
);
27942 p
*= float3(position
.x
/ 640.0f
, position
.y
/ 480.0f
, 0.0f
);
27943 /* sample index must be a literal */
27944 switch (sample_index
)
27946 case 1: return t
.Load(int2(p
.xy
), 1);
27947 case 2: return t
.Load(int2(p
.xy
), 2);
27948 case 3: return t
.Load(int2(p
.xy
), 3);
27949 default: return t
.Load(int2(p
.xy
), 0);
27953 0x43425844, 0x03d62416, 0x1914ee8b, 0xccd08d68, 0x27f42136, 0x00000001, 0x000002f8, 0x00000003,
27954 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
27955 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
27956 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
27957 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x0000025c, 0x00000040,
27958 0x00000097, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04042058, 0x00107000, 0x00000000,
27959 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
27960 0x02000068, 0x00000002, 0x0700003d, 0x001000f2, 0x00000000, 0x00004001, 0x00000000, 0x00107e46,
27961 0x00000000, 0x07000038, 0x00100032, 0x00000000, 0x00100046, 0x00000000, 0x00101046, 0x00000000,
27962 0x0a000038, 0x00100032, 0x00000000, 0x00100046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889,
27963 0x00000000, 0x00000000, 0x0400004c, 0x0020800a, 0x00000000, 0x00000000, 0x03000006, 0x00004001,
27964 0x00000001, 0x0500001b, 0x00100032, 0x00000001, 0x00100046, 0x00000000, 0x08000036, 0x001000c2,
27965 0x00000001, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0900002e, 0x001020f2,
27966 0x00000000, 0x00100e46, 0x00000001, 0x00107e46, 0x00000000, 0x00004001, 0x00000001, 0x0100003e,
27967 0x03000006, 0x00004001, 0x00000002, 0x0500001b, 0x00100032, 0x00000001, 0x00100046, 0x00000000,
27968 0x08000036, 0x001000c2, 0x00000001, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
27969 0x0900002e, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00107e46, 0x00000000, 0x00004001,
27970 0x00000002, 0x0100003e, 0x03000006, 0x00004001, 0x00000003, 0x0500001b, 0x00100032, 0x00000001,
27971 0x00100046, 0x00000000, 0x08000036, 0x001000c2, 0x00000001, 0x00004002, 0x00000000, 0x00000000,
27972 0x00000000, 0x00000000, 0x0900002e, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00107e46,
27973 0x00000000, 0x00004001, 0x00000003, 0x0100003e, 0x0100000a, 0x0500001b, 0x00100032, 0x00000000,
27974 0x00100046, 0x00000000, 0x08000036, 0x001000c2, 0x00000000, 0x00004002, 0x00000000, 0x00000000,
27975 0x00000000, 0x00000000, 0x0900002e, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00107e46,
27976 0x00000000, 0x00004001, 0x00000000, 0x0100003e, 0x01000017, 0x0100003e,
27979 if (!init_test_context(&test_context
, NULL
))
27981 device
= test_context
.device
;
27982 context
= test_context
.immediate_context
;
27984 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
27985 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
27986 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
27988 memset(&cb_data
, 0, sizeof(cb_data
));
27989 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(cb_data
), &cb_data
);
27990 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
27992 for (i
= 0; i
< 4; ++i
)
27995 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &cb_data
, 0, 0);
27996 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
27997 draw_quad(&test_context
);
27998 check_texture_color(test_context
.backbuffer
, 0x00000000, 1);
28001 ID3D11Buffer_Release(cb
);
28002 ID3D11PixelShader_Release(ps
);
28003 release_test_context(&test_context
);
28006 static void test_multiple_viewports(void)
28010 unsigned int draw_id
;
28011 unsigned int padding
[3];
28013 D3D11_VIEWPORT vp
[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
+ 1];
28014 struct d3d11_test_context test_context
;
28015 D3D11_TEXTURE2D_DESC texture_desc
;
28016 ID3D11DeviceContext
*context
;
28017 ID3D11RenderTargetView
*rtv
;
28018 ID3D11Texture2D
*texture
;
28019 ID3D11GeometryShader
*gs
;
28020 ID3D11PixelShader
*ps
;
28021 ID3D11Device
*device
;
28025 static const DWORD gs_code
[] =
28030 float4 pos
: SV_Position
;
28035 float4 pos
: SV_Position
;
28036 uint viewport
: SV_ViewportArrayIndex
;
28039 [maxvertexcount(6)]
28040 void main(triangle gs_in vin
[3], inout TriangleStream
<gs_out
> vout
)
28043 for (uint instance_id
= 0; instance_id
< 2; ++instance_id
)
28045 o
.viewport
= instance_id
;
28046 for (uint i
= 0; i
< 3; ++i
)
28048 o
.pos
= vin
[i
].pos
;
28051 vout
.RestartStrip();
28055 0x43425844, 0xabbb660f, 0x0729bf23, 0x14a9a104, 0x1b454917, 0x00000001, 0x0000021c, 0x00000003,
28056 0x0000002c, 0x00000060, 0x000000c4, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
28057 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x7469736f, 0x006e6f69,
28058 0x4e47534f, 0x0000005c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
28059 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000005, 0x00000001, 0x00000001, 0x00000e01,
28060 0x505f5653, 0x7469736f, 0x006e6f69, 0x565f5653, 0x70776569, 0x4174726f, 0x79617272, 0x65646e49,
28061 0xabab0078, 0x52444853, 0x00000150, 0x00020040, 0x00000054, 0x05000061, 0x002010f2, 0x00000003,
28062 0x00000000, 0x00000001, 0x02000068, 0x00000001, 0x0100185d, 0x0100285c, 0x04000067, 0x001020f2,
28063 0x00000000, 0x00000001, 0x04000067, 0x00102012, 0x00000001, 0x00000005, 0x0200005e, 0x00000006,
28064 0x05000036, 0x00100012, 0x00000000, 0x00004001, 0x00000000, 0x01000030, 0x07000050, 0x00100022,
28065 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000002, 0x03040003, 0x0010001a, 0x00000000,
28066 0x05000036, 0x00100022, 0x00000000, 0x00004001, 0x00000000, 0x01000030, 0x07000050, 0x00100042,
28067 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0x00000003, 0x03040003, 0x0010002a, 0x00000000,
28068 0x07000036, 0x001020f2, 0x00000000, 0x00a01e46, 0x0010001a, 0x00000000, 0x00000000, 0x05000036,
28069 0x00102012, 0x00000001, 0x0010000a, 0x00000000, 0x01000013, 0x0700001e, 0x00100022, 0x00000000,
28070 0x0010001a, 0x00000000, 0x00004001, 0x00000001, 0x01000016, 0x01000009, 0x0700001e, 0x00100012,
28071 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000001, 0x01000016, 0x0100003e,
28073 static const DWORD ps_code
[] =
28078 float4
main(in float4 pos
: SV_Position
,
28079 in uint viewport
: SV_ViewportArrayIndex
) : SV_Target
28081 return float4(viewport
, draw_id
, 0, 0);
28084 0x43425844, 0x77334c0f, 0x5df3ca7a, 0xc53c00db, 0x3e6e5750, 0x00000001, 0x00000150, 0x00000003,
28085 0x0000002c, 0x00000090, 0x000000c4, 0x4e475349, 0x0000005c, 0x00000002, 0x00000008, 0x00000038,
28086 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000005,
28087 0x00000001, 0x00000001, 0x00000101, 0x505f5653, 0x7469736f, 0x006e6f69, 0x565f5653, 0x70776569,
28088 0x4174726f, 0x79617272, 0x65646e49, 0xabab0078, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008,
28089 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261,
28090 0xabab0074, 0x52444853, 0x00000084, 0x00000040, 0x00000021, 0x04000059, 0x00208e46, 0x00000000,
28091 0x00000001, 0x04000864, 0x00101012, 0x00000001, 0x00000005, 0x03000065, 0x001020f2, 0x00000000,
28092 0x05000056, 0x00102012, 0x00000000, 0x0010100a, 0x00000001, 0x06000056, 0x00102022, 0x00000000,
28093 0x0020800a, 0x00000000, 0x00000000, 0x08000036, 0x001020c2, 0x00000000, 0x00004002, 0x00000000,
28094 0x00000000, 0x00000000, 0x00000000, 0x0100003e,
28096 static const struct vec4 expected_values
[] =
28098 {0.0f
, 1.0f
}, {1.0f
, 1.0f
}, {0.0f
, 2.0f
}, {0.5f
, 0.5f
}, {0.5f
, 0.5f
}, {0.0f
, 4.0f
}, {0.5f
, 0.5f
}, {0.5f
, 0.5f
},
28099 {0.0f
, 5.0f
}, {0.5f
, 0.5f
}, {1.0f
, 5.0f
}, {0.5f
, 0.5f
},
28101 static const float clear_color
[] = {0.5f
, 0.5f
, 0.0f
, 0.0f
};
28102 ID3D11RasterizerState
*rasterizer_state
;
28103 D3D11_RASTERIZER_DESC rasterizer_desc
;
28104 unsigned int count
, i
;
28105 D3D11_RECT rects
[2];
28109 if (!init_test_context(&test_context
, NULL
))
28112 device
= test_context
.device
;
28113 context
= test_context
.immediate_context
;
28115 memset(&constant
, 0, sizeof(constant
));
28116 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(constant
), &constant
);
28117 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
28119 hr
= ID3D11Device_CreateGeometryShader(device
, gs_code
, sizeof(gs_code
), NULL
, &gs
);
28120 ok(SUCCEEDED(hr
), "Failed to create geometry shader, hr %#x.\n", hr
);
28121 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
28123 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
28124 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
28125 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
28127 texture_desc
.Width
= 32;
28128 texture_desc
.Height
= 32;
28129 texture_desc
.MipLevels
= 1;
28130 texture_desc
.ArraySize
= 1;
28131 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
28132 texture_desc
.SampleDesc
.Count
= 1;
28133 texture_desc
.SampleDesc
.Quality
= 0;
28134 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
28135 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
28136 texture_desc
.CPUAccessFlags
= 0;
28137 texture_desc
.MiscFlags
= 0;
28138 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
28139 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
28141 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
28142 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
28143 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
28145 width
= texture_desc
.Width
/ 2;
28147 vp
[0].TopLeftX
= 0.0f
;
28148 vp
[0].TopLeftY
= 0.0f
;
28149 vp
[0].Width
= width
;
28150 vp
[0].Height
= texture_desc
.Height
;
28151 vp
[0].MinDepth
= 0.0f
;
28152 vp
[0].MaxDepth
= 1.0f
;
28155 vp
[1].TopLeftX
= width
;
28156 vp
[1].Width
= width
;
28157 ID3D11DeviceContext_RSSetViewports(context
, 2, vp
);
28159 count
= enable_debug_layer
? ARRAY_SIZE(vp
) - 1 : ARRAY_SIZE(vp
);
28160 ID3D11DeviceContext_RSGetViewports(context
, &count
, vp
);
28161 ok(count
== 2, "Unexpected viewport count %d.\n", count
);
28163 constant
.draw_id
= 0;
28164 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
28165 draw_quad(&test_context
);
28166 constant
.draw_id
= 1;
28167 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
28168 draw_quad(&test_context
);
28170 SetRect(&rect
, 0, 0, width
- 1, texture_desc
.Height
- 1);
28171 check_texture_sub_resource_vec4(texture
, 0, &rect
, &expected_values
[0], 1);
28172 SetRect(&rect
, width
, 0, 2 * width
- 1, texture_desc
.Height
- 1);
28173 check_texture_sub_resource_vec4(texture
, 0, &rect
, &expected_values
[1], 1);
28175 /* One viewport. */
28176 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, clear_color
);
28177 ID3D11DeviceContext_RSSetViewports(context
, 1, vp
);
28178 constant
.draw_id
= 2;
28179 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
28180 draw_quad(&test_context
);
28181 SetRect(&rect
, 0, 0, width
- 1, texture_desc
.Height
- 1);
28182 check_texture_sub_resource_vec4(texture
, 0, &rect
, &expected_values
[2], 1);
28183 SetRect(&rect
, width
, 0, 2 * width
- 1, texture_desc
.Height
- 1);
28184 check_texture_sub_resource_vec4(texture
, 0, &rect
, &expected_values
[3], 1);
28186 /* Reset viewports. */
28187 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, clear_color
);
28188 ID3D11DeviceContext_RSSetViewports(context
, 0, NULL
);
28189 constant
.draw_id
= 3;
28190 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
28191 draw_quad(&test_context
);
28192 check_texture_sub_resource_vec4(texture
, 0, NULL
, &expected_values
[4], 1);
28194 /* Two viewports, only first scissor rectangle set. */
28195 memset(&rasterizer_desc
, 0, sizeof(rasterizer_desc
));
28196 rasterizer_desc
.FillMode
= D3D11_FILL_SOLID
;
28197 rasterizer_desc
.CullMode
= D3D11_CULL_BACK
;
28198 rasterizer_desc
.DepthClipEnable
= TRUE
;
28199 rasterizer_desc
.ScissorEnable
= TRUE
;
28200 hr
= ID3D11Device_CreateRasterizerState(device
, &rasterizer_desc
, &rasterizer_state
);
28201 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
28203 ID3D11DeviceContext_RSSetState(context
, rasterizer_state
);
28204 ID3D11RasterizerState_Release(rasterizer_state
);
28206 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, clear_color
);
28207 ID3D11DeviceContext_RSSetViewports(context
, 2, vp
);
28209 SetRect(&rects
[0], 0, 0, width
, texture_desc
.Height
/ 2);
28210 memset(&rects
[1], 0, sizeof(*rects
));
28211 ID3D11DeviceContext_RSSetScissorRects(context
, 1, rects
);
28212 constant
.draw_id
= 4;
28213 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
28214 draw_quad(&test_context
);
28216 SetRect(&rect
, 0, 0, width
- 1, texture_desc
.Height
/ 2 - 1);
28217 check_texture_sub_resource_vec4(texture
, 0, &rect
, &expected_values
[5], 1);
28218 SetRect(&rect
, 0, texture_desc
.Height
/ 2, width
- 1, texture_desc
.Height
- 1);
28219 check_texture_sub_resource_vec4(texture
, 0, &rect
, &expected_values
[6], 1);
28220 SetRect(&rect
, width
, 0, 2 * width
- 1, texture_desc
.Height
- 1);
28221 check_texture_sub_resource_vec4(texture
, 0, &rect
, &expected_values
[7], 1);
28223 /* Set both rectangles. */
28224 SetRect(&rects
[0], 0, 0, width
, texture_desc
.Height
/ 2);
28225 SetRect(&rects
[1], width
, 0, 2 * width
, texture_desc
.Height
/ 2);
28226 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, clear_color
);
28227 ID3D11DeviceContext_RSSetScissorRects(context
, 2, rects
);
28228 constant
.draw_id
= 5;
28229 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
28230 draw_quad(&test_context
);
28232 SetRect(&rect
, 0, 0, width
- 1, texture_desc
.Height
/ 2 - 1);
28233 check_texture_sub_resource_vec4(texture
, 0, &rect
, &expected_values
[8], 1);
28234 SetRect(&rect
, 0, texture_desc
.Height
/ 2, width
- 1, texture_desc
.Height
- 1);
28235 check_texture_sub_resource_vec4(texture
, 0, &rect
, &expected_values
[9], 1);
28237 SetRect(&rect
, width
, 0, 2 * width
- 1, texture_desc
.Height
/ 2 - 1);
28238 check_texture_sub_resource_vec4(texture
, 0, &rect
, &expected_values
[10], 1);
28239 SetRect(&rect
, width
, texture_desc
.Height
/ 2, 2 * width
- 1, texture_desc
.Height
- 1);
28240 check_texture_sub_resource_vec4(texture
, 0, &rect
, &expected_values
[11], 1);
28242 if (enable_debug_layer
)
28245 /* Viewport count exceeding maximum value. */
28246 ID3D11DeviceContext_RSSetViewports(context
, 1, vp
);
28248 vp
[0].TopLeftX
= 1.0f
;
28249 vp
[0].TopLeftY
= 0.0f
;
28250 vp
[0].Width
= width
;
28251 vp
[0].Height
= texture_desc
.Height
;
28252 vp
[0].MinDepth
= 0.0f
;
28253 vp
[0].MaxDepth
= 1.0f
;
28254 for (i
= 1; i
< ARRAY_SIZE(vp
); ++i
)
28258 ID3D11DeviceContext_RSSetViewports(context
, ARRAY_SIZE(vp
), vp
);
28260 count
= ARRAY_SIZE(vp
);
28261 memset(vp
, 0, sizeof(vp
));
28262 ID3D11DeviceContext_RSGetViewports(context
, &count
, vp
);
28263 ok(count
== 1, "Unexpected viewport count %d.\n", count
);
28264 ok(vp
[0].TopLeftX
== 0.0f
&& vp
[0].Width
== width
, "Unexpected viewport.\n");
28267 ID3D11RenderTargetView_Release(rtv
);
28268 ID3D11Texture2D_Release(texture
);
28270 ID3D11Buffer_Release(cb
);
28271 ID3D11GeometryShader_Release(gs
);
28272 ID3D11PixelShader_Release(ps
);
28273 release_test_context(&test_context
);
28276 static void test_multisample_resolve(void)
28278 struct d3d11_test_context test_context
;
28279 D3D11_RENDER_TARGET_VIEW_DESC rtv_desc
;
28280 ID3D11Texture2D
*texture
, *ms_texture
;
28281 D3D11_TEXTURE2D_DESC texture_desc
;
28282 ID3D11DeviceContext
*context
;
28283 ID3D11RenderTargetView
*rtv
;
28284 ID3D11Device
*device
;
28288 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
28289 static const struct vec4 green
= {0.0f
, 1.0f
, 0.0f
, 1.0f
};
28290 static const struct vec4 color
= {0.25f
, 0.5f
, 0.75f
, 1.0f
};
28291 static const struct
28293 DXGI_FORMAT src_format
;
28294 DXGI_FORMAT dst_format
;
28295 DXGI_FORMAT format
;
28297 DXGI_FORMAT rtv_format
;
28299 const struct vec4
*color
;
28300 DWORD expected_color
;
28306 {DXGI_FORMAT_R8G8B8A8_UNORM
,
28307 DXGI_FORMAT_R8G8B8A8_UNORM
,
28308 DXGI_FORMAT_R8G8B8A8_UNORM
,
28309 DXGI_FORMAT_R8G8B8A8_UNORM
,
28310 &green
, 0xff00ff00},
28311 {DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28312 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28313 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28314 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28315 &green
, 0xff00ff00},
28316 {DXGI_FORMAT_R8G8B8A8_UNORM
,
28317 DXGI_FORMAT_R8G8B8A8_UNORM
,
28318 DXGI_FORMAT_R8G8B8A8_UNORM
,
28319 DXGI_FORMAT_R8G8B8A8_UNORM
,
28320 &color
, 0xffbf7f40},
28321 {DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28322 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28323 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28324 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28325 &color
, 0xffe1bc89},
28327 {DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28328 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28329 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28330 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28331 &green
, 0xff00ff00},
28332 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28333 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28334 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28335 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28336 &green
, 0xff00ff00},
28337 {DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28338 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28339 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28340 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28341 &color
, 0xffe1bc89, TRUE
},
28342 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28343 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28344 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28345 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28346 &color
, 0xffe1bc89},
28348 {DXGI_FORMAT_R8G8B8A8_UNORM
,
28349 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28350 DXGI_FORMAT_R8G8B8A8_UNORM
,
28351 DXGI_FORMAT_R8G8B8A8_UNORM
,
28352 &green
, 0xff00ff00},
28353 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28354 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28355 DXGI_FORMAT_R8G8B8A8_UNORM
,
28356 DXGI_FORMAT_R8G8B8A8_UNORM
,
28357 &green
, 0xff00ff00},
28358 {DXGI_FORMAT_R8G8B8A8_UNORM
,
28359 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28360 DXGI_FORMAT_R8G8B8A8_UNORM
,
28361 DXGI_FORMAT_R8G8B8A8_UNORM
,
28362 &color
, 0xffbf7f40},
28363 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28364 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28365 DXGI_FORMAT_R8G8B8A8_UNORM
,
28366 DXGI_FORMAT_R8G8B8A8_UNORM
,
28367 &color
, 0xffbf7f40},
28369 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28370 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28371 DXGI_FORMAT_R8G8B8A8_UNORM
,
28372 DXGI_FORMAT_R8G8B8A8_UNORM
,
28373 &green
, 0xff00ff00},
28374 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28375 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28376 DXGI_FORMAT_R8G8B8A8_UNORM
,
28377 DXGI_FORMAT_R8G8B8A8_UNORM
,
28378 &color
, 0xffbf7f40},
28379 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28380 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28381 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28382 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28383 &green
, 0xff00ff00},
28384 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28385 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28386 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28387 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28388 &color
, 0xffe1bc89},
28389 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28390 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28391 DXGI_FORMAT_R8G8B8A8_UNORM
,
28392 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28393 &green
, 0xff00ff00},
28394 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28395 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28396 DXGI_FORMAT_R8G8B8A8_UNORM
,
28397 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28398 &color
, 0xffe1bc89},
28399 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28400 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28401 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28402 DXGI_FORMAT_R8G8B8A8_UNORM
,
28403 &green
, 0xff00ff00},
28404 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28405 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
28406 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
28407 DXGI_FORMAT_R8G8B8A8_UNORM
,
28408 &color
, 0xffbf7f40},
28411 if (!init_test_context(&test_context
, NULL
))
28413 device
= test_context
.device
;
28414 context
= test_context
.immediate_context
;
28416 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_TYPELESS
, 4, &i
);
28417 ok(hr
== S_OK
, "Failed to check multisample quality levels, hr %#x.\n", hr
);
28420 skip("4xMSAA not supported.\n");
28421 release_test_context(&test_context
);
28425 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
28427 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
28428 texture_desc
.Format
= tests
[i
].dst_format
;
28429 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
28430 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
28432 texture_desc
.Format
= tests
[i
].src_format
;
28433 texture_desc
.SampleDesc
.Count
= 4;
28434 texture_desc
.SampleDesc
.Quality
= 0;
28435 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &ms_texture
);
28436 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
28437 rtv_desc
.Format
= tests
[i
].rtv_format
;
28438 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_TEXTURE2DMS
;
28439 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)ms_texture
, &rtv_desc
, &rtv
);
28440 ok(hr
== S_OK
, "Failed to create render target view, hr %#x.\n", hr
);
28442 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
28443 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, white
);
28444 draw_color_quad(&test_context
, tests
[i
].color
);
28445 ID3D11DeviceContext_ResolveSubresource(context
, (ID3D11Resource
*)texture
, 0,
28446 (ID3D11Resource
*)ms_texture
, 0, tests
[i
].format
);
28447 todo_wine_if(tests
[i
].todo
)
28448 check_texture_color(texture
, tests
[i
].expected_color
, 2);
28450 ID3D11RenderTargetView_Release(rtv
);
28451 ID3D11Texture2D_Release(ms_texture
);
28452 ID3D11Texture2D_Release(texture
);
28455 release_test_context(&test_context
);
28458 static void test_sample_shading(void)
28466 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
28467 struct d3d11_test_context test_context
;
28468 struct swapchain_desc swapchain_desc
;
28469 D3D11_TEXTURE2D_DESC texture_desc
;
28470 ID3D11UnorderedAccessView
*uav
;
28471 D3D11_BUFFER_DESC buffer_desc
;
28472 ID3D11ShaderResourceView
*srv
;
28473 ID3D11DeviceContext
*context
;
28474 ID3D11RenderTargetView
*rtv
;
28475 struct resource_readback rb
;
28476 ID3D11Buffer
*buffer
, *cb
;
28477 ID3D11Texture2D
*texture
;
28478 struct uvec4 ps_constant
;
28479 ID3D11PixelShader
*ps
;
28480 ID3D11Device
*device
;
28485 static const DWORD ps_unused_sample_index_code
[] =
28488 RWByteAddressBuffer u
;
28490 float4
main(uint id
: SV_SampleIndex
) : SV_Target
28492 u
.InterlockedAdd(0, 1);
28493 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
28496 0x43425844, 0x41e4574b, 0x1e6441d6, 0x5e756375, 0xacd5dc27, 0x00000001, 0x00000104, 0x00000003,
28497 0x0000002c, 0x00000064, 0x00000098, 0x4e475349, 0x00000030, 0x00000001, 0x00000008, 0x00000020,
28498 0x00000000, 0x0000000a, 0x00000001, 0x00000000, 0x00000001, 0x535f5653, 0x6c706d61, 0x646e4965,
28499 0xab007865, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
28500 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000064,
28501 0x00000050, 0x00000019, 0x0100086a, 0x0300009d, 0x0011e000, 0x00000001, 0x03000065, 0x001020f2,
28502 0x00000000, 0x070000ad, 0x0011e000, 0x00000001, 0x00004001, 0x00000000, 0x00004001, 0x00000001,
28503 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x3f800000,
28506 static const struct shader ps_unused_sample_index
28507 = {ps_unused_sample_index_code
, sizeof(ps_unused_sample_index_code
)};
28508 static const DWORD ps_sample_index_code
[] =
28511 RWByteAddressBuffer u
;
28513 float4
main(uint id
: SV_SampleIndex
) : SV_Target
28515 u
.InterlockedAdd(0, 1);
28516 u
.InterlockedAdd(4, id
);
28517 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
28520 0x43425844, 0x943ab9ed, 0x91520b4a, 0xb75df9d0, 0x692cd3e6, 0x00000001, 0x00000130, 0x00000003,
28521 0x0000002c, 0x00000064, 0x00000098, 0x4e475349, 0x00000030, 0x00000001, 0x00000008, 0x00000020,
28522 0x00000000, 0x0000000a, 0x00000001, 0x00000000, 0x00000101, 0x535f5653, 0x6c706d61, 0x646e4965,
28523 0xab007865, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
28524 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000090,
28525 0x00000050, 0x00000024, 0x0100086a, 0x0300009d, 0x0011e000, 0x00000001, 0x04000863, 0x00101012,
28526 0x00000000, 0x0000000a, 0x03000065, 0x001020f2, 0x00000000, 0x070000ad, 0x0011e000, 0x00000001,
28527 0x00004001, 0x00000000, 0x00004001, 0x00000001, 0x070000ad, 0x0011e000, 0x00000001, 0x00004001,
28528 0x00000004, 0x0010100a, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000,
28529 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e,
28531 static const struct shader ps_sample_index
= {ps_sample_index_code
, sizeof(ps_sample_index_code
)};
28532 static const DWORD ps_samplepos_code
[] =
28535 Texture2DMS
<float> t
;
28536 RWByteAddressBuffer u
;
28538 float4
main() : SV_Target
28540 float2 sample_position
= t
.GetSamplePosition(0);
28541 u
.InterlockedAdd(0, 1);
28542 u
.InterlockedAdd(4, sample_position
.x
+ sample_position
.y
);
28543 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
28546 0x43425844, 0x9ec7f344, 0x588f5863, 0x436c0531, 0x69dc54bb, 0x00000001, 0x00000160, 0x00000003,
28547 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
28548 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
28549 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000e8, 0x00000050, 0x0000003a,
28550 0x0100086a, 0x04002058, 0x00107000, 0x00000000, 0x00005555, 0x0300009d, 0x0011e000, 0x00000001,
28551 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x070000ad, 0x0011e000, 0x00000001,
28552 0x00004001, 0x00000000, 0x00004001, 0x00000001, 0x0800006e, 0x00100032, 0x00000000, 0x00107046,
28553 0x00000000, 0x00004001, 0x00000000, 0x00000000, 0x07000000, 0x00100012, 0x00000000, 0x0010001a,
28554 0x00000000, 0x0010000a, 0x00000000, 0x0500001c, 0x00100012, 0x00000000, 0x0010000a, 0x00000000,
28555 0x070000ad, 0x0011e000, 0x00000001, 0x00004001, 0x00000004, 0x0010000a, 0x00000000, 0x08000036,
28556 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e,
28558 static const struct shader ps_samplepos
= {ps_samplepos_code
, sizeof(ps_samplepos_code
)};
28559 static const DWORD ps_samplepos_rasterizer_code
[] =
28562 RWByteAddressBuffer u
;
28564 float4
main() : SV_Target
28566 float2 sample_position
= GetRenderTargetSamplePosition(0);
28567 u
.InterlockedAdd(0, 1);
28568 u
.InterlockedAdd(4, sample_position
.x
+ sample_position
.y
);
28569 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
28572 0x43425844, 0xe31795d9, 0x4e9951da, 0xc1713913, 0xfb12da31, 0x00000001, 0x00000148, 0x00000003,
28573 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
28574 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
28575 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000d0, 0x00000050, 0x00000034,
28576 0x0100086a, 0x0300009d, 0x0011e000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
28577 0x00000001, 0x070000ad, 0x0011e000, 0x00000001, 0x00004001, 0x00000000, 0x00004001, 0x00000001,
28578 0x0600006e, 0x00100032, 0x00000000, 0x0000e046, 0x00004001, 0x00000000, 0x07000000, 0x00100012,
28579 0x00000000, 0x0010001a, 0x00000000, 0x0010000a, 0x00000000, 0x0500001c, 0x00100012, 0x00000000,
28580 0x0010000a, 0x00000000, 0x070000ad, 0x0011e000, 0x00000001, 0x00004001, 0x00000004, 0x0010000a,
28581 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x00000000,
28582 0x3f800000, 0x0100003e,
28584 static const struct shader ps_samplepos_rasterizer
28585 = {ps_samplepos_rasterizer_code
, sizeof(ps_samplepos_rasterizer_code
)};
28586 static const DWORD ps_samplepos_indexed_code
[] =
28589 RWByteAddressBuffer u
;
28591 float4
main(uint id
: SV_SampleIndex
) : SV_Target
28593 float2 sample_position
= GetRenderTargetSamplePosition(id
);
28594 u
.InterlockedAdd(0, 1);
28595 u
.InterlockedAdd(4, sample_position
.x
+ sample_position
.y
);
28596 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
28599 0x43425844, 0x4b501464, 0x0cd4f636, 0x36428677, 0x6db6b4fb, 0x00000001, 0x00000180, 0x00000003,
28600 0x0000002c, 0x00000064, 0x00000098, 0x4e475349, 0x00000030, 0x00000001, 0x00000008, 0x00000020,
28601 0x00000000, 0x0000000a, 0x00000001, 0x00000000, 0x00000101, 0x535f5653, 0x6c706d61, 0x646e4965,
28602 0xab007865, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
28603 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000e0,
28604 0x00000050, 0x00000038, 0x0100086a, 0x0300009d, 0x0011e000, 0x00000001, 0x04000863, 0x00101012,
28605 0x00000000, 0x0000000a, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x070000ad,
28606 0x0011e000, 0x00000001, 0x00004001, 0x00000000, 0x00004001, 0x00000001, 0x0600006e, 0x00100032,
28607 0x00000000, 0x0000e046, 0x0010100a, 0x00000000, 0x07000000, 0x00100012, 0x00000000, 0x0010001a,
28608 0x00000000, 0x0010000a, 0x00000000, 0x0500001c, 0x00100012, 0x00000000, 0x0010000a, 0x00000000,
28609 0x070000ad, 0x0011e000, 0x00000001, 0x00004001, 0x00000004, 0x0010000a, 0x00000000, 0x08000036,
28610 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e,
28612 static const struct shader ps_samplepos_indexed
28613 = {ps_samplepos_indexed_code
, sizeof(ps_samplepos_indexed_code
)};
28614 static const DWORD ps_sampleinfo_code
[] =
28617 Texture2DMS
<float> t
;
28618 RWByteAddressBuffer u
;
28620 float4
main() : SV_Target
28622 uint width
, height
, sample_count
;
28623 t
.GetDimensions(width
, height
, sample_count
);
28624 u
.InterlockedAdd(0, 1);
28625 u
.InterlockedAdd(4, sample_count
);
28626 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
28629 0x43425844, 0x4e4f4065, 0x20d88902, 0xd4750e8c, 0x652b8c04, 0x00000001, 0x00000124, 0x00000003,
28630 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
28631 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
28632 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000ac, 0x00000050, 0x0000002b,
28633 0x0100086a, 0x04002058, 0x00107000, 0x00000000, 0x00005555, 0x0300009d, 0x0011e000, 0x00000001,
28634 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x070000ad, 0x0011e000, 0x00000001,
28635 0x00004001, 0x00000000, 0x00004001, 0x00000001, 0x0500086f, 0x00100012, 0x00000000, 0x0010700a,
28636 0x00000000, 0x070000ad, 0x0011e000, 0x00000001, 0x00004001, 0x00000004, 0x0010000a, 0x00000000,
28637 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x3f800000,
28640 static const struct shader ps_sampleinfo
= {ps_sampleinfo_code
, sizeof(ps_sampleinfo_code
)};
28641 static const DWORD ps_sampleinfo_rasterizer_code
[] =
28644 RWByteAddressBuffer u
;
28646 float4
main() : SV_Target
28648 uint sample_count
= GetRenderTargetSampleCount();
28649 u
.InterlockedAdd(0, 1);
28650 u
.InterlockedAdd(4, sample_count
);
28651 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
28654 0x43425844, 0xfbbd8619, 0x9c2654c8, 0xb385363a, 0x4aacd10f, 0x00000001, 0x00000110, 0x00000003,
28655 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
28656 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
28657 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000098, 0x00000050, 0x00000026,
28658 0x0100086a, 0x0300009d, 0x0011e000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
28659 0x00000001, 0x070000ad, 0x0011e000, 0x00000001, 0x00004001, 0x00000000, 0x00004001, 0x00000001,
28660 0x0400086f, 0x00100012, 0x00000000, 0x0000e00a, 0x070000ad, 0x0011e000, 0x00000001, 0x00004001,
28661 0x00000004, 0x0010000a, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000,
28662 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e,
28664 static const struct shader ps_sampleinfo_rasterizer
28665 = {ps_sampleinfo_rasterizer_code
, sizeof(ps_sampleinfo_rasterizer_code
)};
28666 static const DWORD ps_sample_code
[] =
28669 RWByteAddressBuffer u
;
28671 float4
main(sample float4 position
: SV_Position
) : SV_Target
28673 u
.InterlockedAdd(0, 1);
28674 u
.InterlockedAdd(4, position
.x
);
28675 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
28678 0x43425844, 0x46ecbadb, 0xedccbea6, 0x236d7923, 0x0c356c8c, 0x00000001, 0x00000148, 0x00000003,
28679 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
28680 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000010f, 0x505f5653, 0x7469736f, 0x006e6f69,
28681 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
28682 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000ac, 0x00000050,
28683 0x0000002b, 0x0100086a, 0x0300009d, 0x0011e000, 0x00000001, 0x04003864, 0x00101012, 0x00000000,
28684 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x070000ad, 0x0011e000,
28685 0x00000001, 0x00004001, 0x00000000, 0x00004001, 0x00000001, 0x0500001c, 0x00100012, 0x00000000,
28686 0x0010100a, 0x00000000, 0x070000ad, 0x0011e000, 0x00000001, 0x00004001, 0x00000004, 0x0010000a,
28687 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x00000000,
28688 0x3f800000, 0x0100003e,
28690 static const struct shader ps_sample
= {ps_sample_code
, sizeof(ps_sample_code
)};
28691 static const DWORD ps_color_code
[] =
28694 float4
main(uint id
: SV_SampleIndex
) : SV_Target
28698 case 0: return float4(1.0f
, 0.0f
, 0.0f
, 1.0f
);
28699 case 1: return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
28700 case 2: return float4(0.0f
, 0.0f
, 1.0f
, 1.0f
);
28701 default: return float4(0.0f
, 0.0f
, 0.0f
, 1.0f
);
28705 0x43425844, 0x94c35f48, 0x04c6b0f7, 0x407d8214, 0xc24f01e5, 0x00000001, 0x00000194, 0x00000003,
28706 0x0000002c, 0x00000064, 0x00000098, 0x4e475349, 0x00000030, 0x00000001, 0x00000008, 0x00000020,
28707 0x00000000, 0x0000000a, 0x00000001, 0x00000000, 0x00000101, 0x535f5653, 0x6c706d61, 0x646e4965,
28708 0xab007865, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
28709 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000f4,
28710 0x00000050, 0x0000003d, 0x0100086a, 0x04000863, 0x00101012, 0x00000000, 0x0000000a, 0x03000065,
28711 0x001020f2, 0x00000000, 0x0300004c, 0x0010100a, 0x00000000, 0x03000006, 0x00004001, 0x00000000,
28712 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000,
28713 0x0100003e, 0x03000006, 0x00004001, 0x00000001, 0x08000036, 0x001020f2, 0x00000000, 0x00004002,
28714 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e, 0x03000006, 0x00004001, 0x00000002,
28715 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x3f800000, 0x3f800000,
28716 0x0100003e, 0x0100000a, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000,
28717 0x00000000, 0x3f800000, 0x0100003e, 0x01000017, 0x0100003e,
28719 static const DWORD ps_resolve_code
[] =
28722 Texture2DMS
<float4
> t
;
28727 float4
main(float4 position
: SV_Position
) : SV_Target
28730 t
.GetDimensions(p
.x
, p
.y
, p
.z
);
28731 p
*= float3(position
.x
/ rt_size
, position
.y
/ rt_size
, 0);
28732 return t
.Load((int2
)p
.xy
, sample
);
28735 0x43425844, 0x68a4590b, 0xc1ec3070, 0x1b957c43, 0x0c080741, 0x00000001, 0x000001c8, 0x00000003,
28736 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
28737 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
28738 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
28739 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000012c, 0x00000050,
28740 0x0000004b, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04002058, 0x00107000,
28741 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2,
28742 0x00000000, 0x02000068, 0x00000001, 0x06000056, 0x00100012, 0x00000000, 0x0020801a, 0x00000000,
28743 0x00000000, 0x0700000e, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00100006, 0x00000000,
28744 0x8900003d, 0x80000102, 0x00155543, 0x001000c2, 0x00000000, 0x00004001, 0x00000000, 0x001074e6,
28745 0x00000000, 0x07000038, 0x00100032, 0x00000000, 0x00100046, 0x00000000, 0x00100ae6, 0x00000000,
28746 0x0500001b, 0x00100032, 0x00000000, 0x00100046, 0x00000000, 0x08000036, 0x001000c2, 0x00000000,
28747 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8c00002e, 0x80000102, 0x00155543,
28748 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00107e46, 0x00000000, 0x0020800a, 0x00000000,
28749 0x00000000, 0x0100003e,
28751 static const struct
28753 const struct shader
*ps
;
28754 BOOL sample_shading
;
28760 {&ps_unused_sample_index
, FALSE
, FALSE
, TRUE
/* broken on Nvidia */},
28761 {&ps_sample_index
, TRUE
},
28762 {&ps_samplepos
, FALSE
},
28763 {&ps_samplepos_rasterizer
, FALSE
},
28764 {&ps_samplepos_indexed
, TRUE
, TRUE
},
28765 {&ps_sampleinfo
, FALSE
},
28766 {&ps_sampleinfo_rasterizer
, FALSE
},
28767 {&ps_sample
, TRUE
, TRUE
, TRUE
/* broken on Intel */},
28769 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
28770 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
28771 static const unsigned int zero
[4] = {0};
28773 swapchain_desc
.windowed
= TRUE
;
28774 swapchain_desc
.buffer_count
= 1;
28775 swapchain_desc
.width
= 32;
28776 swapchain_desc
.height
= 32;
28777 swapchain_desc
.swap_effect
= DXGI_SWAP_EFFECT_DISCARD
;
28778 swapchain_desc
.flags
= 0;
28779 if (!init_test_context_ext(&test_context
, &feature_level
, &swapchain_desc
))
28781 device
= test_context
.device
;
28782 context
= test_context
.immediate_context
;
28784 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
28785 texture_desc
.SampleDesc
.Count
= 4;
28786 texture_desc
.SampleDesc
.Quality
= 0;
28787 texture_desc
.BindFlags
|= D3D11_BIND_SHADER_RESOURCE
;
28788 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
28789 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
28790 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
28791 ok(hr
== S_OK
, "Failed to create render target view, hr %#x.\n", hr
);
28792 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
28793 ok(hr
== S_OK
, "Failed to create shader resource view, hr %#x.\n", hr
);
28795 buffer_desc
.ByteWidth
= 1024;
28796 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
28797 buffer_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
28798 buffer_desc
.CPUAccessFlags
= 0;
28799 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
;
28800 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
28801 ok(hr
== S_OK
, "Failed to create buffer, hr %#x.\n", hr
);
28802 uav_desc
.Format
= DXGI_FORMAT_R32_TYPELESS
;
28803 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
28804 U(uav_desc
).Buffer
.FirstElement
= 0;
28805 U(uav_desc
).Buffer
.NumElements
= 256;
28806 U(uav_desc
).Buffer
.Flags
= D3D11_BUFFER_UAV_FLAG_RAW
;
28807 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
28808 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
28810 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
28812 hr
= ID3D11Device_CreatePixelShader(device
, tests
[i
].ps
->code
, tests
[i
].ps
->size
, NULL
, &ps
);
28813 ok(hr
== S_OK
, "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
28814 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
28816 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, zero
);
28817 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
28818 ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context
,
28819 1, &test_context
.backbuffer_rtv
, NULL
, 1, 1, &uav
, NULL
);
28820 draw_quad(&test_context
);
28821 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
28822 get_buffer_readback(buffer
, &rb
);
28823 data
= get_readback_color(&rb
, 0, 0, 0);
28824 ok(1024 <= data
&& data
<= 1056, "Test %u: Got unexpected value %u.\n", i
, data
);
28825 release_resource_readback(&rb
);
28827 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, zero
);
28828 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, white
);
28829 ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context
,
28830 1, &rtv
, NULL
, 1, 1, &uav
, NULL
);
28831 draw_quad(&test_context
);
28832 get_buffer_readback(buffer
, &rb
);
28833 data
= get_readback_color(&rb
, 0, 0, 0);
28834 todo_wine_if(tests
[i
].todo
)
28836 if (tests
[i
].sample_shading
)
28838 ok(4096 <= data
|| broken(tests
[i
].broken
&& data
>= 1024),
28839 "Test %u: Got unexpected value %u.\n", i
, data
);
28843 ok((1024 <= data
&& data
<= 1056) || broken(tests
[i
].broken
&& data
>= 4096),
28844 "Test %u: Got unexpected value %u.\n", i
, data
);
28847 release_resource_readback(&rb
);
28849 ID3D11PixelShader_Release(ps
);
28852 if (is_warp_device(device
))
28854 skip("Sample shading tests fail on WARP.\n");
28858 hr
= ID3D11Device_CreatePixelShader(device
, ps_color_code
, sizeof(ps_color_code
), NULL
, &ps
);
28859 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
28860 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
28861 ID3D11PixelShader_Release(ps
);
28863 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, white
);
28864 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
28865 draw_quad(&test_context
);
28866 ID3D11DeviceContext_ResolveSubresource(context
, (ID3D11Resource
*)test_context
.backbuffer
, 0,
28867 (ID3D11Resource
*)texture
, 0, texture_desc
.Format
);
28868 check_texture_color(test_context
.backbuffer
, 0xff404040, 2);
28870 hr
= ID3D11Device_CreatePixelShader(device
, ps_resolve_code
, sizeof(ps_resolve_code
), NULL
, &ps
);
28871 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
28872 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
28873 ID3D11PixelShader_Release(ps
);
28875 ps_constant
.y
= texture_desc
.Width
;
28876 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(ps_constant
), &ps_constant
);
28877 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
28879 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
28880 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &test_context
.backbuffer_rtv
, NULL
);
28881 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
28882 draw_quad(&test_context
);
28883 check_texture_color(test_context
.backbuffer
, 0xff0000ff, 0);
28885 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &ps_constant
, 0, 0);
28886 draw_quad(&test_context
);
28887 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
28889 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &ps_constant
, 0, 0);
28890 draw_quad(&test_context
);
28891 check_texture_color(test_context
.backbuffer
, 0xffff0000, 0);
28893 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &ps_constant
, 0, 0);
28894 draw_quad(&test_context
);
28895 check_texture_color(test_context
.backbuffer
, 0xff000000, 0);
28897 ID3D11Buffer_Release(cb
);
28899 ID3D11Buffer_Release(buffer
);
28900 ID3D11UnorderedAccessView_Release(uav
);
28901 ID3D11RenderTargetView_Release(rtv
);
28902 ID3D11ShaderResourceView_Release(srv
);
28903 ID3D11Texture2D_Release(texture
);
28904 release_test_context(&test_context
);
28907 static void test_sample_mask(void)
28909 static const DWORD ps_code
[] =
28912 float4
main(in float4 pos
: SV_Position
, out uint sample_mask
: SV_Coverage
) : SV_Target
28915 return float4(1.0, 1.0, 1.0, 1.0);
28918 0x43425844, 0x196779a9, 0xda85988a, 0xb7f0a0b6, 0xb30dd6ba, 0x00000001, 0x00000114, 0x00000003,
28919 0x0000002c, 0x00000060, 0x000000b8, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
28920 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69,
28921 0x4e47534f, 0x00000050, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003,
28922 0x00000000, 0x0000000f, 0x00000042, 0x00000000, 0x00000000, 0x00000001, 0xffffffff, 0x00000e01,
28923 0x545f5653, 0x65677261, 0x56530074, 0x766f435f, 0x67617265, 0xabab0065, 0x58454853, 0x00000054,
28924 0x00000050, 0x00000015, 0x0100086a, 0x03000065, 0x001020f2, 0x00000000, 0x02000065, 0x0000f000,
28925 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000,
28926 0x04000036, 0x0000f001, 0x00004001, 0x00000005, 0x0100003e,
28928 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
28929 static const float black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
28930 struct d3d11_test_context test_context
;
28931 D3D11_TEXTURE2D_DESC texture_desc
;
28932 ID3D11DeviceContext
*context
;
28933 ID3D11RenderTargetView
*rtv
;
28934 ID3D11Texture2D
*texture
;
28935 ID3D11PixelShader
*ps
;
28936 ID3D11Device
*device
;
28937 UINT quality_levels
;
28940 if (!init_test_context(&test_context
, &feature_level
))
28942 device
= test_context
.device
;
28943 context
= test_context
.immediate_context
;
28945 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_TYPELESS
, 4, &quality_levels
);
28946 ok(hr
== S_OK
, "Failed to check multisample quality levels, hr %#x.\n", hr
);
28947 if (!quality_levels
)
28949 skip("4xMSAA not supported.\n");
28950 release_test_context(&test_context
);
28954 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
28955 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
28956 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
28958 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
28959 texture_desc
.SampleDesc
.Count
= 4;
28960 texture_desc
.SampleDesc
.Quality
= 0;
28961 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
28962 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
28963 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
28964 ok(hr
== S_OK
, "Failed to create render target view, hr %#x.\n", hr
);
28966 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
28967 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
28968 draw_quad(&test_context
);
28969 ID3D11DeviceContext_ResolveSubresource(context
, (ID3D11Resource
*)test_context
.backbuffer
, 0,
28970 (ID3D11Resource
*)texture
, 0, texture_desc
.Format
);
28971 check_texture_color(test_context
.backbuffer
, 0x7f7f7f7f, 1);
28973 ID3D11RenderTargetView_Release(rtv
);
28974 ID3D11Texture2D_Release(texture
);
28975 ID3D11PixelShader_Release(ps
);
28976 release_test_context(&test_context
);
28979 static void test_depth_clip(void)
28981 struct d3d11_test_context test_context
;
28982 D3D11_TEXTURE2D_DESC texture_desc
;
28983 D3D11_RASTERIZER_DESC rs_desc
;
28984 ID3D11DeviceContext
*context
;
28985 ID3D11DepthStencilView
*dsv
;
28986 ID3D11RasterizerState
*rs
;
28987 ID3D11Texture2D
*texture
;
28988 ID3D11Device
*device
;
28989 unsigned int count
;
28993 if (!init_test_context(&test_context
, NULL
))
28995 device
= test_context
.device
;
28996 context
= test_context
.immediate_context
;
28998 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
28999 texture_desc
.Format
= DXGI_FORMAT_D32_FLOAT
;
29000 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
29002 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
29003 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
29004 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, NULL
, &dsv
);
29005 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
29006 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &test_context
.backbuffer_rtv
, dsv
);
29009 ID3D11DeviceContext_RSGetViewports(context
, &count
, &vp
);
29011 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
29012 set_viewport(context
, vp
.TopLeftX
, vp
.TopLeftY
, vp
.Width
, vp
.Height
, 0.4f
, 0.6f
);
29013 draw_quad_z(&test_context
, 2.0f
);
29014 check_texture_float(texture
, 1.0f
, 1);
29015 draw_quad_z(&test_context
, 0.5f
);
29016 check_texture_float(texture
, 0.5f
, 1);
29017 draw_quad_z(&test_context
, -1.0f
);
29018 check_texture_float(texture
, 0.5f
, 1);
29020 rs_desc
.FillMode
= D3D11_FILL_SOLID
;
29021 rs_desc
.CullMode
= D3D11_CULL_BACK
;
29022 rs_desc
.FrontCounterClockwise
= FALSE
;
29023 rs_desc
.DepthBias
= 0;
29024 rs_desc
.DepthBiasClamp
= 0.0f
;
29025 rs_desc
.SlopeScaledDepthBias
= 0.0f
;
29026 rs_desc
.DepthClipEnable
= FALSE
;
29027 rs_desc
.ScissorEnable
= FALSE
;
29028 rs_desc
.MultisampleEnable
= FALSE
;
29029 rs_desc
.AntialiasedLineEnable
= FALSE
;
29030 hr
= ID3D11Device_CreateRasterizerState(device
, &rs_desc
, &rs
);
29031 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
29033 ID3D11DeviceContext_RSSetState(context
, rs
);
29035 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
29036 set_viewport(context
, vp
.TopLeftX
, vp
.TopLeftY
, vp
.Width
, vp
.Height
, 0.4f
, 0.6f
);
29037 draw_quad_z(&test_context
, 2.0f
);
29038 check_texture_float(texture
, 0.6f
, 1);
29039 draw_quad_z(&test_context
, 0.5f
);
29040 check_texture_float(texture
, 0.5f
, 1);
29041 draw_quad_z(&test_context
, -1.0f
);
29042 check_texture_float(texture
, 0.4f
, 1);
29044 ID3D11DepthStencilView_Release(dsv
);
29045 ID3D11Texture2D_Release(texture
);
29046 ID3D11RasterizerState_Release(rs
);
29047 release_test_context(&test_context
);
29050 static void test_staging_buffers(void)
29052 struct d3d11_test_context test_context
;
29053 ID3D11Buffer
*dst_buffer
, *src_buffer
;
29054 D3D11_SUBRESOURCE_DATA resource_data
;
29055 D3D11_BUFFER_DESC buffer_desc
;
29056 ID3D11DeviceContext
*context
;
29057 struct resource_readback rb
;
29058 float data
[16], value
;
29059 ID3D11Device
*device
;
29063 if (!init_test_context(&test_context
, NULL
))
29065 device
= test_context
.device
;
29066 context
= test_context
.immediate_context
;
29068 buffer_desc
.ByteWidth
= sizeof(data
);
29069 buffer_desc
.Usage
= D3D11_USAGE_STAGING
;
29070 buffer_desc
.BindFlags
= 0;
29071 buffer_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_WRITE
;
29072 buffer_desc
.MiscFlags
= 0;
29073 buffer_desc
.StructureByteStride
= 0;
29075 for (i
= 0; i
< ARRAY_SIZE(data
); ++i
)
29077 resource_data
.pSysMem
= data
;
29078 resource_data
.SysMemPitch
= 0;
29079 resource_data
.SysMemSlicePitch
= 0;
29081 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &resource_data
, &src_buffer
);
29082 ok(hr
== S_OK
, "Failed to create buffer, hr %#x.\n", hr
);
29084 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
29085 buffer_desc
.BindFlags
= D3D11_BIND_CONSTANT_BUFFER
;
29086 buffer_desc
.CPUAccessFlags
= 0;
29087 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &dst_buffer
);
29088 ok(hr
== S_OK
, "Failed to create buffer, hr %#x.\n", hr
);
29090 ID3D11DeviceContext_CopyResource(context
, (ID3D11Resource
*)dst_buffer
, (ID3D11Resource
*)src_buffer
);
29091 get_buffer_readback(dst_buffer
, &rb
);
29092 for (i
= 0; i
< ARRAY_SIZE(data
); ++i
)
29094 value
= get_readback_float(&rb
, i
, 0);
29095 ok(value
== data
[i
], "Got unexpected value %.8e at %u.\n", value
, i
);
29097 release_resource_readback(&rb
);
29099 for (i
= 0; i
< ARRAY_SIZE(data
); ++i
)
29101 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)src_buffer
, 0, NULL
, data
, 0, 0);
29102 ID3D11DeviceContext_CopyResource(context
, (ID3D11Resource
*)dst_buffer
, (ID3D11Resource
*)src_buffer
);
29103 get_buffer_readback(dst_buffer
, &rb
);
29104 for (i
= 0; i
< ARRAY_SIZE(data
); ++i
)
29106 value
= get_readback_float(&rb
, i
, 0);
29107 ok(value
== i
, "Got unexpected value %.8e at %u.\n", value
, i
);
29109 release_resource_readback(&rb
);
29111 ID3D11Buffer_Release(dst_buffer
);
29112 ID3D11Buffer_Release(src_buffer
);
29113 release_test_context(&test_context
);
29116 static void test_render_a8(void)
29118 static const float black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
29119 struct d3d11_test_context test_context
;
29120 D3D11_TEXTURE2D_DESC texture_desc
;
29121 ID3D11DeviceContext
*context
;
29122 ID3D11RenderTargetView
*rtv
;
29123 struct resource_readback rb
;
29124 ID3D11Texture2D
*texture
;
29125 ID3D11PixelShader
*ps
;
29126 ID3D11Device
*device
;
29130 static const DWORD ps_code
[] =
29133 void main(out float4 target
: SV_Target
)
29135 target
= float4(0.0f
, 0.25f
, 0.5f
, 1.0f
);
29138 0x43425844, 0x8a06129f, 0x3041bde2, 0x09389749, 0xb339ba8b, 0x00000001, 0x000000b0, 0x00000003,
29139 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
29140 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
29141 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
29142 0x03000065, 0x001020f2, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000,
29143 0x3e800000, 0x3f000000, 0x3f800000, 0x0100003e,
29146 if (!init_test_context(&test_context
, NULL
))
29148 device
= test_context
.device
;
29149 context
= test_context
.immediate_context
;
29151 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
29152 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
29153 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
29155 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
29156 texture_desc
.Format
= DXGI_FORMAT_A8_UNORM
;
29157 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
29158 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
29159 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
29160 ok(hr
== S_OK
, "Failed to create render target view, hr %#x.\n", hr
);
29162 for (i
= 0; i
< 2; ++i
)
29164 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
29165 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
29166 draw_quad(&test_context
);
29167 get_texture_readback(texture
, 0, &rb
);
29168 check_readback_data_u8(&rb
, NULL
, 0xff, 0);
29169 release_resource_readback(&rb
);
29171 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, black
);
29172 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &test_context
.backbuffer_rtv
, NULL
);
29173 draw_quad(&test_context
);
29174 check_texture_sub_resource_color(test_context
.backbuffer
, 0, NULL
, 0xff7f4000, 1);
29177 ID3D11PixelShader_Release(ps
);
29178 ID3D11Texture2D_Release(texture
);
29179 ID3D11RenderTargetView_Release(rtv
);
29180 release_test_context(&test_context
);
29183 static void test_standard_pattern(void)
29185 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
29186 struct d3d11_test_context test_context
;
29187 struct swapchain_desc swapchain_desc
;
29188 D3D11_TEXTURE2D_DESC texture_desc
;
29189 ID3D11UnorderedAccessView
*uav
;
29190 D3D11_BUFFER_DESC buffer_desc
;
29191 ID3D11ShaderResourceView
*srv
;
29192 ID3D11DeviceContext
*context
;
29193 struct resource_readback rb
;
29194 ID3D11Texture2D
*texture
;
29195 ID3D11PixelShader
*ps
;
29196 ID3D11Buffer
*buffer
;
29197 ID3D11Device
*device
;
29201 static const DWORD ps_samplepos
[] =
29204 Texture2DMS
<float> t
;
29205 RWByteAddressBuffer u
;
29207 float4
main() : SV_Target
29209 u
.Store2(0, asuint(t
.GetSamplePosition(0)));
29210 u
.Store2(8, asuint(t
.GetSamplePosition(1)));
29211 u
.Store2(16, asuint(t
.GetSamplePosition(2)));
29212 u
.Store2(24, asuint(t
.GetSamplePosition(3)));
29213 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
29216 0x43425844, 0xa1db77e8, 0x804d8862, 0x0e3c213d, 0x2703dec6, 0x00000001, 0x00000190, 0x00000003,
29217 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
29218 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
29219 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000118, 0x00000050, 0x00000046,
29220 0x0100086a, 0x04002058, 0x00107000, 0x00000000, 0x00005555, 0x0300009d, 0x0011e000, 0x00000001,
29221 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0800006e, 0x00100032, 0x00000000,
29222 0x00107046, 0x00000000, 0x00004001, 0x00000000, 0x00000000, 0x0800006e, 0x001000c2, 0x00000000,
29223 0x00107406, 0x00000000, 0x00004001, 0x00000001, 0x00000000, 0x070000a6, 0x0011e0f2, 0x00000001,
29224 0x00004001, 0x00000000, 0x00100e46, 0x00000000, 0x0800006e, 0x00100032, 0x00000000, 0x00107046,
29225 0x00000000, 0x00004001, 0x00000002, 0x00000000, 0x0800006e, 0x001000c2, 0x00000000, 0x00107406,
29226 0x00000000, 0x00004001, 0x00000003, 0x00000000, 0x070000a6, 0x0011e0f2, 0x00000001, 0x00004001,
29227 0x00000010, 0x00100e46, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000,
29228 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e
29230 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
29231 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
29232 static const unsigned int zero
[4] = {0};
29233 static const float standard_pos4
[] =
29235 -2 / 16.0f
, -6 / 16.0f
,
29236 6 / 16.0f
, -2 / 16.0f
,
29237 -6 / 16.0f
, 2 / 16.0f
,
29238 2 / 16.0f
, 6 / 16.0f
,
29241 swapchain_desc
.windowed
= TRUE
;
29242 swapchain_desc
.buffer_count
= 1;
29243 swapchain_desc
.width
= 32;
29244 swapchain_desc
.height
= 32;
29245 swapchain_desc
.swap_effect
= DXGI_SWAP_EFFECT_DISCARD
;
29246 swapchain_desc
.flags
= 0;
29247 if (!init_test_context_ext(&test_context
, &feature_level
, &swapchain_desc
))
29249 device
= test_context
.device
;
29250 context
= test_context
.immediate_context
;
29252 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
29253 texture_desc
.SampleDesc
.Count
= 4;
29254 texture_desc
.SampleDesc
.Quality
= D3D11_STANDARD_MULTISAMPLE_PATTERN
;
29255 texture_desc
.BindFlags
|= D3D11_BIND_SHADER_RESOURCE
;
29256 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
29257 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
29258 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
29259 ok(hr
== S_OK
, "Failed to create shader resource view, hr %#x.\n", hr
);
29261 buffer_desc
.ByteWidth
= 1024;
29262 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
29263 buffer_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
29264 buffer_desc
.CPUAccessFlags
= 0;
29265 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
;
29266 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
29267 ok(hr
== S_OK
, "Failed to create buffer, hr %#x.\n", hr
);
29268 uav_desc
.Format
= DXGI_FORMAT_R32_TYPELESS
;
29269 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
29270 U(uav_desc
).Buffer
.FirstElement
= 0;
29271 U(uav_desc
).Buffer
.NumElements
= 256;
29272 U(uav_desc
).Buffer
.Flags
= D3D11_BUFFER_UAV_FLAG_RAW
;
29273 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
29274 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
29276 hr
= ID3D11Device_CreatePixelShader(device
, ps_samplepos
, sizeof(ps_samplepos
), NULL
, &ps
);
29277 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
29278 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
29280 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, zero
);
29281 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
29282 ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context
,
29283 1, &test_context
.backbuffer_rtv
, NULL
, 1, 1, &uav
, NULL
);
29284 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
29285 draw_quad(&test_context
);
29286 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
29287 get_buffer_readback(buffer
, &rb
);
29288 for (i
= 0; i
< ARRAY_SIZE(standard_pos4
); ++i
)
29290 float data
= get_readback_float(&rb
, i
, 0);
29291 /* Wine does not support GetSamplePosition. */
29292 todo_wine
ok(data
== standard_pos4
[i
], "Got sample position %.8e, expected %.8e.\n", data
, standard_pos4
[i
]);
29294 release_resource_readback(&rb
);
29296 ID3D11PixelShader_Release(ps
);
29297 ID3D11Buffer_Release(buffer
);
29298 ID3D11UnorderedAccessView_Release(uav
);
29299 ID3D11ShaderResourceView_Release(srv
);
29300 ID3D11Texture2D_Release(texture
);
29301 release_test_context(&test_context
);
29304 static void test_desktop_window(void)
29306 ID3D11RenderTargetView
*backbuffer_rtv
;
29307 DXGI_SWAP_CHAIN_DESC swapchain_desc
;
29308 ID3D11DeviceContext
*context
;
29309 ID3D11Texture2D
*backbuffer
;
29310 IDXGISwapChain
*swapchain
;
29311 IDXGIDevice
*dxgi_device
;
29312 IDXGIAdapter
*adapter
;
29313 IDXGIFactory
*factory
;
29314 ID3D11Device
*device
;
29318 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 1.0f
};
29320 if (!(device
= create_device(NULL
)))
29322 skip("Failed to create device.\n");
29326 hr
= ID3D11Device_QueryInterface(device
, &IID_IDXGIDevice
, (void **)&dxgi_device
);
29327 ok(SUCCEEDED(hr
), "Failed to get DXGI device, hr %#x.\n", hr
);
29328 hr
= IDXGIDevice_GetAdapter(dxgi_device
, &adapter
);
29329 ok(SUCCEEDED(hr
), "Failed to get adapter, hr %#x.\n", hr
);
29330 IDXGIDevice_Release(dxgi_device
);
29331 hr
= IDXGIAdapter_GetParent(adapter
, &IID_IDXGIFactory
, (void **)&factory
);
29332 ok(SUCCEEDED(hr
), "Failed to get factory, hr %#x.\n", hr
);
29333 IDXGIAdapter_Release(adapter
);
29335 swapchain_desc
.BufferDesc
.Width
= 640;
29336 swapchain_desc
.BufferDesc
.Height
= 480;
29337 swapchain_desc
.BufferDesc
.RefreshRate
.Numerator
= 60;
29338 swapchain_desc
.BufferDesc
.RefreshRate
.Denominator
= 1;
29339 swapchain_desc
.BufferDesc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
29340 swapchain_desc
.BufferDesc
.ScanlineOrdering
= DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED
;
29341 swapchain_desc
.BufferDesc
.Scaling
= DXGI_MODE_SCALING_UNSPECIFIED
;
29342 swapchain_desc
.SampleDesc
.Count
= 1;
29343 swapchain_desc
.SampleDesc
.Quality
= 0;
29344 swapchain_desc
.BufferUsage
= DXGI_USAGE_RENDER_TARGET_OUTPUT
;
29345 swapchain_desc
.BufferCount
= 1;
29346 swapchain_desc
.OutputWindow
= GetDesktopWindow();
29347 swapchain_desc
.Windowed
= TRUE
;
29348 swapchain_desc
.SwapEffect
= DXGI_SWAP_EFFECT_DISCARD
;
29349 swapchain_desc
.Flags
= 0;
29351 hr
= IDXGIFactory_CreateSwapChain(factory
, (IUnknown
*)device
, &swapchain_desc
, &swapchain
);
29352 ok(hr
== S_OK
|| broken(hr
== DXGI_ERROR_INVALID_CALL
) /* Not available on all Windows versions. */,
29353 "Failed to create swapchain, hr %#x.\n", hr
);
29354 IDXGIFactory_Release(factory
);
29357 ID3D11Device_Release(device
);
29361 hr
= IDXGISwapChain_GetBuffer(swapchain
, 0, &IID_ID3D11Texture2D
, (void **)&backbuffer
);
29362 ok(SUCCEEDED(hr
), "Failed to get buffer, hr %#x.\n", hr
);
29364 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)backbuffer
, NULL
, &backbuffer_rtv
);
29365 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
29367 ID3D11Device_GetImmediateContext(device
, &context
);
29369 ID3D11DeviceContext_ClearRenderTargetView(context
, backbuffer_rtv
, red
);
29370 check_texture_color(backbuffer
, 0xff0000ff, 1);
29372 hr
= IDXGISwapChain_Present(swapchain
, 0, 0);
29373 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
29375 ID3D11RenderTargetView_Release(backbuffer_rtv
);
29376 ID3D11Texture2D_Release(backbuffer
);
29377 IDXGISwapChain_Release(swapchain
);
29378 ID3D11DeviceContext_Release(context
);
29379 refcount
= ID3D11Device_Release(device
);
29380 ok(!refcount
, "Device has %u references left.\n", refcount
);
29385 unsigned int argc
, i
;
29388 use_mt
= !getenv("WINETEST_NO_MT_D3D");
29390 argc
= winetest_get_mainargs(&argv
);
29391 for (i
= 2; i
< argc
; ++i
)
29393 if (!strcmp(argv
[i
], "--validate"))
29394 enable_debug_layer
= TRUE
;
29395 else if (!strcmp(argv
[i
], "--warp"))
29396 use_warp_adapter
= TRUE
;
29397 else if (!strcmp(argv
[i
], "--adapter") && i
+ 1 < argc
)
29398 use_adapter_idx
= atoi(argv
[++i
]);
29399 else if (!strcmp(argv
[i
], "--single"))
29403 print_adapter_info();
29405 queue_test(test_create_device
);
29406 queue_for_each_feature_level(test_device_interfaces
);
29407 queue_test(test_get_immediate_context
);
29408 queue_test(test_create_deferred_context
);
29409 queue_test(test_create_texture1d
);
29410 queue_test(test_texture1d_interfaces
);
29411 queue_test(test_create_texture2d
);
29412 queue_test(test_texture2d_interfaces
);
29413 queue_test(test_create_texture3d
);
29414 queue_test(test_texture3d_interfaces
);
29415 queue_test(test_create_buffer
);
29416 queue_test(test_create_depthstencil_view
);
29417 queue_test(test_depthstencil_view_interfaces
);
29418 queue_test(test_create_rendertarget_view
);
29419 queue_test(test_create_shader_resource_view
);
29420 queue_for_each_feature_level(test_create_shader
);
29421 queue_test(test_create_sampler_state
);
29422 queue_test(test_create_blend_state
);
29423 queue_test(test_create_depthstencil_state
);
29424 queue_test(test_create_rasterizer_state
);
29425 queue_test(test_create_query
);
29426 queue_test(test_occlusion_query
);
29427 queue_test(test_pipeline_statistics_query
);
29428 queue_test(test_timestamp_query
);
29429 queue_test(test_so_statistics_query
);
29430 queue_test(test_device_removed_reason
);
29431 queue_test(test_private_data
);
29432 queue_for_each_feature_level(test_state_refcounting
);
29433 queue_test(test_device_context_state
);
29434 queue_test(test_blend
);
29435 queue_test(test_texture1d
);
29436 queue_test(test_texture
);
29437 queue_test(test_cube_maps
);
29438 queue_test(test_depth_stencil_sampling
);
29439 queue_test(test_sample_c_lz
);
29440 queue_test(test_multiple_render_targets
);
29441 queue_test(test_render_target_views
);
29442 queue_test(test_layered_rendering
);
29443 queue_test(test_scissor
);
29444 queue_test(test_clear_state
);
29445 queue_test(test_il_append_aligned
);
29446 queue_test(test_instance_id
);
29447 queue_test(test_vertex_id
);
29448 queue_test(test_fragment_coords
);
29449 queue_test(test_initial_texture_data
);
29450 queue_test(test_update_subresource
);
29451 queue_test(test_copy_subresource_region
);
29452 queue_test(test_copy_subresource_region_1d
);
29453 queue_test(test_copy_subresource_region_3d
);
29454 queue_test(test_resource_map
);
29455 queue_for_each_feature_level(test_resource_access
);
29456 queue_test(test_check_multisample_quality_levels
);
29457 queue_for_each_feature_level(test_swapchain_formats
);
29458 queue_test(test_swapchain_views
);
29459 queue_test(test_swapchain_flip
);
29460 queue_test(test_clear_render_target_view_1d
);
29461 queue_test(test_clear_render_target_view_2d
);
29462 queue_test(test_clear_render_target_view_3d
);
29463 queue_test(test_clear_depth_stencil_view
);
29464 queue_test(test_clear_buffer_unordered_access_view
);
29465 queue_test(test_initial_depth_stencil_state
);
29466 queue_test(test_draw_depth_only
);
29467 queue_test(test_draw_uav_only
);
29468 queue_test(test_cb_relative_addressing
);
29469 queue_test(test_vs_input_relative_addressing
);
29470 queue_test(test_getdc
);
29471 queue_test(test_shader_stage_input_output_matching
);
29472 queue_test(test_shader_interstage_interface
);
29473 queue_test(test_sm4_if_instruction
);
29474 queue_test(test_sm4_breakc_instruction
);
29475 queue_test(test_sm4_continuec_instruction
);
29476 queue_test(test_sm4_discard_instruction
);
29477 queue_test(test_sm5_swapc_instruction
);
29478 queue_test(test_create_input_layout
);
29479 queue_test(test_input_assembler
);
29480 queue_test(test_null_sampler
);
29481 queue_test(test_check_feature_support
);
29482 queue_test(test_create_unordered_access_view
);
29483 queue_test(test_immediate_constant_buffer
);
29484 queue_test(test_fp_specials
);
29485 queue_test(test_uint_shader_instructions
);
29486 queue_test(test_index_buffer_offset
);
29487 queue_test(test_face_culling
);
29488 queue_test(test_line_antialiasing_blending
);
29489 queue_for_each_feature_level(test_format_support
);
29490 queue_for_each_9_x_feature_level(test_fl9_draw
);
29491 queue_test(test_ddy
);
29492 queue_test(test_shader_input_registers_limits
);
29493 queue_test(test_unbind_shader_resource_view
);
29494 queue_test(test_stencil_separate
);
29495 queue_test(test_uav_load
);
29496 queue_test(test_cs_uav_store
);
29497 queue_test(test_uav_store_immediate_constant
);
29498 queue_test(test_ps_cs_uav_binding
);
29499 queue_test(test_atomic_instructions
);
29500 queue_test(test_sm4_ret_instruction
);
29501 queue_test(test_primitive_restart
);
29502 queue_test(test_resinfo_instruction
);
29503 queue_test(test_sm5_bufinfo_instruction
);
29504 queue_test(test_sampleinfo_instruction
);
29505 queue_test(test_render_target_device_mismatch
);
29506 queue_test(test_buffer_srv
);
29507 queue_for_each_feature_level_in_range(D3D_FEATURE_LEVEL_10_0
, D3D_FEATURE_LEVEL_11_0
,
29508 test_unaligned_raw_buffer_access
);
29509 queue_test(test_uav_counters
);
29510 queue_test(test_dispatch_indirect
);
29511 queue_test(test_compute_shader_registers
);
29512 queue_test(test_tgsm
);
29513 queue_test(test_geometry_shader
);
29514 queue_test(test_quad_tessellation
);
29515 queue_test(test_stream_output
);
29516 queue_test(test_fl10_stream_output_desc
);
29517 queue_test(test_stream_output_resume
);
29518 queue_test(test_stream_output_components
);
29519 queue_test(test_stream_output_vs
);
29520 queue_test(test_gather
);
29521 queue_test(test_gather_c
);
29522 queue_test(test_depth_bias
);
29523 queue_test(test_fractional_viewports
);
29524 queue_for_each_feature_level_in_range(D3D_FEATURE_LEVEL_10_0
, D3D_FEATURE_LEVEL_11_0
, test_negative_viewports
);
29525 queue_test(test_early_depth_stencil
);
29526 queue_test(test_conservative_depth_output
);
29527 queue_test(test_format_compatibility
);
29528 queue_test(test_clip_distance
);
29529 queue_test(test_combined_clip_and_cull_distances
);
29530 queue_test(test_generate_mips
);
29531 queue_test(test_alpha_to_coverage
);
29532 queue_test(test_unbound_multisample_texture
);
29533 queue_test(test_multiple_viewports
);
29534 queue_test(test_multisample_resolve
);
29535 queue_test(test_sample_shading
);
29536 queue_test(test_sample_mask
);
29537 queue_test(test_depth_clip
);
29538 queue_test(test_staging_buffers
);
29539 queue_test(test_render_a8
);
29540 queue_test(test_standard_pattern
);
29541 queue_test(test_desktop_window
);
29543 run_queued_tests();