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_uint(unsigned int x
, unsigned int y
, unsigned int max_diff
)
265 unsigned int diff
= x
> y
? x
- y
: y
- x
;
267 return diff
<= max_diff
;
270 static BOOL
compare_uvec4(const struct uvec4
* v1
, const struct uvec4
*v2
)
272 return v1
->x
== v2
->x
&& v1
->y
== v2
->y
&& v1
->z
== v2
->z
&& v1
->w
== v2
->w
;
275 static BOOL
compare_color(DWORD c1
, DWORD c2
, BYTE max_diff
)
277 return compare_uint(c1
& 0xff, c2
& 0xff, max_diff
)
278 && compare_uint((c1
>> 8) & 0xff, (c2
>> 8) & 0xff, max_diff
)
279 && compare_uint((c1
>> 16) & 0xff, (c2
>> 16) & 0xff, max_diff
)
280 && compare_uint((c1
>> 24) & 0xff, (c2
>> 24) & 0xff, max_diff
);
283 static char const *debugstr_viewport(D3D11_VIEWPORT
*vp
)
285 if (!vp
) return "(null)";
286 return wine_dbg_sprintf("{%.8e, %.8e, %.8e, %.8e, %.8e, %.8e}",
287 vp
->TopLeftX
, vp
->TopLeftY
, vp
->Width
, vp
->Height
, vp
->MinDepth
, vp
->MaxDepth
);
293 D3D11_SRV_DIMENSION dimension
;
294 unsigned int miplevel_idx
;
295 unsigned int miplevel_count
;
296 unsigned int layer_idx
;
297 unsigned int layer_count
;
300 static void get_srv_desc(D3D11_SHADER_RESOURCE_VIEW_DESC
*d3d11_desc
, const struct srv_desc
*desc
)
302 d3d11_desc
->Format
= desc
->format
;
303 d3d11_desc
->ViewDimension
= desc
->dimension
;
304 if (desc
->dimension
== D3D11_SRV_DIMENSION_TEXTURE1D
)
306 U(*d3d11_desc
).Texture1D
.MostDetailedMip
= desc
->miplevel_idx
;
307 U(*d3d11_desc
).Texture1D
.MipLevels
= desc
->miplevel_count
;
309 else if (desc
->dimension
== D3D11_SRV_DIMENSION_TEXTURE1DARRAY
)
311 U(*d3d11_desc
).Texture1DArray
.MostDetailedMip
= desc
->miplevel_idx
;
312 U(*d3d11_desc
).Texture1DArray
.MipLevels
= desc
->miplevel_count
;
313 U(*d3d11_desc
).Texture1DArray
.FirstArraySlice
= desc
->layer_idx
;
314 U(*d3d11_desc
).Texture1DArray
.ArraySize
= desc
->layer_count
;
316 else if (desc
->dimension
== D3D11_SRV_DIMENSION_TEXTURE2D
)
318 U(*d3d11_desc
).Texture2D
.MostDetailedMip
= desc
->miplevel_idx
;
319 U(*d3d11_desc
).Texture2D
.MipLevels
= desc
->miplevel_count
;
321 else if (desc
->dimension
== D3D11_SRV_DIMENSION_TEXTURE2DARRAY
)
323 U(*d3d11_desc
).Texture2DArray
.MostDetailedMip
= desc
->miplevel_idx
;
324 U(*d3d11_desc
).Texture2DArray
.MipLevels
= desc
->miplevel_count
;
325 U(*d3d11_desc
).Texture2DArray
.FirstArraySlice
= desc
->layer_idx
;
326 U(*d3d11_desc
).Texture2DArray
.ArraySize
= desc
->layer_count
;
328 else if (desc
->dimension
== D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY
)
330 U(*d3d11_desc
).Texture2DMSArray
.FirstArraySlice
= desc
->layer_idx
;
331 U(*d3d11_desc
).Texture2DMSArray
.ArraySize
= desc
->layer_count
;
333 else if (desc
->dimension
== D3D11_SRV_DIMENSION_TEXTURE3D
)
335 U(*d3d11_desc
).Texture3D
.MostDetailedMip
= desc
->miplevel_idx
;
336 U(*d3d11_desc
).Texture3D
.MipLevels
= desc
->miplevel_count
;
338 else if (desc
->dimension
== D3D11_SRV_DIMENSION_TEXTURECUBE
)
340 U(*d3d11_desc
).TextureCube
.MostDetailedMip
= desc
->miplevel_idx
;
341 U(*d3d11_desc
).TextureCube
.MipLevels
= desc
->miplevel_count
;
343 else if (desc
->dimension
== D3D11_SRV_DIMENSION_TEXTURECUBEARRAY
)
345 U(*d3d11_desc
).TextureCubeArray
.MostDetailedMip
= desc
->miplevel_idx
;
346 U(*d3d11_desc
).TextureCubeArray
.MipLevels
= desc
->miplevel_count
;
347 U(*d3d11_desc
).TextureCubeArray
.First2DArrayFace
= desc
->layer_idx
;
348 U(*d3d11_desc
).TextureCubeArray
.NumCubes
= desc
->layer_count
;
350 else if (desc
->dimension
!= D3D11_SRV_DIMENSION_UNKNOWN
351 && desc
->dimension
!= D3D11_SRV_DIMENSION_TEXTURE2DMS
)
353 trace("Unhandled view dimension %#x.\n", desc
->dimension
);
357 #define check_srv_desc(a, b) check_srv_desc_(__LINE__, a, b)
358 static void check_srv_desc_(unsigned int line
, const D3D11_SHADER_RESOURCE_VIEW_DESC
*desc
,
359 const struct srv_desc
*expected_desc
)
361 ok_(__FILE__
, line
)(desc
->Format
== expected_desc
->format
,
362 "Got format %#x, expected %#x.\n", desc
->Format
, expected_desc
->format
);
363 ok_(__FILE__
, line
)(desc
->ViewDimension
== expected_desc
->dimension
,
364 "Got view dimension %#x, expected %#x.\n", desc
->ViewDimension
, expected_desc
->dimension
);
366 if (desc
->ViewDimension
!= expected_desc
->dimension
)
369 if (desc
->ViewDimension
== D3D11_SRV_DIMENSION_TEXTURE2D
)
371 ok_(__FILE__
, line
)(U(*desc
).Texture2D
.MostDetailedMip
== expected_desc
->miplevel_idx
,
372 "Got MostDetailedMip %u, expected %u.\n",
373 U(*desc
).Texture2D
.MostDetailedMip
, expected_desc
->miplevel_idx
);
374 ok_(__FILE__
, line
)(U(*desc
).Texture2D
.MipLevels
== expected_desc
->miplevel_count
,
375 "Got MipLevels %u, expected %u.\n",
376 U(*desc
).Texture2D
.MipLevels
, expected_desc
->miplevel_count
);
378 else if (desc
->ViewDimension
== D3D11_SRV_DIMENSION_TEXTURE2DARRAY
)
380 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.MostDetailedMip
== expected_desc
->miplevel_idx
,
381 "Got MostDetailedMip %u, expected %u.\n",
382 U(*desc
).Texture2DArray
.MostDetailedMip
, expected_desc
->miplevel_idx
);
383 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.MipLevels
== expected_desc
->miplevel_count
,
384 "Got MipLevels %u, expected %u.\n",
385 U(*desc
).Texture2DArray
.MipLevels
, expected_desc
->miplevel_count
);
386 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.FirstArraySlice
== expected_desc
->layer_idx
,
387 "Got FirstArraySlice %u, expected %u.\n",
388 U(*desc
).Texture2DArray
.FirstArraySlice
, expected_desc
->layer_idx
);
389 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.ArraySize
== expected_desc
->layer_count
,
390 "Got ArraySize %u, expected %u.\n",
391 U(*desc
).Texture2DArray
.ArraySize
, expected_desc
->layer_count
);
393 else if (desc
->ViewDimension
== D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY
)
395 ok_(__FILE__
, line
)(U(*desc
).Texture2DMSArray
.FirstArraySlice
== expected_desc
->layer_idx
,
396 "Got FirstArraySlice %u, expected %u.\n",
397 U(*desc
).Texture2DMSArray
.FirstArraySlice
, expected_desc
->layer_idx
);
398 ok_(__FILE__
, line
)(U(*desc
).Texture2DMSArray
.ArraySize
== expected_desc
->layer_count
,
399 "Got ArraySize %u, expected %u.\n",
400 U(*desc
).Texture2DMSArray
.ArraySize
, expected_desc
->layer_count
);
402 else if (desc
->ViewDimension
== D3D11_SRV_DIMENSION_TEXTURE3D
)
404 ok_(__FILE__
, line
)(U(*desc
).Texture3D
.MostDetailedMip
== expected_desc
->miplevel_idx
,
405 "Got MostDetailedMip %u, expected %u.\n",
406 U(*desc
).Texture3D
.MostDetailedMip
, expected_desc
->miplevel_idx
);
407 ok_(__FILE__
, line
)(U(*desc
).Texture3D
.MipLevels
== expected_desc
->miplevel_count
,
408 "Got MipLevels %u, expected %u.\n",
409 U(*desc
).Texture3D
.MipLevels
, expected_desc
->miplevel_count
);
411 else if (desc
->ViewDimension
== D3D11_SRV_DIMENSION_TEXTURECUBE
)
413 ok_(__FILE__
, line
)(U(*desc
).TextureCube
.MostDetailedMip
== expected_desc
->miplevel_idx
,
414 "Got MostDetailedMip %u, expected %u.\n",
415 U(*desc
).TextureCube
.MostDetailedMip
, expected_desc
->miplevel_idx
);
416 ok_(__FILE__
, line
)(U(*desc
).TextureCube
.MipLevels
== expected_desc
->miplevel_count
,
417 "Got MipLevels %u, expected %u.\n",
418 U(*desc
).TextureCube
.MipLevels
, expected_desc
->miplevel_count
);
420 else if (desc
->ViewDimension
== D3D11_SRV_DIMENSION_TEXTURECUBEARRAY
)
422 ok_(__FILE__
, line
)(U(*desc
).TextureCubeArray
.MostDetailedMip
== expected_desc
->miplevel_idx
,
423 "Got MostDetailedMip %u, expected %u.\n",
424 U(*desc
).TextureCubeArray
.MostDetailedMip
, expected_desc
->miplevel_idx
);
425 ok_(__FILE__
, line
)(U(*desc
).TextureCubeArray
.MipLevels
== expected_desc
->miplevel_count
,
426 "Got MipLevels %u, expected %u.\n",
427 U(*desc
).TextureCubeArray
.MipLevels
, expected_desc
->miplevel_count
);
428 ok_(__FILE__
, line
)(U(*desc
).TextureCubeArray
.First2DArrayFace
== expected_desc
->layer_idx
,
429 "Got First2DArrayFace %u, expected %u.\n",
430 U(*desc
).TextureCubeArray
.First2DArrayFace
, expected_desc
->layer_idx
);
431 ok_(__FILE__
, line
)(U(*desc
).TextureCubeArray
.NumCubes
== expected_desc
->layer_count
,
432 "Got NumCubes %u, expected %u.\n",
433 U(*desc
).TextureCubeArray
.NumCubes
, expected_desc
->layer_count
);
435 else if (desc
->ViewDimension
!= D3D11_SRV_DIMENSION_TEXTURE2DMS
)
437 trace("Unhandled view dimension %#x.\n", desc
->ViewDimension
);
444 D3D11_RTV_DIMENSION dimension
;
445 unsigned int miplevel_idx
;
446 unsigned int layer_idx
;
447 unsigned int layer_count
;
450 static void get_rtv_desc(D3D11_RENDER_TARGET_VIEW_DESC
*d3d11_desc
, const struct rtv_desc
*desc
)
452 d3d11_desc
->Format
= desc
->format
;
453 d3d11_desc
->ViewDimension
= desc
->dimension
;
454 if (desc
->dimension
== D3D11_RTV_DIMENSION_TEXTURE1D
)
456 U(*d3d11_desc
).Texture1D
.MipSlice
= desc
->miplevel_idx
;
458 else if (desc
->dimension
== D3D11_RTV_DIMENSION_TEXTURE1DARRAY
)
460 U(*d3d11_desc
).Texture1DArray
.MipSlice
= desc
->miplevel_idx
;
461 U(*d3d11_desc
).Texture1DArray
.FirstArraySlice
= desc
->layer_idx
;
462 U(*d3d11_desc
).Texture1DArray
.ArraySize
= desc
->layer_count
;
464 else if (desc
->dimension
== D3D11_RTV_DIMENSION_TEXTURE2D
)
466 U(*d3d11_desc
).Texture2D
.MipSlice
= desc
->miplevel_idx
;
468 else if (desc
->dimension
== D3D11_RTV_DIMENSION_TEXTURE2DARRAY
)
470 U(*d3d11_desc
).Texture2DArray
.MipSlice
= desc
->miplevel_idx
;
471 U(*d3d11_desc
).Texture2DArray
.FirstArraySlice
= desc
->layer_idx
;
472 U(*d3d11_desc
).Texture2DArray
.ArraySize
= desc
->layer_count
;
474 else if (desc
->dimension
== D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY
)
476 U(*d3d11_desc
).Texture2DMSArray
.FirstArraySlice
= desc
->layer_idx
;
477 U(*d3d11_desc
).Texture2DMSArray
.ArraySize
= desc
->layer_count
;
479 else if (desc
->dimension
== D3D11_RTV_DIMENSION_TEXTURE3D
)
481 U(*d3d11_desc
).Texture3D
.MipSlice
= desc
->miplevel_idx
;
482 U(*d3d11_desc
).Texture3D
.FirstWSlice
= desc
->layer_idx
;
483 U(*d3d11_desc
).Texture3D
.WSize
= desc
->layer_count
;
485 else if (desc
->dimension
!= D3D11_RTV_DIMENSION_UNKNOWN
486 && desc
->dimension
!= D3D11_RTV_DIMENSION_TEXTURE2DMS
)
488 trace("Unhandled view dimension %#x.\n", desc
->dimension
);
492 #define check_rtv_desc(a, b) check_rtv_desc_(__LINE__, a, b)
493 static void check_rtv_desc_(unsigned int line
, const D3D11_RENDER_TARGET_VIEW_DESC
*desc
,
494 const struct rtv_desc
*expected_desc
)
496 ok_(__FILE__
, line
)(desc
->Format
== expected_desc
->format
,
497 "Got format %#x, expected %#x.\n", desc
->Format
, expected_desc
->format
);
498 ok_(__FILE__
, line
)(desc
->ViewDimension
== expected_desc
->dimension
,
499 "Got view dimension %#x, expected %#x.\n", desc
->ViewDimension
, expected_desc
->dimension
);
501 if (desc
->ViewDimension
!= expected_desc
->dimension
)
504 if (desc
->ViewDimension
== D3D11_RTV_DIMENSION_TEXTURE2D
)
506 ok_(__FILE__
, line
)(U(*desc
).Texture2D
.MipSlice
== expected_desc
->miplevel_idx
,
507 "Got MipSlice %u, expected %u.\n",
508 U(*desc
).Texture2D
.MipSlice
, expected_desc
->miplevel_idx
);
510 else if (desc
->ViewDimension
== D3D11_RTV_DIMENSION_TEXTURE2DARRAY
)
512 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.MipSlice
== expected_desc
->miplevel_idx
,
513 "Got MipSlice %u, expected %u.\n",
514 U(*desc
).Texture2DArray
.MipSlice
, expected_desc
->miplevel_idx
);
515 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.FirstArraySlice
== expected_desc
->layer_idx
,
516 "Got FirstArraySlice %u, expected %u.\n",
517 U(*desc
).Texture2DArray
.FirstArraySlice
, expected_desc
->layer_idx
);
518 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.ArraySize
== expected_desc
->layer_count
,
519 "Got ArraySize %u, expected %u.\n",
520 U(*desc
).Texture2DArray
.ArraySize
, expected_desc
->layer_count
);
522 else if (desc
->ViewDimension
== D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY
)
524 ok_(__FILE__
, line
)(U(*desc
).Texture2DMSArray
.FirstArraySlice
== expected_desc
->layer_idx
,
525 "Got FirstArraySlice %u, expected %u.\n",
526 U(*desc
).Texture2DMSArray
.FirstArraySlice
, expected_desc
->layer_idx
);
527 ok_(__FILE__
, line
)(U(*desc
).Texture2DMSArray
.ArraySize
== expected_desc
->layer_count
,
528 "Got ArraySize %u, expected %u.\n",
529 U(*desc
).Texture2DMSArray
.ArraySize
, expected_desc
->layer_count
);
531 else if (desc
->ViewDimension
== D3D11_RTV_DIMENSION_TEXTURE3D
)
533 ok_(__FILE__
, line
)(U(*desc
).Texture3D
.MipSlice
== expected_desc
->miplevel_idx
,
534 "Got MipSlice %u, expected %u.\n",
535 U(*desc
).Texture3D
.MipSlice
, expected_desc
->miplevel_idx
);
536 ok_(__FILE__
, line
)(U(*desc
).Texture3D
.FirstWSlice
== expected_desc
->layer_idx
,
537 "Got FirstWSlice %u, expected %u.\n",
538 U(*desc
).Texture3D
.FirstWSlice
, expected_desc
->layer_idx
);
539 ok_(__FILE__
, line
)(U(*desc
).Texture3D
.WSize
== expected_desc
->layer_count
,
540 "Got WSize %u, expected %u.\n",
541 U(*desc
).Texture3D
.WSize
, expected_desc
->layer_count
);
543 else if (desc
->ViewDimension
!= D3D11_RTV_DIMENSION_TEXTURE2DMS
)
545 trace("Unhandled view dimension %#x.\n", desc
->ViewDimension
);
552 D3D11_DSV_DIMENSION dimension
;
553 unsigned int miplevel_idx
;
554 unsigned int layer_idx
;
555 unsigned int layer_count
;
558 static void get_dsv_desc(D3D11_DEPTH_STENCIL_VIEW_DESC
*d3d11_desc
, const struct dsv_desc
*desc
)
560 d3d11_desc
->Format
= desc
->format
;
561 d3d11_desc
->ViewDimension
= desc
->dimension
;
562 d3d11_desc
->Flags
= 0;
563 if (desc
->dimension
== D3D11_DSV_DIMENSION_TEXTURE1D
)
565 U(*d3d11_desc
).Texture1D
.MipSlice
= desc
->miplevel_idx
;
567 else if (desc
->dimension
== D3D11_DSV_DIMENSION_TEXTURE1DARRAY
)
569 U(*d3d11_desc
).Texture1DArray
.MipSlice
= desc
->miplevel_idx
;
570 U(*d3d11_desc
).Texture1DArray
.FirstArraySlice
= desc
->layer_idx
;
571 U(*d3d11_desc
).Texture1DArray
.ArraySize
= desc
->layer_count
;
573 else if (desc
->dimension
== D3D11_DSV_DIMENSION_TEXTURE2D
)
575 U(*d3d11_desc
).Texture2D
.MipSlice
= desc
->miplevel_idx
;
577 else if (desc
->dimension
== D3D11_DSV_DIMENSION_TEXTURE2DARRAY
)
579 U(*d3d11_desc
).Texture2DArray
.MipSlice
= desc
->miplevel_idx
;
580 U(*d3d11_desc
).Texture2DArray
.FirstArraySlice
= desc
->layer_idx
;
581 U(*d3d11_desc
).Texture2DArray
.ArraySize
= desc
->layer_count
;
583 else if (desc
->dimension
== D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY
)
585 U(*d3d11_desc
).Texture2DMSArray
.FirstArraySlice
= desc
->layer_idx
;
586 U(*d3d11_desc
).Texture2DMSArray
.ArraySize
= desc
->layer_count
;
588 else if (desc
->dimension
!= D3D11_DSV_DIMENSION_UNKNOWN
589 && desc
->dimension
!= D3D11_DSV_DIMENSION_TEXTURE2DMS
)
591 trace("Unhandled view dimension %#x.\n", desc
->dimension
);
595 #define check_dsv_desc(a, b) check_dsv_desc_(__LINE__, a, b)
596 static void check_dsv_desc_(unsigned int line
, const D3D11_DEPTH_STENCIL_VIEW_DESC
*desc
,
597 const struct dsv_desc
*expected_desc
)
599 ok_(__FILE__
, line
)(desc
->Format
== expected_desc
->format
,
600 "Got format %#x, expected %#x.\n", desc
->Format
, expected_desc
->format
);
601 ok_(__FILE__
, line
)(desc
->ViewDimension
== expected_desc
->dimension
,
602 "Got view dimension %#x, expected %#x.\n", desc
->ViewDimension
, expected_desc
->dimension
);
604 if (desc
->ViewDimension
!= expected_desc
->dimension
)
607 if (desc
->ViewDimension
== D3D11_DSV_DIMENSION_TEXTURE2D
)
609 ok_(__FILE__
, line
)(U(*desc
).Texture2D
.MipSlice
== expected_desc
->miplevel_idx
,
610 "Got MipSlice %u, expected %u.\n",
611 U(*desc
).Texture2D
.MipSlice
, expected_desc
->miplevel_idx
);
613 else if (desc
->ViewDimension
== D3D11_DSV_DIMENSION_TEXTURE2DARRAY
)
615 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.MipSlice
== expected_desc
->miplevel_idx
,
616 "Got MipSlice %u, expected %u.\n",
617 U(*desc
).Texture2DArray
.MipSlice
, expected_desc
->miplevel_idx
);
618 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.FirstArraySlice
== expected_desc
->layer_idx
,
619 "Got FirstArraySlice %u, expected %u.\n",
620 U(*desc
).Texture2DArray
.FirstArraySlice
, expected_desc
->layer_idx
);
621 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.ArraySize
== expected_desc
->layer_count
,
622 "Got ArraySize %u, expected %u.\n",
623 U(*desc
).Texture2DArray
.ArraySize
, expected_desc
->layer_count
);
625 else if (desc
->ViewDimension
== D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY
)
627 ok_(__FILE__
, line
)(U(*desc
).Texture2DMSArray
.FirstArraySlice
== expected_desc
->layer_idx
,
628 "Got FirstArraySlice %u, expected %u.\n",
629 U(*desc
).Texture2DMSArray
.FirstArraySlice
, expected_desc
->layer_idx
);
630 ok_(__FILE__
, line
)(U(*desc
).Texture2DMSArray
.ArraySize
== expected_desc
->layer_count
,
631 "Got ArraySize %u, expected %u.\n",
632 U(*desc
).Texture2DMSArray
.ArraySize
, expected_desc
->layer_count
);
634 else if (desc
->ViewDimension
!= D3D11_DSV_DIMENSION_TEXTURE2DMS
)
636 trace("Unhandled view dimension %#x.\n", desc
->ViewDimension
);
643 D3D11_UAV_DIMENSION dimension
;
644 unsigned int miplevel_idx
;
645 unsigned int layer_idx
;
646 unsigned int layer_count
;
649 static void get_uav_desc(D3D11_UNORDERED_ACCESS_VIEW_DESC
*d3d11_desc
, const struct uav_desc
*desc
)
651 d3d11_desc
->Format
= desc
->format
;
652 d3d11_desc
->ViewDimension
= desc
->dimension
;
653 if (desc
->dimension
== D3D11_UAV_DIMENSION_TEXTURE1D
)
655 U(*d3d11_desc
).Texture1D
.MipSlice
= desc
->miplevel_idx
;
657 else if (desc
->dimension
== D3D11_UAV_DIMENSION_TEXTURE1DARRAY
)
659 U(*d3d11_desc
).Texture1DArray
.MipSlice
= desc
->miplevel_idx
;
660 U(*d3d11_desc
).Texture1DArray
.FirstArraySlice
= desc
->layer_idx
;
661 U(*d3d11_desc
).Texture1DArray
.ArraySize
= desc
->layer_count
;
663 else if (desc
->dimension
== D3D11_UAV_DIMENSION_TEXTURE2D
)
665 U(*d3d11_desc
).Texture2D
.MipSlice
= desc
->miplevel_idx
;
667 else if (desc
->dimension
== D3D11_UAV_DIMENSION_TEXTURE2DARRAY
)
669 U(*d3d11_desc
).Texture2DArray
.MipSlice
= desc
->miplevel_idx
;
670 U(*d3d11_desc
).Texture2DArray
.FirstArraySlice
= desc
->layer_idx
;
671 U(*d3d11_desc
).Texture2DArray
.ArraySize
= desc
->layer_count
;
673 else if (desc
->dimension
== D3D11_UAV_DIMENSION_TEXTURE3D
)
675 U(*d3d11_desc
).Texture3D
.MipSlice
= desc
->miplevel_idx
;
676 U(*d3d11_desc
).Texture3D
.FirstWSlice
= desc
->layer_idx
;
677 U(*d3d11_desc
).Texture3D
.WSize
= desc
->layer_count
;
679 else if (desc
->dimension
!= D3D11_UAV_DIMENSION_UNKNOWN
)
681 trace("Unhandled view dimension %#x.\n", desc
->dimension
);
685 #define check_uav_desc(a, b) check_uav_desc_(__LINE__, a, b)
686 static void check_uav_desc_(unsigned int line
, const D3D11_UNORDERED_ACCESS_VIEW_DESC
*desc
,
687 const struct uav_desc
*expected_desc
)
689 ok_(__FILE__
, line
)(desc
->Format
== expected_desc
->format
,
690 "Got format %#x, expected %#x.\n", desc
->Format
, expected_desc
->format
);
691 ok_(__FILE__
, line
)(desc
->ViewDimension
== expected_desc
->dimension
,
692 "Got view dimension %#x, expected %#x.\n", desc
->ViewDimension
, expected_desc
->dimension
);
694 if (desc
->ViewDimension
!= expected_desc
->dimension
)
697 if (desc
->ViewDimension
== D3D11_UAV_DIMENSION_TEXTURE2D
)
699 ok_(__FILE__
, line
)(U(*desc
).Texture2D
.MipSlice
== expected_desc
->miplevel_idx
,
700 "Got MipSlice %u, expected %u.\n",
701 U(*desc
).Texture2D
.MipSlice
, expected_desc
->miplevel_idx
);
703 else if (desc
->ViewDimension
== D3D11_UAV_DIMENSION_TEXTURE2DARRAY
)
705 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.MipSlice
== expected_desc
->miplevel_idx
,
706 "Got MipSlice %u, expected %u.\n",
707 U(*desc
).Texture2DArray
.MipSlice
, expected_desc
->miplevel_idx
);
708 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.FirstArraySlice
== expected_desc
->layer_idx
,
709 "Got FirstArraySlice %u, expected %u.\n",
710 U(*desc
).Texture2DArray
.FirstArraySlice
, expected_desc
->layer_idx
);
711 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.ArraySize
== expected_desc
->layer_count
,
712 "Got ArraySize %u, expected %u.\n",
713 U(*desc
).Texture2DArray
.ArraySize
, expected_desc
->layer_count
);
715 else if (desc
->ViewDimension
== D3D11_UAV_DIMENSION_TEXTURE3D
)
717 ok_(__FILE__
, line
)(U(*desc
).Texture3D
.MipSlice
== expected_desc
->miplevel_idx
,
718 "Got MipSlice %u, expected %u.\n",
719 U(*desc
).Texture3D
.MipSlice
, expected_desc
->miplevel_idx
);
720 ok_(__FILE__
, line
)(U(*desc
).Texture3D
.FirstWSlice
== expected_desc
->layer_idx
,
721 "Got FirstWSlice %u, expected %u.\n",
722 U(*desc
).Texture3D
.FirstWSlice
, expected_desc
->layer_idx
);
723 ok_(__FILE__
, line
)(U(*desc
).Texture3D
.WSize
== expected_desc
->layer_count
,
724 "Got WSize %u, expected %u.\n",
725 U(*desc
).Texture3D
.WSize
, expected_desc
->layer_count
);
729 trace("Unhandled view dimension %#x.\n", desc
->ViewDimension
);
733 static void set_viewport(ID3D11DeviceContext
*context
, float x
, float y
,
734 float width
, float height
, float min_depth
, float max_depth
)
742 vp
.MinDepth
= min_depth
;
743 vp
.MaxDepth
= max_depth
;
745 ID3D11DeviceContext_RSSetViewports(context
, 1, &vp
);
748 #define create_buffer(a, b, c, d) create_buffer_(__LINE__, a, b, 0, c, d)
749 #define create_buffer_misc(a, b, c, d, e) create_buffer_(__LINE__, a, b, c, d, e)
750 static ID3D11Buffer
*create_buffer_(unsigned int line
, ID3D11Device
*device
,
751 unsigned int bind_flags
, unsigned int misc_flags
, unsigned int size
, const void *data
)
753 D3D11_SUBRESOURCE_DATA resource_data
;
754 D3D11_BUFFER_DESC buffer_desc
;
755 ID3D11Buffer
*buffer
;
758 buffer_desc
.ByteWidth
= size
;
759 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
760 buffer_desc
.BindFlags
= bind_flags
;
761 buffer_desc
.CPUAccessFlags
= 0;
762 buffer_desc
.MiscFlags
= misc_flags
;
763 buffer_desc
.StructureByteStride
= 0;
765 resource_data
.pSysMem
= data
;
766 resource_data
.SysMemPitch
= 0;
767 resource_data
.SysMemSlicePitch
= 0;
769 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, data
? &resource_data
: NULL
, &buffer
);
770 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
774 struct resource_readback
776 ID3D11Resource
*resource
;
777 D3D11_MAPPED_SUBRESOURCE map_desc
;
778 ID3D11DeviceContext
*immediate_context
;
779 unsigned int width
, height
, depth
, sub_resource_idx
;
782 static void init_resource_readback(ID3D11Resource
*resource
, ID3D11Resource
*readback_resource
,
783 unsigned int width
, unsigned int height
, unsigned int depth
, unsigned int sub_resource_idx
,
784 ID3D11Device
*device
, struct resource_readback
*rb
)
788 rb
->resource
= readback_resource
;
792 rb
->sub_resource_idx
= sub_resource_idx
;
794 ID3D11Device_GetImmediateContext(device
, &rb
->immediate_context
);
796 ID3D11DeviceContext_CopyResource(rb
->immediate_context
, rb
->resource
, resource
);
797 if (FAILED(hr
= ID3D11DeviceContext_Map(rb
->immediate_context
,
798 rb
->resource
, sub_resource_idx
, D3D11_MAP_READ
, 0, &rb
->map_desc
)))
800 trace("Failed to map resource, hr %#x.\n", hr
);
801 ID3D11Resource_Release(rb
->resource
);
803 ID3D11DeviceContext_Release(rb
->immediate_context
);
804 rb
->immediate_context
= NULL
;
808 static void get_buffer_readback(ID3D11Buffer
*buffer
, struct resource_readback
*rb
)
810 D3D11_BUFFER_DESC buffer_desc
;
811 ID3D11Resource
*rb_buffer
;
812 ID3D11Device
*device
;
815 memset(rb
, 0, sizeof(*rb
));
817 ID3D11Buffer_GetDevice(buffer
, &device
);
819 ID3D11Buffer_GetDesc(buffer
, &buffer_desc
);
820 buffer_desc
.Usage
= D3D11_USAGE_STAGING
;
821 buffer_desc
.BindFlags
= 0;
822 buffer_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
;
823 buffer_desc
.MiscFlags
= 0;
824 buffer_desc
.StructureByteStride
= 0;
825 if (FAILED(hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, (ID3D11Buffer
**)&rb_buffer
)))
827 trace("Failed to create staging buffer, hr %#x.\n", hr
);
828 ID3D11Device_Release(device
);
832 init_resource_readback((ID3D11Resource
*)buffer
, rb_buffer
,
833 buffer_desc
.ByteWidth
, 1, 1, 0, device
, rb
);
835 ID3D11Device_Release(device
);
838 static void get_texture1d_readback(ID3D11Texture1D
*texture
, unsigned int sub_resource_idx
,
839 struct resource_readback
*rb
)
841 D3D11_TEXTURE1D_DESC texture_desc
;
842 ID3D11Resource
*rb_texture
;
843 unsigned int miplevel
;
844 ID3D11Device
*device
;
847 memset(rb
, 0, sizeof(*rb
));
849 ID3D11Texture1D_GetDevice(texture
, &device
);
851 ID3D11Texture1D_GetDesc(texture
, &texture_desc
);
852 texture_desc
.Usage
= D3D11_USAGE_STAGING
;
853 texture_desc
.BindFlags
= 0;
854 texture_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
;
855 texture_desc
.MiscFlags
= 0;
856 if (FAILED(hr
= ID3D11Device_CreateTexture1D(device
, &texture_desc
, NULL
, (ID3D11Texture1D
**)&rb_texture
)))
858 trace("Failed to create texture, hr %#x.\n", hr
);
859 ID3D11Device_Release(device
);
863 miplevel
= sub_resource_idx
% texture_desc
.MipLevels
;
864 init_resource_readback((ID3D11Resource
*)texture
, rb_texture
,
865 max(1, texture_desc
.Width
>> miplevel
), 1, 1, sub_resource_idx
, device
, rb
);
867 ID3D11Device_Release(device
);
870 static void get_texture_readback(ID3D11Texture2D
*texture
, unsigned int sub_resource_idx
,
871 struct resource_readback
*rb
)
873 D3D11_TEXTURE2D_DESC texture_desc
;
874 ID3D11Resource
*rb_texture
;
875 unsigned int miplevel
;
876 ID3D11Device
*device
;
879 memset(rb
, 0, sizeof(*rb
));
881 ID3D11Texture2D_GetDevice(texture
, &device
);
883 ID3D11Texture2D_GetDesc(texture
, &texture_desc
);
884 texture_desc
.Usage
= D3D11_USAGE_STAGING
;
885 texture_desc
.BindFlags
= 0;
886 texture_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
;
887 texture_desc
.MiscFlags
= 0;
888 if (FAILED(hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, (ID3D11Texture2D
**)&rb_texture
)))
890 trace("Failed to create texture, hr %#x.\n", hr
);
891 ID3D11Device_Release(device
);
895 miplevel
= sub_resource_idx
% texture_desc
.MipLevels
;
896 init_resource_readback((ID3D11Resource
*)texture
, rb_texture
,
897 max(1, texture_desc
.Width
>> miplevel
),
898 max(1, texture_desc
.Height
>> miplevel
),
899 1, sub_resource_idx
, device
, rb
);
901 ID3D11Device_Release(device
);
904 static void get_texture3d_readback(ID3D11Texture3D
*texture
, unsigned int sub_resource_idx
,
905 struct resource_readback
*rb
)
907 D3D11_TEXTURE3D_DESC texture_desc
;
908 ID3D11Resource
*rb_texture
;
909 unsigned int miplevel
;
910 ID3D11Device
*device
;
913 memset(rb
, 0, sizeof(*rb
));
915 ID3D11Texture3D_GetDevice(texture
, &device
);
917 ID3D11Texture3D_GetDesc(texture
, &texture_desc
);
918 texture_desc
.Usage
= D3D11_USAGE_STAGING
;
919 texture_desc
.BindFlags
= 0;
920 texture_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
;
921 texture_desc
.MiscFlags
= 0;
922 if (FAILED(hr
= ID3D11Device_CreateTexture3D(device
, &texture_desc
, NULL
, (ID3D11Texture3D
**)&rb_texture
)))
924 trace("Failed to create texture, hr %#x.\n", hr
);
925 ID3D11Device_Release(device
);
929 miplevel
= sub_resource_idx
% texture_desc
.MipLevels
;
930 init_resource_readback((ID3D11Resource
*)texture
, rb_texture
,
931 max(1, texture_desc
.Width
>> miplevel
),
932 max(1, texture_desc
.Height
>> miplevel
),
933 max(1, texture_desc
.Depth
>> miplevel
),
934 sub_resource_idx
, device
, rb
);
936 ID3D11Device_Release(device
);
939 static void *get_readback_data(struct resource_readback
*rb
,
940 unsigned int x
, unsigned int y
, unsigned int z
, unsigned byte_width
)
942 return (BYTE
*)rb
->map_desc
.pData
+ z
* rb
->map_desc
.DepthPitch
+ y
* rb
->map_desc
.RowPitch
+ x
* byte_width
;
945 static BYTE
get_readback_u8(struct resource_readback
*rb
, unsigned int x
, unsigned int y
, unsigned int z
)
947 return *(BYTE
*)get_readback_data(rb
, x
, y
, z
, sizeof(BYTE
));
950 static WORD
get_readback_u16(struct resource_readback
*rb
, unsigned int x
, unsigned int y
, unsigned int z
)
952 return *(WORD
*)get_readback_data(rb
, x
, y
, z
, sizeof(WORD
));
955 static DWORD
get_readback_u32(struct resource_readback
*rb
, unsigned int x
, unsigned int y
, unsigned int z
)
957 return *(DWORD
*)get_readback_data(rb
, x
, y
, z
, sizeof(DWORD
));
960 static DWORD
get_readback_color(struct resource_readback
*rb
, unsigned int x
, unsigned int y
, unsigned int z
)
962 return get_readback_u32(rb
, x
, y
, z
);
965 static float get_readback_float(struct resource_readback
*rb
, unsigned int x
, unsigned int y
)
967 return *(float *)get_readback_data(rb
, x
, y
, 0, sizeof(float));
970 static const struct vec4
*get_readback_vec4(struct resource_readback
*rb
, unsigned int x
, unsigned int y
)
972 return get_readback_data(rb
, x
, y
, 0, sizeof(struct vec4
));
975 static const struct uvec4
*get_readback_uvec4(struct resource_readback
*rb
, unsigned int x
, unsigned int y
)
977 return get_readback_data(rb
, x
, y
, 0, sizeof(struct uvec4
));
980 static void release_resource_readback(struct resource_readback
*rb
)
982 ID3D11DeviceContext_Unmap(rb
->immediate_context
, rb
->resource
, rb
->sub_resource_idx
);
983 ID3D11Resource_Release(rb
->resource
);
984 ID3D11DeviceContext_Release(rb
->immediate_context
);
987 static DWORD
get_texture_color(ID3D11Texture2D
*texture
, unsigned int x
, unsigned int y
)
989 struct resource_readback rb
;
992 get_texture_readback(texture
, 0, &rb
);
993 color
= get_readback_color(&rb
, x
, y
, 0);
994 release_resource_readback(&rb
);
999 #define check_readback_data_u8(a, b, c, d) check_readback_data_u8_(__LINE__, a, b, c, d)
1000 static void check_readback_data_u8_(unsigned int line
, struct resource_readback
*rb
,
1001 const RECT
*rect
, BYTE expected_value
, BYTE max_diff
)
1003 unsigned int x
= 0, y
= 0, z
= 0;
1004 BOOL all_match
= FALSE
;
1010 SetRect(&default_rect
, 0, 0, rb
->width
, rb
->height
);
1011 rect
= &default_rect
;
1014 for (z
= 0; z
< rb
->depth
; ++z
)
1016 for (y
= rect
->top
; y
< rect
->bottom
; ++y
)
1018 for (x
= rect
->left
; x
< rect
->right
; ++x
)
1020 value
= get_readback_u8(rb
, x
, y
, z
);
1021 if (!compare_uint(value
, expected_value
, max_diff
))
1029 ok_(__FILE__
, line
)(all_match
,
1030 "Got 0x%02x, expected 0x%02x at (%u, %u, %u), sub-resource %u.\n",
1031 value
, expected_value
, x
, y
, z
, rb
->sub_resource_idx
);
1034 #define check_readback_data_u16(a, b, c, d) check_readback_data_u16_(__LINE__, a, b, c, d)
1035 static void check_readback_data_u16_(unsigned int line
, struct resource_readback
*rb
,
1036 const RECT
*rect
, WORD expected_value
, BYTE max_diff
)
1038 unsigned int x
= 0, y
= 0, z
= 0;
1039 BOOL all_match
= FALSE
;
1045 SetRect(&default_rect
, 0, 0, rb
->width
, rb
->height
);
1046 rect
= &default_rect
;
1049 for (z
= 0; z
< rb
->depth
; ++z
)
1051 for (y
= rect
->top
; y
< rect
->bottom
; ++y
)
1053 for (x
= rect
->left
; x
< rect
->right
; ++x
)
1055 value
= get_readback_u16(rb
, x
, y
, z
);
1056 if (!compare_uint(value
, expected_value
, max_diff
))
1064 ok_(__FILE__
, line
)(all_match
,
1065 "Got 0x%04x, expected 0x%04x at (%u, %u, %u), sub-resource %u.\n",
1066 value
, expected_value
, x
, y
, z
, rb
->sub_resource_idx
);
1069 #define check_readback_data_u24(a, b, c, d, e) check_readback_data_u24_(__LINE__, a, b, c, d, e)
1070 static void check_readback_data_u24_(unsigned int line
, struct resource_readback
*rb
,
1071 const RECT
*rect
, unsigned int shift
, DWORD expected_value
, BYTE max_diff
)
1073 unsigned int x
= 0, y
= 0, z
= 0;
1074 BOOL all_match
= FALSE
;
1080 SetRect(&default_rect
, 0, 0, rb
->width
, rb
->height
);
1081 rect
= &default_rect
;
1084 for (z
= 0; z
< rb
->depth
; ++z
)
1086 for (y
= rect
->top
; y
< rect
->bottom
; ++y
)
1088 for (x
= rect
->left
; x
< rect
->right
; ++x
)
1090 value
= get_readback_u32(rb
, x
, y
, z
) >> shift
;
1091 if (!compare_uint(value
, expected_value
, max_diff
))
1099 ok_(__FILE__
, line
)(all_match
,
1100 "Got 0x%06x, expected 0x%06x at (%u, %u, %u), sub-resource %u.\n",
1101 value
, expected_value
, x
, y
, z
, rb
->sub_resource_idx
);
1104 #define check_readback_data_color(a, b, c, d) check_readback_data_color_(__LINE__, a, b, c, d)
1105 static void check_readback_data_color_(unsigned int line
, struct resource_readback
*rb
,
1106 const RECT
*rect
, DWORD expected_color
, BYTE max_diff
)
1108 unsigned int x
= 0, y
= 0, z
= 0;
1109 BOOL all_match
= FALSE
;
1115 SetRect(&default_rect
, 0, 0, rb
->width
, rb
->height
);
1116 rect
= &default_rect
;
1119 for (z
= 0; z
< rb
->depth
; ++z
)
1121 for (y
= rect
->top
; y
< rect
->bottom
; ++y
)
1123 for (x
= rect
->left
; x
< rect
->right
; ++x
)
1125 color
= get_readback_color(rb
, x
, y
, z
);
1126 if (!compare_color(color
, expected_color
, max_diff
))
1134 ok_(__FILE__
, line
)(all_match
,
1135 "Got 0x%08x, expected 0x%08x at (%u, %u, %u), sub-resource %u.\n",
1136 color
, expected_color
, x
, y
, z
, rb
->sub_resource_idx
);
1139 #define check_texture_sub_resource_color(a, b, c, d, e) check_texture_sub_resource_color_(__LINE__, a, b, c, d, e)
1140 static void check_texture_sub_resource_color_(unsigned int line
, ID3D11Texture2D
*texture
,
1141 unsigned int sub_resource_idx
, const RECT
*rect
, DWORD expected_color
, BYTE max_diff
)
1143 struct resource_readback rb
;
1145 get_texture_readback(texture
, sub_resource_idx
, &rb
);
1146 check_readback_data_color_(line
, &rb
, rect
, expected_color
, max_diff
);
1147 release_resource_readback(&rb
);
1150 #define check_texture_color(t, c, d) check_texture_color_(__LINE__, t, c, d)
1151 static void check_texture_color_(unsigned int line
, ID3D11Texture2D
*texture
,
1152 DWORD expected_color
, BYTE max_diff
)
1154 unsigned int sub_resource_idx
, sub_resource_count
;
1155 D3D11_TEXTURE2D_DESC texture_desc
;
1157 ID3D11Texture2D_GetDesc(texture
, &texture_desc
);
1158 sub_resource_count
= texture_desc
.ArraySize
* texture_desc
.MipLevels
;
1159 for (sub_resource_idx
= 0; sub_resource_idx
< sub_resource_count
; ++sub_resource_idx
)
1160 check_texture_sub_resource_color_(line
, texture
, sub_resource_idx
, NULL
, expected_color
, max_diff
);
1163 #define check_texture1d_sub_resource_color(a, b, c, d, e) check_texture1d_sub_resource_color_(__LINE__, a, b, c, d, e)
1164 static void check_texture1d_sub_resource_color_(unsigned int line
, ID3D11Texture1D
*texture
,
1165 unsigned int sub_resource_idx
, const RECT
*rect
, DWORD expected_color
, BYTE max_diff
)
1167 struct resource_readback rb
;
1169 get_texture1d_readback(texture
, sub_resource_idx
, &rb
);
1170 check_readback_data_color_(line
, &rb
, rect
, expected_color
, max_diff
);
1171 release_resource_readback(&rb
);
1174 #define check_texture1d_color(t, c, d) check_texture1d_color_(__LINE__, t, c, d)
1175 static void check_texture1d_color_(unsigned int line
, ID3D11Texture1D
*texture
,
1176 DWORD expected_color
, BYTE max_diff
)
1178 unsigned int sub_resource_idx
, sub_resource_count
;
1179 D3D11_TEXTURE1D_DESC texture_desc
;
1181 ID3D11Texture1D_GetDesc(texture
, &texture_desc
);
1182 sub_resource_count
= texture_desc
.ArraySize
* texture_desc
.MipLevels
;
1183 for (sub_resource_idx
= 0; sub_resource_idx
< sub_resource_count
; ++sub_resource_idx
)
1184 check_texture1d_sub_resource_color_(line
, texture
, sub_resource_idx
, NULL
, expected_color
, max_diff
);
1187 #define check_texture3d_sub_resource_color(a, b, c, d, e) check_texture3d_sub_resource_color_(__LINE__, a, b, c, d, e)
1188 static void check_texture3d_sub_resource_color_(unsigned int line
, ID3D11Texture3D
*texture
,
1189 unsigned int sub_resource_idx
, const RECT
*rect
, DWORD expected_color
, BYTE max_diff
)
1191 struct resource_readback rb
;
1193 get_texture3d_readback(texture
, sub_resource_idx
, &rb
);
1194 check_readback_data_color_(line
, &rb
, rect
, expected_color
, max_diff
);
1195 release_resource_readback(&rb
);
1198 #define check_texture3d_color(t, c, d) check_texture3d_color_(__LINE__, t, c, d)
1199 static void check_texture3d_color_(unsigned int line
, ID3D11Texture3D
*texture
,
1200 DWORD expected_color
, BYTE max_diff
)
1202 unsigned int sub_resource_idx
, sub_resource_count
;
1203 D3D11_TEXTURE3D_DESC texture_desc
;
1205 ID3D11Texture3D_GetDesc(texture
, &texture_desc
);
1206 sub_resource_count
= texture_desc
.MipLevels
;
1207 for (sub_resource_idx
= 0; sub_resource_idx
< sub_resource_count
; ++sub_resource_idx
)
1208 check_texture3d_sub_resource_color_(line
, texture
, sub_resource_idx
, NULL
, expected_color
, max_diff
);
1211 #define check_texture_sub_resource_float(a, b, c, d, e) check_texture_sub_resource_float_(__LINE__, a, b, c, d, e)
1212 static void check_texture_sub_resource_float_(unsigned int line
, ID3D11Texture2D
*texture
,
1213 unsigned int sub_resource_idx
, const RECT
*rect
, float expected_value
, BYTE max_diff
)
1215 struct resource_readback rb
;
1216 unsigned int x
= 0, y
= 0;
1217 BOOL all_match
= TRUE
;
1221 get_texture_readback(texture
, sub_resource_idx
, &rb
);
1224 SetRect(&default_rect
, 0, 0, rb
.width
, rb
.height
);
1225 rect
= &default_rect
;
1227 for (y
= rect
->top
; y
< rect
->bottom
; ++y
)
1229 for (x
= rect
->left
; x
< rect
->right
; ++x
)
1231 value
= get_readback_float(&rb
, x
, y
);
1232 if (!compare_float(value
, expected_value
, max_diff
))
1241 release_resource_readback(&rb
);
1242 ok_(__FILE__
, line
)(all_match
,
1243 "Got %.8e, expected %.8e at (%u, %u), sub-resource %u.\n",
1244 value
, expected_value
, x
, y
, sub_resource_idx
);
1247 #define check_texture_float(r, f, d) check_texture_float_(__LINE__, r, f, d)
1248 static void check_texture_float_(unsigned int line
, ID3D11Texture2D
*texture
,
1249 float expected_value
, BYTE max_diff
)
1251 unsigned int sub_resource_idx
, sub_resource_count
;
1252 D3D11_TEXTURE2D_DESC texture_desc
;
1254 ID3D11Texture2D_GetDesc(texture
, &texture_desc
);
1255 sub_resource_count
= texture_desc
.ArraySize
* texture_desc
.MipLevels
;
1256 for (sub_resource_idx
= 0; sub_resource_idx
< sub_resource_count
; ++sub_resource_idx
)
1257 check_texture_sub_resource_float_(line
, texture
, sub_resource_idx
, NULL
, expected_value
, max_diff
);
1260 #define check_texture_sub_resource_vec4(a, b, c, d, e) check_texture_sub_resource_vec4_(__LINE__, a, b, c, d, e)
1261 static void check_texture_sub_resource_vec4_(unsigned int line
, ID3D11Texture2D
*texture
,
1262 unsigned int sub_resource_idx
, const RECT
*rect
, const struct vec4
*expected_value
, BYTE max_diff
)
1264 struct resource_readback rb
;
1265 unsigned int x
= 0, y
= 0;
1266 struct vec4 value
= {0};
1267 BOOL all_match
= TRUE
;
1270 get_texture_readback(texture
, sub_resource_idx
, &rb
);
1273 SetRect(&default_rect
, 0, 0, rb
.width
, rb
.height
);
1274 rect
= &default_rect
;
1276 for (y
= rect
->top
; y
< rect
->bottom
; ++y
)
1278 for (x
= rect
->left
; x
< rect
->right
; ++x
)
1280 value
= *get_readback_vec4(&rb
, x
, y
);
1281 if (!compare_vec4(&value
, expected_value
, max_diff
))
1290 release_resource_readback(&rb
);
1291 ok_(__FILE__
, line
)(all_match
,
1292 "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e} at (%u, %u), sub-resource %u.\n",
1293 value
.x
, value
.y
, value
.z
, value
.w
,
1294 expected_value
->x
, expected_value
->y
, expected_value
->z
, expected_value
->w
,
1295 x
, y
, sub_resource_idx
);
1298 #define check_texture_vec4(a, b, c) check_texture_vec4_(__LINE__, a, b, c)
1299 static void check_texture_vec4_(unsigned int line
, ID3D11Texture2D
*texture
,
1300 const struct vec4
*expected_value
, BYTE max_diff
)
1302 unsigned int sub_resource_idx
, sub_resource_count
;
1303 D3D11_TEXTURE2D_DESC texture_desc
;
1305 ID3D11Texture2D_GetDesc(texture
, &texture_desc
);
1306 sub_resource_count
= texture_desc
.ArraySize
* texture_desc
.MipLevels
;
1307 for (sub_resource_idx
= 0; sub_resource_idx
< sub_resource_count
; ++sub_resource_idx
)
1308 check_texture_sub_resource_vec4_(line
, texture
, sub_resource_idx
, NULL
, expected_value
, max_diff
);
1311 #define check_texture_sub_resource_uvec4(a, b, c, d) check_texture_sub_resource_uvec4_(__LINE__, a, b, c, d)
1312 static void check_texture_sub_resource_uvec4_(unsigned int line
, ID3D11Texture2D
*texture
,
1313 unsigned int sub_resource_idx
, const RECT
*rect
, const struct uvec4
*expected_value
)
1315 struct resource_readback rb
;
1316 unsigned int x
= 0, y
= 0;
1317 struct uvec4 value
= {0};
1318 BOOL all_match
= TRUE
;
1321 get_texture_readback(texture
, sub_resource_idx
, &rb
);
1324 SetRect(&default_rect
, 0, 0, rb
.width
, rb
.height
);
1325 rect
= &default_rect
;
1327 for (y
= rect
->top
; y
< rect
->bottom
; ++y
)
1329 for (x
= rect
->left
; x
< rect
->right
; ++x
)
1331 value
= *get_readback_uvec4(&rb
, x
, y
);
1332 if (!compare_uvec4(&value
, expected_value
))
1341 release_resource_readback(&rb
);
1342 ok_(__FILE__
, line
)(all_match
,
1343 "Got {0x%08x, 0x%08x, 0x%08x, 0x%08x}, expected {0x%08x, 0x%08x, 0x%08x, 0x%08x} "
1344 "at (%u, %u), sub-resource %u.\n",
1345 value
.x
, value
.y
, value
.z
, value
.w
,
1346 expected_value
->x
, expected_value
->y
, expected_value
->z
, expected_value
->w
,
1347 x
, y
, sub_resource_idx
);
1350 #define check_texture_uvec4(a, b) check_texture_uvec4_(__LINE__, a, b)
1351 static void check_texture_uvec4_(unsigned int line
, ID3D11Texture2D
*texture
,
1352 const struct uvec4
*expected_value
)
1354 unsigned int sub_resource_idx
, sub_resource_count
;
1355 D3D11_TEXTURE2D_DESC texture_desc
;
1357 ID3D11Texture2D_GetDesc(texture
, &texture_desc
);
1358 sub_resource_count
= texture_desc
.ArraySize
* texture_desc
.MipLevels
;
1359 for (sub_resource_idx
= 0; sub_resource_idx
< sub_resource_count
; ++sub_resource_idx
)
1360 check_texture_sub_resource_uvec4_(line
, texture
, sub_resource_idx
, NULL
, expected_value
);
1363 static IDXGIAdapter
*create_adapter(void)
1365 IDXGIFactory4
*factory4
;
1366 IDXGIFactory
*factory
;
1367 IDXGIAdapter
*adapter
;
1370 if (!use_warp_adapter
&& !use_adapter_idx
)
1373 if (FAILED(hr
= CreateDXGIFactory1(&IID_IDXGIFactory
, (void **)&factory
)))
1375 trace("Failed to create IDXGIFactory, hr %#x.\n", hr
);
1380 if (use_warp_adapter
)
1382 if (SUCCEEDED(hr
= IDXGIFactory_QueryInterface(factory
, &IID_IDXGIFactory4
, (void **)&factory4
)))
1384 hr
= IDXGIFactory4_EnumWarpAdapter(factory4
, &IID_IDXGIAdapter
, (void **)&adapter
);
1385 IDXGIFactory4_Release(factory4
);
1389 trace("Failed to get IDXGIFactory4, hr %#x.\n", hr
);
1394 hr
= IDXGIFactory_EnumAdapters(factory
, use_adapter_idx
, &adapter
);
1396 IDXGIFactory_Release(factory
);
1398 trace("Failed to get adapter, hr %#x.\n", hr
);
1402 static ID3D11Device
*create_device(const struct device_desc
*desc
)
1404 static const D3D_FEATURE_LEVEL default_feature_level
[] =
1406 D3D_FEATURE_LEVEL_11_0
,
1407 D3D_FEATURE_LEVEL_10_1
,
1408 D3D_FEATURE_LEVEL_10_0
,
1410 const D3D_FEATURE_LEVEL
*feature_level
;
1411 UINT flags
= desc
? desc
->flags
: 0;
1412 unsigned int feature_level_count
;
1413 IDXGIAdapter
*adapter
;
1414 ID3D11Device
*device
;
1417 if (desc
&& desc
->feature_level
)
1419 feature_level
= desc
->feature_level
;
1420 feature_level_count
= 1;
1424 feature_level
= default_feature_level
;
1425 feature_level_count
= ARRAY_SIZE(default_feature_level
);
1428 if (enable_debug_layer
)
1429 flags
|= D3D11_CREATE_DEVICE_DEBUG
;
1431 if ((adapter
= create_adapter()))
1433 hr
= D3D11CreateDevice(adapter
, D3D_DRIVER_TYPE_UNKNOWN
, NULL
, flags
,
1434 feature_level
, feature_level_count
, D3D11_SDK_VERSION
, &device
, NULL
, NULL
);
1435 IDXGIAdapter_Release(adapter
);
1436 return SUCCEEDED(hr
) ? device
: NULL
;
1439 if (SUCCEEDED(D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, flags
,
1440 feature_level
, feature_level_count
, D3D11_SDK_VERSION
, &device
, NULL
, NULL
)))
1442 if (SUCCEEDED(D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_WARP
, NULL
, flags
,
1443 feature_level
, feature_level_count
, D3D11_SDK_VERSION
, &device
, NULL
, NULL
)))
1445 if (SUCCEEDED(D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_REFERENCE
, NULL
, flags
,
1446 feature_level
, feature_level_count
, D3D11_SDK_VERSION
, &device
, NULL
, NULL
)))
1452 static void get_device_adapter_desc(ID3D11Device
*device
, DXGI_ADAPTER_DESC
*adapter_desc
)
1454 IDXGIDevice
*dxgi_device
;
1455 IDXGIAdapter
*adapter
;
1458 hr
= ID3D11Device_QueryInterface(device
, &IID_IDXGIDevice
, (void **)&dxgi_device
);
1459 ok(SUCCEEDED(hr
), "Failed to query IDXGIDevice interface, hr %#x.\n", hr
);
1460 hr
= IDXGIDevice_GetAdapter(dxgi_device
, &adapter
);
1461 ok(SUCCEEDED(hr
), "Failed to get adapter, hr %#x.\n", hr
);
1462 IDXGIDevice_Release(dxgi_device
);
1463 hr
= IDXGIAdapter_GetDesc(adapter
, adapter_desc
);
1464 ok(SUCCEEDED(hr
), "Failed to get adapter desc, hr %#x.\n", hr
);
1465 IDXGIAdapter_Release(adapter
);
1468 static void print_adapter_info(void)
1470 DXGI_ADAPTER_DESC adapter_desc
;
1471 ID3D11Device
*device
;
1473 if (!(device
= create_device(NULL
)))
1476 get_device_adapter_desc(device
, &adapter_desc
);
1477 trace("Adapter: %s, %04x:%04x.\n", wine_dbgstr_w(adapter_desc
.Description
),
1478 adapter_desc
.VendorId
, adapter_desc
.DeviceId
);
1479 ID3D11Device_Release(device
);
1482 static BOOL
is_warp_device(ID3D11Device
*device
)
1484 DXGI_ADAPTER_DESC adapter_desc
;
1485 get_device_adapter_desc(device
, &adapter_desc
);
1486 return !adapter_desc
.SubSysId
&& !adapter_desc
.Revision
1487 && ((!adapter_desc
.VendorId
&& !adapter_desc
.DeviceId
)
1488 || (adapter_desc
.VendorId
== 0x1414 && adapter_desc
.DeviceId
== 0x008c));
1491 static BOOL
is_vendor_device(ID3D11Device
*device
, unsigned int vendor_id
)
1493 DXGI_ADAPTER_DESC adapter_desc
;
1495 if (!strcmp(winetest_platform
, "wine"))
1498 get_device_adapter_desc(device
, &adapter_desc
);
1499 return adapter_desc
.VendorId
== vendor_id
;
1502 static BOOL
is_amd_device(ID3D11Device
*device
)
1504 return is_vendor_device(device
, 0x1002);
1507 static BOOL
is_intel_device(ID3D11Device
*device
)
1509 return is_vendor_device(device
, 0x8086);
1512 static BOOL
is_nvidia_device(ID3D11Device
*device
)
1514 return is_vendor_device(device
, 0x10de);
1517 static BOOL
is_d3d11_2_runtime(ID3D11Device
*device
)
1519 ID3D11Device2
*device2
;
1522 hr
= ID3D11Device_QueryInterface(device
, &IID_ID3D11Device2
, (void **)&device2
);
1524 ID3D11Device2_Release(device2
);
1528 static BOOL
check_compute_shaders_via_sm4_support(ID3D11Device
*device
)
1530 D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS options
;
1532 if (FAILED(ID3D11Device_CheckFeatureSupport(device
,
1533 D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
, &options
, sizeof(options
))))
1535 return options
.ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x
;
1538 static BOOL
check_viewport_array_index_from_any_shader_support(ID3D11Device
*device
)
1540 D3D11_FEATURE_DATA_D3D11_OPTIONS3 options
;
1542 if (FAILED(ID3D11Device_CheckFeatureSupport(device
,
1543 D3D11_FEATURE_D3D11_OPTIONS3
, &options
, sizeof(options
))))
1545 return options
.VPAndRTArrayIndexFromAnyShaderFeedingRasterizer
;
1548 static BOOL
is_buffer(ID3D11Resource
*resource
)
1550 D3D11_RESOURCE_DIMENSION dimension
;
1551 ID3D11Resource_GetType(resource
, &dimension
);
1552 return dimension
== D3D11_RESOURCE_DIMENSION_BUFFER
;
1555 static IDXGISwapChain
*create_swapchain(ID3D11Device
*device
, HWND window
,
1556 const struct swapchain_desc
*swapchain_desc
)
1558 DXGI_SWAP_CHAIN_DESC dxgi_desc
;
1559 IDXGISwapChain
*swapchain
;
1560 IDXGIDevice
*dxgi_device
;
1561 IDXGIAdapter
*adapter
;
1562 IDXGIFactory
*factory
;
1565 hr
= ID3D11Device_QueryInterface(device
, &IID_IDXGIDevice
, (void **)&dxgi_device
);
1566 ok(SUCCEEDED(hr
), "Failed to get DXGI device, hr %#x.\n", hr
);
1567 hr
= IDXGIDevice_GetAdapter(dxgi_device
, &adapter
);
1568 ok(SUCCEEDED(hr
), "Failed to get adapter, hr %#x.\n", hr
);
1569 IDXGIDevice_Release(dxgi_device
);
1570 hr
= IDXGIAdapter_GetParent(adapter
, &IID_IDXGIFactory
, (void **)&factory
);
1571 ok(SUCCEEDED(hr
), "Failed to get factory, hr %#x.\n", hr
);
1572 IDXGIAdapter_Release(adapter
);
1574 dxgi_desc
.BufferDesc
.Width
= 640;
1575 dxgi_desc
.BufferDesc
.Height
= 480;
1576 dxgi_desc
.BufferDesc
.RefreshRate
.Numerator
= 60;
1577 dxgi_desc
.BufferDesc
.RefreshRate
.Denominator
= 1;
1578 dxgi_desc
.BufferDesc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
1579 dxgi_desc
.BufferDesc
.ScanlineOrdering
= DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED
;
1580 dxgi_desc
.BufferDesc
.Scaling
= DXGI_MODE_SCALING_UNSPECIFIED
;
1581 dxgi_desc
.SampleDesc
.Count
= 1;
1582 dxgi_desc
.SampleDesc
.Quality
= 0;
1583 dxgi_desc
.BufferUsage
= DXGI_USAGE_RENDER_TARGET_OUTPUT
;
1584 dxgi_desc
.BufferCount
= 1;
1585 dxgi_desc
.OutputWindow
= window
;
1586 dxgi_desc
.Windowed
= TRUE
;
1587 dxgi_desc
.SwapEffect
= DXGI_SWAP_EFFECT_DISCARD
;
1588 dxgi_desc
.Flags
= 0;
1592 dxgi_desc
.Windowed
= swapchain_desc
->windowed
;
1593 dxgi_desc
.SwapEffect
= swapchain_desc
->swap_effect
;
1594 dxgi_desc
.BufferCount
= swapchain_desc
->buffer_count
;
1595 if (swapchain_desc
->width
)
1596 dxgi_desc
.BufferDesc
.Width
= swapchain_desc
->width
;
1597 if (swapchain_desc
->height
)
1598 dxgi_desc
.BufferDesc
.Height
= swapchain_desc
->height
;
1600 if (swapchain_desc
->flags
& SWAPCHAIN_FLAG_SHADER_INPUT
)
1601 dxgi_desc
.BufferUsage
|= DXGI_USAGE_SHADER_INPUT
;
1604 hr
= IDXGIFactory_CreateSwapChain(factory
, (IUnknown
*)device
, &dxgi_desc
, &swapchain
);
1605 ok(SUCCEEDED(hr
), "Failed to create swapchain, hr %#x.\n", hr
);
1606 IDXGIFactory_Release(factory
);
1611 struct d3d11_test_context
1613 ID3D11Device
*device
;
1615 IDXGISwapChain
*swapchain
;
1616 ID3D11Texture2D
*backbuffer
;
1617 ID3D11RenderTargetView
*backbuffer_rtv
;
1618 ID3D11DeviceContext
*immediate_context
;
1620 ID3D11InputLayout
*input_layout
;
1621 ID3D11VertexShader
*vs
;
1622 const DWORD
*vs_code
;
1623 ID3D11Buffer
*vs_cb
;
1626 ID3D11PixelShader
*ps
;
1627 ID3D11Buffer
*ps_cb
;
1630 #define init_test_context(a, b) init_test_context_(__LINE__, a, b, NULL)
1631 #define init_test_context_ext(a, b, c) init_test_context_(__LINE__, a, b, c)
1632 static BOOL
init_test_context_(unsigned int line
, struct d3d11_test_context
*context
,
1633 const D3D_FEATURE_LEVEL
*feature_level
, const struct swapchain_desc
*swapchain_desc
)
1635 unsigned int rt_width
, rt_height
;
1636 struct device_desc device_desc
;
1640 memset(context
, 0, sizeof(*context
));
1642 device_desc
.feature_level
= feature_level
;
1643 device_desc
.flags
= 0;
1644 if (!(context
->device
= create_device(&device_desc
)))
1646 skip_(__FILE__
, line
)("Failed to create device.\n");
1650 rt_width
= swapchain_desc
&& swapchain_desc
->width
? swapchain_desc
->width
: 640;
1651 rt_height
= swapchain_desc
&& swapchain_desc
->height
? swapchain_desc
->height
: 480;
1652 SetRect(&rect
, 0, 0, rt_width
, rt_height
);
1653 AdjustWindowRect(&rect
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
, FALSE
);
1654 context
->window
= CreateWindowA("static", "d3d11_test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
1655 0, 0, rect
.right
- rect
.left
, rect
.bottom
- rect
.top
, NULL
, NULL
, NULL
, NULL
);
1656 context
->swapchain
= create_swapchain(context
->device
, context
->window
, swapchain_desc
);
1657 hr
= IDXGISwapChain_GetBuffer(context
->swapchain
, 0, &IID_ID3D11Texture2D
, (void **)&context
->backbuffer
);
1658 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to get backbuffer, hr %#x.\n", hr
);
1660 hr
= ID3D11Device_CreateRenderTargetView(context
->device
, (ID3D11Resource
*)context
->backbuffer
,
1661 NULL
, &context
->backbuffer_rtv
);
1662 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
1664 ID3D11Device_GetImmediateContext(context
->device
, &context
->immediate_context
);
1666 ID3D11DeviceContext_OMSetRenderTargets(context
->immediate_context
, 1, &context
->backbuffer_rtv
, NULL
);
1668 set_viewport(context
->immediate_context
, 0.0f
, 0.0f
, rt_width
, rt_height
, 0.0f
, 1.0f
);
1673 #define release_test_context(context) release_test_context_(__LINE__, context)
1674 static void release_test_context_(unsigned int line
, struct d3d11_test_context
*context
)
1678 if (context
->input_layout
)
1679 ID3D11InputLayout_Release(context
->input_layout
);
1681 ID3D11VertexShader_Release(context
->vs
);
1683 ID3D11Buffer_Release(context
->vs_cb
);
1685 ID3D11Buffer_Release(context
->vb
);
1687 ID3D11PixelShader_Release(context
->ps
);
1689 ID3D11Buffer_Release(context
->ps_cb
);
1691 ID3D11DeviceContext_Release(context
->immediate_context
);
1692 ID3D11RenderTargetView_Release(context
->backbuffer_rtv
);
1693 ID3D11Texture2D_Release(context
->backbuffer
);
1694 IDXGISwapChain_Release(context
->swapchain
);
1695 DestroyWindow(context
->window
);
1697 ref
= ID3D11Device_Release(context
->device
);
1698 ok_(__FILE__
, line
)(!ref
, "Device has %u references left.\n", ref
);
1701 #define draw_quad(context) draw_quad_vs_(__LINE__, context, NULL, 0)
1702 #define draw_quad_vs(a, b, c) draw_quad_vs_(__LINE__, a, b, c)
1703 static void draw_quad_vs_(unsigned int line
, struct d3d11_test_context
*context
,
1704 const DWORD
*vs_code
, size_t vs_code_size
)
1706 static const D3D11_INPUT_ELEMENT_DESC default_layout_desc
[] =
1708 {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
1710 static const DWORD default_vs_code
[] =
1713 float4
main(float4 position
: POSITION
) : SV_POSITION
1718 0x43425844, 0x4fb19b86, 0x955fa240, 0x1a630688, 0x24eb9db4, 0x00000001, 0x000001e0, 0x00000006,
1719 0x00000038, 0x00000084, 0x000000d0, 0x00000134, 0x00000178, 0x000001ac, 0x53414e58, 0x00000044,
1720 0x00000044, 0xfffe0200, 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000,
1721 0x00240000, 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000, 0x02000001, 0xc00f0000, 0x80e40000,
1722 0x0000ffff, 0x50414e58, 0x00000044, 0x00000044, 0xfffe0200, 0x00000020, 0x00000024, 0x00240000,
1723 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000,
1724 0x02000001, 0xc00f0000, 0x80e40000, 0x0000ffff, 0x396e6f41, 0x0000005c, 0x0000005c, 0xfffe0200,
1725 0x00000034, 0x00000028, 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0x00240001, 0x00000000,
1726 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000, 0x04000004, 0xc0030000, 0x90ff0000, 0xa0e40000,
1727 0x90e40000, 0x02000001, 0xc00c0000, 0x90e40000, 0x0000ffff, 0x52444853, 0x0000003c, 0x00010040,
1728 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
1729 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x4e475349, 0x0000002c,
1730 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f,
1731 0x49534f50, 0x4e4f4954, 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
1732 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
1734 static const struct vec3 quad
[] =
1736 {-1.0f
, -1.0f
, 0.0f
},
1737 {-1.0f
, 1.0f
, 0.0f
},
1738 { 1.0f
, -1.0f
, 0.0f
},
1739 { 1.0f
, 1.0f
, 0.0f
},
1742 ID3D11Device
*device
= context
->device
;
1743 unsigned int stride
, offset
;
1748 vs_code
= default_vs_code
;
1749 vs_code_size
= sizeof(default_vs_code
);
1752 if (!context
->input_layout
)
1754 hr
= ID3D11Device_CreateInputLayout(device
, default_layout_desc
, ARRAY_SIZE(default_layout_desc
),
1755 vs_code
, vs_code_size
, &context
->input_layout
);
1756 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
1759 if (context
->vs_code
!= vs_code
)
1762 ID3D11VertexShader_Release(context
->vs
);
1764 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, vs_code_size
, NULL
, &context
->vs
);
1765 ok_(__FILE__
, line
)(hr
== S_OK
, "Failed to create vertex shader, hr %#x.\n", hr
);
1767 context
->vs_code
= vs_code
;
1771 context
->vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(quad
), quad
);
1773 ID3D11DeviceContext_IASetInputLayout(context
->immediate_context
, context
->input_layout
);
1774 ID3D11DeviceContext_IASetPrimitiveTopology(context
->immediate_context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
1775 stride
= sizeof(*quad
);
1777 ID3D11DeviceContext_IASetVertexBuffers(context
->immediate_context
, 0, 1, &context
->vb
, &stride
, &offset
);
1778 ID3D11DeviceContext_VSSetShader(context
->immediate_context
, context
->vs
, NULL
, 0);
1780 ID3D11DeviceContext_Draw(context
->immediate_context
, 4, 0);
1783 #define draw_quad_z(context, z) draw_quad_z_(__LINE__, context, z)
1784 static void draw_quad_z_(unsigned int line
, struct d3d11_test_context
*context
, float z
)
1786 static const DWORD vs_code
[] =
1791 void main(float4 in_position
: POSITION
, out float4 out_position
: SV_Position
)
1793 out_position
= in_position
;
1794 out_position
.z
= depth
;
1797 0x43425844, 0x22d7ff76, 0xd53b167c, 0x1b49ccf1, 0xbebfec39, 0x00000001, 0x00000100, 0x00000003,
1798 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
1799 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000b0f, 0x49534f50, 0x4e4f4954, 0xababab00,
1800 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
1801 0x00000000, 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69, 0x52444853, 0x00000064, 0x00010040,
1802 0x00000019, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005f, 0x001010b2, 0x00000000,
1803 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x05000036, 0x001020b2, 0x00000000, 0x00101c46,
1804 0x00000000, 0x06000036, 0x00102042, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x0100003e,
1807 struct vec4 data
= {z
};
1809 if (!context
->vs_cb
)
1810 context
->vs_cb
= create_buffer(context
->device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(data
), NULL
);
1812 ID3D11DeviceContext_UpdateSubresource(context
->immediate_context
,
1813 (ID3D11Resource
*)context
->vs_cb
, 0, NULL
, &data
, 0, 0);
1815 ID3D11DeviceContext_VSSetConstantBuffers(context
->immediate_context
, 0, 1, &context
->vs_cb
);
1816 draw_quad_vs_(__LINE__
, context
, vs_code
, sizeof(vs_code
));
1819 static void set_quad_color(struct d3d11_test_context
*context
, const struct vec4
*color
)
1821 ID3D11DeviceContext_UpdateSubresource(context
->immediate_context
,
1822 (ID3D11Resource
*)context
->ps_cb
, 0, NULL
, color
, 0, 0);
1825 #define draw_color_quad(a, b) draw_color_quad_(__LINE__, a, b, NULL, 0)
1826 #define draw_color_quad_vs(a, b, c, d) draw_color_quad_(__LINE__, a, b, c, d)
1827 static void draw_color_quad_(unsigned int line
, struct d3d11_test_context
*context
,
1828 const struct vec4
*color
, const DWORD
*vs_code
, size_t vs_code_size
)
1830 static const DWORD ps_color_code
[] =
1835 float4
main() : SV_TARGET
1840 0x43425844, 0xe7ffb369, 0x72bb84ee, 0x6f684dcd, 0xd367d788, 0x00000001, 0x00000158, 0x00000005,
1841 0x00000034, 0x00000080, 0x000000cc, 0x00000114, 0x00000124, 0x53414e58, 0x00000044, 0x00000044,
1842 0xffff0200, 0x00000014, 0x00000030, 0x00240001, 0x00300000, 0x00300000, 0x00240000, 0x00300000,
1843 0x00000000, 0x00000001, 0x00000000, 0xffff0200, 0x02000001, 0x800f0800, 0xa0e40000, 0x0000ffff,
1844 0x396e6f41, 0x00000044, 0x00000044, 0xffff0200, 0x00000014, 0x00000030, 0x00240001, 0x00300000,
1845 0x00300000, 0x00240000, 0x00300000, 0x00000000, 0x00000001, 0x00000000, 0xffff0200, 0x02000001,
1846 0x800f0800, 0xa0e40000, 0x0000ffff, 0x52444853, 0x00000040, 0x00000040, 0x00000010, 0x04000059,
1847 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x06000036, 0x001020f2,
1848 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x0100003e, 0x4e475349, 0x00000008, 0x00000000,
1849 0x00000008, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
1850 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054,
1853 ID3D11Device
*device
= context
->device
;
1858 hr
= ID3D11Device_CreatePixelShader(device
, ps_color_code
, sizeof(ps_color_code
), NULL
, &context
->ps
);
1859 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
1862 if (!context
->ps_cb
)
1863 context
->ps_cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(*color
), NULL
);
1865 ID3D11DeviceContext_PSSetShader(context
->immediate_context
, context
->ps
, NULL
, 0);
1866 ID3D11DeviceContext_PSSetConstantBuffers(context
->immediate_context
, 0, 1, &context
->ps_cb
);
1868 set_quad_color(context
, color
);
1870 draw_quad_vs_(line
, context
, vs_code
, vs_code_size
);
1873 static void test_create_device(void)
1875 static const D3D_FEATURE_LEVEL default_feature_levels
[] =
1877 D3D_FEATURE_LEVEL_11_0
,
1878 D3D_FEATURE_LEVEL_10_1
,
1879 D3D_FEATURE_LEVEL_10_0
,
1880 D3D_FEATURE_LEVEL_9_3
,
1881 D3D_FEATURE_LEVEL_9_2
,
1882 D3D_FEATURE_LEVEL_9_1
,
1884 D3D_FEATURE_LEVEL feature_level
, supported_feature_level
;
1885 DXGI_SWAP_CHAIN_DESC swapchain_desc
, obtained_desc
;
1886 ID3D11DeviceContext
*immediate_context
;
1887 IDXGISwapChain
*swapchain
;
1888 ID3D11Device
*device
;
1893 if (FAILED(hr
= D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
1894 &device
, NULL
, NULL
)))
1896 skip("Failed to create HAL device.\n");
1897 if ((device
= create_device(NULL
)))
1899 trace("Feature level %#x.\n", ID3D11Device_GetFeatureLevel(device
));
1900 ID3D11Device_Release(device
);
1905 supported_feature_level
= ID3D11Device_GetFeatureLevel(device
);
1906 trace("Feature level %#x.\n", supported_feature_level
);
1907 ID3D11Device_Release(device
);
1909 hr
= D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
, NULL
, NULL
, NULL
);
1910 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
1912 hr
= D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
, NULL
,
1913 &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, default_feature_levels
,
1919 ARRAY_SIZE(default_feature_levels
), D3D11_SDK_VERSION
, NULL
, &feature_level
, NULL
);
1920 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
1921 ok(feature_level
== supported_feature_level
, "Got feature level %#x, expected %#x.\n",
1922 feature_level
, supported_feature_level
);
1924 hr
= D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
, NULL
, NULL
,
1925 &immediate_context
);
1926 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
1928 ok(!!immediate_context
, "Expected immediate device context pointer, got NULL.\n");
1929 refcount
= get_refcount(immediate_context
);
1930 ok(refcount
== 1, "Got refcount %u, expected 1.\n", refcount
);
1932 ID3D11DeviceContext_GetDevice(immediate_context
, &device
);
1933 refcount
= ID3D11Device_Release(device
);
1934 ok(refcount
== 1, "Got refcount %u, expected 1.\n", refcount
);
1936 refcount
= ID3D11DeviceContext_Release(immediate_context
);
1937 ok(!refcount
, "ID3D11DeviceContext has %u references left.\n", refcount
);
1939 device
= (ID3D11Device
*)0xdeadbeef;
1940 feature_level
= 0xdeadbeef;
1941 immediate_context
= (ID3D11DeviceContext
*)0xdeadbeef;
1942 hr
= D3D11CreateDevice(NULL
, D3D_DRIVER_TYPE_UNKNOWN
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
1943 &device
, &feature_level
, &immediate_context
);
1944 todo_wine
ok(hr
== E_INVALIDARG
, "D3D11CreateDevice returned %#x.\n", hr
);
1945 ok(!device
, "Got unexpected device pointer %p.\n", device
);
1946 ok(!feature_level
, "Got unexpected feature level %#x.\n", feature_level
);
1947 ok(!immediate_context
, "Got unexpected immediate context pointer %p.\n", immediate_context
);
1949 window
= CreateWindowA("static", "d3d11_test", 0, 0, 0, 0, 0, 0, 0, 0, 0);
1951 swapchain_desc
.BufferDesc
.Width
= 800;
1952 swapchain_desc
.BufferDesc
.Height
= 600;
1953 swapchain_desc
.BufferDesc
.RefreshRate
.Numerator
= 60;
1954 swapchain_desc
.BufferDesc
.RefreshRate
.Denominator
= 60;
1955 swapchain_desc
.BufferDesc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
1956 swapchain_desc
.BufferDesc
.ScanlineOrdering
= DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED
;
1957 swapchain_desc
.BufferDesc
.Scaling
= DXGI_MODE_SCALING_UNSPECIFIED
;
1958 swapchain_desc
.SampleDesc
.Count
= 1;
1959 swapchain_desc
.SampleDesc
.Quality
= 0;
1960 swapchain_desc
.BufferUsage
= DXGI_USAGE_RENDER_TARGET_OUTPUT
;
1961 swapchain_desc
.BufferCount
= 1;
1962 swapchain_desc
.OutputWindow
= window
;
1963 swapchain_desc
.Windowed
= TRUE
;
1964 swapchain_desc
.SwapEffect
= DXGI_SWAP_EFFECT_DISCARD
;
1965 swapchain_desc
.Flags
= 0;
1967 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
1968 &swapchain_desc
, NULL
, NULL
, NULL
, NULL
);
1969 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
1971 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
1972 &swapchain_desc
, NULL
, NULL
, &feature_level
, NULL
);
1973 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
1974 ok(feature_level
== supported_feature_level
, "Got feature level %#x, expected %#x.\n",
1975 feature_level
, supported_feature_level
);
1977 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
1978 &swapchain_desc
, &swapchain
, &device
, NULL
, NULL
);
1979 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
1981 check_interface(swapchain
, &IID_IDXGISwapChain1
, TRUE
, FALSE
);
1983 memset(&obtained_desc
, 0, sizeof(obtained_desc
));
1984 hr
= IDXGISwapChain_GetDesc(swapchain
, &obtained_desc
);
1985 ok(SUCCEEDED(hr
), "GetDesc failed %#x.\n", hr
);
1986 ok(obtained_desc
.BufferDesc
.Width
== swapchain_desc
.BufferDesc
.Width
,
1987 "Got unexpected BufferDesc.Width %u.\n", obtained_desc
.BufferDesc
.Width
);
1988 ok(obtained_desc
.BufferDesc
.Height
== swapchain_desc
.BufferDesc
.Height
,
1989 "Got unexpected BufferDesc.Height %u.\n", obtained_desc
.BufferDesc
.Height
);
1990 todo_wine
ok(obtained_desc
.BufferDesc
.RefreshRate
.Numerator
== swapchain_desc
.BufferDesc
.RefreshRate
.Numerator
,
1991 "Got unexpected BufferDesc.RefreshRate.Numerator %u.\n",
1992 obtained_desc
.BufferDesc
.RefreshRate
.Numerator
);
1993 todo_wine
ok(obtained_desc
.BufferDesc
.RefreshRate
.Denominator
== swapchain_desc
.BufferDesc
.RefreshRate
.Denominator
,
1994 "Got unexpected BufferDesc.RefreshRate.Denominator %u.\n",
1995 obtained_desc
.BufferDesc
.RefreshRate
.Denominator
);
1996 ok(obtained_desc
.BufferDesc
.Format
== swapchain_desc
.BufferDesc
.Format
,
1997 "Got unexpected BufferDesc.Format %#x.\n", obtained_desc
.BufferDesc
.Format
);
1998 ok(obtained_desc
.BufferDesc
.ScanlineOrdering
== swapchain_desc
.BufferDesc
.ScanlineOrdering
,
1999 "Got unexpected BufferDesc.ScanlineOrdering %#x.\n", obtained_desc
.BufferDesc
.ScanlineOrdering
);
2000 ok(obtained_desc
.BufferDesc
.Scaling
== swapchain_desc
.BufferDesc
.Scaling
,
2001 "Got unexpected BufferDesc.Scaling %#x.\n", obtained_desc
.BufferDesc
.Scaling
);
2002 ok(obtained_desc
.SampleDesc
.Count
== swapchain_desc
.SampleDesc
.Count
,
2003 "Got unexpected SampleDesc.Count %u.\n", obtained_desc
.SampleDesc
.Count
);
2004 ok(obtained_desc
.SampleDesc
.Quality
== swapchain_desc
.SampleDesc
.Quality
,
2005 "Got unexpected SampleDesc.Quality %u.\n", obtained_desc
.SampleDesc
.Quality
);
2006 ok(obtained_desc
.BufferUsage
== swapchain_desc
.BufferUsage
,
2007 "Got unexpected BufferUsage %#x.\n", obtained_desc
.BufferUsage
);
2008 ok(obtained_desc
.BufferCount
== swapchain_desc
.BufferCount
,
2009 "Got unexpected BufferCount %u.\n", obtained_desc
.BufferCount
);
2010 ok(obtained_desc
.OutputWindow
== swapchain_desc
.OutputWindow
,
2011 "Got unexpected OutputWindow %p.\n", obtained_desc
.OutputWindow
);
2012 ok(obtained_desc
.Windowed
== swapchain_desc
.Windowed
,
2013 "Got unexpected Windowed %#x.\n", obtained_desc
.Windowed
);
2014 ok(obtained_desc
.SwapEffect
== swapchain_desc
.SwapEffect
,
2015 "Got unexpected SwapEffect %#x.\n", obtained_desc
.SwapEffect
);
2016 ok(obtained_desc
.Flags
== swapchain_desc
.Flags
,
2017 "Got unexpected Flags %#x.\n", obtained_desc
.Flags
);
2019 refcount
= IDXGISwapChain_Release(swapchain
);
2020 ok(!refcount
, "Swapchain has %u references left.\n", refcount
);
2022 feature_level
= ID3D11Device_GetFeatureLevel(device
);
2023 ok(feature_level
== supported_feature_level
, "Got feature level %#x, expected %#x.\n",
2024 feature_level
, supported_feature_level
);
2026 refcount
= ID3D11Device_Release(device
);
2027 ok(!refcount
, "Device has %u references left.\n", refcount
);
2029 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
2030 NULL
, NULL
, &device
, NULL
, NULL
);
2031 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2032 ID3D11Device_Release(device
);
2034 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
2035 NULL
, NULL
, NULL
, NULL
, NULL
);
2036 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
2038 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
2039 NULL
, NULL
, NULL
, &feature_level
, NULL
);
2040 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
2041 ok(feature_level
== supported_feature_level
, "Got feature level %#x, expected %#x.\n",
2042 feature_level
, supported_feature_level
);
2044 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
2045 NULL
, NULL
, NULL
, NULL
, &immediate_context
);
2046 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2047 ID3D11DeviceContext_Release(immediate_context
);
2049 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
2050 &swapchain_desc
, NULL
, NULL
, NULL
, NULL
);
2051 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
2053 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
2054 &swapchain_desc
, &swapchain
, NULL
, NULL
, NULL
);
2055 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2056 IDXGISwapChain_Release(swapchain
);
2058 swapchain_desc
.OutputWindow
= NULL
;
2059 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
2060 &swapchain_desc
, NULL
, NULL
, NULL
, NULL
);
2061 ok(hr
== S_FALSE
, "D3D11CreateDeviceAndSwapChain returned %#x.\n", hr
);
2062 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
2063 &swapchain_desc
, NULL
, &device
, NULL
, NULL
);
2064 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2065 ID3D11Device_Release(device
);
2067 swapchain
= (IDXGISwapChain
*)0xdeadbeef;
2068 device
= (ID3D11Device
*)0xdeadbeef;
2069 feature_level
= 0xdeadbeef;
2070 immediate_context
= (ID3D11DeviceContext
*)0xdeadbeef;
2071 swapchain_desc
.OutputWindow
= NULL
;
2072 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
2073 &swapchain_desc
, &swapchain
, &device
, &feature_level
, &immediate_context
);
2074 ok(hr
== DXGI_ERROR_INVALID_CALL
, "D3D11CreateDeviceAndSwapChain returned %#x.\n", hr
);
2075 ok(!swapchain
, "Got unexpected swapchain pointer %p.\n", swapchain
);
2076 ok(!device
, "Got unexpected device pointer %p.\n", device
);
2077 ok(!feature_level
, "Got unexpected feature level %#x.\n", feature_level
);
2078 ok(!immediate_context
, "Got unexpected immediate context pointer %p.\n", immediate_context
);
2080 swapchain
= (IDXGISwapChain
*)0xdeadbeef;
2081 device
= (ID3D11Device
*)0xdeadbeef;
2082 feature_level
= 0xdeadbeef;
2083 immediate_context
= (ID3D11DeviceContext
*)0xdeadbeef;
2084 swapchain_desc
.OutputWindow
= window
;
2085 swapchain_desc
.BufferDesc
.Format
= DXGI_FORMAT_BC5_UNORM
;
2086 hr
= D3D11CreateDeviceAndSwapChain(NULL
, D3D_DRIVER_TYPE_HARDWARE
, NULL
, 0, NULL
, 0, D3D11_SDK_VERSION
,
2087 &swapchain_desc
, &swapchain
, &device
, &feature_level
, &immediate_context
);
2088 ok(hr
== E_INVALIDARG
, "D3D11CreateDeviceAndSwapChain returned %#x.\n", hr
);
2089 ok(!swapchain
, "Got unexpected swapchain pointer %p.\n", swapchain
);
2090 ok(!device
, "Got unexpected device pointer %p.\n", device
);
2091 ok(!feature_level
, "Got unexpected feature level %#x.\n", feature_level
);
2092 ok(!immediate_context
, "Got unexpected immediate context pointer %p.\n", immediate_context
);
2094 DestroyWindow(window
);
2097 static void test_device_interfaces(const D3D_FEATURE_LEVEL feature_level
)
2099 struct device_desc device_desc
;
2100 IDXGIAdapter
*dxgi_adapter
;
2101 IDXGIDevice
*dxgi_device
;
2102 ID3D11Device
*device
;
2107 device_desc
.feature_level
= &feature_level
;
2108 device_desc
.flags
= 0;
2109 if (!(device
= create_device(&device_desc
)))
2111 skip("Failed to create device for feature level %#x.\n", feature_level
);
2115 check_interface(device
, &IID_IUnknown
, TRUE
, FALSE
);
2116 check_interface(device
, &IID_IDXGIObject
, TRUE
, FALSE
);
2117 check_interface(device
, &IID_IDXGIDevice
, TRUE
, FALSE
);
2118 check_interface(device
, &IID_IDXGIDevice1
, TRUE
, FALSE
);
2119 check_interface(device
, &IID_ID3D10Multithread
, TRUE
, TRUE
); /* Not available on all Windows versions. */
2120 check_interface(device
, &IID_ID3D10Device
, FALSE
, FALSE
);
2121 check_interface(device
, &IID_ID3D10Device1
, FALSE
, FALSE
);
2122 check_interface(device
, &IID_ID3D11InfoQueue
, enable_debug_layer
, FALSE
);
2124 hr
= ID3D11Device_QueryInterface(device
, &IID_IDXGIDevice
, (void **)&dxgi_device
);
2125 ok(SUCCEEDED(hr
), "Device should implement IDXGIDevice.\n");
2126 hr
= IDXGIDevice_GetParent(dxgi_device
, &IID_IDXGIAdapter
, (void **)&dxgi_adapter
);
2127 ok(SUCCEEDED(hr
), "Device parent should implement IDXGIAdapter.\n");
2128 hr
= IDXGIAdapter_GetParent(dxgi_adapter
, &IID_IDXGIFactory
, (void **)&iface
);
2129 ok(SUCCEEDED(hr
), "Adapter parent should implement IDXGIFactory.\n");
2130 IUnknown_Release(iface
);
2131 IDXGIAdapter_Release(dxgi_adapter
);
2132 hr
= IDXGIDevice_GetParent(dxgi_device
, &IID_IDXGIAdapter1
, (void **)&dxgi_adapter
);
2133 ok(SUCCEEDED(hr
), "Device parent should implement IDXGIAdapter1.\n");
2134 hr
= IDXGIAdapter_GetParent(dxgi_adapter
, &IID_IDXGIFactory1
, (void **)&iface
);
2135 ok(SUCCEEDED(hr
), "Adapter parent should implement IDXGIFactory1.\n");
2136 IUnknown_Release(iface
);
2137 IDXGIAdapter_Release(dxgi_adapter
);
2138 IDXGIDevice_Release(dxgi_device
);
2140 refcount
= ID3D11Device_Release(device
);
2141 ok(!refcount
, "Device has %u references left.\n", refcount
);
2143 device_desc
.feature_level
= &feature_level
;
2144 device_desc
.flags
= D3D11_CREATE_DEVICE_DEBUG
;
2145 if (!(device
= create_device(&device_desc
)))
2147 skip("Failed to create debug device for feature level %#x.\n", feature_level
);
2151 todo_wine
check_interface(device
, &IID_ID3D11InfoQueue
, TRUE
, FALSE
);
2153 refcount
= ID3D11Device_Release(device
);
2154 ok(!refcount
, "Device has %u references left.\n", refcount
);
2157 static void test_immediate_context(void)
2159 ID3D11DeviceContext
*immediate_context
, *previous_immediate_context
;
2160 ULONG expected_refcount
, refcount
;
2161 ID3D11CommandList
*command_list
;
2162 ID3D11Multithread
*multithread
;
2163 ID3D11Buffer
*buffer
[2];
2164 ID3D11Device
*device
;
2169 static const unsigned int buffer_contents
[] =
2171 0x11111111, 0x22222222, 0x33333333, 0x44444444,
2172 0x55555555, 0x66666666, 0x77777777, 0x88888888,
2175 if (!(device
= create_device(NULL
)))
2177 skip("Failed to create device.\n");
2181 expected_refcount
= get_refcount(device
) + 1;
2182 ID3D11Device_GetImmediateContext(device
, &immediate_context
);
2183 refcount
= get_refcount(device
);
2184 ok(refcount
== expected_refcount
, "Got unexpected refcount %u.\n", refcount
);
2185 previous_immediate_context
= immediate_context
;
2187 ID3D11Device_GetImmediateContext(device
, &immediate_context
);
2188 ok(immediate_context
== previous_immediate_context
, "Got different immediate device context objects.\n");
2189 refcount
= get_refcount(device
);
2190 ok(refcount
== expected_refcount
, "Got unexpected refcount %u.\n", refcount
);
2192 refcount
= ID3D11DeviceContext_Release(previous_immediate_context
);
2193 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
2194 refcount
= ID3D11DeviceContext_Release(immediate_context
);
2195 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
2197 ID3D11Device_GetImmediateContext(device
, &immediate_context
);
2198 ok(immediate_context
== previous_immediate_context
, "Got different immediate device context objects.\n");
2199 refcount
= ID3D11DeviceContext_Release(immediate_context
);
2200 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
2202 ID3D11Device_GetImmediateContext(device
, &immediate_context
);
2203 expected_refcount
= get_refcount(immediate_context
) + 1;
2204 hr
= ID3D11DeviceContext_QueryInterface(immediate_context
, &IID_ID3D11Multithread
, (void **)&multithread
);
2205 if (hr
== E_NOINTERFACE
)
2207 win_skip("ID3D11Multithread is not supported.\n");
2210 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
2212 refcount
= get_refcount(immediate_context
);
2213 ok(refcount
== expected_refcount
, "Got refcount %u, expected %u.\n", refcount
, expected_refcount
);
2215 expected_refcount
= refcount
;
2216 refcount
= get_refcount(multithread
);
2217 ok(refcount
== expected_refcount
, "Got refcount %u, expected %u.\n", refcount
, expected_refcount
);
2219 enabled
= ID3D11Multithread_GetMultithreadProtected(multithread
);
2220 todo_wine
ok(!enabled
, "Multithread protection is %#x.\n", enabled
);
2222 ID3D11Multithread_Release(multithread
);
2224 ID3D11Device_GetImmediateContext(device
, &immediate_context
);
2226 flags
= ID3D11DeviceContext_GetContextFlags(immediate_context
);
2227 ok(!flags
, "Got unexpected flags %#x.\n", flags
);
2229 hr
= ID3D11DeviceContext_FinishCommandList(immediate_context
, FALSE
, &command_list
);
2230 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
2232 buffer
[0] = create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, 16, &buffer_contents
[0]);
2233 buffer
[1] = create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, 16, &buffer_contents
[4]);
2235 ID3D11DeviceContext_CopyResource(immediate_context
, (ID3D11Resource
*)buffer
[1], (ID3D11Resource
*)buffer
[0]);
2237 hr
= ID3D11DeviceContext_FinishCommandList(immediate_context
, FALSE
, &command_list
);
2238 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
2240 ID3D11Buffer_Release(buffer
[1]);
2241 ID3D11Buffer_Release(buffer
[0]);
2242 ID3D11DeviceContext_Release(immediate_context
);
2245 refcount
= ID3D11DeviceContext_Release(immediate_context
);
2246 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
2247 refcount
= ID3D11Device_Release(device
);
2248 ok(!refcount
, "Device has %u references left.\n", refcount
);
2251 static void test_create_deferred_context(void)
2253 ULONG refcount
, expected_refcount
;
2254 struct device_desc device_desc
;
2255 ID3D11DeviceContext
*context
;
2256 ID3D11Device
*device
;
2259 device_desc
.feature_level
= NULL
;
2260 device_desc
.flags
= D3D11_CREATE_DEVICE_SINGLETHREADED
;
2261 if (!(device
= create_device(&device_desc
)))
2263 skip("Failed to create single-threaded device.\n");
2267 hr
= ID3D11Device_CreateDeferredContext(device
, 0, &context
);
2268 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Failed to create deferred context, hr %#x.\n", hr
);
2270 refcount
= ID3D11Device_Release(device
);
2271 ok(!refcount
, "Device has %u references left.\n", refcount
);
2273 if (!(device
= create_device(NULL
)))
2275 skip("Failed to create device.\n");
2279 expected_refcount
= get_refcount(device
) + 1;
2280 hr
= ID3D11Device_CreateDeferredContext(device
, 0, &context
);
2281 todo_wine
ok(hr
== S_OK
, "Failed to create deferred context, hr %#x.\n", hr
);
2284 refcount
= get_refcount(device
);
2285 ok(refcount
== expected_refcount
, "Got refcount %u, expected %u.\n", refcount
, expected_refcount
);
2286 refcount
= get_refcount(context
);
2287 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
2289 check_interface(context
, &IID_IUnknown
, TRUE
, FALSE
);
2290 check_interface(context
, &IID_ID3D11DeviceChild
, TRUE
, FALSE
);
2291 check_interface(context
, &IID_ID3D11DeviceContext
, TRUE
, FALSE
);
2292 check_interface(context
, &IID_ID3D11Multithread
, FALSE
, FALSE
);
2294 refcount
= ID3D11DeviceContext_Release(context
);
2295 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
2298 refcount
= ID3D11Device_Release(device
);
2299 ok(!refcount
, "Device has %u references left.\n", refcount
);
2302 static void test_create_texture1d(void)
2304 ULONG refcount
, expected_refcount
;
2305 D3D11_SUBRESOURCE_DATA data
= {0};
2306 ID3D11Device
*device
, *tmp
;
2307 D3D11_TEXTURE1D_DESC desc
;
2308 ID3D11Texture1D
*texture
;
2312 if (!(device
= create_device(NULL
)))
2314 skip("Failed to create device.\n");
2321 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
2322 desc
.Usage
= D3D11_USAGE_DEFAULT
;
2323 desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
2324 desc
.CPUAccessFlags
= 0;
2327 hr
= ID3D11Device_CreateTexture1D(device
, &desc
, &data
, &texture
);
2328 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
2330 expected_refcount
= get_refcount(device
) + 1;
2331 hr
= ID3D11Device_CreateTexture1D(device
, &desc
, NULL
, &texture
);
2332 ok(SUCCEEDED(hr
), "Failed to create a 1d texture, hr %#x.\n", hr
);
2333 refcount
= get_refcount(device
);
2334 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2336 expected_refcount
= refcount
+ 1;
2337 ID3D11Texture1D_GetDevice(texture
, &tmp
);
2338 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2339 refcount
= get_refcount(device
);
2340 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2341 ID3D11Device_Release(tmp
);
2343 check_interface(texture
, &IID_IDXGISurface
, TRUE
, FALSE
);
2344 ID3D11Texture1D_Release(texture
);
2347 expected_refcount
= get_refcount(device
) + 1;
2348 hr
= ID3D11Device_CreateTexture1D(device
, &desc
, NULL
, &texture
);
2349 ok(SUCCEEDED(hr
), "Failed to create a 1d texture, hr %#x.\n", hr
);
2350 refcount
= get_refcount(device
);
2351 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2353 expected_refcount
= refcount
+ 1;
2354 ID3D11Texture1D_GetDevice(texture
, &tmp
);
2355 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2356 refcount
= get_refcount(device
);
2357 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2358 ID3D11Device_Release(tmp
);
2360 ID3D11Texture1D_GetDesc(texture
, &desc
);
2361 ok(desc
.Width
== 512, "Got unexpected Width %u.\n", desc
.Width
);
2362 ok(desc
.MipLevels
== 10, "Got unexpected MipLevels %u.\n", desc
.MipLevels
);
2363 ok(desc
.ArraySize
== 1, "Got unexpected ArraySize %u.\n", desc
.ArraySize
);
2364 ok(desc
.Format
== DXGI_FORMAT_R8G8B8A8_UNORM
, "Got unexpected Format %#x.\n", desc
.Format
);
2365 ok(desc
.Usage
== D3D11_USAGE_DEFAULT
, "Got unexpected Usage %u.\n", desc
.Usage
);
2366 ok(desc
.BindFlags
== D3D11_BIND_SHADER_RESOURCE
, "Got unexpected BindFlags %#x.\n", desc
.BindFlags
);
2367 ok(desc
.CPUAccessFlags
== 0, "Got unexpected CPUAccessFlags %#x.\n", desc
.CPUAccessFlags
);
2368 ok(desc
.MiscFlags
== 0, "Got unexpected MiscFlags %#x.\n", desc
.MiscFlags
);
2370 check_interface(texture
, &IID_IDXGISurface
, FALSE
, FALSE
);
2371 ID3D11Texture1D_Release(texture
);
2375 hr
= ID3D11Device_CreateTexture1D(device
, &desc
, NULL
, &texture
);
2376 ok(SUCCEEDED(hr
), "Failed to create a 1d texture, hr %#x.\n", hr
);
2378 check_interface(texture
, &IID_IDXGISurface
, FALSE
, FALSE
);
2379 ID3D11Texture1D_Release(texture
);
2381 for (i
= 0; i
< 4; ++i
)
2384 desc
.Format
= DXGI_FORMAT_R32G32B32A32_TYPELESS
;
2385 desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
2387 hr
= ID3D11Device_CreateTexture1D(device
, &desc
, NULL
, &texture
);
2388 ok(hr
== (i
? S_OK
: E_INVALIDARG
), "Test %u: Got unexpected hr %#x.\n", i
, hr
);
2390 ID3D11Texture1D_Release(texture
);
2393 refcount
= ID3D11Device_Release(device
);
2394 ok(!refcount
, "Device has %u references left.\n", refcount
);
2397 static void test_texture1d_interfaces(void)
2399 ID3D10Texture1D
*d3d10_texture
;
2400 D3D11_TEXTURE1D_DESC desc
;
2401 ID3D11Texture1D
*texture
;
2402 ID3D11Device
*device
;
2407 static const struct test
2409 BOOL implements_d3d10_interfaces
;
2412 UINT expected_bind_flags
;
2413 UINT expected_misc_flags
;
2415 desc_conversion_tests
[] =
2419 D3D11_BIND_SHADER_RESOURCE
, 0,
2420 D3D10_BIND_SHADER_RESOURCE
, 0
2424 D3D11_BIND_UNORDERED_ACCESS
, 0,
2425 D3D11_BIND_UNORDERED_ACCESS
, 0
2429 0, D3D11_RESOURCE_MISC_RESOURCE_CLAMP
,
2434 0, D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX
,
2435 0, D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX
2439 if (!(device
= create_device(NULL
)))
2441 skip("Failed to create ID3D11Device, skipping tests.\n");
2448 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
2449 desc
.Usage
= D3D11_USAGE_DEFAULT
;
2450 desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
2451 desc
.CPUAccessFlags
= 0;
2454 hr
= ID3D11Device_CreateTexture1D(device
, &desc
, NULL
, &texture
);
2455 ok(SUCCEEDED(hr
), "Failed to create a 1d texture, hr %#x.\n", hr
);
2456 check_interface(texture
, &IID_IDXGISurface
, FALSE
, FALSE
);
2457 hr
= check_interface(texture
, &IID_ID3D10Texture1D
, TRUE
, TRUE
); /* Not available on all Windows versions. */
2458 ID3D11Texture1D_Release(texture
);
2461 win_skip("1D textures do not implement ID3D10Texture1D, skipping tests.\n");
2462 ID3D11Device_Release(device
);
2466 for (i
= 0; i
< ARRAY_SIZE(desc_conversion_tests
); ++i
)
2468 const struct test
*current
= &desc_conversion_tests
[i
];
2469 D3D10_TEXTURE1D_DESC d3d10_desc
;
2470 ID3D10Device
*d3d10_device
;
2475 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
2476 desc
.Usage
= D3D11_USAGE_DEFAULT
;
2477 desc
.BindFlags
= current
->bind_flags
;
2478 desc
.CPUAccessFlags
= 0;
2479 desc
.MiscFlags
= current
->misc_flags
;
2481 hr
= ID3D11Device_CreateTexture1D(device
, &desc
, NULL
, &texture
);
2482 /* Shared resources are not supported by REF and WARP devices. */
2483 ok(SUCCEEDED(hr
) || broken(hr
== E_OUTOFMEMORY
),
2484 "Test %u: Failed to create a 1d texture, hr %#x.\n", i
, hr
);
2487 win_skip("Failed to create ID3D11Texture1D, skipping test %u.\n", i
);
2491 check_interface(texture
, &IID_IDXGISurface
, TRUE
, FALSE
);
2493 hr
= ID3D11Texture1D_QueryInterface(texture
, &IID_ID3D10Texture1D
, (void **)&d3d10_texture
);
2494 ID3D11Texture1D_Release(texture
);
2496 if (current
->implements_d3d10_interfaces
)
2498 ok(SUCCEEDED(hr
), "Test %u: Texture should implement ID3D10Texture1D.\n", i
);
2502 todo_wine
ok(hr
== E_NOINTERFACE
, "Test %u: Texture should not implement ID3D10Texture1D.\n", i
);
2503 if (SUCCEEDED(hr
)) ID3D10Texture1D_Release(d3d10_texture
);
2507 ID3D10Texture1D_GetDesc(d3d10_texture
, &d3d10_desc
);
2509 ok(d3d10_desc
.Width
== desc
.Width
,
2510 "Test %u: Got unexpected Width %u.\n", i
, d3d10_desc
.Width
);
2511 ok(d3d10_desc
.MipLevels
== desc
.MipLevels
,
2512 "Test %u: Got unexpected MipLevels %u.\n", i
, d3d10_desc
.MipLevels
);
2513 ok(d3d10_desc
.ArraySize
== desc
.ArraySize
,
2514 "Test %u: Got unexpected ArraySize %u.\n", i
, d3d10_desc
.ArraySize
);
2515 ok(d3d10_desc
.Format
== desc
.Format
,
2516 "Test %u: Got unexpected Format %u.\n", i
, d3d10_desc
.Format
);
2517 ok(d3d10_desc
.BindFlags
== current
->expected_bind_flags
,
2518 "Test %u: Got unexpected BindFlags %#x.\n", i
, d3d10_desc
.BindFlags
);
2519 ok(d3d10_desc
.CPUAccessFlags
== desc
.CPUAccessFlags
,
2520 "Test %u: Got unexpected CPUAccessFlags %#x.\n", i
, d3d10_desc
.CPUAccessFlags
);
2521 ok(d3d10_desc
.MiscFlags
== current
->expected_misc_flags
,
2522 "Test %u: Got unexpected MiscFlags %#x.\n", i
, d3d10_desc
.MiscFlags
);
2524 d3d10_device
= (ID3D10Device
*)0xdeadbeef;
2525 ID3D10Texture1D_GetDevice(d3d10_texture
, &d3d10_device
);
2526 ok(!d3d10_device
, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i
, d3d10_device
);
2527 if (d3d10_device
) ID3D10Device_Release(d3d10_device
);
2529 ID3D10Texture1D_Release(d3d10_texture
);
2532 refcount
= ID3D11Device_Release(device
);
2533 ok(!refcount
, "Device has %u references left.\n", refcount
);
2536 static void test_create_texture2d(void)
2538 ULONG refcount
, expected_refcount
;
2539 D3D11_SUBRESOURCE_DATA data
= {0};
2540 D3D_FEATURE_LEVEL feature_level
;
2541 ID3D11Device
*device
, *tmp
;
2542 D3D11_TEXTURE2D_DESC desc
;
2543 ID3D11Texture2D
*texture
;
2544 UINT quality_level_count
;
2552 D3D11_BIND_FLAG bind_flags
;
2559 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 1, D3D11_BIND_VERTEX_BUFFER
, 0, FALSE
, TRUE
},
2560 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 1, D3D11_BIND_INDEX_BUFFER
, 0, FALSE
, TRUE
},
2561 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 1, D3D11_BIND_CONSTANT_BUFFER
, 0, FALSE
, TRUE
},
2562 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 0, D3D11_BIND_SHADER_RESOURCE
, 0, FALSE
, FALSE
},
2563 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2564 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 2, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2565 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 3, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2566 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 3, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_TEXTURECUBE
,
2568 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_TEXTURECUBE
,
2570 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 5, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_TEXTURECUBE
,
2572 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 6, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_TEXTURECUBE
,
2574 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 7, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_TEXTURECUBE
,
2576 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 10, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_TEXTURECUBE
,
2578 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 12, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_TEXTURECUBE
,
2580 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 0, D3D11_BIND_RENDER_TARGET
, 0, FALSE
, FALSE
},
2581 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2582 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 2, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2583 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 9, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2584 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 1, D3D11_BIND_DEPTH_STENCIL
, 0, FALSE
, FALSE
},
2585 {DXGI_FORMAT_R32G32B32A32_UINT
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2586 {DXGI_FORMAT_R32G32B32A32_SINT
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2587 {DXGI_FORMAT_R32G32B32_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2588 {DXGI_FORMAT_R16G16B16A16_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2589 {DXGI_FORMAT_R16G16B16A16_TYPELESS
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2590 {DXGI_FORMAT_R32G32_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2591 {DXGI_FORMAT_R32G8X24_TYPELESS
, 1, D3D11_BIND_DEPTH_STENCIL
, 0, TRUE
, FALSE
},
2592 {DXGI_FORMAT_R32G8X24_TYPELESS
, 1, D3D11_BIND_UNORDERED_ACCESS
, 0, FALSE
, TRUE
},
2593 {DXGI_FORMAT_X32_TYPELESS_G8X24_UINT
, 1, D3D11_BIND_UNORDERED_ACCESS
, 0, FALSE
, TRUE
},
2594 {DXGI_FORMAT_R10G10B10A2_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2595 {DXGI_FORMAT_R10G10B10A2_TYPELESS
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2596 {DXGI_FORMAT_R16G16_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2597 {DXGI_FORMAT_R16G16_UNORM
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2598 {DXGI_FORMAT_R16G16_SNORM
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2599 {DXGI_FORMAT_R32_TYPELESS
, 0, D3D11_BIND_SHADER_RESOURCE
, 0, FALSE
, FALSE
},
2600 {DXGI_FORMAT_R32_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2601 {DXGI_FORMAT_R32_TYPELESS
, 9, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2602 {DXGI_FORMAT_R32_TYPELESS
, 9, D3D11_BIND_SHADER_RESOURCE
| D3D11_BIND_DEPTH_STENCIL
, 0,
2604 {DXGI_FORMAT_R32_TYPELESS
, 9, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_TEXTURECUBE
,
2606 {DXGI_FORMAT_R32_TYPELESS
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2607 {DXGI_FORMAT_R32_TYPELESS
, 1, D3D11_BIND_RENDER_TARGET
| D3D11_BIND_DEPTH_STENCIL
, 0,
2609 {DXGI_FORMAT_R32_TYPELESS
, 1, D3D11_BIND_DEPTH_STENCIL
, 0, TRUE
, FALSE
},
2610 {DXGI_FORMAT_R32_TYPELESS
, 1, D3D11_BIND_DEPTH_STENCIL
| D3D11_BIND_UNORDERED_ACCESS
, 0,
2612 {DXGI_FORMAT_R24G8_TYPELESS
, 1, D3D11_BIND_VERTEX_BUFFER
, 0, FALSE
, TRUE
},
2613 {DXGI_FORMAT_R24G8_TYPELESS
, 1, D3D11_BIND_INDEX_BUFFER
, 0, FALSE
, TRUE
},
2614 {DXGI_FORMAT_R24G8_TYPELESS
, 1, D3D11_BIND_CONSTANT_BUFFER
, 0, FALSE
, TRUE
},
2615 {DXGI_FORMAT_R24G8_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2616 {DXGI_FORMAT_R24G8_TYPELESS
, 1, D3D11_BIND_DEPTH_STENCIL
, 0, TRUE
, FALSE
},
2617 {DXGI_FORMAT_R24G8_TYPELESS
, 1, D3D11_BIND_UNORDERED_ACCESS
, 0, FALSE
, TRUE
},
2618 {DXGI_FORMAT_X24_TYPELESS_G8_UINT
, 1, D3D11_BIND_UNORDERED_ACCESS
, 0, FALSE
, TRUE
},
2619 {DXGI_FORMAT_R8G8_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2620 {DXGI_FORMAT_R8G8_TYPELESS
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2621 {DXGI_FORMAT_R8G8_UNORM
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2622 {DXGI_FORMAT_R8G8_SNORM
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2623 {DXGI_FORMAT_R16_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2624 {DXGI_FORMAT_R16_TYPELESS
, 1, D3D11_BIND_DEPTH_STENCIL
, 0, TRUE
, FALSE
},
2625 {DXGI_FORMAT_R16_TYPELESS
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2626 {DXGI_FORMAT_R16_UINT
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2627 {DXGI_FORMAT_R16_SINT
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2628 {DXGI_FORMAT_R8_TYPELESS
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2629 {DXGI_FORMAT_R8G8B8A8_UNORM
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2630 {DXGI_FORMAT_R8G8B8A8_UNORM
, 1, D3D11_BIND_DEPTH_STENCIL
, 0, FALSE
, FALSE
},
2631 {DXGI_FORMAT_R8G8B8A8_UINT
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2632 {DXGI_FORMAT_R8G8B8A8_SNORM
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2633 {DXGI_FORMAT_R8G8B8A8_SINT
, 1, D3D11_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
2634 {DXGI_FORMAT_D24_UNORM_S8_UINT
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, FALSE
, TRUE
},
2635 {DXGI_FORMAT_D24_UNORM_S8_UINT
, 1, D3D11_BIND_RENDER_TARGET
, 0, FALSE
, FALSE
},
2636 {DXGI_FORMAT_D32_FLOAT
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, FALSE
, TRUE
},
2637 {DXGI_FORMAT_D32_FLOAT
, 1, D3D11_BIND_SHADER_RESOURCE
| D3D11_BIND_DEPTH_STENCIL
, 0,
2639 {DXGI_FORMAT_D32_FLOAT
, 1, D3D11_BIND_RENDER_TARGET
, 0, FALSE
, FALSE
},
2640 {DXGI_FORMAT_D32_FLOAT
, 1, D3D11_BIND_DEPTH_STENCIL
, 0, TRUE
, FALSE
},
2641 {DXGI_FORMAT_R9G9B9E5_SHAREDEXP
, 1, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
2642 {DXGI_FORMAT_R9G9B9E5_SHAREDEXP
, 1, D3D11_BIND_RENDER_TARGET
, 0, FALSE
, FALSE
},
2643 {DXGI_FORMAT_R9G9B9E5_SHAREDEXP
, 1, D3D11_BIND_DEPTH_STENCIL
, 0, FALSE
, FALSE
},
2646 if (!(device
= create_device(NULL
)))
2648 skip("Failed to create device.\n");
2652 feature_level
= ID3D11Device_GetFeatureLevel(device
);
2658 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
2659 desc
.SampleDesc
.Count
= 1;
2660 desc
.SampleDesc
.Quality
= 0;
2661 desc
.Usage
= D3D11_USAGE_DEFAULT
;
2662 desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
2663 desc
.CPUAccessFlags
= 0;
2666 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, &data
, &texture
);
2667 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
2669 expected_refcount
= get_refcount(device
) + 1;
2670 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
2671 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
2672 refcount
= get_refcount(device
);
2673 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2675 expected_refcount
= refcount
+ 1;
2676 ID3D11Texture2D_GetDevice(texture
, &tmp
);
2677 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2678 refcount
= get_refcount(device
);
2679 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2680 ID3D11Device_Release(tmp
);
2682 check_interface(texture
, &IID_IDXGISurface
, TRUE
, FALSE
);
2683 ID3D11Texture2D_Release(texture
);
2686 expected_refcount
= get_refcount(device
) + 1;
2687 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
2688 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
2689 refcount
= get_refcount(device
);
2690 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2692 expected_refcount
= refcount
+ 1;
2693 ID3D11Texture2D_GetDevice(texture
, &tmp
);
2694 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2695 refcount
= get_refcount(device
);
2696 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2697 ID3D11Device_Release(tmp
);
2699 ID3D11Texture2D_GetDesc(texture
, &desc
);
2700 ok(desc
.Width
== 512, "Got unexpected Width %u.\n", desc
.Width
);
2701 ok(desc
.Height
== 512, "Got unexpected Height %u.\n", desc
.Height
);
2702 ok(desc
.MipLevels
== 10, "Got unexpected MipLevels %u.\n", desc
.MipLevels
);
2703 ok(desc
.ArraySize
== 1, "Got unexpected ArraySize %u.\n", desc
.ArraySize
);
2704 ok(desc
.Format
== DXGI_FORMAT_R8G8B8A8_UNORM
, "Got unexpected Format %#x.\n", desc
.Format
);
2705 ok(desc
.SampleDesc
.Count
== 1, "Got unexpected SampleDesc.Count %u.\n", desc
.SampleDesc
.Count
);
2706 ok(desc
.SampleDesc
.Quality
== 0, "Got unexpected SampleDesc.Quality %u.\n", desc
.SampleDesc
.Quality
);
2707 ok(desc
.Usage
== D3D11_USAGE_DEFAULT
, "Got unexpected Usage %u.\n", desc
.Usage
);
2708 ok(desc
.BindFlags
== D3D11_BIND_RENDER_TARGET
, "Got unexpected BindFlags %#x.\n", desc
.BindFlags
);
2709 ok(desc
.CPUAccessFlags
== 0, "Got unexpected CPUAccessFlags %#x.\n", desc
.CPUAccessFlags
);
2710 ok(desc
.MiscFlags
== 0, "Got unexpected MiscFlags %#x.\n", desc
.MiscFlags
);
2712 check_interface(texture
, &IID_IDXGISurface
, FALSE
, FALSE
);
2713 ID3D11Texture2D_Release(texture
);
2717 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
2718 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
2720 check_interface(texture
, &IID_IDXGISurface
, FALSE
, FALSE
);
2721 ID3D11Texture2D_Release(texture
);
2723 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 2, &quality_level_count
);
2724 ok(hr
== S_OK
, "Failed to check multisample quality levels, hr %#x.\n", hr
);
2726 desc
.SampleDesc
.Count
= 2;
2727 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
2728 if (quality_level_count
)
2730 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
2731 ID3D11Texture2D_Release(texture
);
2732 desc
.SampleDesc
.Quality
= quality_level_count
;
2733 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
2735 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
2737 /* We assume 15 samples multisampling is never supported in practice. */
2738 desc
.SampleDesc
.Count
= 15;
2739 desc
.SampleDesc
.Quality
= 0;
2740 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
2741 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
2743 desc
.SampleDesc
.Count
= 1;
2744 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
2746 HRESULT expected_hr
= tests
[i
].succeeds
? S_OK
: E_INVALIDARG
;
2747 BOOL todo
= tests
[i
].todo
;
2749 if (feature_level
< D3D_FEATURE_LEVEL_10_1
2750 && (tests
[i
].misc_flags
& D3D11_RESOURCE_MISC_TEXTURECUBE
)
2751 && tests
[i
].array_size
> 6)
2753 expected_hr
= E_INVALIDARG
;
2757 desc
.ArraySize
= tests
[i
].array_size
;
2758 desc
.Format
= tests
[i
].format
;
2759 desc
.BindFlags
= tests
[i
].bind_flags
;
2760 desc
.MiscFlags
= tests
[i
].misc_flags
;
2761 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
2764 ok(hr
== expected_hr
, "Test %u: Got unexpected hr %#x (format %#x).\n",
2765 i
, hr
, desc
.Format
);
2768 ID3D11Texture2D_Release(texture
);
2771 refcount
= ID3D11Device_Release(device
);
2772 ok(!refcount
, "Device has %u references left.\n", refcount
);
2775 static void test_texture2d_interfaces(void)
2777 ID3D10Texture2D
*d3d10_texture
;
2778 D3D11_TEXTURE2D_DESC desc
;
2779 ID3D11Texture2D
*texture
;
2780 ID3D11Device
*device
;
2785 static const struct test
2787 BOOL implements_d3d10_interfaces
;
2790 UINT expected_bind_flags
;
2791 UINT expected_misc_flags
;
2793 desc_conversion_tests
[] =
2797 D3D11_BIND_SHADER_RESOURCE
, 0,
2798 D3D10_BIND_SHADER_RESOURCE
, 0
2802 D3D11_BIND_UNORDERED_ACCESS
, 0,
2803 D3D11_BIND_UNORDERED_ACCESS
, 0
2807 0, D3D11_RESOURCE_MISC_RESOURCE_CLAMP
,
2812 0, D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX
,
2813 0, D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX
2817 0, D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX
| D3D11_RESOURCE_MISC_SHARED_NTHANDLE
,
2818 0, D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX
2822 if (!(device
= create_device(NULL
)))
2824 skip("Failed to create ID3D11Device, skipping tests.\n");
2832 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
2833 desc
.SampleDesc
.Count
= 1;
2834 desc
.SampleDesc
.Quality
= 0;
2835 desc
.Usage
= D3D11_USAGE_DEFAULT
;
2836 desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
2837 desc
.CPUAccessFlags
= 0;
2840 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
2841 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
2842 check_interface(texture
, &IID_IDXGISurface
, FALSE
, FALSE
);
2843 hr
= check_interface(texture
, &IID_ID3D10Texture2D
, TRUE
, TRUE
); /* Not available on all Windows versions. */
2844 ID3D11Texture2D_Release(texture
);
2847 win_skip("2D textures do not implement ID3D10Texture2D, skipping tests.\n");
2848 ID3D11Device_Release(device
);
2852 for (i
= 0; i
< ARRAY_SIZE(desc_conversion_tests
); ++i
)
2854 const struct test
*current
= &desc_conversion_tests
[i
];
2855 D3D10_TEXTURE2D_DESC d3d10_desc
;
2856 ID3D10Device
*d3d10_device
;
2862 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
2863 desc
.SampleDesc
.Count
= 1;
2864 desc
.SampleDesc
.Quality
= 0;
2865 desc
.Usage
= D3D11_USAGE_DEFAULT
;
2866 desc
.BindFlags
= current
->bind_flags
;
2867 desc
.CPUAccessFlags
= 0;
2868 desc
.MiscFlags
= current
->misc_flags
;
2870 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
2871 /* Shared resources are not supported by REF and WARP devices. */
2872 ok(SUCCEEDED(hr
) || broken(hr
== E_OUTOFMEMORY
),
2873 "Test %u: Failed to create a 2d texture, hr %#x.\n", i
, hr
);
2876 win_skip("Failed to create ID3D11Texture2D, skipping test %u.\n", i
);
2880 check_interface(texture
, &IID_IDXGISurface
, TRUE
, FALSE
);
2882 hr
= ID3D11Texture2D_QueryInterface(texture
, &IID_ID3D10Texture2D
, (void **)&d3d10_texture
);
2883 ID3D11Texture2D_Release(texture
);
2885 if (current
->implements_d3d10_interfaces
)
2887 ok(SUCCEEDED(hr
), "Test %u: Texture should implement ID3D10Texture2D.\n", i
);
2891 todo_wine
ok(hr
== E_NOINTERFACE
, "Test %u: Texture should not implement ID3D10Texture2D.\n", i
);
2892 if (SUCCEEDED(hr
)) ID3D10Texture2D_Release(d3d10_texture
);
2896 ID3D10Texture2D_GetDesc(d3d10_texture
, &d3d10_desc
);
2898 ok(d3d10_desc
.Width
== desc
.Width
,
2899 "Test %u: Got unexpected Width %u.\n", i
, d3d10_desc
.Width
);
2900 ok(d3d10_desc
.Height
== desc
.Height
,
2901 "Test %u: Got unexpected Height %u.\n", i
, d3d10_desc
.Height
);
2902 ok(d3d10_desc
.MipLevels
== desc
.MipLevels
,
2903 "Test %u: Got unexpected MipLevels %u.\n", i
, d3d10_desc
.MipLevels
);
2904 ok(d3d10_desc
.ArraySize
== desc
.ArraySize
,
2905 "Test %u: Got unexpected ArraySize %u.\n", i
, d3d10_desc
.ArraySize
);
2906 ok(d3d10_desc
.Format
== desc
.Format
,
2907 "Test %u: Got unexpected Format %u.\n", i
, d3d10_desc
.Format
);
2908 ok(d3d10_desc
.SampleDesc
.Count
== desc
.SampleDesc
.Count
,
2909 "Test %u: Got unexpected SampleDesc.Count %u.\n", i
, d3d10_desc
.SampleDesc
.Count
);
2910 ok(d3d10_desc
.SampleDesc
.Quality
== desc
.SampleDesc
.Quality
,
2911 "Test %u: Got unexpected SampleDesc.Quality %u.\n", i
, d3d10_desc
.SampleDesc
.Quality
);
2912 ok(d3d10_desc
.Usage
== (D3D10_USAGE
)desc
.Usage
,
2913 "Test %u: Got unexpected Usage %u.\n", i
, d3d10_desc
.Usage
);
2914 ok(d3d10_desc
.BindFlags
== current
->expected_bind_flags
,
2915 "Test %u: Got unexpected BindFlags %#x.\n", i
, d3d10_desc
.BindFlags
);
2916 ok(d3d10_desc
.CPUAccessFlags
== desc
.CPUAccessFlags
,
2917 "Test %u: Got unexpected CPUAccessFlags %#x.\n", i
, d3d10_desc
.CPUAccessFlags
);
2918 ok(d3d10_desc
.MiscFlags
== current
->expected_misc_flags
,
2919 "Test %u: Got unexpected MiscFlags %#x.\n", i
, d3d10_desc
.MiscFlags
);
2921 d3d10_device
= (ID3D10Device
*)0xdeadbeef;
2922 ID3D10Texture2D_GetDevice(d3d10_texture
, &d3d10_device
);
2923 ok(!d3d10_device
, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i
, d3d10_device
);
2924 if (d3d10_device
) ID3D10Device_Release(d3d10_device
);
2926 ID3D10Texture2D_Release(d3d10_texture
);
2929 refcount
= ID3D11Device_Release(device
);
2930 ok(!refcount
, "Device has %u references left.\n", refcount
);
2933 static void test_create_texture3d(void)
2935 ULONG refcount
, expected_refcount
;
2936 D3D11_SUBRESOURCE_DATA data
= {0};
2937 ID3D11Device
*device
, *tmp
;
2938 D3D11_TEXTURE3D_DESC desc
;
2939 ID3D11Texture3D
*texture
;
2946 D3D11_BIND_FLAG bind_flags
;
2952 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, D3D11_BIND_VERTEX_BUFFER
, FALSE
, TRUE
},
2953 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, D3D11_BIND_INDEX_BUFFER
, FALSE
, TRUE
},
2954 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, D3D11_BIND_CONSTANT_BUFFER
, FALSE
, TRUE
},
2955 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, D3D11_BIND_SHADER_RESOURCE
, TRUE
, FALSE
},
2956 {DXGI_FORMAT_R16G16B16A16_TYPELESS
, D3D11_BIND_SHADER_RESOURCE
, TRUE
, FALSE
},
2957 {DXGI_FORMAT_R10G10B10A2_TYPELESS
, D3D11_BIND_SHADER_RESOURCE
, TRUE
, FALSE
},
2958 {DXGI_FORMAT_R8G8B8A8_UNORM
, D3D11_BIND_DEPTH_STENCIL
, FALSE
, FALSE
},
2959 {DXGI_FORMAT_D24_UNORM_S8_UINT
, D3D11_BIND_RENDER_TARGET
, FALSE
, FALSE
},
2960 {DXGI_FORMAT_D32_FLOAT
, D3D11_BIND_RENDER_TARGET
, FALSE
, FALSE
},
2961 {DXGI_FORMAT_R9G9B9E5_SHAREDEXP
, D3D11_BIND_SHADER_RESOURCE
, TRUE
, FALSE
},
2962 {DXGI_FORMAT_R9G9B9E5_SHAREDEXP
, D3D11_BIND_RENDER_TARGET
, FALSE
, FALSE
},
2963 {DXGI_FORMAT_R9G9B9E5_SHAREDEXP
, D3D11_BIND_DEPTH_STENCIL
, FALSE
, FALSE
},
2966 if (!(device
= create_device(NULL
)))
2968 skip("Failed to create ID3D11Device, skipping tests.\n");
2976 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
2977 desc
.Usage
= D3D11_USAGE_DEFAULT
;
2978 desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
2979 desc
.CPUAccessFlags
= 0;
2982 hr
= ID3D11Device_CreateTexture3D(device
, &desc
, &data
, &texture
);
2983 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
2985 expected_refcount
= get_refcount(device
) + 1;
2986 hr
= ID3D11Device_CreateTexture3D(device
, &desc
, NULL
, &texture
);
2987 ok(SUCCEEDED(hr
), "Failed to create a 3d texture, hr %#x.\n", hr
);
2988 refcount
= get_refcount(device
);
2989 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2991 expected_refcount
= refcount
+ 1;
2992 ID3D11Texture3D_GetDevice(texture
, &tmp
);
2993 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2994 refcount
= get_refcount(device
);
2995 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2996 ID3D11Device_Release(tmp
);
2998 check_interface(texture
, &IID_IDXGISurface
, FALSE
, FALSE
);
2999 ID3D11Texture3D_Release(texture
);
3002 expected_refcount
= get_refcount(device
) + 1;
3003 hr
= ID3D11Device_CreateTexture3D(device
, &desc
, NULL
, &texture
);
3004 ok(SUCCEEDED(hr
), "Failed to create a 3d texture, hr %#x.\n", hr
);
3005 refcount
= get_refcount(device
);
3006 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
3008 expected_refcount
= refcount
+ 1;
3009 ID3D11Texture3D_GetDevice(texture
, &tmp
);
3010 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
3011 refcount
= get_refcount(device
);
3012 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
3013 ID3D11Device_Release(tmp
);
3015 ID3D11Texture3D_GetDesc(texture
, &desc
);
3016 ok(desc
.Width
== 64, "Got unexpected Width %u.\n", desc
.Width
);
3017 ok(desc
.Height
== 64, "Got unexpected Height %u.\n", desc
.Height
);
3018 ok(desc
.Depth
== 64, "Got unexpected Depth %u.\n", desc
.Depth
);
3019 ok(desc
.MipLevels
== 7, "Got unexpected MipLevels %u.\n", desc
.MipLevels
);
3020 ok(desc
.Format
== DXGI_FORMAT_R8G8B8A8_UNORM
, "Got unexpected Format %#x.\n", desc
.Format
);
3021 ok(desc
.Usage
== D3D11_USAGE_DEFAULT
, "Got unexpected Usage %u.\n", desc
.Usage
);
3022 ok(desc
.BindFlags
== D3D11_BIND_RENDER_TARGET
, "Got unexpected BindFlags %u.\n", desc
.BindFlags
);
3023 ok(desc
.CPUAccessFlags
== 0, "Got unexpected CPUAccessFlags %u.\n", desc
.CPUAccessFlags
);
3024 ok(desc
.MiscFlags
== 0, "Got unexpected MiscFlags %u.\n", desc
.MiscFlags
);
3026 check_interface(texture
, &IID_IDXGISurface
, FALSE
, FALSE
);
3027 ID3D11Texture3D_Release(texture
);
3030 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
3032 desc
.Format
= tests
[i
].format
;
3033 desc
.BindFlags
= tests
[i
].bind_flags
;
3034 hr
= ID3D11Device_CreateTexture3D(device
, &desc
, NULL
, &texture
);
3036 todo_wine_if(tests
[i
].todo
)
3037 ok(hr
== (tests
[i
].succeeds
? S_OK
: E_INVALIDARG
), "Test %u: Got unexpected hr %#x.\n", i
, hr
);
3040 ID3D11Texture3D_Release(texture
);
3043 refcount
= ID3D11Device_Release(device
);
3044 ok(!refcount
, "Device has %u references left.\n", refcount
);
3047 static void test_texture3d_interfaces(void)
3049 ID3D10Texture3D
*d3d10_texture
;
3050 D3D11_TEXTURE3D_DESC desc
;
3051 ID3D11Texture3D
*texture
;
3052 ID3D11Device
*device
;
3057 static const struct test
3059 BOOL implements_d3d10_interfaces
;
3062 UINT expected_bind_flags
;
3063 UINT expected_misc_flags
;
3065 desc_conversion_tests
[] =
3069 D3D11_BIND_SHADER_RESOURCE
, 0,
3070 D3D10_BIND_SHADER_RESOURCE
, 0
3074 D3D11_BIND_UNORDERED_ACCESS
, 0,
3075 D3D11_BIND_UNORDERED_ACCESS
, 0
3079 0, D3D11_RESOURCE_MISC_RESOURCE_CLAMP
,
3084 0, D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX
,
3085 0, D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX
3089 if (!(device
= create_device(NULL
)))
3091 skip("Failed to create ID3D11Device.\n");
3099 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
3100 desc
.Usage
= D3D11_USAGE_DEFAULT
;
3101 desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
3102 desc
.CPUAccessFlags
= 0;
3105 hr
= ID3D11Device_CreateTexture3D(device
, &desc
, NULL
, &texture
);
3106 ok(SUCCEEDED(hr
), "Failed to create a 3d texture, hr %#x.\n", hr
);
3107 check_interface(texture
, &IID_IDXGISurface
, FALSE
, FALSE
);
3108 hr
= check_interface(texture
, &IID_ID3D10Texture3D
, TRUE
, TRUE
); /* Not available on all Windows versions. */
3109 ID3D11Texture3D_Release(texture
);
3112 win_skip("3D textures do not implement ID3D10Texture3D.\n");
3113 ID3D11Device_Release(device
);
3117 for (i
= 0; i
< ARRAY_SIZE(desc_conversion_tests
); ++i
)
3119 const struct test
*current
= &desc_conversion_tests
[i
];
3120 D3D10_TEXTURE3D_DESC d3d10_desc
;
3121 ID3D10Device
*d3d10_device
;
3127 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
3128 desc
.Usage
= D3D11_USAGE_DEFAULT
;
3129 desc
.BindFlags
= current
->bind_flags
;
3130 desc
.CPUAccessFlags
= 0;
3131 desc
.MiscFlags
= current
->misc_flags
;
3133 hr
= ID3D11Device_CreateTexture3D(device
, &desc
, NULL
, &texture
);
3134 /* Shared resources are not supported by REF and WARP devices. */
3135 ok(SUCCEEDED(hr
) || broken(hr
== E_OUTOFMEMORY
),
3136 "Test %u: Failed to create a 3d texture, hr %#x.\n", i
, hr
);
3139 win_skip("Failed to create ID3D11Texture3D, skipping test %u.\n", i
);
3143 check_interface(texture
, &IID_IDXGISurface
, FALSE
, FALSE
);
3145 hr
= ID3D11Texture3D_QueryInterface(texture
, &IID_ID3D10Texture3D
, (void **)&d3d10_texture
);
3146 ID3D11Texture3D_Release(texture
);
3148 if (current
->implements_d3d10_interfaces
)
3150 ok(SUCCEEDED(hr
), "Test %u: Texture should implement ID3D10Texture3D.\n", i
);
3154 todo_wine
ok(hr
== E_NOINTERFACE
, "Test %u: Texture should not implement ID3D10Texture3D.\n", i
);
3155 if (SUCCEEDED(hr
)) ID3D10Texture3D_Release(d3d10_texture
);
3159 ID3D10Texture3D_GetDesc(d3d10_texture
, &d3d10_desc
);
3161 ok(d3d10_desc
.Width
== desc
.Width
,
3162 "Test %u: Got unexpected Width %u.\n", i
, d3d10_desc
.Width
);
3163 ok(d3d10_desc
.Height
== desc
.Height
,
3164 "Test %u: Got unexpected Height %u.\n", i
, d3d10_desc
.Height
);
3165 ok(d3d10_desc
.Depth
== desc
.Depth
,
3166 "Test %u: Got unexpected Depth %u.\n", i
, d3d10_desc
.Depth
);
3167 ok(d3d10_desc
.MipLevels
== desc
.MipLevels
,
3168 "Test %u: Got unexpected MipLevels %u.\n", i
, d3d10_desc
.MipLevels
);
3169 ok(d3d10_desc
.Format
== desc
.Format
,
3170 "Test %u: Got unexpected Format %u.\n", i
, d3d10_desc
.Format
);
3171 ok(d3d10_desc
.Usage
== (D3D10_USAGE
)desc
.Usage
,
3172 "Test %u: Got unexpected Usage %u.\n", i
, d3d10_desc
.Usage
);
3173 ok(d3d10_desc
.BindFlags
== current
->expected_bind_flags
,
3174 "Test %u: Got unexpected BindFlags %#x.\n", i
, d3d10_desc
.BindFlags
);
3175 ok(d3d10_desc
.CPUAccessFlags
== desc
.CPUAccessFlags
,
3176 "Test %u: Got unexpected CPUAccessFlags %#x.\n", i
, d3d10_desc
.CPUAccessFlags
);
3177 ok(d3d10_desc
.MiscFlags
== current
->expected_misc_flags
,
3178 "Test %u: Got unexpected MiscFlags %#x.\n", i
, d3d10_desc
.MiscFlags
);
3180 d3d10_device
= (ID3D10Device
*)0xdeadbeef;
3181 ID3D10Texture3D_GetDevice(d3d10_texture
, &d3d10_device
);
3182 ok(!d3d10_device
, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i
, d3d10_device
);
3183 if (d3d10_device
) ID3D10Device_Release(d3d10_device
);
3185 ID3D10Texture3D_Release(d3d10_texture
);
3188 refcount
= ID3D11Device_Release(device
);
3189 ok(!refcount
, "Device has %u references left.\n", refcount
);
3192 static void test_create_buffer(void)
3194 ID3D10Buffer
*d3d10_buffer
;
3195 HRESULT expected_hr
, hr
;
3196 D3D11_BUFFER_DESC desc
;
3197 ID3D11Buffer
*buffer
;
3198 ID3D11Device
*device
;
3202 static const struct test
3205 BOOL implements_d3d10_interfaces
;
3208 UINT structure_stride
;
3209 UINT expected_bind_flags
;
3210 UINT expected_misc_flags
;
3216 D3D11_BIND_VERTEX_BUFFER
, 0, 0,
3217 D3D10_BIND_VERTEX_BUFFER
, 0
3221 D3D11_BIND_INDEX_BUFFER
, 0, 0,
3222 D3D10_BIND_INDEX_BUFFER
, 0
3226 D3D11_BIND_CONSTANT_BUFFER
, 0, 0,
3227 D3D10_BIND_CONSTANT_BUFFER
, 0
3231 D3D11_BIND_SHADER_RESOURCE
, 0, 0,
3232 D3D10_BIND_SHADER_RESOURCE
, 0
3236 D3D11_BIND_STREAM_OUTPUT
, 0, 0,
3237 D3D10_BIND_STREAM_OUTPUT
, 0
3241 D3D11_BIND_RENDER_TARGET
, 0, 0,
3242 D3D10_BIND_RENDER_TARGET
, 0
3246 D3D11_BIND_UNORDERED_ACCESS
, 0, 0,
3247 D3D11_BIND_UNORDERED_ACCESS
, 0
3251 0, D3D11_RESOURCE_MISC_SHARED
, 0,
3252 0, D3D10_RESOURCE_MISC_SHARED
3256 0, D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS
, 0,
3261 D3D11_BIND_VERTEX_BUFFER
, D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
, 0,
3265 D3D11_BIND_INDEX_BUFFER
, D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
, 0,
3269 D3D11_BIND_CONSTANT_BUFFER
, D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
, 0,
3273 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
, 0,
3274 D3D10_BIND_SHADER_RESOURCE
, 0
3278 D3D11_BIND_STREAM_OUTPUT
, D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
, 0,
3282 D3D11_BIND_RENDER_TARGET
, D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
, 0,
3286 D3D11_BIND_UNORDERED_ACCESS
, D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
, 0,
3287 D3D11_BIND_UNORDERED_ACCESS
, 0
3291 0, D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
, 0,
3293 /* Structured buffers do not implement ID3D10Buffer. */
3296 0, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 16,
3300 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 16,
3304 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, ~0u,
3308 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 0,
3312 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 1,
3316 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 2,
3320 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 3,
3324 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 4,
3328 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 5,
3332 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 8,
3336 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 512,
3340 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 513,
3344 D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 1024,
3353 D3D11_BIND_CONSTANT_BUFFER
, 0, 513,
3354 D3D10_BIND_CONSTANT_BUFFER
, 0
3358 D3D11_BIND_SHADER_RESOURCE
, 0, 513,
3359 D3D10_BIND_SHADER_RESOURCE
, 0
3363 D3D11_BIND_UNORDERED_ACCESS
, 0, 513,
3364 D3D11_BIND_UNORDERED_ACCESS
, 0
3368 0, D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
| D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 16,
3372 D3D11_BIND_SHADER_RESOURCE
,
3373 D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
| D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
, 16,
3377 0, D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX
, 0,
3378 0, D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX
3382 if (!(device
= create_device(NULL
)))
3384 skip("Failed to create ID3D11Device.\n");
3388 buffer
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, 1024, NULL
);
3389 hr
= check_interface(buffer
, &IID_ID3D10Buffer
, TRUE
, TRUE
); /* Not available on all Windows versions. */
3390 ID3D11Buffer_Release(buffer
);
3393 win_skip("Buffers do not implement ID3D10Buffer.\n");
3394 ID3D11Device_Release(device
);
3398 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
3400 const struct test
*current
= &tests
[i
];
3401 D3D11_BUFFER_DESC obtained_desc
;
3402 D3D10_BUFFER_DESC d3d10_desc
;
3403 ID3D10Device
*d3d10_device
;
3405 desc
.ByteWidth
= 1024;
3406 desc
.Usage
= D3D11_USAGE_DEFAULT
;
3407 desc
.BindFlags
= current
->bind_flags
;
3408 desc
.CPUAccessFlags
= 0;
3409 desc
.MiscFlags
= current
->misc_flags
;
3410 desc
.StructureByteStride
= current
->structure_stride
;
3412 hr
= ID3D11Device_CreateBuffer(device
, &desc
, NULL
, &buffer
);
3413 expected_hr
= current
->succeeds
? S_OK
: E_INVALIDARG
;
3414 /* Shared resources are not supported by REF and WARP devices. */
3415 ok(hr
== expected_hr
|| broken(hr
== E_OUTOFMEMORY
), "Test %u: Got hr %#x, expected %#x.\n",
3416 i
, hr
, expected_hr
);
3419 if (hr
== E_OUTOFMEMORY
)
3420 win_skip("Failed to create a buffer, skipping test %u.\n", i
);
3424 if (!(desc
.MiscFlags
& D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
))
3425 desc
.StructureByteStride
= 0;
3427 ID3D11Buffer_GetDesc(buffer
, &obtained_desc
);
3429 ok(obtained_desc
.ByteWidth
== desc
.ByteWidth
,
3430 "Test %u: Got unexpected ByteWidth %u.\n", i
, obtained_desc
.ByteWidth
);
3431 ok(obtained_desc
.Usage
== desc
.Usage
,
3432 "Test %u: Got unexpected Usage %u.\n", i
, obtained_desc
.Usage
);
3433 ok(obtained_desc
.BindFlags
== desc
.BindFlags
,
3434 "Test %u: Got unexpected BindFlags %#x.\n", i
, obtained_desc
.BindFlags
);
3435 ok(obtained_desc
.CPUAccessFlags
== desc
.CPUAccessFlags
,
3436 "Test %u: Got unexpected CPUAccessFlags %#x.\n", i
, obtained_desc
.CPUAccessFlags
);
3437 ok(obtained_desc
.MiscFlags
== desc
.MiscFlags
,
3438 "Test %u: Got unexpected MiscFlags %#x.\n", i
, obtained_desc
.MiscFlags
);
3439 ok(obtained_desc
.StructureByteStride
== desc
.StructureByteStride
,
3440 "Test %u: Got unexpected StructureByteStride %u.\n", i
, obtained_desc
.StructureByteStride
);
3442 hr
= ID3D11Buffer_QueryInterface(buffer
, &IID_ID3D10Buffer
, (void **)&d3d10_buffer
);
3443 ID3D11Buffer_Release(buffer
);
3445 if (current
->implements_d3d10_interfaces
)
3447 ok(SUCCEEDED(hr
), "Test %u: Buffer should implement ID3D10Buffer.\n", i
);
3451 todo_wine
ok(hr
== E_NOINTERFACE
, "Test %u: Buffer should not implement ID3D10Buffer.\n", i
);
3452 if (SUCCEEDED(hr
)) ID3D10Buffer_Release(d3d10_buffer
);
3456 ID3D10Buffer_GetDesc(d3d10_buffer
, &d3d10_desc
);
3458 ok(d3d10_desc
.ByteWidth
== desc
.ByteWidth
,
3459 "Test %u: Got unexpected ByteWidth %u.\n", i
, d3d10_desc
.ByteWidth
);
3460 ok(d3d10_desc
.Usage
== (D3D10_USAGE
)desc
.Usage
,
3461 "Test %u: Got unexpected Usage %u.\n", i
, d3d10_desc
.Usage
);
3462 ok(d3d10_desc
.BindFlags
== current
->expected_bind_flags
,
3463 "Test %u: Got unexpected BindFlags %#x.\n", i
, d3d10_desc
.BindFlags
);
3464 ok(d3d10_desc
.CPUAccessFlags
== desc
.CPUAccessFlags
,
3465 "Test %u: Got unexpected CPUAccessFlags %#x.\n", i
, d3d10_desc
.CPUAccessFlags
);
3466 ok(d3d10_desc
.MiscFlags
== current
->expected_misc_flags
,
3467 "Test %u: Got unexpected MiscFlags %#x.\n", i
, d3d10_desc
.MiscFlags
);
3469 d3d10_device
= (ID3D10Device
*)0xdeadbeef;
3470 ID3D10Buffer_GetDevice(d3d10_buffer
, &d3d10_device
);
3471 ok(!d3d10_device
, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i
, d3d10_device
);
3472 if (d3d10_device
) ID3D10Device_Release(d3d10_device
);
3474 ID3D10Buffer_Release(d3d10_buffer
);
3477 memset(&desc
, 0, sizeof(desc
));
3478 desc
.BindFlags
= D3D11_BIND_CONSTANT_BUFFER
;
3479 for (i
= 0; i
<= 32; ++i
)
3482 expected_hr
= !i
|| i
% 16 ? E_INVALIDARG
: S_OK
;
3483 hr
= ID3D11Device_CreateBuffer(device
, &desc
, NULL
, &buffer
);
3484 ok(hr
== expected_hr
, "Got unexpected hr %#x for constant buffer size %u.\n", hr
, i
);
3486 ID3D11Buffer_Release(buffer
);
3489 refcount
= ID3D11Device_Release(device
);
3490 ok(!refcount
, "Device has %u references left.\n", refcount
);
3493 static void test_create_depthstencil_view(void)
3495 D3D11_DEPTH_STENCIL_VIEW_DESC dsv_desc
;
3496 D3D11_TEXTURE2D_DESC texture_desc
;
3497 ULONG refcount
, expected_refcount
;
3498 ID3D11DepthStencilView
*dsview
;
3499 ID3D11Device
*device
, *tmp
;
3500 ID3D11Texture2D
*texture
;
3504 #define FMT_UNKNOWN DXGI_FORMAT_UNKNOWN
3505 #define D24S8 DXGI_FORMAT_D24_UNORM_S8_UINT
3506 #define R24G8_TL DXGI_FORMAT_R24G8_TYPELESS
3507 #define DIM_UNKNOWN D3D11_DSV_DIMENSION_UNKNOWN
3508 #define TEX_1D D3D11_DSV_DIMENSION_TEXTURE1D
3509 #define TEX_1D_ARRAY D3D11_DSV_DIMENSION_TEXTURE1DARRAY
3510 #define TEX_2D D3D11_DSV_DIMENSION_TEXTURE2D
3511 #define TEX_2D_ARRAY D3D11_DSV_DIMENSION_TEXTURE2DARRAY
3512 #define TEX_2DMS D3D11_DSV_DIMENSION_TEXTURE2DMS
3513 #define TEX_2DMS_ARR D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY
3518 unsigned int miplevel_count
;
3519 unsigned int array_size
;
3522 struct dsv_desc dsv_desc
;
3523 struct dsv_desc expected_dsv_desc
;
3527 {{ 1, 1, D24S8
}, {0}, {D24S8
, TEX_2D
, 0}},
3528 {{10, 1, D24S8
}, {0}, {D24S8
, TEX_2D
, 0}},
3529 {{10, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2D
, 0}, {D24S8
, TEX_2D
, 0}},
3530 {{10, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2D
, 1}, {D24S8
, TEX_2D
, 1}},
3531 {{10, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2D
, 9}, {D24S8
, TEX_2D
, 9}},
3532 {{ 1, 1, R24G8_TL
}, {D24S8
, TEX_2D
, 0}, {D24S8
, TEX_2D
, 0}},
3533 {{10, 1, R24G8_TL
}, {D24S8
, TEX_2D
, 0}, {D24S8
, TEX_2D
, 0}},
3534 {{ 1, 4, D24S8
}, {0}, {D24S8
, TEX_2D_ARRAY
, 0, 0, 4}},
3535 {{10, 4, D24S8
}, {0}, {D24S8
, TEX_2D_ARRAY
, 0, 0, 4}},
3536 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 0, ~0u}, {D24S8
, TEX_2D_ARRAY
, 0, 0, 4}},
3537 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 1, 0, ~0u}, {D24S8
, TEX_2D_ARRAY
, 1, 0, 4}},
3538 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 3, 0, ~0u}, {D24S8
, TEX_2D_ARRAY
, 3, 0, 4}},
3539 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 5, 0, ~0u}, {D24S8
, TEX_2D_ARRAY
, 5, 0, 4}},
3540 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 9, 0, ~0u}, {D24S8
, TEX_2D_ARRAY
, 9, 0, 4}},
3541 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 1, ~0u}, {D24S8
, TEX_2D_ARRAY
, 0, 1, 3}},
3542 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 2, ~0u}, {D24S8
, TEX_2D_ARRAY
, 0, 2, 2}},
3543 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 3, ~0u}, {D24S8
, TEX_2D_ARRAY
, 0, 3, 1}},
3544 {{ 1, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS
}, {D24S8
, TEX_2DMS
}},
3545 {{ 1, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS
}, {D24S8
, TEX_2DMS
}},
3546 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS
}, {D24S8
, TEX_2DMS
}},
3547 {{ 1, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 1}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 1}},
3548 {{ 1, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, ~0u}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 1}},
3549 {{10, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 1}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 1}},
3550 {{10, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, ~0u}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 1}},
3551 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 1}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 1}},
3552 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 4}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 4}},
3553 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, ~0u}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 4}},
3559 unsigned int miplevel_count
;
3560 unsigned int array_size
;
3563 struct dsv_desc dsv_desc
;
3565 invalid_desc_tests
[] =
3567 {{1, 1, D24S8
}, {D24S8
, DIM_UNKNOWN
}},
3568 {{6, 4, D24S8
}, {D24S8
, DIM_UNKNOWN
}},
3569 {{1, 1, D24S8
}, {D24S8
, TEX_1D
, 0}},
3570 {{1, 1, D24S8
}, {D24S8
, TEX_1D_ARRAY
, 0, 0, 1}},
3571 {{1, 1, D24S8
}, {R24G8_TL
, TEX_2D
, 0}},
3572 {{1, 1, R24G8_TL
}, {FMT_UNKNOWN
, TEX_2D
, 0}},
3573 {{1, 1, D24S8
}, {D24S8
, TEX_2D
, 1}},
3574 {{1, 1, D24S8
}, {D24S8
, TEX_2D_ARRAY
, 0, 0, 0}},
3575 {{1, 1, D24S8
}, {D24S8
, TEX_2D_ARRAY
, 1, 0, 1}},
3576 {{1, 1, D24S8
}, {D24S8
, TEX_2D_ARRAY
, 0, 0, 2}},
3577 {{1, 1, D24S8
}, {D24S8
, TEX_2D_ARRAY
, 0, 1, 1}},
3578 {{1, 1, D24S8
}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 2}},
3579 {{1, 1, D24S8
}, {D24S8
, TEX_2DMS_ARR
, 0, 1, 1}},
3592 if (!(device
= create_device(NULL
)))
3594 skip("Failed to create device.\n");
3598 texture_desc
.Width
= 512;
3599 texture_desc
.Height
= 512;
3600 texture_desc
.MipLevels
= 1;
3601 texture_desc
.ArraySize
= 1;
3602 texture_desc
.Format
= DXGI_FORMAT_D24_UNORM_S8_UINT
;
3603 texture_desc
.SampleDesc
.Count
= 1;
3604 texture_desc
.SampleDesc
.Quality
= 0;
3605 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
3606 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
3607 texture_desc
.CPUAccessFlags
= 0;
3608 texture_desc
.MiscFlags
= 0;
3610 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
3611 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
3613 expected_refcount
= get_refcount(device
) + 1;
3614 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, NULL
, &dsview
);
3615 ok(SUCCEEDED(hr
), "Failed to create a depthstencil view, hr %#x.\n", hr
);
3616 refcount
= get_refcount(device
);
3617 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
3619 expected_refcount
= refcount
+ 1;
3620 ID3D11DepthStencilView_GetDevice(dsview
, &tmp
);
3621 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
3622 refcount
= get_refcount(device
);
3623 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
3624 ID3D11Device_Release(tmp
);
3626 memset(&dsv_desc
, 0, sizeof(dsv_desc
));
3627 ID3D11DepthStencilView_GetDesc(dsview
, &dsv_desc
);
3628 ok(dsv_desc
.Format
== texture_desc
.Format
, "Got unexpected format %#x.\n", dsv_desc
.Format
);
3629 ok(dsv_desc
.ViewDimension
== D3D11_DSV_DIMENSION_TEXTURE2D
,
3630 "Got unexpected view dimension %#x.\n", dsv_desc
.ViewDimension
);
3631 ok(!dsv_desc
.Flags
, "Got unexpected flags %#x.\n", dsv_desc
.Flags
);
3632 ok(!U(dsv_desc
).Texture2D
.MipSlice
, "Got unexpected mip slice %u.\n", U(dsv_desc
).Texture2D
.MipSlice
);
3634 ID3D11DepthStencilView_Release(dsview
);
3635 ID3D11Texture2D_Release(texture
);
3637 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
3639 D3D11_DEPTH_STENCIL_VIEW_DESC
*current_desc
;
3641 texture_desc
.MipLevels
= tests
[i
].texture
.miplevel_count
;
3642 texture_desc
.ArraySize
= tests
[i
].texture
.array_size
;
3643 texture_desc
.Format
= tests
[i
].texture
.format
;
3645 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
3646 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
3648 if (tests
[i
].dsv_desc
.dimension
== D3D11_DSV_DIMENSION_UNKNOWN
)
3650 current_desc
= NULL
;
3654 current_desc
= &dsv_desc
;
3655 get_dsv_desc(current_desc
, &tests
[i
].dsv_desc
);
3658 expected_refcount
= get_refcount(texture
);
3659 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, current_desc
, &dsview
);
3660 ok(SUCCEEDED(hr
), "Test %u: Failed to create depth stencil view, hr %#x.\n", i
, hr
);
3661 refcount
= get_refcount(texture
);
3662 ok(refcount
== expected_refcount
, "Got refcount %u, expected %u.\n", refcount
, expected_refcount
);
3664 /* Not available on all Windows versions. */
3665 check_interface(dsview
, &IID_ID3D10DepthStencilView
, TRUE
, TRUE
);
3667 memset(&dsv_desc
, 0, sizeof(dsv_desc
));
3668 ID3D11DepthStencilView_GetDesc(dsview
, &dsv_desc
);
3669 check_dsv_desc(&dsv_desc
, &tests
[i
].expected_dsv_desc
);
3671 ID3D11DepthStencilView_Release(dsview
);
3672 ID3D11Texture2D_Release(texture
);
3675 for (i
= 0; i
< ARRAY_SIZE(invalid_desc_tests
); ++i
)
3677 texture_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
3678 texture_desc
.ArraySize
= invalid_desc_tests
[i
].texture
.array_size
;
3679 texture_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
3681 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
3682 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
3684 get_dsv_desc(&dsv_desc
, &invalid_desc_tests
[i
].dsv_desc
);
3685 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, &dsv_desc
, &dsview
);
3686 ok(hr
== E_INVALIDARG
, "Test %u: Got unexpected hr %#x.\n", i
, hr
);
3688 ID3D11Texture2D_Release(texture
);
3691 refcount
= ID3D11Device_Release(device
);
3692 ok(!refcount
, "Device has %u references left.\n", refcount
);
3695 static void test_depthstencil_view_interfaces(void)
3697 D3D10_DEPTH_STENCIL_VIEW_DESC d3d10_dsv_desc
;
3698 D3D11_DEPTH_STENCIL_VIEW_DESC dsv_desc
;
3699 ID3D10DepthStencilView
*d3d10_dsview
;
3700 D3D11_TEXTURE2D_DESC texture_desc
;
3701 ID3D11DepthStencilView
*dsview
;
3702 ID3D11Texture2D
*texture
;
3703 ID3D11Device
*device
;
3707 if (!(device
= create_device(NULL
)))
3709 skip("Failed to create device.\n");
3713 texture_desc
.Width
= 512;
3714 texture_desc
.Height
= 512;
3715 texture_desc
.MipLevels
= 1;
3716 texture_desc
.ArraySize
= 1;
3717 texture_desc
.Format
= DXGI_FORMAT_D24_UNORM_S8_UINT
;
3718 texture_desc
.SampleDesc
.Count
= 1;
3719 texture_desc
.SampleDesc
.Quality
= 0;
3720 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
3721 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
3722 texture_desc
.CPUAccessFlags
= 0;
3723 texture_desc
.MiscFlags
= 0;
3725 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
3726 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
3728 dsv_desc
.Format
= texture_desc
.Format
;
3729 dsv_desc
.ViewDimension
= D3D11_DSV_DIMENSION_TEXTURE2D
;
3731 U(dsv_desc
).Texture2D
.MipSlice
= 0;
3733 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, &dsv_desc
, &dsview
);
3734 ok(SUCCEEDED(hr
), "Failed to create a depthstencil view, hr %#x.\n", hr
);
3736 hr
= ID3D11DepthStencilView_QueryInterface(dsview
, &IID_ID3D10DepthStencilView
, (void **)&d3d10_dsview
);
3737 ID3D11DepthStencilView_Release(dsview
);
3738 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
3739 "Depth stencil view should implement ID3D10DepthStencilView.\n");
3743 win_skip("Depth stencil view does not implement ID3D10DepthStencilView.\n");
3747 ID3D10DepthStencilView_GetDesc(d3d10_dsview
, &d3d10_dsv_desc
);
3748 ok(d3d10_dsv_desc
.Format
== dsv_desc
.Format
, "Got unexpected format %#x.\n", d3d10_dsv_desc
.Format
);
3749 ok(d3d10_dsv_desc
.ViewDimension
== (D3D10_DSV_DIMENSION
)dsv_desc
.ViewDimension
,
3750 "Got unexpected view dimension %u.\n", d3d10_dsv_desc
.ViewDimension
);
3751 ok(U(d3d10_dsv_desc
).Texture2D
.MipSlice
== U(dsv_desc
).Texture2D
.MipSlice
,
3752 "Got unexpected mip slice %u.\n", U(d3d10_dsv_desc
).Texture2D
.MipSlice
);
3754 ID3D10DepthStencilView_Release(d3d10_dsview
);
3757 ID3D11Texture2D_Release(texture
);
3759 refcount
= ID3D11Device_Release(device
);
3760 ok(!refcount
, "Device has %u references left.\n", refcount
);
3763 static void test_create_rendertarget_view(void)
3765 D3D11_RENDER_TARGET_VIEW_DESC rtv_desc
;
3766 D3D11_TEXTURE3D_DESC texture3d_desc
;
3767 D3D11_TEXTURE2D_DESC texture2d_desc
;
3768 D3D11_SUBRESOURCE_DATA data
= {0};
3769 ULONG refcount
, expected_refcount
;
3770 D3D11_BUFFER_DESC buffer_desc
;
3771 ID3D11RenderTargetView
*rtview
;
3772 ID3D11Device
*device
, *tmp
;
3773 ID3D11Texture3D
*texture3d
;
3774 ID3D11Texture2D
*texture2d
;
3775 ID3D11Resource
*texture
;
3776 ID3D11Buffer
*buffer
;
3780 #define FMT_UNKNOWN DXGI_FORMAT_UNKNOWN
3781 #define RGBA8_UNORM DXGI_FORMAT_R8G8B8A8_UNORM
3782 #define RGBA8_TL DXGI_FORMAT_R8G8B8A8_TYPELESS
3783 #define DIM_UNKNOWN D3D11_RTV_DIMENSION_UNKNOWN
3784 #define TEX_1D D3D11_RTV_DIMENSION_TEXTURE1D
3785 #define TEX_1D_ARRAY D3D11_RTV_DIMENSION_TEXTURE1DARRAY
3786 #define TEX_2D D3D11_RTV_DIMENSION_TEXTURE2D
3787 #define TEX_2D_ARRAY D3D11_RTV_DIMENSION_TEXTURE2DARRAY
3788 #define TEX_2DMS D3D11_RTV_DIMENSION_TEXTURE2DMS
3789 #define TEX_2DMS_ARR D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY
3790 #define TEX_3D D3D11_RTV_DIMENSION_TEXTURE3D
3795 unsigned int miplevel_count
;
3796 unsigned int depth_or_array_size
;
3799 struct rtv_desc rtv_desc
;
3800 struct rtv_desc expected_rtv_desc
;
3804 {{ 1, 1, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D
, 0}},
3805 {{10, 1, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D
, 0}},
3806 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D
, 0}, {RGBA8_UNORM
, TEX_2D
, 0}},
3807 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D
, 1}, {RGBA8_UNORM
, TEX_2D
, 1}},
3808 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D
, 9}, {RGBA8_UNORM
, TEX_2D
, 9}},
3809 {{ 1, 1, RGBA8_TL
}, {RGBA8_UNORM
, TEX_2D
, 0}, {RGBA8_UNORM
, TEX_2D
, 0}},
3810 {{10, 1, RGBA8_TL
}, {RGBA8_UNORM
, TEX_2D
, 0}, {RGBA8_UNORM
, TEX_2D
, 0}},
3811 {{ 1, 4, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 4}},
3812 {{10, 4, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 4}},
3813 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 4}},
3814 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 1, 0, 4}},
3815 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 3, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 3, 0, 4}},
3816 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 5, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 5, 0, 4}},
3817 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 9, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 9, 0, 4}},
3818 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 1, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 3}},
3819 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 2, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 2, 2}},
3820 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 3, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 3, 1}},
3821 {{ 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS
}, {RGBA8_UNORM
, TEX_2DMS
}},
3822 {{ 1, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS
}, {RGBA8_UNORM
, TEX_2DMS
}},
3823 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS
}, {RGBA8_UNORM
, TEX_2DMS
}},
3824 {{ 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 1}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 1}},
3825 {{ 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 1}},
3826 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 1}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 1}},
3827 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 1}},
3828 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 1}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 1}},
3829 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 4}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 4}},
3830 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 4}},
3831 {{ 1, 6, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 6}},
3832 {{ 2, 6, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 6}},
3833 {{ 2, 6, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 6}},
3834 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 2}},
3835 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 2}},
3836 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 1, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 1, 3}},
3837 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 2, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 2, 2}},
3838 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 3, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 3, 1}},
3839 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 1, 1}, {RGBA8_UNORM
, TEX_3D
, 0, 1, 1}},
3840 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 1, 1}, {RGBA8_UNORM
, TEX_3D
, 1, 1, 1}},
3841 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 1, ~0u}, {RGBA8_UNORM
, TEX_3D
, 1, 1, 1}},
3842 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 8}},
3843 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 4}},
3844 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 2, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 2, 0, 2}},
3845 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 3, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 3, 0, 1}},
3846 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 4, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 4, 0, 1}},
3847 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 5, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 5, 0, 1}},
3853 D3D11_RTV_DIMENSION dimension
;
3854 unsigned int miplevel_count
;
3855 unsigned int depth_or_array_size
;
3858 struct rtv_desc rtv_desc
;
3860 invalid_desc_tests
[] =
3862 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, DIM_UNKNOWN
}},
3863 {{TEX_2D
, 6, 4, RGBA8_UNORM
}, {RGBA8_UNORM
, DIM_UNKNOWN
}},
3864 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0}},
3865 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 0, 1}},
3866 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 1}},
3867 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, ~0u}},
3868 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_2D
, 0}},
3869 {{TEX_2D
, 1, 1, RGBA8_TL
}, {FMT_UNKNOWN
, TEX_2D
, 0}},
3870 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 1}},
3871 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 0}},
3872 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 1, 0, 1}},
3873 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 2}},
3874 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 1}},
3875 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 2}},
3876 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 1}},
3877 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0}},
3878 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 0, 1}},
3879 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0}},
3880 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 1}},
3881 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0}},
3882 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 0, 1}},
3883 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0}},
3884 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 1}},
3885 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 0}},
3886 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 1}},
3887 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_3D
, 0, 0, 1}},
3888 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_TL
, TEX_3D
, 0, 0, 1}},
3889 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 9}},
3890 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 3, 0, 2}},
3891 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 2, 0, 4}},
3892 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 8}},
3893 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 8, ~0u}},
3894 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 4, ~0u}},
3895 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 2, 2, ~0u}},
3896 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 3, 1, ~0u}},
3910 if (!(device
= create_device(NULL
)))
3912 skip("Failed to create device.\n");
3916 buffer_desc
.ByteWidth
= 1024;
3917 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
3918 buffer_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
3919 buffer_desc
.CPUAccessFlags
= 0;
3920 buffer_desc
.MiscFlags
= 0;
3921 buffer_desc
.StructureByteStride
= 0;
3923 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &data
, &buffer
);
3924 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
3926 expected_refcount
= get_refcount(device
) + 1;
3927 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
3928 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
3929 refcount
= get_refcount(device
);
3930 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
3932 expected_refcount
= refcount
+ 1;
3933 ID3D11Buffer_GetDevice(buffer
, &tmp
);
3934 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
3935 refcount
= get_refcount(device
);
3936 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
3937 ID3D11Device_Release(tmp
);
3939 rtv_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
3940 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_BUFFER
;
3941 U1(U(rtv_desc
).Buffer
).ElementOffset
= 0;
3942 U2(U(rtv_desc
).Buffer
).ElementWidth
= 64;
3944 if (!enable_debug_layer
)
3946 hr
= ID3D11Device_CreateRenderTargetView(device
, NULL
, &rtv_desc
, &rtview
);
3947 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
3950 expected_refcount
= get_refcount(device
) + 1;
3951 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)buffer
, &rtv_desc
, &rtview
);
3952 ok(SUCCEEDED(hr
), "Failed to create a rendertarget view, hr %#x.\n", hr
);
3953 refcount
= get_refcount(device
);
3954 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
3956 expected_refcount
= refcount
+ 1;
3957 ID3D11RenderTargetView_GetDevice(rtview
, &tmp
);
3958 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
3959 refcount
= get_refcount(device
);
3960 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
3961 ID3D11Device_Release(tmp
);
3963 /* Not available on all Windows versions. */
3964 check_interface(rtview
, &IID_ID3D10RenderTargetView
, TRUE
, TRUE
);
3966 ID3D11RenderTargetView_Release(rtview
);
3967 ID3D11Buffer_Release(buffer
);
3969 texture2d_desc
.Width
= 512;
3970 texture2d_desc
.Height
= 512;
3971 texture2d_desc
.SampleDesc
.Count
= 1;
3972 texture2d_desc
.SampleDesc
.Quality
= 0;
3973 texture2d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
3974 texture2d_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
3975 texture2d_desc
.CPUAccessFlags
= 0;
3976 texture2d_desc
.MiscFlags
= 0;
3978 texture3d_desc
.Width
= 64;
3979 texture3d_desc
.Height
= 64;
3980 texture3d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
3981 texture3d_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
3982 texture3d_desc
.CPUAccessFlags
= 0;
3983 texture3d_desc
.MiscFlags
= 0;
3985 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
3987 D3D11_RENDER_TARGET_VIEW_DESC
*current_desc
;
3989 if (tests
[i
].expected_rtv_desc
.dimension
!= D3D11_RTV_DIMENSION_TEXTURE3D
)
3991 texture2d_desc
.MipLevels
= tests
[i
].texture
.miplevel_count
;
3992 texture2d_desc
.ArraySize
= tests
[i
].texture
.depth_or_array_size
;
3993 texture2d_desc
.Format
= tests
[i
].texture
.format
;
3995 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, &texture2d
);
3996 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
3997 texture
= (ID3D11Resource
*)texture2d
;
4001 texture3d_desc
.MipLevels
= tests
[i
].texture
.miplevel_count
;
4002 texture3d_desc
.Depth
= tests
[i
].texture
.depth_or_array_size
;
4003 texture3d_desc
.Format
= tests
[i
].texture
.format
;
4005 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &texture3d
);
4006 ok(SUCCEEDED(hr
), "Test %u: Failed to create 3d texture, hr %#x.\n", i
, hr
);
4007 texture
= (ID3D11Resource
*)texture3d
;
4010 if (tests
[i
].rtv_desc
.dimension
== D3D11_RTV_DIMENSION_UNKNOWN
)
4012 current_desc
= NULL
;
4016 current_desc
= &rtv_desc
;
4017 get_rtv_desc(current_desc
, &tests
[i
].rtv_desc
);
4020 expected_refcount
= get_refcount(texture
);
4021 hr
= ID3D11Device_CreateRenderTargetView(device
, texture
, current_desc
, &rtview
);
4022 ok(SUCCEEDED(hr
), "Test %u: Failed to create render target view, hr %#x.\n", i
, hr
);
4023 refcount
= get_refcount(texture
);
4024 ok(refcount
== expected_refcount
, "Got refcount %u, expected %u.\n", refcount
, expected_refcount
);
4026 /* Not available on all Windows versions. */
4027 check_interface(rtview
, &IID_ID3D10RenderTargetView
, TRUE
, TRUE
);
4029 memset(&rtv_desc
, 0, sizeof(rtv_desc
));
4030 ID3D11RenderTargetView_GetDesc(rtview
, &rtv_desc
);
4031 check_rtv_desc(&rtv_desc
, &tests
[i
].expected_rtv_desc
);
4033 ID3D11RenderTargetView_Release(rtview
);
4034 ID3D11Resource_Release(texture
);
4037 for (i
= 0; i
< ARRAY_SIZE(invalid_desc_tests
); ++i
)
4039 assert(invalid_desc_tests
[i
].texture
.dimension
== D3D11_RTV_DIMENSION_TEXTURE2D
4040 || invalid_desc_tests
[i
].texture
.dimension
== D3D11_RTV_DIMENSION_TEXTURE3D
);
4042 if (invalid_desc_tests
[i
].texture
.dimension
!= D3D11_RTV_DIMENSION_TEXTURE3D
)
4044 texture2d_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
4045 texture2d_desc
.ArraySize
= invalid_desc_tests
[i
].texture
.depth_or_array_size
;
4046 texture2d_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
4048 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, &texture2d
);
4049 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
4050 texture
= (ID3D11Resource
*)texture2d
;
4054 texture3d_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
4055 texture3d_desc
.Depth
= invalid_desc_tests
[i
].texture
.depth_or_array_size
;
4056 texture3d_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
4058 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &texture3d
);
4059 ok(SUCCEEDED(hr
), "Test %u: Failed to create 3d texture, hr %#x.\n", i
, hr
);
4060 texture
= (ID3D11Resource
*)texture3d
;
4063 get_rtv_desc(&rtv_desc
, &invalid_desc_tests
[i
].rtv_desc
);
4064 hr
= ID3D11Device_CreateRenderTargetView(device
, texture
, &rtv_desc
, &rtview
);
4065 ok(hr
== E_INVALIDARG
, "Test %u: Got unexpected hr %#x.\n", i
, hr
);
4067 ID3D11Resource_Release(texture
);
4070 refcount
= ID3D11Device_Release(device
);
4071 ok(!refcount
, "Device has %u references left.\n", refcount
);
4074 static void test_create_shader_resource_view(void)
4076 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
4077 D3D11_TEXTURE3D_DESC texture3d_desc
;
4078 D3D11_TEXTURE2D_DESC texture2d_desc
;
4079 ULONG refcount
, expected_refcount
;
4080 ID3D11ShaderResourceView
*srview
;
4081 D3D_FEATURE_LEVEL feature_level
;
4082 D3D11_BUFFER_DESC buffer_desc
;
4083 ID3D11Device
*device
, *tmp
;
4084 ID3D11Texture3D
*texture3d
;
4085 ID3D11Texture2D
*texture2d
;
4086 ID3D11Resource
*texture
;
4087 ID3D11Buffer
*buffer
;
4091 #define FMT_UNKNOWN DXGI_FORMAT_UNKNOWN
4092 #define RGBA8_UNORM DXGI_FORMAT_R8G8B8A8_UNORM
4093 #define RGBA8_SRGB DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
4094 #define RGBA8_UINT DXGI_FORMAT_R8G8B8A8_UINT
4095 #define RGBA8_TL DXGI_FORMAT_R8G8B8A8_TYPELESS
4096 #define DIM_UNKNOWN D3D11_SRV_DIMENSION_UNKNOWN
4097 #define TEX_1D D3D11_SRV_DIMENSION_TEXTURE1D
4098 #define TEX_1D_ARRAY D3D11_SRV_DIMENSION_TEXTURE1DARRAY
4099 #define TEX_2D D3D11_SRV_DIMENSION_TEXTURE2D
4100 #define TEX_2D_ARRAY D3D11_SRV_DIMENSION_TEXTURE2DARRAY
4101 #define TEX_2DMS D3D11_SRV_DIMENSION_TEXTURE2DMS
4102 #define TEX_2DMS_ARR D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY
4103 #define TEX_3D D3D11_SRV_DIMENSION_TEXTURE3D
4104 #define TEX_CUBE D3D11_SRV_DIMENSION_TEXTURECUBE
4105 #define CUBE_ARRAY D3D11_SRV_DIMENSION_TEXTURECUBEARRAY
4110 unsigned int miplevel_count
;
4111 unsigned int depth_or_array_size
;
4114 struct srv_desc srv_desc
;
4115 struct srv_desc expected_srv_desc
;
4119 {{10, 1, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D
, 0, 10}},
4120 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D
, 0, ~0u}, {RGBA8_UNORM
, TEX_2D
, 0, 10}},
4121 {{10, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0, ~0u}, {RGBA8_UNORM
, TEX_2D
, 0, 10}},
4122 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D
, 0, 10}, {RGBA8_UNORM
, TEX_2D
, 0, 10}},
4123 {{ 1, 1, RGBA8_TL
}, {RGBA8_UNORM
, TEX_2D
, 0, ~0u}, {RGBA8_UNORM
, TEX_2D
, 0, 1}},
4124 {{10, 1, RGBA8_TL
}, {RGBA8_UNORM
, TEX_2D
, 0, ~0u}, {RGBA8_UNORM
, TEX_2D
, 0, 10}},
4125 {{10, 4, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 10, 0, 4}},
4126 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, ~0u, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 10, 0, 4}},
4127 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 1, ~0u, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 1, 9, 0, 4}},
4128 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 3, ~0u, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 3, 7, 0, 4}},
4129 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 5, ~0u, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 5, 5, 0, 4}},
4130 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 9, ~0u, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 9, 1, 0, 4}},
4131 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, ~0u, 1, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 10, 1, 3}},
4132 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, ~0u, 2, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 10, 2, 2}},
4133 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, ~0u, 3, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 10, 3, 1}},
4134 {{ 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS
}, {RGBA8_UNORM
, TEX_2DMS
}},
4135 {{ 1, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS
}, {RGBA8_UNORM
, TEX_2DMS
}},
4136 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS
}, {RGBA8_UNORM
, TEX_2DMS
}},
4137 {{ 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 1, 0, 1}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 1}},
4138 {{ 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 1}},
4139 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 1, 0, 1}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 1}},
4140 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 1}},
4141 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 1, 0, 1}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 1}},
4142 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 1, 0, 4}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 4}},
4143 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 4}},
4144 {{ 1, 12, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_3D
, 0, 1}},
4145 {{ 1, 12, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 1}, {RGBA8_UNORM
, TEX_3D
, 0, 1}},
4146 {{ 1, 12, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 1}},
4147 {{ 4, 12, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 4}},
4148 {{ 1, 6, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_CUBE
, 0, 1}},
4149 {{ 2, 6, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_CUBE
, 0, 2}},
4150 {{ 2, 9, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_CUBE
, 0, 2}},
4151 {{ 2, 11, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_CUBE
, 0, 2}},
4152 {{ 2, 6, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_CUBE
, 0, ~0u}, {RGBA8_UNORM
, TEX_CUBE
, 0, 2}},
4153 {{ 2, 6, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_CUBE
, 0, 1}, {RGBA8_UNORM
, TEX_CUBE
, 0, 1}},
4154 {{ 2, 6, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_CUBE
, 1, 1}, {RGBA8_UNORM
, TEX_CUBE
, 1, 1}},
4155 {{ 2, 6, RGBA8_UNORM
}, {FMT_UNKNOWN
, CUBE_ARRAY
, 0, 1, 0, 1}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 1}},
4156 {{ 2, 6, RGBA8_UNORM
}, {FMT_UNKNOWN
, CUBE_ARRAY
, 0, ~0u, 0, ~0u}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 2, 0, 1}},
4157 {{ 1, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, CUBE_ARRAY
, 0, ~0u, 0, ~0u}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 1}},
4158 {{ 1, 12, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 2}},
4159 {{ 1, 12, RGBA8_UNORM
}, {FMT_UNKNOWN
, CUBE_ARRAY
, 0, ~0u, 0, ~0u}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 2}},
4160 {{ 1, 12, RGBA8_UNORM
}, {FMT_UNKNOWN
, CUBE_ARRAY
, 0, ~0u, 0, 1}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 1}},
4161 {{ 1, 12, RGBA8_UNORM
}, {FMT_UNKNOWN
, CUBE_ARRAY
, 0, ~0u, 0, 2}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 2}},
4162 {{ 1, 13, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 2}},
4163 {{ 1, 14, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 2}},
4164 {{ 1, 18, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 3}},
4165 {{ 1, 1, RGBA8_UINT
}, {0}, {RGBA8_UINT
, TEX_2D
, 0, 1, 0, 1}},
4166 {{ 1, 1, RGBA8_TL
}, {RGBA8_UINT
, TEX_2D
, 0, ~0u}, {RGBA8_UINT
, TEX_2D
, 0, 1, 0, 1}},
4172 D3D11_SRV_DIMENSION dimension
;
4173 unsigned int miplevel_count
;
4174 unsigned int depth_or_array_size
;
4177 struct srv_desc srv_desc
;
4179 invalid_desc_tests
[] =
4181 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, DIM_UNKNOWN
}},
4182 {{TEX_2D
, 6, 4, RGBA8_UNORM
}, {RGBA8_UNORM
, DIM_UNKNOWN
}},
4183 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0, 1}},
4184 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 1, 0, 1}},
4185 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 1}},
4186 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_2D
, 0, ~0u}},
4187 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_2D
, 0, 1}},
4188 {{TEX_2D
, 1, 1, RGBA8_TL
}, {FMT_UNKNOWN
, TEX_2D
, 0, ~0u}},
4189 {{TEX_2D
, 1, 1, RGBA8_TL
}, {FMT_UNKNOWN
, TEX_2D
, 0, 1}},
4190 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0, 0}},
4191 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0, 2}},
4192 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 1, 1}},
4193 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 0, 0}},
4194 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 0, 1}},
4195 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 0, 0}},
4196 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 2, 0, 1}},
4197 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 1, 1, 0, 1}},
4198 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 0, 2}},
4199 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 1, 1}},
4200 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 2}},
4201 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 1, 1}},
4202 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_CUBE
, 0, 0}},
4203 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_CUBE
, 0, 2}},
4204 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_CUBE
, 1, 1}},
4205 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 0, 0, 0}},
4206 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 0, 0, 1}},
4207 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 0}},
4208 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 0}},
4209 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 2, 0, 1}},
4210 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 1, 1, 0, 1}},
4211 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 1, 1}},
4212 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 1, ~0u}},
4213 {{TEX_2D
, 1, 7, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 2, 1}},
4214 {{TEX_2D
, 1, 7, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 2, ~0u}},
4215 {{TEX_2D
, 1, 7, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 2}},
4216 {{TEX_2D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, CUBE_ARRAY
, 0, 1, 0, 2}},
4217 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UINT
, TEX_2D
, 0, 1}},
4218 {{TEX_2D
, 1, 1, RGBA8_UINT
}, {RGBA8_UNORM
, TEX_2D
, 0, 1}},
4219 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_SRGB
, TEX_2D
, 0, 1}},
4220 {{TEX_2D
, 1, 1, RGBA8_SRGB
}, {RGBA8_UNORM
, TEX_2D
, 0, 1}},
4221 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0, 1}},
4222 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 1, 0, 1}},
4223 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0, 1}},
4224 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_CUBE
, 0, 1}},
4225 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 0, 1}},
4226 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0, 1}},
4227 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 1, 0, 1}},
4228 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0, 1}},
4229 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_CUBE
, 0, 1}},
4230 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 0, 1}},
4231 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0}},
4232 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_3D
, 0, 1}},
4233 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 2}},
4234 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 1}},
4235 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 2}},
4236 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 1}},
4254 if (!(device
= create_device(NULL
)))
4256 skip("Failed to create device.\n");
4259 feature_level
= ID3D11Device_GetFeatureLevel(device
);
4261 buffer
= create_buffer(device
, D3D11_BIND_SHADER_RESOURCE
, 1024, NULL
);
4263 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)buffer
, NULL
, &srview
);
4264 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
4266 srv_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
4267 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_BUFFER
;
4268 U1(U(srv_desc
).Buffer
).ElementOffset
= 0;
4269 U2(U(srv_desc
).Buffer
).ElementWidth
= 64;
4271 hr
= ID3D11Device_CreateShaderResourceView(device
, NULL
, &srv_desc
, &srview
);
4272 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
4274 expected_refcount
= get_refcount(device
) + 1;
4275 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)buffer
, &srv_desc
, &srview
);
4276 ok(SUCCEEDED(hr
), "Failed to create a shader resource view, hr %#x.\n", hr
);
4277 refcount
= get_refcount(device
);
4278 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
4280 expected_refcount
= refcount
+ 1;
4281 ID3D11ShaderResourceView_GetDevice(srview
, &tmp
);
4282 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
4283 refcount
= get_refcount(device
);
4284 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
4285 ID3D11Device_Release(tmp
);
4287 /* Not available on all Windows versions. */
4288 check_interface(srview
, &IID_ID3D10ShaderResourceView
, TRUE
, TRUE
);
4289 check_interface(srview
, &IID_ID3D10ShaderResourceView1
, TRUE
, TRUE
);
4291 ID3D11ShaderResourceView_Release(srview
);
4292 ID3D11Buffer_Release(buffer
);
4294 /* Without D3D11_BIND_SHADER_RESOURCE. */
4295 buffer
= create_buffer(device
, 0, 1024, NULL
);
4297 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)buffer
, &srv_desc
, &srview
);
4298 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
4300 ID3D11Buffer_Release(buffer
);
4302 if (feature_level
>= D3D_FEATURE_LEVEL_11_0
)
4304 buffer_desc
.ByteWidth
= 1024;
4305 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
4306 buffer_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
4307 buffer_desc
.CPUAccessFlags
= 0;
4308 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
;
4309 buffer_desc
.StructureByteStride
= 4;
4311 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
4312 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
4314 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)buffer
, NULL
, &srview
);
4315 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
4317 memset(&srv_desc
, 0, sizeof(srv_desc
));
4318 ID3D11ShaderResourceView_GetDesc(srview
, &srv_desc
);
4320 ok(srv_desc
.Format
== DXGI_FORMAT_UNKNOWN
, "Got unexpected format %#x.\n", srv_desc
.Format
);
4321 ok(srv_desc
.ViewDimension
== D3D11_SRV_DIMENSION_BUFFER
, "Got unexpected view dimension %#x.\n",
4322 srv_desc
.ViewDimension
);
4323 ok(!U1(U(srv_desc
).Buffer
).FirstElement
, "Got unexpected first element %u.\n",
4324 U1(U(srv_desc
).Buffer
).FirstElement
);
4325 ok(U2(U(srv_desc
).Buffer
).NumElements
== 256, "Got unexpected num elements %u.\n",
4326 U2(U(srv_desc
).Buffer
).NumElements
);
4328 ID3D11ShaderResourceView_Release(srview
);
4329 ID3D11Buffer_Release(buffer
);
4333 skip("Structured buffers require feature level 11_0.\n");
4336 texture2d_desc
.Width
= 512;
4337 texture2d_desc
.Height
= 512;
4338 texture2d_desc
.SampleDesc
.Count
= 1;
4339 texture2d_desc
.SampleDesc
.Quality
= 0;
4340 texture2d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
4341 texture2d_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
4342 texture2d_desc
.CPUAccessFlags
= 0;
4344 texture3d_desc
.Width
= 64;
4345 texture3d_desc
.Height
= 64;
4346 texture3d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
4347 texture3d_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
4348 texture3d_desc
.CPUAccessFlags
= 0;
4349 texture3d_desc
.MiscFlags
= 0;
4351 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
4353 D3D11_SHADER_RESOURCE_VIEW_DESC
*current_desc
;
4355 if (tests
[i
].expected_srv_desc
.dimension
!= D3D11_SRV_DIMENSION_TEXTURE3D
)
4357 texture2d_desc
.MipLevels
= tests
[i
].texture
.miplevel_count
;
4358 texture2d_desc
.ArraySize
= tests
[i
].texture
.depth_or_array_size
;
4359 texture2d_desc
.Format
= tests
[i
].texture
.format
;
4360 texture2d_desc
.MiscFlags
= 0;
4362 if (tests
[i
].expected_srv_desc
.dimension
== D3D11_SRV_DIMENSION_TEXTURECUBE
4363 || tests
[i
].expected_srv_desc
.dimension
== D3D11_SRV_DIMENSION_TEXTURECUBEARRAY
)
4364 texture2d_desc
.MiscFlags
|= D3D11_RESOURCE_MISC_TEXTURECUBE
;
4366 if (texture2d_desc
.MiscFlags
& D3D11_RESOURCE_MISC_TEXTURECUBE
4367 && (texture2d_desc
.ArraySize
!= 6
4368 || tests
[i
].expected_srv_desc
.dimension
== D3D11_SRV_DIMENSION_TEXTURECUBEARRAY
)
4369 && feature_level
< D3D_FEATURE_LEVEL_10_1
)
4371 skip("Test %u: Cube map array textures require feature level 10_1.\n", i
);
4375 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, &texture2d
);
4376 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
4377 texture
= (ID3D11Resource
*)texture2d
;
4381 texture3d_desc
.MipLevels
= tests
[i
].texture
.miplevel_count
;
4382 texture3d_desc
.Depth
= tests
[i
].texture
.depth_or_array_size
;
4383 texture3d_desc
.Format
= tests
[i
].texture
.format
;
4385 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &texture3d
);
4386 ok(SUCCEEDED(hr
), "Test %u: Failed to create 3d texture, hr %#x.\n", i
, hr
);
4387 texture
= (ID3D11Resource
*)texture3d
;
4390 if (tests
[i
].srv_desc
.dimension
== D3D11_SRV_DIMENSION_UNKNOWN
)
4392 current_desc
= NULL
;
4396 current_desc
= &srv_desc
;
4397 get_srv_desc(current_desc
, &tests
[i
].srv_desc
);
4400 expected_refcount
= get_refcount(texture
);
4401 hr
= ID3D11Device_CreateShaderResourceView(device
, texture
, current_desc
, &srview
);
4402 ok(SUCCEEDED(hr
), "Test %u: Failed to create a shader resource view, hr %#x.\n", i
, hr
);
4403 refcount
= get_refcount(texture
);
4404 ok(refcount
== expected_refcount
, "Got refcount %u, expected %u.\n", refcount
, expected_refcount
);
4406 /* Not available on all Windows versions. */
4407 check_interface(srview
, &IID_ID3D10ShaderResourceView
, TRUE
, TRUE
);
4408 check_interface(srview
, &IID_ID3D10ShaderResourceView1
, TRUE
, TRUE
);
4410 memset(&srv_desc
, 0, sizeof(srv_desc
));
4411 ID3D11ShaderResourceView_GetDesc(srview
, &srv_desc
);
4412 check_srv_desc(&srv_desc
, &tests
[i
].expected_srv_desc
);
4414 ID3D11ShaderResourceView_Release(srview
);
4415 ID3D11Resource_Release(texture
);
4418 for (i
= 0; i
< ARRAY_SIZE(invalid_desc_tests
); ++i
)
4420 assert(invalid_desc_tests
[i
].texture
.dimension
== D3D11_SRV_DIMENSION_TEXTURE2D
4421 || invalid_desc_tests
[i
].texture
.dimension
== D3D11_SRV_DIMENSION_TEXTURE3D
);
4423 if (invalid_desc_tests
[i
].texture
.dimension
== D3D11_SRV_DIMENSION_TEXTURE2D
)
4425 texture2d_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
4426 texture2d_desc
.ArraySize
= invalid_desc_tests
[i
].texture
.depth_or_array_size
;
4427 texture2d_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
4428 texture2d_desc
.MiscFlags
= 0;
4430 if (invalid_desc_tests
[i
].srv_desc
.dimension
== D3D11_SRV_DIMENSION_TEXTURECUBE
4431 || invalid_desc_tests
[i
].srv_desc
.dimension
== D3D11_SRV_DIMENSION_TEXTURECUBEARRAY
)
4432 texture2d_desc
.MiscFlags
|= D3D11_RESOURCE_MISC_TEXTURECUBE
;
4434 if (invalid_desc_tests
[i
].srv_desc
.dimension
== D3D11_SRV_DIMENSION_TEXTURECUBEARRAY
4435 && feature_level
< D3D_FEATURE_LEVEL_10_1
)
4437 skip("Test %u: Cube map array textures require feature level 10_1.\n", i
);
4441 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, &texture2d
);
4442 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
4443 texture
= (ID3D11Resource
*)texture2d
;
4447 texture3d_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
4448 texture3d_desc
.Depth
= invalid_desc_tests
[i
].texture
.depth_or_array_size
;
4449 texture3d_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
4451 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &texture3d
);
4452 ok(SUCCEEDED(hr
), "Test %u: Failed to create 3d texture, hr %#x.\n", i
, hr
);
4453 texture
= (ID3D11Resource
*)texture3d
;
4456 get_srv_desc(&srv_desc
, &invalid_desc_tests
[i
].srv_desc
);
4457 hr
= ID3D11Device_CreateShaderResourceView(device
, texture
, &srv_desc
, &srview
);
4458 ok(hr
== E_INVALIDARG
, "Test %u: Got unexpected hr %#x.\n", i
, hr
);
4460 ID3D11Resource_Release(texture
);
4463 refcount
= ID3D11Device_Release(device
);
4464 ok(!refcount
, "Device has %u references left.\n", refcount
);
4467 static void test_create_shader(const D3D_FEATURE_LEVEL feature_level
)
4475 float4 position
: POSITION
;
4476 float3 normal
: NORMAL
;
4481 float4 position
: POSITION
;
4482 float4 diffuse
: COLOR
;
4485 output
main(const input v
)
4489 o
.position
= mul(v
.position
, mat
);
4490 o
.diffuse
= dot((float3
)light
, v
.normal
);
4495 static const DWORD vs_4_1
[] =
4497 0x43425844, 0xfce5b27c, 0x965db93d, 0x8c3d0459, 0x9890ebac, 0x00000001, 0x000001c4, 0x00000003,
4498 0x0000002c, 0x0000007c, 0x000000cc, 0x4e475349, 0x00000048, 0x00000002, 0x00000008, 0x00000038,
4499 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
4500 0x00000003, 0x00000001, 0x00000707, 0x49534f50, 0x4e4f4954, 0x524f4e00, 0x004c414d, 0x4e47534f,
4501 0x00000048, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
4502 0x0000000f, 0x00000041, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x49534f50,
4503 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x52444853, 0x000000f0, 0x00010041, 0x0000003c, 0x0100086a,
4504 0x04000059, 0x00208e46, 0x00000000, 0x00000005, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f,
4505 0x00101072, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000001,
4506 0x08000011, 0x00102012, 0x00000000, 0x00101e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000001,
4507 0x08000011, 0x00102022, 0x00000000, 0x00101e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000002,
4508 0x08000011, 0x00102042, 0x00000000, 0x00101e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000003,
4509 0x08000011, 0x00102082, 0x00000000, 0x00101e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000004,
4510 0x08000010, 0x001020f2, 0x00000001, 0x00208246, 0x00000000, 0x00000000, 0x00101246, 0x00000001,
4513 static const DWORD vs_4_0
[] =
4515 0x43425844, 0x3ae813ca, 0x0f034b91, 0x790f3226, 0x6b4a718a, 0x00000001, 0x000001c0,
4516 0x00000003, 0x0000002c, 0x0000007c, 0x000000cc, 0x4e475349, 0x00000048, 0x00000002,
4517 0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f,
4518 0x00000041, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000707, 0x49534f50,
4519 0x4e4f4954, 0x524f4e00, 0x004c414d, 0x4e47534f, 0x00000048, 0x00000002, 0x00000008,
4520 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x00000041,
4521 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x49534f50, 0x4e4f4954,
4522 0x4c4f4300, 0xab00524f, 0x52444853, 0x000000ec, 0x00010040, 0x0000003b, 0x04000059,
4523 0x00208e46, 0x00000000, 0x00000005, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f,
4524 0x00101072, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x001020f2,
4525 0x00000001, 0x08000011, 0x00102012, 0x00000000, 0x00101e46, 0x00000000, 0x00208e46,
4526 0x00000000, 0x00000001, 0x08000011, 0x00102022, 0x00000000, 0x00101e46, 0x00000000,
4527 0x00208e46, 0x00000000, 0x00000002, 0x08000011, 0x00102042, 0x00000000, 0x00101e46,
4528 0x00000000, 0x00208e46, 0x00000000, 0x00000003, 0x08000011, 0x00102082, 0x00000000,
4529 0x00101e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x08000010, 0x001020f2,
4530 0x00000001, 0x00208246, 0x00000000, 0x00000000, 0x00101246, 0x00000001, 0x0100003e,
4532 static const DWORD vs_3_0
[] =
4534 0xfffe0300, 0x002bfffe, 0x42415443, 0x0000001c, 0x00000077, 0xfffe0300, 0x00000002,
4535 0x0000001c, 0x00000100, 0x00000070, 0x00000044, 0x00040002, 0x00000001, 0x0000004c,
4536 0x00000000, 0x0000005c, 0x00000002, 0x00000004, 0x00000060, 0x00000000, 0x6867696c,
4537 0xabab0074, 0x00030001, 0x00040001, 0x00000001, 0x00000000, 0x0074616d, 0x00030003,
4538 0x00040004, 0x00000001, 0x00000000, 0x335f7376, 0x4d00305f, 0x6f726369, 0x74666f73,
4539 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e392072,
4540 0x392e3932, 0x332e3235, 0x00313131, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f,
4541 0x80000003, 0x900f0001, 0x0200001f, 0x80000000, 0xe00f0000, 0x0200001f, 0x8000000a,
4542 0xe00f0001, 0x03000009, 0xe0010000, 0x90e40000, 0xa0e40000, 0x03000009, 0xe0020000,
4543 0x90e40000, 0xa0e40001, 0x03000009, 0xe0040000, 0x90e40000, 0xa0e40002, 0x03000009,
4544 0xe0080000, 0x90e40000, 0xa0e40003, 0x03000008, 0xe00f0001, 0xa0e40004, 0x90e40001,
4547 static const DWORD vs_2_0
[] =
4549 0xfffe0200, 0x002bfffe, 0x42415443, 0x0000001c, 0x00000077, 0xfffe0200, 0x00000002,
4550 0x0000001c, 0x00000100, 0x00000070, 0x00000044, 0x00040002, 0x00000001, 0x0000004c,
4551 0x00000000, 0x0000005c, 0x00000002, 0x00000004, 0x00000060, 0x00000000, 0x6867696c,
4552 0xabab0074, 0x00030001, 0x00040001, 0x00000001, 0x00000000, 0x0074616d, 0x00030003,
4553 0x00040004, 0x00000001, 0x00000000, 0x325f7376, 0x4d00305f, 0x6f726369, 0x74666f73,
4554 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e392072,
4555 0x392e3932, 0x332e3235, 0x00313131, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f,
4556 0x80000003, 0x900f0001, 0x03000009, 0xc0010000, 0x90e40000, 0xa0e40000, 0x03000009,
4557 0xc0020000, 0x90e40000, 0xa0e40001, 0x03000009, 0xc0040000, 0x90e40000, 0xa0e40002,
4558 0x03000009, 0xc0080000, 0x90e40000, 0xa0e40003, 0x03000008, 0xd00f0000, 0xa0e40004,
4559 0x90e40001, 0x0000ffff,
4563 float4
main(const float4 color
: COLOR
) : SV_TARGET
4572 static const DWORD ps_4_1
[] =
4574 0x43425844, 0xa1a44423, 0xa4cfcec2, 0x64610832, 0xb7a852bd, 0x00000001, 0x000000d4, 0x00000003,
4575 0x0000002c, 0x0000005c, 0x00000090, 0x4e475349, 0x00000028, 0x00000001, 0x00000008, 0x00000020,
4576 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x4f4c4f43, 0xabab0052, 0x4e47534f,
4577 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
4578 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x0000003c, 0x00000041, 0x0000000f,
4579 0x0100086a, 0x03001062, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
4580 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
4582 static const DWORD ps_4_0
[] =
4584 0x43425844, 0x08c2b568, 0x17d33120, 0xb7d82948, 0x13a570fb, 0x00000001, 0x000000d0, 0x00000003,
4585 0x0000002c, 0x0000005c, 0x00000090, 0x4e475349, 0x00000028, 0x00000001, 0x00000008, 0x00000020,
4586 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x4f4c4f43, 0xabab0052, 0x4e47534f,
4587 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
4588 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
4589 0x03001062, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x05000036, 0x001020f2,
4590 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
4592 static const DWORD ps_4_0_level_9_0
[] =
4594 0x43425844, 0xbc6626e7, 0x7778dc9d, 0xc8a43be2, 0xe4b53f7a, 0x00000001, 0x00000170,
4595 0x00000005, 0x00000034, 0x00000080, 0x000000cc, 0x0000010c, 0x0000013c, 0x53414e58,
4596 0x00000044, 0x00000044, 0xffff0200, 0x00000020, 0x00000024, 0x00240000, 0x00240000,
4597 0x00240000, 0x00240000, 0x00240000, 0xffff0200, 0x0200001f, 0x80000000, 0xb00f0000,
4598 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, 0x396e6f41, 0x00000044, 0x00000044,
4599 0xffff0200, 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000,
4600 0x00240000, 0xffff0200, 0x0200001f, 0x80000000, 0xb00f0000, 0x02000001, 0x800f0800,
4601 0xb0e40000, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040, 0x0000000e, 0x03001062,
4602 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x05000036, 0x001020f2,
4603 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x4e475349, 0x00000028, 0x00000001,
4604 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f,
4605 0x4f4c4f43, 0xabab0052, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
4606 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241,
4609 static const DWORD ps_4_0_level_9_1
[] =
4611 0x43425844, 0x275ecf38, 0x4349ff01, 0xa6b0e324, 0x6e54a4fc, 0x00000001, 0x00000120,
4612 0x00000004, 0x00000030, 0x0000007c, 0x000000bc, 0x000000ec, 0x396e6f41, 0x00000044,
4613 0x00000044, 0xffff0200, 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000,
4614 0x00240000, 0x00240000, 0xffff0200, 0x0200001f, 0x80000000, 0xb00f0000, 0x02000001,
4615 0x800f0800, 0xb0e40000, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
4616 0x03001062, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
4617 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x4e475349, 0x00000028,
4618 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
4619 0x00000f0f, 0x4f4c4f43, 0xabab0052, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008,
4620 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653,
4621 0x45475241, 0xabab0054,
4623 static const DWORD ps_4_0_level_9_3
[] =
4625 0x43425844, 0xc7d541c4, 0x961d4e0e, 0x9ce7ec57, 0x70f47dcb, 0x00000001, 0x00000120,
4626 0x00000004, 0x00000030, 0x0000007c, 0x000000bc, 0x000000ec, 0x396e6f41, 0x00000044,
4627 0x00000044, 0xffff0200, 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000,
4628 0x00240000, 0x00240000, 0xffff0201, 0x0200001f, 0x80000000, 0xb00f0000, 0x02000001,
4629 0x800f0800, 0xb0e40000, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
4630 0x03001062, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
4631 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x4e475349, 0x00000028,
4632 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
4633 0x00000f0f, 0x4f4c4f43, 0xabab0052, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008,
4634 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653,
4635 0x45475241, 0xabab0054,
4641 float4 pos
: SV_POSITION
;
4645 void main(point float4 vin
[1] : POSITION
, inout TriangleStream
<gs_out
> vout
)
4647 float offset
= 0.1 * vin
[0].w
;
4650 v
.pos
= float4(vin
[0].x
- offset
, vin
[0].y
- offset
, vin
[0].z
, vin
[0].w
);
4652 v
.pos
= float4(vin
[0].x
- offset
, vin
[0].y
+ offset
, vin
[0].z
, vin
[0].w
);
4654 v
.pos
= float4(vin
[0].x
+ offset
, vin
[0].y
- offset
, vin
[0].z
, vin
[0].w
);
4656 v
.pos
= float4(vin
[0].x
+ offset
, vin
[0].y
+ offset
, vin
[0].z
, vin
[0].w
);
4660 static const DWORD gs_4_1
[] =
4662 0x43425844, 0x779daaf5, 0x7e154197, 0xcf5e99da, 0xb502b4d2, 0x00000001, 0x00000240, 0x00000003,
4663 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
4664 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
4665 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
4666 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x000001a4, 0x00020041,
4667 0x00000069, 0x0100086a, 0x0400005f, 0x002010f2, 0x00000001, 0x00000000, 0x02000068, 0x00000001,
4668 0x0100085d, 0x0100285c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x0200005e, 0x00000004,
4669 0x0f000032, 0x00100032, 0x00000000, 0x80201ff6, 0x00000041, 0x00000000, 0x00000000, 0x00004002,
4670 0x3dcccccd, 0x3dcccccd, 0x00000000, 0x00000000, 0x00201046, 0x00000000, 0x00000000, 0x05000036,
4671 0x00102032, 0x00000000, 0x00100046, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6,
4672 0x00000000, 0x00000000, 0x01000013, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000,
4673 0x0e000032, 0x00100052, 0x00000000, 0x00201ff6, 0x00000000, 0x00000000, 0x00004002, 0x3dcccccd,
4674 0x00000000, 0x3dcccccd, 0x00000000, 0x00201106, 0x00000000, 0x00000000, 0x05000036, 0x00102022,
4675 0x00000000, 0x0010002a, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000,
4676 0x00000000, 0x01000013, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x05000036,
4677 0x00102022, 0x00000000, 0x0010001a, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6,
4678 0x00000000, 0x00000000, 0x01000013, 0x05000036, 0x00102032, 0x00000000, 0x00100086, 0x00000000,
4679 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000, 0x00000000, 0x01000013, 0x0100003e,
4681 static const DWORD gs_4_0
[] =
4683 0x43425844, 0x000ee786, 0xc624c269, 0x885a5cbe, 0x444b3b1f, 0x00000001, 0x0000023c, 0x00000003,
4684 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
4685 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
4686 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
4687 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x000001a0, 0x00020040,
4688 0x00000068, 0x0400005f, 0x002010f2, 0x00000001, 0x00000000, 0x02000068, 0x00000001, 0x0100085d,
4689 0x0100285c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x0200005e, 0x00000004, 0x0f000032,
4690 0x00100032, 0x00000000, 0x80201ff6, 0x00000041, 0x00000000, 0x00000000, 0x00004002, 0x3dcccccd,
4691 0x3dcccccd, 0x00000000, 0x00000000, 0x00201046, 0x00000000, 0x00000000, 0x05000036, 0x00102032,
4692 0x00000000, 0x00100046, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000,
4693 0x00000000, 0x01000013, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0e000032,
4694 0x00100052, 0x00000000, 0x00201ff6, 0x00000000, 0x00000000, 0x00004002, 0x3dcccccd, 0x00000000,
4695 0x3dcccccd, 0x00000000, 0x00201106, 0x00000000, 0x00000000, 0x05000036, 0x00102022, 0x00000000,
4696 0x0010002a, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000, 0x00000000,
4697 0x01000013, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x05000036, 0x00102022,
4698 0x00000000, 0x0010001a, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000,
4699 0x00000000, 0x01000013, 0x05000036, 0x00102032, 0x00000000, 0x00100086, 0x00000000, 0x06000036,
4700 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000, 0x00000000, 0x01000013, 0x0100003e,
4703 ULONG refcount
, expected_refcount
;
4704 struct device_desc device_desc
;
4705 ID3D11Device
*device
, *tmp
;
4706 ID3D11GeometryShader
*gs
;
4707 ID3D11VertexShader
*vs
;
4708 ID3D11PixelShader
*ps
;
4711 device_desc
.feature_level
= &feature_level
;
4712 device_desc
.flags
= 0;
4713 if (!(device
= create_device(&device_desc
)))
4715 skip("Failed to create device for feature level %#x.\n", feature_level
);
4719 /* level_9 shaders */
4720 hr
= ID3D11Device_CreatePixelShader(device
, ps_4_0_level_9_0
, sizeof(ps_4_0_level_9_0
), NULL
, &ps
);
4721 ok(SUCCEEDED(hr
), "Failed to create ps_4_0_level_9_0 shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4722 ID3D11PixelShader_Release(ps
);
4724 hr
= ID3D11Device_CreatePixelShader(device
, ps_4_0_level_9_1
, sizeof(ps_4_0_level_9_1
), NULL
, &ps
);
4725 ok(SUCCEEDED(hr
), "Failed to create ps_4_0_level_9_1 shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4726 ID3D11PixelShader_Release(ps
);
4728 hr
= ID3D11Device_CreatePixelShader(device
, ps_4_0_level_9_3
, sizeof(ps_4_0_level_9_3
), NULL
, &ps
);
4729 ok(SUCCEEDED(hr
), "Failed to create ps_4_0_level_9_3 shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4730 ID3D11PixelShader_Release(ps
);
4733 hr
= ID3D11Device_CreateVertexShader(device
, vs_2_0
, sizeof(vs_2_0
), NULL
, &vs
);
4734 ok(hr
== E_INVALIDARG
, "Created a SM2 vertex shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4736 hr
= ID3D11Device_CreateVertexShader(device
, vs_3_0
, sizeof(vs_3_0
), NULL
, &vs
);
4737 ok(hr
== E_INVALIDARG
, "Created a SM3 vertex shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4739 hr
= ID3D11Device_CreateVertexShader(device
, ps_4_0
, sizeof(ps_4_0
), NULL
, &vs
);
4740 ok(hr
== E_INVALIDARG
, "Created a SM4 vertex shader from a pixel shader source, hr %#x, feature level %#x.\n",
4743 expected_refcount
= get_refcount(device
) + (feature_level
>= D3D_FEATURE_LEVEL_10_0
);
4744 hr
= ID3D11Device_CreateVertexShader(device
, vs_4_0
, sizeof(vs_4_0
), NULL
, &vs
);
4745 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
4746 ok(SUCCEEDED(hr
), "Failed to create SM4 vertex shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4748 ok(hr
== E_INVALIDARG
, "Created a SM4 vertex shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4750 refcount
= get_refcount(device
);
4751 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n",
4752 refcount
, expected_refcount
);
4753 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
4756 expected_refcount
= refcount
+ 1;
4757 ID3D11VertexShader_GetDevice(vs
, &tmp
);
4758 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
4759 refcount
= get_refcount(device
);
4760 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n",
4761 refcount
, expected_refcount
);
4762 ID3D11Device_Release(tmp
);
4764 /* Not available on all Windows versions. */
4765 check_interface(vs
, &IID_ID3D10VertexShader
, TRUE
, TRUE
);
4767 refcount
= ID3D11VertexShader_Release(vs
);
4768 ok(!refcount
, "Vertex shader has %u references left.\n", refcount
);
4771 hr
= ID3D11Device_CreateVertexShader(device
, vs_4_1
, sizeof(vs_4_1
), NULL
, &vs
);
4772 if (feature_level
>= D3D_FEATURE_LEVEL_10_1
)
4774 ok(SUCCEEDED(hr
), "Failed to create SM4.1 vertex shader, hr %#x, feature level %#x.\n",
4776 refcount
= ID3D11VertexShader_Release(vs
);
4777 ok(!refcount
, "Vertex shader has %u references left.\n", refcount
);
4781 todo_wine_if(feature_level
>= D3D_FEATURE_LEVEL_10_0
)
4782 ok(hr
== E_INVALIDARG
, "Created a SM4.1 vertex shader, hr %#x, feature level %#x.\n",
4785 ID3D11VertexShader_Release(vs
);
4789 expected_refcount
= get_refcount(device
) + (feature_level
>= D3D_FEATURE_LEVEL_10_0
);
4790 hr
= ID3D11Device_CreatePixelShader(device
, ps_4_0
, sizeof(ps_4_0
), NULL
, &ps
);
4791 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
4792 ok(SUCCEEDED(hr
), "Failed to create SM4 pixel shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4794 ok(hr
== E_INVALIDARG
, "Created a SM4 pixel shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4796 refcount
= get_refcount(device
);
4797 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n",
4798 refcount
, expected_refcount
);
4799 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
4802 expected_refcount
= refcount
+ 1;
4803 ID3D11PixelShader_GetDevice(ps
, &tmp
);
4804 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
4805 refcount
= get_refcount(device
);
4806 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n",
4807 refcount
, expected_refcount
);
4808 ID3D11Device_Release(tmp
);
4810 /* Not available on all Windows versions. */
4811 check_interface(ps
, &IID_ID3D10PixelShader
, TRUE
, TRUE
);
4813 refcount
= ID3D11PixelShader_Release(ps
);
4814 ok(!refcount
, "Pixel shader has %u references left.\n", refcount
);
4817 hr
= ID3D11Device_CreatePixelShader(device
, ps_4_1
, sizeof(ps_4_1
), NULL
, &ps
);
4818 if (feature_level
>= D3D_FEATURE_LEVEL_10_1
)
4820 ok(SUCCEEDED(hr
), "Failed to create SM4.1 pixel shader, hr %#x, feature level %#x.\n",
4822 refcount
= ID3D11PixelShader_Release(ps
);
4823 ok(!refcount
, "Pixel shader has %u references left.\n", refcount
);
4827 todo_wine_if(feature_level
>= D3D_FEATURE_LEVEL_10_0
)
4828 ok(hr
== E_INVALIDARG
, "Created a SM4.1 pixel shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4830 ID3D11PixelShader_Release(ps
);
4833 /* geometry shader */
4834 expected_refcount
= get_refcount(device
) + (feature_level
>= D3D_FEATURE_LEVEL_10_0
);
4835 hr
= ID3D11Device_CreateGeometryShader(device
, gs_4_0
, sizeof(gs_4_0
), NULL
, &gs
);
4836 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
4837 ok(SUCCEEDED(hr
), "Failed to create SM4 geometry shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4839 ok(hr
== E_INVALIDARG
, "Created a SM4 geometry shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
4841 refcount
= get_refcount(device
);
4842 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n",
4843 refcount
, expected_refcount
);
4844 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
4847 expected_refcount
= refcount
+ 1;
4848 ID3D11GeometryShader_GetDevice(gs
, &tmp
);
4849 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
4850 refcount
= get_refcount(device
);
4851 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n",
4852 refcount
, expected_refcount
);
4853 ID3D11Device_Release(tmp
);
4855 /* Not available on all Windows versions. */
4856 check_interface(gs
, &IID_ID3D10GeometryShader
, TRUE
, TRUE
);
4858 refcount
= ID3D11GeometryShader_Release(gs
);
4859 ok(!refcount
, "Geometry shader has %u references left.\n", refcount
);
4862 hr
= ID3D11Device_CreateGeometryShader(device
, gs_4_1
, sizeof(gs_4_1
), NULL
, &gs
);
4863 if (feature_level
>= D3D_FEATURE_LEVEL_10_1
)
4865 ok(SUCCEEDED(hr
), "Failed to create SM4.1 geometry shader, hr %#x, feature level %#x.\n",
4867 refcount
= ID3D11GeometryShader_Release(gs
);
4868 ok(!refcount
, "Geometry shader has %u references left.\n", refcount
);
4872 todo_wine_if(feature_level
>= D3D_FEATURE_LEVEL_10_0
)
4873 ok(hr
== E_INVALIDARG
, "Created a SM4.1 geometry shader, hr %#x, feature level %#x.\n",
4876 ID3D11GeometryShader_Release(gs
);
4879 refcount
= ID3D11Device_Release(device
);
4880 ok(!refcount
, "Device has %u references left.\n", refcount
);
4883 static void test_create_sampler_state(void)
4885 static const struct test
4887 D3D11_FILTER filter
;
4888 D3D10_FILTER expected_filter
;
4890 desc_conversion_tests
[] =
4892 {D3D11_FILTER_MIN_MAG_MIP_POINT
, D3D10_FILTER_MIN_MAG_MIP_POINT
},
4893 {D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR
, D3D10_FILTER_MIN_MAG_POINT_MIP_LINEAR
},
4894 {D3D11_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT
, D3D10_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT
},
4895 {D3D11_FILTER_MIN_POINT_MAG_MIP_LINEAR
, D3D10_FILTER_MIN_POINT_MAG_MIP_LINEAR
},
4896 {D3D11_FILTER_MIN_LINEAR_MAG_MIP_POINT
, D3D10_FILTER_MIN_LINEAR_MAG_MIP_POINT
},
4897 {D3D11_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR
, D3D10_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR
},
4898 {D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT
, D3D10_FILTER_MIN_MAG_LINEAR_MIP_POINT
},
4899 {D3D11_FILTER_MIN_MAG_MIP_LINEAR
, D3D10_FILTER_MIN_MAG_MIP_LINEAR
},
4900 {D3D11_FILTER_ANISOTROPIC
, D3D10_FILTER_ANISOTROPIC
},
4901 {D3D11_FILTER_COMPARISON_MIN_MAG_MIP_POINT
, D3D10_FILTER_COMPARISON_MIN_MAG_MIP_POINT
},
4902 {D3D11_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR
, D3D10_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR
},
4904 D3D11_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT
,
4905 D3D10_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT
4907 {D3D11_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR
, D3D10_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR
},
4908 {D3D11_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT
, D3D10_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT
},
4910 D3D11_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR
,
4911 D3D10_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR
4913 {D3D11_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT
, D3D10_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT
},
4914 {D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR
, D3D10_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR
},
4915 {D3D11_FILTER_COMPARISON_ANISOTROPIC
, D3D10_FILTER_COMPARISON_ANISOTROPIC
},
4918 ID3D11SamplerState
*sampler_state1
, *sampler_state2
;
4919 ID3D10SamplerState
*d3d10_sampler_state
;
4920 ULONG refcount
, expected_refcount
;
4921 ID3D11Device
*device
, *tmp
;
4922 D3D11_SAMPLER_DESC desc
;
4926 if (!(device
= create_device(NULL
)))
4928 skip("Failed to create device.\n");
4932 hr
= ID3D11Device_CreateSamplerState(device
, NULL
, &sampler_state1
);
4933 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
4935 desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_LINEAR
;
4936 desc
.AddressU
= D3D11_TEXTURE_ADDRESS_WRAP
;
4937 desc
.AddressV
= D3D11_TEXTURE_ADDRESS_WRAP
;
4938 desc
.AddressW
= D3D11_TEXTURE_ADDRESS_WRAP
;
4939 desc
.MipLODBias
= 0.0f
;
4940 desc
.MaxAnisotropy
= 16;
4941 desc
.ComparisonFunc
= D3D11_COMPARISON_ALWAYS
;
4942 desc
.BorderColor
[0] = 0.0f
;
4943 desc
.BorderColor
[1] = 1.0f
;
4944 desc
.BorderColor
[2] = 0.0f
;
4945 desc
.BorderColor
[3] = 1.0f
;
4947 desc
.MaxLOD
= 16.0f
;
4949 expected_refcount
= get_refcount(device
) + 1;
4950 hr
= ID3D11Device_CreateSamplerState(device
, &desc
, &sampler_state1
);
4951 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
4952 hr
= ID3D11Device_CreateSamplerState(device
, &desc
, &sampler_state2
);
4953 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
4954 ok(sampler_state1
== sampler_state2
, "Got different sampler state objects.\n");
4955 refcount
= get_refcount(device
);
4956 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
4958 expected_refcount
= refcount
+ 1;
4959 ID3D11SamplerState_GetDevice(sampler_state1
, &tmp
);
4960 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
4961 refcount
= get_refcount(device
);
4962 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
4963 ID3D11Device_Release(tmp
);
4965 ID3D11SamplerState_GetDesc(sampler_state1
, &desc
);
4966 ok(desc
.Filter
== D3D11_FILTER_MIN_MAG_MIP_LINEAR
, "Got unexpected filter %#x.\n", desc
.Filter
);
4967 ok(desc
.AddressU
== D3D11_TEXTURE_ADDRESS_WRAP
, "Got unexpected address u %u.\n", desc
.AddressU
);
4968 ok(desc
.AddressV
== D3D11_TEXTURE_ADDRESS_WRAP
, "Got unexpected address v %u.\n", desc
.AddressV
);
4969 ok(desc
.AddressW
== D3D11_TEXTURE_ADDRESS_WRAP
, "Got unexpected address w %u.\n", desc
.AddressW
);
4970 ok(!desc
.MipLODBias
, "Got unexpected mip LOD bias %f.\n", desc
.MipLODBias
);
4971 ok(!desc
.MaxAnisotropy
, "Got unexpected max anisotropy %u.\n", desc
.MaxAnisotropy
);
4972 ok(desc
.ComparisonFunc
== D3D11_COMPARISON_NEVER
, "Got unexpected comparison func %u.\n", desc
.ComparisonFunc
);
4973 ok(!desc
.BorderColor
[0] && !desc
.BorderColor
[1] && !desc
.BorderColor
[2] && !desc
.BorderColor
[3],
4974 "Got unexpected border color {%.8e, %.8e, %.8e, %.8e}.\n",
4975 desc
.BorderColor
[0], desc
.BorderColor
[1], desc
.BorderColor
[2], desc
.BorderColor
[3]);
4976 ok(!desc
.MinLOD
, "Got unexpected min LOD %f.\n", desc
.MinLOD
);
4977 ok(desc
.MaxLOD
== 16.0f
, "Got unexpected max LOD %f.\n", desc
.MaxLOD
);
4979 refcount
= ID3D11SamplerState_Release(sampler_state2
);
4980 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
4981 refcount
= ID3D11SamplerState_Release(sampler_state1
);
4982 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
4984 for (i
= 0; i
< ARRAY_SIZE(desc_conversion_tests
); ++i
)
4986 const struct test
*current
= &desc_conversion_tests
[i
];
4987 D3D10_SAMPLER_DESC d3d10_desc
, expected_desc
;
4989 desc
.Filter
= current
->filter
;
4990 desc
.AddressU
= D3D11_TEXTURE_ADDRESS_WRAP
;
4991 desc
.AddressV
= D3D11_TEXTURE_ADDRESS_WRAP
;
4992 desc
.AddressW
= D3D11_TEXTURE_ADDRESS_BORDER
;
4993 desc
.MipLODBias
= 0.0f
;
4994 desc
.MaxAnisotropy
= 16;
4995 desc
.ComparisonFunc
= D3D11_COMPARISON_ALWAYS
;
4996 desc
.BorderColor
[0] = 0.0f
;
4997 desc
.BorderColor
[1] = 1.0f
;
4998 desc
.BorderColor
[2] = 0.0f
;
4999 desc
.BorderColor
[3] = 1.0f
;
5001 desc
.MaxLOD
= 16.0f
;
5003 hr
= ID3D11Device_CreateSamplerState(device
, &desc
, &sampler_state1
);
5004 ok(SUCCEEDED(hr
), "Test %u: Failed to create sampler state, hr %#x.\n", i
, hr
);
5006 hr
= ID3D11SamplerState_QueryInterface(sampler_state1
, &IID_ID3D10SamplerState
,
5007 (void **)&d3d10_sampler_state
);
5008 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
5009 "Test %u: Sampler state should implement ID3D10SamplerState.\n", i
);
5012 win_skip("Sampler state does not implement ID3D10SamplerState.\n");
5013 ID3D11SamplerState_Release(sampler_state1
);
5017 memcpy(&expected_desc
, &desc
, sizeof(expected_desc
));
5018 expected_desc
.Filter
= current
->expected_filter
;
5019 if (!D3D11_DECODE_IS_ANISOTROPIC_FILTER(current
->filter
))
5020 expected_desc
.MaxAnisotropy
= 0;
5021 if (!D3D11_DECODE_IS_COMPARISON_FILTER(current
->filter
))
5022 expected_desc
.ComparisonFunc
= D3D10_COMPARISON_NEVER
;
5024 ID3D10SamplerState_GetDesc(d3d10_sampler_state
, &d3d10_desc
);
5025 ok(d3d10_desc
.Filter
== expected_desc
.Filter
,
5026 "Test %u: Got unexpected filter %#x.\n", i
, d3d10_desc
.Filter
);
5027 ok(d3d10_desc
.AddressU
== expected_desc
.AddressU
,
5028 "Test %u: Got unexpected address u %u.\n", i
, d3d10_desc
.AddressU
);
5029 ok(d3d10_desc
.AddressV
== expected_desc
.AddressV
,
5030 "Test %u: Got unexpected address v %u.\n", i
, d3d10_desc
.AddressV
);
5031 ok(d3d10_desc
.AddressW
== expected_desc
.AddressW
,
5032 "Test %u: Got unexpected address w %u.\n", i
, d3d10_desc
.AddressW
);
5033 ok(d3d10_desc
.MipLODBias
== expected_desc
.MipLODBias
,
5034 "Test %u: Got unexpected mip LOD bias %f.\n", i
, d3d10_desc
.MipLODBias
);
5035 ok(d3d10_desc
.MaxAnisotropy
== expected_desc
.MaxAnisotropy
,
5036 "Test %u: Got unexpected max anisotropy %u.\n", i
, d3d10_desc
.MaxAnisotropy
);
5037 ok(d3d10_desc
.ComparisonFunc
== expected_desc
.ComparisonFunc
,
5038 "Test %u: Got unexpected comparison func %u.\n", i
, d3d10_desc
.ComparisonFunc
);
5039 ok(d3d10_desc
.BorderColor
[0] == expected_desc
.BorderColor
[0]
5040 && d3d10_desc
.BorderColor
[1] == expected_desc
.BorderColor
[1]
5041 && d3d10_desc
.BorderColor
[2] == expected_desc
.BorderColor
[2]
5042 && d3d10_desc
.BorderColor
[3] == expected_desc
.BorderColor
[3],
5043 "Test %u: Got unexpected border color {%.8e, %.8e, %.8e, %.8e}.\n", i
,
5044 d3d10_desc
.BorderColor
[0], d3d10_desc
.BorderColor
[1],
5045 d3d10_desc
.BorderColor
[2], d3d10_desc
.BorderColor
[3]);
5046 ok(d3d10_desc
.MinLOD
== expected_desc
.MinLOD
,
5047 "Test %u: Got unexpected min LOD %f.\n", i
, d3d10_desc
.MinLOD
);
5048 ok(d3d10_desc
.MaxLOD
== expected_desc
.MaxLOD
,
5049 "Test %u: Got unexpected max LOD %f.\n", i
, d3d10_desc
.MaxLOD
);
5051 refcount
= ID3D10SamplerState_Release(d3d10_sampler_state
);
5052 ok(refcount
== 1, "Test %u: Got unexpected refcount %u.\n", i
, refcount
);
5053 refcount
= ID3D11SamplerState_Release(sampler_state1
);
5054 ok(!refcount
, "Test %u: Got unexpected refcount %u.\n", i
, refcount
);
5057 refcount
= ID3D11Device_Release(device
);
5058 ok(!refcount
, "Device has %u references left.\n", refcount
);
5061 static void test_create_blend_state(void)
5063 static const D3D11_BLEND_DESC desc_conversion_tests
[] =
5069 FALSE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5070 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
5078 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5079 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5082 FALSE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5083 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_RED
5086 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5087 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5090 FALSE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5091 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_GREEN
5094 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5095 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5098 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5099 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5102 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5103 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5106 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5107 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5115 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5116 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5119 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_SUBTRACT
,
5120 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5123 TRUE
, D3D11_BLEND_ZERO
, D3D11_BLEND_ONE
, D3D11_BLEND_OP_ADD
,
5124 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5127 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5128 D3D11_BLEND_ZERO
, D3D11_BLEND_ONE
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5131 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ONE
, D3D11_BLEND_OP_MAX
,
5132 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5135 TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ONE
, D3D11_BLEND_OP_MIN
,
5136 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5139 FALSE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5140 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5143 FALSE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
5144 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
5150 ID3D11BlendState
*blend_state1
, *blend_state2
;
5151 D3D11_BLEND_DESC desc
, obtained_desc
;
5152 ID3D10BlendState
*d3d10_blend_state
;
5153 D3D10_BLEND_DESC d3d10_blend_desc
;
5154 ULONG refcount
, expected_refcount
;
5155 ID3D11Device
*device
, *tmp
;
5159 if (!(device
= create_device(NULL
)))
5161 skip("Failed to create device.\n");
5165 hr
= ID3D11Device_CreateBlendState(device
, NULL
, &blend_state1
);
5166 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5168 memset(&desc
, 0, sizeof(desc
));
5169 desc
.AlphaToCoverageEnable
= FALSE
;
5170 desc
.IndependentBlendEnable
= FALSE
;
5171 desc
.RenderTarget
[0].BlendEnable
= FALSE
;
5172 desc
.RenderTarget
[0].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_ALL
;
5174 expected_refcount
= get_refcount(device
) + 1;
5175 hr
= ID3D11Device_CreateBlendState(device
, &desc
, &blend_state1
);
5176 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
5177 hr
= ID3D11Device_CreateBlendState(device
, &desc
, &blend_state2
);
5178 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
5179 ok(blend_state1
== blend_state2
, "Got different blend state objects.\n");
5180 refcount
= get_refcount(device
);
5181 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
5183 expected_refcount
= refcount
+ 1;
5184 ID3D11BlendState_GetDevice(blend_state1
, &tmp
);
5185 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
5186 refcount
= get_refcount(device
);
5187 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
5188 ID3D11Device_Release(tmp
);
5190 ID3D11BlendState_GetDesc(blend_state1
, &obtained_desc
);
5191 ok(obtained_desc
.AlphaToCoverageEnable
== FALSE
, "Got unexpected alpha to coverage enable %#x.\n",
5192 obtained_desc
.AlphaToCoverageEnable
);
5193 ok(obtained_desc
.IndependentBlendEnable
== FALSE
, "Got unexpected independent blend enable %#x.\n",
5194 obtained_desc
.IndependentBlendEnable
);
5195 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
5197 ok(obtained_desc
.RenderTarget
[i
].BlendEnable
== FALSE
,
5198 "Got unexpected blend enable %#x for render target %u.\n",
5199 obtained_desc
.RenderTarget
[i
].BlendEnable
, i
);
5200 ok(obtained_desc
.RenderTarget
[i
].SrcBlend
== D3D11_BLEND_ONE
,
5201 "Got unexpected src blend %u for render target %u.\n",
5202 obtained_desc
.RenderTarget
[i
].SrcBlend
, i
);
5203 ok(obtained_desc
.RenderTarget
[i
].DestBlend
== D3D11_BLEND_ZERO
,
5204 "Got unexpected dest blend %u for render target %u.\n",
5205 obtained_desc
.RenderTarget
[i
].DestBlend
, i
);
5206 ok(obtained_desc
.RenderTarget
[i
].BlendOp
== D3D11_BLEND_OP_ADD
,
5207 "Got unexpected blend op %u for render target %u.\n",
5208 obtained_desc
.RenderTarget
[i
].BlendOp
, i
);
5209 ok(obtained_desc
.RenderTarget
[i
].SrcBlendAlpha
== D3D11_BLEND_ONE
,
5210 "Got unexpected src blend alpha %u for render target %u.\n",
5211 obtained_desc
.RenderTarget
[i
].SrcBlendAlpha
, i
);
5212 ok(obtained_desc
.RenderTarget
[i
].DestBlendAlpha
== D3D11_BLEND_ZERO
,
5213 "Got unexpected dest blend alpha %u for render target %u.\n",
5214 obtained_desc
.RenderTarget
[i
].DestBlendAlpha
, i
);
5215 ok(obtained_desc
.RenderTarget
[i
].BlendOpAlpha
== D3D11_BLEND_OP_ADD
,
5216 "Got unexpected blend op alpha %u for render target %u.\n",
5217 obtained_desc
.RenderTarget
[i
].BlendOpAlpha
, i
);
5218 ok(obtained_desc
.RenderTarget
[i
].RenderTargetWriteMask
== D3D11_COLOR_WRITE_ENABLE_ALL
,
5219 "Got unexpected render target write mask %#x for render target %u.\n",
5220 obtained_desc
.RenderTarget
[0].RenderTargetWriteMask
, i
);
5223 /* Not available on all Windows versions. */
5224 check_interface(blend_state1
, &IID_ID3D10BlendState
, TRUE
, TRUE
);
5225 check_interface(blend_state1
, &IID_ID3D10BlendState1
, TRUE
, TRUE
);
5227 refcount
= ID3D11BlendState_Release(blend_state1
);
5228 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
5229 refcount
= ID3D11BlendState_Release(blend_state2
);
5230 ok(!refcount
, "Blend state has %u references left.\n", refcount
);
5232 for (i
= 0; i
< ARRAY_SIZE(desc_conversion_tests
); ++i
)
5234 const D3D11_BLEND_DESC
*current_desc
= &desc_conversion_tests
[i
];
5236 hr
= ID3D11Device_CreateBlendState(device
, current_desc
, &blend_state1
);
5237 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
5239 hr
= ID3D11BlendState_QueryInterface(blend_state1
, &IID_ID3D10BlendState
, (void **)&d3d10_blend_state
);
5240 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
5241 "Blend state should implement ID3D10BlendState.\n");
5244 win_skip("Blend state does not implement ID3D10BlendState.\n");
5245 ID3D11BlendState_Release(blend_state1
);
5249 ID3D10BlendState_GetDesc(d3d10_blend_state
, &d3d10_blend_desc
);
5250 ok(d3d10_blend_desc
.AlphaToCoverageEnable
== current_desc
->AlphaToCoverageEnable
,
5251 "Got unexpected alpha to coverage enable %#x for test %u.\n",
5252 d3d10_blend_desc
.AlphaToCoverageEnable
, i
);
5253 ok(d3d10_blend_desc
.SrcBlend
== (D3D10_BLEND
)current_desc
->RenderTarget
[0].SrcBlend
,
5254 "Got unexpected src blend %u for test %u.\n", d3d10_blend_desc
.SrcBlend
, i
);
5255 ok(d3d10_blend_desc
.DestBlend
== (D3D10_BLEND
)current_desc
->RenderTarget
[0].DestBlend
,
5256 "Got unexpected dest blend %u for test %u.\n", d3d10_blend_desc
.DestBlend
, i
);
5257 ok(d3d10_blend_desc
.BlendOp
== (D3D10_BLEND_OP
)current_desc
->RenderTarget
[0].BlendOp
,
5258 "Got unexpected blend op %u for test %u.\n", d3d10_blend_desc
.BlendOp
, i
);
5259 ok(d3d10_blend_desc
.SrcBlendAlpha
== (D3D10_BLEND
)current_desc
->RenderTarget
[0].SrcBlendAlpha
,
5260 "Got unexpected src blend alpha %u for test %u.\n", d3d10_blend_desc
.SrcBlendAlpha
, i
);
5261 ok(d3d10_blend_desc
.DestBlendAlpha
== (D3D10_BLEND
)current_desc
->RenderTarget
[0].DestBlendAlpha
,
5262 "Got unexpected dest blend alpha %u for test %u.\n", d3d10_blend_desc
.DestBlendAlpha
, i
);
5263 ok(d3d10_blend_desc
.BlendOpAlpha
== (D3D10_BLEND_OP
)current_desc
->RenderTarget
[0].BlendOpAlpha
,
5264 "Got unexpected blend op alpha %u for test %u.\n", d3d10_blend_desc
.BlendOpAlpha
, i
);
5265 for (j
= 0; j
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; j
++)
5267 unsigned int k
= current_desc
->IndependentBlendEnable
? j
: 0;
5268 ok(d3d10_blend_desc
.BlendEnable
[j
] == current_desc
->RenderTarget
[k
].BlendEnable
,
5269 "Got unexpected blend enable %#x for test %u, render target %u.\n",
5270 d3d10_blend_desc
.BlendEnable
[j
], i
, j
);
5271 ok(d3d10_blend_desc
.RenderTargetWriteMask
[j
] == current_desc
->RenderTarget
[k
].RenderTargetWriteMask
,
5272 "Got unexpected render target write mask %#x for test %u, render target %u.\n",
5273 d3d10_blend_desc
.RenderTargetWriteMask
[j
], i
, j
);
5276 ID3D10BlendState_Release(d3d10_blend_state
);
5278 refcount
= ID3D11BlendState_Release(blend_state1
);
5279 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
5282 refcount
= ID3D11Device_Release(device
);
5283 ok(!refcount
, "Device has %u references left.\n", refcount
);
5286 static void test_create_depthstencil_state(void)
5288 ID3D11DepthStencilState
*ds_state1
, *ds_state2
;
5289 ULONG refcount
, expected_refcount
;
5290 D3D11_DEPTH_STENCIL_DESC ds_desc
;
5291 ID3D11Device
*device
, *tmp
;
5294 if (!(device
= create_device(NULL
)))
5296 skip("Failed to create device.\n");
5300 hr
= ID3D11Device_CreateDepthStencilState(device
, NULL
, &ds_state1
);
5301 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5303 ds_desc
.DepthEnable
= TRUE
;
5304 ds_desc
.DepthWriteMask
= D3D11_DEPTH_WRITE_MASK_ALL
;
5305 ds_desc
.DepthFunc
= D3D11_COMPARISON_LESS
;
5306 ds_desc
.StencilEnable
= FALSE
;
5307 ds_desc
.StencilReadMask
= D3D11_DEFAULT_STENCIL_READ_MASK
;
5308 ds_desc
.StencilWriteMask
= D3D11_DEFAULT_STENCIL_WRITE_MASK
;
5309 ds_desc
.FrontFace
.StencilFailOp
= D3D11_STENCIL_OP_KEEP
;
5310 ds_desc
.FrontFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_KEEP
;
5311 ds_desc
.FrontFace
.StencilPassOp
= D3D11_STENCIL_OP_KEEP
;
5312 ds_desc
.FrontFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
5313 ds_desc
.BackFace
.StencilFailOp
= D3D11_STENCIL_OP_KEEP
;
5314 ds_desc
.BackFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_KEEP
;
5315 ds_desc
.BackFace
.StencilPassOp
= D3D11_STENCIL_OP_KEEP
;
5316 ds_desc
.BackFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
5318 expected_refcount
= get_refcount(device
) + 1;
5319 hr
= ID3D11Device_CreateDepthStencilState(device
, &ds_desc
, &ds_state1
);
5320 ok(SUCCEEDED(hr
), "Failed to create depthstencil state, hr %#x.\n", hr
);
5321 hr
= ID3D11Device_CreateDepthStencilState(device
, &ds_desc
, &ds_state2
);
5322 ok(SUCCEEDED(hr
), "Failed to create depthstencil state, hr %#x.\n", hr
);
5323 ok(ds_state1
== ds_state2
, "Got different depthstencil state objects.\n");
5324 refcount
= get_refcount(device
);
5325 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
5327 expected_refcount
= refcount
+ 1;
5328 ID3D11DepthStencilState_GetDevice(ds_state1
, &tmp
);
5329 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
5330 refcount
= get_refcount(device
);
5331 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
5332 ID3D11Device_Release(tmp
);
5334 /* Not available on all Windows versions. */
5335 check_interface(ds_state1
, &IID_ID3D10DepthStencilState
, TRUE
, TRUE
);
5337 refcount
= ID3D11DepthStencilState_Release(ds_state2
);
5338 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
5339 refcount
= ID3D11DepthStencilState_Release(ds_state1
);
5340 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
5342 ds_desc
.DepthEnable
= FALSE
;
5343 ds_desc
.DepthWriteMask
= D3D11_DEPTH_WRITE_MASK_ZERO
;
5344 ds_desc
.DepthFunc
= D3D11_COMPARISON_NEVER
;
5345 ds_desc
.StencilEnable
= FALSE
;
5346 ds_desc
.StencilReadMask
= 0;
5347 ds_desc
.StencilWriteMask
= 0;
5348 ds_desc
.FrontFace
.StencilFailOp
= D3D11_STENCIL_OP_ZERO
;
5349 ds_desc
.FrontFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_ZERO
;
5350 ds_desc
.FrontFace
.StencilPassOp
= D3D11_STENCIL_OP_ZERO
;
5351 ds_desc
.FrontFace
.StencilFunc
= D3D11_COMPARISON_NEVER
;
5352 ds_desc
.BackFace
= ds_desc
.FrontFace
;
5354 hr
= ID3D11Device_CreateDepthStencilState(device
, &ds_desc
, &ds_state1
);
5355 ok(SUCCEEDED(hr
), "Failed to create depthstencil state, hr %#x.\n", hr
);
5357 memset(&ds_desc
, 0, sizeof(ds_desc
));
5358 ID3D11DepthStencilState_GetDesc(ds_state1
, &ds_desc
);
5359 ok(!ds_desc
.DepthEnable
, "Got unexpected depth enable %#x.\n", ds_desc
.DepthEnable
);
5360 ok(ds_desc
.DepthWriteMask
== D3D11_DEPTH_WRITE_MASK_ALL
,
5361 "Got unexpected depth write mask %#x.\n", ds_desc
.DepthWriteMask
);
5362 ok(ds_desc
.DepthFunc
== D3D11_COMPARISON_LESS
, "Got unexpected depth func %#x.\n", ds_desc
.DepthFunc
);
5363 ok(!ds_desc
.StencilEnable
, "Got unexpected stencil enable %#x.\n", ds_desc
.StencilEnable
);
5364 ok(ds_desc
.StencilReadMask
== D3D11_DEFAULT_STENCIL_READ_MASK
,
5365 "Got unexpected stencil read mask %#x.\n", ds_desc
.StencilReadMask
);
5366 ok(ds_desc
.StencilWriteMask
== D3D11_DEFAULT_STENCIL_WRITE_MASK
,
5367 "Got unexpected stencil write mask %#x.\n", ds_desc
.StencilWriteMask
);
5368 ok(ds_desc
.FrontFace
.StencilDepthFailOp
== D3D11_STENCIL_OP_KEEP
,
5369 "Got unexpected front face stencil depth fail op %#x.\n", ds_desc
.FrontFace
.StencilDepthFailOp
);
5370 ok(ds_desc
.FrontFace
.StencilPassOp
== D3D11_STENCIL_OP_KEEP
,
5371 "Got unexpected front face stencil pass op %#x.\n", ds_desc
.FrontFace
.StencilPassOp
);
5372 ok(ds_desc
.FrontFace
.StencilFailOp
== D3D11_STENCIL_OP_KEEP
,
5373 "Got unexpected front face stencil fail op %#x.\n", ds_desc
.FrontFace
.StencilFailOp
);
5374 ok(ds_desc
.FrontFace
.StencilFunc
== D3D11_COMPARISON_ALWAYS
,
5375 "Got unexpected front face stencil func %#x.\n", ds_desc
.FrontFace
.StencilFunc
);
5376 ok(ds_desc
.BackFace
.StencilDepthFailOp
== D3D11_STENCIL_OP_KEEP
,
5377 "Got unexpected back face stencil depth fail op %#x.\n", ds_desc
.BackFace
.StencilDepthFailOp
);
5378 ok(ds_desc
.BackFace
.StencilPassOp
== D3D11_STENCIL_OP_KEEP
,
5379 "Got unexpected back face stencil pass op %#x.\n", ds_desc
.BackFace
.StencilPassOp
);
5380 ok(ds_desc
.BackFace
.StencilFailOp
== D3D11_STENCIL_OP_KEEP
,
5381 "Got unexpected back face stencil fail op %#x.\n", ds_desc
.BackFace
.StencilFailOp
);
5382 ok(ds_desc
.BackFace
.StencilFunc
== D3D11_COMPARISON_ALWAYS
,
5383 "Got unexpected back face stencil func %#x.\n", ds_desc
.BackFace
.StencilFunc
);
5385 ID3D11DepthStencilState_Release(ds_state1
);
5387 refcount
= ID3D11Device_Release(device
);
5388 ok(!refcount
, "Device has %u references left.\n", refcount
);
5391 static void test_create_rasterizer_state(void)
5393 ID3D11RasterizerState
*rast_state1
, *rast_state2
;
5394 ID3D10RasterizerState
*d3d10_rast_state
;
5395 ULONG refcount
, expected_refcount
;
5396 D3D10_RASTERIZER_DESC d3d10_desc
;
5397 D3D11_RASTERIZER_DESC desc
;
5398 ID3D11Device
*device
, *tmp
;
5401 if (!(device
= create_device(NULL
)))
5403 skip("Failed to create device.\n");
5407 hr
= ID3D11Device_CreateRasterizerState(device
, NULL
, &rast_state1
);
5408 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5410 desc
.FillMode
= D3D11_FILL_SOLID
;
5411 desc
.CullMode
= D3D11_CULL_BACK
;
5412 desc
.FrontCounterClockwise
= FALSE
;
5414 desc
.DepthBiasClamp
= 0.0f
;
5415 desc
.SlopeScaledDepthBias
= 0.0f
;
5416 desc
.DepthClipEnable
= TRUE
;
5417 desc
.ScissorEnable
= FALSE
;
5418 desc
.MultisampleEnable
= FALSE
;
5419 desc
.AntialiasedLineEnable
= FALSE
;
5421 expected_refcount
= get_refcount(device
) + 1;
5422 hr
= ID3D11Device_CreateRasterizerState(device
, &desc
, &rast_state1
);
5423 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
5424 hr
= ID3D11Device_CreateRasterizerState(device
, &desc
, &rast_state2
);
5425 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
5426 ok(rast_state1
== rast_state2
, "Got different rasterizer state objects.\n");
5427 refcount
= get_refcount(device
);
5428 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
5430 expected_refcount
= refcount
+ 1;
5431 ID3D11RasterizerState_GetDevice(rast_state1
, &tmp
);
5432 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
5433 refcount
= get_refcount(device
);
5434 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
5435 ID3D11Device_Release(tmp
);
5437 hr
= ID3D11RasterizerState_QueryInterface(rast_state1
, &IID_ID3D10RasterizerState
, (void **)&d3d10_rast_state
);
5438 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
5439 "Rasterizer state should implement ID3D10RasterizerState.\n");
5442 ID3D10RasterizerState_GetDesc(d3d10_rast_state
, &d3d10_desc
);
5443 ok(d3d10_desc
.FillMode
== D3D10_FILL_SOLID
, "Got unexpected fill mode %u.\n", d3d10_desc
.FillMode
);
5444 ok(d3d10_desc
.CullMode
== D3D10_CULL_BACK
, "Got unexpected cull mode %u.\n", d3d10_desc
.CullMode
);
5445 ok(!d3d10_desc
.FrontCounterClockwise
, "Got unexpected front counter clockwise %#x.\n",
5446 d3d10_desc
.FrontCounterClockwise
);
5447 ok(!d3d10_desc
.DepthBias
, "Got unexpected depth bias %d.\n", d3d10_desc
.DepthBias
);
5448 ok(!d3d10_desc
.DepthBiasClamp
, "Got unexpected depth bias clamp %f.\n", d3d10_desc
.DepthBiasClamp
);
5449 ok(!d3d10_desc
.SlopeScaledDepthBias
, "Got unexpected slope scaled depth bias %f.\n",
5450 d3d10_desc
.SlopeScaledDepthBias
);
5451 ok(!!d3d10_desc
.DepthClipEnable
, "Got unexpected depth clip enable %#x.\n", d3d10_desc
.DepthClipEnable
);
5452 ok(!d3d10_desc
.ScissorEnable
, "Got unexpected scissor enable %#x.\n", d3d10_desc
.ScissorEnable
);
5453 ok(!d3d10_desc
.MultisampleEnable
, "Got unexpected multisample enable %#x.\n",
5454 d3d10_desc
.MultisampleEnable
);
5455 ok(!d3d10_desc
.AntialiasedLineEnable
, "Got unexpected antialiased line enable %#x.\n",
5456 d3d10_desc
.AntialiasedLineEnable
);
5458 refcount
= ID3D10RasterizerState_Release(d3d10_rast_state
);
5459 ok(refcount
== 2, "Got unexpected refcount %u.\n", refcount
);
5462 refcount
= ID3D11RasterizerState_Release(rast_state2
);
5463 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
5464 refcount
= ID3D11RasterizerState_Release(rast_state1
);
5465 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
5467 refcount
= ID3D11Device_Release(device
);
5468 ok(!refcount
, "Device has %u references left.\n", refcount
);
5471 static void test_create_query(void)
5476 D3D_FEATURE_LEVEL required_feature_level
;
5478 BOOL can_use_create_predicate
;
5483 {D3D11_QUERY_EVENT
, D3D_FEATURE_LEVEL_10_0
, FALSE
, FALSE
, FALSE
},
5484 {D3D11_QUERY_OCCLUSION
, D3D_FEATURE_LEVEL_10_0
, FALSE
, FALSE
, FALSE
},
5485 {D3D11_QUERY_TIMESTAMP
, D3D_FEATURE_LEVEL_10_0
, FALSE
, FALSE
, FALSE
},
5486 {D3D11_QUERY_TIMESTAMP_DISJOINT
, D3D_FEATURE_LEVEL_10_0
, FALSE
, FALSE
, FALSE
},
5487 {D3D11_QUERY_PIPELINE_STATISTICS
, D3D_FEATURE_LEVEL_10_0
, FALSE
, FALSE
, FALSE
},
5488 {D3D11_QUERY_OCCLUSION_PREDICATE
, D3D_FEATURE_LEVEL_10_0
, TRUE
, TRUE
, FALSE
},
5489 {D3D11_QUERY_SO_STATISTICS
, D3D_FEATURE_LEVEL_10_0
, FALSE
, FALSE
, FALSE
},
5490 {D3D11_QUERY_SO_OVERFLOW_PREDICATE
, D3D_FEATURE_LEVEL_10_0
, TRUE
, TRUE
, TRUE
},
5491 {D3D11_QUERY_SO_STATISTICS_STREAM0
, D3D_FEATURE_LEVEL_11_0
, FALSE
, FALSE
, FALSE
},
5492 {D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM0
, D3D_FEATURE_LEVEL_11_0
, TRUE
, FALSE
, TRUE
},
5493 {D3D11_QUERY_SO_STATISTICS_STREAM1
, D3D_FEATURE_LEVEL_11_0
, FALSE
, FALSE
, FALSE
},
5494 {D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM1
, D3D_FEATURE_LEVEL_11_0
, TRUE
, FALSE
, TRUE
},
5495 {D3D11_QUERY_SO_STATISTICS_STREAM2
, D3D_FEATURE_LEVEL_11_0
, FALSE
, FALSE
, FALSE
},
5496 {D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM2
, D3D_FEATURE_LEVEL_11_0
, TRUE
, FALSE
, TRUE
},
5497 {D3D11_QUERY_SO_STATISTICS_STREAM3
, D3D_FEATURE_LEVEL_11_0
, FALSE
, FALSE
, FALSE
},
5498 {D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM3
, D3D_FEATURE_LEVEL_11_0
, TRUE
, FALSE
, TRUE
},
5501 ULONG refcount
, expected_refcount
;
5502 D3D_FEATURE_LEVEL feature_level
;
5503 D3D11_QUERY_DESC query_desc
;
5504 ID3D11Predicate
*predicate
;
5505 ID3D11Device
*device
, *tmp
;
5506 HRESULT hr
, expected_hr
;
5510 if (!(device
= create_device(NULL
)))
5512 skip("Failed to create device.\n");
5515 feature_level
= ID3D11Device_GetFeatureLevel(device
);
5517 hr
= ID3D11Device_CreateQuery(device
, NULL
, &query
);
5518 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5519 hr
= ID3D11Device_CreatePredicate(device
, NULL
, &predicate
);
5520 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5522 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
5524 if (tests
[i
].required_feature_level
> feature_level
)
5526 skip("Query type %u requires feature level %#x.\n", tests
[i
].query
, tests
[i
].required_feature_level
);
5530 query_desc
.Query
= tests
[i
].query
;
5531 query_desc
.MiscFlags
= 0;
5533 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, NULL
);
5534 todo_wine_if(tests
[i
].todo
)
5535 ok(hr
== S_FALSE
, "Got unexpected hr %#x for query type %u.\n", hr
, query_desc
.Query
);
5537 query_desc
.Query
= tests
[i
].query
;
5538 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, &query
);
5539 todo_wine_if(tests
[i
].todo
)
5540 ok(hr
== S_OK
, "Got unexpected hr %#x for query type %u.\n", hr
, query_desc
.Query
);
5544 check_interface(query
, &IID_ID3D11Predicate
, tests
[i
].is_predicate
, FALSE
);
5545 ID3D11Query_Release(query
);
5547 expected_hr
= tests
[i
].can_use_create_predicate
? S_FALSE
: E_INVALIDARG
;
5548 hr
= ID3D11Device_CreatePredicate(device
, &query_desc
, NULL
);
5549 ok(hr
== expected_hr
, "Got unexpected hr %#x for query type %u.\n", hr
, query_desc
.Query
);
5551 expected_hr
= tests
[i
].can_use_create_predicate
? S_OK
: E_INVALIDARG
;
5552 hr
= ID3D11Device_CreatePredicate(device
, &query_desc
, &predicate
);
5553 ok(hr
== expected_hr
, "Got unexpected hr %#x for query type %u.\n", hr
, query_desc
.Query
);
5555 ID3D11Predicate_Release(predicate
);
5558 query_desc
.Query
= D3D11_QUERY_OCCLUSION_PREDICATE
;
5559 expected_refcount
= get_refcount(device
) + 1;
5560 hr
= ID3D11Device_CreatePredicate(device
, &query_desc
, &predicate
);
5561 ok(SUCCEEDED(hr
), "Failed to create predicate, hr %#x.\n", hr
);
5562 refcount
= get_refcount(device
);
5563 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
5565 expected_refcount
= refcount
+ 1;
5566 ID3D11Predicate_GetDevice(predicate
, &tmp
);
5567 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
5568 refcount
= get_refcount(device
);
5569 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
5570 ID3D11Device_Release(tmp
);
5571 /* Not available on all Windows versions. */
5572 check_interface(predicate
, &IID_ID3D10Predicate
, TRUE
, TRUE
);
5573 ID3D11Predicate_Release(predicate
);
5575 refcount
= ID3D11Device_Release(device
);
5576 ok(!refcount
, "Device has %u references left.\n", refcount
);
5579 #define get_query_data(a, b, c, d) get_query_data_(__LINE__, a, b, c, d)
5580 static void get_query_data_(unsigned int line
, ID3D11DeviceContext
*context
,
5581 ID3D11Asynchronous
*query
, void *data
, unsigned int data_size
)
5586 for (i
= 0; i
< 500; ++i
)
5588 if ((hr
= ID3D11DeviceContext_GetData(context
, query
, NULL
, 0, 0)) != S_FALSE
)
5592 ok_(__FILE__
, line
)(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5593 memset(data
, 0xff, data_size
);
5594 hr
= ID3D11DeviceContext_GetData(context
, query
, data
, data_size
, 0);
5595 ok_(__FILE__
, line
)(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5598 static void test_occlusion_query(void)
5600 static const struct vec4 red
= {1.0f
, 0.0f
, 0.0f
, 1.0f
};
5601 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
5603 struct d3d11_test_context test_context
;
5604 D3D11_TEXTURE2D_DESC texture_desc
;
5605 ID3D11DeviceContext
*context
;
5606 ID3D11RenderTargetView
*rtv
;
5607 D3D11_QUERY_DESC query_desc
;
5608 ID3D11Asynchronous
*query
;
5609 unsigned int data_size
, i
;
5610 ID3D11Texture2D
*texture
;
5611 ID3D11Device
*device
;
5619 if (!init_test_context(&test_context
, NULL
))
5622 device
= test_context
.device
;
5623 context
= test_context
.immediate_context
;
5625 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
5627 query_desc
.Query
= D3D11_QUERY_OCCLUSION
;
5628 query_desc
.MiscFlags
= 0;
5629 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, (ID3D11Query
**)&query
);
5630 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5631 data_size
= ID3D11Asynchronous_GetDataSize(query
);
5632 ok(data_size
== sizeof(data
), "Got unexpected data size %u.\n", data_size
);
5634 memset(&data
, 0xff, sizeof(data
));
5635 hr
= ID3D11DeviceContext_GetData(context
, query
, NULL
, 0, 0);
5636 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5637 hr
= ID3D11DeviceContext_GetData(context
, query
, &data
, sizeof(data
), 0);
5638 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5639 ok(data
.dword
[0] == 0xffffffff && data
.dword
[1] == 0xffffffff,
5640 "Data was modified 0x%08x%08x.\n", data
.dword
[1], data
.dword
[0]);
5642 ID3D11DeviceContext_End(context
, query
);
5643 ID3D11DeviceContext_Begin(context
, query
);
5644 ID3D11DeviceContext_Begin(context
, query
);
5646 memset(&data
, 0xff, sizeof(data
));
5647 hr
= ID3D11DeviceContext_GetData(context
, query
, NULL
, 0, 0);
5648 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5649 hr
= ID3D11DeviceContext_GetData(context
, query
, &data
, sizeof(data
), 0);
5650 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5651 ok(data
.dword
[0] == 0xffffffff && data
.dword
[1] == 0xffffffff,
5652 "Data was modified 0x%08x%08x.\n", data
.dword
[1], data
.dword
[0]);
5654 draw_color_quad(&test_context
, &red
);
5656 ID3D11DeviceContext_End(context
, query
);
5657 get_query_data(context
, query
, &data
, sizeof(data
));
5658 ok(data
.uint
== 640 * 480, "Got unexpected query result 0x%08x%08x.\n", data
.dword
[1], data
.dword
[0]);
5660 memset(&data
, 0xff, sizeof(data
));
5661 hr
= ID3D11DeviceContext_GetData(context
, query
, &data
, sizeof(DWORD
), 0);
5662 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5663 hr
= ID3D11DeviceContext_GetData(context
, query
, &data
, sizeof(WORD
), 0);
5664 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5665 hr
= ID3D11DeviceContext_GetData(context
, query
, &data
, sizeof(data
) - 1, 0);
5666 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5667 hr
= ID3D11DeviceContext_GetData(context
, query
, &data
, sizeof(data
) + 1, 0);
5668 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5669 ok(data
.dword
[0] == 0xffffffff && data
.dword
[1] == 0xffffffff,
5670 "Data was modified 0x%08x%08x.\n", data
.dword
[1], data
.dword
[0]);
5672 memset(&data
, 0xff, sizeof(data
));
5673 hr
= ID3D11DeviceContext_GetData(context
, query
, &data
, 0, 0);
5674 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5675 ok(data
.dword
[0] == 0xffffffff && data
.dword
[1] == 0xffffffff,
5676 "Data was modified 0x%08x%08x.\n", data
.dword
[1], data
.dword
[0]);
5678 hr
= ID3D11DeviceContext_GetData(context
, query
, NULL
, sizeof(DWORD
), 0);
5679 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5680 hr
= ID3D11DeviceContext_GetData(context
, query
, NULL
, sizeof(data
), 0);
5681 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5683 ID3D11DeviceContext_Begin(context
, query
);
5684 ID3D11DeviceContext_End(context
, query
);
5685 ID3D11DeviceContext_End(context
, query
);
5687 get_query_data(context
, query
, &data
, sizeof(data
));
5688 ok(!data
.uint
, "Got unexpected query result 0x%08x%08x.\n", data
.dword
[1], data
.dword
[0]);
5689 hr
= ID3D11DeviceContext_GetData(context
, query
, NULL
, 0, 0);
5690 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5692 texture_desc
.Width
= D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION
;
5693 texture_desc
.Height
= D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION
;
5694 texture_desc
.MipLevels
= 1;
5695 texture_desc
.ArraySize
= 1;
5696 texture_desc
.Format
= DXGI_FORMAT_R8_UNORM
;
5697 texture_desc
.SampleDesc
.Count
= 1;
5698 texture_desc
.SampleDesc
.Quality
= 0;
5699 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
5700 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
5701 texture_desc
.CPUAccessFlags
= 0;
5702 texture_desc
.MiscFlags
= 0;
5703 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
5704 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
5705 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
5706 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
5708 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
5709 set_viewport(context
, 0.0f
, 0.0f
, texture_desc
.Width
, texture_desc
.Height
, 0.0f
, 1.0f
);
5711 ID3D11DeviceContext_Begin(context
, query
);
5712 for (i
= 0; i
< 100; i
++)
5713 draw_color_quad(&test_context
, &red
);
5714 ID3D11DeviceContext_End(context
, query
);
5716 get_query_data(context
, query
, &data
, sizeof(data
));
5717 ok((data
.dword
[0] == 0x90000000 && data
.dword
[1] == 0x1)
5718 || (data
.dword
[0] == 0xffffffff && !data
.dword
[1])
5719 || broken(!data
.uint
),
5720 "Got unexpected query result 0x%08x%08x.\n", data
.dword
[1], data
.dword
[0]);
5721 hr
= ID3D11DeviceContext_GetData(context
, query
, NULL
, 0, 0);
5722 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5724 ID3D11Asynchronous_Release(query
);
5726 /* The following test exercises a code path in wined3d. A wined3d context
5727 * associated with the query is destroyed when the swapchain is released. */
5728 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, (ID3D11Query
**)&query
);
5729 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5731 set_viewport(context
, 0.0f
, 0.0f
, 64.0f
, 64.0f
, 0.0f
, 1.0f
);
5732 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
5733 ID3D11DeviceContext_Begin(context
, query
);
5734 draw_color_quad(&test_context
, &red
);
5735 ID3D11DeviceContext_End(context
, query
);
5737 ID3D11RenderTargetView_Release(test_context
.backbuffer_rtv
);
5738 ID3D11Texture2D_Release(test_context
.backbuffer
);
5739 IDXGISwapChain_Release(test_context
.swapchain
);
5740 test_context
.swapchain
= create_swapchain(device
, test_context
.window
, NULL
);
5741 hr
= IDXGISwapChain_GetBuffer(test_context
.swapchain
, 0, &IID_ID3D11Texture2D
,
5742 (void **)&test_context
.backbuffer
);
5743 ok(SUCCEEDED(hr
), "Failed to get backbuffer, hr %#x.\n", hr
);
5744 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)test_context
.backbuffer
,
5745 NULL
, &test_context
.backbuffer_rtv
);
5746 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
5747 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &test_context
.backbuffer_rtv
, NULL
);
5748 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
5750 get_query_data(context
, query
, &data
, sizeof(data
));
5751 /* This test occasionally succeeds with CSMT enabled because of a race condition. */
5753 todo_wine
ok(data
.dword
[0] == 0x1000 && !data
.dword
[1],
5754 "Got unexpected query result 0x%08x%08x.\n", data
.dword
[1], data
.dword
[0]);
5756 ID3D11Asynchronous_Release(query
);
5757 ID3D11RenderTargetView_Release(rtv
);
5758 ID3D11Texture2D_Release(texture
);
5759 release_test_context(&test_context
);
5762 static void test_pipeline_statistics_query(void)
5764 static const struct vec4 red
= {1.0f
, 0.0f
, 0.0f
, 1.0f
};
5765 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
5767 D3D11_QUERY_DATA_PIPELINE_STATISTICS data
;
5768 struct d3d11_test_context test_context
;
5769 ID3D11DeviceContext
*context
;
5770 D3D11_QUERY_DESC query_desc
;
5771 ID3D11Asynchronous
*query
;
5772 unsigned int data_size
;
5773 ID3D11Device
*device
;
5776 if (!init_test_context(&test_context
, NULL
))
5779 device
= test_context
.device
;
5780 context
= test_context
.immediate_context
;
5782 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
5784 query_desc
.Query
= D3D11_QUERY_PIPELINE_STATISTICS
;
5785 query_desc
.MiscFlags
= 0;
5786 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, (ID3D11Query
**)&query
);
5787 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5788 data_size
= ID3D11Asynchronous_GetDataSize(query
);
5789 ok(data_size
== sizeof(data
), "Got unexpected data size %u.\n", data_size
);
5791 hr
= ID3D11DeviceContext_GetData(context
, query
, NULL
, 0, 0);
5792 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5793 hr
= ID3D11DeviceContext_GetData(context
, query
, &data
, sizeof(data
), 0);
5794 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5796 ID3D11DeviceContext_End(context
, query
);
5797 ID3D11DeviceContext_Begin(context
, query
);
5798 ID3D11DeviceContext_Begin(context
, query
);
5800 memset(&data
, 0xff, sizeof(data
));
5801 hr
= ID3D11DeviceContext_GetData(context
, query
, NULL
, 0, 0);
5802 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5803 hr
= ID3D11DeviceContext_GetData(context
, query
, &data
, sizeof(data
), 0);
5804 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5805 ok(data
.IAVertices
== ~(UINT64
)0, "Data was modified.\n");
5807 draw_quad(&test_context
);
5809 ID3D11DeviceContext_End(context
, query
);
5810 get_query_data(context
, query
, &data
, sizeof(data
));
5811 ok(data
.IAVertices
== 4, "Got unexpected IAVertices count: %u.\n", (unsigned int)data
.IAVertices
);
5812 ok(data
.IAPrimitives
== 2, "Got unexpected IAPrimitives count: %u.\n", (unsigned int)data
.IAPrimitives
);
5813 ok(data
.VSInvocations
== 4, "Got unexpected VSInvocations count: %u.\n", (unsigned int)data
.VSInvocations
);
5814 ok(!data
.GSInvocations
, "Got unexpected GSInvocations count: %u.\n", (unsigned int)data
.GSInvocations
);
5815 ok(!data
.GSPrimitives
, "Got unexpected GSPrimitives count: %u.\n", (unsigned int)data
.GSPrimitives
);
5816 ok(data
.CInvocations
== 2, "Got unexpected CInvocations count: %u.\n", (unsigned int)data
.CInvocations
);
5817 ok(data
.CPrimitives
== 2, "Got unexpected CPrimitives count: %u.\n", (unsigned int)data
.CPrimitives
);
5819 ok(!data
.PSInvocations
, "Got unexpected PSInvocations count: %u.\n", (unsigned int)data
.PSInvocations
);
5820 ok(!data
.HSInvocations
, "Got unexpected HSInvocations count: %u.\n", (unsigned int)data
.HSInvocations
);
5821 ok(!data
.DSInvocations
, "Got unexpected DSInvocations count: %u.\n", (unsigned int)data
.DSInvocations
);
5822 ok(!data
.CSInvocations
, "Got unexpected CSInvocations count: %u.\n", (unsigned int)data
.CSInvocations
);
5824 ID3D11DeviceContext_Begin(context
, query
);
5825 draw_color_quad(&test_context
, &red
);
5826 ID3D11DeviceContext_End(context
, query
);
5827 get_query_data(context
, query
, &data
, sizeof(data
));
5828 ok(data
.IAVertices
== 4, "Got unexpected IAVertices count: %u.\n", (unsigned int)data
.IAVertices
);
5829 ok(data
.IAPrimitives
== 2, "Got unexpected IAPrimitives count: %u.\n", (unsigned int)data
.IAPrimitives
);
5830 ok(data
.VSInvocations
== 4, "Got unexpected VSInvocations count: %u.\n", (unsigned int)data
.VSInvocations
);
5831 ok(!data
.GSInvocations
, "Got unexpected GSInvocations count: %u.\n", (unsigned int)data
.GSInvocations
);
5832 ok(!data
.GSPrimitives
, "Got unexpected GSPrimitives count: %u.\n", (unsigned int)data
.GSPrimitives
);
5833 ok(data
.CInvocations
== 2, "Got unexpected CInvocations count: %u.\n", (unsigned int)data
.CInvocations
);
5834 ok(data
.CPrimitives
== 2, "Got unexpected CPrimitives count: %u.\n", (unsigned int)data
.CPrimitives
);
5835 ok(data
.PSInvocations
>= 640 * 480, "Got unexpected PSInvocations count: %u.\n", (unsigned int)data
.PSInvocations
);
5836 ok(!data
.HSInvocations
, "Got unexpected HSInvocations count: %u.\n", (unsigned int)data
.HSInvocations
);
5837 ok(!data
.DSInvocations
, "Got unexpected DSInvocations count: %u.\n", (unsigned int)data
.DSInvocations
);
5838 ok(!data
.CSInvocations
, "Got unexpected CSInvocations count: %u.\n", (unsigned int)data
.CSInvocations
);
5840 ID3D11Asynchronous_Release(query
);
5841 release_test_context(&test_context
);
5844 static void test_timestamp_query(void)
5846 static const struct vec4 red
= {1.0f
, 0.0f
, 0.0f
, 1.0f
};
5848 ID3D11Asynchronous
*timestamp_query
, *timestamp_disjoint_query
;
5849 D3D11_QUERY_DATA_TIMESTAMP_DISJOINT disjoint
, prev_disjoint
;
5850 struct d3d11_test_context test_context
;
5851 ID3D11DeviceContext
*context
;
5852 D3D11_QUERY_DESC query_desc
;
5853 unsigned int data_size
;
5854 ID3D11Device
*device
;
5858 if (!init_test_context(&test_context
, NULL
))
5861 device
= test_context
.device
;
5862 context
= test_context
.immediate_context
;
5864 query_desc
.Query
= D3D11_QUERY_TIMESTAMP
;
5865 query_desc
.MiscFlags
= 0;
5866 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, (ID3D11Query
**)×tamp_query
);
5867 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5868 data_size
= ID3D11Asynchronous_GetDataSize(timestamp_query
);
5869 ok(data_size
== sizeof(UINT64
), "Got unexpected data size %u.\n", data_size
);
5871 query_desc
.Query
= D3D11_QUERY_TIMESTAMP_DISJOINT
;
5872 query_desc
.MiscFlags
= 0;
5873 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, (ID3D11Query
**)×tamp_disjoint_query
);
5874 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5875 data_size
= ID3D11Asynchronous_GetDataSize(timestamp_disjoint_query
);
5876 ok(data_size
== sizeof(disjoint
), "Got unexpected data size %u.\n", data_size
);
5878 disjoint
.Frequency
= 0xdeadbeef;
5879 disjoint
.Disjoint
= 0xdeadbeef;
5880 hr
= ID3D11DeviceContext_GetData(context
, timestamp_disjoint_query
, NULL
, 0, 0);
5881 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5882 hr
= ID3D11DeviceContext_GetData(context
, timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
), 0);
5883 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5884 ok(disjoint
.Frequency
== 0xdeadbeef, "Frequency data was modified.\n");
5885 ok(disjoint
.Disjoint
== 0xdeadbeef, "Disjoint data was modified.\n");
5887 /* Test a TIMESTAMP_DISJOINT query. */
5888 ID3D11DeviceContext_Begin(context
, timestamp_disjoint_query
);
5890 disjoint
.Frequency
= 0xdeadbeef;
5891 disjoint
.Disjoint
= 0xdeadbeef;
5892 hr
= ID3D11DeviceContext_GetData(context
, timestamp_disjoint_query
, NULL
, 0, 0);
5893 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5894 hr
= ID3D11DeviceContext_GetData(context
, timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
), 0);
5895 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5896 ok(disjoint
.Frequency
== 0xdeadbeef, "Frequency data was modified.\n");
5897 ok(disjoint
.Disjoint
== 0xdeadbeef, "Disjoint data was modified.\n");
5899 ID3D11DeviceContext_End(context
, timestamp_disjoint_query
);
5900 get_query_data(context
, timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
));
5901 ok(disjoint
.Frequency
!= ~(UINT64
)0, "Frequency data was not modified.\n");
5902 ok(disjoint
.Disjoint
== TRUE
|| disjoint
.Disjoint
== FALSE
, "Got unexpected disjoint %#x.\n", disjoint
.Disjoint
);
5904 prev_disjoint
= disjoint
;
5906 disjoint
.Frequency
= 0xdeadbeef;
5907 disjoint
.Disjoint
= 0xff;
5908 hr
= ID3D11DeviceContext_GetData(context
, timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
) - 1, 0);
5909 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5910 hr
= ID3D11DeviceContext_GetData(context
, timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
) + 1, 0);
5911 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5912 hr
= ID3D11DeviceContext_GetData(context
, timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
) / 2, 0);
5913 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5914 hr
= ID3D11DeviceContext_GetData(context
, timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
) * 2, 0);
5915 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5916 ok(disjoint
.Frequency
== 0xdeadbeef, "Frequency data was modified.\n");
5917 ok(disjoint
.Disjoint
== 0xff, "Disjoint data was modified.\n");
5919 hr
= ID3D11DeviceContext_GetData(context
, timestamp_disjoint_query
, NULL
, 0, 0);
5920 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5921 hr
= ID3D11DeviceContext_GetData(context
, timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
),
5922 D3D11_ASYNC_GETDATA_DONOTFLUSH
);
5923 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5924 ok(disjoint
.Frequency
== prev_disjoint
.Frequency
, "Frequency data mismatch.\n");
5925 ok(disjoint
.Disjoint
== prev_disjoint
.Disjoint
, "Disjoint data mismatch.\n");
5927 memset(×tamp
, 0xff, sizeof(timestamp
));
5928 hr
= ID3D11DeviceContext_GetData(context
, timestamp_query
, NULL
, 0, 0);
5929 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5930 hr
= ID3D11DeviceContext_GetData(context
, timestamp_query
, ×tamp
, sizeof(timestamp
), 0);
5931 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5932 ok(timestamp
== ~(UINT64
)0, "Timestamp data was modified.\n");
5934 /* Test a TIMESTAMP query inside a TIMESTAMP_DISJOINT query. */
5935 ID3D11DeviceContext_Begin(context
, timestamp_disjoint_query
);
5937 memset(×tamp
, 0xff, sizeof(timestamp
));
5938 hr
= ID3D11DeviceContext_GetData(context
, timestamp_query
, ×tamp
, sizeof(timestamp
), 0);
5939 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
5940 ok(timestamp
== ~(UINT64
)0, "Timestamp data was modified.\n");
5942 draw_color_quad(&test_context
, &red
);
5944 ID3D11DeviceContext_End(context
, timestamp_query
);
5945 get_query_data(context
, timestamp_query
, ×tamp
, sizeof(timestamp
));
5947 timestamp
= 0xdeadbeef;
5948 hr
= ID3D11DeviceContext_GetData(context
, timestamp_query
, ×tamp
, sizeof(timestamp
) / 2, 0);
5949 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5950 ok(timestamp
== 0xdeadbeef, "Timestamp was modified.\n");
5952 hr
= ID3D11DeviceContext_GetData(context
, timestamp_query
, ×tamp
, sizeof(timestamp
), 0);
5953 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5954 ok(timestamp
!= 0xdeadbeef, "Timestamp was not modified.\n");
5956 timestamp
= 0xdeadbeef;
5957 hr
= ID3D11DeviceContext_GetData(context
, timestamp_query
, ×tamp
, sizeof(timestamp
) - 1, 0);
5958 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5959 hr
= ID3D11DeviceContext_GetData(context
, timestamp_query
, ×tamp
, sizeof(timestamp
) + 1, 0);
5960 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5961 hr
= ID3D11DeviceContext_GetData(context
, timestamp_query
, ×tamp
, sizeof(timestamp
) / 2, 0);
5962 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5963 hr
= ID3D11DeviceContext_GetData(context
, timestamp_query
, ×tamp
, sizeof(timestamp
) * 2, 0);
5964 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
5965 ok(timestamp
== 0xdeadbeef, "Timestamp was modified.\n");
5967 ID3D11DeviceContext_End(context
, timestamp_disjoint_query
);
5968 get_query_data(context
, timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
));
5969 disjoint
.Frequency
= 0xdeadbeef;
5970 disjoint
.Disjoint
= 0xff;
5971 hr
= ID3D11DeviceContext_GetData(context
, timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
), 0);
5972 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5973 ok(disjoint
.Frequency
!= 0xdeadbeef, "Frequency data was not modified.\n");
5974 ok(disjoint
.Disjoint
== TRUE
|| disjoint
.Disjoint
== FALSE
, "Got unexpected disjoint %#x.\n", disjoint
.Disjoint
);
5976 /* It's not strictly necessary for the TIMESTAMP query to be inside a TIMESTAMP_DISJOINT query. */
5977 ID3D11Asynchronous_Release(timestamp_query
);
5978 query_desc
.Query
= D3D11_QUERY_TIMESTAMP
;
5979 query_desc
.MiscFlags
= 0;
5980 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, (ID3D11Query
**)×tamp_query
);
5981 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5983 draw_color_quad(&test_context
, &red
);
5985 ID3D11DeviceContext_End(context
, timestamp_query
);
5986 get_query_data(context
, timestamp_query
, ×tamp
, sizeof(timestamp
));
5988 ID3D11Asynchronous_Release(timestamp_query
);
5989 ID3D11Asynchronous_Release(timestamp_disjoint_query
);
5990 release_test_context(&test_context
);
5993 static void test_so_statistics_query(void)
5995 struct d3d11_test_context test_context
;
5996 D3D11_QUERY_DATA_SO_STATISTICS data
;
5997 ID3D11DeviceContext
*context
;
5998 unsigned int vertex_count
[4];
5999 D3D11_QUERY_DESC query_desc
;
6000 ID3D11Buffer
*so_buffer
[4];
6001 ID3D11Asynchronous
*query
;
6002 ID3D11GeometryShader
*gs
;
6003 ID3D11VertexShader
*vs
;
6004 unsigned int data_size
;
6005 ID3D11Device
*device
;
6010 static const DWORD vs_code
[] =
6013 float4
main(uint id
: SV_VertexID
) : custom
6018 0x43425844, 0x8b0e47b9, 0x6efc9512, 0xd55ca6ff, 0x487c5ef2, 0x00000001, 0x000000d4, 0x00000003,
6019 0x0000002c, 0x00000060, 0x00000090, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
6020 0x00000000, 0x00000006, 0x00000001, 0x00000000, 0x00000101, 0x565f5653, 0x65747265, 0x00444978,
6021 0x4e47534f, 0x00000028, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
6022 0x00000000, 0x0000000f, 0x74737563, 0xab006d6f, 0x52444853, 0x0000003c, 0x00010040, 0x0000000f,
6023 0x04000060, 0x00101012, 0x00000000, 0x00000006, 0x03000065, 0x001020f2, 0x00000000, 0x05000056,
6024 0x001020f2, 0x00000000, 0x00101006, 0x00000000, 0x0100003e,
6026 static const DWORD gs_code
[] =
6031 float4 data
: custom
;
6036 [maxvertexcount(32)]
6037 void main(point vertex input
[1], uint id
: SV_PrimitiveID
,
6038 inout PointStream
<vertex
> output0
,
6039 inout PointStream
<vertex
> output1
,
6040 inout PointStream
<vertex
> output2
,
6041 inout PointStream
<vertex
> output3
)
6043 if (id
< vertex_count
.x
)
6044 output0
.Append(input
[0]);
6045 if (id
< vertex_count
.y
)
6046 output1
.Append(input
[0]);
6047 if (id
< vertex_count
.z
)
6048 output2
.Append(input
[0]);
6049 if (id
< vertex_count
.w
)
6050 output3
.Append(input
[0]);
6053 0x43425844, 0xd616829d, 0x4355ce2a, 0xd71909e5, 0xdc916d4c, 0x00000001, 0x000002bc, 0x00000003,
6054 0x0000002c, 0x00000084, 0x0000010c, 0x4e475349, 0x00000050, 0x00000002, 0x00000008, 0x00000038,
6055 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x0000003f, 0x00000000, 0x00000007,
6056 0x00000001, 0xffffffff, 0x00000101, 0x74737563, 0x53006d6f, 0x72505f56, 0x74696d69, 0x49657669,
6057 0xabab0044, 0x3547534f, 0x00000080, 0x00000004, 0x00000008, 0x00000000, 0x00000078, 0x00000000,
6058 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x00000001, 0x00000078, 0x00000000, 0x00000000,
6059 0x00000003, 0x00000000, 0x0000000f, 0x00000002, 0x00000078, 0x00000000, 0x00000000, 0x00000003,
6060 0x00000000, 0x0000000f, 0x00000003, 0x00000078, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
6061 0x0000000f, 0x74737563, 0xab006d6f, 0x58454853, 0x000001a8, 0x00020050, 0x0000006a, 0x0100086a,
6062 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0400005f, 0x002010f2, 0x00000001, 0x00000000,
6063 0x0200005f, 0x0000b000, 0x02000068, 0x00000001, 0x0100085d, 0x0300008f, 0x00110000, 0x00000000,
6064 0x0100085c, 0x03000065, 0x001020f2, 0x00000000, 0x0300008f, 0x00110000, 0x00000001, 0x0100085c,
6065 0x03000065, 0x001020f2, 0x00000000, 0x0300008f, 0x00110000, 0x00000002, 0x0100085c, 0x03000065,
6066 0x001020f2, 0x00000000, 0x0300008f, 0x00110000, 0x00000003, 0x0100085c, 0x03000065, 0x001020f2,
6067 0x00000000, 0x0200005e, 0x00000020, 0x0700004f, 0x001000f2, 0x00000000, 0x0000b001, 0x00208e46,
6068 0x00000000, 0x00000000, 0x0304001f, 0x0010000a, 0x00000000, 0x06000036, 0x001020f2, 0x00000000,
6069 0x00201e46, 0x00000000, 0x00000000, 0x03000075, 0x00110000, 0x00000000, 0x01000015, 0x0304001f,
6070 0x0010001a, 0x00000000, 0x06000036, 0x001020f2, 0x00000000, 0x00201e46, 0x00000000, 0x00000000,
6071 0x03000075, 0x00110000, 0x00000001, 0x01000015, 0x0304001f, 0x0010002a, 0x00000000, 0x06000036,
6072 0x001020f2, 0x00000000, 0x00201e46, 0x00000000, 0x00000000, 0x03000075, 0x00110000, 0x00000002,
6073 0x01000015, 0x0304001f, 0x0010003a, 0x00000000, 0x06000036, 0x001020f2, 0x00000000, 0x00201e46,
6074 0x00000000, 0x00000000, 0x03000075, 0x00110000, 0x00000003, 0x01000015, 0x0100003e,
6076 static const D3D11_SO_DECLARATION_ENTRY so_declaration
[] =
6078 {0, "custom", 0, 0, 4, 0},
6079 {1, "custom", 0, 0, 4, 1},
6080 {2, "custom", 0, 0, 4, 2},
6081 {3, "custom", 0, 0, 4, 3},
6083 static const unsigned int offset
[4] = {0};
6088 D3D_FEATURE_LEVEL feature_level
;
6092 {D3D11_QUERY_SO_STATISTICS
, D3D_FEATURE_LEVEL_10_0
},
6093 {D3D11_QUERY_SO_STATISTICS_STREAM0
, D3D_FEATURE_LEVEL_11_0
},
6094 {D3D11_QUERY_SO_STATISTICS_STREAM1
, D3D_FEATURE_LEVEL_11_0
},
6095 {D3D11_QUERY_SO_STATISTICS_STREAM2
, D3D_FEATURE_LEVEL_11_0
},
6096 {D3D11_QUERY_SO_STATISTICS_STREAM3
, D3D_FEATURE_LEVEL_11_0
},
6099 if (!init_test_context(&test_context
, NULL
))
6102 device
= test_context
.device
;
6103 context
= test_context
.immediate_context
;
6105 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
6107 if (ID3D11Device_GetFeatureLevel(device
) < tests
[i
].feature_level
)
6109 skip("Feature level %#x is required.\n", tests
[i
].feature_level
);
6113 query_desc
.Query
= tests
[i
].query
;
6114 query_desc
.MiscFlags
= 0;
6115 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, (ID3D11Query
**)&query
);
6116 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6117 data_size
= ID3D11Asynchronous_GetDataSize(query
);
6118 ok(data_size
== sizeof(data
), "Got unexpected data size %u.\n", data_size
);
6120 hr
= ID3D11DeviceContext_GetData(context
, query
, NULL
, 0, 0);
6121 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
6122 hr
= ID3D11DeviceContext_GetData(context
, query
, &data
, sizeof(data
), 0);
6123 ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
6125 ID3D11DeviceContext_End(context
, query
);
6126 ID3D11DeviceContext_Begin(context
, query
);
6127 ID3D11DeviceContext_Begin(context
, query
);
6129 memset(&data
, 0xff, sizeof(data
));
6130 hr
= ID3D11DeviceContext_GetData(context
, query
, NULL
, 0, 0);
6131 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
6132 hr
= ID3D11DeviceContext_GetData(context
, query
, &data
, sizeof(data
), 0);
6133 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
6134 ok(data
.NumPrimitivesWritten
== ~(UINT64
)0, "Data was modified.\n");
6135 ok(data
.PrimitivesStorageNeeded
== ~(UINT64
)0, "Data was modified.\n");
6137 draw_quad(&test_context
);
6139 ID3D11DeviceContext_End(context
, query
);
6140 get_query_data(context
, query
, &data
, sizeof(data
));
6141 ok(!data
.NumPrimitivesWritten
, "Got unexpected NumPrimitivesWritten: %u.\n",
6142 (unsigned int)data
.NumPrimitivesWritten
);
6143 todo_wine_if(query_desc
.Query
== D3D11_QUERY_SO_STATISTICS
|| query_desc
.Query
== D3D11_QUERY_SO_STATISTICS_STREAM0
)
6144 ok(!data
.PrimitivesStorageNeeded
, "Got unexpected PrimitivesStorageNeeded: %u.\n",
6145 (unsigned int)data
.PrimitivesStorageNeeded
);
6147 ID3D11DeviceContext_Begin(context
, query
);
6148 draw_quad(&test_context
);
6149 ID3D11DeviceContext_End(context
, query
);
6150 get_query_data(context
, query
, &data
, sizeof(data
));
6151 ok(!data
.NumPrimitivesWritten
, "Got unexpected NumPrimitivesWritten: %u.\n",
6152 (unsigned int)data
.NumPrimitivesWritten
);
6153 todo_wine_if(query_desc
.Query
== D3D11_QUERY_SO_STATISTICS
|| query_desc
.Query
== D3D11_QUERY_SO_STATISTICS_STREAM0
)
6154 ok(!data
.PrimitivesStorageNeeded
, "Got unexpected PrimitivesStorageNeeded: %u.\n",
6155 (unsigned int)data
.PrimitivesStorageNeeded
);
6157 ID3D11Asynchronous_Release(query
);
6160 if (ID3D11Device_GetFeatureLevel(device
) < D3D_FEATURE_LEVEL_11_0
)
6162 skip("Vertex streams are not supported.\n");
6166 /* multiple vertex streams */
6167 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
6168 ok(hr
== S_OK
, "Failed to create vertex shader, hr %#x.\n", hr
);
6169 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
6171 hr
= ID3D11Device_CreateGeometryShaderWithStreamOutput(device
, gs_code
, sizeof(gs_code
),
6172 so_declaration
, ARRAY_SIZE(so_declaration
),
6173 NULL
, 0, D3D11_SO_NO_RASTERIZED_STREAM
, NULL
, &gs
);
6175 ok(hr
== S_OK
, "Failed to create geometry shader with stream output, hr %#x.\n", hr
);
6178 ID3D11VertexShader_Release(vs
);
6181 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
6183 for (i
= 0; i
< ARRAY_SIZE(vertex_count
); ++i
)
6184 vertex_count
[i
] = 5;
6185 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(vertex_count
), vertex_count
);
6186 ID3D11DeviceContext_GSSetConstantBuffers(context
, 0, 1, &cb
);
6188 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST
);
6190 query_desc
.Query
= D3D11_QUERY_SO_STATISTICS
;
6191 query_desc
.MiscFlags
= 0;
6192 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, (ID3D11Query
**)&query
);
6193 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6195 ID3D11DeviceContext_Begin(context
, query
);
6196 ID3D11DeviceContext_Draw(context
, 5, 0);
6197 ID3D11DeviceContext_End(context
, query
);
6199 memset(&data
, 0xff, sizeof(data
));
6200 get_query_data(context
, query
, &data
, sizeof(data
));
6201 ok(!data
.NumPrimitivesWritten
, "Got unexpected primitives written %u.\n",
6202 (unsigned int)data
.NumPrimitivesWritten
);
6203 ok(data
.PrimitivesStorageNeeded
== 5, "Got unexpected primitives storage needed %u.\n",
6204 (unsigned int)data
.PrimitivesStorageNeeded
);
6206 for (i
= 0; i
< ARRAY_SIZE(so_buffer
); ++i
)
6207 so_buffer
[i
] = create_buffer(device
, D3D11_BIND_STREAM_OUTPUT
, sizeof(struct vec4
) * 10, NULL
);
6209 ID3D11DeviceContext_SOSetTargets(context
, D3D11_SO_BUFFER_SLOT_COUNT
, so_buffer
, offset
);
6210 ID3D11DeviceContext_Begin(context
, query
);
6211 ID3D11DeviceContext_Draw(context
, 16, 0);
6212 ID3D11DeviceContext_End(context
, query
);
6213 memset(&data
, 0xff, sizeof(data
));
6214 get_query_data(context
, query
, &data
, sizeof(data
));
6215 ok(data
.NumPrimitivesWritten
== 5, "Got unexpected primitives written %u.\n",
6216 (unsigned int)data
.NumPrimitivesWritten
);
6217 ok(data
.PrimitivesStorageNeeded
== 5, "Got unexpected primitives storage needed %u.\n",
6218 (unsigned int)data
.PrimitivesStorageNeeded
);
6220 vertex_count
[0] = 3;
6221 vertex_count
[1] = 6;
6222 vertex_count
[2] = 4;
6223 vertex_count
[3] = 12;
6224 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, vertex_count
, 0, 0);
6226 ID3D11DeviceContext_SOSetTargets(context
, D3D11_SO_BUFFER_SLOT_COUNT
, so_buffer
, offset
);
6227 ID3D11DeviceContext_Begin(context
, query
);
6228 ID3D11DeviceContext_Draw(context
, 32, 0);
6229 ID3D11DeviceContext_End(context
, query
);
6230 memset(&data
, 0xff, sizeof(data
));
6231 get_query_data(context
, query
, &data
, sizeof(data
));
6232 ok(data
.NumPrimitivesWritten
== 3, "Got unexpected primitives written %u.\n",
6233 (unsigned int)data
.NumPrimitivesWritten
);
6234 ok(data
.PrimitivesStorageNeeded
== 3, "Got unexpected primitives storage needed %u.\n",
6235 (unsigned int)data
.PrimitivesStorageNeeded
);
6237 vertex_count
[0] = 16;
6238 vertex_count
[1] = 6;
6239 vertex_count
[2] = 4;
6240 vertex_count
[3] = 12;
6241 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, vertex_count
, 0, 0);
6243 ID3D11DeviceContext_SOSetTargets(context
, D3D11_SO_BUFFER_SLOT_COUNT
, so_buffer
, offset
);
6244 ID3D11DeviceContext_Begin(context
, query
);
6245 ID3D11DeviceContext_Draw(context
, 32, 0);
6246 ID3D11DeviceContext_End(context
, query
);
6247 memset(&data
, 0xff, sizeof(data
));
6248 get_query_data(context
, query
, &data
, sizeof(data
));
6249 ok(data
.NumPrimitivesWritten
== 10, "Got unexpected primitives written %u.\n",
6250 (unsigned int)data
.NumPrimitivesWritten
);
6251 ok(data
.PrimitivesStorageNeeded
== 16, "Got unexpected primitives storage needed %u.\n",
6252 (unsigned int)data
.PrimitivesStorageNeeded
);
6254 ID3D11Asynchronous_Release(query
);
6256 for (i
= 0; i
< ARRAY_SIZE(so_buffer
); ++i
)
6257 ID3D11Buffer_Release(so_buffer
[i
]);
6258 ID3D11Buffer_Release(cb
);
6259 ID3D11GeometryShader_Release(gs
);
6260 ID3D11VertexShader_Release(vs
);
6263 release_test_context(&test_context
);
6266 static void test_device_removed_reason(void)
6268 ID3D11Device
*device
;
6272 if (!(device
= create_device(NULL
)))
6274 skip("Failed to create device.\n");
6278 hr
= ID3D11Device_GetDeviceRemovedReason(device
);
6279 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6280 hr
= ID3D11Device_GetDeviceRemovedReason(device
);
6281 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6283 refcount
= ID3D11Device_Release(device
);
6284 ok(!refcount
, "Device has %u references left.\n", refcount
);
6287 static void test_private_data(void)
6289 ULONG refcount
, expected_refcount
;
6290 D3D11_TEXTURE2D_DESC texture_desc
;
6291 ID3D10Texture2D
*d3d10_texture
;
6292 ID3D11Device
*test_object
;
6293 ID3D11Texture2D
*texture
;
6294 IDXGIDevice
*dxgi_device
;
6295 IDXGISurface
*surface
;
6296 ID3D11Device
*device
;
6301 static const GUID test_guid
=
6302 {0xfdb37466, 0x428f, 0x4edf, {0xa3, 0x7f, 0x9b, 0x1d, 0xf4, 0x88, 0xc5, 0xfc}};
6303 static const GUID test_guid2
=
6304 {0x2e5afac2, 0x87b5, 0x4c10, {0x9b, 0x4b, 0x89, 0xd7, 0xd1, 0x12, 0xe7, 0x2b}};
6305 static const DWORD data
[] = {1, 2, 3, 4};
6307 if (!(device
= create_device(NULL
)))
6309 skip("Failed to create device.\n");
6313 test_object
= create_device(NULL
);
6315 texture_desc
.Width
= 512;
6316 texture_desc
.Height
= 512;
6317 texture_desc
.MipLevels
= 1;
6318 texture_desc
.ArraySize
= 1;
6319 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
6320 texture_desc
.SampleDesc
.Count
= 1;
6321 texture_desc
.SampleDesc
.Quality
= 0;
6322 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
6323 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
6324 texture_desc
.CPUAccessFlags
= 0;
6325 texture_desc
.MiscFlags
= 0;
6327 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
6328 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
6329 hr
= ID3D11Texture2D_QueryInterface(texture
, &IID_IDXGISurface
, (void **)&surface
);
6330 ok(SUCCEEDED(hr
), "Failed to get IDXGISurface, hr %#x.\n", hr
);
6332 hr
= ID3D11Device_SetPrivateData(device
, &test_guid
, 0, NULL
);
6333 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
6334 hr
= ID3D11Device_SetPrivateDataInterface(device
, &test_guid
, NULL
);
6335 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6336 hr
= ID3D11Device_SetPrivateData(device
, &test_guid
, ~0u, NULL
);
6337 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6338 hr
= ID3D11Device_SetPrivateData(device
, &test_guid
, ~0u, NULL
);
6339 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
6341 hr
= ID3D11Device_SetPrivateDataInterface(device
, &test_guid
, NULL
);
6342 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6343 size
= sizeof(ptr
) * 2;
6344 ptr
= (IUnknown
*)0xdeadbeef;
6345 hr
= ID3D11Device_GetPrivateData(device
, &test_guid
, &size
, &ptr
);
6346 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6347 ok(!ptr
, "Got unexpected pointer %p.\n", ptr
);
6348 ok(size
== sizeof(IUnknown
*), "Got unexpected size %u.\n", size
);
6350 hr
= ID3D11Device_QueryInterface(device
, &IID_IDXGIDevice
, (void **)&dxgi_device
);
6351 ok(SUCCEEDED(hr
), "Failed to get DXGI device, hr %#x.\n", hr
);
6352 size
= sizeof(ptr
) * 2;
6353 ptr
= (IUnknown
*)0xdeadbeef;
6354 hr
= IDXGIDevice_GetPrivateData(dxgi_device
, &test_guid
, &size
, &ptr
);
6355 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6356 ok(!ptr
, "Got unexpected pointer %p.\n", ptr
);
6357 ok(size
== sizeof(IUnknown
*), "Got unexpected size %u.\n", size
);
6358 IDXGIDevice_Release(dxgi_device
);
6360 refcount
= get_refcount(test_object
);
6361 hr
= ID3D11Device_SetPrivateDataInterface(device
, &test_guid
, (IUnknown
*)test_object
);
6362 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6363 expected_refcount
= refcount
+ 1;
6364 refcount
= get_refcount(test_object
);
6365 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
6366 hr
= ID3D11Device_SetPrivateDataInterface(device
, &test_guid
, (IUnknown
*)test_object
);
6367 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6368 refcount
= get_refcount(test_object
);
6369 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
6371 hr
= ID3D11Device_SetPrivateDataInterface(device
, &test_guid
, NULL
);
6372 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6373 --expected_refcount
;
6374 refcount
= get_refcount(test_object
);
6375 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
6377 hr
= ID3D11Device_SetPrivateDataInterface(device
, &test_guid
, (IUnknown
*)test_object
);
6378 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6379 size
= sizeof(data
);
6380 hr
= ID3D11Device_SetPrivateData(device
, &test_guid
, size
, data
);
6381 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6382 refcount
= get_refcount(test_object
);
6383 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
6384 hr
= ID3D11Device_SetPrivateData(device
, &test_guid
, 42, NULL
);
6385 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6386 hr
= ID3D11Device_SetPrivateData(device
, &test_guid
, 42, NULL
);
6387 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
6389 hr
= ID3D11Device_SetPrivateDataInterface(device
, &test_guid
, (IUnknown
*)test_object
);
6390 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6391 ++expected_refcount
;
6392 size
= 2 * sizeof(ptr
);
6394 hr
= ID3D11Device_GetPrivateData(device
, &test_guid
, &size
, &ptr
);
6395 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6396 ok(size
== sizeof(test_object
), "Got unexpected size %u.\n", size
);
6397 ++expected_refcount
;
6398 refcount
= get_refcount(test_object
);
6399 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
6400 IUnknown_Release(ptr
);
6401 --expected_refcount
;
6403 ptr
= (IUnknown
*)0xdeadbeef;
6405 hr
= ID3D11Device_GetPrivateData(device
, &test_guid
, &size
, NULL
);
6406 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6407 ok(size
== sizeof(device
), "Got unexpected size %u.\n", size
);
6408 size
= 2 * sizeof(ptr
);
6409 hr
= ID3D11Device_GetPrivateData(device
, &test_guid
, &size
, NULL
);
6410 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6411 ok(size
== sizeof(device
), "Got unexpected size %u.\n", size
);
6412 refcount
= get_refcount(test_object
);
6413 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
6416 hr
= ID3D11Device_GetPrivateData(device
, &test_guid
, &size
, &ptr
);
6417 ok(hr
== DXGI_ERROR_MORE_DATA
, "Got unexpected hr %#x.\n", hr
);
6418 ok(size
== sizeof(device
), "Got unexpected size %u.\n", size
);
6419 ok(ptr
== (IUnknown
*)0xdeadbeef, "Got unexpected pointer %p.\n", ptr
);
6420 if (!enable_debug_layer
)
6422 hr
= ID3D11Device_GetPrivateData(device
, &test_guid2
, NULL
, NULL
);
6423 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
6425 hr
= ID3D11Device_GetPrivateData(device
, &test_guid2
, &size
, &ptr
);
6426 ok(hr
== DXGI_ERROR_NOT_FOUND
, "Got unexpected hr %#x.\n", hr
);
6427 ok(size
== 0, "Got unexpected size %u.\n", size
);
6428 ok(ptr
== (IUnknown
*)0xdeadbeef, "Got unexpected pointer %p.\n", ptr
);
6429 hr
= ID3D11Device_GetPrivateData(device
, &test_guid
, NULL
, &ptr
);
6430 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
6431 ok(ptr
== (IUnknown
*)0xdeadbeef, "Got unexpected pointer %p.\n", ptr
);
6434 hr
= ID3D11Texture2D_SetPrivateDataInterface(texture
, &test_guid
, (IUnknown
*)test_object
);
6435 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6438 hr
= IDXGISurface_GetPrivateData(surface
, &test_guid
, &size
, &ptr
);
6439 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6440 ok(ptr
== (IUnknown
*)test_object
, "Got unexpected ptr %p, expected %p.\n", ptr
, test_object
);
6441 IUnknown_Release(ptr
);
6443 hr
= ID3D11Texture2D_QueryInterface(texture
, &IID_ID3D10Texture2D
, (void **)&d3d10_texture
);
6444 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
6445 "Texture should implement ID3D10Texture2D.\n");
6450 hr
= ID3D10Texture2D_GetPrivateData(d3d10_texture
, &test_guid
, &size
, &ptr
);
6451 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6452 ok(ptr
== (IUnknown
*)test_object
, "Got unexpected ptr %p, expected %p.\n", ptr
, test_object
);
6453 IUnknown_Release(ptr
);
6454 ID3D10Texture2D_Release(d3d10_texture
);
6457 IDXGISurface_Release(surface
);
6458 ID3D11Texture2D_Release(texture
);
6459 refcount
= ID3D11Device_Release(device
);
6460 ok(!refcount
, "Device has %u references left.\n", refcount
);
6461 refcount
= ID3D11Device_Release(test_object
);
6462 ok(!refcount
, "Test object has %u references left.\n", refcount
);
6465 static void test_state_refcounting(const D3D_FEATURE_LEVEL feature_level
)
6467 ID3D11RasterizerState
*rasterizer_state
, *tmp_rasterizer_state
;
6468 ID3D11Predicate
*predicate
, *tmp_predicate
;
6469 ID3D11SamplerState
*sampler
, *tmp_sampler
;
6470 ID3D11ShaderResourceView
*srv
, *tmp_srv
;
6471 ID3D11RenderTargetView
*rtv
, *tmp_rtv
;
6472 D3D11_RASTERIZER_DESC rasterizer_desc
;
6473 D3D11_TEXTURE2D_DESC texture_desc
;
6474 D3D11_QUERY_DESC predicate_desc
;
6475 D3D11_SAMPLER_DESC sampler_desc
;
6476 struct device_desc device_desc
;
6477 ID3D11DeviceContext
*context
;
6478 ID3D11Texture2D
*texture
;
6479 ID3D11Device
*device
;
6483 device_desc
.feature_level
= &feature_level
;
6484 device_desc
.flags
= 0;
6485 if (!(device
= create_device(&device_desc
)))
6487 skip("Failed to create device for feature level %#x.\n", feature_level
);
6491 ID3D11Device_GetImmediateContext(device
, &context
);
6493 /* ID3D11SamplerState */
6494 memset(&sampler_desc
, 0, sizeof(sampler_desc
));
6495 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_LINEAR
;
6496 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_WRAP
;
6497 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_WRAP
;
6498 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_WRAP
;
6499 sampler_desc
.MaxLOD
= FLT_MAX
;
6500 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler
);
6501 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
6503 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &tmp_sampler
);
6504 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
6505 ok(tmp_sampler
== sampler
, "Got sampler %p, expected %p.\n", tmp_sampler
, sampler
);
6506 ID3D11SamplerState_Release(tmp_sampler
);
6508 tmp_sampler
= sampler
;
6509 refcount
= get_refcount(sampler
);
6510 ok(refcount
== 1, "Got refcount %u, expected 1.\n", refcount
);
6511 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler
);
6512 refcount
= ID3D11SamplerState_Release(sampler
);
6513 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6515 ID3D11DeviceContext_PSGetSamplers(context
, 0, 1, &sampler
);
6516 ok(sampler
== tmp_sampler
, "Got sampler %p, expected %p.\n", sampler
, tmp_sampler
);
6517 refcount
= ID3D11SamplerState_Release(sampler
);
6518 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6520 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &tmp_sampler
);
6521 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
6522 ok(tmp_sampler
== sampler
, "Got sampler %p, expected %p.\n", tmp_sampler
, sampler
);
6523 refcount
= ID3D11SamplerState_Release(tmp_sampler
);
6524 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6526 /* ID3D11RasterizerState */
6527 memset(&rasterizer_desc
, 0, sizeof(rasterizer_desc
));
6528 rasterizer_desc
.FillMode
= D3D11_FILL_SOLID
;
6529 rasterizer_desc
.CullMode
= D3D11_CULL_BACK
;
6530 rasterizer_desc
.DepthClipEnable
= TRUE
;
6531 hr
= ID3D11Device_CreateRasterizerState(device
, &rasterizer_desc
, &rasterizer_state
);
6532 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
6534 ID3D11DeviceContext_RSSetState(context
, rasterizer_state
);
6535 refcount
= ID3D11RasterizerState_Release(rasterizer_state
);
6536 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6537 ID3D11DeviceContext_RSGetState(context
, &tmp_rasterizer_state
);
6538 ok(tmp_rasterizer_state
== rasterizer_state
, "Got rasterizer state %p, expected %p.\n",
6539 tmp_rasterizer_state
, rasterizer_state
);
6540 refcount
= ID3D11RasterizerState_Release(tmp_rasterizer_state
);
6541 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6543 /* ID3D11ShaderResourceView */
6544 memset(&texture_desc
, 0, sizeof(texture_desc
));
6545 texture_desc
.Width
= 32;
6546 texture_desc
.Height
= 32;
6547 texture_desc
.MipLevels
= 1;
6548 texture_desc
.ArraySize
= 1;
6549 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
6550 texture_desc
.SampleDesc
.Count
= 1;
6551 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
6552 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
6553 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
6554 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
6555 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
6556 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
6557 ID3D11Texture2D_Release(texture
);
6559 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
6560 refcount
= ID3D11ShaderResourceView_Release(srv
);
6561 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6562 ID3D11DeviceContext_PSGetShaderResources(context
, 0, 1, &tmp_srv
);
6563 ok(tmp_srv
== srv
, "Got SRV %p, expected %p.\n", tmp_srv
, srv
);
6564 refcount
= ID3D11ShaderResourceView_Release(tmp_srv
);
6565 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6567 /* ID3D11RenderTargetView */
6568 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
6569 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
6570 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
6571 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
6572 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
6573 ID3D11Texture2D_Release(texture
);
6575 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
6576 refcount
= ID3D11RenderTargetView_Release(rtv
);
6577 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6578 ID3D11DeviceContext_OMGetRenderTargets(context
, 1, &tmp_rtv
, NULL
);
6579 ok(tmp_rtv
== rtv
, "Got RTV %p, expected %p.\n", tmp_rtv
, rtv
);
6580 refcount
= ID3D11RenderTargetView_Release(tmp_rtv
);
6581 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6583 /* ID3D11Predicate */
6584 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
6586 predicate_desc
.Query
= D3D11_QUERY_OCCLUSION_PREDICATE
;
6587 predicate_desc
.MiscFlags
= 0;
6588 hr
= ID3D11Device_CreatePredicate(device
, &predicate_desc
, &predicate
);
6589 ok(SUCCEEDED(hr
), "Failed to create predicate, hr %#x.\n", hr
);
6591 ID3D11DeviceContext_SetPredication(context
, predicate
, TRUE
);
6592 refcount
= ID3D11Predicate_Release(predicate
);
6593 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6594 ID3D11DeviceContext_GetPredication(context
, &tmp_predicate
, NULL
);
6595 ok(tmp_predicate
== predicate
, "Got predicate %p, expected %p.\n", tmp_predicate
, predicate
);
6596 refcount
= ID3D11Predicate_Release(tmp_predicate
);
6597 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
6600 ID3D11DeviceContext_Release(context
);
6601 refcount
= ID3D11Device_Release(device
);
6602 ok(!refcount
, "Device has %u references left.\n", refcount
);
6605 static void test_device_context_state(void)
6607 static const GUID test_guid
=
6608 {0xfdb37466, 0x428f, 0x4edf, {0xa3, 0x7f, 0x9b, 0x1d, 0xf4, 0x88, 0xc5, 0xfc}};
6609 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
6611 {"POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
6613 static const float custom_blend_factor
[] = {0.1f
, 0.2f
, 0.3f
, 0.4f
};
6614 static const float default_blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
6616 float4
main(float4 pos
: POSITION
) : POSITION
6621 static const DWORD simple_vs
[] =
6623 0x43425844, 0x66689e7c, 0x643f0971, 0xb7f67ff4, 0xabc48688, 0x00000001, 0x000000d4, 0x00000003,
6624 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
6625 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
6626 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
6627 0x00000000, 0x0000000f, 0x49534f50, 0x4e4f4954, 0xababab00, 0x52444853, 0x00000038, 0x00010040,
6628 0x0000000e, 0x0300005f, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
6629 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
6634 float4 position
: SV_Position
;
6637 struct patch_constant_data
6639 float edges
[3] : SV_TessFactor
;
6640 float inside
: SV_InsideTessFactor
;
6643 void patch_constant(InputPatch
<data
, 3> input
, out patch_constant_data output
)
6645 output
.edges
[0] = output
.edges
[1] = output
.edges
[2] = 1.0f
;
6646 output
.inside
= 1.0f
;
6650 [outputcontrolpoints(3)]
6651 [partitioning("integer")]
6652 [outputtopology("triangle_ccw")]
6653 [patchconstantfunc("patch_constant")]
6654 data
hs_main(InputPatch
<data
, 3> input
, uint i
: SV_OutputControlPointID
)
6660 void ds_main(patch_constant_data input
,
6661 float3 tess_coord
: SV_DomainLocation
,
6662 const OutputPatch
<data
, 3> patch
,
6665 output
.position
= tess_coord
.x
* patch
[0].position
6666 + tess_coord
.y
* patch
[1].position
6667 + tess_coord
.z
* patch
[2].position
;
6670 static const DWORD simple_hs
[] =
6672 0x43425844, 0x42b5df25, 0xfd8aa2b1, 0xbe5490cb, 0xb595f8b1, 0x00000001, 0x0000020c, 0x00000004,
6673 0x00000030, 0x00000064, 0x00000098, 0x0000012c, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008,
6674 0x00000020, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x7469736f,
6675 0x006e6f69, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
6676 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69, 0x47534350, 0x0000008c,
6677 0x00000004, 0x00000008, 0x00000068, 0x00000000, 0x0000000d, 0x00000003, 0x00000000, 0x00000e01,
6678 0x00000068, 0x00000001, 0x0000000d, 0x00000003, 0x00000001, 0x00000e01, 0x00000068, 0x00000002,
6679 0x0000000d, 0x00000003, 0x00000002, 0x00000e01, 0x00000076, 0x00000000, 0x0000000e, 0x00000003,
6680 0x00000003, 0x00000e01, 0x545f5653, 0x46737365, 0x6f746361, 0x56530072, 0x736e495f, 0x54656469,
6681 0x46737365, 0x6f746361, 0xabab0072, 0x58454853, 0x000000d8, 0x00030050, 0x00000036, 0x01000071,
6682 0x01001893, 0x01001894, 0x01001095, 0x01000896, 0x01002097, 0x0100086a, 0x01000073, 0x02000099,
6683 0x00000003, 0x0200005f, 0x00017000, 0x04000067, 0x00102012, 0x00000000, 0x00000011, 0x04000067,
6684 0x00102012, 0x00000001, 0x00000012, 0x04000067, 0x00102012, 0x00000002, 0x00000013, 0x02000068,
6685 0x00000001, 0x0400005b, 0x00102012, 0x00000000, 0x00000003, 0x04000036, 0x00100012, 0x00000000,
6686 0x0001700a, 0x06000036, 0x00902012, 0x0010000a, 0x00000000, 0x00004001, 0x3f800000, 0x0100003e,
6687 0x01000073, 0x04000067, 0x00102012, 0x00000003, 0x00000014, 0x05000036, 0x00102012, 0x00000003,
6688 0x00004001, 0x3f800000, 0x0100003e,
6690 static const DWORD simple_ds
[] =
6692 0x43425844, 0xb7e35b82, 0x1b930ff2, 0x48d3a0f2, 0x375219ed, 0x00000001, 0x000001e0, 0x00000004,
6693 0x00000030, 0x00000064, 0x000000f8, 0x0000012c, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008,
6694 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x7469736f,
6695 0x006e6f69, 0x47534350, 0x0000008c, 0x00000004, 0x00000008, 0x00000068, 0x00000000, 0x0000000d,
6696 0x00000003, 0x00000000, 0x00000001, 0x00000068, 0x00000001, 0x0000000d, 0x00000003, 0x00000001,
6697 0x00000001, 0x00000068, 0x00000002, 0x0000000d, 0x00000003, 0x00000002, 0x00000001, 0x00000076,
6698 0x00000000, 0x0000000e, 0x00000003, 0x00000003, 0x00000001, 0x545f5653, 0x46737365, 0x6f746361,
6699 0x56530072, 0x736e495f, 0x54656469, 0x46737365, 0x6f746361, 0xabab0072, 0x4e47534f, 0x0000002c,
6700 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
6701 0x505f5653, 0x7469736f, 0x006e6f69, 0x58454853, 0x000000ac, 0x00040050, 0x0000002b, 0x01001893,
6702 0x01001095, 0x0100086a, 0x0200005f, 0x0001c072, 0x0400005f, 0x002190f2, 0x00000003, 0x00000000,
6703 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x02000068, 0x00000001, 0x07000038, 0x001000f2,
6704 0x00000000, 0x0001c556, 0x00219e46, 0x00000001, 0x00000000, 0x09000032, 0x001000f2, 0x00000000,
6705 0x0001c006, 0x00219e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000, 0x09000032, 0x001020f2,
6706 0x00000000, 0x0001caa6, 0x00219e46, 0x00000002, 0x00000000, 0x00100e46, 0x00000000, 0x0100003e,
6711 float4 pos
: SV_POSITION
;
6715 void main(point float4 vin
[1] : POSITION
, inout TriangleStream
<gs_out
> vout
)
6717 float offset
= 0.1 * vin
[0].w
;
6720 v
.pos
= float4(vin
[0].x
- offset
, vin
[0].y
- offset
, vin
[0].z
, vin
[0].w
);
6722 v
.pos
= float4(vin
[0].x
- offset
, vin
[0].y
+ offset
, vin
[0].z
, vin
[0].w
);
6724 v
.pos
= float4(vin
[0].x
+ offset
, vin
[0].y
- offset
, vin
[0].z
, vin
[0].w
);
6726 v
.pos
= float4(vin
[0].x
+ offset
, vin
[0].y
+ offset
, vin
[0].z
, vin
[0].w
);
6730 static const DWORD simple_gs
[] =
6732 0x43425844, 0x000ee786, 0xc624c269, 0x885a5cbe, 0x444b3b1f, 0x00000001, 0x0000023c, 0x00000003,
6733 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
6734 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
6735 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
6736 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x000001a0, 0x00020040,
6737 0x00000068, 0x0400005f, 0x002010f2, 0x00000001, 0x00000000, 0x02000068, 0x00000001, 0x0100085d,
6738 0x0100285c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x0200005e, 0x00000004, 0x0f000032,
6739 0x00100032, 0x00000000, 0x80201ff6, 0x00000041, 0x00000000, 0x00000000, 0x00004002, 0x3dcccccd,
6740 0x3dcccccd, 0x00000000, 0x00000000, 0x00201046, 0x00000000, 0x00000000, 0x05000036, 0x00102032,
6741 0x00000000, 0x00100046, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000,
6742 0x00000000, 0x01000013, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0e000032,
6743 0x00100052, 0x00000000, 0x00201ff6, 0x00000000, 0x00000000, 0x00004002, 0x3dcccccd, 0x00000000,
6744 0x3dcccccd, 0x00000000, 0x00201106, 0x00000000, 0x00000000, 0x05000036, 0x00102022, 0x00000000,
6745 0x0010002a, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000, 0x00000000,
6746 0x01000013, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x05000036, 0x00102022,
6747 0x00000000, 0x0010001a, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000,
6748 0x00000000, 0x01000013, 0x05000036, 0x00102032, 0x00000000, 0x00100086, 0x00000000, 0x06000036,
6749 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000, 0x00000000, 0x01000013, 0x0100003e,
6752 float4
main(float4 color
: COLOR
) : SV_TARGET
6757 static const DWORD simple_ps
[] =
6759 0x43425844, 0x08c2b568, 0x17d33120, 0xb7d82948, 0x13a570fb, 0x00000001, 0x000000d0, 0x00000003,
6760 0x0000002c, 0x0000005c, 0x00000090, 0x4e475349, 0x00000028, 0x00000001, 0x00000008, 0x00000020,
6761 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x4f4c4f43, 0xabab0052, 0x4e47534f,
6762 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
6763 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
6764 0x03001062, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x05000036, 0x001020f2,
6765 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
6768 [numthreads(1, 1, 1)]
6771 static const DWORD simple_cs
[] =
6773 0x43425844, 0x1acc3ad0, 0x71c7b057, 0xc72c4306, 0xf432cb57, 0x00000001, 0x00000074, 0x00000003,
6774 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
6775 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000020, 0x00050050, 0x00000008, 0x0100086a,
6776 0x0400009b, 0x00000001, 0x00000001, 0x00000001, 0x0100003e,
6779 ID3DDeviceContextState
*context_state
, *previous_context_state
, *tmp_context_state
, *context_state2
;
6780 UINT ib_offset
, vb_offset
, vb_stride
, so_offset
, offset
, stride
, sample_mask
, stencil_ref
, count
;
6781 ID3D11Buffer
*cb
, *srvb
, *uavb
, *ib
, *vb
, *sob
, *tmp_cb
, *tmp_ib
, *tmp_vb
, *tmp_sob
;
6782 D3D_FEATURE_LEVEL feature_level
, selected_feature_level
;
6783 ID3D11UnorderedAccessView
*tmp_uav
, *uav
, *ps_uav
;
6784 ID3D11Device
*d3d11_device
, *d3d11_device2
;
6785 ID3D11SamplerState
*sampler
, *tmp_sampler
;
6786 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
6787 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
6788 ID3D11DeviceContext1
*context
, *context2
;
6789 ID3D11ShaderResourceView
*tmp_srv
, *srv
;
6790 D3D11_DEVICE_CONTEXT_TYPE context_type
;
6791 ID3D11DepthStencilState
*tmp_dss
, *dss
;
6792 ID3D11RenderTargetView
*tmp_rtv
, *rtv
;
6793 ID3D11DepthStencilView
*tmp_dsv
, *dsv
;
6794 ID3D11VertexShader
*tmp_vs
, *vs
, *vs2
;
6795 ID3D11RasterizerState
*tmp_rs
, *rs
;
6796 D3D11_TEXTURE2D_DESC texture_desc
;
6797 ID3D11GeometryShader
*tmp_gs
, *gs
;
6798 enum D3D_PRIMITIVE_TOPOLOGY topo
;
6799 ID3D11ComputeShader
*tmp_cs
, *cs
;
6800 D3D11_DEPTH_STENCIL_DESC ds_desc
;
6801 ID3D11Predicate
*tmp_pred
, *pred
;
6802 ID3D11DomainShader
*tmp_ds
, *ds
;
6803 D3D11_SAMPLER_DESC sampler_desc
;
6804 D3D11_QUERY_DESC predicate_desc
;
6805 ID3D11Device1
*device
, *device2
;
6806 ID3D11InputLayout
*il
, *tmp_il
;
6807 ID3D11PixelShader
*tmp_ps
, *ps
;
6808 D3D11_RASTERIZER_DESC rs_desc
;
6809 ID3D11BlendState
*tmp_bs
, *bs
;
6810 ID3D11HullShader
*tmp_hs
, *hs
;
6811 D3D11_VIEWPORT tmp_vp
[2], vp
;
6812 D3D11_RECT tmp_rect
[2], rect
;
6813 D3D11_BLEND_DESC blend_desc
;
6814 ID3D11Texture2D
*texture
;
6815 enum DXGI_FORMAT format
;
6816 float blend_factor
[4];
6817 struct vec4 constant
;
6824 if (!(d3d11_device
= create_device(NULL
)))
6826 skip("Failed to create device.\n");
6830 hr
= ID3D11Device_QueryInterface(d3d11_device
, &IID_ID3D11Device1
, (void **)&device
);
6831 ID3D11Device_Release(d3d11_device
);
6834 skip("ID3D11Device1 is not available.\n");
6838 check_interface(device
, &IID_ID3D10Device
, FALSE
, FALSE
);
6839 check_interface(device
, &IID_ID3D10Device1
, FALSE
, FALSE
);
6841 feature_level
= ID3D11Device1_GetFeatureLevel(device
);
6843 ID3D11Device1_GetImmediateContext1(device
, &context
);
6844 ok(!!context
, "Failed to get immediate context.\n");
6846 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_LINEAR
;
6847 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_WRAP
;
6848 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_WRAP
;
6849 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_WRAP
;
6850 sampler_desc
.MipLODBias
= 0.0f
;
6851 sampler_desc
.MaxAnisotropy
= 0;
6852 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_ALWAYS
;
6853 sampler_desc
.BorderColor
[0] = 0.0f
;
6854 sampler_desc
.BorderColor
[1] = 1.0f
;
6855 sampler_desc
.BorderColor
[2] = 0.0f
;
6856 sampler_desc
.BorderColor
[3] = 1.0f
;
6857 sampler_desc
.MinLOD
= 0.0f
;
6858 sampler_desc
.MaxLOD
= 16.0f
;
6859 hr
= ID3D11Device1_CreateSamplerState(device
, &sampler_desc
, &sampler
);
6860 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
6862 feature_level
= min(feature_level
, D3D_FEATURE_LEVEL_11_1
);
6864 hr
= ID3D11Device1_CreateDeviceContextState(device
, 0, &feature_level
,
6865 1, D3D11_SDK_VERSION
, &IID_ID3D11Device1
, NULL
, NULL
);
6866 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
6868 selected_feature_level
= 0xc0de0000;
6869 hr
= ID3D11Device1_CreateDeviceContextState(device
, 0, &feature_level
, 1,
6870 D3D11_SDK_VERSION
, &IID_ID3D11Device1
, &selected_feature_level
, NULL
);
6871 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
6872 ok(selected_feature_level
== feature_level
, "Got unexpected feature level %#x, expected %#x.\n",
6873 selected_feature_level
, feature_level
);
6875 selected_feature_level
= 0xc0de0000;
6876 context_state
= (void *)0xc0de0001;
6877 hr
= ID3D11Device1_CreateDeviceContextState(device
, 0, &feature_level
, 0,
6878 D3D11_SDK_VERSION
, &IID_ID3D11Device1
, &selected_feature_level
, &context_state
);
6879 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
6880 ok(!selected_feature_level
, "Got unexpected feature level %#x.\n", selected_feature_level
);
6881 ok(!context_state
, "Got unexpected context state %p.\n", context_state
);
6883 hr
= ID3D11Device1_CreateDeviceContextState(device
, 0, &feature_level
,
6884 0, D3D11_SDK_VERSION
, &IID_ID3D11Device1
, NULL
, NULL
);
6885 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
6887 hr
= ID3D11Device1_CreateDeviceContextState(device
, 0, NULL
,
6888 0, D3D11_SDK_VERSION
, &IID_ID3D11Device1
, NULL
, NULL
);
6889 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
6891 hr
= ID3D11Device1_CreateDeviceContextState(device
, 0, &feature_level
,
6892 1, D3D11_SDK_VERSION
, &IID_ID3D11Device1
, NULL
, &context_state
);
6893 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6894 refcount
= get_refcount(context_state
);
6895 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
6897 context_type
= ID3D11DeviceContext1_GetType(context
);
6898 ok(context_type
== D3D11_DEVICE_CONTEXT_IMMEDIATE
, "Unexpected context type %u.\n", context_type
);
6900 check_interface(device
, &IID_ID3D10Device
, TRUE
, FALSE
);
6901 check_interface(device
, &IID_ID3D10Device1
, TRUE
, FALSE
);
6902 check_interface(device
, &IID_ID3D11Device
, TRUE
, FALSE
);
6903 check_interface(device
, &IID_ID3D11Device1
, TRUE
, FALSE
);
6905 cb
= create_buffer((ID3D11Device
*)device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(constant
), NULL
);
6906 srvb
= create_buffer((ID3D11Device
*)device
, D3D11_BIND_SHADER_RESOURCE
, 1024, NULL
);
6907 uavb
= create_buffer((ID3D11Device
*)device
, D3D11_BIND_UNORDERED_ACCESS
, 1024, NULL
);
6908 ib
= create_buffer((ID3D11Device
*)device
, D3D11_BIND_INDEX_BUFFER
, 1024, NULL
);
6909 vb
= create_buffer((ID3D11Device
*)device
, D3D11_BIND_VERTEX_BUFFER
, 1024, NULL
);
6910 sob
= create_buffer((ID3D11Device
*)device
, D3D11_BIND_STREAM_OUTPUT
, 1024, NULL
);
6912 hr
= ID3D11Device1_CreateVertexShader(device
, simple_vs
, sizeof(simple_vs
), NULL
, &vs
);
6913 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
6915 hr
= ID3D11Device1_CreateGeometryShader(device
, simple_gs
, sizeof(simple_gs
), NULL
, &gs
);
6916 ok(SUCCEEDED(hr
), "Failed to create geometry shader, hr %#x.\n", hr
);
6918 hr
= ID3D11Device1_CreatePixelShader(device
, simple_ps
, sizeof(simple_ps
), NULL
, &ps
);
6919 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
6921 if (feature_level
< D3D_FEATURE_LEVEL_11_0
) hs
= NULL
;
6924 hr
= ID3D11Device1_CreateHullShader(device
, simple_hs
, sizeof(simple_hs
), NULL
, &hs
);
6925 ok(SUCCEEDED(hr
), "Failed to create hull shader, hr %#x.\n", hr
);
6928 if (feature_level
< D3D_FEATURE_LEVEL_11_0
) ds
= NULL
;
6931 hr
= ID3D11Device1_CreateDomainShader(device
, simple_ds
, sizeof(simple_ds
), NULL
, &ds
);
6932 ok(SUCCEEDED(hr
), "Failed to create domain shader, hr %#x.\n", hr
);
6935 if (feature_level
< D3D_FEATURE_LEVEL_11_0
) cs
= NULL
;
6938 hr
= ID3D11Device1_CreateComputeShader(device
, simple_cs
, sizeof(simple_cs
), NULL
, &cs
);
6939 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
6942 srv_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
6943 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_BUFFER
;
6944 U(srv_desc
).Buffer
.ElementOffset
= 0;
6945 U(srv_desc
).Buffer
.ElementWidth
= 64;
6946 hr
= ID3D11Device1_CreateShaderResourceView(device
, (ID3D11Resource
*)srvb
, &srv_desc
, &srv
);
6947 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
6948 ID3D11Buffer_Release(srvb
);
6950 uav_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
6951 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
6952 U(uav_desc
).Buffer
.FirstElement
= 0;
6953 U(uav_desc
).Buffer
.NumElements
= 4;
6954 U(uav_desc
).Buffer
.Flags
= 0;
6955 hr
= ID3D11Device1_CreateUnorderedAccessView(device
, (ID3D11Resource
*)uavb
, &uav_desc
, &uav
);
6956 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
6957 ID3D11Buffer_Release(uavb
);
6959 uavb
= create_buffer((ID3D11Device
*)device
, D3D11_BIND_UNORDERED_ACCESS
, 1024, NULL
);
6960 hr
= ID3D11Device1_CreateUnorderedAccessView(device
, (ID3D11Resource
*)uavb
, &uav_desc
, &ps_uav
);
6961 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
6962 ID3D11Buffer_Release(uavb
);
6964 hr
= ID3D11Device1_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
6965 simple_vs
, sizeof(simple_vs
), &il
);
6966 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
6973 texture_desc
.Width
= 512;
6974 texture_desc
.Height
= 512;
6975 texture_desc
.MipLevels
= 1;
6976 texture_desc
.ArraySize
= 1;
6977 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
6978 texture_desc
.SampleDesc
.Count
= 1;
6979 texture_desc
.SampleDesc
.Quality
= 0;
6980 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
6981 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
6982 texture_desc
.CPUAccessFlags
= 0;
6983 texture_desc
.MiscFlags
= 0;
6984 hr
= ID3D11Device1_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
6985 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
6986 hr
= ID3D11Device1_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
6987 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
6988 ID3D11Texture2D_Release(texture
);
6990 texture_desc
.Format
= DXGI_FORMAT_D24_UNORM_S8_UINT
;
6991 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
6992 hr
= ID3D11Device1_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
6993 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
6994 hr
= ID3D11Device1_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, NULL
, &dsv
);
6995 ok(SUCCEEDED(hr
), "Failed to create depth/stencil view, hr %#x.\n", hr
);
6996 ID3D11Texture2D_Release(texture
);
6998 memset(&blend_desc
, 0, sizeof(blend_desc
));
6999 blend_desc
.RenderTarget
[0].BlendEnable
= TRUE
;
7000 blend_desc
.RenderTarget
[0].SrcBlend
= D3D11_BLEND_SRC_ALPHA
;
7001 blend_desc
.RenderTarget
[0].DestBlend
= D3D11_BLEND_INV_SRC_ALPHA
;
7002 blend_desc
.RenderTarget
[0].BlendOp
= D3D11_BLEND_OP_ADD
;
7003 blend_desc
.RenderTarget
[0].SrcBlendAlpha
= D3D11_BLEND_SRC_ALPHA
;
7004 blend_desc
.RenderTarget
[0].DestBlendAlpha
= D3D11_BLEND_INV_SRC_ALPHA
;
7005 blend_desc
.RenderTarget
[0].BlendOpAlpha
= D3D11_BLEND_OP_ADD
;
7006 blend_desc
.RenderTarget
[0].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_ALL
;
7007 hr
= ID3D11Device1_CreateBlendState(device
, &blend_desc
, &bs
);
7008 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
7010 ds_desc
.DepthEnable
= TRUE
;
7011 ds_desc
.DepthWriteMask
= D3D11_DEPTH_WRITE_MASK_ALL
;
7012 ds_desc
.DepthFunc
= D3D11_COMPARISON_LESS
;
7013 ds_desc
.StencilEnable
= FALSE
;
7014 ds_desc
.StencilReadMask
= D3D11_DEFAULT_STENCIL_READ_MASK
;
7015 ds_desc
.StencilWriteMask
= D3D11_DEFAULT_STENCIL_WRITE_MASK
;
7016 ds_desc
.FrontFace
.StencilFailOp
= D3D11_STENCIL_OP_KEEP
;
7017 ds_desc
.FrontFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_KEEP
;
7018 ds_desc
.FrontFace
.StencilPassOp
= D3D11_STENCIL_OP_KEEP
;
7019 ds_desc
.FrontFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
7020 ds_desc
.BackFace
.StencilFailOp
= D3D11_STENCIL_OP_KEEP
;
7021 ds_desc
.BackFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_KEEP
;
7022 ds_desc
.BackFace
.StencilPassOp
= D3D11_STENCIL_OP_KEEP
;
7023 ds_desc
.BackFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
7024 hr
= ID3D11Device1_CreateDepthStencilState(device
, &ds_desc
, &dss
);
7025 ok(SUCCEEDED(hr
), "Failed to create depthstencil state, hr %#x.\n", hr
);
7027 rs_desc
.FillMode
= D3D11_FILL_SOLID
;
7028 rs_desc
.CullMode
= D3D11_CULL_BACK
;
7029 rs_desc
.FrontCounterClockwise
= FALSE
;
7030 rs_desc
.DepthBias
= 0;
7031 rs_desc
.DepthBiasClamp
= 0.0f
;
7032 rs_desc
.SlopeScaledDepthBias
= 0.0f
;
7033 rs_desc
.DepthClipEnable
= TRUE
;
7034 rs_desc
.ScissorEnable
= TRUE
;
7035 rs_desc
.MultisampleEnable
= FALSE
;
7036 rs_desc
.AntialiasedLineEnable
= FALSE
;
7037 hr
= ID3D11Device1_CreateRasterizerState(device
, &rs_desc
, &rs
);
7038 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
7040 SetRect(&rect
, 0, 0, 1, 2);
7046 vp
.MaxDepth
= 0.01f
;
7048 predicate_desc
.Query
= D3D11_QUERY_OCCLUSION_PREDICATE
;
7049 predicate_desc
.MiscFlags
= 0;
7050 ID3D11Device1_CreatePredicate(device
, &predicate_desc
, &pred
);
7052 ID3D11DeviceContext1_VSSetConstantBuffers(context
, 0, 1, &cb
);
7053 ID3D11DeviceContext1_VSSetSamplers(context
, 0, 1, &sampler
);
7054 ID3D11DeviceContext1_VSSetShader(context
, vs
, NULL
, 0);
7055 ID3D11DeviceContext1_VSSetShaderResources(context
, 0, 1, &srv
);
7056 refcount
= get_refcount(vs
);
7057 ok(refcount
== 1, "Got refcount %u, expected 1.\n", refcount
);
7059 ID3D11DeviceContext1_GSSetConstantBuffers(context
, 0, 1, &cb
);
7060 ID3D11DeviceContext1_GSSetSamplers(context
, 0, 1, &sampler
);
7061 ID3D11DeviceContext1_GSSetShader(context
, gs
, NULL
, 0);
7062 ID3D11DeviceContext1_GSSetShaderResources(context
, 0, 1, &srv
);
7064 ID3D11DeviceContext1_PSSetConstantBuffers(context
, 0, 1, &cb
);
7065 ID3D11DeviceContext1_PSSetSamplers(context
, 0, 1, &sampler
);
7066 ID3D11DeviceContext1_PSSetShader(context
, ps
, NULL
, 0);
7067 ID3D11DeviceContext1_PSSetShaderResources(context
, 0, 1, &srv
);
7069 ID3D11DeviceContext1_HSSetConstantBuffers(context
, 0, 1, &cb
);
7070 ID3D11DeviceContext1_HSSetSamplers(context
, 0, 1, &sampler
);
7071 ID3D11DeviceContext1_HSSetShader(context
, hs
, NULL
, 0);
7072 ID3D11DeviceContext1_HSSetShaderResources(context
, 0, 1, &srv
);
7074 ID3D11DeviceContext1_DSSetConstantBuffers(context
, 0, 1, &cb
);
7075 ID3D11DeviceContext1_DSSetSamplers(context
, 0, 1, &sampler
);
7076 ID3D11DeviceContext1_DSSetShader(context
, ds
, NULL
, 0);
7077 ID3D11DeviceContext1_DSSetShaderResources(context
, 0, 1, &srv
);
7079 ID3D11DeviceContext1_CSSetConstantBuffers(context
, 0, 1, &cb
);
7080 ID3D11DeviceContext1_CSSetSamplers(context
, 0, 1, &sampler
);
7081 ID3D11DeviceContext1_CSSetShader(context
, cs
, NULL
, 0);
7082 ID3D11DeviceContext1_CSSetShaderResources(context
, 0, 1, &srv
);
7083 ID3D11DeviceContext1_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
7085 ID3D11DeviceContext1_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
7086 ID3D11DeviceContext1_IASetInputLayout(context
, il
);
7087 ID3D11DeviceContext1_IASetIndexBuffer(context
, ib
, DXGI_FORMAT_R32_UINT
, ib_offset
);
7088 ID3D11DeviceContext1_IASetVertexBuffers(context
, 0, 1, &vb
, &vb_stride
, &vb_offset
);
7090 ID3D11DeviceContext1_OMSetBlendState(context
, bs
, custom_blend_factor
, 0xff00ff00);
7091 ID3D11DeviceContext1_OMSetDepthStencilState(context
, dss
, 3);
7092 ID3D11DeviceContext1_OMSetRenderTargetsAndUnorderedAccessViews(context
, 1, &rtv
, dsv
, 1, 1, &ps_uav
, NULL
);
7094 ID3D11DeviceContext1_RSSetScissorRects(context
, 1, &rect
);
7095 ID3D11DeviceContext1_RSSetViewports(context
, 1, &vp
);
7096 ID3D11DeviceContext1_RSSetState(context
, rs
);
7098 ID3D11DeviceContext1_SOSetTargets(context
, 1, &sob
, &so_offset
);
7099 ID3D11DeviceContext1_SetPredication(context
, pred
, TRUE
);
7101 previous_context_state
= (ID3DDeviceContextState
*)0xdeadbeef;
7102 ID3D11DeviceContext1_SwapDeviceContextState(context
, NULL
, &previous_context_state
);
7103 ok(previous_context_state
== NULL
, "Got unexpected state pointer.\n");
7104 previous_context_state
= NULL
;
7105 ID3D11DeviceContext1_SwapDeviceContextState(context
, context_state
, &previous_context_state
);
7106 ok(previous_context_state
!= NULL
, "Failed to get previous context state\n");
7107 refcount
= get_refcount(vs
);
7108 ok(refcount
== 1, "Got refcount %u, expected 1.\n", refcount
);
7110 hr
= ID3DDeviceContextState_SetPrivateData(context_state
, &test_guid
, sizeof(constant
), &constant
);
7111 ok(hr
== S_OK
, "Failed to set private data, hr %#x.\n", hr
);
7112 refcount
= ID3DDeviceContextState_Release(context_state
);
7113 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
7114 ID3D11DeviceContext1_SwapDeviceContextState(context
, previous_context_state
, &context_state
);
7115 data_size
= sizeof(data
);
7116 memset(data
, 0xa5, sizeof(data
));
7117 hr
= ID3DDeviceContextState_GetPrivateData(context_state
, &test_guid
, &data_size
, data
);
7118 ok(hr
== S_OK
, "Failed to get private data, hr %#x.\n", hr
);
7119 ok(data_size
== sizeof(constant
), "Got private data size %x, expected %x.\n", data_size
, sizeof(constant
));
7120 ok(!memcmp(data
, &constant
, sizeof(constant
)), "Got unexpected private data.\n");
7121 ID3D11DeviceContext1_SwapDeviceContextState(context
, context_state
, NULL
);
7123 context_type
= ID3D11DeviceContext1_GetType(context
);
7124 ok(context_type
== D3D11_DEVICE_CONTEXT_IMMEDIATE
, "Unexpected context type %u.\n", context_type
);
7126 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7127 ID3D11DeviceContext1_VSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7128 ok(!tmp_cb
, "Got unexpected buffer %p.\n", tmp_cb
);
7129 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7130 ID3D11DeviceContext1_VSGetSamplers(context
, 0, 1, &tmp_sampler
);
7131 ok(!tmp_sampler
, "Got unexpected sampler %p.\n", tmp_sampler
);
7132 tmp_vs
= (ID3D11VertexShader
*)0xdeadbeef;
7133 ID3D11DeviceContext1_VSGetShader(context
, &tmp_vs
, NULL
, NULL
);
7134 ok(!tmp_vs
, "Got unexpected shader %p.\n", tmp_vs
);
7135 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7136 ID3D11DeviceContext1_VSGetShaderResources(context
, 0, 1, &tmp_srv
);
7137 ok(!tmp_srv
, "Got unexpected srv %p.\n", tmp_srv
);
7139 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7140 ID3D11DeviceContext1_GSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7141 ok(!tmp_cb
, "Got unexpected buffer %p.\n", tmp_cb
);
7142 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7143 ID3D11DeviceContext1_GSGetSamplers(context
, 0, 1, &tmp_sampler
);
7144 ok(!tmp_sampler
, "Got unexpected sampler %p.\n", tmp_sampler
);
7145 tmp_gs
= (ID3D11GeometryShader
*)0xdeadbeef;
7146 ID3D11DeviceContext1_GSGetShader(context
, &tmp_gs
, NULL
, NULL
);
7147 ok(!tmp_gs
, "Got unexpected shader %p.\n", tmp_gs
);
7148 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7149 ID3D11DeviceContext1_GSGetShaderResources(context
, 0, 1, &tmp_srv
);
7150 ok(!tmp_srv
, "Got unexpected srv %p.\n", tmp_srv
);
7152 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7153 ID3D11DeviceContext1_PSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7154 ok(!tmp_cb
, "Got unexpected buffer %p.\n", tmp_cb
);
7155 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7156 ID3D11DeviceContext1_PSGetSamplers(context
, 0, 1, &tmp_sampler
);
7157 ok(!tmp_sampler
, "Got unexpected sampler %p.\n", tmp_sampler
);
7158 tmp_ps
= (ID3D11PixelShader
*)0xdeadbeef;
7159 ID3D11DeviceContext1_PSGetShader(context
, &tmp_ps
, NULL
, NULL
);
7160 ok(!tmp_ps
, "Got unexpected shader %p.\n", tmp_ps
);
7161 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7162 ID3D11DeviceContext1_PSGetShaderResources(context
, 0, 1, &tmp_srv
);
7163 ok(!tmp_srv
, "Got unexpected srv %p.\n", tmp_srv
);
7165 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7166 ID3D11DeviceContext1_HSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7167 ok(!tmp_cb
, "Got unexpected buffer %p.\n", tmp_cb
);
7168 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7169 ID3D11DeviceContext1_HSGetSamplers(context
, 0, 1, &tmp_sampler
);
7170 ok(!tmp_sampler
, "Got unexpected sampler %p.\n", tmp_sampler
);
7171 tmp_hs
= (ID3D11HullShader
*)0xdeadbeef;
7172 ID3D11DeviceContext1_HSGetShader(context
, &tmp_hs
, NULL
, NULL
);
7173 if (hs
) ok(!tmp_hs
, "Got unexpected shader %p.\n", tmp_hs
);
7174 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7175 ID3D11DeviceContext1_HSGetShaderResources(context
, 0, 1, &tmp_srv
);
7176 ok(!tmp_srv
, "Got unexpected srv %p.\n", tmp_srv
);
7178 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7179 ID3D11DeviceContext1_DSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7180 ok(!tmp_cb
, "Got unexpected buffer %p.\n", tmp_cb
);
7181 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7182 ID3D11DeviceContext1_DSGetSamplers(context
, 0, 1, &tmp_sampler
);
7183 ok(!tmp_sampler
, "Got unexpected sampler %p.\n", tmp_sampler
);
7184 tmp_ds
= (ID3D11DomainShader
*)0xdeadbeef;
7185 ID3D11DeviceContext1_DSGetShader(context
, &tmp_ds
, NULL
, NULL
);
7186 if (ds
) ok(!tmp_ds
, "Got unexpected shader %p.\n", tmp_ds
);
7187 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7188 ID3D11DeviceContext1_DSGetShaderResources(context
, 0, 1, &tmp_srv
);
7189 ok(!tmp_srv
, "Got unexpected srv %p.\n", tmp_srv
);
7191 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7192 ID3D11DeviceContext1_CSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7193 ok(!tmp_cb
, "Got unexpected buffer %p.\n", tmp_cb
);
7194 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7195 ID3D11DeviceContext1_CSGetSamplers(context
, 0, 1, &tmp_sampler
);
7196 ok(!tmp_sampler
, "Got unexpected sampler %p.\n", tmp_sampler
);
7197 tmp_cs
= (ID3D11ComputeShader
*)0xdeadbeef;
7198 ID3D11DeviceContext1_CSGetShader(context
, &tmp_cs
, NULL
, NULL
);
7199 if (cs
) ok(!tmp_cs
, "Got unexpected shader %p.\n", tmp_cs
);
7200 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7201 ID3D11DeviceContext1_CSGetShaderResources(context
, 0, 1, &tmp_srv
);
7202 ok(!tmp_srv
, "Got unexpected srv %p.\n", tmp_srv
);
7203 tmp_uav
= (ID3D11UnorderedAccessView
*)0xdeadbeef;
7204 ID3D11DeviceContext1_CSGetUnorderedAccessViews(context
, 0, 1, &tmp_uav
);
7205 ok(!tmp_uav
, "Got unexpected uav %p.\n", tmp_uav
);
7208 ID3D11DeviceContext1_IAGetPrimitiveTopology(context
, &topo
);
7209 ok(topo
== D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED
, "Got unexpected topology %#x.\n", topo
);
7210 tmp_il
= (ID3D11InputLayout
*)0xdeadbeef;
7211 ID3D11DeviceContext1_IAGetInputLayout(context
, &tmp_il
);
7212 ok(!tmp_il
, "Got unexpected input layout %p.\n", tmp_il
);
7213 tmp_ib
= (ID3D11Buffer
*)0xdeadbeef;
7214 format
= 0xdeadbeef;
7215 offset
= 0xdeadbeef;
7216 ID3D11DeviceContext1_IAGetIndexBuffer(context
, &tmp_ib
, &format
, &offset
);
7217 ok(!tmp_ib
, "Got unexpected input buffer %p.\n", tmp_ib
);
7218 ok(format
== DXGI_FORMAT_UNKNOWN
, "Got unexpected input buffer format %#x.\n", format
);
7219 ok(offset
== 0, "Got unexpected input buffer offset %#x.\n", offset
);
7220 tmp_vb
= (ID3D11Buffer
*)0xdeadbeef;
7221 stride
= 0xdeadbeef;
7222 offset
= 0xdeadbeef;
7223 ID3D11DeviceContext1_IAGetVertexBuffers(context
, 0, 1, &tmp_vb
, &stride
, &offset
);
7224 ok(!tmp_vb
, "Got unexpected vertex buffer %p.\n", tmp_vb
);
7225 ok(stride
== 0, "Got unexpected vertex buffer stride %#x.\n", stride
);
7226 ok(offset
== 0, "Got unexpected vertex buffer offset %#x.\n", offset
);
7228 tmp_rtv
= (ID3D11RenderTargetView
*)0xdeadbeef;
7229 tmp_dsv
= (ID3D11DepthStencilView
*)0xdeadbeef;
7230 tmp_uav
= (ID3D11UnorderedAccessView
*)0xdeadbeef;
7231 ID3D11DeviceContext1_OMGetRenderTargetsAndUnorderedAccessViews(context
, 1, &tmp_rtv
, &tmp_dsv
, 1, 1, &tmp_uav
);
7232 ok(!tmp_rtv
, "Got unexpected rendertarget view %p.\n", tmp_rtv
);
7233 ok(!tmp_dsv
, "Got unexpected depth/stencil view %p.\n", tmp_dsv
);
7234 ok(!tmp_uav
, "Got unexpected unordered access view %p.\n", tmp_uav
);
7235 tmp_bs
= (ID3D11BlendState
*)0xdeadbeef;
7236 memset(blend_factor
, 0xcd, sizeof(blend_factor
));
7237 sample_mask
= 0xdeadbeef;
7238 ID3D11DeviceContext1_OMGetBlendState(context
, &tmp_bs
, blend_factor
, &sample_mask
);
7239 ok(!tmp_bs
, "Got unexpected blend state %p.\n", tmp_bs
);
7240 ok(!memcmp(blend_factor
, default_blend_factor
, sizeof(blend_factor
)),
7241 "Got unexpected blend factor %f,%f,%f,%f.\n",
7242 blend_factor
[0], blend_factor
[1], blend_factor
[2], blend_factor
[3]);
7243 ok(sample_mask
== ~0, "Got unexpected sample mask %#x.\n", sample_mask
);
7244 tmp_dss
= (ID3D11DepthStencilState
*)0xdeadbeef;
7245 stencil_ref
= 0xdeadbeef;
7246 ID3D11DeviceContext1_OMGetDepthStencilState(context
, &tmp_dss
, &stencil_ref
);
7247 ok(!tmp_dss
, "Got unexpected depth/stencil state %p.\n", tmp_dss
);
7248 ok(stencil_ref
== 0, "Got unexpected stencil ref %#x.\n", stencil_ref
);
7250 tmp_rs
= (ID3D11RasterizerState
*)0xdeadbeef;
7251 ID3D11DeviceContext1_RSGetState(context
, &tmp_rs
);
7252 ok(!tmp_rs
, "Got unexpected rasterizer state %p.\n", tmp_rs
);
7253 memset(tmp_vp
, 0xa5, sizeof(tmp_vp
));
7255 ID3D11DeviceContext1_RSGetViewports(context
, &count
, tmp_vp
);
7256 ok(count
== 0, "Got unexpected viewport count %u.\n", count
);
7257 memset(tmp_rect
, 0xa5, sizeof(tmp_rect
));
7259 ID3D11DeviceContext1_RSGetScissorRects(context
, &count
, tmp_rect
);
7260 ok(count
== 0, "Got unexpected scissor rect count %u.\n", count
);
7262 tmp_sob
= (ID3D11Buffer
*)0xdeadbeef;
7263 ID3D11DeviceContext1_SOGetTargets(context
, 1, &tmp_sob
);
7264 ok(!tmp_sob
, "Got unexpected stream output buffer %p.\n", tmp_sob
);
7266 tmp_pred
= (ID3D11Predicate
*)0xdeadbeef;
7267 pred_value
= 0xdeadbeef;
7268 ID3D11DeviceContext1_GetPredication(context
, &tmp_pred
, &pred_value
);
7269 ok(!tmp_pred
, "Got unexpected predicate %p.\n", tmp_pred
);
7270 ok(!pred_value
, "Got unexpected predicate value %d.\n", pred_value
);
7272 /* updating the device context should also update the device context state */
7273 hr
= ID3D11Device1_CreateVertexShader(device
, simple_vs
, sizeof(simple_vs
), NULL
, &vs2
);
7274 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
7275 ID3D11DeviceContext1_VSSetShader(context
, vs2
, NULL
, 0);
7276 ID3D11DeviceContext1_SwapDeviceContextState(context
, context_state
, &tmp_context_state
);
7277 refcount
= ID3DDeviceContextState_Release(tmp_context_state
);
7278 ok(refcount
== 1, "Got refcount %u, expected 1.\n", refcount
);
7279 ok(tmp_context_state
== context_state
, "Got unexpected state pointer.\n");
7280 tmp_vs
= (ID3D11VertexShader
*)0xdeadbeef;
7281 ID3D11DeviceContext1_VSGetShader(context
, &tmp_vs
, NULL
, NULL
);
7282 ok(tmp_vs
== vs2
, "Got shader %p, expected %p.\n", tmp_vs
, vs2
);
7283 refcount
= ID3D11VertexShader_Release(tmp_vs
);
7284 ok(refcount
== 1, "Got refcount %u, expected 1.\n", refcount
);
7286 /* context states may be used with other devices instances too */
7287 d3d11_device2
= create_device(NULL
);
7288 ok(!!d3d11_device2
, "Failed to create device.\n");
7289 hr
= ID3D11Device_QueryInterface(d3d11_device2
, &IID_ID3D11Device1
, (void **)&device2
);
7290 ok(SUCCEEDED(hr
), "Failed to query device interface, hr %#x.\n", hr
);
7291 ID3D11Device_Release(d3d11_device2
);
7292 ID3D11Device1_GetImmediateContext1(device2
, &context2
);
7293 ok(!!context2
, "Failed to get immediate context.\n");
7295 /* but they track a distinct state on each context */
7296 ID3D11DeviceContext1_SwapDeviceContextState(context2
, context_state
, &tmp_context_state
);
7297 ok(!!tmp_context_state
, "Failed to get context state.\n");
7298 tmp_vs
= (ID3D11VertexShader
*)0xdeadbeef;
7299 ID3D11DeviceContext1_VSGetShader(context2
, &tmp_vs
, NULL
, NULL
);
7300 ok(!tmp_vs
, "Got unexpected shader %p.\n", tmp_vs
);
7302 /* updating context2 vertex shader doesn't update other contexts using the same state */
7303 ID3D11DeviceContext1_VSSetShader(context2
, vs
, NULL
, 0);
7304 ID3D11DeviceContext1_VSGetShader(context
, &tmp_vs
, NULL
, NULL
);
7305 ok(tmp_vs
== vs2
, "Got shader %p, expected %p.\n", tmp_vs
, vs2
);
7306 refcount
= ID3D11VertexShader_Release(tmp_vs
);
7307 ok(refcount
== 1, "Got refcount %u, expected 1.\n", refcount
);
7309 ID3D11DeviceContext1_SwapDeviceContextState(context2
, tmp_context_state
, &context_state2
);
7310 refcount
= ID3DDeviceContextState_Release(tmp_context_state
);
7311 ok(refcount
== 0, "Got refcount %u, expected 1.\n", refcount
);
7312 refcount
= ID3DDeviceContextState_Release(context_state2
);
7313 ok(refcount
== 1, "Got refcount %u, expected 1.\n", refcount
);
7314 ok(context_state2
== context_state
, "Got unexpected state pointer.\n");
7316 /* swapping the default state on context2 effectively clears the vertex shader */
7317 tmp_vs
= (ID3D11VertexShader
*)0xdeadbeef;
7318 ID3D11DeviceContext1_VSGetShader(context2
, &tmp_vs
, NULL
, NULL
);
7319 ok(!tmp_vs
, "Got unexpected shader %p.\n", tmp_vs
);
7321 ID3D11DeviceContext1_SwapDeviceContextState(context2
, context_state
, &tmp_context_state
);
7322 ok(!!tmp_context_state
, "Failed to get context state.\n");
7323 refcount
= ID3DDeviceContextState_Release(tmp_context_state
);
7324 ok(refcount
== 0, "Got refcount %u, expected 1.\n", refcount
);
7326 /* clearing the vertex shader on context doesn't have side effect on context2 */
7327 ID3D11DeviceContext1_VSSetShader(context
, NULL
, NULL
, 0);
7328 refcount
= ID3D11VertexShader_Release(vs2
);
7329 ok(refcount
== 0, "Got refcount %u, expected 0.\n", refcount
);
7330 tmp_vs
= (ID3D11VertexShader
*)0xdeadbeef;
7331 ID3D11DeviceContext1_VSGetShader(context2
, &tmp_vs
, NULL
, NULL
);
7332 ok(tmp_vs
== vs
, "Got shader %p, expected %p.\n", tmp_vs
, vs
);
7333 refcount
= ID3D11VertexShader_Release(tmp_vs
);
7334 ok(refcount
== 1, "Got refcount %u, expected 1.\n", refcount
);
7336 /* even after swapping it again */
7337 ID3D11DeviceContext1_SwapDeviceContextState(context2
, context_state
, NULL
);
7338 tmp_vs
= (ID3D11VertexShader
*)0xdeadbeef;
7339 ID3D11DeviceContext1_VSGetShader(context2
, &tmp_vs
, NULL
, NULL
);
7340 ok(tmp_vs
== vs
, "Got shader %p, expected %p.\n", tmp_vs
, vs
);
7341 refcount
= ID3D11VertexShader_Release(tmp_vs
);
7342 ok(refcount
== 1, "Got refcount %u, expected 1.\n", refcount
);
7344 /* swapping the initial state on context2 doesn't have side effect on context either */
7345 ID3D11DeviceContext1_SwapDeviceContextState(context2
, previous_context_state
, NULL
);
7346 tmp_vs
= (ID3D11VertexShader
*)0xdeadbeef;
7347 ID3D11DeviceContext1_VSGetShader(context
, &tmp_vs
, NULL
, NULL
);
7348 ok(!tmp_vs
, "Got unexpected shader %p.\n", tmp_vs
);
7350 refcount
= ID3D11DeviceContext1_Release(context2
);
7351 ok(refcount
== 0, "Got refcount %u, expected 0.\n", refcount
);
7352 refcount
= ID3D11Device1_Release(device2
);
7353 ok(refcount
== 0, "Got refcount %u, expected 0.\n", refcount
);
7355 ID3D11DeviceContext1_SwapDeviceContextState(context
, previous_context_state
, &tmp_context_state
);
7356 refcount
= ID3DDeviceContextState_Release(previous_context_state
);
7357 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
7358 refcount
= ID3DDeviceContextState_Release(tmp_context_state
);
7359 ok(refcount
== 1, "Got refcount %u, expected 1.\n", refcount
);
7360 refcount
= ID3DDeviceContextState_Release(context_state
);
7361 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
7362 ok(tmp_context_state
== context_state
, "Got unexpected state pointer.\n");
7363 refcount
= get_refcount(vs
);
7364 ok(refcount
== 1, "Got refcount %u, expected 1.\n", refcount
);
7366 /* ID3DDeviceContextState retains the previous state. */
7368 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7369 ID3D11DeviceContext1_VSGetSamplers(context
, 0, 1, &tmp_sampler
);
7370 ok(tmp_sampler
== sampler
, "Got sampler %p, expected %p.\n", tmp_sampler
, sampler
);
7371 ID3D11SamplerState_Release(tmp_sampler
);
7372 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7373 ID3D11DeviceContext1_VSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7374 ok(tmp_cb
== cb
, "Got buffer %p, expected %p.\n", tmp_cb
, cb
);
7375 ID3D11Buffer_Release(tmp_cb
);
7376 tmp_ps
= (ID3D11PixelShader
*)0xdeadbeef;
7377 ID3D11DeviceContext1_PSGetShader(context
, &tmp_ps
, NULL
, NULL
);
7378 ok(tmp_ps
== ps
, "Got shader %p, expected %p.\n", tmp_ps
, ps
);
7379 ID3D11PixelShader_Release(tmp_ps
);
7380 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7381 ID3D11DeviceContext1_PSGetShaderResources(context
, 0, 1, &tmp_srv
);
7382 ok(tmp_srv
== srv
, "Got srv %p, expected %p.\n", tmp_srv
, srv
);
7383 ID3D11ShaderResourceView_Release(tmp_srv
);
7385 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7386 ID3D11DeviceContext1_GSGetSamplers(context
, 0, 1, &tmp_sampler
);
7387 ok(tmp_sampler
== sampler
, "Got sampler %p, expected %p.\n", tmp_sampler
, sampler
);
7388 ID3D11SamplerState_Release(tmp_sampler
);
7389 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7390 ID3D11DeviceContext1_GSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7391 ok(tmp_cb
== cb
, "Got buffer %p, expected %p.\n", tmp_cb
, cb
);
7392 ID3D11Buffer_Release(tmp_cb
);
7393 tmp_cs
= (ID3D11ComputeShader
*)0xdeadbeef;
7394 ID3D11DeviceContext1_CSGetShader(context
, &tmp_cs
, NULL
, NULL
);
7395 ok(tmp_cs
== cs
, "Got shader %p, expected %p.\n", tmp_cs
, cs
);
7396 if (cs
) ID3D11ComputeShader_Release(tmp_cs
);
7397 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7398 ID3D11DeviceContext1_CSGetShaderResources(context
, 0, 1, &tmp_srv
);
7399 ok(tmp_srv
== srv
, "Got srv %p, expected %p.\n", tmp_srv
, srv
);
7400 ID3D11ShaderResourceView_Release(tmp_srv
);
7401 tmp_uav
= (ID3D11UnorderedAccessView
*)0xdeadbeef;
7402 ID3D11DeviceContext1_CSGetUnorderedAccessViews(context
, 0, 1, &tmp_uav
);
7403 ok(tmp_uav
== uav
, "Got uav %p, expected %p.\n", tmp_uav
, uav
);
7404 ID3D11UnorderedAccessView_Release(tmp_uav
);
7406 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7407 ID3D11DeviceContext1_PSGetSamplers(context
, 0, 1, &tmp_sampler
);
7408 ok(tmp_sampler
== sampler
, "Got sampler %p, expected %p.\n", tmp_sampler
, sampler
);
7409 ID3D11SamplerState_Release(tmp_sampler
);
7410 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7411 ID3D11DeviceContext1_PSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7412 ok(tmp_cb
== cb
, "Got buffer %p, expected %p.\n", tmp_cb
, cb
);
7413 ID3D11Buffer_Release(tmp_cb
);
7414 tmp_ds
= (ID3D11DomainShader
*)0xdeadbeef;
7415 ID3D11DeviceContext1_DSGetShader(context
, &tmp_ds
, NULL
, NULL
);
7416 ok(tmp_ds
== ds
, "Got shader %p, expected %p.\n", tmp_ds
, ds
);
7417 if (ds
) ID3D11DomainShader_Release(tmp_ds
);
7418 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7419 ID3D11DeviceContext1_DSGetShaderResources(context
, 0, 1, &tmp_srv
);
7420 ok(tmp_srv
== srv
, "Got srv %p, expected %p.\n", tmp_srv
, srv
);
7421 ID3D11ShaderResourceView_Release(tmp_srv
);
7423 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7424 ID3D11DeviceContext1_HSGetSamplers(context
, 0, 1, &tmp_sampler
);
7425 ok(tmp_sampler
== sampler
, "Got sampler %p, expected %p.\n", tmp_sampler
, sampler
);
7426 ID3D11SamplerState_Release(tmp_sampler
);
7427 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7428 ID3D11DeviceContext1_HSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7429 ok(tmp_cb
== cb
, "Got buffer %p, expected %p.\n", tmp_cb
, cb
);
7430 ID3D11Buffer_Release(tmp_cb
);
7431 tmp_gs
= (ID3D11GeometryShader
*)0xdeadbeef;
7432 ID3D11DeviceContext1_GSGetShader(context
, &tmp_gs
, NULL
, NULL
);
7433 ok(tmp_gs
== gs
, "Got shader %p, expected %p.\n", tmp_gs
, gs
);
7434 ID3D11GeometryShader_Release(tmp_gs
);
7435 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7436 ID3D11DeviceContext1_GSGetShaderResources(context
, 0, 1, &tmp_srv
);
7437 ok(tmp_srv
== srv
, "Got srv %p, expected %p.\n", tmp_srv
, srv
);
7438 ID3D11ShaderResourceView_Release(tmp_srv
);
7440 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7441 ID3D11DeviceContext1_DSGetSamplers(context
, 0, 1, &tmp_sampler
);
7442 ok(tmp_sampler
== sampler
, "Got sampler %p, expected %p.\n", tmp_sampler
, sampler
);
7443 ID3D11SamplerState_Release(tmp_sampler
);
7444 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7445 ID3D11DeviceContext1_DSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7446 ok(tmp_cb
== cb
, "Got buffer %p, expected %p.\n", tmp_cb
, cb
);
7447 ID3D11Buffer_Release(tmp_cb
);
7448 tmp_hs
= (ID3D11HullShader
*)0xdeadbeef;
7449 ID3D11DeviceContext1_HSGetShader(context
, &tmp_hs
, NULL
, NULL
);
7450 ok(tmp_hs
== hs
, "Got shader %p, expected %p.\n", tmp_hs
, hs
);
7451 if (hs
) ID3D11HullShader_Release(tmp_hs
);
7452 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7453 ID3D11DeviceContext1_HSGetShaderResources(context
, 0, 1, &tmp_srv
);
7454 ok(tmp_srv
== srv
, "Got srv %p, expected %p.\n", tmp_srv
, srv
);
7455 ID3D11ShaderResourceView_Release(tmp_srv
);
7457 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7458 ID3D11DeviceContext1_CSGetSamplers(context
, 0, 1, &tmp_sampler
);
7459 ok(tmp_sampler
== sampler
, "Got sampler %p, expected %p.\n", tmp_sampler
, sampler
);
7460 ID3D11SamplerState_Release(tmp_sampler
);
7461 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7462 ID3D11DeviceContext1_CSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7463 ok(tmp_cb
== cb
, "Got buffer %p, expected %p.\n", tmp_cb
, cb
);
7464 ID3D11Buffer_Release(tmp_cb
);
7465 tmp_vs
= (ID3D11VertexShader
*)0xdeadbeef;
7466 ID3D11DeviceContext1_VSGetShader(context
, &tmp_vs
, NULL
, NULL
);
7467 ok(tmp_vs
== vs
, "Got shader %p, expected %p.\n", tmp_vs
, vs
);
7468 ID3D11VertexShader_Release(tmp_vs
);
7469 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7470 ID3D11DeviceContext1_VSGetShaderResources(context
, 0, 1, &tmp_srv
);
7471 ok(tmp_srv
== srv
, "Got srv %p, expected %p.\n", tmp_srv
, srv
);
7472 ID3D11ShaderResourceView_Release(tmp_srv
);
7475 ID3D11DeviceContext1_IAGetPrimitiveTopology(context
, &topo
);
7476 ok(topo
== D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
, "Got topology %#x, expected %#x.\n", topo
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
7477 tmp_il
= (ID3D11InputLayout
*)0xdeadbeef;
7478 ID3D11DeviceContext1_IAGetInputLayout(context
, &tmp_il
);
7479 ok(tmp_il
== il
, "Got input layout %p, expected %p.\n", tmp_il
, il
);
7480 ID3D11InputLayout_Release(tmp_il
);
7481 tmp_ib
= (ID3D11Buffer
*)0xdeadbeef;
7482 format
= 0xdeadbeef;
7483 offset
= 0xdeadbeef;
7484 ID3D11DeviceContext1_IAGetIndexBuffer(context
, &tmp_ib
, &format
, &offset
);
7485 ok(tmp_ib
== ib
, "Got input buffer %p, expected %p.\n", tmp_ib
, ib
);
7486 ID3D11Buffer_Release(tmp_ib
);
7487 ok(format
== DXGI_FORMAT_R32_UINT
, "Got input buffer format %#x, expected %#x.\n", format
, DXGI_FORMAT_R32_UINT
);
7488 ok(offset
== 16, "Got input buffer offset %#x, expected 16.\n", offset
);
7489 tmp_vb
= (ID3D11Buffer
*)0xdeadbeef;
7490 stride
= 0xdeadbeef;
7491 offset
= 0xdeadbeef;
7492 ID3D11DeviceContext1_IAGetVertexBuffers(context
, 0, 1, &tmp_vb
, &stride
, &offset
);
7493 ok(tmp_vb
== vb
, "Got vertex buffer %p, expected %p.\n", tmp_vb
, vb
);
7494 ID3D11Buffer_Release(tmp_vb
);
7495 ok(stride
== 16, "Got vertex buffer stride %#x, expected 16.\n", stride
);
7496 ok(offset
== 16, "Got vertex buffer offset %#x, expected 16.\n", offset
);
7498 tmp_rtv
= (ID3D11RenderTargetView
*)0xdeadbeef;
7499 tmp_dsv
= (ID3D11DepthStencilView
*)0xdeadbeef;
7500 tmp_uav
= (ID3D11UnorderedAccessView
*)0xdeadbeef;
7501 ID3D11DeviceContext1_OMGetRenderTargetsAndUnorderedAccessViews(context
, 1, &tmp_rtv
, &tmp_dsv
, 1, 1, &tmp_uav
);
7502 ok(tmp_rtv
== rtv
, "Got rendertarget view %p, expected %p.\n", tmp_rtv
, rtv
);
7503 ID3D11RenderTargetView_Release(tmp_rtv
);
7504 ok(tmp_dsv
== dsv
, "Got depth/stencil view %p, expected %p.\n", tmp_dsv
, dsv
);
7505 ID3D11DepthStencilView_Release(tmp_dsv
);
7506 ok(tmp_uav
== ps_uav
, "Got unordered access view %p, expected %p.\n", tmp_uav
, ps_uav
);
7507 ID3D11UnorderedAccessView_Release(tmp_uav
);
7508 tmp_bs
= (ID3D11BlendState
*)0xdeadbeef;
7509 memset(blend_factor
, 0xcd, sizeof(blend_factor
));
7510 sample_mask
= 0xdeadbeef;
7511 ID3D11DeviceContext1_OMGetBlendState(context
, &tmp_bs
, blend_factor
, &sample_mask
);
7512 ok(tmp_bs
== bs
, "Got blend state %p, expected %p.\n", tmp_bs
, bs
);
7513 ID3D11BlendState_Release(tmp_bs
);
7514 ok(!memcmp(blend_factor
, custom_blend_factor
, sizeof(blend_factor
)),
7515 "Got blend factor %f,%f,%f,%f, expected %f,%f,%f,%f.\n",
7516 blend_factor
[0], blend_factor
[1], blend_factor
[2], blend_factor
[3],
7517 custom_blend_factor
[0], custom_blend_factor
[1], custom_blend_factor
[2], custom_blend_factor
[3]);
7518 ok(sample_mask
== 0xff00ff00, "Got sample mask %#x, expected %#x.\n", sample_mask
, 0xff00ff00);
7519 tmp_dss
= (ID3D11DepthStencilState
*)0xdeadbeef;
7520 stencil_ref
= 0xdeadbeef;
7521 ID3D11DeviceContext1_OMGetDepthStencilState(context
, &tmp_dss
, &stencil_ref
);
7522 ok(tmp_dss
== dss
, "Got depth/stencil state %p, expected %p.\n", tmp_dss
, dss
);
7523 ID3D11DepthStencilState_Release(tmp_dss
);
7524 ok(stencil_ref
== 3, "Got stencil ref %#x, expected 3.\n", stencil_ref
);
7526 tmp_rs
= (ID3D11RasterizerState
*)0xdeadbeef;
7527 ID3D11DeviceContext1_RSGetState(context
, &tmp_rs
);
7528 ok(tmp_rs
== rs
, "Got unexpected rasterizer state %p.\n", tmp_rs
);
7529 ID3D11RasterizerState_Release(tmp_rs
);
7530 memset(tmp_vp
, 0xa5, sizeof(tmp_vp
));
7532 ID3D11DeviceContext1_RSGetViewports(context
, &count
, tmp_vp
);
7533 ok(count
== 1, "Got viewport count %u, expected 1.\n", count
);
7534 ok(!memcmp(tmp_vp
, &vp
, sizeof(vp
)), "Got viewport %s, expected %s.\n",
7535 debugstr_viewport(tmp_vp
), debugstr_viewport(&vp
));
7536 memset(tmp_rect
, 0xa5, sizeof(tmp_rect
));
7538 ID3D11DeviceContext1_RSGetScissorRects(context
, &count
, tmp_rect
);
7539 ok(count
== 1, "Got scissor rect count %u, expected 1.\n", count
);
7540 ok(!memcmp(tmp_rect
, &rect
, sizeof(rect
)), "Got scissor rect %s, expected %s.\n",
7541 wine_dbgstr_rect(tmp_rect
), wine_dbgstr_rect(&rect
));
7543 tmp_sob
= (ID3D11Buffer
*)0xdeadbeef;
7544 ID3D11DeviceContext1_SOGetTargets(context
, 1, &tmp_sob
);
7545 ok(tmp_sob
== sob
, "Got stream output buffer %p, expected %p.\n", tmp_sob
, sob
);
7546 ID3D11Buffer_Release(tmp_sob
);
7548 tmp_pred
= (ID3D11Predicate
*)0xdeadbeef;
7549 pred_value
= 0xdeadbeef;
7550 ID3D11DeviceContext1_GetPredication(context
, &tmp_pred
, &pred_value
);
7551 ok(tmp_pred
== pred
, "Got predicate %p, expected %p.\n", tmp_pred
, pred
);
7552 ID3D11Predicate_Release(tmp_pred
);
7553 ok(pred_value
== TRUE
, "Got predicate value %#x, expected TRUE.\n", pred_value
);
7555 feature_level
= min(feature_level
, D3D_FEATURE_LEVEL_10_1
);
7556 hr
= ID3D11Device1_CreateDeviceContextState(device
, 0, &feature_level
, 1, D3D11_SDK_VERSION
,
7557 &IID_ID3D10Device
, NULL
, &context_state
);
7558 ok(SUCCEEDED(hr
), "Failed to create device context state, hr %#x.\n", hr
);
7559 refcount
= get_refcount(context_state
);
7560 ok(refcount
== 1, "Got refcount %u, expected 1.\n", refcount
);
7562 context_type
= ID3D11DeviceContext1_GetType(context
);
7563 ok(context_type
== D3D11_DEVICE_CONTEXT_IMMEDIATE
, "Unexpected context type %u.\n", context_type
);
7565 /* Enable ID3D10Device behavior. */
7566 previous_context_state
= NULL
;
7567 ID3D11DeviceContext1_SwapDeviceContextState(context
, context_state
, &previous_context_state
);
7568 refcount
= ID3DDeviceContextState_Release(context_state
);
7569 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
7570 ok(previous_context_state
!= NULL
, "Failed to get previous context state\n");
7572 context_type
= ID3D11DeviceContext1_GetType(context
);
7573 ok(context_type
== D3D11_DEVICE_CONTEXT_IMMEDIATE
, "Unexpected context type %u.\n", context_type
);
7575 ID3D11DeviceContext1_VSSetConstantBuffers(context
, 0, 1, &cb
);
7576 ID3D11DeviceContext1_VSSetSamplers(context
, 0, 1, &sampler
);
7577 ID3D11DeviceContext1_VSSetShader(context
, vs
, NULL
, 0);
7578 ID3D11DeviceContext1_VSSetShaderResources(context
, 0, 1, &srv
);
7580 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7581 ID3D11DeviceContext1_VSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7582 todo_wine
ok(!tmp_cb
, "Got unexpected buffer %p.\n", tmp_cb
);
7583 if (tmp_cb
&& tmp_cb
!= (ID3D11Buffer
*)0xdeadbeef) ID3D11Buffer_Release(tmp_cb
);
7584 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7585 ID3D11DeviceContext1_VSGetSamplers(context
, 0, 1, &tmp_sampler
);
7586 todo_wine
ok(!tmp_sampler
, "Got unexpected sampler %p.\n", tmp_sampler
);
7587 if (tmp_sampler
&& tmp_sampler
!= (ID3D11SamplerState
*)0xdeadbeef) ID3D11SamplerState_Release(tmp_sampler
);
7588 tmp_vs
= (ID3D11VertexShader
*)0xdeadbeef;
7589 ID3D11DeviceContext1_VSGetShader(context
, &tmp_vs
, NULL
, NULL
);
7590 todo_wine
ok(!tmp_vs
, "Got unexpected shader %p.\n", tmp_vs
);
7591 if (tmp_vs
&& tmp_vs
!= (ID3D11VertexShader
*)0xdeadbeef) ID3D11VertexShader_Release(tmp_vs
);
7592 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7593 ID3D11DeviceContext1_VSGetShaderResources(context
, 0, 1, &tmp_srv
);
7594 todo_wine
ok(!tmp_srv
, "Got unexpected srv %p.\n", tmp_srv
);
7595 if (tmp_srv
&& tmp_srv
!= (ID3D11ShaderResourceView
*)0xdeadbeef) ID3D11ShaderResourceView_Release(tmp_srv
);
7597 ID3D11DeviceContext1_GSSetConstantBuffers(context
, 0, 1, &cb
);
7598 ID3D11DeviceContext1_GSSetSamplers(context
, 0, 1, &sampler
);
7599 ID3D11DeviceContext1_GSSetShader(context
, gs
, NULL
, 0);
7600 ID3D11DeviceContext1_GSSetShaderResources(context
, 0, 1, &srv
);
7602 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7603 ID3D11DeviceContext1_GSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7604 todo_wine
ok(!tmp_cb
, "Got unexpected buffer %p.\n", tmp_cb
);
7605 if (tmp_cb
&& tmp_cb
!= (ID3D11Buffer
*)0xdeadbeef) ID3D11Buffer_Release(tmp_cb
);
7606 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7607 ID3D11DeviceContext1_GSGetSamplers(context
, 0, 1, &tmp_sampler
);
7608 todo_wine
ok(!tmp_sampler
, "Got unexpected sampler %p.\n", tmp_sampler
);
7609 if (tmp_sampler
&& tmp_sampler
!= (ID3D11SamplerState
*)0xdeadbeef) ID3D11SamplerState_Release(tmp_sampler
);
7610 tmp_gs
= (ID3D11GeometryShader
*)0xdeadbeef;
7611 ID3D11DeviceContext1_GSGetShader(context
, &tmp_gs
, NULL
, NULL
);
7612 todo_wine
ok(!tmp_gs
, "Got unexpected shader %p.\n", tmp_gs
);
7613 if (tmp_gs
&& tmp_gs
!= (ID3D11GeometryShader
*)0xdeadbeef) ID3D11GeometryShader_Release(tmp_gs
);
7614 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7615 ID3D11DeviceContext1_GSGetShaderResources(context
, 0, 1, &tmp_srv
);
7616 todo_wine
ok(!tmp_srv
, "Got unexpected srv %p.\n", tmp_srv
);
7617 if (tmp_srv
&& tmp_srv
!= (ID3D11ShaderResourceView
*)0xdeadbeef) ID3D11ShaderResourceView_Release(tmp_srv
);
7619 ID3D11DeviceContext1_PSSetConstantBuffers(context
, 0, 1, &cb
);
7620 ID3D11DeviceContext1_PSSetSamplers(context
, 0, 1, &sampler
);
7621 ID3D11DeviceContext1_PSSetShader(context
, ps
, NULL
, 0);
7622 ID3D11DeviceContext1_PSSetShaderResources(context
, 0, 1, &srv
);
7624 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7625 ID3D11DeviceContext1_PSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7626 todo_wine
ok(!tmp_cb
, "Got unexpected buffer %p.\n", tmp_cb
);
7627 if (tmp_cb
&& tmp_cb
!= (ID3D11Buffer
*)0xdeadbeef) ID3D11Buffer_Release(tmp_cb
);
7628 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7629 ID3D11DeviceContext1_PSGetSamplers(context
, 0, 1, &tmp_sampler
);
7630 todo_wine
ok(tmp_sampler
== (ID3D11SamplerState
*)0xdeadbeef, "Got unexpected sampler %p.\n", tmp_sampler
);
7631 if (tmp_sampler
&& tmp_sampler
!= (ID3D11SamplerState
*)0xdeadbeef) ID3D11SamplerState_Release(tmp_sampler
);
7632 tmp_ps
= (ID3D11PixelShader
*)0xdeadbeef;
7633 ID3D11DeviceContext1_PSGetShader(context
, &tmp_ps
, NULL
, NULL
);
7634 todo_wine
ok(!tmp_ps
, "Got unexpected shader %p.\n", tmp_ps
);
7635 if (tmp_ps
&& tmp_ps
!= (ID3D11PixelShader
*)0xdeadbeef) ID3D11PixelShader_Release(tmp_ps
);
7636 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7637 ID3D11DeviceContext1_PSGetShaderResources(context
, 0, 1, &tmp_srv
);
7638 todo_wine
ok(!tmp_srv
, "Got unexpected srv %p.\n", tmp_srv
);
7639 if (tmp_srv
&& tmp_srv
!= (ID3D11ShaderResourceView
*)0xdeadbeef) ID3D11ShaderResourceView_Release(tmp_srv
);
7641 ID3D11DeviceContext1_HSSetConstantBuffers(context
, 0, 1, &cb
);
7642 ID3D11DeviceContext1_HSSetSamplers(context
, 0, 1, &sampler
);
7643 ID3D11DeviceContext1_HSSetShader(context
, hs
, NULL
, 0);
7644 ID3D11DeviceContext1_HSSetShaderResources(context
, 0, 1, &srv
);
7646 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7647 ID3D11DeviceContext1_HSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7648 todo_wine
ok(!tmp_cb
, "Got unexpected buffer %p.\n", tmp_cb
);
7649 if (tmp_cb
&& tmp_cb
!= (ID3D11Buffer
*)0xdeadbeef) ID3D11Buffer_Release(tmp_cb
);
7650 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7651 ID3D11DeviceContext1_HSGetSamplers(context
, 0, 1, &tmp_sampler
);
7652 todo_wine
ok(!tmp_sampler
, "Got unexpected sampler %p.\n", tmp_sampler
);
7653 if (tmp_sampler
&& tmp_sampler
!= (ID3D11SamplerState
*)0xdeadbeef) ID3D11SamplerState_Release(tmp_sampler
);
7654 tmp_hs
= (ID3D11HullShader
*)0xdeadbeef;
7655 ID3D11DeviceContext1_HSGetShader(context
, &tmp_hs
, NULL
, NULL
);
7656 if (hs
) todo_wine
ok(!tmp_hs
, "Got unexpected shader %p.\n", tmp_hs
);
7657 if (tmp_hs
&& tmp_hs
!= (ID3D11HullShader
*)0xdeadbeef) ID3D11HullShader_Release(tmp_hs
);
7658 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7659 ID3D11DeviceContext1_HSGetShaderResources(context
, 0, 1, &tmp_srv
);
7660 todo_wine
ok(!tmp_srv
, "Got unexpected srv %p.\n", tmp_srv
);
7661 if (tmp_srv
&& tmp_srv
!= (ID3D11ShaderResourceView
*)0xdeadbeef) ID3D11ShaderResourceView_Release(tmp_srv
);
7663 ID3D11DeviceContext1_DSSetConstantBuffers(context
, 0, 1, &cb
);
7664 ID3D11DeviceContext1_DSSetSamplers(context
, 0, 1, &sampler
);
7665 ID3D11DeviceContext1_DSSetShader(context
, ds
, NULL
, 0);
7666 ID3D11DeviceContext1_DSSetShaderResources(context
, 0, 1, &srv
);
7668 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7669 ID3D11DeviceContext1_DSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7670 todo_wine
ok(!tmp_cb
, "Got unexpected buffer %p.\n", tmp_cb
);
7671 if (tmp_cb
&& tmp_cb
!= (ID3D11Buffer
*)0xdeadbeef) ID3D11Buffer_Release(tmp_cb
);
7672 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7673 ID3D11DeviceContext1_DSGetSamplers(context
, 0, 1, &tmp_sampler
);
7674 todo_wine
ok(!tmp_sampler
, "Got unexpected sampler %p.\n", tmp_sampler
);
7675 if (tmp_sampler
&& tmp_sampler
!= (ID3D11SamplerState
*)0xdeadbeef) ID3D11SamplerState_Release(tmp_sampler
);
7676 tmp_ds
= (ID3D11DomainShader
*)0xdeadbeef;
7677 ID3D11DeviceContext1_DSGetShader(context
, &tmp_ds
, NULL
, NULL
);
7678 if (ds
) todo_wine
ok(!tmp_ds
, "Got unexpected shader %p.\n", tmp_ds
);
7679 if (tmp_ds
&& tmp_ds
!= (ID3D11DomainShader
*)0xdeadbeef) ID3D11DomainShader_Release(tmp_ds
);
7680 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7681 ID3D11DeviceContext1_DSGetShaderResources(context
, 0, 1, &tmp_srv
);
7682 todo_wine
ok(!tmp_srv
, "Got unexpected srv %p.\n", tmp_srv
);
7683 if (tmp_srv
&& tmp_srv
!= (ID3D11ShaderResourceView
*)0xdeadbeef) ID3D11ShaderResourceView_Release(tmp_srv
);
7685 ID3D11DeviceContext1_CSSetConstantBuffers(context
, 0, 1, &cb
);
7686 ID3D11DeviceContext1_CSSetSamplers(context
, 0, 1, &sampler
);
7687 ID3D11DeviceContext1_CSSetShader(context
, cs
, NULL
, 0);
7688 ID3D11DeviceContext1_CSSetShaderResources(context
, 0, 1, &srv
);
7689 ID3D11DeviceContext1_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
7691 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7692 ID3D11DeviceContext1_CSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7693 todo_wine
ok(!tmp_cb
, "Got unexpected buffer %p.\n", tmp_cb
);
7694 if (tmp_cb
&& tmp_cb
!= (ID3D11Buffer
*)0xdeadbeef) ID3D11Buffer_Release(tmp_cb
);
7695 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7696 ID3D11DeviceContext1_CSGetSamplers(context
, 0, 1, &tmp_sampler
);
7697 todo_wine
ok(!tmp_sampler
, "Got unexpected sampler %p.\n", tmp_sampler
);
7698 if (tmp_sampler
&& tmp_sampler
!= (ID3D11SamplerState
*)0xdeadbeef) ID3D11SamplerState_Release(tmp_sampler
);
7699 tmp_cs
= (ID3D11ComputeShader
*)0xdeadbeef;
7700 ID3D11DeviceContext1_CSGetShader(context
, &tmp_cs
, NULL
, NULL
);
7701 if (cs
) todo_wine
ok(!tmp_cs
, "Got unexpected shader %p.\n", tmp_cs
);
7702 if (tmp_cs
&& tmp_cs
!= (ID3D11ComputeShader
*)0xdeadbeef) ID3D11ComputeShader_Release(tmp_cs
);
7703 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7704 ID3D11DeviceContext1_CSGetShaderResources(context
, 0, 1, &tmp_srv
);
7705 todo_wine
ok(!tmp_srv
, "Got unexpected srv %p.\n", tmp_srv
);
7706 if (tmp_srv
&& tmp_srv
!= (ID3D11ShaderResourceView
*)0xdeadbeef) ID3D11ShaderResourceView_Release(tmp_srv
);
7707 tmp_uav
= (ID3D11UnorderedAccessView
*)0xdeadbeef;
7708 ID3D11DeviceContext1_CSGetUnorderedAccessViews(context
, 0, 1, &tmp_uav
);
7709 todo_wine
ok(!tmp_uav
, "Got unexpected uav %p.\n", tmp_uav
);
7710 if (tmp_uav
&& tmp_uav
!= (ID3D11UnorderedAccessView
*)0xdeadbeef) ID3D11UnorderedAccessView_Release(tmp_uav
);
7712 ID3D11DeviceContext1_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
7713 ID3D11DeviceContext1_IASetInputLayout(context
, il
);
7714 ID3D11DeviceContext1_IASetIndexBuffer(context
, ib
, DXGI_FORMAT_R32_UINT
, ib_offset
);
7715 ID3D11DeviceContext1_IASetVertexBuffers(context
, 0, 1, &vb
, &vb_stride
, &vb_offset
);
7718 ID3D11DeviceContext1_IAGetPrimitiveTopology(context
, &topo
);
7719 todo_wine
ok(topo
== D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED
, "Got unexpected topology %#x.\n", topo
);
7720 tmp_il
= (ID3D11InputLayout
*)0xdeadbeef;
7721 ID3D11DeviceContext1_IAGetInputLayout(context
, &tmp_il
);
7722 todo_wine
ok(!tmp_il
, "Got unexpected input layout %p.\n", tmp_il
);
7723 if (tmp_il
) ID3D11InputLayout_Release(tmp_il
);
7724 tmp_ib
= (ID3D11Buffer
*)0xdeadbeef;
7725 format
= 0xdeadbeef;
7726 offset
= 0xdeadbeef;
7727 ID3D11DeviceContext1_IAGetIndexBuffer(context
, &tmp_ib
, &format
, &offset
);
7728 todo_wine
ok(!tmp_ib
, "Got unexpected input buffer %p.\n", tmp_ib
);
7729 if (tmp_ib
) ID3D11Buffer_Release(tmp_ib
);
7730 todo_wine
ok(format
== DXGI_FORMAT_UNKNOWN
, "Got unexpected input buffer format %#x.\n", format
);
7731 todo_wine
ok(offset
== 0, "Got unexpected input buffer offset %#x.\n", offset
);
7732 tmp_vb
= (ID3D11Buffer
*)0xdeadbeef;
7733 stride
= 0xdeadbeef;
7734 offset
= 0xdeadbeef;
7735 ID3D11DeviceContext1_IAGetVertexBuffers(context
, 0, 1, &tmp_vb
, &stride
, &offset
);
7736 todo_wine
ok(!tmp_vb
, "Got unexpected vertex buffer %p.\n", tmp_vb
);
7737 if (tmp_vb
) ID3D11Buffer_Release(tmp_vb
);
7738 todo_wine
ok(stride
== 0, "Got unexpected vertex buffer stride %#x.\n", stride
);
7739 todo_wine
ok(offset
== 0, "Got unexpected vertex buffer offset %#x.\n", offset
);
7741 ID3D11DeviceContext1_OMSetBlendState(context
, bs
, custom_blend_factor
, 0xff00ff00);
7742 ID3D11DeviceContext1_OMSetDepthStencilState(context
, dss
, 3);
7743 ID3D11DeviceContext1_OMSetRenderTargetsAndUnorderedAccessViews(context
, 1, &rtv
, dsv
, 1, 1, &ps_uav
, NULL
);
7745 tmp_rtv
= (ID3D11RenderTargetView
*)0xdeadbeef;
7746 tmp_dsv
= (ID3D11DepthStencilView
*)0xdeadbeef;
7747 tmp_uav
= (ID3D11UnorderedAccessView
*)0xdeadbeef;
7748 ID3D11DeviceContext1_OMGetRenderTargetsAndUnorderedAccessViews(context
, 1, &tmp_rtv
, &tmp_dsv
, 1, 1, &tmp_uav
);
7749 todo_wine
ok(!tmp_rtv
, "Got unexpected rendertarget view %p.\n", tmp_rtv
);
7750 if (tmp_rtv
) ID3D11RenderTargetView_Release(tmp_rtv
);
7751 todo_wine
ok(!tmp_dsv
, "Got unexpected depth/stencil view %p.\n", tmp_dsv
);
7752 if (tmp_dsv
) ID3D11DepthStencilView_Release(tmp_dsv
);
7753 todo_wine
ok(!tmp_uav
, "Got unexpected unordered access view %p.\n", tmp_uav
);
7754 if (tmp_uav
) ID3D11UnorderedAccessView_Release(tmp_uav
);
7755 tmp_bs
= (ID3D11BlendState
*)0xdeadbeef;
7756 memset(blend_factor
, 0xcd, sizeof(blend_factor
));
7757 sample_mask
= 0xdeadbeef;
7758 ID3D11DeviceContext1_OMGetBlendState(context
, &tmp_bs
, blend_factor
, &sample_mask
);
7759 todo_wine
ok(!tmp_bs
, "Got unexpected blend state %p.\n", tmp_bs
);
7760 if (tmp_bs
) ID3D11BlendState_Release(tmp_bs
);
7761 todo_wine
ok(!memcmp(blend_factor
, default_blend_factor
, sizeof(blend_factor
)),
7762 "Got unexpected blend factor %f,%f,%f,%f.\n",
7763 blend_factor
[0], blend_factor
[1], blend_factor
[2], blend_factor
[3]);
7764 todo_wine
ok(sample_mask
== ~0, "Got unexpected sample mask %#x.\n", sample_mask
);
7765 tmp_dss
= (ID3D11DepthStencilState
*)0xdeadbeef;
7766 stencil_ref
= 0xdeadbeef;
7767 ID3D11DeviceContext1_OMGetDepthStencilState(context
, &tmp_dss
, &stencil_ref
);
7768 todo_wine
ok(!tmp_dss
, "Got unexpected depth/stencil state %p.\n", tmp_dss
);
7769 if (tmp_dss
) ID3D11DepthStencilState_Release(tmp_dss
);
7770 todo_wine
ok(stencil_ref
== 0, "Got unexpected stencil ref %#x.\n", stencil_ref
);
7772 ID3D11DeviceContext1_RSSetScissorRects(context
, 1, &rect
);
7773 ID3D11DeviceContext1_RSSetViewports(context
, 1, &vp
);
7774 ID3D11DeviceContext1_RSSetState(context
, rs
);
7776 ID3D11DeviceContext1_SOSetTargets(context
, 1, &sob
, &so_offset
);
7777 ID3D11DeviceContext1_SetPredication(context
, pred
, TRUE
);
7779 tmp_rs
= (ID3D11RasterizerState
*)0xdeadbeef;
7780 ID3D11DeviceContext1_RSGetState(context
, &tmp_rs
);
7781 todo_wine
ok(!tmp_rs
, "Got unexpected rasterizer state %p.\n", tmp_rs
);
7782 if (tmp_rs
) ID3D11RasterizerState_Release(tmp_rs
);
7783 memset(tmp_vp
, 0xa5, sizeof(tmp_vp
));
7785 ID3D11DeviceContext1_RSGetViewports(context
, &count
, tmp_vp
);
7786 todo_wine
ok(count
== 0, "Got unexpected viewport count %u.\n", count
);
7787 memset(tmp_rect
, 0xa5, sizeof(tmp_rect
));
7789 ID3D11DeviceContext1_RSGetScissorRects(context
, &count
, tmp_rect
);
7790 todo_wine
ok(count
== 0, "Got unexpected scissor rect count %u.\n", count
);
7792 tmp_sob
= (ID3D11Buffer
*)0xdeadbeef;
7793 ID3D11DeviceContext1_SOGetTargets(context
, 1, &tmp_sob
);
7794 todo_wine
ok(!tmp_sob
, "Got unexpected stream output buffer %p.\n", tmp_sob
);
7795 if (tmp_sob
) ID3D11Buffer_Release(tmp_sob
);
7797 tmp_pred
= (ID3D11Predicate
*)0xdeadbeef;
7798 pred_value
= 0xdeadbeef;
7799 ID3D11DeviceContext1_GetPredication(context
, &tmp_pred
, &pred_value
);
7800 todo_wine
ok(!tmp_pred
, "Got unexpected predicate %p.\n", tmp_pred
);
7801 if (tmp_pred
) ID3D11Predicate_Release(tmp_pred
);
7802 todo_wine
ok(!pred_value
, "Got unexpected predicate value %d.\n", pred_value
);
7804 check_interface(device
, &IID_ID3D10Device
, TRUE
, FALSE
);
7805 check_interface(device
, &IID_ID3D10Device1
, TRUE
, FALSE
);
7807 context_state
= NULL
;
7808 ID3D11DeviceContext1_SwapDeviceContextState(context
, previous_context_state
, &context_state
);
7809 refcount
= ID3DDeviceContextState_Release(context_state
);
7810 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
7811 refcount
= ID3DDeviceContextState_Release(previous_context_state
);
7812 ok(!refcount
, "Got refcount %u, expected 0.\n", refcount
);
7814 /* ID3DDeviceContextState retains the previous state. */
7816 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7817 ID3D11DeviceContext1_VSGetSamplers(context
, 0, 1, &tmp_sampler
);
7818 ok(tmp_sampler
== sampler
, "Got sampler %p, expected %p.\n", tmp_sampler
, sampler
);
7819 ID3D11SamplerState_Release(tmp_sampler
);
7820 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7821 ID3D11DeviceContext1_VSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7822 ok(tmp_cb
== cb
, "Got buffer %p, expected %p.\n", tmp_cb
, cb
);
7823 ID3D11Buffer_Release(tmp_cb
);
7824 tmp_vs
= (ID3D11VertexShader
*)0xdeadbeef;
7825 ID3D11DeviceContext1_VSGetShader(context
, &tmp_vs
, NULL
, NULL
);
7826 ok(tmp_vs
== vs
, "Got shader %p, expected %p.\n", tmp_vs
, vs
);
7827 ID3D11VertexShader_Release(tmp_vs
);
7828 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7829 ID3D11DeviceContext1_VSGetShaderResources(context
, 0, 1, &tmp_srv
);
7830 ok(tmp_srv
== srv
, "Got srv %p, expected %p.\n", tmp_srv
, srv
);
7831 ID3D11ShaderResourceView_Release(tmp_srv
);
7833 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7834 ID3D11DeviceContext1_GSGetSamplers(context
, 0, 1, &tmp_sampler
);
7835 ok(tmp_sampler
== sampler
, "Got sampler %p, expected %p.\n", tmp_sampler
, sampler
);
7836 ID3D11SamplerState_Release(tmp_sampler
);
7837 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7838 ID3D11DeviceContext1_GSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7839 ok(tmp_cb
== cb
, "Got buffer %p, expected %p.\n", tmp_cb
, cb
);
7840 ID3D11Buffer_Release(tmp_cb
);
7841 tmp_gs
= (ID3D11GeometryShader
*)0xdeadbeef;
7842 ID3D11DeviceContext1_GSGetShader(context
, &tmp_gs
, NULL
, NULL
);
7843 ok(tmp_gs
== gs
, "Got shader %p, expected %p.\n", tmp_gs
, gs
);
7844 ID3D11GeometryShader_Release(tmp_gs
);
7845 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7846 ID3D11DeviceContext1_GSGetShaderResources(context
, 0, 1, &tmp_srv
);
7847 ok(tmp_srv
== srv
, "Got srv %p, expected %p.\n", tmp_srv
, srv
);
7848 ID3D11ShaderResourceView_Release(tmp_srv
);
7850 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7851 ID3D11DeviceContext1_PSGetSamplers(context
, 0, 1, &tmp_sampler
);
7852 ok(tmp_sampler
== sampler
, "Got sampler %p, expected %p.\n", tmp_sampler
, sampler
);
7853 ID3D11SamplerState_Release(tmp_sampler
);
7854 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7855 ID3D11DeviceContext1_PSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7856 ok(tmp_cb
== cb
, "Got buffer %p, expected %p.\n", tmp_cb
, cb
);
7857 ID3D11Buffer_Release(tmp_cb
);
7858 tmp_ps
= (ID3D11PixelShader
*)0xdeadbeef;
7859 ID3D11DeviceContext1_PSGetShader(context
, &tmp_ps
, NULL
, NULL
);
7860 ok(tmp_ps
== ps
, "Got shader %p, expected %p.\n", tmp_ps
, ps
);
7861 ID3D11PixelShader_Release(tmp_ps
);
7862 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7863 ID3D11DeviceContext1_PSGetShaderResources(context
, 0, 1, &tmp_srv
);
7864 ok(tmp_srv
== srv
, "Got srv %p, expected %p.\n", tmp_srv
, srv
);
7865 ID3D11ShaderResourceView_Release(tmp_srv
);
7867 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7868 ID3D11DeviceContext1_HSGetSamplers(context
, 0, 1, &tmp_sampler
);
7869 ok(tmp_sampler
== sampler
, "Got sampler %p, expected %p.\n", tmp_sampler
, sampler
);
7870 ID3D11SamplerState_Release(tmp_sampler
);
7871 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7872 ID3D11DeviceContext1_HSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7873 ok(tmp_cb
== cb
, "Got buffer %p, expected %p.\n", tmp_cb
, cb
);
7874 ID3D11Buffer_Release(tmp_cb
);
7875 tmp_hs
= (ID3D11HullShader
*)0xdeadbeef;
7876 ID3D11DeviceContext1_HSGetShader(context
, &tmp_hs
, NULL
, NULL
);
7877 ok(tmp_hs
== hs
, "Got shader %p, expected %p.\n", tmp_hs
, hs
);
7878 if (hs
) ID3D11HullShader_Release(tmp_hs
);
7879 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7880 ID3D11DeviceContext1_HSGetShaderResources(context
, 0, 1, &tmp_srv
);
7881 ok(tmp_srv
== srv
, "Got srv %p, expected %p.\n", tmp_srv
, srv
);
7882 ID3D11ShaderResourceView_Release(tmp_srv
);
7884 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7885 ID3D11DeviceContext1_DSGetSamplers(context
, 0, 1, &tmp_sampler
);
7886 ok(tmp_sampler
== sampler
, "Got sampler %p, expected %p.\n", tmp_sampler
, sampler
);
7887 ID3D11SamplerState_Release(tmp_sampler
);
7888 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7889 ID3D11DeviceContext1_DSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7890 ok(tmp_cb
== cb
, "Got buffer %p, expected %p.\n", tmp_cb
, cb
);
7891 ID3D11Buffer_Release(tmp_cb
);
7892 tmp_ds
= (ID3D11DomainShader
*)0xdeadbeef;
7893 ID3D11DeviceContext1_DSGetShader(context
, &tmp_ds
, NULL
, NULL
);
7894 ok(tmp_ds
== ds
, "Got shader %p, expected %p.\n", tmp_ds
, ds
);
7895 if (ds
) ID3D11DomainShader_Release(tmp_ds
);
7896 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7897 ID3D11DeviceContext1_DSGetShaderResources(context
, 0, 1, &tmp_srv
);
7898 ok(tmp_srv
== srv
, "Got srv %p, expected %p.\n", tmp_srv
, srv
);
7899 ID3D11ShaderResourceView_Release(tmp_srv
);
7901 tmp_sampler
= (ID3D11SamplerState
*)0xdeadbeef;
7902 ID3D11DeviceContext1_CSGetSamplers(context
, 0, 1, &tmp_sampler
);
7903 ok(tmp_sampler
== sampler
, "Got sampler %p, expected %p.\n", tmp_sampler
, sampler
);
7904 ID3D11SamplerState_Release(tmp_sampler
);
7905 tmp_cb
= (ID3D11Buffer
*)0xdeadbeef;
7906 ID3D11DeviceContext1_CSGetConstantBuffers(context
, 0, 1, &tmp_cb
);
7907 ok(tmp_cb
== cb
, "Got buffer %p, expected %p.\n", tmp_cb
, cb
);
7908 ID3D11Buffer_Release(tmp_cb
);
7909 tmp_cs
= (ID3D11ComputeShader
*)0xdeadbeef;
7910 ID3D11DeviceContext1_CSGetShader(context
, &tmp_cs
, NULL
, NULL
);
7911 ok(tmp_cs
== cs
, "Got shader %p, expected %p.\n", tmp_cs
, cs
);
7912 if (cs
) ID3D11ComputeShader_Release(tmp_cs
);
7913 tmp_srv
= (ID3D11ShaderResourceView
*)0xdeadbeef;
7914 ID3D11DeviceContext1_CSGetShaderResources(context
, 0, 1, &tmp_srv
);
7915 ok(tmp_srv
== srv
, "Got srv %p, expected %p.\n", tmp_srv
, srv
);
7916 ID3D11ShaderResourceView_Release(tmp_srv
);
7917 tmp_uav
= (ID3D11UnorderedAccessView
*)0xdeadbeef;
7918 ID3D11DeviceContext1_CSGetUnorderedAccessViews(context
, 0, 1, &tmp_uav
);
7919 ok(tmp_uav
== uav
, "Got uav %p, expected %p.\n", tmp_uav
, uav
);
7920 ID3D11UnorderedAccessView_Release(tmp_uav
);
7923 ID3D11DeviceContext1_IAGetPrimitiveTopology(context
, &topo
);
7924 ok(topo
== D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
, "Got topology %#x, expected %#x.\n", topo
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
7925 tmp_il
= (ID3D11InputLayout
*)0xdeadbeef;
7926 ID3D11DeviceContext1_IAGetInputLayout(context
, &tmp_il
);
7927 ok(tmp_il
== il
, "Got input layout %p, expected %p.\n", tmp_il
, il
);
7928 ID3D11InputLayout_Release(tmp_il
);
7929 tmp_ib
= (ID3D11Buffer
*)0xdeadbeef;
7930 format
= 0xdeadbeef;
7931 offset
= 0xdeadbeef;
7932 ID3D11DeviceContext1_IAGetIndexBuffer(context
, &tmp_ib
, &format
, &offset
);
7933 ok(tmp_ib
== ib
, "Got input buffer %p, expected %p.\n", tmp_ib
, ib
);
7934 ID3D11Buffer_Release(tmp_ib
);
7935 ok(format
== DXGI_FORMAT_R32_UINT
, "Got input buffer format %#x, expected %#x.\n", format
, DXGI_FORMAT_R32_UINT
);
7936 ok(offset
== 16, "Got input buffer offset %#x, expected 16.\n", offset
);
7937 tmp_vb
= (ID3D11Buffer
*)0xdeadbeef;
7938 stride
= 0xdeadbeef;
7939 offset
= 0xdeadbeef;
7940 ID3D11DeviceContext1_IAGetVertexBuffers(context
, 0, 1, &tmp_vb
, &stride
, &offset
);
7941 ok(tmp_vb
== vb
, "Got vertex buffer %p, expected %p.\n", tmp_vb
, vb
);
7942 ID3D11Buffer_Release(tmp_vb
);
7943 ok(stride
== 16, "Got vertex buffer stride %#x, expected 16.\n", stride
);
7944 ok(offset
== 16, "Got vertex buffer offset %#x, expected 16.\n", offset
);
7946 tmp_rtv
= (ID3D11RenderTargetView
*)0xdeadbeef;
7947 tmp_dsv
= (ID3D11DepthStencilView
*)0xdeadbeef;
7948 tmp_uav
= (ID3D11UnorderedAccessView
*)0xdeadbeef;
7949 ID3D11DeviceContext1_OMGetRenderTargetsAndUnorderedAccessViews(context
, 1, &tmp_rtv
, &tmp_dsv
, 1, 1, &tmp_uav
);
7950 ok(tmp_rtv
== rtv
, "Got rendertarget view %p, expected %p.\n", tmp_rtv
, rtv
);
7951 ID3D11RenderTargetView_Release(tmp_rtv
);
7952 ok(tmp_dsv
== dsv
, "Got depth/stencil view %p, expected %p.\n", tmp_dsv
, dsv
);
7953 ID3D11DepthStencilView_Release(tmp_dsv
);
7954 ok(tmp_uav
== ps_uav
, "Got unordered access view %p, expected %p.\n", tmp_uav
, ps_uav
);
7955 ID3D11UnorderedAccessView_Release(tmp_uav
);
7956 tmp_bs
= (ID3D11BlendState
*)0xdeadbeef;
7957 memset(blend_factor
, 0xcd, sizeof(blend_factor
));
7958 sample_mask
= 0xdeadbeef;
7959 ID3D11DeviceContext1_OMGetBlendState(context
, &tmp_bs
, blend_factor
, &sample_mask
);
7960 ok(tmp_bs
== bs
, "Got blend state %p, expected %p.\n", tmp_bs
, bs
);
7961 ID3D11BlendState_Release(tmp_bs
);
7962 ok(!memcmp(blend_factor
, custom_blend_factor
, sizeof(blend_factor
)),
7963 "Got blend factor %f,%f,%f,%f, expected %f,%f,%f,%f.\n",
7964 blend_factor
[0], blend_factor
[1], blend_factor
[2], blend_factor
[3],
7965 custom_blend_factor
[0], custom_blend_factor
[1], custom_blend_factor
[2], custom_blend_factor
[3]);
7966 ok(sample_mask
== 0xff00ff00, "Got sample mask %#x, expected %#x.\n", sample_mask
, 0xff00ff00);
7967 tmp_dss
= (ID3D11DepthStencilState
*)0xdeadbeef;
7968 stencil_ref
= 0xdeadbeef;
7969 ID3D11DeviceContext1_OMGetDepthStencilState(context
, &tmp_dss
, &stencil_ref
);
7970 ok(tmp_dss
== dss
, "Got depth/stencil state %p, expected %p.\n", tmp_dss
, dss
);
7971 ID3D11DepthStencilState_Release(tmp_dss
);
7972 ok(stencil_ref
== 3, "Got stencil ref %#x, expected 3.\n", stencil_ref
);
7974 tmp_rs
= (ID3D11RasterizerState
*)0xdeadbeef;
7975 ID3D11DeviceContext1_RSGetState(context
, &tmp_rs
);
7976 ok(tmp_rs
== rs
, "Got unexpected rasterizer state %p.\n", tmp_rs
);
7977 ID3D11RasterizerState_Release(tmp_rs
);
7978 memset(tmp_vp
, 0xa5, sizeof(tmp_vp
));
7980 ID3D11DeviceContext1_RSGetViewports(context
, &count
, tmp_vp
);
7981 ok(count
== 1, "Got viewport count %u, expected 1.\n", count
);
7982 ok(!memcmp(tmp_vp
, &vp
, sizeof(vp
)), "Got viewport %s, expected %s.\n",
7983 debugstr_viewport(tmp_vp
), debugstr_viewport(&vp
));
7984 memset(tmp_rect
, 0xa5, sizeof(tmp_rect
));
7986 ID3D11DeviceContext1_RSGetScissorRects(context
, &count
, tmp_rect
);
7987 ok(count
== 1, "Got scissor rect count %u, expected 1.\n", count
);
7988 ok(!memcmp(tmp_rect
, &rect
, sizeof(rect
)), "Got scissor rect %s, expected %s.\n",
7989 wine_dbgstr_rect(tmp_rect
), wine_dbgstr_rect(&rect
));
7991 tmp_sob
= (ID3D11Buffer
*)0xdeadbeef;
7992 ID3D11DeviceContext1_SOGetTargets(context
, 1, &tmp_sob
);
7993 ok(tmp_sob
== sob
, "Got stream output buffer %p, expected %p.\n", tmp_sob
, sob
);
7994 ID3D11Buffer_Release(tmp_sob
);
7996 tmp_pred
= (ID3D11Predicate
*)0xdeadbeef;
7997 pred_value
= 0xdeadbeef;
7998 ID3D11DeviceContext1_GetPredication(context
, &tmp_pred
, &pred_value
);
7999 ok(tmp_pred
== pred
, "Got predicate %p, expected %p.\n", tmp_pred
, pred
);
8000 ID3D11Predicate_Release(tmp_pred
);
8001 ok(pred_value
== TRUE
, "Got predicate value %#x, expected TRUE.\n", pred_value
);
8003 check_interface(device
, &IID_ID3D10Device
, TRUE
, FALSE
);
8004 check_interface(device
, &IID_ID3D10Device1
, TRUE
, FALSE
);
8006 ID3D11Predicate_Release(pred
);
8007 ID3D11Buffer_Release(sob
);
8008 ID3D11RasterizerState_Release(rs
);
8009 ID3D11BlendState_Release(bs
);
8010 ID3D11DepthStencilState_Release(dss
);
8011 ID3D11DepthStencilView_Release(dsv
);
8012 ID3D11RenderTargetView_Release(rtv
);
8013 ID3D11UnorderedAccessView_Release(ps_uav
);
8014 ID3D11InputLayout_Release(il
);
8015 ID3D11Buffer_Release(ib
);
8016 ID3D11Buffer_Release(vb
);
8017 if (cs
) ID3D11ComputeShader_Release(cs
);
8018 if (ds
) ID3D11DomainShader_Release(ds
);
8019 if (hs
) ID3D11HullShader_Release(hs
);
8020 ID3D11PixelShader_Release(ps
);
8021 ID3D11GeometryShader_Release(gs
);
8022 ID3D11VertexShader_Release(vs
);
8023 ID3D11Buffer_Release(cb
);
8024 ID3D11ShaderResourceView_Release(srv
);
8025 ID3D11UnorderedAccessView_Release(uav
);
8026 ID3D11SamplerState_Release(sampler
);
8027 ID3D11DeviceContext1_Release(context
);
8028 refcount
= ID3D11Device1_Release(device
);
8029 ok(!refcount
, "Device has %u references left.\n", refcount
);
8032 static void test_blend(void)
8034 ID3D11BlendState
*src_blend
, *dst_blend
, *dst_blend_factor
;
8035 struct d3d11_test_context test_context
;
8036 ID3D11RenderTargetView
*offscreen_rtv
;
8037 D3D11_TEXTURE2D_DESC texture_desc
;
8038 ID3D11InputLayout
*input_layout
;
8039 ID3D11DeviceContext
*context
;
8040 D3D11_BLEND_DESC blend_desc
;
8041 unsigned int stride
, offset
;
8042 ID3D11Texture2D
*offscreen
;
8043 ID3D11VertexShader
*vs
;
8044 ID3D11PixelShader
*ps
;
8045 ID3D11Device
*device
;
8050 static const DWORD vs_code
[] =
8055 float4 position
: SV_POSITION
;
8056 float4 color
: COLOR
;
8059 struct vs_out
main(float4 position
: POSITION
, float4 color
: COLOR
)
8063 o
.position
= position
;
8069 0x43425844, 0x5c73b061, 0x5c71125f, 0x3f8b345f, 0xce04b9ab, 0x00000001, 0x00000140, 0x00000003,
8070 0x0000002c, 0x0000007c, 0x000000d0, 0x4e475349, 0x00000048, 0x00000002, 0x00000008, 0x00000038,
8071 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
8072 0x00000003, 0x00000001, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x4e47534f,
8073 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003, 0x00000000,
8074 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x505f5653,
8075 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000068, 0x00010040, 0x0000001a,
8076 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067, 0x001020f2,
8077 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2, 0x00000000,
8078 0x00101e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001, 0x0100003e,
8080 static const DWORD ps_code
[] =
8085 float4 position
: SV_POSITION
;
8086 float4 color
: COLOR
;
8089 float4
main(struct vs_out i
) : SV_TARGET
8094 0x43425844, 0xe2087fa6, 0xa35fbd95, 0x8e585b3f, 0x67890f54, 0x00000001, 0x000000f4, 0x00000003,
8095 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
8096 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
8097 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
8098 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
8099 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040,
8100 0x0000000e, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
8101 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
8105 struct vec3 position
;
8111 {{-1.0f
, -1.0f
, 0.1f
}, 0x4000ff00},
8112 {{-1.0f
, 0.0f
, 0.1f
}, 0x4000ff00},
8113 {{ 1.0f
, -1.0f
, 0.1f
}, 0x4000ff00},
8114 {{ 1.0f
, 0.0f
, 0.1f
}, 0x4000ff00},
8116 {{-1.0f
, 0.0f
, 0.1f
}, 0xc0ff0000},
8117 {{-1.0f
, 1.0f
, 0.1f
}, 0xc0ff0000},
8118 {{ 1.0f
, 0.0f
, 0.1f
}, 0xc0ff0000},
8119 {{ 1.0f
, 1.0f
, 0.1f
}, 0xc0ff0000},
8121 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
8123 {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
8124 {"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, 12, D3D11_INPUT_PER_VERTEX_DATA
, 0},
8126 static const float blend_factor
[] = {0.3f
, 0.4f
, 0.8f
, 0.9f
};
8127 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
8129 if (!init_test_context(&test_context
, NULL
))
8132 device
= test_context
.device
;
8133 context
= test_context
.immediate_context
;
8135 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
8136 vs_code
, sizeof(vs_code
), &input_layout
);
8137 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
8139 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(quads
), quads
);
8141 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
8142 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
8143 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
8144 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
8146 memset(&blend_desc
, 0, sizeof(blend_desc
));
8147 blend_desc
.RenderTarget
[0].BlendEnable
= TRUE
;
8148 blend_desc
.RenderTarget
[0].SrcBlend
= D3D11_BLEND_SRC_ALPHA
;
8149 blend_desc
.RenderTarget
[0].DestBlend
= D3D11_BLEND_INV_SRC_ALPHA
;
8150 blend_desc
.RenderTarget
[0].BlendOp
= D3D11_BLEND_OP_ADD
;
8151 blend_desc
.RenderTarget
[0].SrcBlendAlpha
= D3D11_BLEND_SRC_ALPHA
;
8152 blend_desc
.RenderTarget
[0].DestBlendAlpha
= D3D11_BLEND_INV_SRC_ALPHA
;
8153 blend_desc
.RenderTarget
[0].BlendOpAlpha
= D3D11_BLEND_OP_ADD
;
8154 blend_desc
.RenderTarget
[0].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_ALL
;
8156 hr
= ID3D11Device_CreateBlendState(device
, &blend_desc
, &src_blend
);
8157 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
8159 blend_desc
.RenderTarget
[0].SrcBlend
= D3D11_BLEND_DEST_ALPHA
;
8160 blend_desc
.RenderTarget
[0].DestBlend
= D3D11_BLEND_INV_DEST_ALPHA
;
8161 blend_desc
.RenderTarget
[0].SrcBlendAlpha
= D3D11_BLEND_DEST_ALPHA
;
8162 blend_desc
.RenderTarget
[0].DestBlendAlpha
= D3D11_BLEND_INV_DEST_ALPHA
;
8164 hr
= ID3D11Device_CreateBlendState(device
, &blend_desc
, &dst_blend
);
8165 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
8167 blend_desc
.RenderTarget
[0].SrcBlend
= D3D11_BLEND_BLEND_FACTOR
;
8168 blend_desc
.RenderTarget
[0].DestBlend
= D3D11_BLEND_INV_BLEND_FACTOR
;
8169 blend_desc
.RenderTarget
[0].SrcBlendAlpha
= D3D11_BLEND_DEST_ALPHA
;
8170 blend_desc
.RenderTarget
[0].DestBlendAlpha
= D3D11_BLEND_INV_DEST_ALPHA
;
8172 hr
= ID3D11Device_CreateBlendState(device
, &blend_desc
, &dst_blend_factor
);
8173 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
8175 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
8176 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
8177 stride
= sizeof(*quads
);
8179 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, &stride
, &offset
);
8180 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
8181 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
8183 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
8185 ID3D11DeviceContext_OMSetBlendState(context
, src_blend
, NULL
, D3D11_DEFAULT_SAMPLE_MASK
);
8186 ID3D11DeviceContext_Draw(context
, 4, 0);
8187 ID3D11DeviceContext_OMSetBlendState(context
, dst_blend
, NULL
, D3D11_DEFAULT_SAMPLE_MASK
);
8188 ID3D11DeviceContext_Draw(context
, 4, 4);
8190 color
= get_texture_color(test_context
.backbuffer
, 320, 360);
8191 ok(compare_color(color
, 0x700040bf, 1), "Got unexpected color 0x%08x.\n", color
);
8192 color
= get_texture_color(test_context
.backbuffer
, 320, 120);
8193 ok(compare_color(color
, 0xa080007f, 1), "Got unexpected color 0x%08x.\n", color
);
8195 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
8197 ID3D11DeviceContext_OMSetBlendState(context
, dst_blend_factor
, blend_factor
, D3D11_DEFAULT_SAMPLE_MASK
);
8198 ID3D11DeviceContext_Draw(context
, 4, 0);
8199 ID3D11DeviceContext_Draw(context
, 4, 4);
8201 color
= get_texture_color(test_context
.backbuffer
, 320, 360);
8202 ok(compare_color(color
, 0x600066b3, 1), "Got unexpected color 0x%08x.\n", color
);
8203 color
= get_texture_color(test_context
.backbuffer
, 320, 120);
8204 ok(compare_color(color
, 0xa0cc00b3, 1), "Got unexpected color 0x%08x.\n", color
);
8206 texture_desc
.Width
= 128;
8207 texture_desc
.Height
= 128;
8208 texture_desc
.MipLevels
= 1;
8209 texture_desc
.ArraySize
= 1;
8210 texture_desc
.Format
= DXGI_FORMAT_B8G8R8X8_UNORM
;
8211 texture_desc
.SampleDesc
.Count
= 1;
8212 texture_desc
.SampleDesc
.Quality
= 0;
8213 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
8214 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
| D3D11_BIND_RENDER_TARGET
;
8215 texture_desc
.CPUAccessFlags
= 0;
8216 texture_desc
.MiscFlags
= 0;
8218 /* DXGI_FORMAT_B8G8R8X8_UNORM is not supported on all implementations. */
8219 if (FAILED(ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &offscreen
)))
8221 skip("DXGI_FORMAT_B8G8R8X8_UNORM not supported.\n");
8225 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)offscreen
, NULL
, &offscreen_rtv
);
8226 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
8228 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &offscreen_rtv
, NULL
);
8230 set_viewport(context
, 0.0f
, 0.0f
, 128.0f
, 128.0f
, 0.0f
, 1.0f
);
8232 ID3D11DeviceContext_ClearRenderTargetView(context
, offscreen_rtv
, red
);
8234 ID3D11DeviceContext_OMSetBlendState(context
, src_blend
, NULL
, D3D11_DEFAULT_SAMPLE_MASK
);
8235 ID3D11DeviceContext_Draw(context
, 4, 0);
8236 ID3D11DeviceContext_OMSetBlendState(context
, dst_blend
, NULL
, D3D11_DEFAULT_SAMPLE_MASK
);
8237 ID3D11DeviceContext_Draw(context
, 4, 4);
8239 color
= get_texture_color(offscreen
, 64, 96) & 0x00ffffff;
8240 ok(compare_color(color
, 0x00bf4000, 1), "Got unexpected color 0x%08x.\n", color
);
8241 color
= get_texture_color(offscreen
, 64, 32) & 0x00ffffff;
8242 ok(compare_color(color
, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color
);
8244 ID3D11RenderTargetView_Release(offscreen_rtv
);
8245 ID3D11Texture2D_Release(offscreen
);
8247 ID3D11BlendState_Release(dst_blend_factor
);
8248 ID3D11BlendState_Release(dst_blend
);
8249 ID3D11BlendState_Release(src_blend
);
8250 ID3D11PixelShader_Release(ps
);
8251 ID3D11VertexShader_Release(vs
);
8252 ID3D11Buffer_Release(vb
);
8253 ID3D11InputLayout_Release(input_layout
);
8254 release_test_context(&test_context
);
8257 static void test_texture1d(void)
8267 UINT miplevel_count
;
8270 D3D11_SUBRESOURCE_DATA data
[3];
8273 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
8274 struct d3d11_test_context test_context
;
8275 const struct texture
*current_texture
;
8276 D3D11_TEXTURE1D_DESC texture_desc
;
8277 D3D11_SAMPLER_DESC sampler_desc
;
8278 const struct shader
*current_ps
;
8279 D3D_FEATURE_LEVEL feature_level
;
8280 ID3D11ShaderResourceView
*srv
;
8281 ID3D11DeviceContext
*context
;
8282 ID3D11SamplerState
*sampler
;
8283 struct resource_readback rb
;
8284 ID3D11Texture1D
*texture
;
8285 struct vec4 ps_constant
;
8286 ID3D11PixelShader
*ps
;
8287 ID3D11Device
*device
;
8293 static const DWORD ps_ld_code
[] =
8300 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
8303 t
.GetDimensions(miplevel
, p
.x
, p
.y
);
8305 p
*= float2(position
.x
/ 640.0f
, 1.0f
);
8306 return t
.Load(int2(p
));
8309 0x43425844, 0x7b0c6359, 0x598178f6, 0xef2ddbdb, 0x88fc794c, 0x00000001, 0x000001ac, 0x00000003,
8310 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
8311 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000010f, 0x505f5653, 0x5449534f, 0x004e4f49,
8312 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
8313 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000110, 0x00000040,
8314 0x00000044, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04001058, 0x00107000, 0x00000000,
8315 0x00005555, 0x04002064, 0x00101012, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
8316 0x02000068, 0x00000001, 0x0600001c, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000,
8317 0x0700003d, 0x001000f2, 0x00000000, 0x0010000a, 0x00000000, 0x00107e46, 0x00000000, 0x07000038,
8318 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x0010100a, 0x00000000, 0x06000036, 0x001000e2,
8319 0x00000000, 0x00208006, 0x00000000, 0x00000000, 0x0a000038, 0x001000f2, 0x00000000, 0x00100e46,
8320 0x00000000, 0x00004002, 0x3acccccd, 0x3f800000, 0x3f800000, 0x3f800000, 0x0500001b, 0x001000f2,
8321 0x00000000, 0x00100e46, 0x00000000, 0x0700002d, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
8322 0x00107e46, 0x00000000, 0x0100003e,
8324 static const struct shader ps_ld
= {ps_ld_code
, sizeof(ps_ld_code
)};
8325 static const DWORD ps_ld_sint8_code
[] =
8330 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
8335 p
= float2(position
.x
/ 640.0f
, 0.0f
);
8336 t
.GetDimensions(0, s
.x
, s
.y
);
8339 c
= t
.Load(int2(p
));
8340 return (max(c
/ (float4
)127, (float4
)-1) + (float4
)1) / 2.0f
;
8343 0x43425844, 0x65a13d1e, 0x8a0bfc92, 0xa2f2708a, 0x0bafafb6, 0x00000001, 0x00000234, 0x00000003,
8344 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
8345 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000010f, 0x505f5653, 0x5449534f, 0x004e4f49,
8346 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
8347 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000198, 0x00000040,
8348 0x00000066, 0x04001058, 0x00107000, 0x00000000, 0x00003333, 0x04002064, 0x00101012, 0x00000000,
8349 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x0700003d, 0x001000f2,
8350 0x00000000, 0x00004001, 0x00000000, 0x00107e46, 0x00000000, 0x07000038, 0x00100012, 0x00000001,
8351 0x0010100a, 0x00000000, 0x00004001, 0x3acccccd, 0x08000036, 0x001000e2, 0x00000001, 0x00004002,
8352 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07000038, 0x001000f2, 0x00000000, 0x00100fc6,
8353 0x00000000, 0x00100e46, 0x00000001, 0x0500001b, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
8354 0x0700002d, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00107e46, 0x00000000, 0x0500002b,
8355 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x0a000038, 0x001000f2, 0x00000000, 0x00100e46,
8356 0x00000000, 0x00004002, 0x3c010204, 0x3c010204, 0x3c010204, 0x3c010204, 0x0a000034, 0x001000f2,
8357 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0xbf800000, 0xbf800000, 0xbf800000, 0xbf800000,
8358 0x0a000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3f800000, 0x3f800000,
8359 0x3f800000, 0x3f800000, 0x0a000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002,
8360 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, 0x0100003e,
8362 static const struct shader ps_ld_sint8
= {ps_ld_sint8_code
, sizeof(ps_ld_sint8_code
)};
8363 static const DWORD ps_ld_uint8_code
[] =
8368 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
8372 p
= float2(position
.x
/ 640.0f
, 0.0f
);
8373 t
.GetDimensions(0, s
.x
, s
.y
);
8376 return t
.Load(int2(p
)) / (float4
)255;
8379 0x43425844, 0x35186c1f, 0x55bad4fd, 0xb7c97a57, 0x99c060e7, 0x00000001, 0x000001bc, 0x00000003,
8380 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
8381 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000010f, 0x505f5653, 0x5449534f, 0x004e4f49,
8382 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
8383 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000120, 0x00000040,
8384 0x00000048, 0x04001058, 0x00107000, 0x00000000, 0x00004444, 0x04002064, 0x00101012, 0x00000000,
8385 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x0700003d, 0x001000f2,
8386 0x00000000, 0x00004001, 0x00000000, 0x00107e46, 0x00000000, 0x07000038, 0x00100012, 0x00000001,
8387 0x0010100a, 0x00000000, 0x00004001, 0x3acccccd, 0x08000036, 0x001000e2, 0x00000001, 0x00004002,
8388 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07000038, 0x001000f2, 0x00000000, 0x00100fc6,
8389 0x00000000, 0x00100e46, 0x00000001, 0x0500001b, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
8390 0x0700002d, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00107e46, 0x00000000, 0x05000056,
8391 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x0a000038, 0x001020f2, 0x00000000, 0x00100e46,
8392 0x00000000, 0x00004002, 0x3b808081, 0x3b808081, 0x3b808081, 0x3b808081, 0x0100003e,
8394 static const struct shader ps_ld_uint8
= {ps_ld_uint8_code
, sizeof(ps_ld_uint8_code
)};
8395 static DWORD ps_ld_array_code
[] =
8402 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
8405 t
.GetDimensions(miplevel
, p
.x
, p
.y
, p
.z
);
8408 p
*= float3(position
.x
/ 640.0f
, 1.0f
, 1.0f
);
8409 return t
.Load(int3(p
));
8412 0x43425844, 0xbfccadc4, 0xc00ff13d, 0x2ba75365, 0xf747cbee, 0x00000001, 0x000001c0, 0x00000003,
8413 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
8414 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000010f, 0x505f5653, 0x5449534f, 0x004e4f49,
8415 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
8416 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000124, 0x00000040,
8417 0x00000049, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04003858, 0x00107000, 0x00000000,
8418 0x00005555, 0x04002064, 0x00101012, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
8419 0x02000068, 0x00000001, 0x0600001c, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000,
8420 0x0700003d, 0x001000f2, 0x00000000, 0x0010000a, 0x00000000, 0x00107e46, 0x00000000, 0x07000038,
8421 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x0010100a, 0x00000000, 0x06000036, 0x001000c2,
8422 0x00000000, 0x00208006, 0x00000000, 0x00000000, 0x0a000038, 0x00100072, 0x00000000, 0x00100386,
8423 0x00000000, 0x00004002, 0x3acccccd, 0x3f800000, 0x3f800000, 0x00000000, 0x0500001b, 0x001000d2,
8424 0x00000000, 0x00100906, 0x00000000, 0x05000036, 0x00100022, 0x00000000, 0x00004001, 0x00000001,
8425 0x0700002d, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00107e46, 0x00000000, 0x0100003e,
8427 static const struct shader ps_ld_array
= {ps_ld_array_code
, sizeof(ps_ld_array_code
)};
8429 static const DWORD rgba_level_0
[] =
8431 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
8433 static const DWORD rgba_level_1
[] =
8435 0xffffffff, 0xff0000ff,
8437 static const DWORD rgba_level_2
[] =
8441 static const DWORD srgb_data
[] =
8443 0x00000000, 0xffffffff, 0xff000000, 0x7f7f7f7f,
8445 static const DWORD r32_uint
[] =
8449 static const DWORD r9g9b9e5_data
[] =
8451 0x80000100, 0x80020000, 0x84000000, 0x84000100,
8453 static const DWORD array_data0
[] =
8455 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
8457 static const DWORD array_data1
[] =
8459 0x00ffff00, 0xff000000, 0x00ff0000, 0x000000ff,
8461 static const DWORD array_data2
[] =
8463 0x000000ff, 0xffff00ff, 0x0000ff00, 0xff000000,
8465 static const struct texture rgba_texture
=
8467 4, 3, 1, DXGI_FORMAT_R8G8B8A8_UNORM
,
8469 {rgba_level_0
, 4 * sizeof(*rgba_level_0
), 0},
8470 {rgba_level_1
, 2 * sizeof(*rgba_level_1
), 0},
8471 {rgba_level_2
, sizeof(*rgba_level_2
), 0},
8474 static const struct texture srgb_texture
= {4, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
8475 {{srgb_data
, 4 * sizeof(*srgb_data
)}}};
8476 static const struct texture sint8_texture
= {4, 1, 1, DXGI_FORMAT_R8G8B8A8_SINT
,
8477 {{rgba_level_0
, 4 * sizeof(*rgba_level_0
)}}};
8478 static const struct texture uint8_texture
= {4, 1, 1, DXGI_FORMAT_R8G8B8A8_UINT
,
8479 {{rgba_level_0
, 4 * sizeof(*rgba_level_0
)}}};
8480 static const struct texture r32u_typeless
= {4, 1, 1, DXGI_FORMAT_R32_TYPELESS
,
8481 {{r32_uint
, 4 * sizeof(*r32_uint
)}}};
8482 static const struct texture r9g9b9e5_texture
= {4, 1, 1, DXGI_FORMAT_R9G9B9E5_SHAREDEXP
,
8483 {{r9g9b9e5_data
, 4 * sizeof(*r9g9b9e5_data
)}}};
8484 static const struct texture array_texture
= {4, 1, 3, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
8486 {array_data0
, 4 * sizeof(*array_data0
)},
8487 {array_data1
, 4 * sizeof(*array_data1
)},
8488 {array_data2
, 4 * sizeof(*array_data2
)},
8492 static const DWORD level_1_colors
[] =
8494 0xffffffff, 0xffffffff, 0xff0000ff, 0xff0000ff,
8496 static const DWORD level_2_colors
[] =
8498 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
8500 static const DWORD srgb_colors
[] =
8502 0x00000001, 0xffffffff, 0xff000000, 0x7f363636,
8504 static const DWORD sint8_colors
[] =
8506 0x7e80807e, 0x7e807e7e, 0x7e807e80, 0x7e7e7e80,
8508 static const DWORD r32u_colors
[4] =
8510 0x01000000, 0x01000001, 0x01000002, 0x01000003,
8512 static const DWORD r9g9b9e5_colors
[4] =
8514 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffff00ff,
8516 static const DWORD zero_colors
[4] = {0};
8517 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
8518 static const struct texture_test
8520 const struct shader
*ps
;
8521 const struct texture
*texture
;
8522 D3D11_FILTER filter
;
8527 const DWORD
*expected_colors
;
8531 #define POINT D3D11_FILTER_MIN_MAG_MIP_POINT
8532 #define POINT_LINEAR D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR
8533 #define MIP_MAX D3D11_FLOAT32_MAX
8534 {&ps_ld
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, rgba_level_0
},
8535 {&ps_ld
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, level_1_colors
},
8536 {&ps_ld
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 2.0f
, level_2_colors
},
8537 {&ps_ld
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 3.0f
, zero_colors
},
8538 {&ps_ld
, &srgb_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, srgb_colors
},
8539 {&ps_ld
, &r9g9b9e5_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, r9g9b9e5_colors
},
8540 {&ps_ld
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, zero_colors
},
8541 {&ps_ld
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, zero_colors
},
8542 {&ps_ld_sint8
, &sint8_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, sint8_colors
},
8543 {&ps_ld_uint8
, &uint8_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, rgba_level_0
},
8544 {&ps_ld_array
, &array_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, array_data1
},
8549 static const struct srv_test
8551 const struct shader
*ps
;
8552 const struct texture
*texture
;
8553 struct srv_desc srv_desc
;
8555 const DWORD
*expected_colors
;
8559 #define TEX_1D D3D11_SRV_DIMENSION_TEXTURE1D
8560 #define R32_UINT DXGI_FORMAT_R32_UINT
8561 {&ps_ld_uint8
, &r32u_typeless
, {R32_UINT
, TEX_1D
, 0, 1}, 0.0f
, r32u_colors
},
8567 if (!init_test_context(&test_context
, NULL
))
8570 device
= test_context
.device
;
8571 context
= test_context
.immediate_context
;
8572 feature_level
= ID3D11Device_GetFeatureLevel(device
);
8574 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(ps_constant
), NULL
);
8576 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
8578 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
8579 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
8580 texture_desc
.CPUAccessFlags
= 0;
8581 texture_desc
.MiscFlags
= 0;
8583 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
8584 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
8585 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
8586 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
8587 sampler_desc
.MipLODBias
= 0.0f
;
8588 sampler_desc
.MaxAnisotropy
= 0;
8589 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
8590 sampler_desc
.BorderColor
[0] = 0.0f
;
8591 sampler_desc
.BorderColor
[1] = 0.0f
;
8592 sampler_desc
.BorderColor
[2] = 0.0f
;
8593 sampler_desc
.BorderColor
[3] = 0.0f
;
8594 sampler_desc
.MinLOD
= 0.0f
;
8595 sampler_desc
.MaxLOD
= D3D11_FLOAT32_MAX
;
8602 current_texture
= NULL
;
8603 for (i
= 0; i
< ARRAY_SIZE(texture_tests
); ++i
)
8605 const struct texture_test
*test
= &texture_tests
[i
];
8607 if (current_ps
!= test
->ps
)
8610 ID3D11PixelShader_Release(ps
);
8612 current_ps
= test
->ps
;
8614 hr
= ID3D11Device_CreatePixelShader(device
, current_ps
->code
, current_ps
->size
, NULL
, &ps
);
8615 ok(SUCCEEDED(hr
), "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
8617 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
8620 if (current_texture
!= test
->texture
)
8623 ID3D11Texture1D_Release(texture
);
8625 ID3D11ShaderResourceView_Release(srv
);
8627 current_texture
= test
->texture
;
8629 if (current_texture
)
8631 texture_desc
.Width
= current_texture
->width
;
8632 texture_desc
.MipLevels
= current_texture
->miplevel_count
;
8633 texture_desc
.ArraySize
= current_texture
->array_size
;
8634 texture_desc
.Format
= current_texture
->format
;
8636 hr
= ID3D11Device_CreateTexture1D(device
, &texture_desc
, current_texture
->data
, &texture
);
8637 ok(SUCCEEDED(hr
), "Test %u: Failed to create 1d texture, hr %#x.\n", i
, hr
);
8639 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
8640 ok(SUCCEEDED(hr
), "Test %u: Failed to create shader resource view, hr %#x.\n", i
, hr
);
8648 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
8651 if (!sampler
|| (sampler_desc
.Filter
!= test
->filter
8652 || sampler_desc
.MipLODBias
!= test
->lod_bias
8653 || sampler_desc
.MinLOD
!= test
->min_lod
8654 || sampler_desc
.MaxLOD
!= test
->max_lod
))
8657 ID3D11SamplerState_Release(sampler
);
8659 sampler_desc
.Filter
= test
->filter
;
8660 sampler_desc
.MipLODBias
= test
->lod_bias
;
8661 sampler_desc
.MinLOD
= test
->min_lod
;
8662 sampler_desc
.MaxLOD
= test
->max_lod
;
8664 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler
);
8665 ok(SUCCEEDED(hr
), "Test %u: Failed to create sampler state, hr %#x.\n", i
, hr
);
8667 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler
);
8670 ps_constant
.x
= test
->ps_constant
;
8671 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &ps_constant
, 0, 0);
8673 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
8675 draw_quad(&test_context
);
8677 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
8678 for (x
= 0; x
< 4; ++x
)
8680 color
= get_readback_color(&rb
, 80 + x
* 160, 0, 0);
8681 ok(compare_color(color
, test
->expected_colors
[x
], 2),
8682 "Test %u: Got unexpected color 0x%08x at (%u).\n", i
, color
, x
);
8684 release_resource_readback(&rb
);
8687 ID3D11ShaderResourceView_Release(srv
);
8688 ID3D11SamplerState_Release(sampler
);
8690 ID3D11Texture1D_Release(texture
);
8691 ID3D11PixelShader_Release(ps
);
8693 if (is_warp_device(device
) && feature_level
< D3D_FEATURE_LEVEL_11_0
)
8695 win_skip("SRV tests are broken on WARP.\n");
8696 ID3D11Buffer_Release(cb
);
8697 release_test_context(&test_context
);
8701 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
8702 sampler_desc
.MipLODBias
= 0.0f
;
8703 sampler_desc
.MinLOD
= 0.0f
;
8704 sampler_desc
.MaxLOD
= D3D11_FLOAT32_MAX
;
8706 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler
);
8707 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
8709 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler
);
8715 current_texture
= NULL
;
8716 for (i
= 0; i
< ARRAY_SIZE(srv_tests
); ++i
)
8718 const struct srv_test
*test
= &srv_tests
[i
];
8720 if (current_ps
!= test
->ps
)
8723 ID3D11PixelShader_Release(ps
);
8725 current_ps
= test
->ps
;
8727 hr
= ID3D11Device_CreatePixelShader(device
, current_ps
->code
, current_ps
->size
, NULL
, &ps
);
8728 ok(SUCCEEDED(hr
), "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
8730 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
8733 if (current_texture
!= test
->texture
)
8736 ID3D11Texture1D_Release(texture
);
8738 current_texture
= test
->texture
;
8740 texture_desc
.Width
= current_texture
->width
;
8741 texture_desc
.MipLevels
= current_texture
->miplevel_count
;
8742 texture_desc
.ArraySize
= current_texture
->array_size
;
8743 texture_desc
.Format
= current_texture
->format
;
8745 hr
= ID3D11Device_CreateTexture1D(device
, &texture_desc
, current_texture
->data
, &texture
);
8746 ok(SUCCEEDED(hr
), "Test %u: Failed to create 1d texture, hr %#x.\n", i
, hr
);
8750 ID3D11ShaderResourceView_Release(srv
);
8752 get_srv_desc(&srv_desc
, &test
->srv_desc
);
8753 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, &srv_desc
, &srv
);
8754 ok(SUCCEEDED(hr
), "Test %u: Failed to create shader resource view, hr %#x.\n", i
, hr
);
8756 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
8758 ps_constant
.x
= test
->ps_constant
;
8759 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &ps_constant
, 0, 0);
8761 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
8763 draw_quad(&test_context
);
8765 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
8766 for (x
= 0; x
< 4; ++x
)
8768 color
= get_readback_color(&rb
, 80 + x
* 160, 0, 0);
8769 ok(compare_color(color
, test
->expected_colors
[x
], 1),
8770 "Test %u: Got unexpected color 0x%08x at (%u).\n", i
, color
, x
);
8772 release_resource_readback(&rb
);
8774 ID3D11PixelShader_Release(ps
);
8775 ID3D11Texture1D_Release(texture
);
8776 ID3D11ShaderResourceView_Release(srv
);
8777 ID3D11SamplerState_Release(sampler
);
8779 ID3D11Buffer_Release(cb
);
8780 release_test_context(&test_context
);
8783 static void test_texture(void)
8794 UINT miplevel_count
;
8797 D3D11_SUBRESOURCE_DATA data
[3];
8800 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
8801 struct d3d11_test_context test_context
;
8802 const struct texture
*current_texture
;
8803 D3D11_TEXTURE2D_DESC texture_desc
;
8804 D3D11_SAMPLER_DESC sampler_desc
;
8805 const struct shader
*current_ps
;
8806 D3D_FEATURE_LEVEL feature_level
;
8807 ID3D11ShaderResourceView
*srv
;
8808 ID3D11DeviceContext
*context
;
8809 ID3D11SamplerState
*sampler
;
8810 struct resource_readback rb
;
8811 ID3D11Texture2D
*texture
;
8812 struct vec4 ps_constant
;
8813 ID3D11PixelShader
*ps
;
8814 ID3D11Device
*device
;
8815 unsigned int i
, x
, y
;
8820 static const DWORD ps_ld_code
[] =
8827 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
8830 t
.GetDimensions(miplevel
, p
.x
, p
.y
, p
.z
);
8832 p
*= float3(position
.x
/ 640.0f
, position
.y
/ 480.0f
, 1.0f
);
8833 return t
.Load(int3(p
));
8836 0x43425844, 0xbdda6bdf, 0xc6ffcdf1, 0xa58596b3, 0x822383f0, 0x00000001, 0x000001ac, 0x00000003,
8837 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
8838 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
8839 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
8840 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000110, 0x00000040,
8841 0x00000044, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04001858, 0x00107000, 0x00000000,
8842 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
8843 0x02000068, 0x00000001, 0x0600001c, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000,
8844 0x0700003d, 0x001000f2, 0x00000000, 0x0010000a, 0x00000000, 0x00107e46, 0x00000000, 0x07000038,
8845 0x00100032, 0x00000000, 0x00100046, 0x00000000, 0x00101046, 0x00000000, 0x06000036, 0x001000c2,
8846 0x00000000, 0x00208006, 0x00000000, 0x00000000, 0x0a000038, 0x001000f2, 0x00000000, 0x00100e46,
8847 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x3f800000, 0x3f800000, 0x0500001b, 0x001000f2,
8848 0x00000000, 0x00100e46, 0x00000000, 0x0700002d, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
8849 0x00107e46, 0x00000000, 0x0100003e,
8851 static const struct shader ps_ld
= {ps_ld_code
, sizeof(ps_ld_code
)};
8852 static const DWORD ps_ld_sint8_code
[] =
8857 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
8862 p
= float3(position
.x
/ 640.0f
, position
.y
/ 480.0f
, 0.0f
);
8863 t
.GetDimensions(0, s
.x
, s
.y
, s
.z
);
8866 c
= t
.Load(int3(p
));
8867 return (max(c
/ (float4
)127, (float4
)-1) + (float4
)1) / 2.0f
;
8870 0x43425844, 0xb3d0b0fc, 0x0e486f4a, 0xf67eec12, 0xfb9dd52f, 0x00000001, 0x00000240, 0x00000003,
8871 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
8872 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
8873 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
8874 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000001a4, 0x00000040,
8875 0x00000069, 0x04001858, 0x00107000, 0x00000000, 0x00003333, 0x04002064, 0x00101032, 0x00000000,
8876 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x0700003d, 0x001000f2,
8877 0x00000000, 0x00004001, 0x00000000, 0x00107e46, 0x00000000, 0x0a000038, 0x00100032, 0x00000001,
8878 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x08000036,
8879 0x001000c2, 0x00000001, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07000038,
8880 0x001000f2, 0x00000000, 0x00100f46, 0x00000000, 0x00100e46, 0x00000001, 0x0500001b, 0x001000f2,
8881 0x00000000, 0x00100e46, 0x00000000, 0x0700002d, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
8882 0x00107e46, 0x00000000, 0x0500002b, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x0a000038,
8883 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3c010204, 0x3c010204, 0x3c010204,
8884 0x3c010204, 0x0a000034, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0xbf800000,
8885 0xbf800000, 0xbf800000, 0xbf800000, 0x0a000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
8886 0x00004002, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000, 0x0a000038, 0x001020f2, 0x00000000,
8887 0x00100e46, 0x00000000, 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, 0x0100003e,
8889 static const struct shader ps_ld_sint8
= {ps_ld_sint8_code
, sizeof(ps_ld_sint8_code
)};
8890 static const DWORD ps_ld_uint8_code
[] =
8895 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
8899 p
= float3(position
.x
/ 640.0f
, position
.y
/ 480.0f
, 0.0f
);
8900 t
.GetDimensions(0, s
.x
, s
.y
, s
.z
);
8903 return t
.Load(int3(p
)) / (float4
)255;
8906 0x43425844, 0xd09917eb, 0x4508a07e, 0xb0b7250a, 0x228c1f0e, 0x00000001, 0x000001c8, 0x00000003,
8907 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
8908 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
8909 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
8910 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x0000012c, 0x00000040,
8911 0x0000004b, 0x04001858, 0x00107000, 0x00000000, 0x00004444, 0x04002064, 0x00101032, 0x00000000,
8912 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x0700003d, 0x001000f2,
8913 0x00000000, 0x00004001, 0x00000000, 0x00107e46, 0x00000000, 0x0a000038, 0x00100032, 0x00000001,
8914 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x08000036,
8915 0x001000c2, 0x00000001, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07000038,
8916 0x001000f2, 0x00000000, 0x00100f46, 0x00000000, 0x00100e46, 0x00000001, 0x0500001b, 0x001000f2,
8917 0x00000000, 0x00100e46, 0x00000000, 0x0700002d, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
8918 0x00107e46, 0x00000000, 0x05000056, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x0a000038,
8919 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3b808081, 0x3b808081, 0x3b808081,
8920 0x3b808081, 0x0100003e,
8922 static const struct shader ps_ld_uint8
= {ps_ld_uint8_code
, sizeof(ps_ld_uint8_code
)};
8923 static const DWORD ps_sample_code
[] =
8929 float4
main(float4 position
: SV_POSITION
) : SV_Target
8933 p
.x
= position
.x
/ 640.0f
;
8934 p
.y
= position
.y
/ 480.0f
;
8935 return t
.Sample(s
, p
);
8938 0x43425844, 0x1ce9b612, 0xc8176faa, 0xd37844af, 0xdb515605, 0x00000001, 0x00000134, 0x00000003,
8939 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
8940 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
8941 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
8942 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
8943 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
8944 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
8945 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
8946 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
8947 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
8949 static const struct shader ps_sample
= {ps_sample_code
, sizeof(ps_sample_code
)};
8950 static const DWORD ps_sample_b_code
[] =
8958 float4
main(float4 position
: SV_POSITION
) : SV_Target
8962 p
.x
= position
.x
/ 640.0f
;
8963 p
.y
= position
.y
/ 480.0f
;
8964 return t
.SampleBias(s
, p
, bias
);
8967 0x43425844, 0xc39b0686, 0x8244a7fc, 0x14c0b97a, 0x2900b3b7, 0x00000001, 0x00000150, 0x00000003,
8968 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
8969 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
8970 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
8971 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000b4, 0x00000040,
8972 0x0000002d, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000, 0x00000000,
8973 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001,
8974 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0a000038, 0x00100032, 0x00000000,
8975 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x0c00004a,
8976 0x001020f2, 0x00000000, 0x00100046, 0x00000000, 0x00107e46, 0x00000000, 0x00106000, 0x00000000,
8977 0x0020800a, 0x00000000, 0x00000000, 0x0100003e,
8979 static const struct shader ps_sample_b
= {ps_sample_b_code
, sizeof(ps_sample_b_code
)};
8980 static const DWORD ps_sample_l_code
[] =
8988 float4
main(float4 position
: SV_POSITION
) : SV_Target
8992 p
.x
= position
.x
/ 640.0f
;
8993 p
.y
= position
.y
/ 480.0f
;
8994 return t
.SampleLevel(s
, p
, level
);
8997 0x43425844, 0x61e05d85, 0x2a7300fb, 0x0a83706b, 0x889d1683, 0x00000001, 0x00000150, 0x00000003,
8998 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
8999 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
9000 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
9001 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000b4, 0x00000040,
9002 0x0000002d, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000, 0x00000000,
9003 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001,
9004 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0a000038, 0x00100032, 0x00000000,
9005 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x0c000048,
9006 0x001020f2, 0x00000000, 0x00100046, 0x00000000, 0x00107e46, 0x00000000, 0x00106000, 0x00000000,
9007 0x0020800a, 0x00000000, 0x00000000, 0x0100003e,
9009 static const struct shader ps_sample_l
= {ps_sample_l_code
, sizeof(ps_sample_l_code
)};
9010 static const DWORD ps_sample_2d_array_code
[] =
9018 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
9021 float3 p
= float3(position
.x
/ 640.0f
, position
.y
/ 480.0f
, 1.0f
);
9022 t
.GetDimensions(d
.x
, d
.y
, d
.z
);
9024 return t
.Sample(s
, p
* d
);
9027 0x43425844, 0xa9457e44, 0xc0b3ef8e, 0x3d751ae8, 0x23fa4807, 0x00000001, 0x00000194, 0x00000003,
9028 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
9029 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
9030 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
9031 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000f8, 0x00000040,
9032 0x0000003e, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000, 0x00000000,
9033 0x04004058, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001,
9034 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0700003d, 0x001000f2, 0x00000000,
9035 0x00004001, 0x00000000, 0x00107e46, 0x00000000, 0x0a000038, 0x001000c2, 0x00000000, 0x00101406,
9036 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x3acccccd, 0x3b088889, 0x07000038, 0x00100032,
9037 0x00000000, 0x00100046, 0x00000000, 0x00100ae6, 0x00000000, 0x06000036, 0x00100042, 0x00000000,
9038 0x0020800a, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100246, 0x00000000,
9039 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
9041 static const struct shader ps_sample_2d_array
= {ps_sample_2d_array_code
, sizeof(ps_sample_2d_array_code
)};
9042 static const DWORD red_data
[] =
9044 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff, 0x00000000, 0x00000000,
9045 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff, 0x00000000, 0x00000000,
9046 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff, 0x00000000, 0x00000000,
9047 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff, 0x00000000, 0x00000000,
9049 static const DWORD green_data
[] =
9051 0xff00ff00, 0xff00ff00, 0xff00ff00, 0xff00ff00,
9052 0xff00ff00, 0xff00ff00, 0xff00ff00, 0xff00ff00,
9053 0xff00ff00, 0xff00ff00, 0xff00ff00, 0xff00ff00,
9054 0xff00ff00, 0xff00ff00, 0xff00ff00, 0xff00ff00,
9056 static const DWORD blue_data
[] =
9058 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000, 0x00000000,
9059 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000, 0x00000000,
9060 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000, 0x00000000,
9061 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000, 0x00000000,
9063 static const DWORD rgba_level_0
[] =
9065 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
9066 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
9067 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
9068 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
9070 static const DWORD rgba_level_1
[] =
9072 0xffffffff, 0xff0000ff,
9073 0xff000000, 0xff00ff00,
9075 static const DWORD rgba_level_2
[] =
9079 static const DWORD srgb_data
[] =
9081 0x00000000, 0xffffffff, 0xff000000, 0x7f7f7f7f,
9082 0xff010203, 0xff102030, 0xff0a0b0c, 0xff8090a0,
9083 0xffb1c4de, 0xfff0f1f2, 0xfffafdfe, 0xff5a560f,
9084 0xffd5ff00, 0xffc8f99f, 0xffaa00aa, 0xffdd55bb,
9086 static const WORD r8g8_data
[] =
9088 0x0000, 0xffff, 0x0000, 0x7fff,
9089 0x0203, 0xff10, 0x0b0c, 0x8000,
9090 0xc4de, 0xfff0, 0xfdfe, 0x5a6f,
9091 0xff00, 0xffc8, 0x00aa, 0xdd5b,
9093 static const BYTE a8_data
[] =
9095 0x00, 0x10, 0x20, 0x30,
9096 0x40, 0x50, 0x60, 0x70,
9097 0x80, 0x90, 0xa0, 0xb0,
9098 0xc0, 0xd0, 0xe0, 0xf0,
9100 static const BYTE bc1_data
[] =
9102 0x00, 0xf8, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
9103 0xe0, 0x07, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00,
9104 0x1f, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
9105 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
9107 static const BYTE bc2_data
[] =
9109 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf8, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
9110 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x07, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00,
9111 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
9112 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
9114 static const BYTE bc3_data
[] =
9116 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
9117 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00,
9118 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
9119 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
9121 static const BYTE bc4_data
[] =
9123 0x10, 0x7f, 0x77, 0x39, 0x05, 0x00, 0x00, 0x00,
9124 0x10, 0x7f, 0x49, 0x92, 0x24, 0x49, 0x92, 0x24,
9125 0x10, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
9126 0x10, 0x7f, 0xb6, 0x6d, 0xdb, 0xb6, 0x6d, 0xdb,
9128 static const BYTE bc5_data
[] =
9130 0x10, 0x7f, 0x77, 0x39, 0x05, 0x00, 0x00, 0x00, 0x10, 0x7f, 0x77, 0x39, 0x05, 0x00, 0x00, 0x00,
9131 0x10, 0x7f, 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0x10, 0x7f, 0x49, 0x92, 0x24, 0x49, 0x92, 0x24,
9132 0x10, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x10, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
9133 0x10, 0x7f, 0xb6, 0x6d, 0xdb, 0xb6, 0x6d, 0xdb, 0x10, 0x7f, 0xb6, 0x6d, 0xdb, 0xb6, 0x6d, 0xdb,
9135 static const BYTE bc6h_u_data
[] =
9137 0xe3, 0x5e, 0x00, 0x00, 0x78, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9138 0x03, 0x80, 0x7b, 0x01, 0x00, 0xe0, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9139 0x03, 0x00, 0x00, 0xee, 0x05, 0x00, 0x80, 0xf7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9140 0xe3, 0xde, 0x7b, 0xef, 0x7d, 0xef, 0xbd, 0xf7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9142 static const BYTE bc6h_s_data
[] =
9144 0x63, 0x2f, 0x00, 0x00, 0xb8, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9145 0x03, 0x80, 0xbd, 0x00, 0x00, 0xe0, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9146 0x03, 0x00, 0x00, 0xf6, 0x02, 0x00, 0x80, 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9147 0x63, 0xaf, 0xbd, 0xf6, 0xba, 0xe7, 0x9e, 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9149 static const BYTE bc7_data
[] =
9151 0x02, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9152 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9153 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9154 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
9156 static const float r32_float
[] =
9158 0.0f
, 1.0f
, 0.5f
, 0.50f
,
9159 1.0f
, 0.0f
, 0.0f
, 0.75f
,
9160 0.0f
, 1.0f
, 0.5f
, 0.25f
,
9161 1.0f
, 0.0f
, 0.0f
, 0.75f
,
9163 static const DWORD r32_uint
[] =
9170 static const DWORD r9g9b9e5_data
[] =
9172 0x80000100, 0x80020000, 0x84000000, 0x84000100,
9173 0x78000100, 0x78020000, 0x7c000000, 0x78020100,
9174 0x70000133, 0x70026600, 0x74cc0000, 0x74cc0133,
9175 0x6800019a, 0x68033400, 0x6e680000, 0x6e6b359a,
9177 static const struct texture rgba_texture
=
9179 4, 4, 3, 1, DXGI_FORMAT_R8G8B8A8_UNORM
,
9181 {rgba_level_0
, 4 * sizeof(*rgba_level_0
), 0},
9182 {rgba_level_1
, 2 * sizeof(*rgba_level_1
), 0},
9183 {rgba_level_2
, sizeof(*rgba_level_2
), 0},
9186 static const struct texture srgb_texture
= {4, 4, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
9187 {{srgb_data
, 4 * sizeof(*srgb_data
)}}};
9188 static const struct texture srgb_typeless
= {4, 4, 1, 1, DXGI_FORMAT_R8G8B8A8_TYPELESS
,
9189 {{srgb_data
, 4 * sizeof(*srgb_data
)}}};
9190 static const struct texture a8_texture
= {4, 4, 1, 1, DXGI_FORMAT_A8_UNORM
,
9191 {{a8_data
, 4 * sizeof(*a8_data
)}}};
9192 static const struct texture bc1_texture
= {8, 8, 1, 1, DXGI_FORMAT_BC1_UNORM
, {{bc1_data
, 2 * 8}}};
9193 static const struct texture bc2_texture
= {8, 8, 1, 1, DXGI_FORMAT_BC2_UNORM
, {{bc2_data
, 2 * 16}}};
9194 static const struct texture bc3_texture
= {8, 8, 1, 1, DXGI_FORMAT_BC3_UNORM
, {{bc3_data
, 2 * 16}}};
9195 static const struct texture bc4_texture
= {8, 8, 1, 1, DXGI_FORMAT_BC4_UNORM
, {{bc4_data
, 2 * 8}}};
9196 static const struct texture bc5_texture
= {8, 8, 1, 1, DXGI_FORMAT_BC5_UNORM
, {{bc5_data
, 2 * 16}}};
9197 static const struct texture bc6h_u_texture
= {8, 8, 1, 1, DXGI_FORMAT_BC6H_UF16
, {{bc6h_u_data
, 2 * 16}}};
9198 static const struct texture bc6h_s_texture
= {8, 8, 1, 1, DXGI_FORMAT_BC6H_SF16
, {{bc6h_s_data
, 2 * 16}}};
9199 static const struct texture bc7_texture
= {8, 8, 1, 1, DXGI_FORMAT_BC7_UNORM
, {{bc7_data
, 2 * 16}}};
9200 static const struct texture bc1_texture_srgb
= {8, 8, 1, 1, DXGI_FORMAT_BC1_UNORM_SRGB
, {{bc1_data
, 2 * 8}}};
9201 static const struct texture bc2_texture_srgb
= {8, 8, 1, 1, DXGI_FORMAT_BC2_UNORM_SRGB
, {{bc2_data
, 2 * 16}}};
9202 static const struct texture bc3_texture_srgb
= {8, 8, 1, 1, DXGI_FORMAT_BC3_UNORM_SRGB
, {{bc3_data
, 2 * 16}}};
9203 static const struct texture bc7_texture_srgb
= {8, 8, 1, 1, DXGI_FORMAT_BC7_UNORM_SRGB
, {{bc7_data
, 2 * 16}}};
9204 static const struct texture bc1_typeless
= {8, 8, 1, 1, DXGI_FORMAT_BC1_TYPELESS
, {{bc1_data
, 2 * 8}}};
9205 static const struct texture bc2_typeless
= {8, 8, 1, 1, DXGI_FORMAT_BC2_TYPELESS
, {{bc2_data
, 2 * 16}}};
9206 static const struct texture bc3_typeless
= {8, 8, 1, 1, DXGI_FORMAT_BC3_TYPELESS
, {{bc3_data
, 2 * 16}}};
9207 static const struct texture sint8_texture
= {4, 4, 1, 1, DXGI_FORMAT_R8G8B8A8_SINT
,
9208 {{rgba_level_0
, 4 * sizeof(*rgba_level_0
)}}};
9209 static const struct texture uint8_texture
= {4, 4, 1, 1, DXGI_FORMAT_R8G8B8A8_UINT
,
9210 {{rgba_level_0
, 4 * sizeof(*rgba_level_0
)}}};
9211 static const struct texture array_2d_texture
=
9213 4, 4, 1, 3, DXGI_FORMAT_R8G8B8A8_UNORM
,
9215 {red_data
, 6 * sizeof(*red_data
)},
9216 {green_data
, 4 * sizeof(*green_data
)},
9217 {blue_data
, 5 * sizeof(*blue_data
)},
9220 static const struct texture r32f_float
= {4, 4, 1, 1, DXGI_FORMAT_R32_FLOAT
,
9221 {{r32_float
, 4 * sizeof(*r32_float
)}}};
9222 static const struct texture r32f_typeless
= {4, 4, 1, 1, DXGI_FORMAT_R32_TYPELESS
,
9223 {{r32_float
, 4 * sizeof(*r32_float
)}}};
9224 static const struct texture r32u_typeless
= {4, 4, 1, 1, DXGI_FORMAT_R32_TYPELESS
,
9225 {{r32_uint
, 4 * sizeof(*r32_uint
)}}};
9226 static const struct texture r8g8_snorm
= {4, 4, 1, 1, DXGI_FORMAT_R8G8_SNORM
,
9227 {{r8g8_data
, 4 * sizeof(*r8g8_data
)}}};
9228 static const struct texture r9g9b9e5_texture
= {4, 4, 1, 1, DXGI_FORMAT_R9G9B9E5_SHAREDEXP
,
9229 {{r9g9b9e5_data
, 4 * sizeof(*r9g9b9e5_data
)}}};
9230 static const DWORD red_colors
[] =
9232 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff,
9233 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff,
9234 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff,
9235 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff,
9237 static const DWORD blue_colors
[] =
9239 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
9240 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
9241 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
9242 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
9244 static const DWORD level_1_colors
[] =
9246 0xffffffff, 0xffffffff, 0xff0000ff, 0xff0000ff,
9247 0xffffffff, 0xffffffff, 0xff0000ff, 0xff0000ff,
9248 0xff000000, 0xff000000, 0xff00ff00, 0xff00ff00,
9249 0xff000000, 0xff000000, 0xff00ff00, 0xff00ff00,
9251 static const DWORD lerp_1_2_colors
[] =
9253 0xffff7f7f, 0xffff7f7f, 0xff7f007f, 0xff7f007f,
9254 0xffff7f7f, 0xffff7f7f, 0xff7f007f, 0xff7f007f,
9255 0xff7f0000, 0xff7f0000, 0xff7f7f00, 0xff7f7f00,
9256 0xff7f0000, 0xff7f0000, 0xff7f7f00, 0xff7f7f00,
9258 static const DWORD level_2_colors
[] =
9260 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
9261 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
9262 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
9263 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
9265 static const DWORD srgb_colors
[] =
9267 0x00000001, 0xffffffff, 0xff000000, 0x7f363636,
9268 0xff000000, 0xff010408, 0xff010101, 0xff37475a,
9269 0xff708cba, 0xffdee0e2, 0xfff3fbfd, 0xff1a1801,
9270 0xffa9ff00, 0xff93f159, 0xff670067, 0xffb8177f,
9272 static const DWORD a8_colors
[] =
9274 0x00000000, 0x10000000, 0x20000000, 0x30000000,
9275 0x40000000, 0x50000000, 0x60000000, 0x70000000,
9276 0x80000000, 0x90000000, 0xa0000000, 0xb0000000,
9277 0xc0000000, 0xd0000000, 0xe0000000, 0xf0000000,
9279 static const DWORD bc_colors
[] =
9281 0xff0000ff, 0xff0000ff, 0xff00ff00, 0xff00ff00,
9282 0xff0000ff, 0xff0000ff, 0xff00ff00, 0xff00ff00,
9283 0xffff0000, 0xffff0000, 0xffffffff, 0xffffffff,
9284 0xffff0000, 0xffff0000, 0xffffffff, 0xffffffff,
9286 static const DWORD bc4_colors
[] =
9288 0xff000026, 0xff000010, 0xff00007f, 0xff00007f,
9289 0xff000010, 0xff000010, 0xff00007f, 0xff00007f,
9290 0xff0000ff, 0xff0000ff, 0xff000000, 0xff000000,
9291 0xff0000ff, 0xff0000ff, 0xff000000, 0xff000000,
9293 static const DWORD bc5_colors
[] =
9295 0xff002626, 0xff001010, 0xff007f7f, 0xff007f7f,
9296 0xff001010, 0xff001010, 0xff007f7f, 0xff007f7f,
9297 0xff00ffff, 0xff00ffff, 0xff000000, 0xff000000,
9298 0xff00ffff, 0xff00ffff, 0xff000000, 0xff000000,
9300 static const DWORD bc7_colors
[] =
9302 0xff0000fc, 0xff0000fc, 0xff00fc00, 0xff00fc00,
9303 0xff0000fc, 0xff0000fc, 0xff00fc00, 0xff00fc00,
9304 0xfffc0000, 0xfffc0000, 0xffffffff, 0xffffffff,
9305 0xfffc0000, 0xfffc0000, 0xffffffff, 0xffffffff,
9307 static const DWORD sint8_colors
[] =
9309 0x7e80807e, 0x7e807e7e, 0x7e807e80, 0x7e7e7e80,
9310 0x7e7e8080, 0x7e7e7f7f, 0x7e808080, 0x7effffff,
9311 0x7e7e7e7e, 0x7e7e7e7e, 0x7e7e7e7e, 0x7e808080,
9312 0x7e7e7e7e, 0x7e7f7f7f, 0x7e7f7f7f, 0x7e7f7f7f,
9314 static const DWORD snorm_colors
[] =
9316 0xff000000, 0xff000000, 0xff000000, 0xff00ff00,
9317 0xff000406, 0xff000020, 0xff001618, 0xff000000,
9318 0xff000000, 0xff000000, 0xff000000, 0xff00b5df,
9319 0xff000000, 0xff000000, 0xff000000, 0xff0000b7,
9321 static const DWORD r32f_colors
[] =
9323 0xff000000, 0xff0000ff, 0xff00007f, 0xff00007f,
9324 0xff0000ff, 0xff000000, 0xff000000, 0xff0000bf,
9325 0xff000000, 0xff0000ff, 0xff00007f, 0xff000040,
9326 0xff0000ff, 0xff000000, 0xff000000, 0xff0000bf,
9328 static const DWORD r32u_colors
[16] =
9330 0x01000000, 0x01000001, 0x01000002, 0x01000003,
9331 0x01000064, 0x010000c8, 0x010000ff, 0x01000080,
9332 0x01000028, 0x0100001e, 0x01000014, 0x0100000a,
9333 0x010000fa, 0x010000d2, 0x0100009b, 0x010000be,
9335 static const DWORD r9g9b9e5_colors
[16] =
9337 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffff00ff,
9338 0xff00007f, 0xff007f00, 0xff7f0000, 0xff007f7f,
9339 0xff00004c, 0xff004c00, 0xff4c0000, 0xff4c004c,
9340 0xff000033, 0xff003300, 0xff330000, 0xff333333,
9342 static const DWORD zero_colors
[4 * 4] = {0};
9343 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
9345 static const struct texture_test
9347 const struct shader
*ps
;
9348 const struct texture
*texture
;
9349 D3D11_FILTER filter
;
9354 const DWORD
*expected_colors
;
9358 #define POINT D3D11_FILTER_MIN_MAG_MIP_POINT
9359 #define POINT_LINEAR D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR
9360 #define MIP_MAX D3D11_FLOAT32_MAX
9361 {&ps_ld
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, rgba_level_0
},
9362 {&ps_ld
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, level_1_colors
},
9363 {&ps_ld
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 2.0f
, level_2_colors
},
9364 {&ps_ld
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 3.0f
, zero_colors
},
9365 {&ps_ld
, &srgb_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, srgb_colors
},
9366 {&ps_ld
, &bc1_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
9367 {&ps_ld
, &bc1_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, zero_colors
},
9368 {&ps_ld
, &bc2_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
9369 {&ps_ld
, &bc2_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, zero_colors
},
9370 {&ps_ld
, &bc3_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
9371 {&ps_ld
, &bc3_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, zero_colors
},
9372 {&ps_ld
, &bc1_texture_srgb
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
9373 {&ps_ld
, &bc2_texture_srgb
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
9374 {&ps_ld
, &bc3_texture_srgb
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
9375 {&ps_ld
, &bc4_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc4_colors
},
9376 {&ps_ld
, &bc5_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc5_colors
},
9377 {&ps_ld
, &bc6h_u_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
9378 {&ps_ld
, &bc6h_s_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
9379 {&ps_ld
, &bc7_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc7_colors
},
9380 {&ps_ld
, &bc7_texture_srgb
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc7_colors
},
9381 {&ps_ld
, &r9g9b9e5_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, r9g9b9e5_colors
},
9382 {&ps_ld
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, zero_colors
},
9383 {&ps_ld
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, zero_colors
},
9384 {&ps_ld_sint8
, &sint8_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, sint8_colors
},
9385 {&ps_ld_uint8
, &uint8_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, rgba_level_0
},
9386 {&ps_sample
, &bc1_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
9387 {&ps_sample
, &bc2_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
9388 {&ps_sample
, &bc3_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
9389 {&ps_sample
, &bc4_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc4_colors
},
9390 {&ps_sample
, &bc5_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc5_colors
},
9391 {&ps_sample
, &bc6h_u_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
9392 {&ps_sample
, &bc6h_s_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
9393 {&ps_sample
, &bc7_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc7_colors
},
9394 {&ps_sample
, &bc7_texture_srgb
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc7_colors
},
9395 {&ps_sample
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, rgba_level_0
},
9396 {&ps_sample
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, rgba_level_0
},
9397 {&ps_sample
, &rgba_texture
, POINT
, 2.0f
, 0.0f
, MIP_MAX
, 0.0f
, rgba_level_0
},
9398 {&ps_sample
, &rgba_texture
, POINT
, 8.0f
, 0.0f
, MIP_MAX
, 0.0f
, level_1_colors
},
9399 {&ps_sample
, &srgb_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, srgb_colors
},
9400 {&ps_sample
, &a8_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, a8_colors
},
9401 {&ps_sample
, &r9g9b9e5_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, r9g9b9e5_colors
},
9402 {&ps_sample
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, zero_colors
},
9403 {&ps_sample
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, zero_colors
},
9404 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, rgba_level_0
},
9405 {&ps_sample_b
, &rgba_texture
, POINT
, 8.0f
, 0.0f
, MIP_MAX
, 0.0f
, level_1_colors
},
9406 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 8.0f
, level_1_colors
},
9407 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 8.4f
, level_1_colors
},
9408 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 8.5f
, level_2_colors
},
9409 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 9.0f
, level_2_colors
},
9410 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 2.0f
, 1.0f
, rgba_level_0
},
9411 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 2.0f
, 9.0f
, level_2_colors
},
9412 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 1.0f
, 9.0f
, level_1_colors
},
9413 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 9.0f
, rgba_level_0
},
9414 {&ps_sample_b
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, zero_colors
},
9415 {&ps_sample_b
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, zero_colors
},
9416 {&ps_sample_b
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, zero_colors
},
9417 {&ps_sample_b
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 1.0f
, zero_colors
},
9418 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, -1.0f
, rgba_level_0
},
9419 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, rgba_level_0
},
9420 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.4f
, rgba_level_0
},
9421 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.5f
, level_1_colors
},
9422 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 1.0f
, level_1_colors
},
9423 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 1.4f
, level_1_colors
},
9424 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 1.5f
, level_2_colors
},
9425 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 2.0f
, level_2_colors
},
9426 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 3.0f
, level_2_colors
},
9427 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 4.0f
, level_2_colors
},
9428 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 0.0f
, 0.0f
, MIP_MAX
, 1.5f
, lerp_1_2_colors
},
9429 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 0.0f
, MIP_MAX
, -2.0f
, rgba_level_0
},
9430 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 0.0f
, MIP_MAX
, -1.0f
, level_1_colors
},
9431 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 0.0f
, MIP_MAX
, 0.0f
, level_2_colors
},
9432 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 0.0f
, MIP_MAX
, 1.0f
, level_2_colors
},
9433 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 0.0f
, MIP_MAX
, 1.5f
, level_2_colors
},
9434 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 2.0f
, 2.0f
, -9.0f
, level_2_colors
},
9435 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 2.0f
, 2.0f
, -1.0f
, level_2_colors
},
9436 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 2.0f
, 2.0f
, 0.0f
, level_2_colors
},
9437 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 2.0f
, 2.0f
, 1.0f
, level_2_colors
},
9438 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 2.0f
, 2.0f
, 9.0f
, level_2_colors
},
9439 {&ps_sample_l
, &rgba_texture
, POINT
, 2.0f
, 2.0f
, 2.0f
, -9.0f
, level_2_colors
},
9440 {&ps_sample_l
, &rgba_texture
, POINT
, 2.0f
, 2.0f
, 2.0f
, -1.0f
, level_2_colors
},
9441 {&ps_sample_l
, &rgba_texture
, POINT
, 2.0f
, 2.0f
, 2.0f
, 0.0f
, level_2_colors
},
9442 {&ps_sample_l
, &rgba_texture
, POINT
, 2.0f
, 2.0f
, 2.0f
, 1.0f
, level_2_colors
},
9443 {&ps_sample_l
, &rgba_texture
, POINT
, 2.0f
, 2.0f
, 2.0f
, 9.0f
, level_2_colors
},
9444 {&ps_sample_l
, NULL
, POINT
, 2.0f
, 2.0f
, 0.0f
, 0.0f
, zero_colors
},
9445 {&ps_sample_l
, NULL
, POINT
, 2.0f
, 2.0f
, 0.0f
, 1.0f
, zero_colors
},
9446 {&ps_sample_l
, NULL
, POINT
, 2.0f
, 2.0f
, MIP_MAX
, 0.0f
, zero_colors
},
9447 {&ps_sample_l
, NULL
, POINT
, 2.0f
, 2.0f
, MIP_MAX
, 1.0f
, zero_colors
},
9448 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, -9.0f
, red_colors
},
9449 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, -1.0f
, red_colors
},
9450 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, red_colors
},
9451 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.4f
, red_colors
},
9452 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.5f
, red_colors
},
9453 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 1.0f
, green_data
},
9454 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 1.4f
, green_data
},
9455 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 2.0f
, blue_colors
},
9456 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 2.1f
, blue_colors
},
9457 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 3.0f
, blue_colors
},
9458 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 3.1f
, blue_colors
},
9459 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 9.0f
, blue_colors
},
9460 {&ps_sample_2d_array
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, zero_colors
},
9461 {&ps_sample_2d_array
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, zero_colors
},
9462 {&ps_sample_2d_array
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 2.0f
, zero_colors
},
9463 {&ps_sample_2d_array
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, zero_colors
},
9464 {&ps_sample_2d_array
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 1.0f
, zero_colors
},
9465 {&ps_sample_2d_array
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 2.0f
, zero_colors
},
9470 static const struct srv_test
9472 const struct shader
*ps
;
9473 const struct texture
*texture
;
9474 struct srv_desc srv_desc
;
9476 const DWORD
*expected_colors
;
9480 #define TEX_2D D3D11_SRV_DIMENSION_TEXTURE2D
9481 #define TEX_2D_ARRAY D3D11_SRV_DIMENSION_TEXTURE2DARRAY
9482 #define BC1_UNORM DXGI_FORMAT_BC1_UNORM
9483 #define BC1_UNORM_SRGB DXGI_FORMAT_BC1_UNORM_SRGB
9484 #define BC2_UNORM DXGI_FORMAT_BC2_UNORM
9485 #define BC2_UNORM_SRGB DXGI_FORMAT_BC2_UNORM_SRGB
9486 #define BC3_UNORM DXGI_FORMAT_BC3_UNORM
9487 #define BC3_UNORM_SRGB DXGI_FORMAT_BC3_UNORM_SRGB
9488 #define R8G8B8A8_UNORM_SRGB DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
9489 #define R8G8B8A8_UNORM DXGI_FORMAT_R8G8B8A8_UNORM
9490 #define R8G8_SNORM DXGI_FORMAT_R8G8_SNORM
9491 #define R32_FLOAT DXGI_FORMAT_R32_FLOAT
9492 #define R32_UINT DXGI_FORMAT_R32_UINT
9493 #define FMT_UNKNOWN DXGI_FORMAT_UNKNOWN
9494 {&ps_sample
, &bc1_typeless
, {BC1_UNORM
, TEX_2D
, 0, 1}, 0.0f
, bc_colors
},
9495 {&ps_sample
, &bc1_typeless
, {BC1_UNORM_SRGB
, TEX_2D
, 0, 1}, 0.0f
, bc_colors
},
9496 {&ps_sample
, &bc2_typeless
, {BC2_UNORM
, TEX_2D
, 0, 1}, 0.0f
, bc_colors
},
9497 {&ps_sample
, &bc2_typeless
, {BC2_UNORM_SRGB
, TEX_2D
, 0, 1}, 0.0f
, bc_colors
},
9498 {&ps_sample
, &bc3_typeless
, {BC3_UNORM
, TEX_2D
, 0, 1}, 0.0f
, bc_colors
},
9499 {&ps_sample
, &bc3_typeless
, {BC3_UNORM_SRGB
, TEX_2D
, 0, 1}, 0.0f
, bc_colors
},
9500 {&ps_sample
, &srgb_typeless
, {R8G8B8A8_UNORM_SRGB
, TEX_2D
, 0, 1}, 0.0f
, srgb_colors
},
9501 {&ps_sample
, &srgb_typeless
, {R8G8B8A8_UNORM
, TEX_2D
, 0, 1}, 0.0f
, srgb_data
},
9502 {&ps_sample
, &r32f_typeless
, {R32_FLOAT
, TEX_2D
, 0, 1}, 0.0f
, r32f_colors
},
9503 {&ps_sample
, &r32f_float
, {R32_FLOAT
, TEX_2D
, 0, 1}, 0.0f
, r32f_colors
},
9504 {&ps_sample
, &r8g8_snorm
, {R8G8_SNORM
, TEX_2D
, 0, 1}, 0.0f
, snorm_colors
},
9505 {&ps_sample
, &array_2d_texture
, {FMT_UNKNOWN
, TEX_2D
, 0, 1}, 0.0f
, red_colors
},
9506 {&ps_sample_2d_array
, &array_2d_texture
, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 1, 0, 1}, 0.0f
, red_colors
},
9507 {&ps_sample_2d_array
, &array_2d_texture
, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 1, 1, 1}, 0.0f
, green_data
},
9508 {&ps_sample_2d_array
, &array_2d_texture
, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 1, 2, 1}, 0.0f
, blue_colors
},
9509 {&ps_ld_uint8
, &r32u_typeless
, {R32_UINT
, TEX_2D
, 0, 1}, 0.0f
, r32u_colors
},
9513 #undef BC1_UNORM_SRGB
9515 #undef BC2_UNORM_SRGB
9517 #undef BC3_UNORM_SRGB
9518 #undef R8G8B8A8_UNORM_SRGB
9519 #undef R8G8B8A8_UNORM
9526 if (!init_test_context(&test_context
, NULL
))
9529 device
= test_context
.device
;
9530 context
= test_context
.immediate_context
;
9531 feature_level
= ID3D11Device_GetFeatureLevel(device
);
9533 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(ps_constant
), NULL
);
9535 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
9537 texture_desc
.SampleDesc
.Count
= 1;
9538 texture_desc
.SampleDesc
.Quality
= 0;
9539 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
9540 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
9541 texture_desc
.CPUAccessFlags
= 0;
9542 texture_desc
.MiscFlags
= 0;
9544 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
9545 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
9546 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
9547 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
9548 sampler_desc
.MipLODBias
= 0.0f
;
9549 sampler_desc
.MaxAnisotropy
= 0;
9550 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
9551 sampler_desc
.BorderColor
[0] = 0.0f
;
9552 sampler_desc
.BorderColor
[1] = 0.0f
;
9553 sampler_desc
.BorderColor
[2] = 0.0f
;
9554 sampler_desc
.BorderColor
[3] = 0.0f
;
9555 sampler_desc
.MinLOD
= 0.0f
;
9556 sampler_desc
.MaxLOD
= D3D11_FLOAT32_MAX
;
9563 current_texture
= NULL
;
9564 for (i
= 0; i
< ARRAY_SIZE(texture_tests
); ++i
)
9566 const struct texture_test
*test
= &texture_tests
[i
];
9568 if (test
->texture
&& (test
->texture
->format
== DXGI_FORMAT_BC7_UNORM
9569 || test
->texture
->format
== DXGI_FORMAT_BC7_UNORM_SRGB
)
9570 && feature_level
< D3D_FEATURE_LEVEL_11_0
)
9572 skip("Feature level >= 11.0 is required for BC7 tests.\n");
9576 if (test
->texture
&& (test
->texture
->format
== DXGI_FORMAT_BC6H_UF16
9577 || test
->texture
->format
== DXGI_FORMAT_BC6H_SF16
)
9578 && feature_level
< D3D_FEATURE_LEVEL_11_0
)
9580 skip("Feature level >= 11.0 is required for BC6H tests.\n");
9584 if (current_ps
!= test
->ps
)
9587 ID3D11PixelShader_Release(ps
);
9589 current_ps
= test
->ps
;
9591 hr
= ID3D11Device_CreatePixelShader(device
, current_ps
->code
, current_ps
->size
, NULL
, &ps
);
9592 ok(SUCCEEDED(hr
), "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
9594 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
9597 if (current_texture
!= test
->texture
)
9600 ID3D11Texture2D_Release(texture
);
9602 ID3D11ShaderResourceView_Release(srv
);
9604 current_texture
= test
->texture
;
9606 if (current_texture
)
9608 texture_desc
.Width
= current_texture
->width
;
9609 texture_desc
.Height
= current_texture
->height
;
9610 texture_desc
.MipLevels
= current_texture
->miplevel_count
;
9611 texture_desc
.ArraySize
= current_texture
->array_size
;
9612 texture_desc
.Format
= current_texture
->format
;
9614 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, current_texture
->data
, &texture
);
9615 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
9617 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
9618 ok(SUCCEEDED(hr
), "Test %u: Failed to create shader resource view, hr %#x.\n", i
, hr
);
9626 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
9629 if (!sampler
|| (sampler_desc
.Filter
!= test
->filter
9630 || sampler_desc
.MipLODBias
!= test
->lod_bias
9631 || sampler_desc
.MinLOD
!= test
->min_lod
9632 || sampler_desc
.MaxLOD
!= test
->max_lod
))
9635 ID3D11SamplerState_Release(sampler
);
9637 sampler_desc
.Filter
= test
->filter
;
9638 sampler_desc
.MipLODBias
= test
->lod_bias
;
9639 sampler_desc
.MinLOD
= test
->min_lod
;
9640 sampler_desc
.MaxLOD
= test
->max_lod
;
9642 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler
);
9643 ok(SUCCEEDED(hr
), "Test %u: Failed to create sampler state, hr %#x.\n", i
, hr
);
9645 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler
);
9648 ps_constant
.x
= test
->ps_constant
;
9649 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &ps_constant
, 0, 0);
9651 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
9653 draw_quad(&test_context
);
9655 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
9656 for (y
= 0; y
< 4; ++y
)
9658 for (x
= 0; x
< 4; ++x
)
9660 color
= get_readback_color(&rb
, 80 + x
* 160, 60 + y
* 120, 0);
9661 ok(compare_color(color
, test
->expected_colors
[y
* 4 + x
], 2),
9662 "Test %u: Got unexpected color 0x%08x at (%u, %u).\n", i
, color
, x
, y
);
9665 release_resource_readback(&rb
);
9668 ID3D11ShaderResourceView_Release(srv
);
9669 ID3D11SamplerState_Release(sampler
);
9671 ID3D11Texture2D_Release(texture
);
9672 ID3D11PixelShader_Release(ps
);
9674 if (is_warp_device(device
) && feature_level
< D3D_FEATURE_LEVEL_11_0
)
9676 win_skip("SRV tests are broken on WARP.\n");
9677 ID3D11Buffer_Release(cb
);
9678 release_test_context(&test_context
);
9682 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
9683 sampler_desc
.MipLODBias
= 0.0f
;
9684 sampler_desc
.MinLOD
= 0.0f
;
9685 sampler_desc
.MaxLOD
= D3D11_FLOAT32_MAX
;
9687 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler
);
9688 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
9690 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler
);
9696 current_texture
= NULL
;
9697 for (i
= 0; i
< ARRAY_SIZE(srv_tests
); ++i
)
9699 const struct srv_test
*test
= &srv_tests
[i
];
9701 if (current_ps
!= test
->ps
)
9704 ID3D11PixelShader_Release(ps
);
9706 current_ps
= test
->ps
;
9708 hr
= ID3D11Device_CreatePixelShader(device
, current_ps
->code
, current_ps
->size
, NULL
, &ps
);
9709 ok(SUCCEEDED(hr
), "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
9711 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
9714 if (current_texture
!= test
->texture
)
9717 ID3D11Texture2D_Release(texture
);
9719 current_texture
= test
->texture
;
9721 texture_desc
.Width
= current_texture
->width
;
9722 texture_desc
.Height
= current_texture
->height
;
9723 texture_desc
.MipLevels
= current_texture
->miplevel_count
;
9724 texture_desc
.ArraySize
= current_texture
->array_size
;
9725 texture_desc
.Format
= current_texture
->format
;
9727 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, current_texture
->data
, &texture
);
9728 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
9732 ID3D11ShaderResourceView_Release(srv
);
9734 get_srv_desc(&srv_desc
, &test
->srv_desc
);
9735 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, &srv_desc
, &srv
);
9736 ok(SUCCEEDED(hr
), "Test %u: Failed to create shader resource view, hr %#x.\n", i
, hr
);
9738 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
9740 ps_constant
.x
= test
->ps_constant
;
9741 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &ps_constant
, 0, 0);
9743 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
9745 draw_quad(&test_context
);
9747 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
9748 for (y
= 0; y
< 4; ++y
)
9750 for (x
= 0; x
< 4; ++x
)
9752 color
= get_readback_color(&rb
, 80 + x
* 160, 60 + y
* 120, 0);
9753 ok(compare_color(color
, test
->expected_colors
[y
* 4 + x
], 1),
9754 "Test %u: Got unexpected color 0x%08x at (%u, %u).\n", i
, color
, x
, y
);
9757 release_resource_readback(&rb
);
9759 ID3D11PixelShader_Release(ps
);
9760 ID3D11Texture2D_Release(texture
);
9761 ID3D11ShaderResourceView_Release(srv
);
9762 ID3D11SamplerState_Release(sampler
);
9764 ID3D11Buffer_Release(cb
);
9765 release_test_context(&test_context
);
9768 static void test_cube_maps(void)
9776 unsigned int i
, j
, sub_resource_idx
, sub_resource_count
;
9777 struct d3d11_test_context test_context
;
9778 D3D11_TEXTURE2D_DESC texture_desc
;
9779 const struct shader
*current_ps
;
9780 D3D_FEATURE_LEVEL feature_level
;
9781 ID3D11ShaderResourceView
*srv
;
9782 ID3D11DeviceContext
*context
;
9783 ID3D11Texture2D
*rtv_texture
;
9784 ID3D11RenderTargetView
*rtv
;
9785 struct vec4 expected_result
;
9786 ID3D11Resource
*texture
;
9787 ID3D11PixelShader
*ps
;
9788 ID3D11Device
*device
;
9789 float data
[64 * 64];
9798 unsigned int padding
;
9801 static const DWORD ps_cube_code
[] =
9810 float4
main(float4 position
: SV_POSITION
) : SV_Target
9813 p
.x
= position
.x
/ 640.0f
;
9814 p
.y
= position
.y
/ 480.0f
;
9820 coord
= float3(1.0f
, p
.x
, p
.y
);
9823 coord
= float3(-1.0f
, p
.x
, p
.y
);
9826 coord
= float3(p
.x
, 1.0f
, p
.y
);
9829 coord
= float3(p
.x
, -1.0f
, p
.y
);
9832 coord
= float3(p
.x
, p
.y
, 1.0f
);
9836 coord
= float3(p
.x
, p
.y
, -1.0f
);
9839 return t
.SampleLevel(s
, coord
, level
);
9842 0x43425844, 0x039aee18, 0xfd630453, 0xb884cf0f, 0x10100744, 0x00000001, 0x00000310, 0x00000003,
9843 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
9844 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
9845 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
9846 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000274, 0x00000040,
9847 0x0000009d, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000, 0x00000000,
9848 0x04003058, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001,
9849 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0400004c, 0x0020800a, 0x00000000,
9850 0x00000000, 0x03000006, 0x00004001, 0x00000000, 0x05000036, 0x00100012, 0x00000000, 0x00004001,
9851 0x3f800000, 0x0a000038, 0x00100062, 0x00000000, 0x00101106, 0x00000000, 0x00004002, 0x00000000,
9852 0x3acccccd, 0x3b088889, 0x00000000, 0x01000002, 0x03000006, 0x00004001, 0x00000001, 0x05000036,
9853 0x00100012, 0x00000000, 0x00004001, 0xbf800000, 0x0a000038, 0x00100062, 0x00000000, 0x00101106,
9854 0x00000000, 0x00004002, 0x00000000, 0x3acccccd, 0x3b088889, 0x00000000, 0x01000002, 0x03000006,
9855 0x00004001, 0x00000002, 0x0a000038, 0x00100052, 0x00000000, 0x00101106, 0x00000000, 0x00004002,
9856 0x3acccccd, 0x00000000, 0x3b088889, 0x00000000, 0x05000036, 0x00100022, 0x00000000, 0x00004001,
9857 0x3f800000, 0x01000002, 0x03000006, 0x00004001, 0x00000003, 0x0a000038, 0x00100052, 0x00000000,
9858 0x00101106, 0x00000000, 0x00004002, 0x3acccccd, 0x00000000, 0x3b088889, 0x00000000, 0x05000036,
9859 0x00100022, 0x00000000, 0x00004001, 0xbf800000, 0x01000002, 0x03000006, 0x00004001, 0x00000004,
9860 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889,
9861 0x00000000, 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0x3f800000, 0x01000002,
9862 0x0100000a, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
9863 0x3b088889, 0x00000000, 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0xbf800000,
9864 0x01000002, 0x01000017, 0x06000056, 0x00100082, 0x00000000, 0x0020801a, 0x00000000, 0x00000000,
9865 0x0b000048, 0x001020f2, 0x00000000, 0x00100246, 0x00000000, 0x00107e46, 0x00000000, 0x00106000,
9866 0x00000000, 0x0010003a, 0x00000000, 0x0100003e,
9868 static const struct shader ps_cube
= {ps_cube_code
, sizeof(ps_cube_code
)};
9869 static const DWORD ps_cube_array_code
[] =
9879 float4
main(float4 position
: SV_POSITION
) : SV_Target
9882 p
.x
= position
.x
/ 640.0f
;
9883 p
.y
= position
.y
/ 480.0f
;
9889 coord
= float3(1.0f
, p
.x
, p
.y
);
9892 coord
= float3(-1.0f
, p
.x
, p
.y
);
9895 coord
= float3(p
.x
, 1.0f
, p
.y
);
9898 coord
= float3(p
.x
, -1.0f
, p
.y
);
9901 coord
= float3(p
.x
, p
.y
, 1.0f
);
9905 coord
= float3(p
.x
, p
.y
, -1.0f
);
9908 return t
.SampleLevel(s
, float4(coord
, cube
), level
);
9911 0x43425844, 0xb8d5b94a, 0xdb4be034, 0x183aed19, 0xad4af415, 0x00000001, 0x00000328, 0x00000003,
9912 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
9913 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
9914 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
9915 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x0000028c, 0x00000041,
9916 0x000000a3, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000,
9917 0x00000000, 0x04005058, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000,
9918 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x0400004c, 0x0020800a,
9919 0x00000000, 0x00000000, 0x03000006, 0x00004001, 0x00000000, 0x05000036, 0x00100012, 0x00000000,
9920 0x00004001, 0x3f800000, 0x0a000038, 0x00100062, 0x00000000, 0x00101106, 0x00000000, 0x00004002,
9921 0x00000000, 0x3acccccd, 0x3b088889, 0x00000000, 0x01000002, 0x03000006, 0x00004001, 0x00000001,
9922 0x05000036, 0x00100012, 0x00000000, 0x00004001, 0xbf800000, 0x0a000038, 0x00100062, 0x00000000,
9923 0x00101106, 0x00000000, 0x00004002, 0x00000000, 0x3acccccd, 0x3b088889, 0x00000000, 0x01000002,
9924 0x03000006, 0x00004001, 0x00000002, 0x0a000038, 0x00100052, 0x00000000, 0x00101106, 0x00000000,
9925 0x00004002, 0x3acccccd, 0x00000000, 0x3b088889, 0x00000000, 0x05000036, 0x00100022, 0x00000000,
9926 0x00004001, 0x3f800000, 0x01000002, 0x03000006, 0x00004001, 0x00000003, 0x0a000038, 0x00100052,
9927 0x00000000, 0x00101106, 0x00000000, 0x00004002, 0x3acccccd, 0x00000000, 0x3b088889, 0x00000000,
9928 0x05000036, 0x00100022, 0x00000000, 0x00004001, 0xbf800000, 0x01000002, 0x03000006, 0x00004001,
9929 0x00000004, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
9930 0x3b088889, 0x00000000, 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0x3f800000,
9931 0x01000002, 0x0100000a, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002,
9932 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x00004001,
9933 0xbf800000, 0x01000002, 0x01000017, 0x06000056, 0x00100032, 0x00000001, 0x00208a66, 0x00000000,
9934 0x00000000, 0x05000036, 0x00100082, 0x00000000, 0x0010000a, 0x00000001, 0x0b000048, 0x001020f2,
9935 0x00000000, 0x00100e46, 0x00000000, 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0010001a,
9936 0x00000001, 0x0100003e,
9938 static const struct shader ps_cube_array
= {ps_cube_array_code
, sizeof(ps_cube_array_code
)};
9939 static const struct ps_test
9941 const struct shader
*ps
;
9942 unsigned int miplevel_count
;
9943 unsigned int array_size
;
9952 {&ps_cube_array
, 1, 12},
9953 {&ps_cube_array
, 2, 12},
9954 {&ps_cube_array
, 3, 12},
9955 {&ps_cube_array
, 0, 12},
9958 if (!init_test_context(&test_context
, NULL
))
9961 device
= test_context
.device
;
9962 context
= test_context
.immediate_context
;
9963 feature_level
= ID3D11Device_GetFeatureLevel(device
);
9965 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
9966 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
9967 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rtv_texture
);
9968 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
9969 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rtv_texture
, NULL
, &rtv
);
9970 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
9972 memset(&constant
, 0, sizeof(constant
));
9973 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(constant
), &constant
);
9975 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
9976 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
9980 for (i
= 0; i
< ARRAY_SIZE(ps_tests
); ++i
)
9982 const struct ps_test
*test
= &ps_tests
[i
];
9984 if (test
->array_size
/ 6 > 1 && feature_level
< D3D_FEATURE_LEVEL_10_1
)
9986 skip("Test %u: Cube map array textures require feature level 10_1.\n", i
);
9990 if (current_ps
!= test
->ps
)
9993 ID3D11PixelShader_Release(ps
);
9995 current_ps
= test
->ps
;
9997 hr
= ID3D11Device_CreatePixelShader(device
, current_ps
->code
, current_ps
->size
, NULL
, &ps
);
9998 ok(SUCCEEDED(hr
), "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
9999 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
10002 if (!test
->miplevel_count
)
10005 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
10007 memset(&expected_result
, 0, sizeof(expected_result
));
10009 memset(&constant
, 0, sizeof(constant
));
10010 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
10011 draw_quad(&test_context
);
10012 check_texture_vec4(rtv_texture
, &expected_result
, 0);
10013 constant
.level
= 1;
10014 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
10015 draw_quad(&test_context
);
10016 check_texture_vec4(rtv_texture
, &expected_result
, 0);
10020 texture_desc
.Width
= 64;
10021 texture_desc
.Height
= 64;
10022 texture_desc
.MipLevels
= test
->miplevel_count
;
10023 texture_desc
.ArraySize
= test
->array_size
;
10024 texture_desc
.Format
= DXGI_FORMAT_R32_FLOAT
;
10025 texture_desc
.SampleDesc
.Count
= 1;
10026 texture_desc
.SampleDesc
.Quality
= 0;
10027 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
10028 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
10029 texture_desc
.CPUAccessFlags
= 0;
10030 texture_desc
.MiscFlags
= D3D11_RESOURCE_MISC_TEXTURECUBE
;
10031 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, (ID3D11Texture2D
**)&texture
);
10032 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
10034 hr
= ID3D11Device_CreateShaderResourceView(device
, texture
, NULL
, &srv
);
10035 ok(SUCCEEDED(hr
), "Test %u: Failed to create shader resource view, hr %#x.\n", i
, hr
);
10036 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
10038 sub_resource_count
= texture_desc
.MipLevels
* texture_desc
.ArraySize
;
10039 for (sub_resource_idx
= 0; sub_resource_idx
< sub_resource_count
; ++sub_resource_idx
)
10041 for (j
= 0; j
< ARRAY_SIZE(data
); ++j
)
10042 data
[j
] = sub_resource_idx
;
10043 ID3D11DeviceContext_UpdateSubresource(context
, texture
, sub_resource_idx
, NULL
, data
,
10044 texture_desc
.Width
* sizeof(*data
), 0);
10047 expected_result
.y
= expected_result
.z
= 0.0f
;
10048 expected_result
.w
= 1.0f
;
10049 for (sub_resource_idx
= 0; sub_resource_idx
< sub_resource_count
; ++sub_resource_idx
)
10051 constant
.face
= (sub_resource_idx
/ texture_desc
.MipLevels
) % 6;
10052 constant
.level
= sub_resource_idx
% texture_desc
.MipLevels
;
10053 constant
.cube
= (sub_resource_idx
/ texture_desc
.MipLevels
) / 6;
10054 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
10056 draw_quad(&test_context
);
10057 expected_result
.x
= sub_resource_idx
;
10058 /* Avoid testing values affected by seamless cube map filtering. */
10059 SetRect(&rect
, 100, 100, 540, 380);
10060 check_texture_sub_resource_vec4(rtv_texture
, 0, &rect
, &expected_result
, 0);
10063 ID3D11Resource_Release(texture
);
10064 ID3D11ShaderResourceView_Release(srv
);
10066 ID3D11PixelShader_Release(ps
);
10068 ID3D11Buffer_Release(cb
);
10069 ID3D11RenderTargetView_Release(rtv
);
10070 ID3D11Texture2D_Release(rtv_texture
);
10071 release_test_context(&test_context
);
10074 static void test_depth_stencil_sampling(void)
10076 ID3D11PixelShader
*ps_cmp
, *ps_depth
, *ps_stencil
, *ps_depth_stencil
;
10077 ID3D11ShaderResourceView
*depth_srv
, *stencil_srv
;
10078 ID3D11SamplerState
*cmp_sampler
, *sampler
;
10079 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
10080 D3D11_DEPTH_STENCIL_VIEW_DESC dsv_desc
;
10081 struct d3d11_test_context test_context
;
10082 ID3D11Texture2D
*texture
, *rt_texture
;
10083 D3D11_TEXTURE2D_DESC texture_desc
;
10084 D3D11_SAMPLER_DESC sampler_desc
;
10085 ID3D11DeviceContext
*context
;
10086 ID3D11DepthStencilView
*dsv
;
10087 ID3D11RenderTargetView
*rtv
;
10088 struct vec4 ps_constant
;
10089 ID3D11Device
*device
;
10094 static const float black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
10095 static const DWORD ps_compare_code
[] =
10099 SamplerComparisonState s
;
10103 float4
main(float4 position
: SV_Position
) : SV_Target
10105 return t
.SampleCmp(s
, float2(position
.x
/ 640.0f
, position
.y
/ 480.0f
), ref
);
10108 0x43425844, 0xc2e0d84e, 0x0522c395, 0x9ff41580, 0xd3ca29cc, 0x00000001, 0x00000164, 0x00000003,
10109 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
10110 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
10111 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
10112 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000c8, 0x00000040,
10113 0x00000032, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300085a, 0x00106000, 0x00000000,
10114 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001,
10115 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0a000038, 0x00100032, 0x00000000,
10116 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x0c000046,
10117 0x00100012, 0x00000000, 0x00100046, 0x00000000, 0x00107006, 0x00000000, 0x00106000, 0x00000000,
10118 0x0020800a, 0x00000000, 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100006, 0x00000000,
10121 static const DWORD ps_sample_code
[] =
10127 float4
main(float4 position
: SV_Position
) : SV_Target
10129 return t
.Sample(s
, float2(position
.x
/ 640.0f
, position
.y
/ 480.0f
));
10132 0x43425844, 0x7472c092, 0x5548f00e, 0xf4e007f1, 0x5970429c, 0x00000001, 0x00000134, 0x00000003,
10133 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
10134 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
10135 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
10136 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
10137 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
10138 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
10139 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
10140 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
10141 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
10143 static const DWORD ps_stencil_code
[] =
10146 Texture2D
<uint4
> t
;
10148 float4
main(float4 position
: SV_Position
) : SV_Target
10151 t
.GetDimensions(s
.x
, s
.y
);
10152 return t
.Load(int3(float3(s
.x
* position
.x
/ 640.0f
, s
.y
* position
.y
/ 480.0f
, 0))).y
;
10155 0x43425844, 0x929fced8, 0x2cd93320, 0x0591ece3, 0xee50d04a, 0x00000001, 0x000001a0, 0x00000003,
10156 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
10157 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
10158 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
10159 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000104, 0x00000040,
10160 0x00000041, 0x04001858, 0x00107000, 0x00000000, 0x00004444, 0x04002064, 0x00101032, 0x00000000,
10161 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0700003d, 0x001000f2,
10162 0x00000000, 0x00004001, 0x00000000, 0x00107e46, 0x00000000, 0x07000038, 0x00100032, 0x00000000,
10163 0x00100046, 0x00000000, 0x00101046, 0x00000000, 0x0a000038, 0x00100032, 0x00000000, 0x00100046,
10164 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x0500001b, 0x00100032,
10165 0x00000000, 0x00100046, 0x00000000, 0x08000036, 0x001000c2, 0x00000000, 0x00004002, 0x00000000,
10166 0x00000000, 0x00000000, 0x00000000, 0x0700002d, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
10167 0x00107e46, 0x00000000, 0x05000056, 0x001020f2, 0x00000000, 0x00100556, 0x00000000, 0x0100003e,
10169 static const DWORD ps_depth_stencil_code
[] =
10173 Texture2D depth_tex
;
10174 Texture2D
<uint4
> stencil_tex
;
10176 float main(float4 position
: SV_Position
) : SV_Target
10179 float depth
, stencil
;
10180 depth_tex
.GetDimensions(s
.x
, s
.y
);
10181 p
= float2(s
.x
* position
.x
/ 640.0f
, s
.y
* position
.y
/ 480.0f
);
10182 depth
= depth_tex
.Sample(samp
, p
).r
;
10183 stencil
= stencil_tex
.Load(int3(float3(p
.x
, p
.y
, 0))).y
;
10184 return depth
+ stencil
;
10187 0x43425844, 0x348f8377, 0x977d1ee0, 0x8cca4f35, 0xff5c5afc, 0x00000001, 0x000001fc, 0x00000003,
10188 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
10189 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
10190 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
10191 0x00000000, 0x00000e01, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000160, 0x00000040,
10192 0x00000058, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
10193 0x04001858, 0x00107000, 0x00000001, 0x00004444, 0x04002064, 0x00101032, 0x00000000, 0x00000001,
10194 0x03000065, 0x00102012, 0x00000000, 0x02000068, 0x00000002, 0x0700003d, 0x001000f2, 0x00000000,
10195 0x00004001, 0x00000000, 0x00107e46, 0x00000000, 0x07000038, 0x00100032, 0x00000000, 0x00100046,
10196 0x00000000, 0x00101046, 0x00000000, 0x0a000038, 0x00100032, 0x00000000, 0x00100046, 0x00000000,
10197 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x0500001b, 0x00100032, 0x00000001,
10198 0x00100046, 0x00000000, 0x09000045, 0x001000f2, 0x00000000, 0x00100046, 0x00000000, 0x00107e46,
10199 0x00000000, 0x00106000, 0x00000000, 0x08000036, 0x001000c2, 0x00000001, 0x00004002, 0x00000000,
10200 0x00000000, 0x00000000, 0x00000000, 0x0700002d, 0x001000f2, 0x00000001, 0x00100e46, 0x00000001,
10201 0x00107e46, 0x00000001, 0x05000056, 0x00100022, 0x00000000, 0x0010001a, 0x00000001, 0x07000000,
10202 0x00102012, 0x00000000, 0x0010001a, 0x00000000, 0x0010000a, 0x00000000, 0x0100003e,
10204 static const struct test
10206 DXGI_FORMAT typeless_format
;
10207 DXGI_FORMAT dsv_format
;
10208 DXGI_FORMAT depth_view_format
;
10209 DXGI_FORMAT stencil_view_format
;
10213 {DXGI_FORMAT_R32G8X24_TYPELESS
, DXGI_FORMAT_D32_FLOAT_S8X24_UINT
,
10214 DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS
, DXGI_FORMAT_X32_TYPELESS_G8X24_UINT
},
10215 {DXGI_FORMAT_R32_TYPELESS
, DXGI_FORMAT_D32_FLOAT
,
10216 DXGI_FORMAT_R32_FLOAT
},
10217 {DXGI_FORMAT_R24G8_TYPELESS
, DXGI_FORMAT_D24_UNORM_S8_UINT
,
10218 DXGI_FORMAT_R24_UNORM_X8_TYPELESS
, DXGI_FORMAT_X24_TYPELESS_G8_UINT
},
10219 {DXGI_FORMAT_R16_TYPELESS
, DXGI_FORMAT_D16_UNORM
,
10220 DXGI_FORMAT_R16_UNORM
},
10223 if (!init_test_context(&test_context
, NULL
))
10226 device
= test_context
.device
;
10227 context
= test_context
.immediate_context
;
10229 if (is_amd_device(device
))
10231 /* Reads from depth/stencil shader resource views return stale values on some AMD drivers. */
10232 win_skip("Some AMD drivers have a bug affecting the test.\n");
10233 release_test_context(&test_context
);
10237 sampler_desc
.Filter
= D3D11_FILTER_COMPARISON_MIN_MAG_MIP_POINT
;
10238 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
10239 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
10240 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
10241 sampler_desc
.MipLODBias
= 0.0f
;
10242 sampler_desc
.MaxAnisotropy
= 0;
10243 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_GREATER
;
10244 sampler_desc
.BorderColor
[0] = 0.0f
;
10245 sampler_desc
.BorderColor
[1] = 0.0f
;
10246 sampler_desc
.BorderColor
[2] = 0.0f
;
10247 sampler_desc
.BorderColor
[3] = 0.0f
;
10248 sampler_desc
.MinLOD
= 0.0f
;
10249 sampler_desc
.MaxLOD
= 0.0f
;
10250 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &cmp_sampler
);
10251 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
10253 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
10254 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
10255 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler
);
10256 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
10258 texture_desc
.Width
= 640;
10259 texture_desc
.Height
= 480;
10260 texture_desc
.MipLevels
= 1;
10261 texture_desc
.ArraySize
= 1;
10262 texture_desc
.Format
= DXGI_FORMAT_R32_FLOAT
;
10263 texture_desc
.SampleDesc
.Count
= 1;
10264 texture_desc
.SampleDesc
.Quality
= 0;
10265 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
10266 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
10267 texture_desc
.CPUAccessFlags
= 0;
10268 texture_desc
.MiscFlags
= 0;
10269 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rt_texture
);
10270 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
10271 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rt_texture
, NULL
, &rtv
);
10272 ok(SUCCEEDED(hr
), "Failed to create render target, hr %#x.\n", hr
);
10273 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
10275 memset(&ps_constant
, 0, sizeof(ps_constant
));
10276 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(ps_constant
), &ps_constant
);
10277 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
10279 hr
= ID3D11Device_CreatePixelShader(device
, ps_compare_code
, sizeof(ps_compare_code
), NULL
, &ps_cmp
);
10280 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
10281 hr
= ID3D11Device_CreatePixelShader(device
, ps_sample_code
, sizeof(ps_sample_code
), NULL
, &ps_depth
);
10282 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
10283 hr
= ID3D11Device_CreatePixelShader(device
, ps_stencil_code
, sizeof(ps_stencil_code
), NULL
, &ps_stencil
);
10284 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
10285 hr
= ID3D11Device_CreatePixelShader(device
, ps_depth_stencil_code
, sizeof(ps_depth_stencil_code
), NULL
,
10286 &ps_depth_stencil
);
10287 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
10289 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
10291 texture_desc
.Format
= tests
[i
].typeless_format
;
10292 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
| D3D11_BIND_DEPTH_STENCIL
;
10293 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
10294 ok(SUCCEEDED(hr
), "Failed to create texture for format %#x, hr %#x.\n",
10295 texture_desc
.Format
, hr
);
10297 dsv_desc
.Format
= tests
[i
].dsv_format
;
10298 dsv_desc
.ViewDimension
= D3D11_DSV_DIMENSION_TEXTURE2D
;
10299 dsv_desc
.Flags
= 0;
10300 U(dsv_desc
).Texture2D
.MipSlice
= 0;
10301 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, &dsv_desc
, &dsv
);
10302 ok(SUCCEEDED(hr
), "Failed to create depth stencil view for format %#x, hr %#x.\n",
10303 dsv_desc
.Format
, hr
);
10305 srv_desc
.Format
= tests
[i
].depth_view_format
;
10306 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_TEXTURE2D
;
10307 U(srv_desc
).Texture2D
.MostDetailedMip
= 0;
10308 U(srv_desc
).Texture2D
.MipLevels
= 1;
10309 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, &srv_desc
, &depth_srv
);
10310 ok(SUCCEEDED(hr
), "Failed to create depth shader resource view for format %#x, hr %#x.\n",
10311 srv_desc
.Format
, hr
);
10313 ID3D11DeviceContext_PSSetShader(context
, ps_cmp
, NULL
, 0);
10314 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &depth_srv
);
10315 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &cmp_sampler
);
10317 ps_constant
.x
= 0.5f
;
10318 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
10319 NULL
, &ps_constant
, 0, 0);
10321 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
10322 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
10323 draw_quad(&test_context
);
10324 check_texture_float(rt_texture
, 0.0f
, 2);
10326 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 0.0f
, 0);
10327 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
10328 draw_quad(&test_context
);
10329 check_texture_float(rt_texture
, 1.0f
, 2);
10331 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 0.5f
, 0);
10332 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
10333 draw_quad(&test_context
);
10334 check_texture_float(rt_texture
, 0.0f
, 2);
10336 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 0.6f
, 0);
10337 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
10338 draw_quad(&test_context
);
10339 check_texture_float(rt_texture
, 0.0f
, 2);
10341 ps_constant
.x
= 0.7f
;
10342 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
10343 NULL
, &ps_constant
, 0, 0);
10345 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
10346 draw_quad(&test_context
);
10347 check_texture_float(rt_texture
, 1.0f
, 2);
10349 ID3D11DeviceContext_PSSetShader(context
, ps_depth
, NULL
, 0);
10350 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler
);
10352 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
10353 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
10354 draw_quad(&test_context
);
10355 check_texture_float(rt_texture
, 1.0f
, 2);
10357 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 0.2f
, 0);
10358 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
10359 draw_quad(&test_context
);
10360 check_texture_float(rt_texture
, 0.2f
, 2);
10362 if (!tests
[i
].stencil_view_format
)
10364 ID3D11DepthStencilView_Release(dsv
);
10365 ID3D11ShaderResourceView_Release(depth_srv
);
10366 ID3D11Texture2D_Release(texture
);
10370 srv_desc
.Format
= tests
[i
].stencil_view_format
;
10371 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, &srv_desc
, &stencil_srv
);
10372 if (hr
== E_OUTOFMEMORY
)
10374 skip("Could not create SRV for format %#x.\n", srv_desc
.Format
);
10375 ID3D11DepthStencilView_Release(dsv
);
10376 ID3D11ShaderResourceView_Release(depth_srv
);
10377 ID3D11Texture2D_Release(texture
);
10380 ok(SUCCEEDED(hr
), "Failed to create stencil shader resource view for format %#x, hr %#x.\n",
10381 srv_desc
.Format
, hr
);
10383 ID3D11DeviceContext_PSSetShader(context
, ps_stencil
, NULL
, 0);
10384 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &stencil_srv
);
10386 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_STENCIL
, 0.0f
, 0);
10387 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
10388 draw_quad(&test_context
);
10389 check_texture_float(rt_texture
, 0.0f
, 0);
10391 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_STENCIL
, 0.0f
, 100);
10392 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
10393 draw_quad(&test_context
);
10394 check_texture_float(rt_texture
, 100.0f
, 0);
10396 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_STENCIL
, 0.0f
, 255);
10397 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
10398 draw_quad(&test_context
);
10399 check_texture_float(rt_texture
, 255.0f
, 0);
10401 ID3D11DeviceContext_PSSetShader(context
, ps_depth_stencil
, NULL
, 0);
10402 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &depth_srv
);
10403 ID3D11DeviceContext_PSSetShaderResources(context
, 1, 1, &stencil_srv
);
10405 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
| D3D11_CLEAR_STENCIL
, 0.3f
, 3);
10406 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
10407 draw_quad(&test_context
);
10408 check_texture_float(rt_texture
, 3.3f
, 2);
10410 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
| D3D11_CLEAR_STENCIL
, 1.0f
, 3);
10411 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
10412 draw_quad(&test_context
);
10413 check_texture_float(rt_texture
, 4.0f
, 2);
10415 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
| D3D11_CLEAR_STENCIL
, 0.0f
, 0);
10416 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
10417 draw_quad(&test_context
);
10418 check_texture_float(rt_texture
, 0.0f
, 2);
10420 ID3D11DepthStencilView_Release(dsv
);
10421 ID3D11ShaderResourceView_Release(depth_srv
);
10422 ID3D11ShaderResourceView_Release(stencil_srv
);
10423 ID3D11Texture2D_Release(texture
);
10426 ID3D11Buffer_Release(cb
);
10427 ID3D11PixelShader_Release(ps_cmp
);
10428 ID3D11PixelShader_Release(ps_depth
);
10429 ID3D11PixelShader_Release(ps_depth_stencil
);
10430 ID3D11PixelShader_Release(ps_stencil
);
10431 ID3D11RenderTargetView_Release(rtv
);
10432 ID3D11SamplerState_Release(cmp_sampler
);
10433 ID3D11SamplerState_Release(sampler
);
10434 ID3D11Texture2D_Release(rt_texture
);
10435 release_test_context(&test_context
);
10438 static void test_sample_c_lz(void)
10440 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
10441 D3D11_DEPTH_STENCIL_VIEW_DESC dsv_desc
;
10442 struct d3d11_test_context test_context
;
10443 ID3D11Texture2D
*texture
, *rt_texture
;
10444 D3D11_TEXTURE2D_DESC texture_desc
;
10445 D3D11_SAMPLER_DESC sampler_desc
;
10446 ID3D11ShaderResourceView
*srv
;
10447 ID3D11DeviceContext
*context
;
10448 ID3D11DepthStencilView
*dsv
;
10449 ID3D11RenderTargetView
*rtv
;
10450 ID3D11SamplerState
*sampler
;
10451 struct vec4 ps_constant
;
10452 ID3D11PixelShader
*ps
;
10453 ID3D11Device
*device
;
10459 static const float clear_color
[] = {0.5f
, 0.5f
, 0.5f
, 0.5f
};
10460 static const DWORD ps_array_code
[] =
10464 SamplerComparisonState s
;
10469 float4
main(float4 position
: SV_Position
) : SV_Target
10471 return t
.SampleCmpLevelZero(s
, float3(position
.x
/ 640.0f
, position
.y
/ 480.0f
, layer
), ref
);
10474 0x43425844, 0xfe28b3c3, 0xdd7ef404, 0x8d5874a1, 0x984ff182, 0x00000001, 0x00000180, 0x00000003,
10475 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
10476 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
10477 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
10478 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000e4, 0x00000041,
10479 0x00000039, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300085a, 0x00106000,
10480 0x00000000, 0x04004058, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000,
10481 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0a000038, 0x00100032,
10482 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000,
10483 0x06000036, 0x00100042, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0c000047, 0x00100012,
10484 0x00000000, 0x00100246, 0x00000000, 0x00107006, 0x00000000, 0x00106000, 0x00000000, 0x0020800a,
10485 0x00000000, 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100006, 0x00000000, 0x0100003e,
10487 static const DWORD ps_cube_code
[] =
10491 SamplerComparisonState s
;
10496 float4
main(float4 position
: SV_Position
) : SV_Target
10499 p
.x
= position
.x
/ 640.0f
;
10500 p
.y
= position
.y
/ 480.0f
;
10503 switch ((uint
)face
)
10506 coord
= float3(1.0f
, p
.x
, p
.y
);
10509 coord
= float3(-1.0f
, p
.x
, p
.y
);
10512 coord
= float3(p
.x
, 1.0f
, p
.y
);
10515 coord
= float3(p
.x
, -1.0f
, p
.y
);
10518 coord
= float3(p
.x
, p
.y
, 1.0f
);
10522 coord
= float3(p
.x
, p
.y
, -1.0f
);
10526 return t
.SampleCmpLevelZero(s
, coord
, ref
);
10529 0x43425844, 0xde5655e5, 0x1b116fa1, 0xfce9e757, 0x41c28aac, 0x00000001, 0x00000328, 0x00000003,
10530 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
10531 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
10532 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
10533 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x0000028c, 0x00000041,
10534 0x000000a3, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300085a, 0x00106000,
10535 0x00000000, 0x04003058, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000,
10536 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0600001c, 0x00100012,
10537 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0300004c, 0x0010000a, 0x00000000, 0x03000006,
10538 0x00004001, 0x00000000, 0x05000036, 0x00100012, 0x00000000, 0x00004001, 0x3f800000, 0x0a000038,
10539 0x00100062, 0x00000000, 0x00101106, 0x00000000, 0x00004002, 0x00000000, 0x3acccccd, 0x3b088889,
10540 0x00000000, 0x01000002, 0x03000006, 0x00004001, 0x00000001, 0x05000036, 0x00100012, 0x00000000,
10541 0x00004001, 0xbf800000, 0x0a000038, 0x00100062, 0x00000000, 0x00101106, 0x00000000, 0x00004002,
10542 0x00000000, 0x3acccccd, 0x3b088889, 0x00000000, 0x01000002, 0x03000006, 0x00004001, 0x00000002,
10543 0x0a000038, 0x00100052, 0x00000000, 0x00101106, 0x00000000, 0x00004002, 0x3acccccd, 0x00000000,
10544 0x3b088889, 0x00000000, 0x05000036, 0x00100022, 0x00000000, 0x00004001, 0x3f800000, 0x01000002,
10545 0x03000006, 0x00004001, 0x00000003, 0x0a000038, 0x00100052, 0x00000000, 0x00101106, 0x00000000,
10546 0x00004002, 0x3acccccd, 0x00000000, 0x3b088889, 0x00000000, 0x05000036, 0x00100022, 0x00000000,
10547 0x00004001, 0xbf800000, 0x01000002, 0x03000006, 0x00004001, 0x00000004, 0x0a000038, 0x00100032,
10548 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000,
10549 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0x3f800000, 0x01000002, 0x0100000a, 0x0a000038,
10550 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000,
10551 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0xbf800000, 0x01000002, 0x01000017,
10552 0x0c000047, 0x00100012, 0x00000000, 0x00100246, 0x00000000, 0x00107006, 0x00000000, 0x00106000,
10553 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100006,
10554 0x00000000, 0x0100003e,
10556 static const float depth_values
[] = {1.0f
, 0.0f
, 0.5f
, 0.6f
, 0.4f
, 0.1f
};
10557 static const struct
10559 unsigned int layer
;
10587 if (!init_test_context(&test_context
, NULL
))
10590 device
= test_context
.device
;
10591 context
= test_context
.immediate_context
;
10593 sampler_desc
.Filter
= D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR
;
10594 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
10595 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
10596 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
10597 sampler_desc
.MipLODBias
= 0.0f
;
10598 sampler_desc
.MaxAnisotropy
= 0;
10599 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_GREATER
;
10600 sampler_desc
.BorderColor
[0] = 0.0f
;
10601 sampler_desc
.BorderColor
[1] = 0.0f
;
10602 sampler_desc
.BorderColor
[2] = 0.0f
;
10603 sampler_desc
.BorderColor
[3] = 0.0f
;
10604 sampler_desc
.MinLOD
= 0.0f
;
10605 sampler_desc
.MaxLOD
= 10.0f
;
10606 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler
);
10607 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
10609 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
10610 texture_desc
.Format
= DXGI_FORMAT_R32_FLOAT
;
10611 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rt_texture
);
10612 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
10613 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rt_texture
, NULL
, &rtv
);
10614 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
10615 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
10617 memset(&ps_constant
, 0, sizeof(ps_constant
));
10618 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(ps_constant
), &ps_constant
);
10620 /* 2D array texture */
10621 texture_desc
.Width
= 32;
10622 texture_desc
.Height
= 32;
10623 texture_desc
.MipLevels
= 2;
10624 texture_desc
.ArraySize
= ARRAY_SIZE(depth_values
);
10625 texture_desc
.Format
= DXGI_FORMAT_R32_TYPELESS
;
10626 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
| D3D11_BIND_DEPTH_STENCIL
;
10627 texture_desc
.MiscFlags
= 0;
10628 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
10629 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
10631 for (i
= 0; i
< ARRAY_SIZE(depth_values
); ++i
)
10633 dsv_desc
.Format
= DXGI_FORMAT_D32_FLOAT
;
10634 dsv_desc
.ViewDimension
= D3D11_DSV_DIMENSION_TEXTURE2DARRAY
;
10635 dsv_desc
.Flags
= 0;
10636 U(dsv_desc
).Texture2DArray
.MipSlice
= 0;
10637 U(dsv_desc
).Texture2DArray
.FirstArraySlice
= i
;
10638 U(dsv_desc
).Texture2DArray
.ArraySize
= 1;
10640 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, &dsv_desc
, &dsv
);
10641 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
10642 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, depth_values
[i
], 0);
10643 ID3D11DepthStencilView_Release(dsv
);
10645 U(dsv_desc
).Texture2DArray
.MipSlice
= 1;
10646 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, &dsv_desc
, &dsv
);
10647 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
10648 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
10649 ID3D11DepthStencilView_Release(dsv
);
10652 srv_desc
.Format
= DXGI_FORMAT_R32_FLOAT
;
10653 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_TEXTURE2DARRAY
;
10654 U(srv_desc
).Texture2DArray
.MostDetailedMip
= 0;
10655 U(srv_desc
).Texture2DArray
.MipLevels
= ~0u;
10656 U(srv_desc
).Texture2DArray
.FirstArraySlice
= 0;
10657 U(srv_desc
).Texture2DArray
.ArraySize
= ~0u;
10658 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, &srv_desc
, &srv
);
10659 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
10661 hr
= ID3D11Device_CreatePixelShader(device
, ps_array_code
, sizeof(ps_array_code
), NULL
, &ps
);
10662 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
10664 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
10665 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
10666 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler
);
10667 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
10669 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
10671 ps_constant
.x
= tests
[i
].d_ref
;
10672 ps_constant
.y
= tests
[i
].layer
;
10673 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
10674 NULL
, &ps_constant
, 0, 0);
10675 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, clear_color
);
10676 draw_quad(&test_context
);
10677 check_texture_float(rt_texture
, tests
[i
].expected
, 2);
10680 ID3D11Texture2D_Release(texture
);
10681 ID3D11ShaderResourceView_Release(srv
);
10682 ID3D11PixelShader_Release(ps
);
10685 texture_desc
.MiscFlags
= D3D11_RESOURCE_MISC_TEXTURECUBE
;
10686 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
10687 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
10689 for (i
= 0; i
< ARRAY_SIZE(depth_values
); ++i
)
10691 dsv_desc
.Format
= DXGI_FORMAT_D32_FLOAT
;
10692 dsv_desc
.ViewDimension
= D3D11_DSV_DIMENSION_TEXTURE2DARRAY
;
10693 dsv_desc
.Flags
= 0;
10694 U(dsv_desc
).Texture2DArray
.MipSlice
= 0;
10695 U(dsv_desc
).Texture2DArray
.FirstArraySlice
= i
;
10696 U(dsv_desc
).Texture2DArray
.ArraySize
= 1;
10698 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, &dsv_desc
, &dsv
);
10699 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
10700 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, depth_values
[i
], 0);
10701 ID3D11DepthStencilView_Release(dsv
);
10703 U(dsv_desc
).Texture2DArray
.MipSlice
= 1;
10704 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, &dsv_desc
, &dsv
);
10705 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
10706 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
10707 ID3D11DepthStencilView_Release(dsv
);
10710 srv_desc
.Format
= DXGI_FORMAT_R32_FLOAT
;
10711 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_TEXTURECUBE
;
10712 U(srv_desc
).TextureCube
.MostDetailedMip
= 0;
10713 U(srv_desc
).TextureCube
.MipLevels
= ~0u;
10714 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, &srv_desc
, &srv
);
10715 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
10717 hr
= ID3D11Device_CreatePixelShader(device
, ps_cube_code
, sizeof(ps_cube_code
), NULL
, &ps
);
10718 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
10720 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
10721 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
10722 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler
);
10723 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
10725 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
10727 ps_constant
.x
= tests
[i
].d_ref
;
10728 ps_constant
.y
= tests
[i
].layer
;
10729 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
10730 NULL
, &ps_constant
, 0, 0);
10731 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, clear_color
);
10732 draw_quad(&test_context
);
10733 /* Avoid testing values affected by seamless cube map filtering. */
10734 SetRect(&rect
, 100, 100, 540, 380);
10735 check_texture_sub_resource_float(rt_texture
, 0, &rect
, tests
[i
].expected
, 2);
10738 ID3D11Texture2D_Release(texture
);
10739 ID3D11ShaderResourceView_Release(srv
);
10741 ID3D11Buffer_Release(cb
);
10742 ID3D11PixelShader_Release(ps
);
10743 ID3D11RenderTargetView_Release(rtv
);
10744 ID3D11SamplerState_Release(sampler
);
10745 ID3D11Texture2D_Release(rt_texture
);
10746 release_test_context(&test_context
);
10749 static void test_multiple_render_targets(void)
10751 ID3D11RenderTargetView
*rtv
[4], *tmp_rtv
[4];
10752 D3D11_TEXTURE2D_DESC texture_desc
;
10753 ID3D11InputLayout
*input_layout
;
10754 unsigned int stride
, offset
, i
;
10755 ID3D11DeviceContext
*context
;
10756 ID3D11Texture2D
*rt
[4];
10757 ID3D11VertexShader
*vs
;
10758 ID3D11PixelShader
*ps
;
10759 ID3D11Device
*device
;
10764 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
10766 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
10768 static const DWORD vs_code
[] =
10771 float4
main(float4 position
: POSITION
) : SV_POSITION
10776 0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003,
10777 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
10778 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
10779 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
10780 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
10781 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
10782 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
10784 static const DWORD ps_code
[] =
10789 float4 t1
: SV_TARGET0
;
10790 float4 t2
: SV_Target1
;
10791 float4 t3
: SV_TARGET2
;
10792 float4 t4
: SV_Target3
;
10795 output
main(float4 position
: SV_POSITION
)
10798 o
.t1
= (float4
)1.0f
;
10799 o
.t2
= (float4
)0.5f
;
10800 o
.t3
= (float4
)0.2f
;
10801 o
.t4
= float4(0.0f
, 0.2f
, 0.5f
, 1.0f
);
10805 0x43425844, 0x8701ad18, 0xe3d5291d, 0x7b4288a6, 0x01917515, 0x00000001, 0x000001a8, 0x00000003,
10806 0x0000002c, 0x00000060, 0x000000e4, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
10807 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
10808 0x4e47534f, 0x0000007c, 0x00000004, 0x00000008, 0x00000068, 0x00000000, 0x00000000, 0x00000003,
10809 0x00000000, 0x0000000f, 0x00000072, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
10810 0x00000068, 0x00000002, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x00000072, 0x00000003,
10811 0x00000000, 0x00000003, 0x00000003, 0x0000000f, 0x545f5653, 0x45475241, 0x56530054, 0x7261545f,
10812 0x00746567, 0x52444853, 0x000000bc, 0x00000040, 0x0000002f, 0x03000065, 0x001020f2, 0x00000000,
10813 0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x03000065, 0x001020f2,
10814 0x00000003, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x3f800000, 0x3f800000,
10815 0x3f800000, 0x08000036, 0x001020f2, 0x00000001, 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000,
10816 0x3f000000, 0x08000036, 0x001020f2, 0x00000002, 0x00004002, 0x3e4ccccd, 0x3e4ccccd, 0x3e4ccccd,
10817 0x3e4ccccd, 0x08000036, 0x001020f2, 0x00000003, 0x00004002, 0x00000000, 0x3e4ccccd, 0x3f000000,
10818 0x3f800000, 0x0100003e,
10820 static const struct vec2 quad
[] =
10827 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 1.0f
};
10829 if (!(device
= create_device(NULL
)))
10831 skip("Failed to create device.\n");
10835 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
10836 vs_code
, sizeof(vs_code
), &input_layout
);
10837 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
10839 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(quad
), quad
);
10841 texture_desc
.Width
= 640;
10842 texture_desc
.Height
= 480;
10843 texture_desc
.MipLevels
= 1;
10844 texture_desc
.ArraySize
= 1;
10845 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
10846 texture_desc
.SampleDesc
.Count
= 1;
10847 texture_desc
.SampleDesc
.Quality
= 0;
10848 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
10849 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
10850 texture_desc
.CPUAccessFlags
= 0;
10851 texture_desc
.MiscFlags
= 0;
10853 for (i
= 0; i
< ARRAY_SIZE(rt
); ++i
)
10855 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rt
[i
]);
10856 ok(SUCCEEDED(hr
), "Failed to create texture %u, hr %#x.\n", i
, hr
);
10858 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rt
[i
], NULL
, &rtv
[i
]);
10859 ok(SUCCEEDED(hr
), "Failed to create rendertarget view %u, hr %#x.\n", i
, hr
);
10862 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
10863 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
10864 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
10865 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
10867 ID3D11Device_GetImmediateContext(device
, &context
);
10869 ID3D11DeviceContext_OMSetRenderTargets(context
, 4, rtv
, NULL
);
10870 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
10871 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
10872 stride
= sizeof(*quad
);
10874 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, &stride
, &offset
);
10875 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
10876 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
10878 set_viewport(context
, 0.0f
, 0.0f
, 640.0f
, 480.0f
, 0.0f
, 1.0f
);
10880 for (i
= 0; i
< ARRAY_SIZE(rtv
); ++i
)
10881 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
[i
], red
);
10882 ID3D11DeviceContext_Draw(context
, 4, 0);
10883 check_texture_color(rt
[0], 0xffffffff, 2);
10884 check_texture_color(rt
[1], 0x7f7f7f7f, 2);
10885 check_texture_color(rt
[2], 0x33333333, 2);
10886 check_texture_color(rt
[3], 0xff7f3300, 2);
10888 for (i
= 0; i
< ARRAY_SIZE(rtv
); ++i
)
10889 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
[i
], red
);
10890 for (i
= 0; i
< ARRAY_SIZE(tmp_rtv
); ++i
)
10892 memset(tmp_rtv
, 0, sizeof(tmp_rtv
));
10893 tmp_rtv
[i
] = rtv
[i
];
10894 ID3D11DeviceContext_OMSetRenderTargets(context
, 4, tmp_rtv
, NULL
);
10895 ID3D11DeviceContext_Draw(context
, 4, 0);
10897 check_texture_color(rt
[0], 0xffffffff, 2);
10898 check_texture_color(rt
[1], 0x7f7f7f7f, 2);
10899 check_texture_color(rt
[2], 0x33333333, 2);
10900 check_texture_color(rt
[3], 0xff7f3300, 2);
10902 ID3D11Buffer_Release(vb
);
10903 ID3D11PixelShader_Release(ps
);
10904 ID3D11VertexShader_Release(vs
);
10905 ID3D11InputLayout_Release(input_layout
);
10906 for (i
= 0; i
< ARRAY_SIZE(rtv
); ++i
)
10908 ID3D11RenderTargetView_Release(rtv
[i
]);
10909 ID3D11Texture2D_Release(rt
[i
]);
10911 ID3D11DeviceContext_Release(context
);
10912 refcount
= ID3D11Device_Release(device
);
10913 ok(!refcount
, "Device has %u references left.\n", refcount
);
10916 static void test_render_target_views(void)
10920 UINT miplevel_count
;
10924 static const struct vec4 red
= {1.0f
, 0.0f
, 0.0f
, 1.0f
};
10927 struct texture texture
;
10928 struct rtv_desc rtv
;
10929 DWORD expected_colors
[4];
10933 {{2, 1}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2D
, 0},
10934 {0xff0000ff, 0x00000000}},
10935 {{2, 1}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2D
, 1},
10936 {0x00000000, 0xff0000ff}},
10937 {{2, 1}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 0, 1},
10938 {0xff0000ff, 0x00000000}},
10939 {{2, 1}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2DARRAY
, 1, 0, 1},
10940 {0x00000000, 0xff0000ff}},
10941 {{1, 4}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2D
, 0},
10942 {0xff0000ff, 0x00000000, 0x00000000, 0x00000000}},
10943 {{1, 4}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 0, 1},
10944 {0xff0000ff, 0x00000000, 0x00000000, 0x00000000}},
10945 {{1, 4}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 1, 1},
10946 {0x00000000, 0xff0000ff, 0x00000000, 0x00000000}},
10947 {{1, 4}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 2, 1},
10948 {0x00000000, 0x00000000, 0xff0000ff, 0x00000000}},
10949 {{1, 4}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 3, 1},
10950 {0x00000000, 0x00000000, 0x00000000, 0xff0000ff}},
10951 {{1, 4}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 0, 4},
10952 {0xff0000ff, 0x00000000, 0x00000000, 0x00000000}},
10953 {{2, 2}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2D
, 0},
10954 {0xff0000ff, 0x00000000, 0x00000000, 0x00000000}},
10955 {{2, 2}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 0, 1},
10956 {0xff0000ff, 0x00000000, 0x00000000, 0x00000000}},
10957 {{2, 2}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 1, 1},
10958 {0x00000000, 0x00000000, 0xff0000ff, 0x00000000}},
10959 {{2, 2}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2DARRAY
, 1, 0, 1},
10960 {0x00000000, 0xff0000ff, 0x00000000, 0x00000000}},
10961 {{2, 2}, {DXGI_FORMAT_UNKNOWN
, D3D11_RTV_DIMENSION_TEXTURE2DARRAY
, 1, 1, 1},
10962 {0x00000000, 0x00000000, 0x00000000, 0xff0000ff}},
10964 #define FMT_UNKNOWN DXGI_FORMAT_UNKNOWN
10965 #define RGBA8_UNORM DXGI_FORMAT_R8G8B8A8_UNORM
10966 #define RGBA8_SRGB DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
10967 #define RGBA8_UINT DXGI_FORMAT_R8G8B8A8_UINT
10968 #define RGBA8_TL DXGI_FORMAT_R8G8B8A8_TYPELESS
10969 #define DIM_UNKNOWN D3D11_RTV_DIMENSION_UNKNOWN
10970 #define TEX_1D D3D11_RTV_DIMENSION_TEXTURE1D
10971 #define TEX_1D_ARRAY D3D11_RTV_DIMENSION_TEXTURE1DARRAY
10972 #define TEX_2D D3D11_RTV_DIMENSION_TEXTURE2D
10973 #define TEX_2D_ARRAY D3D11_RTV_DIMENSION_TEXTURE2DARRAY
10974 #define TEX_3D D3D11_RTV_DIMENSION_TEXTURE3D
10975 static const struct
10979 D3D11_RTV_DIMENSION dimension
;
10980 unsigned int miplevel_count
;
10981 unsigned int depth_or_array_size
;
10982 DXGI_FORMAT format
;
10984 struct rtv_desc rtv_desc
;
10986 invalid_desc_tests
[] =
10988 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, DIM_UNKNOWN
}},
10989 {{TEX_2D
, 6, 4, RGBA8_UNORM
}, {RGBA8_UNORM
, DIM_UNKNOWN
}},
10990 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0}},
10991 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 0, 1}},
10992 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 1}},
10993 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, ~0u}},
10994 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_2D
, 0}},
10995 {{TEX_2D
, 1, 1, RGBA8_TL
}, {FMT_UNKNOWN
, TEX_2D
, 0}},
10996 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 1}},
10997 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 0}},
10998 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 1, 0, 1}},
10999 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 2}},
11000 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 1}},
11001 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UINT
, TEX_2D
, 0, 0, 1}},
11002 {{TEX_2D
, 1, 1, RGBA8_UINT
}, {RGBA8_UNORM
, TEX_2D
, 0, 0, 1}},
11003 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_SRGB
, TEX_2D
, 0, 0, 1}},
11004 {{TEX_2D
, 1, 1, RGBA8_SRGB
}, {RGBA8_UNORM
, TEX_2D
, 0, 0, 1}},
11005 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0}},
11006 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 0, 1}},
11007 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0}},
11008 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 1}},
11009 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0}},
11010 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 0, 1}},
11011 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0}},
11012 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 1}},
11013 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 0}},
11014 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 1}},
11015 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_3D
, 0, 0, 1}},
11016 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_TL
, TEX_3D
, 0, 0, 1}},
11017 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 9}},
11018 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 3, 0, 2}},
11019 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 2, 0, 4}},
11020 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 8}},
11021 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 8, ~0u}},
11022 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 4, ~0u}},
11023 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 2, 2, ~0u}},
11024 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 3, 1, ~0u}},
11033 #undef TEX_1D_ARRAY
11035 #undef TEX_2D_ARRAY
11038 struct d3d11_test_context test_context
;
11039 D3D11_RENDER_TARGET_VIEW_DESC rtv_desc
;
11040 D3D11_TEXTURE3D_DESC texture3d_desc
;
11041 D3D11_TEXTURE2D_DESC texture_desc
;
11042 ID3D11DeviceContext
*context
;
11043 ID3D11RenderTargetView
*rtv
;
11044 ID3D11Texture3D
*texture3d
;
11045 ID3D11Texture2D
*texture
;
11046 ID3D11Resource
*resource
;
11047 ID3D11Device
*device
;
11048 unsigned int i
, j
, k
;
11052 if (!init_test_context(&test_context
, NULL
))
11055 device
= test_context
.device
;
11056 context
= test_context
.immediate_context
;
11058 texture_desc
.Width
= 32;
11059 texture_desc
.Height
= 32;
11060 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
11061 texture_desc
.SampleDesc
.Count
= 1;
11062 texture_desc
.SampleDesc
.Quality
= 0;
11063 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
11064 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
11065 texture_desc
.CPUAccessFlags
= 0;
11066 texture_desc
.MiscFlags
= 0;
11068 data
= heap_alloc_zero(texture_desc
.Width
* texture_desc
.Height
* 4);
11069 ok(!!data
, "Failed to allocate memory.\n");
11071 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
11073 const struct test
*test
= &tests
[i
];
11074 unsigned int sub_resource_count
;
11076 texture_desc
.MipLevels
= test
->texture
.miplevel_count
;
11077 texture_desc
.ArraySize
= test
->texture
.array_size
;
11079 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
11080 ok(SUCCEEDED(hr
), "Test %u: Failed to create texture, hr %#x.\n", i
, hr
);
11082 get_rtv_desc(&rtv_desc
, &test
->rtv
);
11083 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, &rtv_desc
, &rtv
);
11084 ok(SUCCEEDED(hr
), "Test %u: Failed to create render target view, hr %#x.\n", i
, hr
);
11086 for (j
= 0; j
< texture_desc
.ArraySize
; ++j
)
11088 for (k
= 0; k
< texture_desc
.MipLevels
; ++k
)
11090 unsigned int sub_resource_idx
= j
* texture_desc
.MipLevels
+ k
;
11091 ID3D11DeviceContext_UpdateSubresource(context
,
11092 (ID3D11Resource
*)texture
, sub_resource_idx
, NULL
, data
, texture_desc
.Width
* 4, 0);
11095 check_texture_color(texture
, 0, 0);
11097 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
11098 draw_color_quad(&test_context
, &red
);
11100 sub_resource_count
= texture_desc
.MipLevels
* texture_desc
.ArraySize
;
11101 assert(sub_resource_count
<= ARRAY_SIZE(test
->expected_colors
));
11102 for (j
= 0; j
< sub_resource_count
; ++j
)
11103 check_texture_sub_resource_color(texture
, j
, NULL
, test
->expected_colors
[j
], 1);
11105 ID3D11RenderTargetView_Release(rtv
);
11106 ID3D11Texture2D_Release(texture
);
11109 texture3d_desc
.Width
= 32;
11110 texture3d_desc
.Height
= 32;
11111 texture3d_desc
.Depth
= 32;
11112 texture3d_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
11113 texture3d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
11114 texture3d_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
11115 texture3d_desc
.CPUAccessFlags
= 0;
11116 texture3d_desc
.MiscFlags
= 0;
11118 for (i
= 0; i
< ARRAY_SIZE(invalid_desc_tests
); ++i
)
11120 assert(invalid_desc_tests
[i
].texture
.dimension
== D3D11_RTV_DIMENSION_TEXTURE2D
11121 || invalid_desc_tests
[i
].texture
.dimension
== D3D11_RTV_DIMENSION_TEXTURE3D
);
11123 if (invalid_desc_tests
[i
].texture
.dimension
== D3D11_RTV_DIMENSION_TEXTURE2D
)
11125 texture_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
11126 texture_desc
.ArraySize
= invalid_desc_tests
[i
].texture
.depth_or_array_size
;
11127 texture_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
11128 texture_desc
.MiscFlags
= 0;
11130 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
11131 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
11132 resource
= (ID3D11Resource
*)texture
;
11136 texture3d_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
11137 texture3d_desc
.Depth
= invalid_desc_tests
[i
].texture
.depth_or_array_size
;
11138 texture3d_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
11140 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &texture3d
);
11141 ok(SUCCEEDED(hr
), "Test %u: Failed to create 3d texture, hr %#x.\n", i
, hr
);
11142 resource
= (ID3D11Resource
*)texture3d
;
11145 get_rtv_desc(&rtv_desc
, &invalid_desc_tests
[i
].rtv_desc
);
11146 hr
= ID3D11Device_CreateRenderTargetView(device
, resource
, &rtv_desc
, &rtv
);
11147 ok(hr
== E_INVALIDARG
, "Test %u: Got unexpected hr %#x.\n", i
, hr
);
11149 ID3D11Resource_Release(resource
);
11153 release_test_context(&test_context
);
11156 static void test_layered_rendering(void)
11160 unsigned int layer_offset
;
11161 unsigned int draw_id
;
11162 unsigned int padding
[2];
11164 struct d3d11_test_context test_context
;
11165 D3D11_RENDER_TARGET_VIEW_DESC rtv_desc
;
11166 unsigned int i
, sub_resource_count
;
11167 D3D11_TEXTURE2D_DESC texture_desc
;
11168 ID3D11DeviceContext
*context
;
11169 ID3D11RenderTargetView
*rtv
;
11170 ID3D11Texture2D
*texture
;
11171 ID3D11GeometryShader
*gs
;
11172 ID3D11VertexShader
*vs
;
11173 ID3D11PixelShader
*ps
;
11174 ID3D11Device
*device
;
11179 static const DWORD vs_code
[] =
11184 void main(float4 position
: POSITION
,
11185 out float4 out_position
: SV_POSITION
,
11186 out uint layer
: SV_RenderTargetArrayIndex
)
11188 out_position
= position
;
11189 layer
= layer_offset
;
11192 0x43425844, 0x71f7b9cd, 0x2ab8c713, 0x53e77663, 0x54a9ba68, 0x00000001, 0x00000158, 0x00000004,
11193 0x00000030, 0x00000064, 0x000000cc, 0x00000148, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008,
11194 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954,
11195 0xababab00, 0x4e47534f, 0x00000060, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001,
11196 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000004, 0x00000001, 0x00000001,
11197 0x00000e01, 0x505f5653, 0x5449534f, 0x004e4f49, 0x525f5653, 0x65646e65, 0x72615472, 0x41746567,
11198 0x79617272, 0x65646e49, 0xabab0078, 0x52444853, 0x00000074, 0x00010040, 0x0000001d, 0x04000059,
11199 0x00208e46, 0x00000000, 0x00000001, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2,
11200 0x00000000, 0x00000001, 0x04000067, 0x00102012, 0x00000001, 0x00000004, 0x05000036, 0x001020f2,
11201 0x00000000, 0x00101e46, 0x00000000, 0x06000036, 0x00102012, 0x00000001, 0x0020800a, 0x00000000,
11202 0x00000000, 0x0100003e, 0x30494653, 0x00000008, 0x00002000, 0x00000000,
11204 static const DWORD gs_5_code
[] =
11211 float4 pos
: SV_Position
;
11216 float4 pos
: SV_Position
;
11217 uint layer
: SV_RenderTargetArrayIndex
;
11221 [maxvertexcount(3)]
11222 void main(triangle gs_in vin
[3], in uint instance_id
: SV_GSInstanceID
,
11223 inout TriangleStream
<gs_out
> vout
)
11226 o
.layer
= layer_offset
+ instance_id
;
11227 for (uint i
= 0; i
< 3; ++i
)
11229 o
.pos
= vin
[i
].pos
;
11234 0x43425844, 0xb52da162, 0x9a13d8ee, 0xf7c30b50, 0xe80bc2e7, 0x00000001, 0x00000218, 0x00000003,
11235 0x0000002c, 0x00000060, 0x000000d0, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
11236 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x7469736f, 0x006e6f69,
11237 0x3547534f, 0x00000068, 0x00000002, 0x00000008, 0x00000000, 0x00000040, 0x00000000, 0x00000001,
11238 0x00000003, 0x00000000, 0x0000000f, 0x00000000, 0x0000004c, 0x00000000, 0x00000004, 0x00000001,
11239 0x00000001, 0x00000e01, 0x505f5653, 0x7469736f, 0x006e6f69, 0x525f5653, 0x65646e65, 0x72615472,
11240 0x41746567, 0x79617272, 0x65646e49, 0xabab0078, 0x58454853, 0x00000140, 0x00020050, 0x00000050,
11241 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x05000061, 0x002010f2, 0x00000003,
11242 0x00000000, 0x00000001, 0x0200005f, 0x00025000, 0x02000068, 0x00000001, 0x020000ce, 0x00000004,
11243 0x0100185d, 0x0300008f, 0x00110000, 0x00000000, 0x0100285c, 0x04000067, 0x001020f2, 0x00000000,
11244 0x00000001, 0x04000067, 0x00102012, 0x00000001, 0x00000004, 0x0200005e, 0x00000003, 0x0700001e,
11245 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x0002500a, 0x05000036, 0x00100022,
11246 0x00000000, 0x00004001, 0x00000000, 0x01000030, 0x07000050, 0x00100042, 0x00000000, 0x0010001a,
11247 0x00000000, 0x00004001, 0x00000003, 0x03040003, 0x0010002a, 0x00000000, 0x07000036, 0x001020f2,
11248 0x00000000, 0x00a01e46, 0x0010001a, 0x00000000, 0x00000000, 0x05000036, 0x00102012, 0x00000001,
11249 0x0010000a, 0x00000000, 0x03000075, 0x00110000, 0x00000000, 0x0700001e, 0x00100022, 0x00000000,
11250 0x0010001a, 0x00000000, 0x00004001, 0x00000001, 0x01000016, 0x0100003e,
11252 static const DWORD gs_4_code
[] =
11259 float4 pos
: SV_Position
;
11264 float4 pos
: SV_Position
;
11265 uint layer
: SV_RenderTargetArrayIndex
;
11268 [maxvertexcount(12)]
11269 void main(triangle gs_in vin
[3], inout TriangleStream
<gs_out
> vout
)
11272 for (uint instance_id
= 0; instance_id
< 4; ++instance_id
)
11274 o
.layer
= layer_offset
+ instance_id
;
11275 for (uint i
= 0; i
< 3; ++i
)
11277 o
.pos
= vin
[i
].pos
;
11280 vout
.RestartStrip();
11284 0x43425844, 0x7eabd7c5, 0x8af1468e, 0xd585cade, 0xfe0d761d, 0x00000001, 0x00000250, 0x00000003,
11285 0x0000002c, 0x00000060, 0x000000c8, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
11286 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x7469736f, 0x006e6f69,
11287 0x4e47534f, 0x00000060, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
11288 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000004, 0x00000001, 0x00000001, 0x00000e01,
11289 0x505f5653, 0x7469736f, 0x006e6f69, 0x525f5653, 0x65646e65, 0x72615472, 0x41746567, 0x79617272,
11290 0x65646e49, 0xabab0078, 0x52444853, 0x00000180, 0x00020040, 0x00000060, 0x04000059, 0x00208e46,
11291 0x00000000, 0x00000001, 0x05000061, 0x002010f2, 0x00000003, 0x00000000, 0x00000001, 0x02000068,
11292 0x00000001, 0x0100185d, 0x0100285c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x04000067,
11293 0x00102012, 0x00000001, 0x00000004, 0x0200005e, 0x0000000c, 0x05000036, 0x00100012, 0x00000000,
11294 0x00004001, 0x00000000, 0x01000030, 0x07000050, 0x00100022, 0x00000000, 0x0010000a, 0x00000000,
11295 0x00004001, 0x00000004, 0x03040003, 0x0010001a, 0x00000000, 0x0800001e, 0x00100022, 0x00000000,
11296 0x0020800a, 0x00000000, 0x00000000, 0x0010000a, 0x00000000, 0x05000036, 0x00100042, 0x00000000,
11297 0x00004001, 0x00000000, 0x01000030, 0x07000050, 0x00100082, 0x00000000, 0x0010002a, 0x00000000,
11298 0x00004001, 0x00000003, 0x03040003, 0x0010003a, 0x00000000, 0x07000036, 0x001020f2, 0x00000000,
11299 0x00a01e46, 0x0010002a, 0x00000000, 0x00000000, 0x05000036, 0x00102012, 0x00000001, 0x0010001a,
11300 0x00000000, 0x01000013, 0x0700001e, 0x00100042, 0x00000000, 0x0010002a, 0x00000000, 0x00004001,
11301 0x00000001, 0x01000016, 0x01000009, 0x0700001e, 0x00100012, 0x00000000, 0x0010000a, 0x00000000,
11302 0x00004001, 0x00000001, 0x01000016, 0x0100003e,
11304 static const DWORD ps_code
[] =
11310 float4
main(in float4 pos
: SV_Position
,
11311 in uint layer
: SV_RenderTargetArrayIndex
) : SV_Target
11313 return float4(layer
, draw_id
, 0, 0);
11316 0x43425844, 0x5fa6ae84, 0x3f893c81, 0xf15892d6, 0x142e2e6b, 0x00000001, 0x00000154, 0x00000003,
11317 0x0000002c, 0x00000094, 0x000000c8, 0x4e475349, 0x00000060, 0x00000002, 0x00000008, 0x00000038,
11318 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000004,
11319 0x00000001, 0x00000001, 0x00000101, 0x505f5653, 0x7469736f, 0x006e6f69, 0x525f5653, 0x65646e65,
11320 0x72615472, 0x41746567, 0x79617272, 0x65646e49, 0xabab0078, 0x4e47534f, 0x0000002c, 0x00000001,
11321 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653,
11322 0x65677261, 0xabab0074, 0x52444853, 0x00000084, 0x00000040, 0x00000021, 0x04000059, 0x00208e46,
11323 0x00000000, 0x00000001, 0x04000864, 0x00101012, 0x00000001, 0x00000004, 0x03000065, 0x001020f2,
11324 0x00000000, 0x05000056, 0x00102012, 0x00000000, 0x0010100a, 0x00000001, 0x06000056, 0x00102022,
11325 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x08000036, 0x001020c2, 0x00000000, 0x00004002,
11326 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0100003e,
11328 static const struct vec4 expected_values
[] =
11330 {0.0f
, 0.0f
}, {0.0f
, 3.0f
}, {3.0f
, 11.0f
}, {1.0f
, 0.0f
}, {1.0f
, 3.0f
}, {3.0f
, 10.0f
},
11331 {2.0f
, 0.0f
}, {2.0f
, 3.0f
}, {3.0f
, 9.0f
}, {4.0f
, 2.0f
}, {3.0f
, 3.0f
}, {3.0f
, 8.0f
},
11332 {4.0f
, 1.0f
}, {4.0f
, 3.0f
}, {3.0f
, 7.0f
}, {5.0f
, 1.0f
}, {5.0f
, 3.0f
}, {3.0f
, 6.0f
},
11333 {6.0f
, 1.0f
}, {6.0f
, 3.0f
}, {3.0f
, 5.0f
}, {7.0f
, 1.0f
}, {7.0f
, 3.0f
}, {3.0f
, 4.0f
},
11335 static const struct vec4 vs_expected_value
= {1.0f
, 42.0f
};
11337 if (!init_test_context(&test_context
, NULL
))
11340 device
= test_context
.device
;
11341 context
= test_context
.immediate_context
;
11343 warp
= is_warp_device(device
);
11345 memset(&constant
, 0, sizeof(constant
));
11346 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(constant
), &constant
);
11347 ID3D11DeviceContext_VSSetConstantBuffers(context
, 0, 1, &cb
);
11348 ID3D11DeviceContext_GSSetConstantBuffers(context
, 0, 1, &cb
);
11349 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
11351 /* Geometry shader instancing seems broken on WARP. */
11352 if (ID3D11Device_GetFeatureLevel(device
) < D3D_FEATURE_LEVEL_11_0
|| warp
)
11354 hr
= ID3D11Device_CreateGeometryShader(device
, gs_4_code
, sizeof(gs_4_code
), NULL
, &gs
);
11355 ok(SUCCEEDED(hr
), "Failed to create geometry shader, hr %#x.\n", hr
);
11359 hr
= ID3D11Device_CreateGeometryShader(device
, gs_5_code
, sizeof(gs_5_code
), NULL
, &gs
);
11360 ok(SUCCEEDED(hr
), "Failed to create geometry shader, hr %#x.\n", hr
);
11362 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
11364 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
11365 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
11366 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
11368 texture_desc
.Width
= 32;
11369 texture_desc
.Height
= 32;
11370 texture_desc
.MipLevels
= 3;
11371 texture_desc
.ArraySize
= 8;
11372 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
11373 texture_desc
.SampleDesc
.Count
= 1;
11374 texture_desc
.SampleDesc
.Quality
= 0;
11375 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
11376 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
11377 texture_desc
.CPUAccessFlags
= 0;
11378 texture_desc
.MiscFlags
= 0;
11379 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
11380 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
11382 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
11383 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
11384 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
11385 constant
.layer_offset
= 0;
11386 constant
.draw_id
= 0;
11387 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
11388 draw_quad(&test_context
);
11389 constant
.layer_offset
= 4;
11390 constant
.draw_id
= 1;
11391 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
11392 draw_quad(&test_context
);
11393 ID3D11RenderTargetView_Release(rtv
);
11395 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_TEXTURE2DARRAY
;
11396 rtv_desc
.Format
= texture_desc
.Format
;
11397 U(rtv_desc
).Texture2DArray
.MipSlice
= 0;
11398 U(rtv_desc
).Texture2DArray
.FirstArraySlice
= 3;
11399 U(rtv_desc
).Texture2DArray
.ArraySize
= 1;
11400 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, &rtv_desc
, &rtv
);
11401 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
11402 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
11403 constant
.layer_offset
= 1;
11404 constant
.draw_id
= 2;
11405 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
11406 draw_quad(&test_context
);
11407 ID3D11RenderTargetView_Release(rtv
);
11409 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_TEXTURE2DARRAY
;
11410 U(rtv_desc
).Texture2DArray
.MipSlice
= 1;
11411 U(rtv_desc
).Texture2DArray
.FirstArraySlice
= 0;
11412 U(rtv_desc
).Texture2DArray
.ArraySize
= ~0u;
11413 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, &rtv_desc
, &rtv
);
11414 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
11415 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
11416 constant
.layer_offset
= 0;
11417 constant
.draw_id
= 3;
11418 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
11419 draw_quad(&test_context
);
11420 constant
.layer_offset
= 4;
11421 constant
.draw_id
= 3;
11422 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
11423 draw_quad(&test_context
);
11424 ID3D11RenderTargetView_Release(rtv
);
11426 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_TEXTURE2DARRAY
;
11427 U(rtv_desc
).Texture2DArray
.MipSlice
= 2;
11428 U(rtv_desc
).Texture2DArray
.ArraySize
= 1;
11429 for (i
= 0; i
< texture_desc
.ArraySize
; ++i
)
11431 U(rtv_desc
).Texture2DArray
.FirstArraySlice
= texture_desc
.ArraySize
- 1 - i
;
11432 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, &rtv_desc
, &rtv
);
11433 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
11434 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
11435 constant
.layer_offset
= 0;
11436 constant
.draw_id
= 4 + i
;
11437 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
11438 draw_quad(&test_context
);
11439 ID3D11RenderTargetView_Release(rtv
);
11442 sub_resource_count
= texture_desc
.MipLevels
* texture_desc
.ArraySize
;
11443 assert(ARRAY_SIZE(expected_values
) == sub_resource_count
);
11444 for (i
= 0; i
< sub_resource_count
; ++i
)
11446 if (warp
&& (i
== 3 || i
== 4)) /* Broken on WARP. */
11448 check_texture_sub_resource_vec4(texture
, i
, NULL
, &expected_values
[i
], 1);
11451 /* layered rendering without GS */
11452 if (!check_viewport_array_index_from_any_shader_support(device
))
11454 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
11455 todo_wine
ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
11457 ID3D11VertexShader_Release(vs
);
11458 skip("Viewport array index not supported in vertex shaders.\n");
11462 ID3D11DeviceContext_GSSetShader(context
, NULL
, NULL
, 0);
11464 constant
.layer_offset
= 1;
11465 constant
.draw_id
= 42;
11466 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
11467 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_TEXTURE2DARRAY
;
11468 U(rtv_desc
).Texture2DArray
.MipSlice
= 0;
11469 U(rtv_desc
).Texture2DArray
.FirstArraySlice
= 0;
11470 U(rtv_desc
).Texture2DArray
.ArraySize
= ~0u;
11471 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, &rtv_desc
, &rtv
);
11472 ok(hr
== S_OK
, "Failed to create render target view, hr %#x.\n", hr
);
11473 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
11474 draw_quad_vs(&test_context
, vs_code
, sizeof(vs_code
));
11475 check_texture_sub_resource_vec4(texture
,
11476 constant
.layer_offset
* texture_desc
.MipLevels
, NULL
, &vs_expected_value
, 1);
11477 ID3D11RenderTargetView_Release(rtv
);
11480 ID3D11Texture2D_Release(texture
);
11482 ID3D11Buffer_Release(cb
);
11483 ID3D11GeometryShader_Release(gs
);
11484 ID3D11PixelShader_Release(ps
);
11485 release_test_context(&test_context
);
11488 static void test_scissor(void)
11490 struct d3d11_test_context test_context
;
11491 ID3D11DeviceContext
*immediate_context
;
11492 D3D11_RASTERIZER_DESC rs_desc
;
11493 ID3D11RasterizerState
*rs
;
11494 D3D11_RECT scissor_rect
;
11495 ID3D11Device
*device
;
11499 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 1.0f
};
11500 static const struct vec4 green
= {0.0f
, 1.0f
, 0.0f
, 1.0f
};
11502 if (!init_test_context(&test_context
, NULL
))
11505 device
= test_context
.device
;
11506 immediate_context
= test_context
.immediate_context
;
11508 rs_desc
.FillMode
= D3D11_FILL_SOLID
;
11509 rs_desc
.CullMode
= D3D11_CULL_BACK
;
11510 rs_desc
.FrontCounterClockwise
= FALSE
;
11511 rs_desc
.DepthBias
= 0;
11512 rs_desc
.DepthBiasClamp
= 0.0f
;
11513 rs_desc
.SlopeScaledDepthBias
= 0.0f
;
11514 rs_desc
.DepthClipEnable
= TRUE
;
11515 rs_desc
.ScissorEnable
= TRUE
;
11516 rs_desc
.MultisampleEnable
= FALSE
;
11517 rs_desc
.AntialiasedLineEnable
= FALSE
;
11518 hr
= ID3D11Device_CreateRasterizerState(device
, &rs_desc
, &rs
);
11519 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
11521 SetRect(&scissor_rect
, 160, 120, 480, 360);
11522 ID3D11DeviceContext_RSSetScissorRects(immediate_context
, 1, &scissor_rect
);
11524 ID3D11DeviceContext_ClearRenderTargetView(immediate_context
, test_context
.backbuffer_rtv
, red
);
11525 check_texture_color(test_context
.backbuffer
, 0xff0000ff, 1);
11527 draw_color_quad(&test_context
, &green
);
11528 color
= get_texture_color(test_context
.backbuffer
, 320, 60);
11529 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
11530 color
= get_texture_color(test_context
.backbuffer
, 80, 240);
11531 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
11532 color
= get_texture_color(test_context
.backbuffer
, 320, 240);
11533 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
11534 color
= get_texture_color(test_context
.backbuffer
, 560, 240);
11535 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
11536 color
= get_texture_color(test_context
.backbuffer
, 320, 420);
11537 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
11539 ID3D11DeviceContext_ClearRenderTargetView(immediate_context
, test_context
.backbuffer_rtv
, red
);
11540 ID3D11DeviceContext_RSSetState(immediate_context
, rs
);
11541 draw_color_quad(&test_context
, &green
);
11542 color
= get_texture_color(test_context
.backbuffer
, 320, 60);
11543 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
11544 color
= get_texture_color(test_context
.backbuffer
, 80, 240);
11545 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
11546 color
= get_texture_color(test_context
.backbuffer
, 320, 240);
11547 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
11548 color
= get_texture_color(test_context
.backbuffer
, 560, 240);
11549 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
11550 color
= get_texture_color(test_context
.backbuffer
, 320, 420);
11551 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
11553 ID3D11RasterizerState_Release(rs
);
11554 release_test_context(&test_context
);
11557 static void test_clear_state(void)
11559 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
11560 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
11562 {"POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
11565 float4
main(float4 pos
: POSITION
) : POSITION
11570 static const DWORD simple_vs
[] =
11572 0x43425844, 0x66689e7c, 0x643f0971, 0xb7f67ff4, 0xabc48688, 0x00000001, 0x000000d4, 0x00000003,
11573 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
11574 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
11575 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
11576 0x00000000, 0x0000000f, 0x49534f50, 0x4e4f4954, 0xababab00, 0x52444853, 0x00000038, 0x00010040,
11577 0x0000000e, 0x0300005f, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
11578 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
11583 float4 position
: SV_Position
;
11586 struct patch_constant_data
11588 float edges
[3] : SV_TessFactor
;
11589 float inside
: SV_InsideTessFactor
;
11592 void patch_constant(InputPatch
<data
, 3> input
, out patch_constant_data output
)
11594 output
.edges
[0] = output
.edges
[1] = output
.edges
[2] = 1.0f
;
11595 output
.inside
= 1.0f
;
11599 [outputcontrolpoints(3)]
11600 [partitioning("integer")]
11601 [outputtopology("triangle_ccw")]
11602 [patchconstantfunc("patch_constant")]
11603 data
hs_main(InputPatch
<data
, 3> input
, uint i
: SV_OutputControlPointID
)
11609 void ds_main(patch_constant_data input
,
11610 float3 tess_coord
: SV_DomainLocation
,
11611 const OutputPatch
<data
, 3> patch
,
11614 output
.position
= tess_coord
.x
* patch
[0].position
11615 + tess_coord
.y
* patch
[1].position
11616 + tess_coord
.z
* patch
[2].position
;
11619 static const DWORD simple_hs
[] =
11621 0x43425844, 0x42b5df25, 0xfd8aa2b1, 0xbe5490cb, 0xb595f8b1, 0x00000001, 0x0000020c, 0x00000004,
11622 0x00000030, 0x00000064, 0x00000098, 0x0000012c, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008,
11623 0x00000020, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x7469736f,
11624 0x006e6f69, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
11625 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69, 0x47534350, 0x0000008c,
11626 0x00000004, 0x00000008, 0x00000068, 0x00000000, 0x0000000d, 0x00000003, 0x00000000, 0x00000e01,
11627 0x00000068, 0x00000001, 0x0000000d, 0x00000003, 0x00000001, 0x00000e01, 0x00000068, 0x00000002,
11628 0x0000000d, 0x00000003, 0x00000002, 0x00000e01, 0x00000076, 0x00000000, 0x0000000e, 0x00000003,
11629 0x00000003, 0x00000e01, 0x545f5653, 0x46737365, 0x6f746361, 0x56530072, 0x736e495f, 0x54656469,
11630 0x46737365, 0x6f746361, 0xabab0072, 0x58454853, 0x000000d8, 0x00030050, 0x00000036, 0x01000071,
11631 0x01001893, 0x01001894, 0x01001095, 0x01000896, 0x01002097, 0x0100086a, 0x01000073, 0x02000099,
11632 0x00000003, 0x0200005f, 0x00017000, 0x04000067, 0x00102012, 0x00000000, 0x00000011, 0x04000067,
11633 0x00102012, 0x00000001, 0x00000012, 0x04000067, 0x00102012, 0x00000002, 0x00000013, 0x02000068,
11634 0x00000001, 0x0400005b, 0x00102012, 0x00000000, 0x00000003, 0x04000036, 0x00100012, 0x00000000,
11635 0x0001700a, 0x06000036, 0x00902012, 0x0010000a, 0x00000000, 0x00004001, 0x3f800000, 0x0100003e,
11636 0x01000073, 0x04000067, 0x00102012, 0x00000003, 0x00000014, 0x05000036, 0x00102012, 0x00000003,
11637 0x00004001, 0x3f800000, 0x0100003e,
11639 static const DWORD simple_ds
[] =
11641 0x43425844, 0xb7e35b82, 0x1b930ff2, 0x48d3a0f2, 0x375219ed, 0x00000001, 0x000001e0, 0x00000004,
11642 0x00000030, 0x00000064, 0x000000f8, 0x0000012c, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008,
11643 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x7469736f,
11644 0x006e6f69, 0x47534350, 0x0000008c, 0x00000004, 0x00000008, 0x00000068, 0x00000000, 0x0000000d,
11645 0x00000003, 0x00000000, 0x00000001, 0x00000068, 0x00000001, 0x0000000d, 0x00000003, 0x00000001,
11646 0x00000001, 0x00000068, 0x00000002, 0x0000000d, 0x00000003, 0x00000002, 0x00000001, 0x00000076,
11647 0x00000000, 0x0000000e, 0x00000003, 0x00000003, 0x00000001, 0x545f5653, 0x46737365, 0x6f746361,
11648 0x56530072, 0x736e495f, 0x54656469, 0x46737365, 0x6f746361, 0xabab0072, 0x4e47534f, 0x0000002c,
11649 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
11650 0x505f5653, 0x7469736f, 0x006e6f69, 0x58454853, 0x000000ac, 0x00040050, 0x0000002b, 0x01001893,
11651 0x01001095, 0x0100086a, 0x0200005f, 0x0001c072, 0x0400005f, 0x002190f2, 0x00000003, 0x00000000,
11652 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x02000068, 0x00000001, 0x07000038, 0x001000f2,
11653 0x00000000, 0x0001c556, 0x00219e46, 0x00000001, 0x00000000, 0x09000032, 0x001000f2, 0x00000000,
11654 0x0001c006, 0x00219e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000, 0x09000032, 0x001020f2,
11655 0x00000000, 0x0001caa6, 0x00219e46, 0x00000002, 0x00000000, 0x00100e46, 0x00000000, 0x0100003e,
11660 float4 pos
: SV_POSITION
;
11663 [maxvertexcount(4)]
11664 void main(point float4 vin
[1] : POSITION
, inout TriangleStream
<gs_out
> vout
)
11666 float offset
= 0.1 * vin
[0].w
;
11669 v
.pos
= float4(vin
[0].x
- offset
, vin
[0].y
- offset
, vin
[0].z
, vin
[0].w
);
11671 v
.pos
= float4(vin
[0].x
- offset
, vin
[0].y
+ offset
, vin
[0].z
, vin
[0].w
);
11673 v
.pos
= float4(vin
[0].x
+ offset
, vin
[0].y
- offset
, vin
[0].z
, vin
[0].w
);
11675 v
.pos
= float4(vin
[0].x
+ offset
, vin
[0].y
+ offset
, vin
[0].z
, vin
[0].w
);
11679 static const DWORD simple_gs
[] =
11681 0x43425844, 0x000ee786, 0xc624c269, 0x885a5cbe, 0x444b3b1f, 0x00000001, 0x0000023c, 0x00000003,
11682 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
11683 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
11684 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
11685 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x000001a0, 0x00020040,
11686 0x00000068, 0x0400005f, 0x002010f2, 0x00000001, 0x00000000, 0x02000068, 0x00000001, 0x0100085d,
11687 0x0100285c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x0200005e, 0x00000004, 0x0f000032,
11688 0x00100032, 0x00000000, 0x80201ff6, 0x00000041, 0x00000000, 0x00000000, 0x00004002, 0x3dcccccd,
11689 0x3dcccccd, 0x00000000, 0x00000000, 0x00201046, 0x00000000, 0x00000000, 0x05000036, 0x00102032,
11690 0x00000000, 0x00100046, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000,
11691 0x00000000, 0x01000013, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0e000032,
11692 0x00100052, 0x00000000, 0x00201ff6, 0x00000000, 0x00000000, 0x00004002, 0x3dcccccd, 0x00000000,
11693 0x3dcccccd, 0x00000000, 0x00201106, 0x00000000, 0x00000000, 0x05000036, 0x00102022, 0x00000000,
11694 0x0010002a, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000, 0x00000000,
11695 0x01000013, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x05000036, 0x00102022,
11696 0x00000000, 0x0010001a, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000,
11697 0x00000000, 0x01000013, 0x05000036, 0x00102032, 0x00000000, 0x00100086, 0x00000000, 0x06000036,
11698 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000, 0x00000000, 0x01000013, 0x0100003e,
11701 float4
main(float4 color
: COLOR
) : SV_TARGET
11706 static const DWORD simple_ps
[] =
11708 0x43425844, 0x08c2b568, 0x17d33120, 0xb7d82948, 0x13a570fb, 0x00000001, 0x000000d0, 0x00000003,
11709 0x0000002c, 0x0000005c, 0x00000090, 0x4e475349, 0x00000028, 0x00000001, 0x00000008, 0x00000020,
11710 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x4f4c4f43, 0xabab0052, 0x4e47534f,
11711 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
11712 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
11713 0x03001062, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x05000036, 0x001020f2,
11714 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
11717 [numthreads(1, 1, 1)]
11720 static const DWORD simple_cs
[] =
11722 0x43425844, 0x1acc3ad0, 0x71c7b057, 0xc72c4306, 0xf432cb57, 0x00000001, 0x00000074, 0x00000003,
11723 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
11724 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000020, 0x00050050, 0x00000008, 0x0100086a,
11725 0x0400009b, 0x00000001, 0x00000001, 0x00000001, 0x0100003e,
11728 D3D11_VIEWPORT tmp_viewport
[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
];
11729 ID3D11ShaderResourceView
*tmp_srv
[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
];
11730 ID3D11ShaderResourceView
*srv
[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
];
11731 ID3D11RenderTargetView
*tmp_rtv
[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
];
11732 RECT tmp_rect
[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
];
11733 ID3D11SamplerState
*tmp_sampler
[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
];
11734 ID3D11RenderTargetView
*rtv
[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
];
11735 ID3D11Texture2D
*rt_texture
[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
];
11736 ID3D11Buffer
*cb
[D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
];
11737 ID3D11Buffer
*tmp_buffer
[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
];
11738 ID3D11SamplerState
*sampler
[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
];
11739 ID3D11UnorderedAccessView
*tmp_uav
[D3D11_PS_CS_UAV_REGISTER_COUNT
];
11740 ID3D11UnorderedAccessView
*cs_uav
[D3D11_PS_CS_UAV_REGISTER_COUNT
];
11741 ID3D11Buffer
*buffer
[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
];
11742 ID3D11Buffer
*cs_uav_buffer
[D3D11_PS_CS_UAV_REGISTER_COUNT
];
11743 UINT offset
[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
];
11744 UINT stride
[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
];
11745 ID3D11Buffer
*so_buffer
[D3D11_SO_BUFFER_SLOT_COUNT
];
11746 ID3D11InputLayout
*tmp_input_layout
, *input_layout
;
11747 ID3D11DepthStencilState
*tmp_ds_state
, *ds_state
;
11748 ID3D11BlendState
*tmp_blend_state
, *blend_state
;
11749 ID3D11RasterizerState
*tmp_rs_state
, *rs_state
;
11750 ID3D11Predicate
*tmp_predicate
, *predicate
;
11751 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
11752 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
11753 ID3D11DepthStencilView
*tmp_dsv
, *dsv
;
11754 ID3D11UnorderedAccessView
*ps_uav
;
11755 D3D11_PRIMITIVE_TOPOLOGY topology
;
11756 D3D11_TEXTURE2D_DESC texture_desc
;
11757 ID3D11GeometryShader
*tmp_gs
, *gs
;
11758 ID3D11ComputeShader
*tmp_cs
, *cs
;
11759 D3D11_DEPTH_STENCIL_DESC ds_desc
;
11760 ID3D11VertexShader
*tmp_vs
, *vs
;
11761 ID3D11DomainShader
*tmp_ds
, *ds
;
11762 D3D11_SAMPLER_DESC sampler_desc
;
11763 D3D11_QUERY_DESC predicate_desc
;
11764 struct device_desc device_desc
;
11765 ID3D11PixelShader
*tmp_ps
, *ps
;
11766 ID3D11HullShader
*tmp_hs
, *hs
;
11767 D3D11_RASTERIZER_DESC rs_desc
;
11768 ID3D11DeviceContext
*context
;
11769 D3D11_BLEND_DESC blend_desc
;
11770 ID3D11Texture2D
*ds_texture
;
11771 ID3D11Buffer
*ps_uav_buffer
;
11772 float blend_factor
[4];
11773 ID3D11Device
*device
;
11774 BOOL predicate_value
;
11775 UINT instance_count
;
11776 DXGI_FORMAT format
;
11783 device_desc
.feature_level
= &feature_level
;
11784 device_desc
.flags
= 0;
11785 if (!(device
= create_device(&device_desc
)))
11787 skip("Failed to create device.\n");
11791 ID3D11Device_GetImmediateContext(device
, &context
);
11793 /* Verify the initial state after device creation. */
11795 ID3D11DeviceContext_VSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
11797 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
11799 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
11801 ID3D11DeviceContext_VSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
11802 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
11804 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
11806 ID3D11DeviceContext_VSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
11807 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
11809 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
11811 instance_count
= 100;
11812 ID3D11DeviceContext_VSGetShader(context
, &tmp_vs
, NULL
, &instance_count
);
11813 ok(!tmp_vs
, "Got unexpected vertex shader %p.\n", tmp_vs
);
11814 ok(!instance_count
, "Got unexpected instance count %u.\n", instance_count
);
11816 ID3D11DeviceContext_HSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
11818 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
11820 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
11822 ID3D11DeviceContext_HSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
11823 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
11825 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
11827 ID3D11DeviceContext_HSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
11828 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
11830 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
11832 instance_count
= 100;
11833 ID3D11DeviceContext_HSGetShader(context
, &tmp_hs
, NULL
, &instance_count
);
11834 ok(!tmp_hs
, "Got unexpected hull shader %p.\n", tmp_hs
);
11835 ok(!instance_count
, "Got unexpected instance count %u.\n", instance_count
);
11837 ID3D11DeviceContext_DSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
11839 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
11841 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
11843 ID3D11DeviceContext_DSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
11844 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
11846 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
11848 ID3D11DeviceContext_DSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
11849 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
11851 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
11853 instance_count
= 100;
11854 ID3D11DeviceContext_DSGetShader(context
, &tmp_ds
, NULL
, &instance_count
);
11855 ok(!tmp_ds
, "Got unexpected domain shader %p.\n", tmp_ds
);
11856 ok(!instance_count
, "Got unexpected instance count %u.\n", instance_count
);
11858 ID3D11DeviceContext_GSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
11860 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
11862 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
11864 ID3D11DeviceContext_GSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
11865 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
11867 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
11869 ID3D11DeviceContext_GSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
11870 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
11872 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
11874 instance_count
= 100;
11875 ID3D11DeviceContext_GSGetShader(context
, &tmp_gs
, NULL
, &instance_count
);
11876 ok(!tmp_gs
, "Got unexpected geometry shader %p.\n", tmp_gs
);
11877 ok(!instance_count
, "Got unexpected instance count %u.\n", instance_count
);
11879 ID3D11DeviceContext_PSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
11881 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
11883 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
11885 ID3D11DeviceContext_PSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
,
11887 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
11889 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
11891 ID3D11DeviceContext_PSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
11892 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
11894 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
11896 instance_count
= 100;
11897 ID3D11DeviceContext_PSGetShader(context
, &tmp_ps
, NULL
, &instance_count
);
11898 ok(!tmp_ps
, "Got unexpected pixel shader %p.\n", tmp_ps
);
11899 ok(!instance_count
, "Got unexpected instance count %u.\n", instance_count
);
11901 ID3D11DeviceContext_CSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
11903 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
11905 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
11907 ID3D11DeviceContext_CSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
,
11909 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
11911 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
11913 ID3D11DeviceContext_CSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
11914 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
11916 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
11918 instance_count
= 100;
11919 ID3D11DeviceContext_CSGetShader(context
, &tmp_cs
, NULL
, &instance_count
);
11920 ok(!tmp_cs
, "Got unexpected compute shader %p.\n", tmp_cs
);
11921 ok(!instance_count
, "Got unexpected instance count %u.\n", instance_count
);
11922 ID3D11DeviceContext_CSGetUnorderedAccessViews(context
, 0, D3D11_PS_CS_UAV_REGISTER_COUNT
, tmp_uav
);
11923 for (i
= 0; i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
11925 ok(!tmp_uav
[i
], "Got unexpected unordered access view %p in slot %u.\n", tmp_uav
[i
], i
);
11928 ID3D11DeviceContext_IAGetVertexBuffers(context
, 0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
,
11929 tmp_buffer
, stride
, offset
);
11930 for (i
= 0; i
< D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
11932 ok(!tmp_buffer
[i
], "Got unexpected vertex buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
11933 ok(!stride
[i
], "Got unexpected stride %u in slot %u.\n", stride
[i
], i
);
11934 ok(!offset
[i
], "Got unexpected offset %u in slot %u.\n", offset
[i
], i
);
11936 ID3D11DeviceContext_IAGetIndexBuffer(context
, tmp_buffer
, &format
, offset
);
11937 ok(!tmp_buffer
[0], "Got unexpected index buffer %p.\n", tmp_buffer
[0]);
11938 ok(format
== DXGI_FORMAT_UNKNOWN
, "Got unexpected index buffer format %#x.\n", format
);
11939 ok(!offset
[0], "Got unexpected index buffer offset %u.\n", offset
[0]);
11940 ID3D11DeviceContext_IAGetInputLayout(context
, &tmp_input_layout
);
11941 ok(!tmp_input_layout
, "Got unexpected input layout %p.\n", tmp_input_layout
);
11942 ID3D11DeviceContext_IAGetPrimitiveTopology(context
, &topology
);
11943 ok(topology
== D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED
, "Got unexpected primitive topology %#x.\n", topology
);
11945 ID3D11DeviceContext_OMGetBlendState(context
, &tmp_blend_state
, blend_factor
, &sample_mask
);
11946 ok(!tmp_blend_state
, "Got unexpected blend state %p.\n", tmp_blend_state
);
11947 ok(blend_factor
[0] == 1.0f
&& blend_factor
[1] == 1.0f
11948 && blend_factor
[2] == 1.0f
&& blend_factor
[3] == 1.0f
,
11949 "Got unexpected blend factor {%.8e, %.8e, %.8e, %.8e}.\n",
11950 blend_factor
[0], blend_factor
[1], blend_factor
[2], blend_factor
[3]);
11951 ok(sample_mask
== D3D11_DEFAULT_SAMPLE_MASK
, "Got unexpected sample mask %#x.\n", sample_mask
);
11952 ID3D11DeviceContext_OMGetDepthStencilState(context
, &tmp_ds_state
, &stencil_ref
);
11953 ok(!tmp_ds_state
, "Got unexpected depth stencil state %p.\n", tmp_ds_state
);
11954 ok(!stencil_ref
, "Got unexpected stencil ref %u.\n", stencil_ref
);
11955 ID3D11DeviceContext_OMGetRenderTargets(context
, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
, tmp_rtv
, &tmp_dsv
);
11956 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
11958 ok(!tmp_rtv
[i
], "Got unexpected render target view %p in slot %u.\n", tmp_rtv
[i
], i
);
11960 ok(!tmp_dsv
, "Got unexpected depth stencil view %p.\n", tmp_dsv
);
11961 ID3D11DeviceContext_OMGetRenderTargetsAndUnorderedAccessViews(context
,
11962 D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
, tmp_rtv
, &tmp_dsv
,
11963 0, D3D11_PS_CS_UAV_REGISTER_COUNT
, tmp_uav
);
11964 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
11966 ok(!tmp_rtv
[i
], "Got unexpected render target view %p in slot %u.\n", tmp_rtv
[i
], i
);
11968 ok(!tmp_dsv
, "Got unexpected depth stencil view %p.\n", tmp_dsv
);
11969 for (i
= 0; i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
11971 ok(!tmp_uav
[i
], "Got unexpected unordered access view %p in slot %u.\n", tmp_uav
[i
], i
);
11974 if (!enable_debug_layer
)
11976 ID3D11DeviceContext_RSGetScissorRects(context
, &count
, NULL
);
11977 ok(!count
, "Got unexpected scissor rect count %u.\n", count
);
11979 memset(tmp_rect
, 0x55, sizeof(tmp_rect
));
11980 count
= D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
;
11981 ID3D11DeviceContext_RSGetScissorRects(context
, &count
, tmp_rect
);
11982 for (i
= 0; i
< D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
; ++i
)
11984 ok(!tmp_rect
[i
].left
&& !tmp_rect
[i
].top
&& !tmp_rect
[i
].right
&& !tmp_rect
[i
].bottom
,
11985 "Got unexpected scissor rect %s in slot %u.\n", wine_dbgstr_rect(&tmp_rect
[i
]), i
);
11987 ID3D11DeviceContext_RSGetViewports(context
, &count
, NULL
);
11988 ok(!count
, "Got unexpected viewport count %u.\n", count
);
11989 memset(tmp_viewport
, 0x55, sizeof(tmp_viewport
));
11990 count
= D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
;
11991 ID3D11DeviceContext_RSGetViewports(context
, &count
, tmp_viewport
);
11992 for (i
= 0; i
< D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
; ++i
)
11994 ok(!tmp_viewport
[i
].TopLeftX
&& !tmp_viewport
[i
].TopLeftY
&& !tmp_viewport
[i
].Width
11995 && !tmp_viewport
[i
].Height
&& !tmp_viewport
[i
].MinDepth
&& !tmp_viewport
[i
].MaxDepth
,
11996 "Got unexpected viewport {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e} in slot %u.\n",
11997 tmp_viewport
[i
].TopLeftX
, tmp_viewport
[i
].TopLeftY
, tmp_viewport
[i
].Width
,
11998 tmp_viewport
[i
].Height
, tmp_viewport
[i
].MinDepth
, tmp_viewport
[i
].MaxDepth
, i
);
12000 ID3D11DeviceContext_RSGetState(context
, &tmp_rs_state
);
12001 ok(!tmp_rs_state
, "Got unexpected rasterizer state %p.\n", tmp_rs_state
);
12003 ID3D11DeviceContext_SOGetTargets(context
, D3D11_SO_BUFFER_SLOT_COUNT
, tmp_buffer
);
12004 for (i
= 0; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
12006 ok(!tmp_buffer
[i
], "Got unexpected stream output %p in slot %u.\n", tmp_buffer
[i
], i
);
12009 ID3D11DeviceContext_GetPredication(context
, &tmp_predicate
, &predicate_value
);
12010 ok(!tmp_predicate
, "Got unexpected predicate %p.\n", tmp_predicate
);
12011 ok(!predicate_value
, "Got unexpected predicate value %#x.\n", predicate_value
);
12013 /* Create resources. */
12015 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
12016 cb
[i
] = create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, 1024, NULL
);
12018 for (i
= 0; i
< D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
12020 buffer
[i
] = create_buffer(device
,
12021 D3D11_BIND_VERTEX_BUFFER
| D3D11_BIND_INDEX_BUFFER
| D3D11_BIND_SHADER_RESOURCE
,
12024 stride
[i
] = (i
+ 1) * 4;
12025 offset
[i
] = (i
+ 1) * 16;
12028 for (i
= 0; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
12029 so_buffer
[i
] = create_buffer(device
, D3D11_BIND_STREAM_OUTPUT
, 1024, NULL
);
12031 srv_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
12032 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_BUFFER
;
12033 U(srv_desc
).Buffer
.ElementOffset
= 0;
12034 U(srv_desc
).Buffer
.ElementWidth
= 64;
12036 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
12038 hr
= ID3D11Device_CreateShaderResourceView(device
,
12039 (ID3D11Resource
*)buffer
[i
% D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
], &srv_desc
, &srv
[i
]);
12040 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
12043 uav_desc
.Format
= DXGI_FORMAT_R32_UINT
;
12044 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
12045 U(uav_desc
).Buffer
.FirstElement
= 0;
12046 U(uav_desc
).Buffer
.NumElements
= 8;
12047 U(uav_desc
).Buffer
.Flags
= 0;
12049 for (i
= 0; i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
12051 cs_uav_buffer
[i
] = create_buffer(device
, D3D11_BIND_UNORDERED_ACCESS
, 32, NULL
);
12052 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)cs_uav_buffer
[i
],
12053 &uav_desc
, &cs_uav
[i
]);
12054 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
12057 ps_uav_buffer
= create_buffer(device
, D3D11_BIND_UNORDERED_ACCESS
, 32, NULL
);
12058 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)ps_uav_buffer
,
12059 &uav_desc
, &ps_uav
);
12060 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
12062 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_LINEAR
;
12063 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
12064 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
12065 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
12066 sampler_desc
.MipLODBias
= 0.0f
;
12067 sampler_desc
.MaxAnisotropy
= 16;
12068 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
12069 sampler_desc
.BorderColor
[0] = 0.0f
;
12070 sampler_desc
.BorderColor
[1] = 0.0f
;
12071 sampler_desc
.BorderColor
[2] = 0.0f
;
12072 sampler_desc
.BorderColor
[3] = 0.0f
;
12073 sampler_desc
.MinLOD
= 0.0f
;
12074 sampler_desc
.MaxLOD
= 16.0f
;
12076 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
12078 sampler_desc
.MinLOD
= (float)i
;
12080 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler
[i
]);
12081 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
12084 hr
= ID3D11Device_CreateVertexShader(device
, simple_vs
, sizeof(simple_vs
), NULL
, &vs
);
12085 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
12087 hr
= ID3D11Device_CreateHullShader(device
, simple_hs
, sizeof(simple_hs
), NULL
, &hs
);
12088 ok(SUCCEEDED(hr
), "Failed to create hull shader, hr %#x.\n", hr
);
12090 hr
= ID3D11Device_CreateDomainShader(device
, simple_ds
, sizeof(simple_ds
), NULL
, &ds
);
12091 ok(SUCCEEDED(hr
), "Failed to create domain shader, hr %#x.\n", hr
);
12093 hr
= ID3D11Device_CreateGeometryShader(device
, simple_gs
, sizeof(simple_gs
), NULL
, &gs
);
12094 ok(SUCCEEDED(hr
), "Failed to create geometry shader, hr %#x.\n", hr
);
12096 hr
= ID3D11Device_CreatePixelShader(device
, simple_ps
, sizeof(simple_ps
), NULL
, &ps
);
12097 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
12099 hr
= ID3D11Device_CreateComputeShader(device
, simple_cs
, sizeof(simple_cs
), NULL
, &cs
);
12100 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
12102 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
12103 simple_vs
, sizeof(simple_vs
), &input_layout
);
12104 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
12106 memset(&blend_desc
, 0, sizeof(blend_desc
));
12107 blend_desc
.AlphaToCoverageEnable
= FALSE
;
12108 blend_desc
.IndependentBlendEnable
= FALSE
;
12109 blend_desc
.RenderTarget
[0].BlendEnable
= TRUE
;
12110 blend_desc
.RenderTarget
[0].SrcBlend
= D3D11_BLEND_ONE
;
12111 blend_desc
.RenderTarget
[0].DestBlend
= D3D11_BLEND_ZERO
;
12112 blend_desc
.RenderTarget
[0].BlendOp
= D3D11_BLEND_OP_ADD
;
12113 blend_desc
.RenderTarget
[0].SrcBlendAlpha
= D3D11_BLEND_ONE
;
12114 blend_desc
.RenderTarget
[0].DestBlendAlpha
= D3D11_BLEND_ZERO
;
12115 blend_desc
.RenderTarget
[0].BlendOpAlpha
= D3D11_BLEND_OP_ADD
;
12116 blend_desc
.RenderTarget
[0].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_ALL
;
12118 hr
= ID3D11Device_CreateBlendState(device
, &blend_desc
, &blend_state
);
12119 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
12121 ds_desc
.DepthEnable
= TRUE
;
12122 ds_desc
.DepthWriteMask
= D3D11_DEPTH_WRITE_MASK_ALL
;
12123 ds_desc
.DepthFunc
= D3D11_COMPARISON_LESS
;
12124 ds_desc
.StencilEnable
= FALSE
;
12125 ds_desc
.StencilReadMask
= D3D11_DEFAULT_STENCIL_READ_MASK
;
12126 ds_desc
.StencilWriteMask
= D3D11_DEFAULT_STENCIL_WRITE_MASK
;
12127 ds_desc
.FrontFace
.StencilFailOp
= D3D11_STENCIL_OP_KEEP
;
12128 ds_desc
.FrontFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_KEEP
;
12129 ds_desc
.FrontFace
.StencilPassOp
= D3D11_STENCIL_OP_KEEP
;
12130 ds_desc
.FrontFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
12131 ds_desc
.BackFace
.StencilFailOp
= D3D11_STENCIL_OP_KEEP
;
12132 ds_desc
.BackFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_KEEP
;
12133 ds_desc
.BackFace
.StencilPassOp
= D3D11_STENCIL_OP_KEEP
;
12134 ds_desc
.BackFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
12136 hr
= ID3D11Device_CreateDepthStencilState(device
, &ds_desc
, &ds_state
);
12137 ok(SUCCEEDED(hr
), "Failed to create depthstencil state, hr %#x.\n", hr
);
12139 texture_desc
.Width
= 512;
12140 texture_desc
.Height
= 512;
12141 texture_desc
.MipLevels
= 1;
12142 texture_desc
.ArraySize
= 1;
12143 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
12144 texture_desc
.SampleDesc
.Count
= 1;
12145 texture_desc
.SampleDesc
.Quality
= 0;
12146 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
12147 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
12148 texture_desc
.CPUAccessFlags
= 0;
12149 texture_desc
.MiscFlags
= 0;
12151 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
12153 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rt_texture
[i
]);
12154 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
12157 texture_desc
.Format
= DXGI_FORMAT_D24_UNORM_S8_UINT
;
12158 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
12160 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &ds_texture
);
12161 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
12163 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
12165 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rt_texture
[i
], NULL
, &rtv
[i
]);
12166 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
12169 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)ds_texture
, NULL
, &dsv
);
12170 ok(SUCCEEDED(hr
), "Failed to create depthstencil view, hr %#x.\n", hr
);
12172 for (i
= 0; i
< D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
; ++i
)
12174 SetRect(&tmp_rect
[i
], i
, i
* 2, i
+ 1, (i
+ 1) * 2);
12176 tmp_viewport
[i
].TopLeftX
= i
* 3;
12177 tmp_viewport
[i
].TopLeftY
= i
* 4;
12178 tmp_viewport
[i
].Width
= 3;
12179 tmp_viewport
[i
].Height
= 4;
12180 tmp_viewport
[i
].MinDepth
= i
* 0.01f
;
12181 tmp_viewport
[i
].MaxDepth
= (i
+ 1) * 0.01f
;
12184 rs_desc
.FillMode
= D3D11_FILL_SOLID
;
12185 rs_desc
.CullMode
= D3D11_CULL_BACK
;
12186 rs_desc
.FrontCounterClockwise
= FALSE
;
12187 rs_desc
.DepthBias
= 0;
12188 rs_desc
.DepthBiasClamp
= 0.0f
;
12189 rs_desc
.SlopeScaledDepthBias
= 0.0f
;
12190 rs_desc
.DepthClipEnable
= TRUE
;
12191 rs_desc
.ScissorEnable
= FALSE
;
12192 rs_desc
.MultisampleEnable
= FALSE
;
12193 rs_desc
.AntialiasedLineEnable
= FALSE
;
12195 hr
= ID3D11Device_CreateRasterizerState(device
, &rs_desc
, &rs_state
);
12196 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
12198 predicate_desc
.Query
= D3D11_QUERY_OCCLUSION_PREDICATE
;
12199 predicate_desc
.MiscFlags
= 0;
12201 hr
= ID3D11Device_CreatePredicate(device
, &predicate_desc
, &predicate
);
12202 ok(SUCCEEDED(hr
), "Failed to create predicate, hr %#x.\n", hr
);
12206 /* Some versions of Windows AMD drivers hang while the device is being
12207 * released, if the total number of used resource slots exceeds some limit.
12208 * Do not use all constant buffers slots in order to not trigger this
12210 ID3D11DeviceContext_VSSetConstantBuffers(context
, 0, 1, &cb
[0]);
12211 ID3D11DeviceContext_VSSetConstantBuffers(context
, 7, 1, &cb
[7]);
12212 ID3D11DeviceContext_VSSetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, srv
);
12213 ID3D11DeviceContext_VSSetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, sampler
);
12214 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
12216 ID3D11DeviceContext_HSSetConstantBuffers(context
, 0, 1, &cb
[0]);
12217 ID3D11DeviceContext_HSSetConstantBuffers(context
, 7, 1, &cb
[7]);
12218 ID3D11DeviceContext_HSSetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, srv
);
12219 ID3D11DeviceContext_HSSetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, sampler
);
12220 ID3D11DeviceContext_HSSetShader(context
, hs
, NULL
, 0);
12222 ID3D11DeviceContext_DSSetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, cb
);
12223 ID3D11DeviceContext_DSSetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, srv
);
12224 ID3D11DeviceContext_DSSetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, sampler
);
12225 ID3D11DeviceContext_DSSetShader(context
, ds
, NULL
, 0);
12227 ID3D11DeviceContext_GSSetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, cb
);
12228 ID3D11DeviceContext_GSSetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, srv
);
12229 ID3D11DeviceContext_GSSetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, sampler
);
12230 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
12232 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, cb
);
12233 ID3D11DeviceContext_PSSetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, srv
);
12234 ID3D11DeviceContext_PSSetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, sampler
);
12235 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
12237 ID3D11DeviceContext_CSSetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, cb
);
12238 ID3D11DeviceContext_CSSetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, srv
);
12239 ID3D11DeviceContext_CSSetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, sampler
);
12240 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
12241 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, D3D11_PS_CS_UAV_REGISTER_COUNT
, cs_uav
, NULL
);
12243 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
,
12244 buffer
, stride
, offset
);
12245 ID3D11DeviceContext_IASetIndexBuffer(context
, buffer
[0], DXGI_FORMAT_R32_UINT
, offset
[0]);
12246 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
12247 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
12249 blend_factor
[0] = 0.1f
;
12250 blend_factor
[1] = 0.2f
;
12251 blend_factor
[2] = 0.3f
;
12252 blend_factor
[3] = 0.4f
;
12253 ID3D11DeviceContext_OMSetBlendState(context
, blend_state
, blend_factor
, 0xff00ff00);
12254 ID3D11DeviceContext_OMSetDepthStencilState(context
, ds_state
, 3);
12255 ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context
,
12256 D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
- 1, rtv
, dsv
,
12257 D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
- 1, 1, &ps_uav
, NULL
);
12259 ID3D11DeviceContext_RSSetScissorRects(context
, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
,
12261 ID3D11DeviceContext_RSSetViewports(context
, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
,
12263 ID3D11DeviceContext_RSSetState(context
, rs_state
);
12265 ID3D11DeviceContext_SOSetTargets(context
, D3D11_SO_BUFFER_SLOT_COUNT
, so_buffer
, offset
);
12267 ID3D11DeviceContext_SetPredication(context
, predicate
, TRUE
);
12269 /* Verify the set state. */
12271 ID3D11DeviceContext_VSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
12273 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
12275 ID3D11Buffer
*expected_cb
= i
% 7 ? NULL
: cb
[i
];
12276 ok(tmp_buffer
[i
] == expected_cb
, "Got unexpected constant buffer %p in slot %u, expected %p.\n",
12277 tmp_buffer
[i
], i
, expected_cb
);
12279 ID3D11Buffer_Release(tmp_buffer
[i
]);
12281 ID3D11DeviceContext_VSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
12282 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
12284 ok(tmp_srv
[i
] == srv
[i
], "Got unexpected shader resource view %p in slot %u, expected %p.\n",
12285 tmp_srv
[i
], i
, srv
[i
]);
12286 ID3D11ShaderResourceView_Release(tmp_srv
[i
]);
12288 ID3D11DeviceContext_VSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
12289 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
12291 ok(tmp_sampler
[i
] == sampler
[i
], "Got unexpected sampler %p in slot %u, expected %p.\n",
12292 tmp_sampler
[i
], i
, sampler
[i
]);
12293 ID3D11SamplerState_Release(tmp_sampler
[i
]);
12295 ID3D11DeviceContext_VSGetShader(context
, &tmp_vs
, NULL
, 0);
12296 ok(tmp_vs
== vs
, "Got unexpected vertex shader %p, expected %p.\n", tmp_vs
, vs
);
12297 ID3D11VertexShader_Release(tmp_vs
);
12299 ID3D11DeviceContext_HSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
12301 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
12303 ID3D11Buffer
*expected_cb
= i
% 7 ? NULL
: cb
[i
];
12304 ok(tmp_buffer
[i
] == expected_cb
, "Got unexpected constant buffer %p in slot %u, expected %p.\n",
12305 tmp_buffer
[i
], i
, expected_cb
);
12307 ID3D11Buffer_Release(tmp_buffer
[i
]);
12309 ID3D11DeviceContext_HSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
12310 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
12312 ok(tmp_srv
[i
] == srv
[i
], "Got unexpected shader resource view %p in slot %u, expected %p.\n",
12313 tmp_srv
[i
], i
, srv
[i
]);
12314 ID3D11ShaderResourceView_Release(tmp_srv
[i
]);
12316 ID3D11DeviceContext_HSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
12317 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
12319 ok(tmp_sampler
[i
] == sampler
[i
], "Got unexpected sampler %p in slot %u, expected %p.\n",
12320 tmp_sampler
[i
], i
, sampler
[i
]);
12321 ID3D11SamplerState_Release(tmp_sampler
[i
]);
12323 ID3D11DeviceContext_HSGetShader(context
, &tmp_hs
, NULL
, 0);
12324 ok(tmp_hs
== hs
, "Got unexpected hull shader %p, expected %p.\n", tmp_hs
, hs
);
12325 ID3D11HullShader_Release(tmp_hs
);
12327 ID3D11DeviceContext_DSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
12329 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
12331 ok(tmp_buffer
[i
] == cb
[i
], "Got unexpected constant buffer %p in slot %u, expected %p.\n",
12332 tmp_buffer
[i
], i
, cb
[i
]);
12333 ID3D11Buffer_Release(tmp_buffer
[i
]);
12335 ID3D11DeviceContext_DSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
12336 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
12338 ok(tmp_srv
[i
] == srv
[i
], "Got unexpected shader resource view %p in slot %u, expected %p.\n",
12339 tmp_srv
[i
], i
, srv
[i
]);
12340 ID3D11ShaderResourceView_Release(tmp_srv
[i
]);
12342 ID3D11DeviceContext_DSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
12343 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
12345 ok(tmp_sampler
[i
] == sampler
[i
], "Got unexpected sampler %p in slot %u, expected %p.\n",
12346 tmp_sampler
[i
], i
, sampler
[i
]);
12347 ID3D11SamplerState_Release(tmp_sampler
[i
]);
12349 ID3D11DeviceContext_DSGetShader(context
, &tmp_ds
, NULL
, 0);
12350 ok(tmp_ds
== ds
, "Got unexpected domain shader %p, expected %p.\n", tmp_ds
, ds
);
12351 ID3D11DomainShader_Release(tmp_ds
);
12353 ID3D11DeviceContext_GSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
12355 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
12357 ok(tmp_buffer
[i
] == cb
[i
], "Got unexpected constant buffer %p in slot %u, expected %p.\n",
12358 tmp_buffer
[i
], i
, cb
[i
]);
12359 ID3D11Buffer_Release(tmp_buffer
[i
]);
12361 ID3D11DeviceContext_GSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
12362 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
12364 ok(tmp_srv
[i
] == srv
[i
], "Got unexpected shader resource view %p in slot %u, expected %p.\n",
12365 tmp_srv
[i
], i
, srv
[i
]);
12366 ID3D11ShaderResourceView_Release(tmp_srv
[i
]);
12368 ID3D11DeviceContext_GSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
12369 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
12371 ok(tmp_sampler
[i
] == sampler
[i
], "Got unexpected sampler %p in slot %u, expected %p.\n",
12372 tmp_sampler
[i
], i
, sampler
[i
]);
12373 ID3D11SamplerState_Release(tmp_sampler
[i
]);
12375 ID3D11DeviceContext_GSGetShader(context
, &tmp_gs
, NULL
, 0);
12376 ok(tmp_gs
== gs
, "Got unexpected geometry shader %p, expected %p.\n", tmp_gs
, gs
);
12377 ID3D11GeometryShader_Release(tmp_gs
);
12379 ID3D11DeviceContext_PSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
12381 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
12383 ok(tmp_buffer
[i
] == cb
[i
], "Got unexpected constant buffer %p in slot %u, expected %p.\n",
12384 tmp_buffer
[i
], i
, cb
[i
]);
12385 ID3D11Buffer_Release(tmp_buffer
[i
]);
12387 ID3D11DeviceContext_PSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
12388 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
12390 ok(tmp_srv
[i
] == srv
[i
], "Got unexpected shader resource view %p in slot %u, expected %p.\n",
12391 tmp_srv
[i
], i
, srv
[i
]);
12392 ID3D11ShaderResourceView_Release(tmp_srv
[i
]);
12394 ID3D11DeviceContext_PSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
12395 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
12397 ok(tmp_sampler
[i
] == sampler
[i
], "Got unexpected sampler %p in slot %u, expected %p.\n",
12398 tmp_sampler
[i
], i
, sampler
[i
]);
12399 ID3D11SamplerState_Release(tmp_sampler
[i
]);
12401 ID3D11DeviceContext_PSGetShader(context
, &tmp_ps
, NULL
, 0);
12402 ok(tmp_ps
== ps
, "Got unexpected pixel shader %p, expected %p.\n", tmp_ps
, ps
);
12403 ID3D11PixelShader_Release(tmp_ps
);
12405 ID3D11DeviceContext_CSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
12407 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
12409 ok(tmp_buffer
[i
] == cb
[i
], "Got unexpected constant buffer %p in slot %u, expected %p.\n",
12410 tmp_buffer
[i
], i
, cb
[i
]);
12411 ID3D11Buffer_Release(tmp_buffer
[i
]);
12413 ID3D11DeviceContext_CSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
12414 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
12416 ok(tmp_srv
[i
] == srv
[i
], "Got unexpected shader resource view %p in slot %u, expected %p.\n",
12417 tmp_srv
[i
], i
, srv
[i
]);
12418 ID3D11ShaderResourceView_Release(tmp_srv
[i
]);
12420 ID3D11DeviceContext_CSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
12421 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
12423 ok(tmp_sampler
[i
] == sampler
[i
], "Got unexpected sampler %p in slot %u, expected %p.\n",
12424 tmp_sampler
[i
], i
, sampler
[i
]);
12425 ID3D11SamplerState_Release(tmp_sampler
[i
]);
12427 ID3D11DeviceContext_CSGetShader(context
, &tmp_cs
, NULL
, 0);
12428 ok(tmp_cs
== cs
, "Got unexpected compute shader %p, expected %p.\n", tmp_cs
, cs
);
12429 ID3D11ComputeShader_Release(tmp_cs
);
12430 ID3D11DeviceContext_CSGetUnorderedAccessViews(context
, 0, D3D11_PS_CS_UAV_REGISTER_COUNT
, tmp_uav
);
12431 for (i
= 0; i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
12433 ok(tmp_uav
[i
] == cs_uav
[i
], "Got unexpected unordered access view %p in slot %u, expected %p.\n",
12434 tmp_uav
[i
], i
, cs_uav
[i
]);
12435 ID3D11UnorderedAccessView_Release(tmp_uav
[i
]);
12438 ID3D11DeviceContext_IAGetVertexBuffers(context
, 0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
,
12439 tmp_buffer
, stride
, offset
);
12440 for (i
= 0; i
< D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
12442 todo_wine_if(i
>= D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
)
12444 ok(tmp_buffer
[i
] == buffer
[i
], "Got unexpected vertex buffer %p in slot %u, expected %p.\n",
12445 tmp_buffer
[i
], i
, buffer
[i
]);
12446 ok(stride
[i
] == (i
+ 1) * 4, "Got unexpected stride %u in slot %u.\n", stride
[i
], i
);
12447 ok(offset
[i
] == (i
+ 1) * 16, "Got unexpected offset %u in slot %u.\n", offset
[i
], i
);
12450 ID3D11Buffer_Release(tmp_buffer
[i
]);
12452 ID3D11DeviceContext_IAGetIndexBuffer(context
, tmp_buffer
, &format
, offset
);
12453 ok(tmp_buffer
[0] == buffer
[0], "Got unexpected index buffer %p, expected %p.\n", tmp_buffer
[0], buffer
[0]);
12454 ID3D11Buffer_Release(tmp_buffer
[0]);
12455 ok(format
== DXGI_FORMAT_R32_UINT
, "Got unexpected index buffer format %#x.\n", format
);
12456 ok(offset
[0] == 16, "Got unexpected index buffer offset %u.\n", offset
[0]);
12457 ID3D11DeviceContext_IAGetInputLayout(context
, &tmp_input_layout
);
12458 ok(tmp_input_layout
== input_layout
, "Got unexpected input layout %p, expected %p.\n",
12459 tmp_input_layout
, input_layout
);
12460 ID3D11InputLayout_Release(tmp_input_layout
);
12461 ID3D11DeviceContext_IAGetPrimitiveTopology(context
, &topology
);
12462 ok(topology
== D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
, "Got unexpected primitive topology %#x.\n", topology
);
12464 ID3D11DeviceContext_OMGetBlendState(context
, &tmp_blend_state
, blend_factor
, &sample_mask
);
12465 ok(tmp_blend_state
== blend_state
, "Got unexpected blend state %p, expected %p.\n", tmp_blend_state
, blend_state
);
12466 ID3D11BlendState_Release(tmp_blend_state
);
12467 ok(blend_factor
[0] == 0.1f
&& blend_factor
[1] == 0.2f
12468 && blend_factor
[2] == 0.3f
&& blend_factor
[3] == 0.4f
,
12469 "Got unexpected blend factor {%.8e, %.8e, %.8e, %.8e}.\n",
12470 blend_factor
[0], blend_factor
[1], blend_factor
[2], blend_factor
[3]);
12471 ok(sample_mask
== 0xff00ff00, "Got unexpected sample mask %#x.\n", sample_mask
);
12472 ID3D11DeviceContext_OMGetDepthStencilState(context
, &tmp_ds_state
, &stencil_ref
);
12473 ok(tmp_ds_state
== ds_state
, "Got unexpected depth stencil state %p, expected %p.\n", tmp_ds_state
, ds_state
);
12474 ID3D11DepthStencilState_Release(tmp_ds_state
);
12475 ok(stencil_ref
== 3, "Got unexpected stencil ref %u.\n", stencil_ref
);
12476 ID3D11DeviceContext_OMGetRenderTargets(context
, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
, tmp_rtv
, &tmp_dsv
);
12477 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
- 1; ++i
)
12479 ok(tmp_rtv
[i
] == rtv
[i
], "Got unexpected render target view %p in slot %u, expected %p.\n",
12480 tmp_rtv
[i
], i
, rtv
[i
]);
12481 ID3D11RenderTargetView_Release(tmp_rtv
[i
]);
12483 ok(!tmp_rtv
[i
], "Got unexpected render target view %p in slot %u.\n", tmp_rtv
[i
], i
);
12484 ok(tmp_dsv
== dsv
, "Got unexpected depth stencil view %p, expected %p.\n", tmp_dsv
, dsv
);
12485 ID3D11DepthStencilView_Release(tmp_dsv
);
12486 ID3D11DeviceContext_OMGetRenderTargetsAndUnorderedAccessViews(context
,
12487 D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
, tmp_rtv
, &tmp_dsv
,
12488 0, D3D11_PS_CS_UAV_REGISTER_COUNT
, tmp_uav
);
12489 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
- 1; ++i
)
12491 ok(tmp_rtv
[i
] == rtv
[i
], "Got unexpected render target view %p in slot %u, expected %p.\n",
12492 tmp_rtv
[i
], i
, rtv
[i
]);
12493 ID3D11RenderTargetView_Release(tmp_rtv
[i
]);
12495 ok(!tmp_rtv
[i
], "Got unexpected render target view %p in slot %u.\n", tmp_rtv
[i
], i
);
12496 ok(tmp_dsv
== dsv
, "Got unexpected depth stencil view %p, expected %p.\n", tmp_dsv
, dsv
);
12497 ID3D11DepthStencilView_Release(tmp_dsv
);
12498 for (i
= 0; i
< D3D11_PS_CS_UAV_REGISTER_COUNT
- 1; ++i
)
12500 ok(!tmp_uav
[i
], "Got unexpected unordered access view %p in slot %u.\n", tmp_uav
[i
], i
);
12502 ok(tmp_uav
[i
] == ps_uav
, "Got unexpected unordered access view %p in slot %u, expected %p.\n",
12503 tmp_uav
[i
], i
, ps_uav
);
12504 ID3D11UnorderedAccessView_Release(tmp_uav
[i
]);
12506 ID3D11DeviceContext_RSGetScissorRects(context
, &count
, NULL
);
12507 ok(count
== D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
,
12508 "Got unexpected scissor rect count %u.\n", count
);
12509 memset(tmp_rect
, 0x55, sizeof(tmp_rect
));
12510 ID3D11DeviceContext_RSGetScissorRects(context
, &count
, tmp_rect
);
12511 for (i
= 0; i
< count
; ++i
)
12513 ok(tmp_rect
[i
].left
== i
12514 && tmp_rect
[i
].top
== i
* 2
12515 && tmp_rect
[i
].right
== i
+ 1
12516 && tmp_rect
[i
].bottom
== (i
+ 1) * 2,
12517 "Got unexpected scissor rect %s in slot %u.\n", wine_dbgstr_rect(&tmp_rect
[i
]), i
);
12519 ID3D11DeviceContext_RSGetViewports(context
, &count
, NULL
);
12520 ok(count
== D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
,
12521 "Got unexpected viewport count %u.\n", count
);
12522 memset(tmp_viewport
, 0x55, sizeof(tmp_viewport
));
12523 ID3D11DeviceContext_RSGetViewports(context
, &count
, tmp_viewport
);
12524 for (i
= 0; i
< count
; ++i
)
12526 ok(tmp_viewport
[i
].TopLeftX
== i
* 3
12527 && tmp_viewport
[i
].TopLeftY
== i
* 4
12528 && tmp_viewport
[i
].Width
== 3
12529 && tmp_viewport
[i
].Height
== 4
12530 && compare_float(tmp_viewport
[i
].MinDepth
, i
* 0.01f
, 16)
12531 && compare_float(tmp_viewport
[i
].MaxDepth
, (i
+ 1) * 0.01f
, 16),
12532 "Got unexpected viewport {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e} in slot %u.\n",
12533 tmp_viewport
[i
].TopLeftX
, tmp_viewport
[i
].TopLeftY
, tmp_viewport
[i
].Width
,
12534 tmp_viewport
[i
].Height
, tmp_viewport
[i
].MinDepth
, tmp_viewport
[i
].MaxDepth
, i
);
12536 ID3D11DeviceContext_RSGetState(context
, &tmp_rs_state
);
12537 ok(tmp_rs_state
== rs_state
, "Got unexpected rasterizer state %p, expected %p.\n", tmp_rs_state
, rs_state
);
12538 ID3D11RasterizerState_Release(tmp_rs_state
);
12540 ID3D11DeviceContext_SOGetTargets(context
, D3D11_SO_BUFFER_SLOT_COUNT
, tmp_buffer
);
12541 for (i
= 0; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
12543 ok(tmp_buffer
[i
] == so_buffer
[i
], "Got unexpected stream output %p in slot %u, expected %p.\n",
12544 tmp_buffer
[i
], i
, so_buffer
[i
]);
12545 ID3D11Buffer_Release(tmp_buffer
[i
]);
12548 ID3D11DeviceContext_GetPredication(context
, &tmp_predicate
, &predicate_value
);
12549 ok(tmp_predicate
== predicate
, "Got unexpected predicate %p, expected %p.\n", tmp_predicate
, predicate
);
12550 ID3D11Predicate_Release(tmp_predicate
);
12551 ok(predicate_value
, "Got unexpected predicate value %#x.\n", predicate_value
);
12553 /* Verify ClearState(). */
12555 ID3D11DeviceContext_ClearState(context
);
12557 ID3D11DeviceContext_VSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
12559 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
12561 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
12563 ID3D11DeviceContext_VSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
12564 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
12566 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
12568 ID3D11DeviceContext_VSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
12569 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
12571 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
12573 ID3D11DeviceContext_VSGetShader(context
, &tmp_vs
, NULL
, 0);
12574 ok(!tmp_vs
, "Got unexpected vertex shader %p.\n", tmp_vs
);
12576 ID3D11DeviceContext_HSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
12578 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
12580 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
12582 ID3D11DeviceContext_HSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
12583 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
12585 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
12587 ID3D11DeviceContext_HSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
12588 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
12590 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
12592 ID3D11DeviceContext_HSGetShader(context
, &tmp_hs
, NULL
, 0);
12593 ok(!tmp_hs
, "Got unexpected hull shader %p.\n", tmp_hs
);
12595 ID3D11DeviceContext_DSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
12597 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
12599 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
12601 ID3D11DeviceContext_DSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
12602 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
12604 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
12606 ID3D11DeviceContext_DSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
12607 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
12609 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
12611 ID3D11DeviceContext_DSGetShader(context
, &tmp_ds
, NULL
, 0);
12612 ok(!tmp_ds
, "Got unexpected domain shader %p.\n", tmp_ds
);
12614 ID3D11DeviceContext_GSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
12616 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
12618 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
12620 ID3D11DeviceContext_GSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
12621 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
12623 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
12625 ID3D11DeviceContext_GSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
12626 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
12628 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
12630 ID3D11DeviceContext_GSGetShader(context
, &tmp_gs
, NULL
, 0);
12631 ok(!tmp_gs
, "Got unexpected geometry shader %p.\n", tmp_gs
);
12633 ID3D11DeviceContext_PSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
12635 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
12637 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
12639 ID3D11DeviceContext_PSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
12640 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
12642 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
12644 ID3D11DeviceContext_PSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
12645 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
12647 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
12649 ID3D11DeviceContext_PSGetShader(context
, &tmp_ps
, NULL
, 0);
12650 ok(!tmp_ps
, "Got unexpected pixel shader %p.\n", tmp_ps
);
12652 ID3D11DeviceContext_CSGetConstantBuffers(context
, 0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
,
12654 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
12656 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
12658 ID3D11DeviceContext_CSGetShaderResources(context
, 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
,
12660 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
12662 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
12664 ID3D11DeviceContext_CSGetSamplers(context
, 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
12665 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
12667 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
12669 ID3D11DeviceContext_CSGetShader(context
, &tmp_cs
, NULL
, 0);
12670 ok(!tmp_cs
, "Got unexpected compute shader %p.\n", tmp_cs
);
12671 ID3D11DeviceContext_CSGetUnorderedAccessViews(context
, 0, D3D11_PS_CS_UAV_REGISTER_COUNT
, tmp_uav
);
12672 for (i
= 0; i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
12674 ok(!tmp_uav
[i
], "Got unexpected unordered access view %p in slot %u.\n", tmp_uav
[i
], i
);
12677 ID3D11DeviceContext_IAGetVertexBuffers(context
, 0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
,
12678 tmp_buffer
, stride
, offset
);
12679 for (i
= 0; i
< D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
12681 ok(!tmp_buffer
[i
], "Got unexpected vertex buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
12682 ok(!stride
[i
], "Got unexpected stride %u in slot %u.\n", stride
[i
], i
);
12683 ok(!offset
[i
], "Got unexpected offset %u in slot %u.\n", offset
[i
], i
);
12685 ID3D11DeviceContext_IAGetIndexBuffer(context
, tmp_buffer
, &format
, offset
);
12686 ok(!tmp_buffer
[0], "Got unexpected index buffer %p.\n", tmp_buffer
[0]);
12687 ok(format
== DXGI_FORMAT_UNKNOWN
, "Got unexpected index buffer format %#x.\n", format
);
12688 ok(!offset
[0], "Got unexpected index buffer offset %u.\n", offset
[0]);
12689 ID3D11DeviceContext_IAGetInputLayout(context
, &tmp_input_layout
);
12690 ok(!tmp_input_layout
, "Got unexpected input layout %p.\n", tmp_input_layout
);
12691 ID3D11DeviceContext_IAGetPrimitiveTopology(context
, &topology
);
12692 ok(topology
== D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED
, "Got unexpected primitive topology %#x.\n", topology
);
12694 ID3D11DeviceContext_OMGetBlendState(context
, &tmp_blend_state
, blend_factor
, &sample_mask
);
12695 ok(!tmp_blend_state
, "Got unexpected blend state %p.\n", tmp_blend_state
);
12696 ok(blend_factor
[0] == 1.0f
&& blend_factor
[1] == 1.0f
12697 && blend_factor
[2] == 1.0f
&& blend_factor
[3] == 1.0f
,
12698 "Got unexpected blend factor {%.8e, %.8e, %.8e, %.8e}.\n",
12699 blend_factor
[0], blend_factor
[1], blend_factor
[2], blend_factor
[3]);
12700 ok(sample_mask
== D3D11_DEFAULT_SAMPLE_MASK
, "Got unexpected sample mask %#x.\n", sample_mask
);
12701 ID3D11DeviceContext_OMGetDepthStencilState(context
, &tmp_ds_state
, &stencil_ref
);
12702 ok(!tmp_ds_state
, "Got unexpected depth stencil state %p.\n", tmp_ds_state
);
12703 ok(!stencil_ref
, "Got unexpected stencil ref %u.\n", stencil_ref
);
12704 ID3D11DeviceContext_OMGetRenderTargets(context
, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
, tmp_rtv
, &tmp_dsv
);
12705 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
12707 ok(!tmp_rtv
[i
], "Got unexpected render target view %p in slot %u.\n", tmp_rtv
[i
], i
);
12709 ok(!tmp_dsv
, "Got unexpected depth stencil view %p.\n", tmp_dsv
);
12710 ID3D11DeviceContext_OMGetRenderTargetsAndUnorderedAccessViews(context
,
12711 D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
, tmp_rtv
, &tmp_dsv
,
12712 0, D3D11_PS_CS_UAV_REGISTER_COUNT
, tmp_uav
);
12713 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
12715 ok(!tmp_rtv
[i
], "Got unexpected render target view %p in slot %u.\n", tmp_rtv
[i
], i
);
12717 ok(!tmp_dsv
, "Got unexpected depth stencil view %p.\n", tmp_dsv
);
12718 for (i
= 0; i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
12720 ok(!tmp_uav
[i
], "Got unexpected unordered access view %p in slot %u.\n", tmp_uav
[i
], i
);
12723 ID3D11DeviceContext_RSGetScissorRects(context
, &count
, NULL
);
12724 ok(!count
, "Got unexpected scissor rect count %u.\n", count
);
12725 memset(tmp_rect
, 0x55, sizeof(tmp_rect
));
12726 count
= D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
;
12727 ID3D11DeviceContext_RSGetScissorRects(context
, &count
, tmp_rect
);
12728 for (i
= 0; i
< D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
; ++i
)
12730 ok(!tmp_rect
[i
].left
&& !tmp_rect
[i
].top
&& !tmp_rect
[i
].right
&& !tmp_rect
[i
].bottom
,
12731 "Got unexpected scissor rect %s in slot %u.\n",
12732 wine_dbgstr_rect(&tmp_rect
[i
]), i
);
12734 ID3D11DeviceContext_RSGetViewports(context
, &count
, NULL
);
12735 ok(!count
, "Got unexpected viewport count %u.\n", count
);
12736 memset(tmp_viewport
, 0x55, sizeof(tmp_viewport
));
12737 count
= D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
;
12738 ID3D11DeviceContext_RSGetViewports(context
, &count
, tmp_viewport
);
12739 for (i
= 0; i
< D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
; ++i
)
12741 ok(!tmp_viewport
[i
].TopLeftX
&& !tmp_viewport
[i
].TopLeftY
&& !tmp_viewport
[i
].Width
12742 && !tmp_viewport
[i
].Height
&& !tmp_viewport
[i
].MinDepth
&& !tmp_viewport
[i
].MaxDepth
,
12743 "Got unexpected viewport {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e} in slot %u.\n",
12744 tmp_viewport
[i
].TopLeftX
, tmp_viewport
[i
].TopLeftY
, tmp_viewport
[i
].Width
,
12745 tmp_viewport
[i
].Height
, tmp_viewport
[i
].MinDepth
, tmp_viewport
[i
].MaxDepth
, i
);
12747 ID3D11DeviceContext_RSGetState(context
, &tmp_rs_state
);
12748 ok(!tmp_rs_state
, "Got unexpected rasterizer state %p.\n", tmp_rs_state
);
12750 ID3D11DeviceContext_SOGetTargets(context
, D3D11_SO_BUFFER_SLOT_COUNT
, tmp_buffer
);
12751 for (i
= 0; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
12753 ok(!tmp_buffer
[i
], "Got unexpected stream output %p in slot %u.\n", tmp_buffer
[i
], i
);
12756 ID3D11DeviceContext_GetPredication(context
, &tmp_predicate
, &predicate_value
);
12757 ok(!tmp_predicate
, "Got unexpected predicate %p.\n", tmp_predicate
);
12758 ok(!predicate_value
, "Got unexpected predicate value %#x.\n", predicate_value
);
12762 ID3D11Predicate_Release(predicate
);
12763 ID3D11RasterizerState_Release(rs_state
);
12764 ID3D11DepthStencilView_Release(dsv
);
12765 ID3D11Texture2D_Release(ds_texture
);
12767 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
12769 ID3D11RenderTargetView_Release(rtv
[i
]);
12770 ID3D11Texture2D_Release(rt_texture
[i
]);
12773 ID3D11DepthStencilState_Release(ds_state
);
12774 ID3D11BlendState_Release(blend_state
);
12775 ID3D11InputLayout_Release(input_layout
);
12776 ID3D11VertexShader_Release(vs
);
12777 ID3D11HullShader_Release(hs
);
12778 ID3D11DomainShader_Release(ds
);
12779 ID3D11GeometryShader_Release(gs
);
12780 ID3D11PixelShader_Release(ps
);
12781 ID3D11ComputeShader_Release(cs
);
12783 for (i
= 0; i
< D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
12785 ID3D11SamplerState_Release(sampler
[i
]);
12788 for (i
= 0; i
< D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
12790 ID3D11ShaderResourceView_Release(srv
[i
]);
12793 for (i
= 0; i
< D3D11_PS_CS_UAV_REGISTER_COUNT
; ++i
)
12795 ID3D11UnorderedAccessView_Release(cs_uav
[i
]);
12796 ID3D11Buffer_Release(cs_uav_buffer
[i
]);
12798 ID3D11UnorderedAccessView_Release(ps_uav
);
12799 ID3D11Buffer_Release(ps_uav_buffer
);
12801 for (i
= 0; i
< D3D11_SO_BUFFER_SLOT_COUNT
; ++i
)
12803 ID3D11Buffer_Release(so_buffer
[i
]);
12806 for (i
= 0; i
< D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
12808 ID3D11Buffer_Release(buffer
[i
]);
12811 for (i
= 0; i
< D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
12813 ID3D11Buffer_Release(cb
[i
]);
12816 ID3D11DeviceContext_Release(context
);
12817 refcount
= ID3D11Device_Release(device
);
12818 ok(!refcount
, "Device has %u references left.\n", refcount
);
12821 static void test_il_append_aligned(void)
12823 struct d3d11_test_context test_context
;
12824 ID3D11InputLayout
*input_layout
;
12825 ID3D11DeviceContext
*context
;
12826 unsigned int stride
, offset
;
12827 ID3D11VertexShader
*vs
;
12828 ID3D11PixelShader
*ps
;
12829 ID3D11Device
*device
;
12830 ID3D11Buffer
*vb
[3];
12834 /* Semantic names are case-insensitive. */
12835 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
12837 {"CoLoR", 2, DXGI_FORMAT_R32G32_FLOAT
, 1, D3D11_APPEND_ALIGNED_ELEMENT
,
12838 D3D11_INPUT_PER_INSTANCE_DATA
, 2},
12839 {"ColoR", 3, DXGI_FORMAT_R32G32_FLOAT
, 2, D3D11_APPEND_ALIGNED_ELEMENT
,
12840 D3D11_INPUT_PER_INSTANCE_DATA
, 1},
12841 {"POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, D3D11_APPEND_ALIGNED_ELEMENT
,
12842 D3D11_INPUT_PER_VERTEX_DATA
, 0},
12843 {"ColoR", 0, DXGI_FORMAT_R32G32_FLOAT
, 2, D3D11_APPEND_ALIGNED_ELEMENT
,
12844 D3D11_INPUT_PER_INSTANCE_DATA
, 1},
12845 {"cOLOr", 1, DXGI_FORMAT_R32G32_FLOAT
, 1, D3D11_APPEND_ALIGNED_ELEMENT
,
12846 D3D11_INPUT_PER_INSTANCE_DATA
, 2},
12848 static const DWORD vs_code
[] =
12853 float4 position
: POSITION
;
12854 float2 color_xy
: COLOR0
;
12855 float2 color_zw
: COLOR1
;
12856 unsigned int instance_id
: SV_INSTANCEID
;
12861 float4 position
: SV_POSITION
;
12862 float2 color_xy
: COLOR0
;
12863 float2 color_zw
: COLOR1
;
12866 struct vs_out
main(struct vs_in i
)
12870 o
.position
= i
.position
;
12871 o
.position
.x
+= i
.instance_id
* 0.5;
12872 o
.color_xy
= i
.color_xy
;
12873 o
.color_zw
= i
.color_zw
;
12878 0x43425844, 0x52e3bf46, 0x6300403d, 0x624cffe4, 0xa4fc0013, 0x00000001, 0x00000214, 0x00000003,
12879 0x0000002c, 0x000000bc, 0x00000128, 0x4e475349, 0x00000088, 0x00000004, 0x00000008, 0x00000068,
12880 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000071, 0x00000000, 0x00000000,
12881 0x00000003, 0x00000001, 0x00000303, 0x00000071, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
12882 0x00000303, 0x00000077, 0x00000000, 0x00000008, 0x00000001, 0x00000003, 0x00000101, 0x49534f50,
12883 0x4e4f4954, 0x4c4f4300, 0x5300524f, 0x4e495f56, 0x4e415453, 0x44494543, 0xababab00, 0x4e47534f,
12884 0x00000064, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000,
12885 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000c03, 0x0000005c,
12886 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000030c, 0x505f5653, 0x5449534f, 0x004e4f49,
12887 0x4f4c4f43, 0xabab0052, 0x52444853, 0x000000e4, 0x00010040, 0x00000039, 0x0300005f, 0x001010f2,
12888 0x00000000, 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x00101032, 0x00000002, 0x04000060,
12889 0x00101012, 0x00000003, 0x00000008, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065,
12890 0x00102032, 0x00000001, 0x03000065, 0x001020c2, 0x00000001, 0x02000068, 0x00000001, 0x05000056,
12891 0x00100012, 0x00000000, 0x0010100a, 0x00000003, 0x09000032, 0x00102012, 0x00000000, 0x0010000a,
12892 0x00000000, 0x00004001, 0x3f000000, 0x0010100a, 0x00000000, 0x05000036, 0x001020e2, 0x00000000,
12893 0x00101e56, 0x00000000, 0x05000036, 0x00102032, 0x00000001, 0x00101046, 0x00000001, 0x05000036,
12894 0x001020c2, 0x00000001, 0x00101406, 0x00000002, 0x0100003e,
12896 static const DWORD ps_code
[] =
12901 float4 position
: SV_POSITION
;
12902 float2 color_xy
: COLOR0
;
12903 float2 color_zw
: COLOR1
;
12906 float4
main(struct vs_out i
) : SV_TARGET
12908 return float4(i
.color_xy
.xy
, i
.color_zw
.xy
);
12911 0x43425844, 0x64e48a09, 0xaa484d46, 0xe40a6e78, 0x9885edf3, 0x00000001, 0x00000118, 0x00000003,
12912 0x0000002c, 0x00000098, 0x000000cc, 0x4e475349, 0x00000064, 0x00000003, 0x00000008, 0x00000050,
12913 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000,
12914 0x00000003, 0x00000001, 0x00000303, 0x0000005c, 0x00000001, 0x00000000, 0x00000003, 0x00000001,
12915 0x00000c0c, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x4e47534f, 0x0000002c,
12916 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f,
12917 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000044, 0x00000040, 0x00000011, 0x03001062,
12918 0x00101032, 0x00000001, 0x03001062, 0x001010c2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
12919 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
12921 static const struct
12923 struct vec4 position
;
12927 {{-1.0f
, -1.0f
, 0.0f
, 1.0f
}},
12928 {{-1.0f
, 1.0f
, 0.0f
, 1.0f
}},
12929 {{-0.5f
, -1.0f
, 0.0f
, 1.0f
}},
12930 {{-0.5f
, 1.0f
, 0.0f
, 1.0f
}},
12932 static const struct
12934 struct vec2 color2
;
12935 struct vec2 color1
;
12939 {{0.5f
, 0.5f
}, {0.0f
, 1.0f
}},
12940 {{0.5f
, 0.5f
}, {1.0f
, 1.0f
}},
12942 static const struct
12944 struct vec2 color3
;
12945 struct vec2 color0
;
12949 {{0.5f
, 0.5f
}, {1.0f
, 0.0f
}},
12950 {{0.5f
, 0.5f
}, {0.0f
, 1.0f
}},
12951 {{0.5f
, 0.5f
}, {0.0f
, 0.0f
}},
12952 {{0.5f
, 0.5f
}, {1.0f
, 0.0f
}},
12954 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
12956 if (!init_test_context(&test_context
, NULL
))
12959 device
= test_context
.device
;
12960 context
= test_context
.immediate_context
;
12962 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
12963 vs_code
, sizeof(vs_code
), &input_layout
);
12964 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
12966 vb
[0] = create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(stream0
), stream0
);
12967 vb
[1] = create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(stream1
), stream1
);
12968 vb
[2] = create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(stream2
), stream2
);
12970 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
12971 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
12972 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
12973 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
12975 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
12976 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
12978 stride
= sizeof(*stream0
);
12979 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
[0], &stride
, &offset
);
12980 stride
= sizeof(*stream1
);
12981 ID3D11DeviceContext_IASetVertexBuffers(context
, 1, 1, &vb
[1], &stride
, &offset
);
12982 stride
= sizeof(*stream2
);
12983 ID3D11DeviceContext_IASetVertexBuffers(context
, 2, 1, &vb
[2], &stride
, &offset
);
12984 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
12985 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
12987 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
12989 ID3D11DeviceContext_DrawInstanced(context
, 4, 4, 0, 0);
12991 color
= get_texture_color(test_context
.backbuffer
, 80, 240);
12992 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
12993 color
= get_texture_color(test_context
.backbuffer
, 240, 240);
12994 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
12995 color
= get_texture_color(test_context
.backbuffer
, 400, 240);
12996 ok(compare_color(color
, 0xffff0000, 1), "Got unexpected color 0x%08x.\n", color
);
12997 color
= get_texture_color(test_context
.backbuffer
, 560, 240);
12998 ok(compare_color(color
, 0xffff00ff, 1), "Got unexpected color 0x%08x.\n", color
);
13000 ID3D11PixelShader_Release(ps
);
13001 ID3D11VertexShader_Release(vs
);
13002 ID3D11Buffer_Release(vb
[2]);
13003 ID3D11Buffer_Release(vb
[1]);
13004 ID3D11Buffer_Release(vb
[0]);
13005 ID3D11InputLayout_Release(input_layout
);
13006 release_test_context(&test_context
);
13009 static void test_instanced_draw(void)
13011 struct d3d11_test_context test_context
;
13012 D3D11_TEXTURE2D_DESC texture_desc
;
13013 ID3D11InputLayout
*input_layout
;
13014 ID3D11RenderTargetView
*rtvs
[2];
13015 ID3D11Texture2D
*render_target
;
13016 ID3D11DeviceContext
*context
;
13017 struct resource_readback rb
;
13018 unsigned int stride
, offset
;
13019 ID3D11Buffer
*args_buffer
;
13020 ID3D11VertexShader
*vs
;
13021 ID3D11PixelShader
*ps
;
13022 ID3D11Device
*device
;
13023 ID3D11Buffer
*vb
[4];
13027 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
13029 {"position", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, D3D11_APPEND_ALIGNED_ELEMENT
,
13030 D3D11_INPUT_PER_VERTEX_DATA
, 0},
13031 {"color", 0, DXGI_FORMAT_R8_UNORM
, 1, D3D11_APPEND_ALIGNED_ELEMENT
,
13032 D3D11_INPUT_PER_INSTANCE_DATA
, 1},
13033 {"color", 1, DXGI_FORMAT_R8_UNORM
, 2, D3D11_APPEND_ALIGNED_ELEMENT
,
13034 D3D10_INPUT_PER_INSTANCE_DATA
, 0},
13035 {"color", 2, DXGI_FORMAT_R8_UNORM
, 3, D3D11_APPEND_ALIGNED_ELEMENT
,
13036 D3D10_INPUT_PER_INSTANCE_DATA
, 2},
13037 {"v_offset", 0, DXGI_FORMAT_R32_FLOAT
, 1, D3D11_APPEND_ALIGNED_ELEMENT
,
13038 D3D11_INPUT_PER_INSTANCE_DATA
, 1},
13040 static const DWORD vs_code
[] =
13045 float4 position
: Position
;
13049 float v_offset
: V_Offset
;
13050 uint instance_id
: SV_InstanceId
;
13055 float4 position
: SV_Position
;
13059 uint instance_id
: InstanceId
;
13062 void main(vs_in i
, out vs_out o
)
13064 o
.position
= i
.position
;
13065 o
.position
.x
+= i
.v_offset
;
13069 o
.instance_id
= i
.instance_id
;
13072 0x43425844, 0x036df42e, 0xff0da346, 0x7b23a14a, 0xc26ec9be, 0x00000001, 0x000002bc, 0x00000003,
13073 0x0000002c, 0x000000f4, 0x0000019c, 0x4e475349, 0x000000c0, 0x00000006, 0x00000008, 0x00000098,
13074 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x000000a1, 0x00000000, 0x00000000,
13075 0x00000003, 0x00000001, 0x00000101, 0x000000a1, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
13076 0x00000101, 0x000000a1, 0x00000002, 0x00000000, 0x00000003, 0x00000003, 0x00000101, 0x000000a7,
13077 0x00000000, 0x00000000, 0x00000003, 0x00000004, 0x00000101, 0x000000b0, 0x00000000, 0x00000008,
13078 0x00000001, 0x00000005, 0x00000101, 0x69736f50, 0x6e6f6974, 0x6c6f6300, 0x5600726f, 0x66664f5f,
13079 0x00746573, 0x495f5653, 0x6174736e, 0x4965636e, 0xabab0064, 0x4e47534f, 0x000000a0, 0x00000005,
13080 0x00000008, 0x00000080, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000008c,
13081 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000e01, 0x0000008c, 0x00000001, 0x00000000,
13082 0x00000003, 0x00000001, 0x00000d02, 0x0000008c, 0x00000002, 0x00000000, 0x00000003, 0x00000001,
13083 0x00000b04, 0x00000092, 0x00000000, 0x00000000, 0x00000001, 0x00000002, 0x00000e01, 0x505f5653,
13084 0x7469736f, 0x006e6f69, 0x6f6c6f63, 0x6e490072, 0x6e617473, 0x64496563, 0xababab00, 0x52444853,
13085 0x00000118, 0x00010040, 0x00000046, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x00101012,
13086 0x00000001, 0x0300005f, 0x00101012, 0x00000002, 0x0300005f, 0x00101012, 0x00000003, 0x0300005f,
13087 0x00101012, 0x00000004, 0x04000060, 0x00101012, 0x00000005, 0x00000008, 0x04000067, 0x001020f2,
13088 0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000001, 0x03000065, 0x00102022, 0x00000001,
13089 0x03000065, 0x00102042, 0x00000001, 0x03000065, 0x00102012, 0x00000002, 0x07000000, 0x00102012,
13090 0x00000000, 0x0010100a, 0x00000000, 0x0010100a, 0x00000004, 0x05000036, 0x001020e2, 0x00000000,
13091 0x00101e56, 0x00000000, 0x05000036, 0x00102012, 0x00000001, 0x0010100a, 0x00000001, 0x05000036,
13092 0x00102022, 0x00000001, 0x0010100a, 0x00000002, 0x05000036, 0x00102042, 0x00000001, 0x0010100a,
13093 0x00000003, 0x05000036, 0x00102012, 0x00000002, 0x0010100a, 0x00000005, 0x0100003e,
13095 static const DWORD ps_code
[] =
13100 float4 position
: SV_Position
;
13104 uint instance_id
: InstanceId
;
13107 void main(vs_out i
, out float4 o0
: SV_Target0
, out uint4 o1
: SV_Target1
)
13109 o0
= float4(i
.r
, i
.g
, i
.b
, 1.0f
);
13110 o1
= i
.instance_id
;
13113 0x43425844, 0xc9f9c86d, 0xa24d87aa, 0xff75d05b, 0xfbe0581a, 0x00000001, 0x000001b8, 0x00000003,
13114 0x0000002c, 0x000000d4, 0x00000120, 0x4e475349, 0x000000a0, 0x00000005, 0x00000008, 0x00000080,
13115 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000008c, 0x00000000, 0x00000000,
13116 0x00000003, 0x00000001, 0x00000101, 0x0000008c, 0x00000001, 0x00000000, 0x00000003, 0x00000001,
13117 0x00000202, 0x0000008c, 0x00000002, 0x00000000, 0x00000003, 0x00000001, 0x00000404, 0x00000092,
13118 0x00000000, 0x00000000, 0x00000001, 0x00000002, 0x00000101, 0x505f5653, 0x7469736f, 0x006e6f69,
13119 0x6f6c6f63, 0x6e490072, 0x6e617473, 0x64496563, 0xababab00, 0x4e47534f, 0x00000044, 0x00000002,
13120 0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x00000038,
13121 0x00000001, 0x00000000, 0x00000001, 0x00000001, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074,
13122 0x52444853, 0x00000090, 0x00000040, 0x00000024, 0x03001062, 0x00101012, 0x00000001, 0x03001062,
13123 0x00101022, 0x00000001, 0x03001062, 0x00101042, 0x00000001, 0x03000862, 0x00101012, 0x00000002,
13124 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x00102072,
13125 0x00000000, 0x00101246, 0x00000001, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x3f800000,
13126 0x05000036, 0x001020f2, 0x00000001, 0x00101006, 0x00000002, 0x0100003e,
13128 static const struct vec4 stream0
[] =
13130 {-1.00f
, 0.0f
, 0.0f
, 1.0f
},
13131 {-1.00f
, 1.0f
, 0.0f
, 1.0f
},
13132 {-0.75f
, 0.0f
, 0.0f
, 1.0f
},
13133 {-0.75f
, 1.0f
, 0.0f
, 1.0f
},
13134 /* indirect draws data */
13135 {-1.00f
, -1.0f
, 0.0f
, 1.0f
},
13136 {-1.00f
, 0.0f
, 0.0f
, 1.0f
},
13137 {-0.75f
, -1.0f
, 0.0f
, 1.0f
},
13138 {-0.75f
, 0.0f
, 0.0f
, 1.0f
},
13140 static const struct
13157 static const BYTE stream2
[] = {0xf0, 0x80, 0x10, 0x40, 0xaa, 0xbb, 0xcc, 0x90};
13158 static const BYTE stream3
[] = {0xf0, 0x80, 0x10, 0x40, 0xaa, 0xbb, 0xcc, 0x90};
13159 static const D3D11_DRAW_INSTANCED_INDIRECT_ARGS argument_data
[] =
13164 static const struct
13167 unsigned int color
;
13168 unsigned int instance_id
;
13170 expected_results
[] =
13172 {{ 0, 0, 80, 240}, 0xfff0f0f0, 0},
13173 {{ 80, 0, 160, 240}, 0xfff0f080, 1},
13174 {{160, 0, 240, 240}, 0xff80f010, 2},
13175 {{240, 0, 320, 240}, 0xff80f040, 3},
13176 {{320, 0, 400, 240}, 0xffaaaaaa, 0},
13177 {{400, 0, 480, 240}, 0xffaaaabb, 1},
13178 {{480, 0, 560, 240}, 0xffbbaacc, 2},
13179 {{560, 0, 640, 240}, 0xffbbaa90, 3},
13180 /* indirect draws results */
13181 {{ 0, 240, 80, 480}, 0xfff0f0f0, 0},
13182 {{ 80, 240, 160, 480}, 0xfff0f080, 1},
13183 {{160, 240, 240, 480}, 0xff80f010, 2},
13184 {{240, 240, 320, 480}, 0xff80f040, 3},
13185 {{320, 240, 400, 480}, 0xffaaaaaa, 0},
13186 {{400, 240, 480, 480}, 0xffaaaabb, 1},
13187 {{480, 240, 560, 480}, 0xffbbaacc, 2},
13188 {{560, 240, 640, 480}, 0xffbbaa90, 3},
13190 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
13191 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
13193 if (!init_test_context(&test_context
, &feature_level
))
13195 device
= test_context
.device
;
13196 context
= test_context
.immediate_context
;
13198 rtvs
[0] = test_context
.backbuffer_rtv
;
13200 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
13201 texture_desc
.Format
= DXGI_FORMAT_R32_UINT
;
13202 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &render_target
);
13203 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
13204 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)render_target
, NULL
, &rtvs
[1]);
13205 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
13207 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
13208 vs_code
, sizeof(vs_code
), &input_layout
);
13209 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
13211 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
13212 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
13213 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
13214 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
13216 vb
[0] = create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(stream0
), stream0
);
13217 vb
[1] = create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(stream1
), stream1
);
13218 vb
[2] = create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(stream2
), stream2
);
13219 vb
[3] = create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(stream3
), stream3
);
13221 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
13222 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
13223 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
13224 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
13226 stride
= sizeof(*stream0
);
13227 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
[0], &stride
, &offset
);
13228 stride
= sizeof(*stream1
);
13229 ID3D11DeviceContext_IASetVertexBuffers(context
, 1, 1, &vb
[1], &stride
, &offset
);
13230 stride
= sizeof(*stream2
);
13231 ID3D11DeviceContext_IASetVertexBuffers(context
, 2, 1, &vb
[2], &stride
, &offset
);
13232 stride
= sizeof(*stream3
);
13233 ID3D11DeviceContext_IASetVertexBuffers(context
, 3, 1, &vb
[3], &stride
, &offset
);
13235 ID3D11DeviceContext_ClearRenderTargetView(context
, rtvs
[0], white
);
13236 ID3D11DeviceContext_ClearRenderTargetView(context
, rtvs
[1], white
);
13238 ID3D11DeviceContext_OMSetRenderTargets(context
, ARRAY_SIZE(rtvs
), rtvs
, NULL
);
13239 ID3D11DeviceContext_DrawInstanced(context
, 4, 4, 0, 0);
13240 ID3D11DeviceContext_DrawInstanced(context
, 4, 4, 0, 4);
13242 args_buffer
= create_buffer_misc(device
, 0, D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS
,
13243 sizeof(argument_data
), argument_data
);
13245 ID3D11DeviceContext_DrawInstancedIndirect(context
, args_buffer
, 0);
13246 ID3D11DeviceContext_DrawInstancedIndirect(context
, args_buffer
, sizeof(*argument_data
));
13248 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
13249 for (i
= 0; i
< ARRAY_SIZE(expected_results
); ++i
)
13250 check_readback_data_color(&rb
, &expected_results
[i
].rect
, expected_results
[i
].color
, 1);
13251 release_resource_readback(&rb
);
13253 get_texture_readback(render_target
, 0, &rb
);
13254 for (i
= 0; i
< ARRAY_SIZE(expected_results
); ++i
)
13255 check_readback_data_color(&rb
, &expected_results
[i
].rect
, expected_results
[i
].instance_id
, 0);
13256 release_resource_readback(&rb
);
13258 ID3D11Buffer_Release(vb
[0]);
13259 ID3D11Buffer_Release(vb
[1]);
13260 ID3D11Buffer_Release(vb
[2]);
13261 ID3D11Buffer_Release(vb
[3]);
13262 ID3D11Buffer_Release(args_buffer
);
13263 ID3D11RenderTargetView_Release(rtvs
[1]);
13264 ID3D11Texture2D_Release(render_target
);
13265 ID3D11VertexShader_Release(vs
);
13266 ID3D11PixelShader_Release(ps
);
13267 ID3D11InputLayout_Release(input_layout
);
13268 release_test_context(&test_context
);
13271 static void test_vertex_id(void)
13273 static const DWORD vs_code
[] =
13276 uint4
main(uint id
: ID
, uint instance_id
: SV_InstanceID
, uint vertex_id
: SV_VertexID
) : OUTPUT
13278 return uint4(id
, instance_id
, vertex_id
, 0);
13281 0x43425844, 0x5625197b, 0x588ccf8f, 0x48694905, 0x961d19ca, 0x00000001, 0x00000170, 0x00000003,
13282 0x0000002c, 0x000000a4, 0x000000d4, 0x4e475349, 0x00000070, 0x00000003, 0x00000008, 0x00000050,
13283 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000101, 0x00000053, 0x00000000, 0x00000008,
13284 0x00000001, 0x00000001, 0x00000101, 0x00000061, 0x00000000, 0x00000006, 0x00000001, 0x00000002,
13285 0x00000101, 0x53004449, 0x6e495f56, 0x6e617473, 0x44496563, 0x5f565300, 0x74726556, 0x44497865,
13286 0xababab00, 0x4e47534f, 0x00000028, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
13287 0x00000001, 0x00000000, 0x0000000f, 0x5054554f, 0xab005455, 0x52444853, 0x00000094, 0x00010040,
13288 0x00000025, 0x0300005f, 0x00101012, 0x00000000, 0x04000060, 0x00101012, 0x00000001, 0x00000008,
13289 0x04000060, 0x00101012, 0x00000002, 0x00000006, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
13290 0x00102012, 0x00000000, 0x0010100a, 0x00000000, 0x05000036, 0x00102022, 0x00000000, 0x0010100a,
13291 0x00000001, 0x05000036, 0x00102042, 0x00000000, 0x0010100a, 0x00000002, 0x05000036, 0x00102082,
13292 0x00000000, 0x00004001, 0x00000000, 0x0100003e,
13294 D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
13296 {"ID", 0, DXGI_FORMAT_R32_UINT
, 0, D3D11_APPEND_ALIGNED_ELEMENT
, D3D11_INPUT_PER_VERTEX_DATA
, 0},
13298 static const D3D11_SO_DECLARATION_ENTRY so_declaration
[] =
13300 {0, "OUTPUT", 0, 0, 4, 0},
13302 static const unsigned int vertices
[] =
13320 static const unsigned int indices
[] =
13326 struct uvec4 expected_values
[] =
13351 BOOL found_values
[ARRAY_SIZE(expected_values
)] = {0};
13352 BOOL used_values
[ARRAY_SIZE(expected_values
)] = {0};
13353 struct d3d11_test_context test_context
;
13354 D3D11_QUERY_DATA_SO_STATISTICS data
;
13355 ID3D11Buffer
*vb
, *ib
, *so_buffer
;
13356 ID3D11InputLayout
*input_layout
;
13357 ID3D11DeviceContext
*context
;
13358 D3D11_QUERY_DESC query_desc
;
13359 struct resource_readback rb
;
13360 unsigned int stride
, offset
;
13361 ID3D11Asynchronous
*query
;
13362 ID3D11GeometryShader
*gs
;
13363 ID3D11VertexShader
*vs
;
13364 ID3D11Device
*device
;
13365 unsigned int count
;
13369 if (!init_test_context(&test_context
, NULL
))
13371 device
= test_context
.device
;
13372 context
= test_context
.immediate_context
;
13374 query_desc
.Query
= D3D11_QUERY_SO_STATISTICS
;
13375 query_desc
.MiscFlags
= 0;
13376 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, (ID3D11Query
**)&query
);
13377 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
13379 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
13380 vs_code
, sizeof(vs_code
), &input_layout
);
13381 ok(hr
== S_OK
, "Failed to create input layout, hr %#x.\n", hr
);
13383 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
13384 ok(hr
== S_OK
, "Failed to create vertex shader, hr %#x.\n", hr
);
13387 hr
= ID3D11Device_CreateGeometryShaderWithStreamOutput(device
, vs_code
, sizeof(vs_code
),
13388 so_declaration
, ARRAY_SIZE(so_declaration
), &stride
, 1, 0, NULL
, &gs
);
13389 ok(hr
== S_OK
, "Failed to create geometry shader with stream output, hr %#x.\n", hr
);
13391 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(vertices
), vertices
);
13392 ib
= create_buffer(device
, D3D11_BIND_INDEX_BUFFER
, sizeof(indices
), indices
);
13393 so_buffer
= create_buffer(device
, D3D11_BIND_STREAM_OUTPUT
, 1024, NULL
);
13395 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
13396 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
13397 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
13398 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST
);
13399 ID3D11DeviceContext_IASetIndexBuffer(context
, ib
, DXGI_FORMAT_R32_UINT
, 0);
13401 stride
= sizeof(*vertices
);
13402 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, &stride
, &offset
);
13405 ID3D11DeviceContext_SOSetTargets(context
, 1, &so_buffer
, &offset
);
13407 ID3D11DeviceContext_Begin(context
, query
);
13409 ID3D11DeviceContext_DrawInstanced(context
, 3, 2, 0, 0);
13410 ID3D11DeviceContext_DrawInstanced(context
, 3, 1, 3, 16);
13412 ID3D11DeviceContext_DrawIndexedInstanced(context
, 3, 2, 0, 0, 0);
13413 ID3D11DeviceContext_DrawIndexedInstanced(context
, 3, 1, 3, 9, 7);
13415 ID3D11DeviceContext_End(context
, query
);
13417 get_query_data(context
, query
, &data
, sizeof(data
));
13418 count
= data
.NumPrimitivesWritten
;
13419 ok(count
== ARRAY_SIZE(expected_values
), "Got unexpected value %u.\n", count
);
13421 count
= min(count
, ARRAY_SIZE(used_values
));
13422 get_buffer_readback(so_buffer
, &rb
);
13423 for (i
= 0; i
< ARRAY_SIZE(expected_values
); ++i
)
13425 for (j
= 0; j
< count
; ++j
)
13427 if (!used_values
[j
] && compare_uvec4(get_readback_uvec4(&rb
, j
, 0), &expected_values
[i
]))
13429 found_values
[i
] = TRUE
;
13430 used_values
[j
] = TRUE
;
13436 for (i
= 0; i
< count
; ++i
)
13438 const struct uvec4
*v
= get_readback_uvec4(&rb
, i
, 0);
13439 ok(used_values
[i
], "Found unexpected value {0x%08x, 0x%08x, 0x%08x, 0x%08x}.\n", v
->x
, v
->y
, v
->z
, v
->w
);
13441 release_resource_readback(&rb
);
13443 for (i
= 0; i
< ARRAY_SIZE(expected_values
); ++i
)
13445 ok(found_values
[i
], "Failed to find value {0x%08x, 0x%08x, 0x%08x, 0x%08x}.\n",
13446 expected_values
[i
].x
, expected_values
[i
].y
, expected_values
[i
].z
, expected_values
[i
].w
);
13449 ID3D11Asynchronous_Release(query
);
13450 ID3D11Buffer_Release(so_buffer
);
13451 ID3D11Buffer_Release(vb
);
13452 ID3D11Buffer_Release(ib
);
13453 ID3D11GeometryShader_Release(gs
);
13454 ID3D11VertexShader_Release(vs
);
13455 ID3D11InputLayout_Release(input_layout
);
13456 release_test_context(&test_context
);
13459 static void test_fragment_coords(void)
13461 struct d3d11_test_context test_context
;
13462 ID3D11PixelShader
*ps
, *ps_frac
;
13463 ID3D11DeviceContext
*context
;
13464 ID3D11Device
*device
;
13465 ID3D11Buffer
*ps_cb
;
13469 static const DWORD ps_code
[] =
13474 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
13476 float4 ret
= float4(0.0, 0.0, 0.0, 1.0);
13478 if (position
.x
> cutoff
.x
)
13480 if (position
.y
> cutoff
.y
)
13486 0x43425844, 0x49fc9e51, 0x8068867d, 0xf20cfa39, 0xb8099e6b, 0x00000001, 0x00000144, 0x00000003,
13487 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
13488 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
13489 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
13490 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000a8, 0x00000040,
13491 0x0000002a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04002064, 0x00101032, 0x00000000,
13492 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x08000031, 0x00100032,
13493 0x00000000, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000000, 0x0a000001, 0x00102062,
13494 0x00000000, 0x00100106, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x3f800000, 0x00000000,
13495 0x08000036, 0x00102092, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x3f800000,
13498 static const DWORD ps_frac_code
[] =
13501 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
13503 return float4(frac(position
.xy
), 0.0, 1.0);
13506 0x43425844, 0x86d9d78a, 0x190b72c2, 0x50841fd6, 0xdc24022e, 0x00000001, 0x000000f8, 0x00000003,
13507 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
13508 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
13509 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
13510 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x0000005c, 0x00000040,
13511 0x00000017, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
13512 0x0500001a, 0x00102032, 0x00000000, 0x00101046, 0x00000000, 0x08000036, 0x001020c2, 0x00000000,
13513 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e,
13515 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
13516 struct vec4 cutoff
= {320.0f
, 240.0f
, 0.0f
, 0.0f
};
13518 if (!init_test_context(&test_context
, NULL
))
13521 device
= test_context
.device
;
13522 context
= test_context
.immediate_context
;
13524 ps_cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(cutoff
), &cutoff
);
13526 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
13527 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
13528 hr
= ID3D11Device_CreatePixelShader(device
, ps_frac_code
, sizeof(ps_frac_code
), NULL
, &ps_frac
);
13529 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
13531 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &ps_cb
);
13532 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
13534 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
13536 draw_quad(&test_context
);
13538 color
= get_texture_color(test_context
.backbuffer
, 319, 239);
13539 ok(compare_color(color
, 0xff000000, 1), "Got unexpected color 0x%08x.\n", color
);
13540 color
= get_texture_color(test_context
.backbuffer
, 320, 239);
13541 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
13542 color
= get_texture_color(test_context
.backbuffer
, 319, 240);
13543 ok(compare_color(color
, 0xffff0000, 1), "Got unexpected color 0x%08x.\n", color
);
13544 color
= get_texture_color(test_context
.backbuffer
, 320, 240);
13545 ok(compare_color(color
, 0xffffff00, 1), "Got unexpected color 0x%08x.\n", color
);
13547 ID3D11Buffer_Release(ps_cb
);
13550 ps_cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(cutoff
), &cutoff
);
13551 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &ps_cb
);
13553 draw_quad(&test_context
);
13555 color
= get_texture_color(test_context
.backbuffer
, 14, 14);
13556 ok(compare_color(color
, 0xff000000, 1), "Got unexpected color 0x%08x.\n", color
);
13557 color
= get_texture_color(test_context
.backbuffer
, 18, 14);
13558 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
13559 color
= get_texture_color(test_context
.backbuffer
, 14, 18);
13560 ok(compare_color(color
, 0xffff0000, 1), "Got unexpected color 0x%08x.\n", color
);
13561 color
= get_texture_color(test_context
.backbuffer
, 18, 18);
13562 ok(compare_color(color
, 0xffffff00, 1), "Got unexpected color 0x%08x.\n", color
);
13564 ID3D11DeviceContext_PSSetShader(context
, ps_frac
, NULL
, 0);
13565 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
13567 ID3D11DeviceContext_Draw(context
, 4, 0);
13569 color
= get_texture_color(test_context
.backbuffer
, 14, 14);
13570 ok(compare_color(color
, 0xff008080, 1), "Got unexpected color 0x%08x.\n", color
);
13572 ID3D11Buffer_Release(ps_cb
);
13573 ID3D11PixelShader_Release(ps_frac
);
13574 ID3D11PixelShader_Release(ps
);
13575 release_test_context(&test_context
);
13578 static void test_initial_texture_data(void)
13580 ID3D11Texture2D
*texture
, *staging_texture
;
13581 struct d3d11_test_context test_context
;
13582 D3D11_SUBRESOURCE_DATA resource_data
;
13583 D3D11_TEXTURE2D_DESC texture_desc
;
13584 ID3D11SamplerState
*sampler_state
;
13585 ID3D11ShaderResourceView
*ps_srv
;
13586 D3D11_SAMPLER_DESC sampler_desc
;
13587 ID3D11DeviceContext
*context
;
13588 struct resource_readback rb
;
13589 ID3D11PixelShader
*ps
;
13590 ID3D11Device
*device
;
13595 static const DWORD ps_code
[] =
13601 float4
main(float4 position
: SV_POSITION
) : SV_Target
13605 p
.x
= position
.x
/ 640.0f
;
13606 p
.y
= position
.y
/ 480.0f
;
13607 return t
.Sample(s
, p
);
13610 0x43425844, 0x1ce9b612, 0xc8176faa, 0xd37844af, 0xdb515605, 0x00000001, 0x00000134, 0x00000003,
13611 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
13612 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
13613 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
13614 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
13615 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
13616 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
13617 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
13618 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
13619 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
13621 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
13622 static const DWORD bitmap_data
[] =
13624 0xffffffff, 0xff000000, 0xffffffff, 0xff000000,
13625 0xff00ff00, 0xff0000ff, 0xff00ffff, 0x00000000,
13626 0xffffff00, 0xffff0000, 0xffff00ff, 0x00000000,
13627 0xff000000, 0xff7f7f7f, 0xffffffff, 0x00000000,
13630 if (!init_test_context(&test_context
, NULL
))
13633 device
= test_context
.device
;
13634 context
= test_context
.immediate_context
;
13636 texture_desc
.Width
= 4;
13637 texture_desc
.Height
= 4;
13638 texture_desc
.MipLevels
= 1;
13639 texture_desc
.ArraySize
= 1;
13640 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
13641 texture_desc
.SampleDesc
.Count
= 1;
13642 texture_desc
.SampleDesc
.Quality
= 0;
13643 texture_desc
.Usage
= D3D11_USAGE_STAGING
;
13644 texture_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_WRITE
;
13645 texture_desc
.BindFlags
= 0;
13646 texture_desc
.MiscFlags
= 0;
13648 resource_data
.pSysMem
= bitmap_data
;
13649 resource_data
.SysMemPitch
= texture_desc
.Width
* sizeof(*bitmap_data
);
13650 resource_data
.SysMemSlicePitch
= 0;
13652 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &staging_texture
);
13653 ok(hr
== S_OK
, "Failed to create 2d texture, hr %#x.\n", hr
);
13655 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
13656 texture_desc
.CPUAccessFlags
= 0;
13657 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
13658 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
13659 ok(hr
== S_OK
, "Failed to create 2d texture, hr %#x.\n", hr
);
13661 ID3D11DeviceContext_CopyResource(context
, (ID3D11Resource
*)texture
, (ID3D11Resource
*)staging_texture
);
13663 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &ps_srv
);
13664 ok(hr
== S_OK
, "Failed to create shader resource view, hr %#x.\n", hr
);
13666 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
13667 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
13668 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
13669 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
13670 sampler_desc
.MipLODBias
= 0.0f
;
13671 sampler_desc
.MaxAnisotropy
= 0;
13672 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
13673 sampler_desc
.BorderColor
[0] = 0.0f
;
13674 sampler_desc
.BorderColor
[1] = 0.0f
;
13675 sampler_desc
.BorderColor
[2] = 0.0f
;
13676 sampler_desc
.BorderColor
[3] = 0.0f
;
13677 sampler_desc
.MinLOD
= 0.0f
;
13678 sampler_desc
.MaxLOD
= 0.0f
;
13679 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler_state
);
13680 ok(hr
== S_OK
, "Failed to create sampler state, hr %#x.\n", hr
);
13682 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
13683 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
13685 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &ps_srv
);
13686 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler_state
);
13687 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
13689 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
13690 draw_quad(&test_context
);
13691 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
13692 for (i
= 0; i
< 4; ++i
)
13694 for (j
= 0; j
< 4; ++j
)
13696 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120, 0);
13697 ok(compare_color(color
, bitmap_data
[j
+ i
* 4], 1),
13698 "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
13699 color
, j
, i
, bitmap_data
[j
+ i
* 4]);
13702 release_resource_readback(&rb
);
13704 ID3D11PixelShader_Release(ps
);
13705 ID3D11SamplerState_Release(sampler_state
);
13706 ID3D11ShaderResourceView_Release(ps_srv
);
13707 ID3D11Texture2D_Release(staging_texture
);
13708 ID3D11Texture2D_Release(texture
);
13709 release_test_context(&test_context
);
13712 static void test_update_subresource(void)
13714 struct d3d11_test_context test_context
;
13715 D3D11_SUBRESOURCE_DATA resource_data
;
13716 D3D11_TEXTURE3D_DESC texture_desc_3d
;
13717 D3D11_TEXTURE2D_DESC texture_desc
;
13718 ID3D11SamplerState
*sampler_state
;
13719 ID3D11ShaderResourceView
*ps_srv
;
13720 D3D11_SAMPLER_DESC sampler_desc
;
13721 ID3D11DeviceContext
*context
;
13722 struct resource_readback rb
;
13723 ID3D11Texture3D
*texture_3d
;
13724 ID3D11Texture2D
*texture
;
13725 ID3D11PixelShader
*ps
;
13726 ID3D11Device
*device
;
13732 static const DWORD ps_code
[] =
13738 float4
main(float4 position
: SV_POSITION
) : SV_Target
13742 p
.x
= position
.x
/ 640.0f
;
13743 p
.y
= position
.y
/ 480.0f
;
13744 return t
.Sample(s
, p
);
13747 0x43425844, 0x1ce9b612, 0xc8176faa, 0xd37844af, 0xdb515605, 0x00000001, 0x00000134, 0x00000003,
13748 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
13749 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
13750 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
13751 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
13752 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
13753 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
13754 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
13755 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
13756 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
13758 static const DWORD ps_code_3d
[] =
13764 float4
main(float4 position
: SV_POSITION
) : SV_Target
13767 p2
.x
= p1
.x
= position
.x
/ 640.0f
;
13768 p2
.y
= p1
.y
= position
.y
/ 480.0f
;
13771 return 0.5 * (t
.Sample(s
, p1
) + t
.Sample(s
, p2
));
13774 0x43425844, 0x4d466d63, 0xa3d10db1, 0xd6534470, 0x16d738ef, 0x00000001, 0x000001ec, 0x00000003,
13775 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
13776 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
13777 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
13778 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000150, 0x00000040,
13779 0x00000054, 0x0300005a, 0x00106000, 0x00000000, 0x04002858, 0x00107000, 0x00000000, 0x00005555,
13780 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
13781 0x00000002, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
13782 0x3b088889, 0x00000000, 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0x3e800000,
13783 0x09000045, 0x001000f2, 0x00000000, 0x00100246, 0x00000000, 0x00107e46, 0x00000000, 0x00106000,
13784 0x00000000, 0x0a000038, 0x00100032, 0x00000001, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
13785 0x3b088889, 0x00000000, 0x00000000, 0x05000036, 0x00100042, 0x00000001, 0x00004001, 0x3f400000,
13786 0x09000045, 0x001000f2, 0x00000001, 0x00100246, 0x00000001, 0x00107e46, 0x00000000, 0x00106000,
13787 0x00000000, 0x07000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00100e46, 0x00000001,
13788 0x0a000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3f000000, 0x3f000000,
13789 0x3f000000, 0x3f000000, 0x0100003e,
13791 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
13792 static const DWORD initial_data
[32] = {0};
13793 static const DWORD bitmap_data
[] =
13795 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
13796 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
13797 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
13798 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
13800 static const DWORD expected_colors
[] =
13802 0xffffffff, 0xff000000, 0xffffffff, 0xff000000,
13803 0xff00ff00, 0xff0000ff, 0xff00ffff, 0x00000000,
13804 0xffffff00, 0xffff0000, 0xffff00ff, 0x00000000,
13805 0xff000000, 0xff7f7f7f, 0xffffffff, 0x00000000,
13807 static const DWORD bc7_data
[] =
13809 0x3a7b944b, 0x982a5800, 0x9cab4983, 0xc6a09579,
13810 0x5f7f2bfe, 0xa95d98f2, 0x3bfb4c03, 0x8be16a41,
13811 0x8362e6c0, 0x358ed7a2, 0xec3e130b, 0x86cebc86,
13812 0xf045be66, 0x7a16507f, 0xfe9ccc9f, 0x3f103e16,
13813 0x84d466c5, 0xfaf5cb5a, 0x9b9e1859, 0x384589b0,
13814 0x9268b4b8, 0x212b3643, 0x813f853a, 0x4a2bd7c2,
13815 0x1809f3e0, 0xf646d5ef, 0x40e80679, 0x05791fe5,
13816 0x6604e7e5, 0x5c28b55d, 0x1ef211f5, 0x632d47f6,
13818 static const DWORD bc7_expected_colors
[] =
13820 0xc1752752, 0xc39859a9, 0xff79c08e, 0xff63bf6c,
13821 0xbf7d2756, 0xb89f3d40, 0xffda3a77, 0xffd08099,
13822 0x415f1f37, 0x43671d3f, 0xffc64758, 0xff57a194,
13823 0x405a2032, 0x39422619, 0xff749b76, 0xffabb879,
13825 static const DWORD expected_colors_3d
[] = { 0xffff8000, 0xffff8080, 0x80008000, 0xff8080ff };
13827 if (!init_test_context(&test_context
, NULL
))
13830 device
= test_context
.device
;
13831 context
= test_context
.immediate_context
;
13833 texture_desc
.Width
= 4;
13834 texture_desc
.Height
= 4;
13835 texture_desc
.MipLevels
= 1;
13836 texture_desc
.ArraySize
= 1;
13837 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
13838 texture_desc
.SampleDesc
.Count
= 1;
13839 texture_desc
.SampleDesc
.Quality
= 0;
13840 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
13841 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
13842 texture_desc
.CPUAccessFlags
= 0;
13843 texture_desc
.MiscFlags
= 0;
13845 resource_data
.pSysMem
= initial_data
;
13846 resource_data
.SysMemPitch
= texture_desc
.Width
* sizeof(*initial_data
);
13847 resource_data
.SysMemSlicePitch
= 0;
13849 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &texture
);
13850 ok(SUCCEEDED(hr
), "Failed to create 2d texture, hr %#x.\n", hr
);
13852 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &ps_srv
);
13853 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
13855 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
13856 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
13857 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
13858 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
13859 sampler_desc
.MipLODBias
= 0.0f
;
13860 sampler_desc
.MaxAnisotropy
= 0;
13861 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
13862 sampler_desc
.BorderColor
[0] = 0.0f
;
13863 sampler_desc
.BorderColor
[1] = 0.0f
;
13864 sampler_desc
.BorderColor
[2] = 0.0f
;
13865 sampler_desc
.BorderColor
[3] = 0.0f
;
13866 sampler_desc
.MinLOD
= 0.0f
;
13867 sampler_desc
.MaxLOD
= 0.0f
;
13869 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler_state
);
13870 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
13872 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
13873 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
13875 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &ps_srv
);
13876 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler_state
);
13877 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
13879 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
13880 check_texture_color(test_context
.backbuffer
, 0x7f0000ff, 1);
13882 draw_quad(&test_context
);
13883 check_texture_color(test_context
.backbuffer
, 0x00000000, 0);
13885 set_box(&box
, 1, 1, 0, 3, 3, 1);
13886 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture
, 0, &box
,
13887 bitmap_data
, 4 * sizeof(*bitmap_data
), 0);
13888 set_box(&box
, 0, 3, 0, 3, 4, 1);
13889 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture
, 0, &box
,
13890 &bitmap_data
[6], 4 * sizeof(*bitmap_data
), 0);
13891 set_box(&box
, 0, 0, 0, 4, 1, 1);
13892 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture
, 0, &box
,
13893 &bitmap_data
[10], 4 * sizeof(*bitmap_data
), 0);
13894 set_box(&box
, 0, 1, 0, 1, 3, 1);
13895 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture
, 0, &box
,
13896 &bitmap_data
[2], sizeof(*bitmap_data
), 0);
13897 set_box(&box
, 4, 4, 0, 3, 1, 1);
13898 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture
, 0, &box
,
13899 bitmap_data
, sizeof(*bitmap_data
), 0);
13900 set_box(&box
, 0, 0, 0, 4, 4, 0);
13901 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture
, 0, &box
,
13902 bitmap_data
, 4 * sizeof(*bitmap_data
), 0);
13903 draw_quad(&test_context
);
13904 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
13905 for (i
= 0; i
< 4; ++i
)
13907 for (j
= 0; j
< 4; ++j
)
13909 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120, 0);
13910 ok(compare_color(color
, expected_colors
[j
+ i
* 4], 1),
13911 "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
13912 color
, j
, i
, expected_colors
[j
+ i
* 4]);
13915 release_resource_readback(&rb
);
13917 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture
, 0, NULL
,
13918 bitmap_data
, 4 * sizeof(*bitmap_data
), 0);
13919 draw_quad(&test_context
);
13920 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
13921 for (i
= 0; i
< 4; ++i
)
13923 for (j
= 0; j
< 4; ++j
)
13925 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120, 0);
13926 ok(compare_color(color
, bitmap_data
[j
+ i
* 4], 1),
13927 "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
13928 color
, j
, i
, bitmap_data
[j
+ i
* 4]);
13931 release_resource_readback(&rb
);
13933 ID3D11ShaderResourceView_Release(ps_srv
);
13934 ID3D11Texture2D_Release(texture
);
13935 ID3D11PixelShader_Release(ps
);
13937 hr
= ID3D11Device_CreatePixelShader(device
, ps_code_3d
, sizeof(ps_code_3d
), NULL
, &ps
);
13938 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
13940 texture_desc_3d
.Width
= 2;
13941 texture_desc_3d
.Height
= 2;
13942 texture_desc_3d
.Depth
= 2;
13943 texture_desc_3d
.MipLevels
= 1;
13944 texture_desc_3d
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
13945 texture_desc_3d
.Usage
= D3D11_USAGE_DEFAULT
;
13946 texture_desc_3d
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
13947 texture_desc_3d
.CPUAccessFlags
= 0;
13948 texture_desc_3d
.MiscFlags
= 0;
13950 resource_data
.SysMemPitch
= texture_desc_3d
.Width
* sizeof(*initial_data
);
13951 resource_data
.SysMemSlicePitch
= texture_desc_3d
.Width
* texture_desc_3d
.Height
* sizeof(*initial_data
);
13953 hr
= ID3D11Device_CreateTexture3D(device
, &texture_desc_3d
, &resource_data
, &texture_3d
);
13954 ok(SUCCEEDED(hr
), "Failed to create 3d texture, hr %#x.\n", hr
);
13956 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture_3d
, NULL
, &ps_srv
);
13957 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
13959 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
13960 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &ps_srv
);
13962 set_box(&box
, 0, 0, 0, 1, 2, 1);
13963 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture_3d
, 0, &box
, bitmap_data
, 8, 16);
13964 set_box(&box
, 0, 0, 0, 1, 1, 2);
13965 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture_3d
, 0, &box
, bitmap_data
+ 4, 16, 32);
13966 set_box(&box
, 1, 0, 0, 2, 1, 2);
13967 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture_3d
, 0, &box
, bitmap_data
+ 8, 4, 0);
13968 set_box(&box
, 0, 0, 1, 2, 1, 2);
13969 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture_3d
, 0, &box
, bitmap_data
+ 2, 4, 5);
13970 set_box(&box
, 0, 0, 1, 2, 1, 2);
13971 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture_3d
, 0, &box
, bitmap_data
+ 3, 12, 0);
13972 set_box(&box
, 1, 1, 0, 2, 2, 2);
13973 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture_3d
, 0, &box
, bitmap_data
, 0, 32);
13975 draw_quad(&test_context
);
13976 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
13977 for (i
= 0; i
< 2; ++i
)
13979 for (j
= 0; j
< 2; ++j
)
13981 color
= get_readback_color(&rb
, 160 + j
* 320, 120 + i
* 240, 0);
13982 ok(compare_color(color
, expected_colors_3d
[j
+ i
* 2], 1),
13983 "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
13984 color
, j
, i
, expected_colors_3d
[j
+ i
* 2]);
13987 release_resource_readback(&rb
);
13988 ID3D11ShaderResourceView_Release(ps_srv
);
13989 ID3D11Texture3D_Release(texture_3d
);
13991 texture_desc_3d
.Width
= 8;
13992 texture_desc_3d
.Height
= 8;
13993 texture_desc_3d
.Depth
= 2;
13994 texture_desc_3d
.Format
= DXGI_FORMAT_BC7_UNORM
;
13996 resource_data
.SysMemPitch
= 32;
13997 resource_data
.SysMemSlicePitch
= 64;
13999 hr
= ID3D11Device_CreateTexture3D(device
, &texture_desc_3d
, &resource_data
, &texture_3d
);
14002 skip("Failed to create BC7 3d texture, hr %#x.\n", hr
);
14006 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture_3d
, NULL
, &ps_srv
);
14007 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
14009 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &ps_srv
);
14010 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
14012 set_box(&box
, 0, 0, 0, 8, 8, 2);
14013 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture_3d
, 0, &box
, bc7_data
, 32, 64);
14014 set_box(&box
, 0, 0, 1, 8, 8, 2);
14015 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture_3d
, 0, &box
, bc7_data
, 16, 0);
14016 set_box(&box
, 0, 0, 0, 4, 4, 1);
14017 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture_3d
, 0, &box
, bc7_data
+ 8, 0, 0);
14018 set_box(&box
, 4, 4, 0, 8, 8, 2);
14019 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture_3d
, 0, &box
, bc7_data
+ 16, 0, 16);
14020 set_box(&box
, 0, 4, 1, 8, 8, 2);
14021 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture_3d
, 0, &box
, bc7_data
+ 1, 4, 32);
14022 set_box(&box
, 4, 0, 0, 8, 4, 2);
14023 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)texture_3d
, 0, &box
, bc7_data
+ 2, 0, 1);
14025 draw_quad(&test_context
);
14026 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
14027 for (i
= 0; i
< 4; ++i
)
14029 for (j
= 0; j
< 4; ++j
)
14031 color
= get_readback_color(&rb
, 70 + j
* 160, 50 + i
* 120, 0);
14032 ok(compare_color(color
, bc7_expected_colors
[j
+ i
* 4], 1),
14033 "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
14034 color
, j
, i
, bc7_expected_colors
[j
+ i
* 4]);
14037 release_resource_readback(&rb
);
14038 ID3D11ShaderResourceView_Release(ps_srv
);
14039 ID3D11Texture3D_Release(texture_3d
);
14042 ID3D11PixelShader_Release(ps
);
14043 ID3D11SamplerState_Release(sampler_state
);
14044 release_test_context(&test_context
);
14047 static void test_copy_subresource_region(void)
14049 ID3D11Texture2D
*dst_texture
, *src_texture
;
14050 struct d3d11_test_context test_context
;
14051 ID3D11Buffer
*dst_buffer
, *src_buffer
;
14052 D3D11_SUBRESOURCE_DATA resource_data
;
14053 D3D11_TEXTURE2D_DESC texture_desc
;
14054 ID3D11SamplerState
*sampler_state
;
14055 ID3D11ShaderResourceView
*ps_srv
;
14056 D3D11_SAMPLER_DESC sampler_desc
;
14057 ID3D11DeviceContext1
*context1
;
14058 ID3D11DeviceContext
*context
;
14059 struct vec4 float_colors
[16];
14060 struct resource_readback rb
;
14061 ID3D11PixelShader
*ps
;
14062 ID3D11Device
*device
;
14068 static const DWORD ps_code
[] =
14074 float4
main(float4 position
: SV_POSITION
) : SV_Target
14078 p
.x
= position
.x
/ 640.0f
;
14079 p
.y
= position
.y
/ 480.0f
;
14080 return t
.Sample(s
, p
);
14083 0x43425844, 0x1ce9b612, 0xc8176faa, 0xd37844af, 0xdb515605, 0x00000001, 0x00000134, 0x00000003,
14084 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
14085 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
14086 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
14087 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
14088 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
14089 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
14090 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
14091 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
14092 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
14094 static const DWORD ps_buffer_code
[] =
14099 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
14101 float2 p
= (float2
)4;
14102 p
*= float2(position
.x
/ 640.0f
, position
.y
/ 480.0f
);
14103 return buffer
[(int)p
.y
* 4 + (int)p
.x
];
14106 0x43425844, 0x57e7139f, 0x4f0c9e52, 0x598b77e3, 0x5a239132, 0x00000001, 0x0000016c, 0x00000003,
14107 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
14108 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
14109 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
14110 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000d0, 0x00000040,
14111 0x00000034, 0x04000859, 0x00208e46, 0x00000000, 0x00000010, 0x04002064, 0x00101032, 0x00000000,
14112 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0a000038, 0x00100032,
14113 0x00000000, 0x00101516, 0x00000000, 0x00004002, 0x3c088889, 0x3bcccccd, 0x00000000, 0x00000000,
14114 0x0500001b, 0x00100032, 0x00000000, 0x00100046, 0x00000000, 0x07000029, 0x00100012, 0x00000000,
14115 0x0010000a, 0x00000000, 0x00004001, 0x00000002, 0x0700001e, 0x00100012, 0x00000000, 0x0010000a,
14116 0x00000000, 0x0010001a, 0x00000000, 0x07000036, 0x001020f2, 0x00000000, 0x04208e46, 0x00000000,
14117 0x0010000a, 0x00000000, 0x0100003e,
14119 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
14120 static const DWORD initial_data
[16] = {0};
14121 static const DWORD bitmap_data
[] =
14123 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
14124 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
14125 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
14126 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
14128 static const DWORD expected_colors
[] =
14130 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
14131 0xffffff00, 0xff0000ff, 0xff00ffff, 0x00000000,
14132 0xff7f7f7f, 0xffff0000, 0xffff00ff, 0xff7f7f7f,
14133 0xffffffff, 0xffffffff, 0xff000000, 0x00000000,
14136 if (!init_test_context(&test_context
, NULL
))
14139 device
= test_context
.device
;
14140 context
= test_context
.immediate_context
;
14142 texture_desc
.Width
= 4;
14143 texture_desc
.Height
= 4;
14144 texture_desc
.MipLevels
= 1;
14145 texture_desc
.ArraySize
= 1;
14146 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
14147 texture_desc
.SampleDesc
.Count
= 1;
14148 texture_desc
.SampleDesc
.Quality
= 0;
14149 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
14150 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
14151 texture_desc
.CPUAccessFlags
= 0;
14152 texture_desc
.MiscFlags
= 0;
14154 resource_data
.pSysMem
= initial_data
;
14155 resource_data
.SysMemPitch
= texture_desc
.Width
* sizeof(*initial_data
);
14156 resource_data
.SysMemSlicePitch
= 0;
14158 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &dst_texture
);
14159 ok(SUCCEEDED(hr
), "Failed to create 2d texture, hr %#x.\n", hr
);
14161 texture_desc
.Usage
= D3D11_USAGE_IMMUTABLE
;
14163 resource_data
.pSysMem
= bitmap_data
;
14164 resource_data
.SysMemPitch
= texture_desc
.Width
* sizeof(*bitmap_data
);
14165 resource_data
.SysMemSlicePitch
= 0;
14167 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &src_texture
);
14168 ok(SUCCEEDED(hr
), "Failed to create 2d texture, hr %#x.\n", hr
);
14170 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)dst_texture
, NULL
, &ps_srv
);
14171 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
14173 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
14174 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
14175 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
14176 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
14177 sampler_desc
.MipLODBias
= 0.0f
;
14178 sampler_desc
.MaxAnisotropy
= 0;
14179 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
14180 sampler_desc
.BorderColor
[0] = 0.0f
;
14181 sampler_desc
.BorderColor
[1] = 0.0f
;
14182 sampler_desc
.BorderColor
[2] = 0.0f
;
14183 sampler_desc
.BorderColor
[3] = 0.0f
;
14184 sampler_desc
.MinLOD
= 0.0f
;
14185 sampler_desc
.MaxLOD
= 0.0f
;
14187 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler_state
);
14188 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
14190 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
14191 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
14193 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &ps_srv
);
14194 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler_state
);
14195 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
14197 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
14199 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
14200 1, 1, 0, NULL
, 0, &box
);
14201 ID3D11DeviceContext_CopySubresourceRegion(context
, NULL
, 0,
14202 1, 1, 0, (ID3D11Resource
*)src_texture
, 0, &box
);
14204 set_box(&box
, 0, 0, 0, 2, 2, 1);
14205 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
14206 1, 1, 0, (ID3D11Resource
*)src_texture
, 0, &box
);
14207 set_box(&box
, 1, 2, 0, 4, 3, 1);
14208 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
14209 0, 3, 0, (ID3D11Resource
*)src_texture
, 0, &box
);
14210 set_box(&box
, 0, 3, 0, 4, 4, 1);
14211 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
14212 0, 0, 0, (ID3D11Resource
*)src_texture
, 0, &box
);
14213 set_box(&box
, 3, 0, 0, 4, 2, 1);
14214 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
14215 0, 1, 0, (ID3D11Resource
*)src_texture
, 0, &box
);
14216 set_box(&box
, 3, 1, 0, 4, 2, 1);
14217 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
14218 3, 2, 0, (ID3D11Resource
*)src_texture
, 0, &box
);
14219 set_box(&box
, 0, 0, 0, 4, 4, 0);
14220 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
14221 0, 0, 0, (ID3D11Resource
*)src_texture
, 0, &box
);
14222 draw_quad(&test_context
);
14223 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
14224 for (i
= 0; i
< 4; ++i
)
14226 for (j
= 0; j
< 4; ++j
)
14228 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120, 0);
14229 ok(compare_color(color
, expected_colors
[j
+ i
* 4], 1),
14230 "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
14231 color
, j
, i
, expected_colors
[j
+ i
* 4]);
14234 release_resource_readback(&rb
);
14236 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
14237 0, 0, 0, (ID3D11Resource
*)src_texture
, 0, NULL
);
14238 draw_quad(&test_context
);
14239 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
14240 for (i
= 0; i
< 4; ++i
)
14242 for (j
= 0; j
< 4; ++j
)
14244 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120, 0);
14245 ok(compare_color(color
, bitmap_data
[j
+ i
* 4], 1),
14246 "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
14247 color
, j
, i
, bitmap_data
[j
+ i
* 4]);
14250 release_resource_readback(&rb
);
14252 hr
= ID3D11DeviceContext_QueryInterface(context
, &IID_ID3D11DeviceContext1
, (void **)&context1
);
14253 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
14254 "Failed to query ID3D11DeviceContext1, hr %#x.\n", hr
);
14258 ID3D11DeviceContext1_ClearRenderTargetView(context1
, test_context
.backbuffer_rtv
, red
);
14259 check_texture_color(test_context
.backbuffer
, 0x800000ff, 2);
14261 memset(float_colors
, 0, sizeof(float_colors
));
14262 for (i
= 0; i
< texture_desc
.Width
; ++i
)
14263 ((unsigned int *)float_colors
)[i
] = 0x45454545;
14265 ID3D11DeviceContext1_UpdateSubresource1(context1
, (ID3D11Resource
*)dst_texture
, 0, NULL
,
14266 float_colors
, 0, 0, 0);
14267 draw_quad(&test_context
);
14268 check_texture_color(test_context
.backbuffer
, 0x45454545, 1);
14270 ID3D11DeviceContext1_CopySubresourceRegion1(context1
, (ID3D11Resource
*)dst_texture
, 0,
14271 0, 0, 0, (ID3D11Resource
*)src_texture
, 0, NULL
, 0);
14272 draw_quad(&test_context
);
14274 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
14275 for (i
= 0; i
< 4; ++i
)
14277 for (j
= 0; j
< 4; ++j
)
14279 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120, 0);
14280 ok(compare_color(color
, bitmap_data
[j
+ i
* 4], 1),
14281 "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
14282 color
, j
, i
, bitmap_data
[j
+ i
* 4]);
14285 release_resource_readback(&rb
);
14287 ID3D11DeviceContext1_Release(context1
);
14291 ID3D11PixelShader_Release(ps
);
14292 hr
= ID3D11Device_CreatePixelShader(device
, ps_buffer_code
, sizeof(ps_buffer_code
), NULL
, &ps
);
14293 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
14295 ID3D11ShaderResourceView_Release(ps_srv
);
14298 ID3D11SamplerState_Release(sampler_state
);
14299 sampler_state
= NULL
;
14301 ID3D11Texture2D_Release(dst_texture
);
14302 ID3D11Texture2D_Release(src_texture
);
14304 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &ps_srv
);
14305 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler_state
);
14306 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
14308 memset(float_colors
, 0, sizeof(float_colors
));
14309 dst_buffer
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(float_colors
), float_colors
);
14310 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &dst_buffer
);
14312 src_buffer
= create_buffer(device
, 0, 256 * sizeof(*float_colors
), NULL
);
14314 for (i
= 0; i
< 4; ++i
)
14316 for (j
= 0; j
< 4; ++j
)
14318 float_colors
[j
+ i
* 4].x
= ((bitmap_data
[j
+ i
* 4] >> 0) & 0xff) / 255.0f
;
14319 float_colors
[j
+ i
* 4].y
= ((bitmap_data
[j
+ i
* 4] >> 8) & 0xff) / 255.0f
;
14320 float_colors
[j
+ i
* 4].z
= ((bitmap_data
[j
+ i
* 4] >> 16) & 0xff) / 255.0f
;
14321 float_colors
[j
+ i
* 4].w
= ((bitmap_data
[j
+ i
* 4] >> 24) & 0xff) / 255.0f
;
14324 set_box(&box
, 0, 0, 0, sizeof(float_colors
), 1, 1);
14325 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)src_buffer
, 0, &box
, float_colors
, 0, 0);
14327 set_box(&box
, 0, 0, 0, sizeof(float_colors
), 0, 1);
14328 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_buffer
, 0,
14329 0, 0, 0, (ID3D11Resource
*)src_buffer
, 0, &box
);
14330 draw_quad(&test_context
);
14331 check_texture_color(test_context
.backbuffer
, 0x00000000, 0);
14333 set_box(&box
, 0, 0, 0, sizeof(float_colors
), 1, 0);
14334 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_buffer
, 0,
14335 0, 0, 0, (ID3D11Resource
*)src_buffer
, 0, &box
);
14336 draw_quad(&test_context
);
14337 check_texture_color(test_context
.backbuffer
, 0x00000000, 0);
14339 set_box(&box
, 0, 0, 0, sizeof(float_colors
), 0, 0);
14340 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_buffer
, 0,
14341 0, 0, 0, (ID3D11Resource
*)src_buffer
, 0, &box
);
14342 draw_quad(&test_context
);
14343 check_texture_color(test_context
.backbuffer
, 0x00000000, 0);
14345 set_box(&box
, 0, 0, 0, sizeof(float_colors
), 1, 1);
14346 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_buffer
, 0,
14347 0, 0, 0, (ID3D11Resource
*)src_buffer
, 0, &box
);
14348 draw_quad(&test_context
);
14349 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
14350 for (i
= 0; i
< 4; ++i
)
14352 for (j
= 0; j
< 4; ++j
)
14354 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120, 0);
14355 ok(compare_color(color
, bitmap_data
[j
+ i
* 4], 1),
14356 "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
14357 color
, j
, i
, bitmap_data
[j
+ i
* 4]);
14360 release_resource_readback(&rb
);
14362 ID3D11Buffer_Release(dst_buffer
);
14363 ID3D11Buffer_Release(src_buffer
);
14364 ID3D11PixelShader_Release(ps
);
14365 release_test_context(&test_context
);
14368 static void test_copy_subresource_region_1d(void)
14370 D3D11_SUBRESOURCE_DATA resource_data
[4];
14371 struct d3d11_test_context test_context
;
14372 D3D11_TEXTURE1D_DESC texture1d_desc
;
14373 D3D11_TEXTURE2D_DESC texture2d_desc
;
14374 ID3D11DeviceContext
*context
;
14375 struct resource_readback rb
;
14376 ID3D11Texture1D
*texture1d
;
14377 ID3D11Texture2D
*texture2d
;
14378 ID3D11Device
*device
;
14384 static const DWORD bitmap_data
[] =
14386 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
14387 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
14388 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
14389 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
14392 if (!init_test_context(&test_context
, NULL
))
14394 device
= test_context
.device
;
14395 context
= test_context
.immediate_context
;
14397 texture1d_desc
.Width
= 4;
14398 texture1d_desc
.MipLevels
= 1;
14399 texture1d_desc
.ArraySize
= 4;
14400 texture1d_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
14401 texture1d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
14402 texture1d_desc
.BindFlags
= 0;
14403 texture1d_desc
.CPUAccessFlags
= 0;
14404 texture1d_desc
.MiscFlags
= 0;
14406 for (i
= 0; i
< ARRAY_SIZE(resource_data
); ++i
)
14408 resource_data
[i
].pSysMem
= &bitmap_data
[4 * i
];
14409 resource_data
[i
].SysMemPitch
= texture1d_desc
.Width
* sizeof(bitmap_data
);
14410 resource_data
[i
].SysMemSlicePitch
= 0;
14413 hr
= ID3D11Device_CreateTexture1D(device
, &texture1d_desc
, resource_data
, &texture1d
);
14414 ok(hr
== S_OK
, "Failed to create 1d texture, hr %#x.\n", hr
);
14416 texture2d_desc
.Width
= 4;
14417 texture2d_desc
.Height
= 4;
14418 texture2d_desc
.MipLevels
= 1;
14419 texture2d_desc
.ArraySize
= 1;
14420 texture2d_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
14421 texture2d_desc
.SampleDesc
.Count
= 1;
14422 texture2d_desc
.SampleDesc
.Quality
= 0;
14423 texture2d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
14424 texture2d_desc
.BindFlags
= 0;
14425 texture2d_desc
.CPUAccessFlags
= 0;
14426 texture2d_desc
.MiscFlags
= 0;
14428 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, &texture2d
);
14429 ok(hr
== S_OK
, "Failed to create 2d texture, hr %#x.\n", hr
);
14431 set_box(&box
, 0, 0, 0, 4, 1, 1);
14432 for (i
= 0; i
< ARRAY_SIZE(resource_data
); ++i
)
14434 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)texture2d
, 0,
14435 0, i
, 0, (ID3D11Resource
*)texture1d
, i
, &box
);
14438 get_texture_readback(texture2d
, 0, &rb
);
14439 for (i
= 0; i
< 4; ++i
)
14441 for (j
= 0; j
< 4; ++j
)
14443 color
= get_readback_color(&rb
, j
, i
, 0);
14444 ok(compare_color(color
, bitmap_data
[j
+ i
* 4], 1),
14445 "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
14446 color
, j
, i
, bitmap_data
[j
+ i
* 4]);
14449 release_resource_readback(&rb
);
14451 get_texture1d_readback(texture1d
, 0, &rb
);
14452 for (i
= 0; i
< texture1d_desc
.Width
; ++i
)
14454 color
= get_readback_color(&rb
, i
, 0, 0);
14455 ok(compare_color(color
, bitmap_data
[i
], 1),
14456 "Got color 0x%08x at %u, expected 0x%08x.\n",
14457 color
, i
, bitmap_data
[i
]);
14459 release_resource_readback(&rb
);
14461 ID3D11Texture1D_Release(texture1d
);
14462 ID3D11Texture2D_Release(texture2d
);
14463 release_test_context(&test_context
);
14466 static void test_copy_subresource_region_3d(void)
14468 ID3D11ShaderResourceView
*dst_srv
, *src_srv
;
14469 ID3D11Texture3D
*dst_texture
, *src_texture
;
14470 D3D11_SUBRESOURCE_DATA resource_data
[4];
14471 struct d3d11_test_context test_context
;
14472 D3D11_TEXTURE2D_DESC texture2d_desc
;
14473 D3D11_TEXTURE3D_DESC texture3d_desc
;
14474 ID3D11SamplerState
*sampler_state
;
14475 D3D11_SAMPLER_DESC sampler_desc
;
14476 ID3D11DeviceContext
*context
;
14477 struct resource_readback rb
;
14478 ID3D11Texture2D
*texture2d
;
14479 ID3D11PixelShader
*ps
;
14480 ID3D11Device
*device
;
14487 static const DWORD ps_code
[] =
14493 float4
main(float4 position
: SV_POSITION
) : SV_Target
14495 return t
.Sample(s
, position
.xyz
/ float3(640, 480, 1));
14498 0x43425844, 0x27b15ae8, 0xbebf46f7, 0x6cd88d8d, 0x5118de51, 0x00000001, 0x00000134, 0x00000003,
14499 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
14500 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000070f, 0x505f5653, 0x5449534f, 0x004e4f49,
14501 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
14502 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
14503 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04002858, 0x00107000, 0x00000000, 0x00005555,
14504 0x04002064, 0x00101072, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
14505 0x00000001, 0x0a000038, 0x00100072, 0x00000000, 0x00101246, 0x00000000, 0x00004002, 0x3acccccd,
14506 0x3b088889, 0x3f800000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100246, 0x00000000,
14507 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
14509 static const DWORD bitmap_data
[] =
14511 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
14512 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
14513 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
14514 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
14517 if (!init_test_context(&test_context
, NULL
))
14519 device
= test_context
.device
;
14520 context
= test_context
.immediate_context
;
14522 texture3d_desc
.Width
= 4;
14523 texture3d_desc
.Height
= 4;
14524 texture3d_desc
.Depth
= 4;
14525 texture3d_desc
.MipLevels
= 1;
14526 texture3d_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
14527 texture3d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
14528 texture3d_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
14529 texture3d_desc
.CPUAccessFlags
= 0;
14530 texture3d_desc
.MiscFlags
= 0;
14532 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &src_texture
);
14533 ok(hr
== S_OK
, "Failed to create 3d texture, hr %#x.\n", hr
);
14534 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &dst_texture
);
14535 ok(hr
== S_OK
, "Failed to create 3d texture, hr %#x.\n", hr
);
14537 texture2d_desc
.Width
= 4;
14538 texture2d_desc
.Height
= 4;
14539 texture2d_desc
.MipLevels
= 1;
14540 texture2d_desc
.ArraySize
= 4;
14541 texture2d_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
14542 texture2d_desc
.SampleDesc
.Count
= 1;
14543 texture2d_desc
.SampleDesc
.Quality
= 0;
14544 texture2d_desc
.Usage
= D3D11_USAGE_IMMUTABLE
;
14545 texture2d_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
14546 texture2d_desc
.CPUAccessFlags
= 0;
14547 texture2d_desc
.MiscFlags
= 0;
14549 for (i
= 0; i
< ARRAY_SIZE(*data
); ++i
)
14551 data
[0][i
] = 0xff0000ff;
14552 data
[1][i
] = bitmap_data
[i
];
14553 data
[2][i
] = 0xff00ff00;
14554 data
[3][i
] = 0xffff00ff;
14557 for (i
= 0; i
< ARRAY_SIZE(resource_data
); ++i
)
14559 resource_data
[i
].pSysMem
= data
[i
];
14560 resource_data
[i
].SysMemPitch
= texture2d_desc
.Width
* sizeof(data
[0][0]);
14561 resource_data
[i
].SysMemSlicePitch
= 0;
14564 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, resource_data
, &texture2d
);
14565 ok(hr
== S_OK
, "Failed to create 2d texture, hr %#x.\n", hr
);
14567 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)src_texture
, NULL
, &src_srv
);
14568 ok(hr
== S_OK
, "Failed to create shader resource view, hr %#x.\n", hr
);
14569 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)dst_texture
, NULL
, &dst_srv
);
14570 ok(hr
== S_OK
, "Failed to create shader resource view, hr %#x.\n", hr
);
14572 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
14573 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
14574 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
14575 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
14576 sampler_desc
.MipLODBias
= 0.0f
;
14577 sampler_desc
.MaxAnisotropy
= 0;
14578 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
14579 sampler_desc
.BorderColor
[0] = 0.0f
;
14580 sampler_desc
.BorderColor
[1] = 0.0f
;
14581 sampler_desc
.BorderColor
[2] = 0.0f
;
14582 sampler_desc
.BorderColor
[3] = 0.0f
;
14583 sampler_desc
.MinLOD
= 0.0f
;
14584 sampler_desc
.MaxLOD
= 0.0f
;
14586 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler_state
);
14587 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
14589 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
14590 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
14592 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &src_srv
);
14593 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler_state
);
14594 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
14596 set_box(&box
, 0, 0, 0, 4, 4, 1);
14597 for (i
= 0; i
< ARRAY_SIZE(resource_data
); ++i
)
14599 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)src_texture
, 0,
14600 0, 0, i
, (ID3D11Resource
*)texture2d
, i
, &box
);
14602 draw_quad(&test_context
);
14603 check_texture_color(test_context
.backbuffer
, 0xff0000ff, 1);
14604 draw_quad_z(&test_context
, 0.25f
);
14605 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
14606 for (i
= 0; i
< 4; ++i
)
14608 for (j
= 0; j
< 4; ++j
)
14610 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120, 0);
14611 ok(compare_color(color
, bitmap_data
[j
+ i
* 4], 1),
14612 "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
14613 color
, j
, i
, bitmap_data
[j
+ i
* 4]);
14616 release_resource_readback(&rb
);
14617 draw_quad_z(&test_context
, 0.5f
);
14618 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
14619 draw_quad_z(&test_context
, 1.0f
);
14620 check_texture_color(test_context
.backbuffer
, 0xffff00ff, 1);
14622 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &dst_srv
);
14624 set_box(&box
, 0, 0, 0, 4, 4, 2);
14625 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
14626 0, 0, 2, (ID3D11Resource
*)src_texture
, 0, &box
);
14627 set_box(&box
, 0, 0, 2, 4, 4, 4);
14628 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
14629 0, 0, 0, (ID3D11Resource
*)src_texture
, 0, &box
);
14631 set_box(&box
, 0, 0, 0, 4, 4, 1);
14632 for (i
= 0; i
< ARRAY_SIZE(resource_data
); ++i
)
14634 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)src_texture
, 0,
14635 0, 0, i
, (ID3D11Resource
*)texture2d
, i
, &box
);
14637 draw_quad(&test_context
);
14638 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
14639 draw_quad_z(&test_context
, 0.25f
);
14640 check_texture_color(test_context
.backbuffer
, 0xffff00ff, 1);
14641 draw_quad_z(&test_context
, 0.5f
);
14642 check_texture_color(test_context
.backbuffer
, 0xff0000ff, 1);
14643 draw_quad_z(&test_context
, 1.0f
);
14644 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
14645 for (i
= 0; i
< 4; ++i
)
14647 for (j
= 0; j
< 4; ++j
)
14649 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120, 0);
14650 ok(compare_color(color
, bitmap_data
[j
+ i
* 4], 1),
14651 "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
14652 color
, j
, i
, bitmap_data
[j
+ i
* 4]);
14655 release_resource_readback(&rb
);
14657 ID3D11PixelShader_Release(ps
);
14658 ID3D11SamplerState_Release(sampler_state
);
14659 ID3D11ShaderResourceView_Release(dst_srv
);
14660 ID3D11ShaderResourceView_Release(src_srv
);
14661 ID3D11Texture2D_Release(texture2d
);
14662 ID3D11Texture3D_Release(dst_texture
);
14663 ID3D11Texture3D_Release(src_texture
);
14664 release_test_context(&test_context
);
14667 static void test_resource_map(void)
14669 D3D11_MAPPED_SUBRESOURCE mapped_subresource
;
14670 D3D11_TEXTURE3D_DESC texture3d_desc
;
14671 D3D11_TEXTURE2D_DESC texture2d_desc
;
14672 D3D11_BUFFER_DESC buffer_desc
;
14673 ID3D11DeviceContext
*context
;
14674 ID3D11Texture3D
*texture3d
;
14675 ID3D11Texture2D
*texture2d
;
14676 ID3D11Buffer
*buffer
;
14677 ID3D11Device
*device
;
14682 if (!(device
= create_device(NULL
)))
14684 skip("Failed to create device.\n");
14688 ID3D11Device_GetImmediateContext(device
, &context
);
14690 buffer_desc
.ByteWidth
= 1024;
14691 buffer_desc
.Usage
= D3D11_USAGE_STAGING
;
14692 buffer_desc
.BindFlags
= 0;
14693 buffer_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
| D3D11_CPU_ACCESS_WRITE
;
14694 buffer_desc
.MiscFlags
= 0;
14695 buffer_desc
.StructureByteStride
= 0;
14697 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
14698 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
14700 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)buffer
, 1, D3D11_MAP_READ
, 0, &mapped_subresource
);
14701 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
14703 memset(&mapped_subresource
, 0, sizeof(mapped_subresource
));
14704 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)buffer
, 0, D3D11_MAP_WRITE
, 0, &mapped_subresource
);
14705 ok(SUCCEEDED(hr
), "Failed to map buffer, hr %#x.\n", hr
);
14706 ok(mapped_subresource
.RowPitch
== 1024, "Got unexpected row pitch %u.\n", mapped_subresource
.RowPitch
);
14707 ok(mapped_subresource
.DepthPitch
== 1024, "Got unexpected depth pitch %u.\n", mapped_subresource
.DepthPitch
);
14708 *((DWORD
*)mapped_subresource
.pData
) = 0xdeadbeef;
14709 ID3D11DeviceContext_Unmap(context
, (ID3D11Resource
*)buffer
, 0);
14711 memset(&mapped_subresource
, 0, sizeof(mapped_subresource
));
14712 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)buffer
, 0, D3D11_MAP_READ
, 0, &mapped_subresource
);
14713 ok(SUCCEEDED(hr
), "Failed to map buffer, hr %#x.\n", hr
);
14714 ok(mapped_subresource
.RowPitch
== 1024, "Got unexpected row pitch %u.\n", mapped_subresource
.RowPitch
);
14715 ok(mapped_subresource
.DepthPitch
== 1024, "Got unexpected depth pitch %u.\n", mapped_subresource
.DepthPitch
);
14716 data
= *((DWORD
*)mapped_subresource
.pData
);
14717 ok(data
== 0xdeadbeef, "Got unexpected data %#x.\n", data
);
14718 ID3D11DeviceContext_Unmap(context
, (ID3D11Resource
*)buffer
, 0);
14720 refcount
= ID3D11Buffer_Release(buffer
);
14721 ok(!refcount
, "Buffer has %u references left.\n", refcount
);
14723 texture2d_desc
.Width
= 512;
14724 texture2d_desc
.Height
= 512;
14725 texture2d_desc
.MipLevels
= 1;
14726 texture2d_desc
.ArraySize
= 1;
14727 texture2d_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
14728 texture2d_desc
.SampleDesc
.Count
= 1;
14729 texture2d_desc
.SampleDesc
.Quality
= 0;
14730 texture2d_desc
.Usage
= D3D11_USAGE_STAGING
;
14731 texture2d_desc
.BindFlags
= 0;
14732 texture2d_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
| D3D11_CPU_ACCESS_WRITE
;
14733 texture2d_desc
.MiscFlags
= 0;
14735 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, &texture2d
);
14736 ok(SUCCEEDED(hr
), "Failed to create 2d texture, hr %#x.\n", hr
);
14738 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)texture2d
, 1, D3D11_MAP_READ
, 0, &mapped_subresource
);
14739 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
14741 memset(&mapped_subresource
, 0, sizeof(mapped_subresource
));
14742 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)texture2d
, 0, D3D11_MAP_WRITE
, 0, &mapped_subresource
);
14743 ok(SUCCEEDED(hr
), "Failed to map texture, hr %#x.\n", hr
);
14744 ok(mapped_subresource
.RowPitch
== 4 * 512, "Got unexpected row pitch %u.\n", mapped_subresource
.RowPitch
);
14745 ok(mapped_subresource
.DepthPitch
== 4 * 512 * 512, "Got unexpected depth pitch %u.\n",
14746 mapped_subresource
.DepthPitch
);
14747 *((DWORD
*)mapped_subresource
.pData
) = 0xdeadbeef;
14748 ID3D11DeviceContext_Unmap(context
, (ID3D11Resource
*)texture2d
, 0);
14750 memset(&mapped_subresource
, 0, sizeof(mapped_subresource
));
14751 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)texture2d
, 0, D3D11_MAP_READ
, 0, &mapped_subresource
);
14752 ok(SUCCEEDED(hr
), "Failed to map texture, hr %#x.\n", hr
);
14753 ok(mapped_subresource
.RowPitch
== 4 * 512, "Got unexpected row pitch %u.\n", mapped_subresource
.RowPitch
);
14754 ok(mapped_subresource
.DepthPitch
== 4 * 512 * 512, "Got unexpected depth pitch %u.\n",
14755 mapped_subresource
.DepthPitch
);
14756 data
= *((DWORD
*)mapped_subresource
.pData
);
14757 ok(data
== 0xdeadbeef, "Got unexpected data %#x.\n", data
);
14758 ID3D11DeviceContext_Unmap(context
, (ID3D11Resource
*)texture2d
, 0);
14760 refcount
= ID3D11Texture2D_Release(texture2d
);
14761 ok(!refcount
, "2D texture has %u references left.\n", refcount
);
14763 texture3d_desc
.Width
= 64;
14764 texture3d_desc
.Height
= 64;
14765 texture3d_desc
.Depth
= 64;
14766 texture3d_desc
.MipLevels
= 1;
14767 texture3d_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
14768 texture3d_desc
.Usage
= D3D11_USAGE_STAGING
;
14769 texture3d_desc
.BindFlags
= 0;
14770 texture3d_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
| D3D11_CPU_ACCESS_WRITE
;
14771 texture3d_desc
.MiscFlags
= 0;
14773 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &texture3d
);
14774 ok(SUCCEEDED(hr
), "Failed to create 3d texture, hr %#x.\n", hr
);
14776 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)texture3d
, 1, D3D11_MAP_READ
, 0, &mapped_subresource
);
14777 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
14779 memset(&mapped_subresource
, 0, sizeof(mapped_subresource
));
14780 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)texture3d
, 0, D3D11_MAP_WRITE
, 0, &mapped_subresource
);
14781 ok(SUCCEEDED(hr
), "Failed to map texture, hr %#x.\n", hr
);
14782 ok(mapped_subresource
.RowPitch
== 4 * 64, "Got unexpected row pitch %u.\n", mapped_subresource
.RowPitch
);
14783 ok(mapped_subresource
.DepthPitch
== 4 * 64 * 64, "Got unexpected depth pitch %u.\n",
14784 mapped_subresource
.DepthPitch
);
14785 *((DWORD
*)mapped_subresource
.pData
) = 0xdeadbeef;
14786 ID3D11DeviceContext_Unmap(context
, (ID3D11Resource
*)texture3d
, 0);
14788 memset(&mapped_subresource
, 0, sizeof(mapped_subresource
));
14789 hr
= ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)texture3d
, 0, D3D11_MAP_READ
, 0, &mapped_subresource
);
14790 ok(SUCCEEDED(hr
), "Failed to map texture, hr %#x.\n", hr
);
14791 ok(mapped_subresource
.RowPitch
== 4 * 64, "Got unexpected row pitch %u.\n", mapped_subresource
.RowPitch
);
14792 ok(mapped_subresource
.DepthPitch
== 4 * 64 * 64, "Got unexpected depth pitch %u.\n",
14793 mapped_subresource
.DepthPitch
);
14794 data
= *((DWORD
*)mapped_subresource
.pData
);
14795 ok(data
== 0xdeadbeef, "Got unexpected data %#x.\n", data
);
14796 ID3D11DeviceContext_Unmap(context
, (ID3D11Resource
*)texture3d
, 0);
14798 refcount
= ID3D11Texture3D_Release(texture3d
);
14799 ok(!refcount
, "3D texture has %u references left.\n", refcount
);
14801 ID3D11DeviceContext_Release(context
);
14803 refcount
= ID3D11Device_Release(device
);
14804 ok(!refcount
, "Device has %u references left.\n", refcount
);
14807 #define check_resource_cpu_access(a, b, c, d, e) check_resource_cpu_access_(__LINE__, a, b, c, d, e)
14808 static void check_resource_cpu_access_(unsigned int line
, ID3D11DeviceContext
*context
,
14809 ID3D11Resource
*resource
, D3D11_USAGE usage
, UINT bind_flags
, UINT cpu_access
)
14811 BOOL cpu_write
= cpu_access
& D3D11_CPU_ACCESS_WRITE
;
14812 BOOL cpu_read
= cpu_access
& D3D11_CPU_ACCESS_READ
;
14813 BOOL dynamic
= usage
== D3D11_USAGE_DYNAMIC
;
14814 D3D11_MAPPED_SUBRESOURCE map_desc
;
14815 HRESULT hr
, expected_hr
;
14816 ID3D11Device
*device
;
14818 expected_hr
= cpu_read
? S_OK
: E_INVALIDARG
;
14819 hr
= ID3D11DeviceContext_Map(context
, resource
, 0, D3D11_MAP_READ
, 0, &map_desc
);
14820 ok_(__FILE__
, line
)(hr
== expected_hr
, "Got hr %#x for READ.\n", hr
);
14822 ID3D11DeviceContext_Unmap(context
, resource
, 0);
14824 /* WRITE_DISCARD and WRITE_NO_OVERWRITE are the only allowed options for dynamic resources. */
14825 expected_hr
= !dynamic
&& cpu_write
? S_OK
: E_INVALIDARG
;
14826 hr
= ID3D11DeviceContext_Map(context
, resource
, 0, D3D11_MAP_WRITE
, 0, &map_desc
);
14827 todo_wine_if(dynamic
&& cpu_write
)
14828 ok_(__FILE__
, line
)(hr
== expected_hr
, "Got hr %#x for WRITE.\n", hr
);
14830 ID3D11DeviceContext_Unmap(context
, resource
, 0);
14832 expected_hr
= cpu_read
&& cpu_write
? S_OK
: E_INVALIDARG
;
14833 hr
= ID3D11DeviceContext_Map(context
, resource
, 0, D3D11_MAP_READ_WRITE
, 0, &map_desc
);
14834 ok_(__FILE__
, line
)(hr
== expected_hr
, "Got hr %#x for READ_WRITE.\n", hr
);
14836 ID3D11DeviceContext_Unmap(context
, resource
, 0);
14838 expected_hr
= dynamic
? S_OK
: E_INVALIDARG
;
14839 hr
= ID3D11DeviceContext_Map(context
, resource
, 0, D3D11_MAP_WRITE_DISCARD
, 0, &map_desc
);
14840 todo_wine_if(!dynamic
&& cpu_write
)
14841 ok_(__FILE__
, line
)(hr
== expected_hr
, "Got hr %#x for WRITE_DISCARD.\n", hr
);
14843 ID3D11DeviceContext_Unmap(context
, resource
, 0);
14848 ID3D11DeviceContext_GetDevice(context
, &device
);
14850 /* WRITE_NO_OVERWRITE is supported only for buffers. */
14851 expected_hr
= is_buffer(resource
) ? S_OK
: E_INVALIDARG
;
14852 hr
= ID3D11DeviceContext_Map(context
, resource
, 0, D3D11_MAP_WRITE_NO_OVERWRITE
, 0, &map_desc
);
14853 /* D3D11.1 is required for constant and shader buffers. */
14854 todo_wine_if(expected_hr
!= S_OK
)
14855 ok_(__FILE__
, line
)(hr
== expected_hr
14856 || broken(bind_flags
& (D3D11_BIND_CONSTANT_BUFFER
| D3D11_BIND_SHADER_RESOURCE
)),
14857 "Got hr %#x for WRITE_NO_OVERWRITE.\n", hr
);
14859 ID3D11DeviceContext_Unmap(context
, resource
, 0);
14861 ID3D11Device_Release(device
);
14864 static void test_resource_access(const D3D_FEATURE_LEVEL feature_level
)
14866 D3D11_TEXTURE2D_DESC texture_desc
;
14867 struct device_desc device_desc
;
14868 D3D11_BUFFER_DESC buffer_desc
;
14869 ID3D11DeviceContext
*context
;
14870 D3D11_SUBRESOURCE_DATA data
;
14871 ID3D11Resource
*resource
;
14872 BOOL required_cpu_access
;
14873 BOOL cpu_write
, cpu_read
;
14874 HRESULT hr
, expected_hr
;
14875 UINT allowed_cpu_access
;
14876 BOOL broken_validation
;
14877 ID3D11Device
*device
;
14881 static const struct
14886 UINT allowed_cpu_access
;
14890 /* Default resources cannot be written by CPU. */
14891 {D3D11_USAGE_DEFAULT
, D3D11_BIND_VERTEX_BUFFER
, TRUE
, 0},
14892 {D3D11_USAGE_DEFAULT
, D3D11_BIND_INDEX_BUFFER
, TRUE
, 0},
14893 {D3D11_USAGE_DEFAULT
, D3D11_BIND_CONSTANT_BUFFER
, TRUE
, 0},
14894 {D3D11_USAGE_DEFAULT
, D3D11_BIND_SHADER_RESOURCE
, TRUE
, 0},
14895 {D3D11_USAGE_DEFAULT
, D3D11_BIND_STREAM_OUTPUT
, TRUE
, 0},
14896 {D3D11_USAGE_DEFAULT
, D3D11_BIND_RENDER_TARGET
, TRUE
, 0},
14897 {D3D11_USAGE_DEFAULT
, D3D11_BIND_DEPTH_STENCIL
, TRUE
, 0},
14898 {D3D11_USAGE_DEFAULT
, D3D11_BIND_UNORDERED_ACCESS
, TRUE
, 0},
14900 /* Immutable resources cannot be written by CPU and GPU. */
14901 {D3D11_USAGE_IMMUTABLE
, 0, FALSE
, 0},
14902 {D3D11_USAGE_IMMUTABLE
, D3D11_BIND_VERTEX_BUFFER
, TRUE
, 0},
14903 {D3D11_USAGE_IMMUTABLE
, D3D11_BIND_INDEX_BUFFER
, TRUE
, 0},
14904 {D3D11_USAGE_IMMUTABLE
, D3D11_BIND_CONSTANT_BUFFER
, TRUE
, 0},
14905 {D3D11_USAGE_IMMUTABLE
, D3D11_BIND_SHADER_RESOURCE
, TRUE
, 0},
14906 {D3D11_USAGE_IMMUTABLE
, D3D11_BIND_STREAM_OUTPUT
, FALSE
, 0},
14907 {D3D11_USAGE_IMMUTABLE
, D3D11_BIND_RENDER_TARGET
, FALSE
, 0},
14908 {D3D11_USAGE_IMMUTABLE
, D3D11_BIND_DEPTH_STENCIL
, FALSE
, 0},
14909 {D3D11_USAGE_IMMUTABLE
, D3D11_BIND_UNORDERED_ACCESS
, FALSE
, 0},
14911 /* Dynamic resources cannot be written by GPU. */
14912 {D3D11_USAGE_DYNAMIC
, 0, FALSE
, D3D11_CPU_ACCESS_WRITE
},
14913 {D3D11_USAGE_DYNAMIC
, D3D11_BIND_VERTEX_BUFFER
, TRUE
, D3D11_CPU_ACCESS_WRITE
},
14914 {D3D11_USAGE_DYNAMIC
, D3D11_BIND_INDEX_BUFFER
, TRUE
, D3D11_CPU_ACCESS_WRITE
},
14915 {D3D11_USAGE_DYNAMIC
, D3D11_BIND_CONSTANT_BUFFER
, TRUE
, D3D11_CPU_ACCESS_WRITE
},
14916 {D3D11_USAGE_DYNAMIC
, D3D11_BIND_SHADER_RESOURCE
, TRUE
, D3D11_CPU_ACCESS_WRITE
},
14917 {D3D11_USAGE_DYNAMIC
, D3D11_BIND_STREAM_OUTPUT
, FALSE
, D3D11_CPU_ACCESS_WRITE
},
14918 {D3D11_USAGE_DYNAMIC
, D3D11_BIND_RENDER_TARGET
, FALSE
, D3D11_CPU_ACCESS_WRITE
},
14919 {D3D11_USAGE_DYNAMIC
, D3D11_BIND_DEPTH_STENCIL
, FALSE
, D3D11_CPU_ACCESS_WRITE
},
14920 {D3D11_USAGE_DYNAMIC
, D3D11_BIND_UNORDERED_ACCESS
, FALSE
, D3D11_CPU_ACCESS_WRITE
},
14922 /* Staging resources support only data transfer. */
14923 {D3D11_USAGE_STAGING
, 0, TRUE
, D3D11_CPU_ACCESS_WRITE
| D3D11_CPU_ACCESS_READ
},
14924 {D3D11_USAGE_STAGING
, D3D11_BIND_VERTEX_BUFFER
, FALSE
, 0},
14925 {D3D11_USAGE_STAGING
, D3D11_BIND_INDEX_BUFFER
, FALSE
, 0},
14926 {D3D11_USAGE_STAGING
, D3D11_BIND_CONSTANT_BUFFER
, FALSE
, 0},
14927 {D3D11_USAGE_STAGING
, D3D11_BIND_SHADER_RESOURCE
, FALSE
, 0},
14928 {D3D11_USAGE_STAGING
, D3D11_BIND_STREAM_OUTPUT
, FALSE
, 0},
14929 {D3D11_USAGE_STAGING
, D3D11_BIND_RENDER_TARGET
, FALSE
, 0},
14930 {D3D11_USAGE_STAGING
, D3D11_BIND_DEPTH_STENCIL
, FALSE
, 0},
14931 {D3D11_USAGE_STAGING
, D3D11_BIND_UNORDERED_ACCESS
, FALSE
, 0},
14934 device_desc
.feature_level
= &feature_level
;
14935 device_desc
.flags
= 0;
14936 if (!(device
= create_device(&device_desc
)))
14938 skip("Failed to create device for feature level %#x.\n", feature_level
);
14941 ID3D11Device_GetImmediateContext(device
, &context
);
14943 data
.SysMemPitch
= 0;
14944 data
.SysMemSlicePitch
= 0;
14945 data
.pSysMem
= heap_alloc(10240);
14946 ok(!!data
.pSysMem
, "Failed to allocate memory.\n");
14948 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
14950 switch (tests
[i
].bind_flags
)
14952 case D3D11_BIND_DEPTH_STENCIL
:
14955 case D3D11_BIND_SHADER_RESOURCE
:
14956 case D3D11_BIND_STREAM_OUTPUT
:
14957 case D3D11_BIND_RENDER_TARGET
:
14958 if (feature_level
< D3D_FEATURE_LEVEL_10_0
)
14962 case D3D11_BIND_UNORDERED_ACCESS
:
14963 if (feature_level
< D3D_FEATURE_LEVEL_11_0
)
14971 allowed_cpu_access
= tests
[i
].allowed_cpu_access
;
14972 if (feature_level
>= D3D_FEATURE_LEVEL_11_0
&& is_d3d11_2_runtime(device
)
14973 && tests
[i
].usage
== D3D11_USAGE_DEFAULT
14974 && (tests
[i
].bind_flags
== D3D11_BIND_SHADER_RESOURCE
14975 || tests
[i
].bind_flags
== D3D11_BIND_UNORDERED_ACCESS
))
14976 allowed_cpu_access
|= D3D11_CPU_ACCESS_WRITE
| D3D11_CPU_ACCESS_READ
;
14978 required_cpu_access
= tests
[i
].usage
== D3D11_USAGE_DYNAMIC
|| tests
[i
].usage
== D3D11_USAGE_STAGING
;
14979 cpu_write
= allowed_cpu_access
& D3D11_CPU_ACCESS_WRITE
;
14980 cpu_read
= allowed_cpu_access
& D3D11_CPU_ACCESS_READ
;
14982 buffer_desc
.ByteWidth
= 1024;
14983 buffer_desc
.Usage
= tests
[i
].usage
;
14984 buffer_desc
.BindFlags
= tests
[i
].bind_flags
;
14985 buffer_desc
.MiscFlags
= 0;
14986 buffer_desc
.StructureByteStride
= 0;
14988 buffer_desc
.CPUAccessFlags
= 0;
14989 expected_hr
= tests
[i
].is_valid
&& !required_cpu_access
? S_OK
: E_INVALIDARG
;
14990 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &data
, (ID3D11Buffer
**)&resource
);
14991 ok(hr
== expected_hr
, "Got hr %#x, expected %#x, test %u.\n", hr
, expected_hr
, i
);
14994 check_resource_cpu_access(context
, resource
,
14995 buffer_desc
.Usage
, buffer_desc
.BindFlags
, buffer_desc
.CPUAccessFlags
);
14996 ID3D11Resource_Release(resource
);
14999 buffer_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_WRITE
;
15000 expected_hr
= tests
[i
].is_valid
&& cpu_write
? S_OK
: E_INVALIDARG
;
15001 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &data
, (ID3D11Buffer
**)&resource
);
15002 ok(hr
== expected_hr
, "Got hr %#x, expected %#x, test %u.\n", hr
, expected_hr
, i
);
15005 check_resource_cpu_access(context
, resource
,
15006 buffer_desc
.Usage
, buffer_desc
.BindFlags
, buffer_desc
.CPUAccessFlags
);
15007 ID3D11Resource_Release(resource
);
15010 buffer_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
;
15011 expected_hr
= tests
[i
].is_valid
&& cpu_read
? S_OK
: E_INVALIDARG
;
15012 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &data
, (ID3D11Buffer
**)&resource
);
15013 ok(hr
== expected_hr
, "Got hr %#x, expected %#x, test %u.\n", hr
, expected_hr
, i
);
15016 check_resource_cpu_access(context
, resource
,
15017 buffer_desc
.Usage
, buffer_desc
.BindFlags
, buffer_desc
.CPUAccessFlags
);
15018 ID3D11Resource_Release(resource
);
15021 buffer_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_WRITE
| D3D11_CPU_ACCESS_READ
;
15022 expected_hr
= tests
[i
].is_valid
&& cpu_write
&& cpu_read
? S_OK
: E_INVALIDARG
;
15023 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &data
, (ID3D11Buffer
**)&resource
);
15024 ok(hr
== expected_hr
, "Got hr %#x, expected %#x, test %u.\n", hr
, expected_hr
, i
);
15027 check_resource_cpu_access(context
, resource
,
15028 buffer_desc
.Usage
, buffer_desc
.BindFlags
, buffer_desc
.CPUAccessFlags
);
15029 ID3D11Resource_Release(resource
);
15033 data
.SysMemPitch
= 16;
15035 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
15037 switch (tests
[i
].bind_flags
)
15039 case D3D11_BIND_VERTEX_BUFFER
:
15040 case D3D11_BIND_INDEX_BUFFER
:
15041 case D3D11_BIND_CONSTANT_BUFFER
:
15042 case D3D11_BIND_STREAM_OUTPUT
:
15045 case D3D11_BIND_UNORDERED_ACCESS
:
15046 if (feature_level
< D3D_FEATURE_LEVEL_11_0
)
15054 broken_validation
= tests
[i
].usage
== D3D11_USAGE_DEFAULT
15055 && (tests
[i
].bind_flags
== D3D11_BIND_SHADER_RESOURCE
15056 || tests
[i
].bind_flags
== D3D11_BIND_RENDER_TARGET
15057 || tests
[i
].bind_flags
== D3D11_BIND_UNORDERED_ACCESS
);
15059 required_cpu_access
= tests
[i
].usage
== D3D11_USAGE_DYNAMIC
|| tests
[i
].usage
== D3D11_USAGE_STAGING
;
15060 cpu_write
= tests
[i
].allowed_cpu_access
& D3D11_CPU_ACCESS_WRITE
;
15061 cpu_read
= tests
[i
].allowed_cpu_access
& D3D11_CPU_ACCESS_READ
;
15063 texture_desc
.Width
= 4;
15064 texture_desc
.Height
= 4;
15065 texture_desc
.MipLevels
= 1;
15066 texture_desc
.ArraySize
= 1;
15067 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
15068 texture_desc
.SampleDesc
.Count
= 1;
15069 texture_desc
.SampleDesc
.Quality
= 0;
15070 texture_desc
.Usage
= tests
[i
].usage
;
15071 texture_desc
.BindFlags
= tests
[i
].bind_flags
;
15072 texture_desc
.MiscFlags
= 0;
15073 if (tests
[i
].bind_flags
== D3D11_BIND_DEPTH_STENCIL
)
15074 texture_desc
.Format
= DXGI_FORMAT_D16_UNORM
;
15076 texture_desc
.CPUAccessFlags
= 0;
15077 expected_hr
= tests
[i
].is_valid
&& !required_cpu_access
? S_OK
: E_INVALIDARG
;
15078 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &data
, (ID3D11Texture2D
**)&resource
);
15079 ok(hr
== expected_hr
, "Got hr %#x, expected %#x, test %u.\n", hr
, expected_hr
, i
);
15082 check_resource_cpu_access(context
, resource
,
15083 texture_desc
.Usage
, texture_desc
.BindFlags
, texture_desc
.CPUAccessFlags
);
15084 ID3D11Resource_Release(resource
);
15087 texture_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_WRITE
;
15088 expected_hr
= tests
[i
].is_valid
&& cpu_write
? S_OK
: E_INVALIDARG
;
15089 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &data
, (ID3D11Texture2D
**)&resource
);
15090 ok(hr
== expected_hr
|| (hr
== S_OK
&& broken_validation
),
15091 "Got hr %#x, expected %#x, test %u.\n", hr
, expected_hr
, i
);
15094 if (broken_validation
)
15095 texture_desc
.CPUAccessFlags
= 0;
15096 check_resource_cpu_access(context
, resource
,
15097 texture_desc
.Usage
, texture_desc
.BindFlags
, texture_desc
.CPUAccessFlags
);
15098 ID3D11Resource_Release(resource
);
15101 texture_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
;
15102 expected_hr
= tests
[i
].is_valid
&& cpu_read
? S_OK
: E_INVALIDARG
;
15103 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &data
, (ID3D11Texture2D
**)&resource
);
15104 ok(hr
== expected_hr
|| (hr
== S_OK
&& broken_validation
),
15105 "Got hr %#x, expected %#x, test %u.\n", hr
, expected_hr
, i
);
15108 if (broken_validation
)
15109 texture_desc
.CPUAccessFlags
= 0;
15110 check_resource_cpu_access(context
, resource
,
15111 texture_desc
.Usage
, texture_desc
.BindFlags
, texture_desc
.CPUAccessFlags
);
15112 ID3D11Resource_Release(resource
);
15115 texture_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_WRITE
| D3D11_CPU_ACCESS_READ
;
15116 expected_hr
= tests
[i
].is_valid
&& cpu_write
&& cpu_read
? S_OK
: E_INVALIDARG
;
15117 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &data
, (ID3D11Texture2D
**)&resource
);
15118 ok(hr
== expected_hr
|| (hr
== S_OK
&& broken_validation
),
15119 "Got hr %#x, expected %#x, test %u.\n", hr
, expected_hr
, i
);
15122 if (broken_validation
)
15123 texture_desc
.CPUAccessFlags
= 0;
15124 check_resource_cpu_access(context
, resource
,
15125 texture_desc
.Usage
, texture_desc
.BindFlags
, texture_desc
.CPUAccessFlags
);
15126 ID3D11Resource_Release(resource
);
15130 heap_free((void *)data
.pSysMem
);
15132 ID3D11DeviceContext_Release(context
);
15133 refcount
= ID3D11Device_Release(device
);
15134 ok(!refcount
, "Device has %u references left.\n", refcount
);
15137 static void test_check_multisample_quality_levels(void)
15139 ID3D11Device
*device
;
15140 UINT quality_levels
;
15144 if (!(device
= create_device(NULL
)))
15146 skip("Failed to create device.\n");
15150 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 2, &quality_levels
);
15151 ok(hr
== S_OK
, "Failed to check multisample quality levels, hr %#x.\n", hr
);
15152 if (!quality_levels
)
15154 skip("Multisampling not supported for DXGI_FORMAT_R8G8B8A8_UNORM, skipping test.\n");
15158 quality_levels
= 0xdeadbeef;
15159 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_UNKNOWN
, 2, &quality_levels
);
15160 todo_wine
ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
15161 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
15162 quality_levels
= 0xdeadbeef;
15163 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, 65536, 2, &quality_levels
);
15164 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
15165 todo_wine
ok(quality_levels
== 0xdeadbeef, "Got unexpected quality_levels %u.\n", quality_levels
);
15167 if (!enable_debug_layer
)
15169 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, NULL
);
15170 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
15171 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 1, NULL
);
15172 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
15173 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 2, NULL
);
15174 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
15177 quality_levels
= 0xdeadbeef;
15178 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, &quality_levels
);
15179 ok(hr
== E_FAIL
, "Got unexpected hr %#x.\n", hr
);
15180 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
15182 quality_levels
= 0xdeadbeef;
15183 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 1, &quality_levels
);
15184 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
15185 ok(quality_levels
== 1, "Got unexpected quality_levels %u.\n", quality_levels
);
15187 quality_levels
= 0xdeadbeef;
15188 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 2, &quality_levels
);
15189 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
15190 ok(quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
15192 /* We assume 15 samples multisampling is never supported in practice. */
15193 quality_levels
= 0xdeadbeef;
15194 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 15, &quality_levels
);
15195 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
15196 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
15197 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 32, &quality_levels
);
15198 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
15199 quality_levels
= 0xdeadbeef;
15200 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 33, &quality_levels
);
15201 ok(hr
== E_FAIL
, "Got unexpected hr %#x.\n", hr
);
15202 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
15203 quality_levels
= 0xdeadbeef;
15204 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 64, &quality_levels
);
15205 ok(hr
== E_FAIL
, "Got unexpected hr %#x.\n", hr
);
15206 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
15208 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_BC3_UNORM
, 2, &quality_levels
);
15209 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
15210 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
15213 refcount
= ID3D11Device_Release(device
);
15214 ok(!refcount
, "Device has %u references left.\n", refcount
);
15217 static void test_swapchain_formats(const D3D_FEATURE_LEVEL feature_level
)
15219 DXGI_SWAP_CHAIN_DESC swapchain_desc
;
15220 struct device_desc device_desc
;
15221 IDXGISwapChain
*swapchain
;
15222 IDXGIDevice
*dxgi_device
;
15223 HRESULT hr
, expected_hr
;
15224 IDXGIAdapter
*adapter
;
15225 IDXGIFactory
*factory
;
15226 ID3D11Device
*device
;
15230 swapchain_desc
.BufferDesc
.Width
= 800;
15231 swapchain_desc
.BufferDesc
.Height
= 600;
15232 swapchain_desc
.BufferDesc
.RefreshRate
.Numerator
= 60;
15233 swapchain_desc
.BufferDesc
.RefreshRate
.Denominator
= 60;
15234 swapchain_desc
.BufferDesc
.ScanlineOrdering
= DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED
;
15235 swapchain_desc
.BufferDesc
.Scaling
= DXGI_MODE_SCALING_UNSPECIFIED
;
15236 swapchain_desc
.SampleDesc
.Count
= 1;
15237 swapchain_desc
.SampleDesc
.Quality
= 0;
15238 swapchain_desc
.BufferUsage
= DXGI_USAGE_RENDER_TARGET_OUTPUT
;
15239 swapchain_desc
.BufferCount
= 1;
15240 swapchain_desc
.OutputWindow
= CreateWindowA("static", "d3d11_test", 0, 0, 0, 0, 0, 0, 0, 0, 0);
15241 swapchain_desc
.Windowed
= TRUE
;
15242 swapchain_desc
.SwapEffect
= DXGI_SWAP_EFFECT_DISCARD
;
15243 swapchain_desc
.Flags
= 0;
15245 device_desc
.feature_level
= &feature_level
;
15246 device_desc
.flags
= 0;
15247 if (!(device
= create_device(&device_desc
)))
15249 skip("Failed to create device for feature level %#x.\n", feature_level
);
15253 hr
= ID3D11Device_QueryInterface(device
, &IID_IDXGIDevice
, (void **)&dxgi_device
);
15254 ok(SUCCEEDED(hr
), "Failed to query IDXGIDevice, hr %#x.\n", hr
);
15255 hr
= IDXGIDevice_GetAdapter(dxgi_device
, &adapter
);
15256 ok(SUCCEEDED(hr
), "GetAdapter failed, hr %#x.\n", hr
);
15257 IDXGIDevice_Release(dxgi_device
);
15258 hr
= IDXGIAdapter_GetParent(adapter
, &IID_IDXGIFactory
, (void **)&factory
);
15259 ok(SUCCEEDED(hr
), "GetParent failed, hr %#x.\n", hr
);
15260 IDXGIAdapter_Release(adapter
);
15262 swapchain_desc
.BufferDesc
.Format
= DXGI_FORMAT_R8G8B8A8_TYPELESS
;
15263 hr
= IDXGIFactory_CreateSwapChain(factory
, (IUnknown
*)device
, &swapchain_desc
, &swapchain
);
15264 todo_wine
ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x for typeless format (feature level %#x).\n",
15265 hr
, feature_level
);
15267 IDXGISwapChain_Release(swapchain
);
15269 for (i
= 0; i
< ARRAY_SIZE(display_format_support
); ++i
)
15271 DXGI_FORMAT format
= display_format_support
[i
].format
;
15274 if (display_format_support
[i
].fl_required
<= feature_level
)
15276 expected_hr
= S_OK
;
15277 if (format
== DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM
)
15280 else if (!display_format_support
[i
].fl_optional
15281 || display_format_support
[i
].fl_optional
> feature_level
)
15283 expected_hr
= E_INVALIDARG
;
15284 if (format
!= DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM
)
15292 swapchain_desc
.BufferDesc
.Format
= format
;
15293 hr
= IDXGIFactory_CreateSwapChain(factory
, (IUnknown
*)device
, &swapchain_desc
, &swapchain
);
15295 ok(hr
== expected_hr
|| broken(hr
== E_OUTOFMEMORY
),
15296 "Got hr %#x, expected %#x (feature level %#x, format %#x).\n",
15297 hr
, expected_hr
, feature_level
, format
);
15300 refcount
= IDXGISwapChain_Release(swapchain
);
15301 ok(!refcount
, "Swapchain has %u references left.\n", refcount
);
15304 refcount
= ID3D11Device_Release(device
);
15305 ok(!refcount
, "Device has %u references left.\n", refcount
);
15306 refcount
= IDXGIFactory_Release(factory
);
15307 ok(!refcount
, "Factory has %u references left.\n", refcount
);
15308 DestroyWindow(swapchain_desc
.OutputWindow
);
15311 static void test_swapchain_views(void)
15313 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
15314 struct d3d11_test_context test_context
;
15315 D3D11_RENDER_TARGET_VIEW_DESC rtv_desc
;
15316 ID3D11ShaderResourceView
*srv
;
15317 ID3D11DeviceContext
*context
;
15318 ID3D11RenderTargetView
*rtv
;
15319 ID3D11Device
*device
;
15323 static const struct vec4 color
= {0.2f
, 0.3f
, 0.5f
, 1.0f
};
15325 if (!init_test_context(&test_context
, NULL
))
15328 device
= test_context
.device
;
15329 context
= test_context
.immediate_context
;
15331 refcount
= get_refcount(test_context
.backbuffer
);
15332 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
15334 draw_color_quad(&test_context
, &color
);
15335 check_texture_color(test_context
.backbuffer
, 0xff7f4c33, 1);
15337 rtv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
;
15338 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_TEXTURE2D
;
15339 U(rtv_desc
).Texture2D
.MipSlice
= 0;
15340 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)test_context
.backbuffer
, &rtv_desc
, &rtv
);
15341 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
15342 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
15344 refcount
= get_refcount(test_context
.backbuffer
);
15345 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
15347 draw_color_quad(&test_context
, &color
);
15348 check_texture_color(test_context
.backbuffer
, 0xffbc957c, 1);
15350 srv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
;
15351 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_TEXTURE2D
;
15352 U(srv_desc
).Texture2D
.MostDetailedMip
= 0;
15353 U(srv_desc
).Texture2D
.MipLevels
= 1;
15354 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)test_context
.backbuffer
, &srv_desc
, &srv
);
15355 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
15357 ID3D11ShaderResourceView_Release(srv
);
15359 ID3D11RenderTargetView_Release(rtv
);
15360 release_test_context(&test_context
);
15363 static void test_swapchain_flip(void)
15365 ID3D11Texture2D
*backbuffer_0
, *backbuffer_1
, *backbuffer_2
, *offscreen
;
15366 ID3D11ShaderResourceView
*backbuffer_0_srv
, *backbuffer_1_srv
;
15367 ID3D11RenderTargetView
*backbuffer_0_rtv
, *offscreen_rtv
;
15368 D3D11_TEXTURE2D_DESC texture_desc
;
15369 ID3D11InputLayout
*input_layout
;
15370 ID3D11DeviceContext
*context
;
15371 unsigned int stride
, offset
;
15372 struct swapchain_desc desc
;
15373 IDXGISwapChain
*swapchain
;
15374 ID3D11VertexShader
*vs
;
15375 ID3D11PixelShader
*ps
;
15376 ID3D11Device
*device
;
15384 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
15386 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
15388 static const DWORD vs_code
[] =
15391 float4
main(float4 position
: POSITION
) : SV_POSITION
15396 0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003,
15397 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
15398 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
15399 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
15400 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
15401 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
15402 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
15405 static const DWORD ps_code
[] =
15411 float4
main(float4 position
: SV_POSITION
) : SV_Target
15417 if (position
.x
< 320)
15418 return t0
.Sample(s
, p
);
15419 return t1
.Sample(s
, p
);
15422 0x43425844, 0xc00961ea, 0x48558efd, 0x5eec7aed, 0xb597e6d1, 0x00000001, 0x00000188, 0x00000003,
15423 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
15424 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000010f, 0x505f5653, 0x5449534f, 0x004e4f49,
15425 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
15426 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000ec, 0x00000040,
15427 0x0000003b, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
15428 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x04002064, 0x00101012, 0x00000000, 0x00000001,
15429 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x07000031, 0x00100012, 0x00000000,
15430 0x0010100a, 0x00000000, 0x00004001, 0x43a00000, 0x0304001f, 0x0010000a, 0x00000000, 0x0c000045,
15431 0x001020f2, 0x00000000, 0x00004002, 0x3f000000, 0x3f000000, 0x00000000, 0x00000000, 0x00107e46,
15432 0x00000000, 0x00106000, 0x00000000, 0x0100003e, 0x01000015, 0x0c000045, 0x001020f2, 0x00000000,
15433 0x00004002, 0x3f000000, 0x3f000000, 0x00000000, 0x00000000, 0x00107e46, 0x00000001, 0x00106000,
15434 0x00000000, 0x0100003e,
15436 static const struct vec2 quad
[] =
15443 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
15444 static const float green
[] = {0.0f
, 1.0f
, 0.0f
, 0.5f
};
15445 static const float blue
[] = {0.0f
, 0.0f
, 1.0f
, 0.5f
};
15447 if (!(device
= create_device(NULL
)))
15449 skip("Failed to create device, skipping tests.\n");
15452 SetRect(&rect
, 0, 0, 640, 480);
15453 AdjustWindowRect(&rect
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
, FALSE
);
15454 window
= CreateWindowA("static", "d3d11_test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
15455 0, 0, rect
.right
- rect
.left
, rect
.bottom
- rect
.top
, NULL
, NULL
, NULL
, NULL
);
15456 desc
.buffer_count
= 3;
15457 desc
.width
= desc
.height
= 0;
15458 desc
.swap_effect
= DXGI_SWAP_EFFECT_SEQUENTIAL
;
15459 desc
.windowed
= TRUE
;
15460 desc
.flags
= SWAPCHAIN_FLAG_SHADER_INPUT
;
15461 swapchain
= create_swapchain(device
, window
, &desc
);
15463 hr
= IDXGISwapChain_GetBuffer(swapchain
, 0, &IID_ID3D11Texture2D
, (void **)&backbuffer_0
);
15464 ok(SUCCEEDED(hr
), "Failed to get buffer, hr %#x.\n", hr
);
15465 hr
= IDXGISwapChain_GetBuffer(swapchain
, 1, &IID_ID3D11Texture2D
, (void **)&backbuffer_1
);
15466 ok(SUCCEEDED(hr
), "Failed to get buffer, hr %#x.\n", hr
);
15467 hr
= IDXGISwapChain_GetBuffer(swapchain
, 2, &IID_ID3D11Texture2D
, (void **)&backbuffer_2
);
15468 ok(SUCCEEDED(hr
), "Failed to get buffer, hr %#x.\n", hr
);
15470 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)backbuffer_0
, NULL
, &backbuffer_0_rtv
);
15471 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
15472 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)backbuffer_0
, NULL
, &backbuffer_0_srv
);
15473 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
15474 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)backbuffer_1
, NULL
, &backbuffer_1_srv
);
15475 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
15477 ID3D11Texture2D_GetDesc(backbuffer_0
, &texture_desc
);
15478 ok((texture_desc
.BindFlags
& (D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
))
15479 == (D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
),
15480 "Got unexpected bind flags %x.\n", texture_desc
.BindFlags
);
15481 ok(texture_desc
.Usage
== D3D11_USAGE_DEFAULT
, "Got unexpected usage %u.\n", texture_desc
.Usage
);
15483 ID3D11Texture2D_GetDesc(backbuffer_1
, &texture_desc
);
15484 ok((texture_desc
.BindFlags
& (D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
))
15485 == (D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
),
15486 "Got unexpected bind flags %x.\n", texture_desc
.BindFlags
);
15487 ok(texture_desc
.Usage
== D3D11_USAGE_DEFAULT
, "Got unexpected usage %u.\n", texture_desc
.Usage
);
15489 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)backbuffer_1
, NULL
, &offscreen_rtv
);
15490 todo_wine
ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
15492 ID3D11RenderTargetView_Release(offscreen_rtv
);
15494 ID3D11Device_GetImmediateContext(device
, &context
);
15496 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &backbuffer_0_srv
);
15497 ID3D11DeviceContext_PSSetShaderResources(context
, 1, 1, &backbuffer_1_srv
);
15499 texture_desc
.Width
= 640;
15500 texture_desc
.Height
= 480;
15501 texture_desc
.MipLevels
= 1;
15502 texture_desc
.ArraySize
= 1;
15503 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
15504 texture_desc
.SampleDesc
.Count
= 1;
15505 texture_desc
.SampleDesc
.Quality
= 0;
15506 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
15507 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
15508 texture_desc
.CPUAccessFlags
= 0;
15509 texture_desc
.MiscFlags
= 0;
15510 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &offscreen
);
15511 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
15512 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)offscreen
, NULL
, &offscreen_rtv
);
15513 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
15514 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &offscreen_rtv
, NULL
);
15515 set_viewport(context
, 0.0f
, 0.0f
, 640.0f
, 480.0f
, 0.0f
, 1.0f
);
15517 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(quad
), quad
);
15519 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
15520 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
15521 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
15522 vs_code
, sizeof(vs_code
), &input_layout
);
15523 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
15524 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
15525 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
15526 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
15527 stride
= sizeof(*quad
);
15529 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, &stride
, &offset
);
15531 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
15532 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
15533 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
15535 ID3D11DeviceContext_ClearRenderTargetView(context
, backbuffer_0_rtv
, red
);
15537 ID3D11DeviceContext_Draw(context
, 4, 0);
15538 color
= get_texture_color(offscreen
, 120, 240);
15539 ok(compare_color(color
, 0x7f0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
15541 /* DXGI moves buffers in the same direction as earlier versions. Buffer 2
15542 * becomes buffer 1, buffer 1 becomes the new buffer 0, and buffer 0
15543 * becomes buffer n - 1. However, only buffer 0 can be rendered to.
15545 * What is this good for? I don't know. Ad-hoc tests suggest that
15546 * Present() always waits for the next V-sync interval, even if there are
15547 * still untouched buffers. Buffer 0 is the buffer that is shown on the
15548 * screen, just like in <= d3d9. Present() also doesn't discard buffers if
15549 * rendering finishes before the V-sync interval is over. I haven't found
15550 * any productive use for more than one buffer. */
15551 IDXGISwapChain_Present(swapchain
, 0, 0);
15553 ID3D11DeviceContext_ClearRenderTargetView(context
, backbuffer_0_rtv
, green
);
15555 ID3D11DeviceContext_Draw(context
, 4, 0);
15556 color
= get_texture_color(offscreen
, 120, 240); /* green, buf 0 */
15557 ok(compare_color(color
, 0x7f00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
15558 /* Buffer 1 is still untouched. */
15560 color
= get_texture_color(backbuffer_0
, 320, 240); /* green */
15561 ok(compare_color(color
, 0x7f00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
15562 color
= get_texture_color(backbuffer_2
, 320, 240); /* red */
15563 ok(compare_color(color
, 0x7f0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
15565 IDXGISwapChain_Present(swapchain
, 0, 0);
15567 ID3D11DeviceContext_ClearRenderTargetView(context
, backbuffer_0_rtv
, blue
);
15569 ID3D11DeviceContext_Draw(context
, 4, 0);
15570 color
= get_texture_color(offscreen
, 120, 240); /* blue, buf 0 */
15571 ok(compare_color(color
, 0x7fff0000, 1), "Got unexpected color 0x%08x.\n", color
);
15572 color
= get_texture_color(offscreen
, 360, 240); /* red, buf 1 */
15573 ok(compare_color(color
, 0x7f0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
15575 color
= get_texture_color(backbuffer_0
, 320, 240); /* blue */
15576 ok(compare_color(color
, 0x7fff0000, 1), "Got unexpected color 0x%08x.\n", color
);
15577 color
= get_texture_color(backbuffer_1
, 320, 240); /* red */
15578 ok(compare_color(color
, 0x7f0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
15579 color
= get_texture_color(backbuffer_2
, 320, 240); /* green */
15580 ok(compare_color(color
, 0x7f00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
15582 ID3D11VertexShader_Release(vs
);
15583 ID3D11PixelShader_Release(ps
);
15584 ID3D11Buffer_Release(vb
);
15585 ID3D11InputLayout_Release(input_layout
);
15586 ID3D11ShaderResourceView_Release(backbuffer_0_srv
);
15587 ID3D11ShaderResourceView_Release(backbuffer_1_srv
);
15588 ID3D11RenderTargetView_Release(backbuffer_0_rtv
);
15589 ID3D11RenderTargetView_Release(offscreen_rtv
);
15590 ID3D11Texture2D_Release(offscreen
);
15591 ID3D11Texture2D_Release(backbuffer_0
);
15592 ID3D11Texture2D_Release(backbuffer_1
);
15593 ID3D11Texture2D_Release(backbuffer_2
);
15594 IDXGISwapChain_Release(swapchain
);
15596 ID3D11DeviceContext_Release(context
);
15597 refcount
= ID3D11Device_Release(device
);
15598 ok(!refcount
, "Device has %u references left.\n", refcount
);
15599 DestroyWindow(window
);
15602 static void test_clear_render_target_view_1d(void)
15604 static const float color
[] = {0.1f
, 0.5f
, 0.3f
, 0.75f
};
15605 static const float green
[] = {0.0f
, 1.0f
, 0.0f
, 0.5f
};
15607 struct d3d11_test_context test_context
;
15608 D3D11_TEXTURE1D_DESC texture_desc
;
15609 ID3D11DeviceContext
*context
;
15610 ID3D11RenderTargetView
*rtv
;
15611 ID3D11Texture1D
*texture
;
15612 ID3D11Device
*device
;
15615 if (!init_test_context(&test_context
, NULL
))
15618 device
= test_context
.device
;
15619 context
= test_context
.immediate_context
;
15621 texture_desc
.Width
= 64;
15622 texture_desc
.MipLevels
= 1;
15623 texture_desc
.ArraySize
= 1;
15624 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
15625 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
15626 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
15627 texture_desc
.CPUAccessFlags
= 0;
15628 texture_desc
.MiscFlags
= 0;
15629 hr
= ID3D11Device_CreateTexture1D(device
, &texture_desc
, NULL
, &texture
);
15630 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
15632 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
15633 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
15635 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, color
);
15636 check_texture1d_color(texture
, 0xbf4c7f19, 1);
15638 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, green
);
15639 check_texture1d_color(texture
, 0x8000ff00, 1);
15641 ID3D11RenderTargetView_Release(rtv
);
15642 ID3D11Texture1D_Release(texture
);
15643 release_test_context(&test_context
);
15646 static void test_clear_render_target_view_2d(void)
15648 static const DWORD expected_color
= 0xbf4c7f19, expected_srgb_color
= 0xbf95bc59;
15649 static const float clear_colour
[] = {0.1f
, 0.5f
, 0.3f
, 0.75f
};
15650 static const float green
[] = {0.0f
, 1.0f
, 0.0f
, 0.5f
};
15651 static const float blue
[] = {0.0f
, 0.0f
, 1.0f
, 0.5f
};
15653 ID3D11RenderTargetView
*rtv
[3], *srgb_rtv
;
15654 ID3D11Texture2D
*texture
, *srgb_texture
;
15655 struct d3d11_test_context test_context
;
15656 D3D11_RENDER_TARGET_VIEW_DESC rtv_desc
;
15657 D3D11_TEXTURE2D_DESC texture_desc
;
15658 ID3D11DeviceContext
*context
;
15659 struct resource_readback rb
;
15660 ID3D11Device
*device
;
15665 if (!init_test_context(&test_context
, NULL
))
15668 device
= test_context
.device
;
15669 context
= test_context
.immediate_context
;
15671 texture_desc
.Width
= 640;
15672 texture_desc
.Height
= 480;
15673 texture_desc
.MipLevels
= 1;
15674 texture_desc
.ArraySize
= 1;
15675 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
15676 texture_desc
.SampleDesc
.Count
= 1;
15677 texture_desc
.SampleDesc
.Quality
= 0;
15678 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
15679 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
15680 texture_desc
.CPUAccessFlags
= 0;
15681 texture_desc
.MiscFlags
= 0;
15682 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
15683 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
15685 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
;
15686 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &srgb_texture
);
15687 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
15689 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
[0]);
15690 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
15692 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)srgb_texture
, NULL
, &srgb_rtv
);
15693 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
15695 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, clear_colour
);
15696 check_texture_color(test_context
.backbuffer
, expected_color
, 1);
15698 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
[0], clear_colour
);
15699 check_texture_color(texture
, expected_color
, 1);
15701 if (!enable_debug_layer
)
15702 ID3D11DeviceContext_ClearRenderTargetView(context
, NULL
, green
);
15703 check_texture_color(texture
, expected_color
, 1);
15705 ID3D11DeviceContext_ClearRenderTargetView(context
, srgb_rtv
, clear_colour
);
15706 check_texture_color(srgb_texture
, expected_srgb_color
, 1);
15708 ID3D11RenderTargetView_Release(srgb_rtv
);
15709 ID3D11RenderTargetView_Release(rtv
[0]);
15710 ID3D11Texture2D_Release(srgb_texture
);
15711 ID3D11Texture2D_Release(texture
);
15713 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_TYPELESS
;
15714 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
15715 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
15717 rtv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
;
15718 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_TEXTURE2D
;
15719 U(rtv_desc
).Texture2D
.MipSlice
= 0;
15720 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, &rtv_desc
, &srgb_rtv
);
15721 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
15723 rtv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
15724 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_TEXTURE2D
;
15725 U(rtv_desc
).Texture2D
.MipSlice
= 0;
15726 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, &rtv_desc
, &rtv
[0]);
15727 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
15729 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
[0], clear_colour
);
15730 check_texture_color(texture
, expected_color
, 1);
15732 ID3D11DeviceContext_ClearRenderTargetView(context
, srgb_rtv
, clear_colour
);
15733 get_texture_readback(texture
, 0, &rb
);
15734 for (i
= 0; i
< 4; ++i
)
15736 for (j
= 0; j
< 4; ++j
)
15738 BOOL broken_device
= is_warp_device(device
) || is_nvidia_device(device
);
15739 colour
= get_readback_color(&rb
, 80 + i
* 160, 60 + j
* 120, 0);
15740 ok(compare_color(colour
, expected_srgb_color
, 1)
15741 || broken(compare_color(colour
, expected_color
, 1) && broken_device
),
15742 "Got unexpected colour 0x%08x.\n", colour
);
15745 release_resource_readback(&rb
);
15747 ID3D11RenderTargetView_Release(srgb_rtv
);
15748 ID3D11RenderTargetView_Release(rtv
[0]);
15749 ID3D11Texture2D_Release(texture
);
15751 texture_desc
.Width
= 16;
15752 texture_desc
.Height
= 16;
15753 texture_desc
.ArraySize
= 5;
15754 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
15755 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
15757 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_TEXTURE2DARRAY
;
15758 U(rtv_desc
).Texture2DArray
.MipSlice
= 0;
15759 U(rtv_desc
).Texture2DArray
.FirstArraySlice
= 0;
15760 U(rtv_desc
).Texture2DArray
.ArraySize
= 5;
15761 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, &rtv_desc
, &rtv
[0]);
15762 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
15764 U(rtv_desc
).Texture2DArray
.FirstArraySlice
= 1;
15765 U(rtv_desc
).Texture2DArray
.ArraySize
= 3;
15766 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, &rtv_desc
, &rtv
[1]);
15767 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
15769 U(rtv_desc
).Texture2DArray
.FirstArraySlice
= 2;
15770 U(rtv_desc
).Texture2DArray
.ArraySize
= 1;
15771 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, &rtv_desc
, &rtv
[2]);
15772 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
15774 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
[0], blue
);
15775 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
[1], green
);
15776 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
[2], clear_colour
);
15778 get_texture_readback(texture
, 0, &rb
);
15779 colour
= get_readback_color(&rb
, 8, 8, 0);
15780 ok(compare_color(colour
, 0x80ff0000, 1), "Got unexpected colour 0x%08x.\n", colour
);
15781 release_resource_readback(&rb
);
15783 get_texture_readback(texture
, 1, &rb
);
15784 colour
= get_readback_color(&rb
, 8, 8, 0);
15785 ok(compare_color(colour
, 0x8000ff00, 1), "Got unexpected colour 0x%08x.\n", colour
);
15786 release_resource_readback(&rb
);
15788 get_texture_readback(texture
, 2, &rb
);
15789 colour
= get_readback_color(&rb
, 8, 8, 0);
15790 ok(compare_color(colour
, 0xbf4c7f19, 1), "Got unexpected colour 0x%08x.\n", colour
);
15791 release_resource_readback(&rb
);
15793 get_texture_readback(texture
, 3, &rb
);
15794 colour
= get_readback_color(&rb
, 8, 8, 0);
15795 ok(compare_color(colour
, 0x8000ff00, 1), "Got unexpected colour 0x%08x.\n", colour
);
15796 release_resource_readback(&rb
);
15798 get_texture_readback(texture
, 4, &rb
);
15799 colour
= get_readback_color(&rb
, 8, 8, 0);
15800 ok(compare_color(colour
, 0x80ff0000, 1), "Got unexpected colour 0x%08x.\n", colour
);
15801 release_resource_readback(&rb
);
15803 ID3D11RenderTargetView_Release(rtv
[2]);
15804 ID3D11RenderTargetView_Release(rtv
[1]);
15805 ID3D11RenderTargetView_Release(rtv
[0]);
15806 ID3D11Texture2D_Release(texture
);
15808 release_test_context(&test_context
);
15811 static void test_clear_render_target_view_3d(void)
15813 static const float color
[] = {0.1f
, 0.5f
, 0.3f
, 0.75f
};
15814 static const float green
[] = {0.0f
, 1.0f
, 0.0f
, 0.5f
};
15816 struct d3d11_test_context test_context
;
15817 D3D11_RENDER_TARGET_VIEW_DESC rtv_desc
;
15818 D3D11_TEXTURE3D_DESC texture_desc
;
15819 ID3D11DeviceContext
*context
;
15820 ID3D11RenderTargetView
*rtv
;
15821 ID3D11Texture3D
*texture
;
15822 ID3D11Device
*device
;
15825 if (!init_test_context(&test_context
, NULL
))
15827 device
= test_context
.device
;
15828 context
= test_context
.immediate_context
;
15830 texture_desc
.Width
= 8;
15831 texture_desc
.Height
= 8;
15832 texture_desc
.Depth
= 4;
15833 texture_desc
.MipLevels
= 1;
15834 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
15835 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
15836 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
15837 texture_desc
.CPUAccessFlags
= 0;
15838 texture_desc
.MiscFlags
= 0;
15839 hr
= ID3D11Device_CreateTexture3D(device
, &texture_desc
, NULL
, &texture
);
15840 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
15842 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
15843 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
15845 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, color
);
15846 check_texture3d_color(texture
, 0xbf4c7f19, 1);
15847 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, green
);
15848 check_texture3d_color(texture
, 0x8000ff00, 1);
15850 ID3D11RenderTargetView_Release(rtv
);
15851 ID3D11Texture3D_Release(texture
);
15853 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_TYPELESS
;
15854 hr
= ID3D11Device_CreateTexture3D(device
, &texture_desc
, NULL
, &texture
);
15855 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
15857 rtv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
;
15858 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_TEXTURE3D
;
15859 U(rtv_desc
).Texture3D
.MipSlice
= 0;
15860 U(rtv_desc
).Texture3D
.FirstWSlice
= 0;
15861 U(rtv_desc
).Texture3D
.WSize
= ~0u;
15862 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, &rtv_desc
, &rtv
);
15863 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
15865 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, color
);
15866 check_texture3d_color(texture
, 0xbf95bc59, 1);
15867 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, green
);
15868 check_texture3d_color(texture
, 0x8000ff00, 1);
15870 ID3D11RenderTargetView_Release(rtv
);
15871 ID3D11Texture3D_Release(texture
);
15872 release_test_context(&test_context
);
15875 static void test_clear_depth_stencil_view(void)
15877 D3D11_TEXTURE2D_DESC texture_desc
;
15878 ID3D11Texture2D
*depth_texture
;
15879 ID3D11DeviceContext
*context
;
15880 ID3D11DepthStencilView
*dsv
;
15881 ID3D11Device
*device
;
15885 if (!(device
= create_device(NULL
)))
15887 skip("Failed to create device.\n");
15891 ID3D11Device_GetImmediateContext(device
, &context
);
15893 texture_desc
.Width
= 640;
15894 texture_desc
.Height
= 480;
15895 texture_desc
.MipLevels
= 1;
15896 texture_desc
.ArraySize
= 1;
15897 texture_desc
.Format
= DXGI_FORMAT_D32_FLOAT
;
15898 texture_desc
.SampleDesc
.Count
= 1;
15899 texture_desc
.SampleDesc
.Quality
= 0;
15900 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
15901 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
15902 texture_desc
.CPUAccessFlags
= 0;
15903 texture_desc
.MiscFlags
= 0;
15904 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &depth_texture
);
15905 ok(SUCCEEDED(hr
), "Failed to create depth texture, hr %#x.\n", hr
);
15907 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)depth_texture
, NULL
, &dsv
);
15908 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
15910 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
15911 check_texture_float(depth_texture
, 1.0f
, 0);
15913 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 0.25f
, 0);
15914 check_texture_float(depth_texture
, 0.25f
, 0);
15916 if (!enable_debug_layer
)
15917 ID3D11DeviceContext_ClearDepthStencilView(context
, NULL
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
15918 check_texture_float(depth_texture
, 0.25f
, 0);
15920 ID3D11Texture2D_Release(depth_texture
);
15921 ID3D11DepthStencilView_Release(dsv
);
15923 texture_desc
.Format
= DXGI_FORMAT_D24_UNORM_S8_UINT
;
15924 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &depth_texture
);
15925 ok(SUCCEEDED(hr
), "Failed to create depth texture, hr %#x.\n", hr
);
15927 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)depth_texture
, NULL
, &dsv
);
15928 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
15930 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
| D3D11_CLEAR_STENCIL
, 1.0f
, 0);
15931 todo_wine
check_texture_color(depth_texture
, 0x00ffffff, 0);
15933 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
| D3D11_CLEAR_STENCIL
, 0.0f
, 0xff);
15934 todo_wine
check_texture_color(depth_texture
, 0xff000000, 0);
15936 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
| D3D11_CLEAR_STENCIL
, 1.0f
, 0xff);
15937 check_texture_color(depth_texture
, 0xffffffff, 0);
15939 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
| D3D11_CLEAR_STENCIL
, 0.0f
, 0);
15940 check_texture_color(depth_texture
, 0x00000000, 0);
15942 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0xff);
15943 todo_wine
check_texture_color(depth_texture
, 0x00ffffff, 0);
15945 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_STENCIL
, 0.0f
, 0xff);
15946 check_texture_color(depth_texture
, 0xffffffff, 0);
15948 ID3D11Texture2D_Release(depth_texture
);
15949 ID3D11DepthStencilView_Release(dsv
);
15951 ID3D11DeviceContext_Release(context
);
15953 refcount
= ID3D11Device_Release(device
);
15954 ok(!refcount
, "Device has %u references left.\n", refcount
);
15957 static unsigned int to_sint8(unsigned int x
)
15965 return min(max(bits
.s
, -128), 127) & 0xff;
15968 #define check_rgba_sint8(data, uvec) check_rgba_sint8_(__LINE__, data, uvec)
15969 static void check_rgba_sint8_(unsigned int line
, DWORD data
, const struct uvec4
*v
)
15971 unsigned int x
= to_sint8(v
->x
);
15972 unsigned int y
= to_sint8(v
->y
);
15973 unsigned int z
= to_sint8(v
->z
);
15974 unsigned int w
= to_sint8(v
->w
);
15977 /* Windows 7 - Nvidia, WARP */
15978 (v
->x
& 0xff) | (v
->y
& 0xff) << 8 | (v
->z
& 0xff) << 16 | (v
->w
& 0xff) << 24,
15979 /* Windows 10 - AMD */
15980 x
| y
<< 8 | z
<< 16 | w
<< 24,
15981 /* Windows 10 - Intel */
15982 x
| x
<< 8 | x
<< 16 | x
<< 24,
15985 ok_(__FILE__
, line
)(data
== expected
[0] || data
== expected
[1] || broken(data
== expected
[2]),
15986 "Got %#x, expected %#x or %#x at %u, uvec4 %#x, %#x, %#x, %#x.\n",
15987 data
, expected
[0], expected
[1], x
, v
->x
, v
->y
, v
->z
, v
->w
);
15990 static void test_clear_buffer_unordered_access_view(void)
15992 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
15993 ID3D11UnorderedAccessView
*uav
, *uav2
;
15994 struct device_desc device_desc
;
15995 D3D11_BUFFER_DESC buffer_desc
;
15996 ID3D11DeviceContext
*context
;
15997 struct resource_readback rb
;
15998 ID3D11Buffer
*buffer
;
15999 ID3D11Device
*device
;
16000 struct uvec4 uvec4
;
16006 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
16007 static const struct uvec4 fe_uvec4
= {0xfefefefe, 0xfefefefe, 0xfefefefe, 0xfefefefe};
16008 static const struct uvec4 uvec4_data
[] =
16010 {0x00000000, 0x00000000, 0x00000000, 0x00000000},
16012 {0x00000000, 0xffffffff, 0xffffffff, 0xffffffff},
16013 {0xffffffff, 0x00000000, 0x00000000, 0x00000000},
16014 {0x00000000, 0xffffffff, 0x00000000, 0x00000000},
16015 {0x00000000, 0x00000000, 0xffffffff, 0x00000000},
16016 {0x00000000, 0x00000000, 0x00000000, 0xffffffff},
16018 {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff},
16019 {0x80000000, 0x80000000, 0x80000000, 0x80000000},
16020 {0x000000ff, 0x00000080, 0x80000080, 0x00000080},
16021 {0x000000ff, 0x0000007f, 0x000000ef, 0x000000fe},
16022 {0x800000ff, 0x8000007f, 0x800000ef, 0x800000fe},
16023 {0xfefefefe, 0xf0f0f0f0, 0xefefefef, 0x0f0f0f0f},
16024 {0xaaaaaaaa, 0xdeadbeef, 0xdeadbabe, 0xdeadf00d},
16026 {0x00000001, 0x00000002, 0x00000003, 0x00000004},
16027 {0x000000ff, 0x000000fe, 0x000000fd, 0x000000fc},
16028 {0x000000f2, 0x000000f1, 0x000000f0, 0x000000ef},
16029 {0x0000000a, 0x0000000d, 0x0000000e, 0x0000000f},
16030 {0x0000001a, 0x0000002d, 0x0000003e, 0x0000004f},
16031 {0x00000050, 0x00000060, 0x00000070, 0x00000080},
16032 {0x00000090, 0x000000a0, 0x000000b0, 0x000000c0},
16033 {0x000000d0, 0x000000e0, 0x000000f0, 0x000000ff},
16034 {0x00000073, 0x00000077, 0x0000007a, 0x0000007b},
16035 {0x0000007c, 0x0000007d, 0x0000007e, 0x0000007f},
16037 {0x80000001, 0x80000002, 0x80000003, 0x80000004},
16038 {0x800000ff, 0x800000fe, 0x800000fd, 0x800000fc},
16039 {0x800000f2, 0x800000f1, 0x800000f0, 0x800000ef},
16040 {0x8000000a, 0x0000000d, 0x8000000e, 0x8000000f},
16041 {0x8000001a, 0x8000002d, 0x8000003e, 0x8000004f},
16042 {0x80000050, 0x80000060, 0x80000070, 0x00000080},
16043 {0x80000090, 0x800000a0, 0x800000b0, 0x800000c0},
16044 {0x800000d0, 0x800000e0, 0x800000f0, 0x800000ff},
16045 {0x80000073, 0x80000077, 0x8000007a, 0x8000007b},
16046 {0x8000007c, 0x8000007d, 0x8000007e, 0x8000007f},
16048 {0x7fffff01, 0x7fffff02, 0x7fffff03, 0x7fffff04},
16049 {0x7fffffff, 0x7ffffffe, 0x7ffffffd, 0x7ffffffc},
16050 {0x7ffffff2, 0x7ffffff1, 0x7ffffff0, 0x7fffffef},
16051 {0x7fffff0a, 0x7fffff0d, 0x7fffff0e, 0x7fffff0f},
16052 {0x7fffff1a, 0x7fffff2d, 0x7fffff3e, 0x7fffff4f},
16053 {0x7fffff50, 0x7fffff60, 0x7fffff70, 0x7fffff80},
16054 {0x8fffff90, 0x7fffffa0, 0x7fffffb0, 0x7fffffc0},
16055 {0x7fffffd0, 0x7fffffe0, 0x7ffffff0, 0x7fffffff},
16056 {0x7fffff73, 0x7fffff77, 0x7fffff7a, 0x7fffff7b},
16057 {0x7fffff7c, 0x7fffff7d, 0x7fffff7e, 0x7fffff7f},
16059 {0xffffff01, 0xffffff02, 0xffffff03, 0xffffff04},
16060 {0xffffffff, 0xfffffffe, 0xfffffffd, 0xfffffffc},
16061 {0xfffffff2, 0xfffffff1, 0xfffffff0, 0xffffffef},
16062 {0xffffff0a, 0xffffff0d, 0xffffff0e, 0xffffff0f},
16063 {0xffffff1a, 0xffffff2d, 0xffffff3e, 0xffffff4f},
16064 {0xffffff50, 0xffffff60, 0xffffff70, 0xffffff80},
16065 {0xffffff90, 0xffffffa0, 0xffffffb0, 0xffffffc0},
16066 {0xffffffd0, 0xffffffe0, 0xfffffff0, 0xffffffff},
16067 {0xffffff73, 0xffffff77, 0xffffff7a, 0xffffff7b},
16068 {0xffffff7c, 0xffffff7d, 0xffffff7e, 0xffffff7f},
16071 device_desc
.feature_level
= &feature_level
;
16072 device_desc
.flags
= 0;
16073 if (!(device
= create_device(&device_desc
)))
16075 skip("Failed to create device for feature level %#x.\n", feature_level
);
16079 ID3D11Device_GetImmediateContext(device
, &context
);
16081 /* Structured buffer views */
16082 buffer_desc
.ByteWidth
= 64;
16083 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
16084 buffer_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
16085 buffer_desc
.CPUAccessFlags
= 0;
16086 buffer_desc
.MiscFlags
= 0;
16087 buffer_desc
.StructureByteStride
= 0;
16088 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
;
16089 buffer_desc
.StructureByteStride
= 4;
16090 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
16091 ok(hr
== S_OK
, "Failed to create a buffer, hr %#x.\n", hr
);
16093 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, NULL
, &uav
);
16094 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
16096 uav_desc
.Format
= DXGI_FORMAT_UNKNOWN
;
16097 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
16098 U(uav_desc
).Buffer
.FirstElement
= 0;
16099 U(uav_desc
).Buffer
.NumElements
= 4;
16100 U(uav_desc
).Buffer
.Flags
= 0;
16101 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav2
);
16102 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
16104 for (i
= 0; i
< ARRAY_SIZE(uvec4_data
); ++i
)
16106 uvec4
= uvec4_data
[i
];
16107 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, &uvec4
.x
);
16108 get_buffer_readback(buffer
, &rb
);
16109 SetRect(&rect
, 0, 0, buffer_desc
.ByteWidth
/ sizeof(uvec4
.x
), 1);
16110 check_readback_data_color(&rb
, &rect
, uvec4
.x
, 0);
16111 release_resource_readback(&rb
);
16113 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav2
, &fe_uvec4
.x
);
16114 get_buffer_readback(buffer
, &rb
);
16115 SetRect(&rect
, 0, 0, U(uav_desc
).Buffer
.NumElements
, 1);
16116 check_readback_data_color(&rb
, &rect
, fe_uvec4
.x
, 0);
16117 SetRect(&rect
, U(uav_desc
).Buffer
.NumElements
, 0, buffer_desc
.ByteWidth
/ sizeof(uvec4
.x
), 1);
16118 check_readback_data_color(&rb
, &rect
, uvec4
.x
, 0);
16119 release_resource_readback(&rb
);
16122 ID3D11Buffer_Release(buffer
);
16123 ID3D11UnorderedAccessView_Release(uav
);
16124 ID3D11UnorderedAccessView_Release(uav2
);
16126 /* Raw buffer views */
16127 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
;
16128 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
16129 ok(hr
== S_OK
, "Failed to create a buffer, hr %#x.\n", hr
);
16131 uav_desc
.Format
= DXGI_FORMAT_R32_TYPELESS
;
16132 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
16133 U(uav_desc
).Buffer
.FirstElement
= 0;
16134 U(uav_desc
).Buffer
.NumElements
= 16;
16135 U(uav_desc
).Buffer
.Flags
= D3D11_BUFFER_UAV_FLAG_RAW
;
16136 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
16137 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
16138 U(uav_desc
).Buffer
.FirstElement
= 8;
16139 U(uav_desc
).Buffer
.NumElements
= 8;
16140 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav2
);
16141 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
16143 for (i
= 0; i
< ARRAY_SIZE(uvec4_data
); ++i
)
16145 uvec4
= uvec4_data
[i
];
16146 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, &uvec4
.x
);
16147 get_buffer_readback(buffer
, &rb
);
16148 SetRect(&rect
, 0, 0, buffer_desc
.ByteWidth
/ sizeof(uvec4
.x
), 1);
16149 check_readback_data_color(&rb
, &rect
, uvec4
.x
, 0);
16150 release_resource_readback(&rb
);
16152 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav2
, &fe_uvec4
.x
);
16153 get_buffer_readback(buffer
, &rb
);
16154 SetRect(&rect
, 0, 0, U(uav_desc
).Buffer
.FirstElement
, 1);
16155 check_readback_data_color(&rb
, &rect
, uvec4
.x
, 0);
16156 SetRect(&rect
, U(uav_desc
).Buffer
.FirstElement
, 0, buffer_desc
.ByteWidth
/ sizeof(uvec4
.x
), 1);
16157 check_readback_data_color(&rb
, &rect
, fe_uvec4
.x
, 0);
16158 release_resource_readback(&rb
);
16161 ID3D11Buffer_Release(buffer
);
16162 ID3D11UnorderedAccessView_Release(uav
);
16163 ID3D11UnorderedAccessView_Release(uav2
);
16165 /* Typed buffer views */
16166 buffer_desc
.MiscFlags
= 0;
16167 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
16168 ok(hr
== S_OK
, "Failed to create a buffer, hr %#x.\n", hr
);
16170 uav_desc
.Format
= DXGI_FORMAT_R32_SINT
;
16171 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
16172 U(uav_desc
).Buffer
.FirstElement
= 0;
16173 U(uav_desc
).Buffer
.NumElements
= 16;
16174 U(uav_desc
).Buffer
.Flags
= 0;
16175 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
16176 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
16177 U(uav_desc
).Buffer
.FirstElement
= 9;
16178 U(uav_desc
).Buffer
.NumElements
= 7;
16179 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav2
);
16180 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
16182 for (i
= 0; i
< ARRAY_SIZE(uvec4_data
); ++i
)
16184 uvec4
= uvec4_data
[i
];
16185 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, &uvec4
.x
);
16186 get_buffer_readback(buffer
, &rb
);
16187 SetRect(&rect
, 0, 0, buffer_desc
.ByteWidth
/ sizeof(uvec4
.x
), 1);
16188 check_readback_data_color(&rb
, &rect
, uvec4
.x
, 0);
16189 release_resource_readback(&rb
);
16191 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav2
, &fe_uvec4
.x
);
16192 get_buffer_readback(buffer
, &rb
);
16193 SetRect(&rect
, 0, 0, U(uav_desc
).Buffer
.FirstElement
, 1);
16194 check_readback_data_color(&rb
, &rect
, uvec4
.x
, 0);
16195 SetRect(&rect
, U(uav_desc
).Buffer
.FirstElement
, 0, buffer_desc
.ByteWidth
/ sizeof(uvec4
.x
), 1);
16196 check_readback_data_color(&rb
, &rect
, fe_uvec4
.x
, 0);
16197 release_resource_readback(&rb
);
16200 ID3D11UnorderedAccessView_Release(uav
);
16201 ID3D11UnorderedAccessView_Release(uav2
);
16203 uav_desc
.Format
= DXGI_FORMAT_R32G32B32A32_SINT
;
16204 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
16205 U(uav_desc
).Buffer
.FirstElement
= 0;
16206 U(uav_desc
).Buffer
.NumElements
= 4;
16207 U(uav_desc
).Buffer
.Flags
= 0;
16208 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
16209 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
16210 U(uav_desc
).Buffer
.FirstElement
= 2;
16211 U(uav_desc
).Buffer
.NumElements
= 2;
16212 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav2
);
16213 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
16215 for (i
= 0; i
< ARRAY_SIZE(uvec4_data
); ++i
)
16217 const struct uvec4
*data
= NULL
;
16220 uvec4
= uvec4_data
[i
];
16221 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, &uvec4
.x
);
16222 get_buffer_readback(buffer
, &rb
);
16223 for (x
= 0, all_match
= TRUE
; x
< buffer_desc
.ByteWidth
/ sizeof(uvec4
); ++x
)
16225 const struct uvec4 broken_result
= {uvec4
.x
, uvec4
.x
, uvec4
.x
, uvec4
.x
}; /* Intel */
16226 data
= get_readback_uvec4(&rb
, x
, 0);
16227 if (!(compare_uvec4(data
, &uvec4
) || broken(compare_uvec4(data
, &broken_result
))))
16233 ok(all_match
, "Got {%#x, %#x, %#x, %#x}, expected {%#x, %#x, %#x, %#x} at %u.\n",
16234 data
->x
, data
->y
, data
->z
, data
->w
, uvec4
.x
, uvec4
.y
, uvec4
.z
, uvec4
.w
, x
);
16235 release_resource_readback(&rb
);
16237 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav2
, &fe_uvec4
.x
);
16238 get_buffer_readback(buffer
, &rb
);
16239 for (x
= 0, all_match
= TRUE
; x
< buffer_desc
.ByteWidth
/ sizeof(uvec4
); ++x
)
16241 struct uvec4 broken_result
;
16242 data
= get_readback_uvec4(&rb
, x
, 0);
16243 uvec4
= U(uav_desc
).Buffer
.FirstElement
<= x
? fe_uvec4
: uvec4_data
[i
];
16244 broken_result
.x
= broken_result
.y
= broken_result
.z
= broken_result
.w
= uvec4
.x
;
16245 if (!(compare_uvec4(data
, &uvec4
) || broken(compare_uvec4(data
, &broken_result
))))
16251 ok(all_match
, "Got {%#x, %#x, %#x, %#x}, expected {%#x, %#x, %#x, %#x} at %u.\n",
16252 data
->x
, data
->y
, data
->z
, data
->w
, uvec4
.x
, uvec4
.y
, uvec4
.z
, uvec4
.w
, x
);
16253 release_resource_readback(&rb
);
16256 uvec4
.x
= uvec4
.y
= uvec4
.z
= uvec4
.w
= 0xdeadbeef;
16257 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, &uvec4
.x
);
16258 ID3D11UnorderedAccessView_Release(uav
);
16259 ID3D11UnorderedAccessView_Release(uav2
);
16261 uav_desc
.Format
= DXGI_FORMAT_R8G8B8A8_SINT
;
16262 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
16263 U(uav_desc
).Buffer
.FirstElement
= 0;
16264 U(uav_desc
).Buffer
.NumElements
= 16;
16265 U(uav_desc
).Buffer
.Flags
= 0;
16266 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
16267 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
16268 U(uav_desc
).Buffer
.FirstElement
= 8;
16269 U(uav_desc
).Buffer
.NumElements
= 8;
16270 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav2
);
16271 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
16273 for (i
= 0; i
< ARRAY_SIZE(uvec4_data
); ++i
)
16275 uvec4
= uvec4_data
[i
];
16276 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, &uvec4
.x
);
16277 get_buffer_readback(buffer
, &rb
);
16278 todo_wine
check_rgba_sint8(get_readback_color(&rb
, 0, 0, 0), &uvec4
);
16279 todo_wine
check_rgba_sint8(get_readback_color(&rb
, 7, 0, 0), &uvec4
);
16280 todo_wine
check_rgba_sint8(get_readback_color(&rb
, 15, 0, 0), &uvec4
);
16281 release_resource_readback(&rb
);
16283 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav2
, &fe_uvec4
.x
);
16284 get_buffer_readback(buffer
, &rb
);
16285 todo_wine
check_rgba_sint8(get_readback_color(&rb
, 0, 0, 0), &uvec4
);
16286 todo_wine
check_rgba_sint8(get_readback_color(&rb
, U(uav_desc
).Buffer
.FirstElement
- 1, 0, 0), &uvec4
);
16287 todo_wine
check_rgba_sint8(get_readback_color(&rb
, U(uav_desc
).Buffer
.FirstElement
, 0, 0), &fe_uvec4
);
16288 release_resource_readback(&rb
);
16291 ID3D11UnorderedAccessView_Release(uav
);
16292 ID3D11UnorderedAccessView_Release(uav2
);
16294 ID3D11Buffer_Release(buffer
);
16296 ID3D11DeviceContext_Release(context
);
16297 refcount
= ID3D11Device_Release(device
);
16298 ok(!refcount
, "Device has %u references left.\n", refcount
);
16301 static void test_initial_depth_stencil_state(void)
16303 static const struct vec4 green
= {0.0f
, 1.0f
, 0.0f
, 1.0f
};
16304 static const struct vec4 red
= {1.0f
, 0.0f
, 0.0f
, 1.0f
};
16305 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
16306 struct d3d11_test_context test_context
;
16307 D3D11_TEXTURE2D_DESC texture_desc
;
16308 ID3D11DeviceContext
*context
;
16309 ID3D11DepthStencilView
*dsv
;
16310 ID3D11Texture2D
*texture
;
16311 ID3D11Device
*device
;
16312 unsigned int count
;
16316 if (!init_test_context(&test_context
, NULL
))
16319 device
= test_context
.device
;
16320 context
= test_context
.immediate_context
;
16322 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
16323 texture_desc
.Format
= DXGI_FORMAT_D32_FLOAT
;
16324 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
16325 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
16326 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
16328 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, NULL
, &dsv
);
16329 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
16331 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &test_context
.backbuffer_rtv
, dsv
);
16334 ID3D11DeviceContext_RSGetViewports(context
, &count
, &vp
);
16336 /* check if depth function is D3D11_COMPARISON_LESS */
16337 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
16338 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 0.5f
, 0);
16339 set_viewport(context
, vp
.TopLeftX
, vp
.TopLeftY
, vp
.Width
, vp
.Height
, 0.4f
, 0.4f
);
16340 draw_color_quad(&test_context
, &green
);
16341 draw_color_quad(&test_context
, &red
);
16342 set_viewport(context
, vp
.TopLeftX
, vp
.TopLeftY
, vp
.Width
, vp
.Height
, 0.6f
, 0.6f
);
16343 draw_color_quad(&test_context
, &red
);
16344 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
16345 check_texture_float(texture
, 0.4f
, 1);
16347 ID3D11DepthStencilView_Release(dsv
);
16348 ID3D11Texture2D_Release(texture
);
16349 release_test_context(&test_context
);
16352 static void test_draw_depth_only(void)
16354 struct d3d11_test_context test_context
;
16355 ID3D11PixelShader
*ps_color
, *ps_depth
;
16356 D3D11_TEXTURE2D_DESC texture_desc
;
16357 ID3D11DeviceContext
*context
;
16358 ID3D11DepthStencilView
*dsv
;
16359 struct resource_readback rb
;
16360 ID3D11Texture2D
*texture
;
16361 ID3D11Device
*device
;
16367 static const DWORD ps_color_code
[] =
16370 float4
main(float4 position
: SV_POSITION
) : SV_Target
16372 return float4(0.0, 1.0, 0.0, 1.0);
16375 0x43425844, 0x30240e72, 0x012f250c, 0x8673c6ea, 0x392e4cec, 0x00000001, 0x000000d4, 0x00000003,
16376 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
16377 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
16378 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
16379 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000038, 0x00000040,
16380 0x0000000e, 0x03000065, 0x001020f2, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002,
16381 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e,
16383 static const DWORD ps_depth_code
[] =
16388 float main() : SV_Depth
16393 0x43425844, 0x91af6cd0, 0x7e884502, 0xcede4f54, 0x6f2c9326, 0x00000001, 0x000000b0, 0x00000003,
16394 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
16395 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff,
16396 0x00000e01, 0x445f5653, 0x68747065, 0xababab00, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
16397 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x02000065, 0x0000c001, 0x05000036, 0x0000c001,
16398 0x0020800a, 0x00000000, 0x00000000, 0x0100003e,
16401 if (!init_test_context(&test_context
, NULL
))
16404 device
= test_context
.device
;
16405 context
= test_context
.immediate_context
;
16407 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(depth
), NULL
);
16409 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
16410 texture_desc
.Format
= DXGI_FORMAT_D32_FLOAT
;
16411 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
16412 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
16413 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
16415 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, NULL
, &dsv
);
16416 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
16418 hr
= ID3D11Device_CreatePixelShader(device
, ps_color_code
, sizeof(ps_color_code
), NULL
, &ps_color
);
16419 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
16420 hr
= ID3D11Device_CreatePixelShader(device
, ps_depth_code
, sizeof(ps_depth_code
), NULL
, &ps_depth
);
16421 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
16423 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
16424 ID3D11DeviceContext_PSSetShader(context
, ps_color
, NULL
, 0);
16425 ID3D11DeviceContext_OMSetRenderTargets(context
, 0, NULL
, dsv
);
16427 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
16428 check_texture_float(texture
, 1.0f
, 1);
16429 draw_quad(&test_context
);
16430 check_texture_float(texture
, 0.0f
, 1);
16432 ID3D11DeviceContext_PSSetShader(context
, ps_depth
, NULL
, 0);
16435 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &depth
, 0, 0);
16436 draw_quad(&test_context
);
16437 check_texture_float(texture
, 0.0f
, 1);
16438 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
16439 check_texture_float(texture
, 1.0f
, 1);
16440 draw_quad(&test_context
);
16441 check_texture_float(texture
, 0.7f
, 1);
16443 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &depth
, 0, 0);
16444 draw_quad(&test_context
);
16445 check_texture_float(texture
, 0.7f
, 1);
16447 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &depth
, 0, 0);
16448 draw_quad(&test_context
);
16449 check_texture_float(texture
, 0.5f
, 1);
16451 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
16452 for (i
= 0; i
< 4; ++i
)
16454 for (j
= 0; j
< 4; ++j
)
16456 depth
.x
= 1.0f
/ 16.0f
* (j
+ 4 * i
);
16457 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &depth
, 0, 0);
16459 set_viewport(context
, 160.0f
* j
, 120.0f
* i
, 160.0f
, 120.0f
, 0.0f
, 1.0f
);
16461 draw_quad(&test_context
);
16464 get_texture_readback(texture
, 0, &rb
);
16465 for (i
= 0; i
< 4; ++i
)
16467 for (j
= 0; j
< 4; ++j
)
16469 float obtained_depth
, expected_depth
;
16471 obtained_depth
= get_readback_float(&rb
, 80 + j
* 160, 60 + i
* 120);
16472 expected_depth
= 1.0f
/ 16.0f
* (j
+ 4 * i
);
16473 ok(compare_float(obtained_depth
, expected_depth
, 1),
16474 "Got unexpected depth %.8e at (%u, %u), expected %.8e.\n",
16475 obtained_depth
, j
, i
, expected_depth
);
16478 release_resource_readback(&rb
);
16480 ID3D11Buffer_Release(cb
);
16481 ID3D11PixelShader_Release(ps_color
);
16482 ID3D11PixelShader_Release(ps_depth
);
16483 ID3D11DepthStencilView_Release(dsv
);
16484 ID3D11Texture2D_Release(texture
);
16485 release_test_context(&test_context
);
16488 static void test_draw_uav_only(void)
16490 struct d3d11_test_context test_context
;
16491 D3D11_TEXTURE2D_DESC texture_desc
;
16492 ID3D11UnorderedAccessView
*uav
;
16493 ID3D11DeviceContext
*context
;
16494 ID3D11Texture2D
*texture
;
16495 ID3D11PixelShader
*ps
;
16496 ID3D11Device
*device
;
16499 static const DWORD ps_code
[] =
16502 RWTexture2D
<int> u
;
16506 InterlockedAdd(u
[uint2(0, 0)], 1);
16509 0x43425844, 0x237a8398, 0xe7b34c17, 0xa28c91a4, 0xb3614d73, 0x00000001, 0x0000009c, 0x00000003,
16510 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
16511 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000048, 0x00000050, 0x00000012, 0x0100086a,
16512 0x0400189c, 0x0011e000, 0x00000000, 0x00003333, 0x0a0000ad, 0x0011e000, 0x00000000, 0x00004002,
16513 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00004001, 0x00000001, 0x0100003e,
16515 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
16516 static const UINT values
[4] = {0};
16518 if (!init_test_context(&test_context
, &feature_level
))
16521 device
= test_context
.device
;
16522 context
= test_context
.immediate_context
;
16524 texture_desc
.Width
= 1;
16525 texture_desc
.Height
= 1;
16526 texture_desc
.MipLevels
= 1;
16527 texture_desc
.ArraySize
= 1;
16528 texture_desc
.Format
= DXGI_FORMAT_R32_SINT
;
16529 texture_desc
.SampleDesc
.Count
= 1;
16530 texture_desc
.SampleDesc
.Quality
= 0;
16531 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
16532 texture_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
16533 texture_desc
.CPUAccessFlags
= 0;
16534 texture_desc
.MiscFlags
= 0;
16536 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
16537 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
16539 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)texture
, NULL
, &uav
);
16540 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
16542 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
16543 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
16545 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
16546 ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context
, 0, NULL
, NULL
,
16549 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, values
);
16550 set_viewport(context
, 0.0f
, 0.0f
, 10.0f
, 10.0f
, 0.0f
, 0.0f
);
16551 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, values
);
16552 draw_quad(&test_context
);
16553 check_texture_color(texture
, 100, 1);
16555 draw_quad(&test_context
);
16556 draw_quad(&test_context
);
16557 draw_quad(&test_context
);
16558 draw_quad(&test_context
);
16559 check_texture_color(texture
, 500, 1);
16561 ID3D11PixelShader_Release(ps
);
16562 ID3D11Texture2D_Release(texture
);
16563 ID3D11UnorderedAccessView_Release(uav
);
16564 release_test_context(&test_context
);
16567 static void test_cb_relative_addressing(void)
16569 struct d3d11_test_context test_context
;
16570 ID3D11Buffer
*colors_cb
, *index_cb
;
16571 unsigned int i
, index
[4] = {0};
16572 ID3D11DeviceContext
*context
;
16573 ID3D11PixelShader
*ps
;
16574 ID3D11Device
*device
;
16577 static const DWORD vs_code
[] =
16589 float4 position
: POSITION
;
16594 float4 position
: SV_POSITION
;
16595 float4 color
: COLOR
;
16598 vs_out
main(const vs_in v
)
16602 o
.position
= v
.position
;
16603 o
.color
= colors
[color_index
];
16608 0x43425844, 0xc2eb30bf, 0x2868c855, 0xaa34b609, 0x1f4957d4, 0x00000001, 0x00000164, 0x00000003,
16609 0x0000002c, 0x00000060, 0x000000b4, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
16610 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
16611 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
16612 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
16613 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x58454853, 0x000000a8, 0x00010050,
16614 0x0000002a, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04000859, 0x00208e46,
16615 0x00000001, 0x00000008, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000,
16616 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x02000068, 0x00000001, 0x05000036, 0x001020f2,
16617 0x00000000, 0x00101e46, 0x00000000, 0x06000036, 0x00100012, 0x00000000, 0x0020800a, 0x00000000,
16618 0x00000000, 0x07000036, 0x001020f2, 0x00000001, 0x04208e46, 0x00000001, 0x0010000a, 0x00000000,
16621 static const DWORD ps_code
[] =
16626 float4 position
: SV_POSITION
;
16627 float4 color
: COLOR
;
16630 float4
main(const ps_in v
) : SV_TARGET
16635 0x43425844, 0x1a6def50, 0x9c069300, 0x7cce68f0, 0x621239b9, 0x00000001, 0x000000f8, 0x00000003,
16636 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
16637 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
16638 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
16639 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
16640 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x58454853, 0x0000003c, 0x00000050,
16641 0x0000000f, 0x0100086a, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
16642 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
16644 static const struct
16650 {{0.0f
, 0.0f
, 0.0f
, 1.0f
}},
16651 {{0.0f
, 0.0f
, 1.0f
, 0.0f
}},
16652 {{0.0f
, 0.0f
, 1.0f
, 1.0f
}},
16653 {{0.0f
, 1.0f
, 0.0f
, 0.0f
}},
16654 {{0.0f
, 1.0f
, 0.0f
, 1.0f
}},
16655 {{0.0f
, 1.0f
, 1.0f
, 0.0f
}},
16656 {{0.0f
, 1.0f
, 1.0f
, 1.0f
}},
16657 {{1.0f
, 0.0f
, 0.0f
, 0.0f
}},
16658 {{1.0f
, 0.0f
, 0.0f
, 1.0f
}},
16659 {{1.0f
, 0.0f
, 1.0f
, 0.0f
}},
16661 static const struct
16663 unsigned int index
;
16680 static const float white_color
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
16681 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
16683 if (!init_test_context(&test_context
, &feature_level
))
16686 device
= test_context
.device
;
16687 context
= test_context
.immediate_context
;
16689 colors_cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(colors
), &colors
);
16690 index_cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(index
), NULL
);
16692 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
16693 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
16695 ID3D11DeviceContext_VSSetConstantBuffers(context
, 0, 1, &index_cb
);
16696 ID3D11DeviceContext_VSSetConstantBuffers(context
, 1, 1, &colors_cb
);
16697 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
16699 for (i
= 0; i
< ARRAY_SIZE(test_data
); ++i
)
16701 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white_color
);
16703 index
[0] = test_data
[i
].index
;
16704 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)index_cb
, 0, NULL
, &index
, 0, 0);
16706 draw_quad_vs(&test_context
, vs_code
, sizeof(vs_code
));
16707 check_texture_color(test_context
.backbuffer
, test_data
[i
].expected
, 1);
16710 ID3D11Buffer_Release(index_cb
);
16711 ID3D11Buffer_Release(colors_cb
);
16712 ID3D11PixelShader_Release(ps
);
16714 release_test_context(&test_context
);
16717 static void test_vs_input_relative_addressing(void)
16719 struct d3d11_test_context test_context
;
16720 ID3D11DeviceContext
*context
;
16721 unsigned int offset
, stride
;
16722 unsigned int index
[4] = {0};
16723 ID3D11PixelShader
*ps
;
16724 ID3D11Buffer
*vb
, *cb
;
16725 ID3D11Device
*device
;
16729 static const DWORD vs_code
[] =
16734 float4 position
: POSITION
;
16735 float4 colors
[4] : COLOR
;
16740 void main(vertex vin
, out float4 position
: SV_Position
,
16741 out float4 color
: COLOR
)
16743 position
= vin
.position
;
16744 color
= vin
.colors
[index
];
16747 0x43425844, 0x8623dd89, 0xe37fecf5, 0xea3fdfe1, 0xdf36e4e4, 0x00000001, 0x000001f4, 0x00000003,
16748 0x0000002c, 0x000000c4, 0x00000118, 0x4e475349, 0x00000090, 0x00000005, 0x00000008, 0x00000080,
16749 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000089, 0x00000000, 0x00000000,
16750 0x00000003, 0x00000001, 0x00000f0f, 0x00000089, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
16751 0x00000f0f, 0x00000089, 0x00000002, 0x00000000, 0x00000003, 0x00000003, 0x00000f0f, 0x00000089,
16752 0x00000003, 0x00000000, 0x00000003, 0x00000004, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x4c4f4300,
16753 0xab00524f, 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001,
16754 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001,
16755 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x000000d4,
16756 0x00010040, 0x00000035, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005f, 0x001010f2,
16757 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x0300005f, 0x001010f2, 0x00000002, 0x0300005f,
16758 0x001010f2, 0x00000003, 0x0300005f, 0x001010f2, 0x00000004, 0x04000067, 0x001020f2, 0x00000000,
16759 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x02000068, 0x00000001, 0x0400005b, 0x001010f2,
16760 0x00000001, 0x00000004, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x06000036,
16761 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x07000036, 0x001020f2, 0x00000001,
16762 0x00d01e46, 0x00000001, 0x0010000a, 0x00000000, 0x0100003e,
16764 static const DWORD ps_code
[] =
16769 float4 position
: SV_POSITION
;
16770 float4 color
: COLOR
;
16773 float4
main(struct vs_out i
) : SV_TARGET
16778 0x43425844, 0xe2087fa6, 0xa35fbd95, 0x8e585b3f, 0x67890f54, 0x00000001, 0x000000f4, 0x00000003,
16779 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
16780 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
16781 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
16782 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
16783 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040,
16784 0x0000000e, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
16785 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
16787 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
16789 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
16790 {"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM
, 1, 0, D3D11_INPUT_PER_INSTANCE_DATA
, 1},
16791 {"COLOR", 1, DXGI_FORMAT_R8G8B8A8_UNORM
, 1, 4, D3D11_INPUT_PER_INSTANCE_DATA
, 1},
16792 {"COLOR", 2, DXGI_FORMAT_R8G8B8A8_UNORM
, 1, 8, D3D11_INPUT_PER_INSTANCE_DATA
, 1},
16793 {"COLOR", 3, DXGI_FORMAT_R8G8B8A8_UNORM
, 1, 12, D3D11_INPUT_PER_INSTANCE_DATA
, 1},
16795 static const unsigned int colors
[] = {0xff0000ff, 0xff00ff00, 0xffff0000, 0xff0f0f0f};
16796 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
16798 if (!init_test_context(&test_context
, NULL
))
16800 device
= test_context
.device
;
16801 context
= test_context
.immediate_context
;
16803 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
16804 vs_code
, sizeof(vs_code
), &test_context
.input_layout
);
16805 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
16807 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(index
), NULL
);
16808 ID3D11DeviceContext_VSSetConstantBuffers(context
, 0, 1, &cb
);
16810 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(colors
), colors
);
16811 stride
= sizeof(colors
);
16813 ID3D11DeviceContext_IASetVertexBuffers(context
, 1, 1, &vb
, &stride
, &offset
);
16815 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
16816 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
16817 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
16819 for (i
= 0; i
< ARRAY_SIZE(colors
); ++i
)
16822 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, index
, 0, 0);
16823 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
16824 draw_quad_vs(&test_context
, vs_code
, sizeof(vs_code
));
16825 check_texture_color(test_context
.backbuffer
, colors
[i
], 1);
16828 ID3D11Buffer_Release(cb
);
16829 ID3D11Buffer_Release(vb
);
16830 ID3D11PixelShader_Release(ps
);
16831 release_test_context(&test_context
);
16834 static void test_getdc(void)
16836 static const struct
16839 DXGI_FORMAT format
;
16840 BOOL getdc_supported
;
16844 {"B8G8R8A8_UNORM", DXGI_FORMAT_B8G8R8A8_UNORM
, TRUE
},
16845 {"B8G8R8A8_TYPELESS", DXGI_FORMAT_B8G8R8A8_TYPELESS
, TRUE
},
16846 {"B8G8R8A8_UNORM_SRGB", DXGI_FORMAT_B8G8R8A8_UNORM_SRGB
, TRUE
},
16847 {"B8G8R8X8_UNORM", DXGI_FORMAT_B8G8R8X8_UNORM
, FALSE
},
16848 {"B8G8R8X8_TYPELESS", DXGI_FORMAT_B8G8R8X8_TYPELESS
, FALSE
},
16849 {"B8G8R8X8_UNORM_SRGB", DXGI_FORMAT_B8G8R8X8_UNORM_SRGB
, FALSE
},
16851 struct device_desc device_desc
;
16852 D3D11_TEXTURE2D_DESC desc
;
16853 ID3D11Texture2D
*texture
;
16854 IDXGISurface1
*surface
;
16855 ID3D11Device
*device
;
16861 device_desc
.feature_level
= NULL
;
16862 device_desc
.flags
= D3D11_CREATE_DEVICE_BGRA_SUPPORT
;
16863 if (!(device
= create_device(&device_desc
)))
16865 skip("Failed to create device.\n");
16869 /* Without D3D11_RESOURCE_MISC_GDI_COMPATIBLE. */
16872 desc
.MipLevels
= 1;
16873 desc
.ArraySize
= 1;
16874 desc
.Format
= DXGI_FORMAT_B8G8R8A8_UNORM
;
16875 desc
.SampleDesc
.Count
= 1;
16876 desc
.SampleDesc
.Quality
= 0;
16877 desc
.Usage
= D3D11_USAGE_DEFAULT
;
16878 desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
16879 desc
.CPUAccessFlags
= 0;
16880 desc
.MiscFlags
= 0;
16881 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
16882 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
16884 hr
= ID3D11Texture2D_QueryInterface(texture
, &IID_IDXGISurface1
, (void**)&surface
);
16885 ok(SUCCEEDED(hr
), "Failed to get IDXGISurface1 interface, hr %#x.\n", hr
);
16887 hr
= IDXGISurface1_GetDC(surface
, FALSE
, &dc
);
16888 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
16890 IDXGISurface1_Release(surface
);
16891 ID3D11Texture2D_Release(texture
);
16893 desc
.MiscFlags
= D3D11_RESOURCE_MISC_GDI_COMPATIBLE
;
16894 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
16895 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
16897 hr
= ID3D11Texture2D_QueryInterface(texture
, &IID_IDXGISurface1
, (void**)&surface
);
16898 ok(SUCCEEDED(hr
), "Failed to get IDXGISurface1 interface, hr %#x.\n", hr
);
16900 hr
= IDXGISurface1_ReleaseDC(surface
, NULL
);
16901 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
16903 hr
= IDXGISurface1_GetDC(surface
, FALSE
, &dc
);
16904 ok(SUCCEEDED(hr
), "Failed to get DC, hr %#x.\n", hr
);
16906 hr
= IDXGISurface1_ReleaseDC(surface
, NULL
);
16907 ok(SUCCEEDED(hr
), "Failed to release DC, hr %#x.\n", hr
);
16909 IDXGISurface1_Release(surface
);
16910 ID3D11Texture2D_Release(texture
);
16912 for (i
= 0; i
< ARRAY_SIZE(testdata
); ++i
)
16914 static const unsigned int bit_count
= 32;
16915 unsigned int width_bytes
;
16923 desc
.MipLevels
= 1;
16924 desc
.ArraySize
= 1;
16925 desc
.Format
= testdata
[i
].format
;
16926 desc
.SampleDesc
.Count
= 1;
16927 desc
.SampleDesc
.Quality
= 0;
16928 desc
.Usage
= D3D11_USAGE_STAGING
;
16929 desc
.BindFlags
= 0;
16930 desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
;
16931 desc
.MiscFlags
= 0;
16933 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
16934 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
16935 ID3D11Texture2D_Release(texture
);
16937 /* STAGING usage, requesting GDI compatibility mode. */
16938 desc
.MiscFlags
= D3D11_RESOURCE_MISC_GDI_COMPATIBLE
;
16939 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
16940 ok(FAILED(hr
), "Expected CreateTexture2D to fail, hr %#x.\n", hr
);
16942 desc
.Usage
= D3D11_USAGE_DEFAULT
;
16943 desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
16944 desc
.CPUAccessFlags
= 0;
16945 hr
= ID3D11Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
16946 if (testdata
[i
].getdc_supported
)
16947 ok(SUCCEEDED(hr
), "Got unexpected hr %#x for format %s.\n", hr
, testdata
[i
].name
);
16949 ok(FAILED(hr
), "Got unexpected hr %#x for format %s.\n", hr
, testdata
[i
].name
);
16954 hr
= ID3D11Texture2D_QueryInterface(texture
, &IID_IDXGISurface1
, (void**)&surface
);
16955 ok(SUCCEEDED(hr
), "Failed to get IDXGISurface1 interface, hr %#x.\n", hr
);
16957 dc
= (void *)0x1234;
16958 hr
= IDXGISurface1_GetDC(surface
, FALSE
, &dc
);
16959 ok(SUCCEEDED(hr
), "Got unexpected hr %#x for format %s.\n", hr
, testdata
[i
].name
);
16963 IDXGISurface1_Release(surface
);
16964 ID3D11Texture2D_Release(texture
);
16968 type
= GetObjectType(dc
);
16969 ok(type
== OBJ_MEMDC
, "Got unexpected object type %#x for format %s.\n", type
, testdata
[i
].name
);
16970 bitmap
= GetCurrentObject(dc
, OBJ_BITMAP
);
16971 type
= GetObjectType(bitmap
);
16972 ok(type
== OBJ_BITMAP
, "Got unexpected object type %#x for format %s.\n", type
, testdata
[i
].name
);
16974 size
= GetObjectA(bitmap
, sizeof(dib
), &dib
);
16975 ok(size
== sizeof(dib
) || broken(size
== sizeof(dib
.dsBm
)),
16976 "Got unexpected size %d for format %s.\n", size
, testdata
[i
].name
);
16978 ok(!dib
.dsBm
.bmType
, "Got unexpected type %#x for format %s.\n",
16979 dib
.dsBm
.bmType
, testdata
[i
].name
);
16980 ok(dib
.dsBm
.bmWidth
== 64, "Got unexpected width %d for format %s.\n",
16981 dib
.dsBm
.bmWidth
, testdata
[i
].name
);
16982 ok(dib
.dsBm
.bmHeight
== 64, "Got unexpected height %d for format %s.\n",
16983 dib
.dsBm
.bmHeight
, testdata
[i
].name
);
16984 width_bytes
= ((dib
.dsBm
.bmWidth
* bit_count
+ 31) >> 3) & ~3;
16985 ok(dib
.dsBm
.bmWidthBytes
== width_bytes
, "Got unexpected width bytes %d for format %s.\n",
16986 dib
.dsBm
.bmWidthBytes
, testdata
[i
].name
);
16987 ok(dib
.dsBm
.bmPlanes
== 1, "Got unexpected plane count %d for format %s.\n",
16988 dib
.dsBm
.bmPlanes
, testdata
[i
].name
);
16989 ok(dib
.dsBm
.bmBitsPixel
== bit_count
, "Got unexpected bit count %d for format %s.\n",
16990 dib
.dsBm
.bmBitsPixel
, testdata
[i
].name
);
16992 if (size
== sizeof(dib
))
16993 ok(!!dib
.dsBm
.bmBits
, "Got unexpected bits %p for format %s.\n",
16994 dib
.dsBm
.bmBits
, testdata
[i
].name
);
16996 ok(!dib
.dsBm
.bmBits
, "Got unexpected bits %p for format %s.\n",
16997 dib
.dsBm
.bmBits
, testdata
[i
].name
);
16999 if (size
== sizeof(dib
))
17001 ok(dib
.dsBmih
.biSize
== sizeof(dib
.dsBmih
), "Got unexpected size %u for format %s.\n",
17002 dib
.dsBmih
.biSize
, testdata
[i
].name
);
17003 ok(dib
.dsBmih
.biWidth
== 64, "Got unexpected width %d for format %s.\n",
17004 dib
.dsBmih
.biHeight
, testdata
[i
].name
);
17005 ok(dib
.dsBmih
.biHeight
== 64, "Got unexpected height %d for format %s.\n",
17006 dib
.dsBmih
.biHeight
, testdata
[i
].name
);
17007 ok(dib
.dsBmih
.biPlanes
== 1, "Got unexpected plane count %u for format %s.\n",
17008 dib
.dsBmih
.biPlanes
, testdata
[i
].name
);
17009 ok(dib
.dsBmih
.biBitCount
== bit_count
, "Got unexpected bit count %u for format %s.\n",
17010 dib
.dsBmih
.biBitCount
, testdata
[i
].name
);
17011 ok(dib
.dsBmih
.biCompression
== BI_RGB
, "Got unexpected compression %#x for format %s.\n",
17012 dib
.dsBmih
.biCompression
, testdata
[i
].name
);
17013 ok(!dib
.dsBmih
.biSizeImage
, "Got unexpected image size %u for format %s.\n",
17014 dib
.dsBmih
.biSizeImage
, testdata
[i
].name
);
17015 ok(!dib
.dsBmih
.biXPelsPerMeter
, "Got unexpected horizontal resolution %d for format %s.\n",
17016 dib
.dsBmih
.biXPelsPerMeter
, testdata
[i
].name
);
17017 ok(!dib
.dsBmih
.biYPelsPerMeter
, "Got unexpected vertical resolution %d for format %s.\n",
17018 dib
.dsBmih
.biYPelsPerMeter
, testdata
[i
].name
);
17019 ok(!dib
.dsBmih
.biClrUsed
, "Got unexpected used colour count %u for format %s.\n",
17020 dib
.dsBmih
.biClrUsed
, testdata
[i
].name
);
17021 ok(!dib
.dsBmih
.biClrImportant
, "Got unexpected important colour count %u for format %s.\n",
17022 dib
.dsBmih
.biClrImportant
, testdata
[i
].name
);
17023 ok(!dib
.dsBitfields
[0] && !dib
.dsBitfields
[1] && !dib
.dsBitfields
[2],
17024 "Got unexpected colour masks 0x%08x 0x%08x 0x%08x for format %s.\n",
17025 dib
.dsBitfields
[0], dib
.dsBitfields
[1], dib
.dsBitfields
[2], testdata
[i
].name
);
17026 ok(!dib
.dshSection
, "Got unexpected section %p for format %s.\n", dib
.dshSection
, testdata
[i
].name
);
17027 ok(!dib
.dsOffset
, "Got unexpected offset %u for format %s.\n", dib
.dsOffset
, testdata
[i
].name
);
17030 hr
= IDXGISurface1_ReleaseDC(surface
, NULL
);
17031 ok(hr
== S_OK
, "Failed to release DC, hr %#x.\n", hr
);
17033 IDXGISurface1_Release(surface
);
17034 ID3D11Texture2D_Release(texture
);
17037 refcount
= ID3D11Device_Release(device
);
17038 ok(!refcount
, "Device has %u references left.\n", refcount
);
17041 static void test_shader_stage_input_output_matching(void)
17043 struct d3d11_test_context test_context
;
17044 D3D11_TEXTURE2D_DESC texture_desc
;
17045 ID3D11Texture2D
*render_target
;
17046 ID3D11RenderTargetView
*rtv
[2];
17047 ID3D11DeviceContext
*context
;
17048 ID3D11VertexShader
*vs
;
17049 ID3D11PixelShader
*ps
;
17050 ID3D11Device
*device
;
17053 static const DWORD vs_code
[] =
17058 float4 position
: SV_PoSiTion
;
17059 float4 color0
: COLOR0
;
17060 float4 color1
: COLOR1
;
17063 void main(uint id
: SV_VertexID
, out output o
)
17065 float2 coords
= float2((id
<< 1) & 2, id
& 2);
17066 o
.position
= float4(coords
* float2(2, -2) + float2(-1, 1), 0, 1);
17067 o
.color0
= float4(1.0f
, 0.0f
, 0.0f
, 1.0f
);
17068 o
.color1
= float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
17071 0x43425844, 0x93c216a1, 0xbaa7e8d4, 0xd5368c6a, 0x4e889e07, 0x00000001, 0x00000224, 0x00000003,
17072 0x0000002c, 0x00000060, 0x000000cc, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
17073 0x00000000, 0x00000006, 0x00000001, 0x00000000, 0x00000101, 0x565f5653, 0x65747265, 0x00444978,
17074 0x4e47534f, 0x00000064, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003,
17075 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
17076 0x0000005c, 0x00000001, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x505f5653, 0x5469536f,
17077 0x006e6f69, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000150, 0x00010040, 0x00000054, 0x04000060,
17078 0x00101012, 0x00000000, 0x00000006, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065,
17079 0x001020f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068, 0x00000001, 0x07000029,
17080 0x00100012, 0x00000000, 0x0010100a, 0x00000000, 0x00004001, 0x00000001, 0x07000001, 0x00100012,
17081 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000002, 0x07000001, 0x00100042, 0x00000000,
17082 0x0010100a, 0x00000000, 0x00004001, 0x00000002, 0x05000056, 0x00100032, 0x00000000, 0x00100086,
17083 0x00000000, 0x0f000032, 0x00102032, 0x00000000, 0x00100046, 0x00000000, 0x00004002, 0x40000000,
17084 0xc0000000, 0x00000000, 0x00000000, 0x00004002, 0xbf800000, 0x3f800000, 0x00000000, 0x00000000,
17085 0x08000036, 0x001020c2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x3f800000,
17086 0x08000036, 0x001020f2, 0x00000001, 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000,
17087 0x08000036, 0x001020f2, 0x00000002, 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x3f800000,
17090 static const DWORD ps_code
[] =
17095 float4 position
: SV_PoSiTiOn
;
17096 float4 color1
: COLOR1
;
17097 float4 color0
: COLOR0
;
17102 float4 target0
: SV_Target0
;
17103 float4 target1
: SV_Target1
;
17106 void main(const in input i
, out output o
)
17108 o
.target0
= i
.color0
;
17109 o
.target1
= i
.color1
;
17112 0x43425844, 0x620ef963, 0xed8f19fe, 0x7b3a0a53, 0x126ce021, 0x00000001, 0x00000150, 0x00000003,
17113 0x0000002c, 0x00000098, 0x000000e4, 0x4e475349, 0x00000064, 0x00000003, 0x00000008, 0x00000050,
17114 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000001, 0x00000000,
17115 0x00000003, 0x00000001, 0x00000f0f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000002,
17116 0x00000f0f, 0x505f5653, 0x5469536f, 0x006e4f69, 0x4f4c4f43, 0xabab0052, 0x4e47534f, 0x00000044,
17117 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f,
17118 0x00000038, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x545f5653, 0x65677261,
17119 0xabab0074, 0x52444853, 0x00000064, 0x00000040, 0x00000019, 0x03001062, 0x001010f2, 0x00000001,
17120 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x001020f2,
17121 0x00000001, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000002, 0x05000036, 0x001020f2,
17122 0x00000001, 0x00101e46, 0x00000001, 0x0100003e,
17125 if (!init_test_context(&test_context
, NULL
))
17128 device
= test_context
.device
;
17129 context
= test_context
.immediate_context
;
17131 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
17132 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
17133 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
17134 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
17136 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
17137 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &render_target
);
17138 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
17140 rtv
[0] = test_context
.backbuffer_rtv
;
17141 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)render_target
, NULL
, &rtv
[1]);
17142 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
17144 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
17145 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
17146 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST
);
17147 ID3D11DeviceContext_OMSetRenderTargets(context
, 2, rtv
, NULL
);
17148 ID3D11DeviceContext_Draw(context
, 3, 0);
17150 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
17151 check_texture_color(render_target
, 0xff0000ff, 0);
17153 ID3D11RenderTargetView_Release(rtv
[1]);
17154 ID3D11Texture2D_Release(render_target
);
17155 ID3D11PixelShader_Release(ps
);
17156 ID3D11VertexShader_Release(vs
);
17157 release_test_context(&test_context
);
17160 static void test_shader_interstage_interface(void)
17162 struct d3d11_test_context test_context
;
17163 D3D11_TEXTURE2D_DESC texture_desc
;
17164 ID3D11InputLayout
*input_layout
;
17165 ID3D11Texture2D
*render_target
;
17166 ID3D11DeviceContext
*context
;
17167 ID3D11RenderTargetView
*rtv
;
17168 ID3D11VertexShader
*vs
;
17169 ID3D11PixelShader
*ps
;
17170 ID3D11Device
*device
;
17171 UINT stride
, offset
;
17176 static const DWORD vs_code
[] =
17181 float4 position
: SV_Position
;
17182 float2 t0
: TEXCOORD0
;
17183 nointerpolation
float t1
: TEXCOORD1
;
17184 uint t2
: TEXCOORD2
;
17185 uint t3
: TEXCOORD3
;
17186 float t4
: TEXCOORD4
;
17189 void main(in vertex vin
, out vertex vout
)
17194 0x43425844, 0xd55780bf, 0x76866b06, 0x45d697a2, 0xafac2ecd, 0x00000001, 0x000002bc, 0x00000003,
17195 0x0000002c, 0x000000e4, 0x0000019c, 0x4e475349, 0x000000b0, 0x00000006, 0x00000008, 0x00000098,
17196 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x000000a4, 0x00000000, 0x00000000,
17197 0x00000003, 0x00000001, 0x00000303, 0x000000a4, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
17198 0x00000101, 0x000000a4, 0x00000002, 0x00000000, 0x00000001, 0x00000003, 0x00000101, 0x000000a4,
17199 0x00000003, 0x00000000, 0x00000001, 0x00000004, 0x00000101, 0x000000a4, 0x00000004, 0x00000000,
17200 0x00000003, 0x00000005, 0x00000101, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f,
17201 0xababab00, 0x4e47534f, 0x000000b0, 0x00000006, 0x00000008, 0x00000098, 0x00000000, 0x00000001,
17202 0x00000003, 0x00000000, 0x0000000f, 0x000000a4, 0x00000000, 0x00000000, 0x00000003, 0x00000001,
17203 0x00000c03, 0x000000a4, 0x00000004, 0x00000000, 0x00000003, 0x00000001, 0x00000b04, 0x000000a4,
17204 0x00000001, 0x00000000, 0x00000003, 0x00000002, 0x00000e01, 0x000000a4, 0x00000002, 0x00000000,
17205 0x00000001, 0x00000002, 0x00000d02, 0x000000a4, 0x00000003, 0x00000000, 0x00000001, 0x00000002,
17206 0x00000b04, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f, 0xababab00, 0x52444853,
17207 0x00000118, 0x00010040, 0x00000046, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x00101032,
17208 0x00000001, 0x0300005f, 0x00101012, 0x00000002, 0x0300005f, 0x00101012, 0x00000003, 0x0300005f,
17209 0x00101012, 0x00000004, 0x0300005f, 0x00101012, 0x00000005, 0x04000067, 0x001020f2, 0x00000000,
17210 0x00000001, 0x03000065, 0x00102032, 0x00000001, 0x03000065, 0x00102042, 0x00000001, 0x03000065,
17211 0x00102012, 0x00000002, 0x03000065, 0x00102022, 0x00000002, 0x03000065, 0x00102042, 0x00000002,
17212 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x00102032, 0x00000001,
17213 0x00101046, 0x00000001, 0x05000036, 0x00102042, 0x00000001, 0x0010100a, 0x00000005, 0x05000036,
17214 0x00102012, 0x00000002, 0x0010100a, 0x00000002, 0x05000036, 0x00102022, 0x00000002, 0x0010100a,
17215 0x00000003, 0x05000036, 0x00102042, 0x00000002, 0x0010100a, 0x00000004, 0x0100003e,
17217 static const DWORD ps_code
[] =
17220 void main(float4 position
: SV_Position
, float2 t0
: TEXCOORD0
,
17221 nointerpolation
float t1
: TEXCOORD1
, uint t2
: TEXCOORD2
,
17222 uint t3
: TEXCOORD3
, float t4
: TEXCOORD4
, out float4 o
: SV_Target
)
17230 0x43425844, 0x8a7ef706, 0xc8f2cbf1, 0x83a05df1, 0xfab8e613, 0x00000001, 0x000001dc, 0x00000003,
17231 0x0000002c, 0x000000e4, 0x00000118, 0x4e475349, 0x000000b0, 0x00000006, 0x00000008, 0x00000098,
17232 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x000000a4, 0x00000000, 0x00000000,
17233 0x00000003, 0x00000001, 0x00000303, 0x000000a4, 0x00000004, 0x00000000, 0x00000003, 0x00000001,
17234 0x00000404, 0x000000a4, 0x00000001, 0x00000000, 0x00000003, 0x00000002, 0x00000101, 0x000000a4,
17235 0x00000002, 0x00000000, 0x00000001, 0x00000002, 0x00000202, 0x000000a4, 0x00000003, 0x00000000,
17236 0x00000001, 0x00000002, 0x00000404, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f,
17237 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
17238 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000bc,
17239 0x00000040, 0x0000002f, 0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x00101042, 0x00000001,
17240 0x03000862, 0x00101012, 0x00000002, 0x03000862, 0x00101022, 0x00000002, 0x03000862, 0x00101042,
17241 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0700001e, 0x00100012,
17242 0x00000000, 0x0010101a, 0x00000002, 0x0010102a, 0x00000002, 0x05000056, 0x00102022, 0x00000000,
17243 0x0010000a, 0x00000000, 0x07000000, 0x00102012, 0x00000000, 0x0010101a, 0x00000001, 0x0010100a,
17244 0x00000002, 0x05000036, 0x001020c2, 0x00000000, 0x001012a6, 0x00000001, 0x0100003e,
17246 static const DWORD ps_partial_input_code
[] =
17249 void main(float4 position
: SV_Position
, float2 t0
: TEXCOORD0
,
17250 nointerpolation
float t1
: TEXCOORD1
, uint t2
: TEXCOORD2
,
17251 uint t3
: TEXCOORD3
, out float4 o
: SV_Target
)
17259 0x43425844, 0x5b1db356, 0xaa5a5e9d, 0xb916a081, 0x61e6dcb1, 0x00000001, 0x000001cc, 0x00000003,
17260 0x0000002c, 0x000000cc, 0x00000100, 0x4e475349, 0x00000098, 0x00000005, 0x00000008, 0x00000080,
17261 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000008c, 0x00000000, 0x00000000,
17262 0x00000003, 0x00000001, 0x00000303, 0x0000008c, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
17263 0x00000101, 0x0000008c, 0x00000002, 0x00000000, 0x00000001, 0x00000002, 0x00000202, 0x0000008c,
17264 0x00000003, 0x00000000, 0x00000001, 0x00000002, 0x00000404, 0x505f5653, 0x7469736f, 0x006e6f69,
17265 0x43584554, 0x44524f4f, 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
17266 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074,
17267 0x52444853, 0x000000c4, 0x00000040, 0x00000031, 0x03001062, 0x00101032, 0x00000001, 0x03000862,
17268 0x00101012, 0x00000002, 0x03000862, 0x00101022, 0x00000002, 0x03000862, 0x00101042, 0x00000002,
17269 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0700001e, 0x00100012, 0x00000000,
17270 0x0010102a, 0x00000002, 0x0010101a, 0x00000002, 0x05000056, 0x00102022, 0x00000000, 0x0010000a,
17271 0x00000000, 0x07000000, 0x00102012, 0x00000000, 0x0010101a, 0x00000001, 0x0010100a, 0x00000002,
17272 0x05000036, 0x00102042, 0x00000000, 0x00004001, 0x00000000, 0x05000036, 0x00102082, 0x00000000,
17273 0x0010100a, 0x00000001, 0x0100003e,
17275 static const DWORD ps_single_input_code
[] =
17278 void main(float4 position
: SV_Position
, float2 t0
: TEXCOORD0
, out float4 o
: SV_Target
)
17286 0x43425844, 0x7cc601b6, 0xc65b8bdb, 0x54d0f606, 0x9cc74d3d, 0x00000001, 0x00000118, 0x00000003,
17287 0x0000002c, 0x00000084, 0x000000b8, 0x4e475349, 0x00000050, 0x00000002, 0x00000008, 0x00000038,
17288 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
17289 0x00000003, 0x00000001, 0x00000303, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f,
17290 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
17291 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000058,
17292 0x00000040, 0x00000016, 0x03001062, 0x00101032, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
17293 0x05000036, 0x00102032, 0x00000000, 0x00101046, 0x00000001, 0x08000036, 0x001020c2, 0x00000000,
17294 0x00004002, 0x00000000, 0x00000000, 0x3f800000, 0x40000000, 0x0100003e,
17296 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
17298 {"SV_POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
17299 {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 8, D3D11_INPUT_PER_VERTEX_DATA
, 0},
17300 {"TEXCOORD", 1, DXGI_FORMAT_R32_FLOAT
, 0, 16, D3D11_INPUT_PER_VERTEX_DATA
, 0},
17301 {"TEXCOORD", 2, DXGI_FORMAT_R32_UINT
, 0, 20, D3D11_INPUT_PER_VERTEX_DATA
, 0},
17302 {"TEXCOORD", 3, DXGI_FORMAT_R32_UINT
, 0, 24, D3D11_INPUT_PER_VERTEX_DATA
, 0},
17303 {"TEXCOORD", 4, DXGI_FORMAT_R32_FLOAT
, 0, 28, D3D11_INPUT_PER_VERTEX_DATA
, 0},
17305 static const struct
17307 struct vec2 position
;
17316 {{-1.0f
, -1.0f
}, {3.0f
, 5.0f
}, 5.0f
, 2, 6, 7.0f
},
17317 {{-1.0f
, 1.0f
}, {3.0f
, 5.0f
}, 5.0f
, 2, 6, 7.0f
},
17318 {{ 1.0f
, -1.0f
}, {3.0f
, 5.0f
}, 5.0f
, 2, 6, 7.0f
},
17319 {{ 1.0f
, 1.0f
}, {3.0f
, 5.0f
}, 5.0f
, 2, 6, 7.0f
},
17321 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
17322 static const struct
17324 const DWORD
*ps_code
;
17326 struct vec4 expected_result
;
17330 {ps_code
, sizeof(ps_code
), {10.0f
, 8.0f
, 7.0f
, 3.0f
}},
17331 {ps_partial_input_code
, sizeof(ps_partial_input_code
), {10.0f
, 8.0f
, 0.0f
, 3.0f
}},
17332 {ps_single_input_code
, sizeof(ps_single_input_code
), {3.0f
, 5.0f
, 1.0f
, 2.0f
}},
17335 if (!init_test_context(&test_context
, NULL
))
17338 device
= test_context
.device
;
17339 context
= test_context
.immediate_context
;
17341 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
17342 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
17344 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
17345 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
17346 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &render_target
);
17347 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
17349 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)render_target
, NULL
, &rtv
);
17350 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
17352 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
17353 vs_code
, sizeof(vs_code
), &input_layout
);
17354 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
17356 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(quad
), quad
);
17358 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, white
);
17360 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
17361 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
17362 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
17363 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
17365 stride
= sizeof(*quad
);
17366 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, &stride
, &offset
);
17368 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
17370 hr
= ID3D11Device_CreatePixelShader(device
, tests
[i
].ps_code
, tests
[i
].ps_size
, NULL
, &ps
);
17371 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
17372 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
17373 ID3D11DeviceContext_Draw(context
, 4, 0);
17374 check_texture_vec4(render_target
, &tests
[i
].expected_result
, 0);
17375 ID3D11PixelShader_Release(ps
);
17378 ID3D11InputLayout_Release(input_layout
);
17379 ID3D11RenderTargetView_Release(rtv
);
17380 ID3D11Texture2D_Release(render_target
);
17381 ID3D11VertexShader_Release(vs
);
17382 ID3D11Buffer_Release(vb
);
17383 release_test_context(&test_context
);
17386 static void test_sm4_if_instruction(void)
17388 struct d3d11_test_context test_context
;
17389 ID3D11PixelShader
*ps_if_nz
, *ps_if_z
;
17390 ID3D11DeviceContext
*context
;
17391 ID3D11Device
*device
;
17392 unsigned int bits
[4];
17393 DWORD expected_color
;
17398 static const DWORD ps_if_nz_code
[] =
17403 float4
main() : SV_TARGET
17406 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
17408 return float4(1.0f
, 0.0f
, 0.0f
, 1.0f
);
17411 0x43425844, 0x2a94f6f1, 0xdbe88943, 0x3426a708, 0x09cec990, 0x00000001, 0x00000100, 0x00000003,
17412 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17413 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
17414 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000088, 0x00000040, 0x00000022,
17415 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x0404001f,
17416 0x0020800a, 0x00000000, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000,
17417 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000012, 0x08000036, 0x001020f2, 0x00000000,
17418 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000015, 0x0100003e,
17420 static const DWORD ps_if_z_code
[] =
17425 float4
main() : SV_TARGET
17428 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
17430 return float4(1.0f
, 0.0f
, 0.0f
, 1.0f
);
17433 0x43425844, 0x2e3030ca, 0x94c8610c, 0xdf0c1b1f, 0x80f2ca2c, 0x00000001, 0x00000100, 0x00000003,
17434 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17435 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
17436 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000088, 0x00000040, 0x00000022,
17437 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x0400001f,
17438 0x0020800a, 0x00000000, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000,
17439 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000012, 0x08000036, 0x001020f2, 0x00000000,
17440 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000015, 0x0100003e,
17442 static unsigned int bit_patterns
[] =
17444 0x00000000, 0x00000001, 0x10010001, 0x10000000, 0x80000000, 0xffff0000, 0x0000ffff, 0xffffffff,
17447 if (!init_test_context(&test_context
, NULL
))
17450 device
= test_context
.device
;
17451 context
= test_context
.immediate_context
;
17453 hr
= ID3D11Device_CreatePixelShader(device
, ps_if_nz_code
, sizeof(ps_if_nz_code
), NULL
, &ps_if_nz
);
17454 ok(SUCCEEDED(hr
), "Failed to create if_nz pixel shader, hr %#x.\n", hr
);
17455 hr
= ID3D11Device_CreatePixelShader(device
, ps_if_z_code
, sizeof(ps_if_z_code
), NULL
, &ps_if_z
);
17456 ok(SUCCEEDED(hr
), "Failed to create if_z pixel shader, hr %#x.\n", hr
);
17458 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(bits
), NULL
);
17459 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
17461 for (i
= 0; i
< ARRAY_SIZE(bit_patterns
); ++i
)
17463 *bits
= bit_patterns
[i
];
17464 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, bits
, 0, 0);
17466 ID3D11DeviceContext_PSSetShader(context
, ps_if_nz
, NULL
, 0);
17467 expected_color
= *bits
? 0xff00ff00 : 0xff0000ff;
17468 draw_quad(&test_context
);
17469 check_texture_color(test_context
.backbuffer
, expected_color
, 0);
17471 ID3D11DeviceContext_PSSetShader(context
, ps_if_z
, NULL
, 0);
17472 expected_color
= *bits
? 0xff0000ff : 0xff00ff00;
17473 draw_quad(&test_context
);
17474 check_texture_color(test_context
.backbuffer
, expected_color
, 0);
17477 ID3D11Buffer_Release(cb
);
17478 ID3D11PixelShader_Release(ps_if_z
);
17479 ID3D11PixelShader_Release(ps_if_nz
);
17480 release_test_context(&test_context
);
17483 static void test_sm4_breakc_instruction(void)
17485 struct d3d11_test_context test_context
;
17486 ID3D11DeviceContext
*context
;
17487 ID3D11PixelShader
*ps
;
17488 ID3D11Device
*device
;
17491 static const DWORD ps_breakc_nz_code
[] =
17494 float4
main() : SV_TARGET
17498 for (uint i
= 0; i
< 255; ++i
)
17501 if (counter
== 255)
17502 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
17504 return float4(1.0f
, 0.0f
, 0.0f
, 1.0f
);
17507 0x43425844, 0x065ac80a, 0x24369e7e, 0x218d5dc1, 0x3532868c, 0x00000001, 0x00000188, 0x00000003,
17508 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17509 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
17510 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000110, 0x00000040, 0x00000044,
17511 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x08000036, 0x00100032, 0x00000000,
17512 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01000030, 0x07000050, 0x00100042,
17513 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0x000000ff, 0x03040003, 0x0010002a, 0x00000000,
17514 0x0a00001e, 0x00100032, 0x00000000, 0x00100046, 0x00000000, 0x00004002, 0x00000001, 0x00000001,
17515 0x00000000, 0x00000000, 0x01000016, 0x07000020, 0x00100012, 0x00000000, 0x0010000a, 0x00000000,
17516 0x00004001, 0x000000ff, 0x0304001f, 0x0010000a, 0x00000000, 0x08000036, 0x001020f2, 0x00000000,
17517 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000012, 0x08000036,
17518 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e,
17519 0x01000015, 0x0100003e,
17521 static const DWORD ps_breakc_z_code
[] =
17524 float4
main() : SV_TARGET
17528 for (int i
= 0, j
= 254; i
< 255 && j
>= 0; ++i
, --j
)
17531 if (counter
== 255)
17532 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
17534 return float4(1.0f
, 0.0f
, 0.0f
, 1.0f
);
17537 0x43425844, 0x687406ef, 0x7bdeb7d1, 0xb3282292, 0x934a9101, 0x00000001, 0x000001c0, 0x00000003,
17538 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17539 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
17540 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000148, 0x00000040, 0x00000052,
17541 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x08000036, 0x00100072, 0x00000000,
17542 0x00004002, 0x00000000, 0x00000000, 0x000000fe, 0x00000000, 0x01000030, 0x07000022, 0x00100082,
17543 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0x000000ff, 0x07000021, 0x00100012, 0x00000001,
17544 0x0010002a, 0x00000000, 0x00004001, 0x00000000, 0x07000001, 0x00100082, 0x00000000, 0x0010003a,
17545 0x00000000, 0x0010000a, 0x00000001, 0x03000003, 0x0010003a, 0x00000000, 0x0a00001e, 0x00100072,
17546 0x00000000, 0x00100246, 0x00000000, 0x00004002, 0x00000001, 0x00000001, 0xffffffff, 0x00000000,
17547 0x01000016, 0x07000020, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x000000ff,
17548 0x0304001f, 0x0010000a, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000,
17549 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000012, 0x08000036, 0x001020f2, 0x00000000,
17550 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000015, 0x0100003e,
17553 if (!init_test_context(&test_context
, NULL
))
17556 device
= test_context
.device
;
17557 context
= test_context
.immediate_context
;
17559 hr
= ID3D11Device_CreatePixelShader(device
, ps_breakc_nz_code
, sizeof(ps_breakc_nz_code
), NULL
, &ps
);
17560 ok(SUCCEEDED(hr
), "Failed to create breakc_nz pixel shader, hr %#x.\n", hr
);
17561 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
17562 draw_quad(&test_context
);
17563 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
17564 ID3D11PixelShader_Release(ps
);
17566 hr
= ID3D11Device_CreatePixelShader(device
, ps_breakc_z_code
, sizeof(ps_breakc_z_code
), NULL
, &ps
);
17567 ok(SUCCEEDED(hr
), "Failed to create breakc_z pixel shader, hr %#x.\n", hr
);
17568 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
17569 draw_quad(&test_context
);
17570 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
17571 ID3D11PixelShader_Release(ps
);
17573 release_test_context(&test_context
);
17576 static void test_sm4_continuec_instruction(void)
17578 struct d3d11_test_context test_context
;
17579 ID3D11DeviceContext
*context
;
17580 ID3D11PixelShader
*ps
;
17581 ID3D11Device
*device
;
17584 /* To get fxc to output continuec_z/continuec_nz instead of an if-block
17585 * with a normal continue inside, the shaders have been compiled with
17586 * the /Gfa flag. */
17587 static const DWORD ps_continuec_nz_code
[] =
17590 float4
main() : SV_TARGET
17605 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
17607 return float4(1.0f
, 0.0f
, 0.0f
, 1.0f
);
17610 0x43425844, 0xaadaac96, 0xbe00fdfb, 0x29356be0, 0x47e79bd6, 0x00000001, 0x00000208, 0x00000003,
17611 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17612 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
17613 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000190, 0x00000040, 0x00000064,
17614 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000003, 0x08000036, 0x00100032, 0x00000000,
17615 0x00004002, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x01000030, 0x07000021, 0x00100042,
17616 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0x000000ff, 0x03040003, 0x0010002a, 0x00000000,
17617 0x0700001e, 0x00100022, 0x00000001, 0x0010001a, 0x00000000, 0x00004001, 0x00000001, 0x09000037,
17618 0x00100022, 0x00000002, 0x0010001a, 0x00000001, 0x0010001a, 0x00000001, 0x00004001, 0x00000000,
17619 0x05000036, 0x00100012, 0x00000002, 0x0010000a, 0x00000000, 0x05000036, 0x00100032, 0x00000000,
17620 0x00100046, 0x00000002, 0x05000036, 0x00100042, 0x00000000, 0x0010001a, 0x00000001, 0x03040008,
17621 0x0010002a, 0x00000000, 0x0700001e, 0x00100012, 0x00000001, 0x0010000a, 0x00000000, 0x00004001,
17622 0x00000001, 0x05000036, 0x00100032, 0x00000000, 0x00100046, 0x00000001, 0x01000016, 0x07000020,
17623 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000001, 0x08000036, 0x001020f2,
17624 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x0304003f, 0x0010000a,
17625 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x00000000, 0x00000000,
17626 0x3f800000, 0x0100003e,
17629 static const DWORD ps_continuec_z_code
[] =
17632 float4
main() : SV_TARGET
17646 if (counter
== 255)
17647 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
17649 return float4(1.0f
, 0.0f
, 0.0f
, 1.0f
);
17652 0x43425844, 0x0322b23d, 0x52b25dc8, 0xa625f5f1, 0x271e3f46, 0x00000001, 0x000001d0, 0x00000003,
17653 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17654 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
17655 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000158, 0x00000040, 0x00000056,
17656 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x08000036, 0x00100032, 0x00000000,
17657 0x00004002, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x01000030, 0x07000021, 0x00100042,
17658 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0x000000ff, 0x03040003, 0x0010002a, 0x00000000,
17659 0x0700001e, 0x00100022, 0x00000001, 0x0010001a, 0x00000000, 0x00004001, 0x00000001, 0x05000036,
17660 0x00100042, 0x00000001, 0x0010000a, 0x00000000, 0x05000036, 0x00100072, 0x00000000, 0x00100966,
17661 0x00000001, 0x03000008, 0x0010002a, 0x00000000, 0x0700001e, 0x00100012, 0x00000001, 0x0010000a,
17662 0x00000000, 0x00004001, 0x00000001, 0x05000036, 0x00100032, 0x00000000, 0x00100046, 0x00000001,
17663 0x01000016, 0x07000020, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x000000ff,
17664 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x3f800000,
17665 0x0304003f, 0x0010000a, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000,
17666 0x00000000, 0x00000000, 0x3f800000, 0x0100003e,
17669 if (!init_test_context(&test_context
, NULL
))
17672 device
= test_context
.device
;
17673 context
= test_context
.immediate_context
;
17675 hr
= ID3D11Device_CreatePixelShader(device
, ps_continuec_nz_code
, sizeof(ps_continuec_nz_code
), NULL
, &ps
);
17676 ok(SUCCEEDED(hr
), "Failed to create continuec_nz pixel shader, hr %#x.\n", hr
);
17677 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
17678 draw_quad(&test_context
);
17679 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
17680 ID3D11PixelShader_Release(ps
);
17682 hr
= ID3D11Device_CreatePixelShader(device
, ps_continuec_z_code
, sizeof(ps_continuec_z_code
), NULL
, &ps
);
17683 ok(SUCCEEDED(hr
), "Failed to create continuec_z pixel shader, hr %#x.\n", hr
);
17684 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
17685 draw_quad(&test_context
);
17686 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
17687 ID3D11PixelShader_Release(ps
);
17689 release_test_context(&test_context
);
17692 static void test_sm4_discard_instruction(void)
17694 ID3D11PixelShader
*ps_discard_nz
, *ps_discard_z
;
17695 struct d3d11_test_context test_context
;
17696 ID3D11DeviceContext
*context
;
17697 ID3D11Device
*device
;
17702 static const DWORD ps_discard_nz_code
[] =
17707 float4
main() : SV_Target
17711 return float4(0.0f
, 0.5f
, 0.0f
, 1.0f
);
17714 0x43425844, 0xfa7e5758, 0xd8716ffc, 0x5ad6a940, 0x2b99bba2, 0x00000001, 0x000000d0, 0x00000003,
17715 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17716 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
17717 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000058, 0x00000040, 0x00000016,
17718 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x0404000d,
17719 0x0020800a, 0x00000000, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000,
17720 0x3f000000, 0x00000000, 0x3f800000, 0x0100003e,
17722 static const DWORD ps_discard_z_code
[] =
17727 float4
main() : SV_Target
17731 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
17734 0x43425844, 0x5c4dd108, 0x1eb43558, 0x7c02c98c, 0xd81eb34c, 0x00000001, 0x000000d0, 0x00000003,
17735 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17736 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
17737 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000058, 0x00000040, 0x00000016,
17738 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x0400000d,
17739 0x0020800a, 0x00000000, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000,
17740 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e,
17742 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
17743 static const struct uvec4 values
[] =
17751 if (!init_test_context(&test_context
, NULL
))
17754 device
= test_context
.device
;
17755 context
= test_context
.immediate_context
;
17757 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(*values
), NULL
);
17758 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
17760 hr
= ID3D11Device_CreatePixelShader(device
, ps_discard_nz_code
, sizeof(ps_discard_nz_code
),
17761 NULL
, &ps_discard_nz
);
17762 ok(SUCCEEDED(hr
), "Failed to create discard_nz pixel shader, hr %#x.\n", hr
);
17763 hr
= ID3D11Device_CreatePixelShader(device
, ps_discard_z_code
, sizeof(ps_discard_z_code
),
17764 NULL
, &ps_discard_z
);
17765 ok(SUCCEEDED(hr
), "Failed to create discard_z pixel shader, hr %#x.\n", hr
);
17767 for (i
= 0; i
< ARRAY_SIZE(values
); ++i
)
17769 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &values
[i
], 0, 0);
17771 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
17772 ID3D11DeviceContext_PSSetShader(context
, ps_discard_nz
, NULL
, 0);
17773 draw_quad(&test_context
);
17774 check_texture_color(test_context
.backbuffer
, values
[i
].x
? 0xffffffff : 0xff007f00, 1);
17776 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
17777 ID3D11DeviceContext_PSSetShader(context
, ps_discard_z
, NULL
, 0);
17778 draw_quad(&test_context
);
17779 check_texture_color(test_context
.backbuffer
, values
[i
].x
? 0xff00ff00 : 0xffffffff, 1);
17782 ID3D11Buffer_Release(cb
);
17783 ID3D11PixelShader_Release(ps_discard_nz
);
17784 ID3D11PixelShader_Release(ps_discard_z
);
17785 release_test_context(&test_context
);
17788 static void test_sm5_swapc_instruction(void)
17797 struct d3d11_test_context test_context
;
17798 D3D11_TEXTURE2D_DESC texture_desc
;
17799 ID3D11DeviceContext
*context
;
17800 ID3D11RenderTargetView
*rtv
;
17801 ID3D11Texture2D
*texture
;
17802 ID3D11PixelShader
*ps
[6];
17803 ID3D11Device
*device
;
17808 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
17809 static const DWORD ps_swapc0_code
[] =
17813 dcl_globalFlags refactoringAllowed
17814 dcl_constantbuffer cb0
[3], immediateIndexed
17817 swapc r0
.xyzw
, r1
.xyzw
, cb0
[0].xyzw
, cb0
[1].xyzw
, cb0
[2].xyzw
17818 mov o0
.xyzw
, r0
.xyzw
17821 0x43425844, 0x9e089246, 0x9f8b5cbe, 0xbac66faf, 0xaef23488, 0x00000001, 0x000000f8, 0x00000003,
17822 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17823 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
17824 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000080, 0x00000050, 0x00000020,
17825 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000003, 0x03000065, 0x001020f2, 0x00000000,
17826 0x02000068, 0x00000002, 0x0e00008e, 0x001000f2, 0x00000000, 0x001000f2, 0x00000001, 0x00208e46,
17827 0x00000000, 0x00000000, 0x00208e46, 0x00000000, 0x00000001, 0x00208e46, 0x00000000, 0x00000002,
17828 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x0100003e,
17830 static const DWORD ps_swapc1_code
[] =
17834 dcl_globalFlags refactoringAllowed
17835 dcl_constantbuffer cb0
[3], immediateIndexed
17838 swapc r0
.xyzw
, r1
.xyzw
, cb0
[0].xyzw
, cb0
[1].xyzw
, cb0
[2].xyzw
17839 mov o0
.xyzw
, r1
.xyzw
17842 0x43425844, 0xf2daed61, 0xede211f7, 0x7300dbea, 0x573ed49f, 0x00000001, 0x000000f8, 0x00000003,
17843 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17844 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
17845 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000080, 0x00000050, 0x00000020,
17846 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000003, 0x03000065, 0x001020f2, 0x00000000,
17847 0x02000068, 0x00000002, 0x0e00008e, 0x001000f2, 0x00000000, 0x001000f2, 0x00000001, 0x00208e46,
17848 0x00000000, 0x00000000, 0x00208e46, 0x00000000, 0x00000001, 0x00208e46, 0x00000000, 0x00000002,
17849 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x0100003e,
17851 static const DWORD ps_swapc2_code
[] =
17855 dcl_globalFlags refactoringAllowed
17856 dcl_constantbuffer cb0
[3], immediateIndexed
17859 mov r0
.xyzw
, cb0
[1].xyzw
17860 mov r1
.xyzw
, cb0
[2].xyzw
17861 swapc r0
.xyzw
, r1
.xyzw
, cb0
[0].xyzw
, r0
.xyzw
, r1
.xyzw
17862 mov o0
.xyzw
, r0
.xyzw
17865 0x43425844, 0x230fcb22, 0x70d99148, 0x65814d89, 0x97473498, 0x00000001, 0x00000120, 0x00000003,
17866 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17867 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
17868 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000a8, 0x00000050, 0x0000002a,
17869 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000003, 0x03000065, 0x001020f2, 0x00000000,
17870 0x02000068, 0x00000002, 0x06000036, 0x001000f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000001,
17871 0x06000036, 0x001000f2, 0x00000001, 0x00208e46, 0x00000000, 0x00000002, 0x0c00008e, 0x001000f2,
17872 0x00000000, 0x001000f2, 0x00000001, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000,
17873 0x00100e46, 0x00000001, 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x0100003e,
17875 static const DWORD ps_swapc3_code
[] =
17879 dcl_globalFlags refactoringAllowed
17880 dcl_constantbuffer cb0
[3], immediateIndexed
17883 mov r0
.xyzw
, cb0
[1].xyzw
17884 mov r1
.xyzw
, cb0
[2].xyzw
17885 swapc r0
.xyzw
, r1
.xyzw
, cb0
[0].xyzw
, r0
.xyzw
, r1
.xyzw
17886 mov o0
.xyzw
, r1
.xyzw
17889 0x43425844, 0xce595d62, 0x98305541, 0xb04e74c8, 0xfc010f3a, 0x00000001, 0x00000120, 0x00000003,
17890 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17891 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
17892 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000a8, 0x00000050, 0x0000002a,
17893 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000003, 0x03000065, 0x001020f2, 0x00000000,
17894 0x02000068, 0x00000002, 0x06000036, 0x001000f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000001,
17895 0x06000036, 0x001000f2, 0x00000001, 0x00208e46, 0x00000000, 0x00000002, 0x0c00008e, 0x001000f2,
17896 0x00000000, 0x001000f2, 0x00000001, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000,
17897 0x00100e46, 0x00000001, 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x0100003e,
17899 static const DWORD ps_swapc4_code
[] =
17903 dcl_globalFlags refactoringAllowed
17904 dcl_constantbuffer cb0
[3], immediateIndexed
17907 mov r0
.xyzw
, cb0
[0].xyzw
17908 swapc r0
.xyzw
, r1
.xyzw
, r0
.xyzw
, cb0
[1].xyzw
, cb0
[2].xyzw
17909 mov o0
.xyzw
, r0
.xyzw
17912 0x43425844, 0x72067c48, 0xb53572a0, 0x9dd9e0fd, 0x903e37e3, 0x00000001, 0x0000010c, 0x00000003,
17913 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17914 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
17915 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000094, 0x00000050, 0x00000025,
17916 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000003, 0x03000065, 0x001020f2, 0x00000000,
17917 0x02000068, 0x00000002, 0x06000036, 0x001000f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000000,
17918 0x0d00008e, 0x001000f2, 0x00000000, 0x001000f2, 0x00000001, 0x00100e46, 0x00000000, 0x00208e46,
17919 0x00000000, 0x00000001, 0x00208e46, 0x00000000, 0x00000002, 0x05000036, 0x001020f2, 0x00000000,
17920 0x00100e46, 0x00000000, 0x0100003e,
17922 static const DWORD ps_swapc5_code
[] =
17926 dcl_globalFlags refactoringAllowed
17927 dcl_constantbuffer cb0
[3], immediateIndexed
17930 mov r1
.xyzw
, cb0
[0].xyzw
17931 swapc r0
.xyzw
, r1
.xyzw
, r1
.xyzw
, cb0
[1].xyzw
, cb0
[2].xyzw
17932 mov o0
.xyzw
, r1
.xyzw
17935 0x43425844, 0x7078fb08, 0xdd24cd44, 0x469d3258, 0x9e33a0bc, 0x00000001, 0x0000010c, 0x00000003,
17936 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
17937 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
17938 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000094, 0x00000050, 0x00000025,
17939 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000003, 0x03000065, 0x001020f2, 0x00000000,
17940 0x02000068, 0x00000002, 0x06000036, 0x001000f2, 0x00000001, 0x00208e46, 0x00000000, 0x00000000,
17941 0x0d00008e, 0x001000f2, 0x00000000, 0x001000f2, 0x00000001, 0x00100e46, 0x00000001, 0x00208e46,
17942 0x00000000, 0x00000001, 0x00208e46, 0x00000000, 0x00000002, 0x05000036, 0x001020f2, 0x00000000,
17943 0x00100e46, 0x00000001, 0x0100003e,
17945 static const struct
17947 struct input input
;
17954 {{0, 0, 0, 0}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
17955 {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}
17958 {{1, 1, 1, 1}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
17959 {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}, {0xdead, 0xc0de, 0xffff, 0xeeee},
17962 {{0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff},
17963 {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
17964 {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}, {0xdead, 0xc0de, 0xffff, 0xeeee},
17967 {{1, 0, 1, 0}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
17968 {0xaaaa, 0xc0de, 0xcccc, 0xeeee}, {0xdead, 0xbbbb, 0xffff, 0xdddd},
17971 {{1, 0, 0, 1}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
17972 {0xaaaa, 0xc0de, 0xffff, 0xdddd}, {0xdead, 0xbbbb, 0xcccc, 0xeeee},
17975 {{1, 0, 0, 0}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
17976 {0xaaaa, 0xc0de, 0xffff, 0xeeee}, {0xdead, 0xbbbb, 0xcccc, 0xdddd}
17979 {{0, 1, 0, 0}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
17980 {0xdead, 0xbbbb, 0xffff, 0xeeee}, {0xaaaa, 0xc0de, 0xcccc, 0xdddd}
17983 {{0, 0, 1, 0}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
17984 {0xdead, 0xc0de, 0xcccc, 0xeeee}, {0xaaaa, 0xbbbb, 0xffff, 0xdddd}
17987 {{0, 0, 0, 1}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
17988 {0xdead, 0xc0de, 0xffff, 0xdddd}, {0xaaaa, 0xbbbb, 0xcccc, 0xeeee},
17992 if (!init_test_context(&test_context
, &feature_level
))
17995 device
= test_context
.device
;
17996 context
= test_context
.immediate_context
;
17998 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
17999 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_UINT
;
18000 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
18001 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
18003 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
18004 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
18006 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
18008 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(struct input
), NULL
);
18009 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
18011 hr
= ID3D11Device_CreatePixelShader(device
, ps_swapc0_code
, sizeof(ps_swapc0_code
), NULL
, &ps
[0]);
18012 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
18013 hr
= ID3D11Device_CreatePixelShader(device
, ps_swapc1_code
, sizeof(ps_swapc1_code
), NULL
, &ps
[1]);
18014 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
18015 hr
= ID3D11Device_CreatePixelShader(device
, ps_swapc2_code
, sizeof(ps_swapc2_code
), NULL
, &ps
[2]);
18016 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
18017 hr
= ID3D11Device_CreatePixelShader(device
, ps_swapc3_code
, sizeof(ps_swapc3_code
), NULL
, &ps
[3]);
18018 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
18019 hr
= ID3D11Device_CreatePixelShader(device
, ps_swapc4_code
, sizeof(ps_swapc4_code
), NULL
, &ps
[4]);
18020 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
18021 hr
= ID3D11Device_CreatePixelShader(device
, ps_swapc5_code
, sizeof(ps_swapc5_code
), NULL
, &ps
[5]);
18022 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
18024 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
18026 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &tests
[i
].input
, 0, 0);
18028 ID3D11DeviceContext_PSSetShader(context
, ps
[0], NULL
, 0);
18029 draw_quad(&test_context
);
18030 check_texture_uvec4(texture
, &tests
[i
].dst0
);
18032 ID3D11DeviceContext_PSSetShader(context
, ps
[1], NULL
, 0);
18033 draw_quad(&test_context
);
18034 check_texture_uvec4(texture
, &tests
[i
].dst1
);
18036 ID3D11DeviceContext_PSSetShader(context
, ps
[2], NULL
, 0);
18037 draw_quad(&test_context
);
18038 check_texture_uvec4(texture
, &tests
[i
].dst0
);
18040 ID3D11DeviceContext_PSSetShader(context
, ps
[3], NULL
, 0);
18041 draw_quad(&test_context
);
18042 check_texture_uvec4(texture
, &tests
[i
].dst1
);
18044 ID3D11DeviceContext_PSSetShader(context
, ps
[4], NULL
, 0);
18045 draw_quad(&test_context
);
18046 check_texture_uvec4(texture
, &tests
[i
].dst0
);
18048 ID3D11DeviceContext_PSSetShader(context
, ps
[5], NULL
, 0);
18049 draw_quad(&test_context
);
18050 check_texture_uvec4(texture
, &tests
[i
].dst1
);
18053 for (i
= 0; i
< ARRAY_SIZE(ps
); ++i
)
18054 ID3D11PixelShader_Release(ps
[i
]);
18055 ID3D11RenderTargetView_Release(rtv
);
18056 ID3D11Texture2D_Release(texture
);
18057 ID3D11Buffer_Release(cb
);
18058 release_test_context(&test_context
);
18061 static void test_create_input_layout(void)
18063 D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
18065 {"POSITION", 0, DXGI_FORMAT_UNKNOWN
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18067 ULONG refcount
, expected_refcount
;
18068 ID3D11InputLayout
*input_layout
;
18069 ID3D11Device
*device
;
18073 static const DWORD vs_code
[] =
18076 float4
main(float4 position
: POSITION
) : SV_POSITION
18081 0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003,
18082 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
18083 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
18084 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
18085 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
18086 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
18087 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
18089 static const DXGI_FORMAT vertex_formats
[] =
18091 DXGI_FORMAT_R32G32_FLOAT
,
18092 DXGI_FORMAT_R32G32_UINT
,
18093 DXGI_FORMAT_R32G32_SINT
,
18094 DXGI_FORMAT_R16G16_FLOAT
,
18095 DXGI_FORMAT_R16G16_UINT
,
18096 DXGI_FORMAT_R16G16_SINT
,
18097 DXGI_FORMAT_R32_FLOAT
,
18098 DXGI_FORMAT_R32_UINT
,
18099 DXGI_FORMAT_R32_SINT
,
18100 DXGI_FORMAT_R16_UINT
,
18101 DXGI_FORMAT_R16_SINT
,
18102 DXGI_FORMAT_R8G8_UNORM
,
18103 DXGI_FORMAT_R8_UINT
,
18104 DXGI_FORMAT_R8_SINT
,
18107 if (!(device
= create_device(NULL
)))
18109 skip("Failed to create device.\n");
18113 for (i
= 0; i
< ARRAY_SIZE(vertex_formats
); ++i
)
18115 expected_refcount
= get_refcount(device
) + 1;
18116 layout_desc
->Format
= vertex_formats
[i
];
18117 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
18118 vs_code
, sizeof(vs_code
), &input_layout
);
18119 ok(hr
== S_OK
, "Failed to create input layout for format %#x, hr %#x.\n",
18120 vertex_formats
[i
], hr
);
18121 refcount
= get_refcount(device
);
18122 ok(refcount
== expected_refcount
, "Got refcount %u, expected %u.\n",
18123 refcount
, expected_refcount
);
18124 ID3D11InputLayout_Release(input_layout
);
18127 refcount
= ID3D11Device_Release(device
);
18128 ok(!refcount
, "Device has %u references left.\n", refcount
);
18131 static void test_input_layout_alignment(void)
18133 ID3D11InputLayout
*layout
;
18134 ID3D11Device
*device
;
18139 static const DWORD vs_code
[] =
18142 float4
main(float4 position
: POSITION
) : SV_POSITION
18147 0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003,
18148 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
18149 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
18150 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
18151 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
18152 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
18153 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
18156 static const struct
18158 D3D11_INPUT_ELEMENT_DESC elements
[2];
18164 {"POSITION", 0, DXGI_FORMAT_R8_UINT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18165 {"COLOR", 0, DXGI_FORMAT_R16_UINT
, 0, 2, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18168 {"POSITION", 0, DXGI_FORMAT_R8_UINT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18169 {"COLOR", 0, DXGI_FORMAT_R16_UINT
, 0, 1, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18172 {"POSITION", 0, DXGI_FORMAT_R8_UINT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18173 {"COLOR", 0, DXGI_FORMAT_R8_UINT
, 0, 1, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18176 {"POSITION", 0, DXGI_FORMAT_R16_UINT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18177 {"COLOR", 0, DXGI_FORMAT_R32_UINT
, 0, 2, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18180 {"POSITION", 0, DXGI_FORMAT_R16_UINT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18181 {"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 2, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18184 {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18185 {"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 16, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18188 {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18189 {"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 17, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18192 {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18193 {"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 18, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18196 {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18197 {"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 19, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18200 {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18201 {"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 20, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18205 if (!(device
= create_device(NULL
)))
18207 skip("Failed to create device.\n");
18211 for (i
= 0; i
< ARRAY_SIZE(test_data
); ++i
)
18213 hr
= ID3D11Device_CreateInputLayout(device
, test_data
[i
].elements
, 2, vs_code
, sizeof(vs_code
), &layout
);
18214 ok(hr
== test_data
[i
].hr
, "Test %u: Got unexpected hr %#x, expected %#x.\n", i
, hr
, test_data
[i
].hr
);
18216 ID3D11InputLayout_Release(layout
);
18219 refcount
= ID3D11Device_Release(device
);
18220 ok(!refcount
, "Device has %u references left.\n", refcount
);
18223 static void test_input_assembler(void)
18242 D3D11_INPUT_ELEMENT_DESC input_layout_desc
[] =
18244 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18245 {"ATTRIBUTE", 0, DXGI_FORMAT_UNKNOWN
, 1, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
18247 ID3D11VertexShader
*vs_float
, *vs_uint
, *vs_sint
;
18248 ID3D11InputLayout
*input_layout
[LAYOUT_COUNT
];
18249 ID3D11Buffer
*vb_position
, *vb_attribute
;
18250 struct d3d11_test_context test_context
;
18251 D3D11_TEXTURE2D_DESC texture_desc
;
18252 unsigned int i
, j
, stride
, offset
;
18253 ID3D11Texture2D
*render_target
;
18254 ID3D11DeviceContext
*context
;
18255 ID3D11RenderTargetView
*rtv
;
18256 ID3D11PixelShader
*ps
;
18257 ID3D11Device
*device
;
18260 static const DXGI_FORMAT layout_formats
[LAYOUT_COUNT
] =
18262 DXGI_FORMAT_R32G32B32A32_FLOAT
,
18263 DXGI_FORMAT_R16G16B16A16_UINT
,
18264 DXGI_FORMAT_R16G16B16A16_SINT
,
18265 DXGI_FORMAT_R16G16B16A16_UNORM
,
18266 DXGI_FORMAT_R16G16B16A16_SNORM
,
18267 DXGI_FORMAT_R8G8B8A8_UINT
,
18268 DXGI_FORMAT_R8G8B8A8_SINT
,
18269 DXGI_FORMAT_R8G8B8A8_UNORM
,
18270 DXGI_FORMAT_R8G8B8A8_SNORM
,
18271 DXGI_FORMAT_R10G10B10A2_UNORM
,
18272 DXGI_FORMAT_R10G10B10A2_UINT
,
18274 static const struct vec2 quad
[] =
18281 static const DWORD ps_code
[] =
18284 float4
main(float4 position
: POSITION
, float4 color
: COLOR
) : SV_Target
18289 0x43425844, 0xa9150342, 0x70e18d2e, 0xf7769835, 0x4c3a7f02, 0x00000001, 0x000000f0, 0x00000003,
18290 0x0000002c, 0x0000007c, 0x000000b0, 0x4e475349, 0x00000048, 0x00000002, 0x00000008, 0x00000038,
18291 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x00000041, 0x00000000, 0x00000000,
18292 0x00000003, 0x00000001, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x4e47534f,
18293 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
18294 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
18295 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036, 0x001020f2,
18296 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
18298 static const DWORD vs_float_code
[] =
18303 float4 position
: SV_Position
;
18304 float4 color
: COLOR
;
18307 void main(float4 position
: POSITION
, float4 color
: ATTRIBUTE
, out output o
)
18309 o
.position
= position
;
18313 0x43425844, 0xf6051ffd, 0xd9e49503, 0x171ad197, 0x3764fe47, 0x00000001, 0x00000144, 0x00000003,
18314 0x0000002c, 0x00000080, 0x000000d4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
18315 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
18316 0x00000003, 0x00000001, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x54544100, 0x55424952, 0xab004554,
18317 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
18318 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
18319 0x505f5653, 0x7469736f, 0x006e6f69, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000068, 0x00010040,
18320 0x0000001a, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067,
18321 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2,
18322 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001,
18325 static const DWORD vs_uint_code
[] =
18330 float4 position
: SV_Position
;
18331 float4 color
: COLOR
;
18334 void main(float4 position
: POSITION
, uint4 color
: ATTRIBUTE
, out output o
)
18336 o
.position
= position
;
18340 0x43425844, 0x0bae0bc0, 0xf6473aa5, 0x4ecf4a25, 0x414fac23, 0x00000001, 0x00000144, 0x00000003,
18341 0x0000002c, 0x00000080, 0x000000d4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
18342 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
18343 0x00000001, 0x00000001, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x54544100, 0x55424952, 0xab004554,
18344 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
18345 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
18346 0x505f5653, 0x7469736f, 0x006e6f69, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000068, 0x00010040,
18347 0x0000001a, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067,
18348 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2,
18349 0x00000000, 0x00101e46, 0x00000000, 0x05000056, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001,
18352 static const DWORD vs_sint_code
[] =
18357 float4 position
: SV_Position
;
18358 float4 color
: COLOR
;
18361 void main(float4 position
: POSITION
, int4 color
: ATTRIBUTE
, out output o
)
18363 o
.position
= position
;
18367 0x43425844, 0xaf60aad9, 0xba91f3a4, 0x2015d384, 0xf746fdf5, 0x00000001, 0x00000144, 0x00000003,
18368 0x0000002c, 0x00000080, 0x000000d4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
18369 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
18370 0x00000002, 0x00000001, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x54544100, 0x55424952, 0xab004554,
18371 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
18372 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
18373 0x505f5653, 0x7469736f, 0x006e6f69, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000068, 0x00010040,
18374 0x0000001a, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067,
18375 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2,
18376 0x00000000, 0x00101e46, 0x00000000, 0x0500002b, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001,
18379 static const float float32_data
[] = {1.0f
, 2.0f
, 3.0f
, 4.0f
};
18380 static const unsigned short uint16_data
[] = {6, 8, 55, 777};
18381 static const short sint16_data
[] = {-1, 33, 8, -77};
18382 static const unsigned short unorm16_data
[] = {0, 16383, 32767, 65535};
18383 static const short snorm16_data
[] = {-32768, 0, 32767, 0};
18384 static const unsigned char uint8_data
[] = {0, 64, 128, 255};
18385 static const signed char sint8_data
[] = {-128, 0, 127, 64};
18386 static const unsigned int uint32_zero
= 0;
18387 static const unsigned int uint32_max
= 0xffffffff;
18388 static const unsigned int unorm10_2_data
= 0xa00003ff;
18389 static const unsigned int g10_data
= 0x000ffc00;
18390 static const unsigned int a2_data
= 0xc0000000;
18391 static const struct
18393 enum layout_id layout_id
;
18394 unsigned int stride
;
18396 struct vec4 expected_color
;
18401 {LAYOUT_FLOAT32
, sizeof(float32_data
), float32_data
,
18402 {1.0f
, 2.0f
, 3.0f
, 4.0f
}},
18403 {LAYOUT_UINT16
, sizeof(uint16_data
), uint16_data
,
18404 {6.0f
, 8.0f
, 55.0f
, 777.0f
}, TRUE
},
18405 {LAYOUT_SINT16
, sizeof(sint16_data
), sint16_data
,
18406 {-1.0f
, 33.0f
, 8.0f
, -77.0f
}, TRUE
},
18407 {LAYOUT_UNORM16
, sizeof(unorm16_data
), unorm16_data
,
18408 {0.0f
, 16383.0f
/ 65535.0f
, 32767.0f
/ 65535.0f
, 1.0f
}},
18409 {LAYOUT_SNORM16
, sizeof(snorm16_data
), snorm16_data
,
18410 {-1.0f
, 0.0f
, 1.0f
, 0.0f
}},
18411 {LAYOUT_UINT8
, sizeof(uint32_zero
), &uint32_zero
,
18412 {0.0f
, 0.0f
, 0.0f
, 0.0f
}},
18413 {LAYOUT_UINT8
, sizeof(uint32_max
), &uint32_max
,
18414 {255.0f
, 255.0f
, 255.0f
, 255.0f
}},
18415 {LAYOUT_UINT8
, sizeof(uint8_data
), uint8_data
,
18416 {0.0f
, 64.0f
, 128.0f
, 255.0f
}},
18417 {LAYOUT_SINT8
, sizeof(uint32_zero
), &uint32_zero
,
18418 {0.0f
, 0.0f
, 0.0f
, 0.0f
}},
18419 {LAYOUT_SINT8
, sizeof(uint32_max
), &uint32_max
,
18420 {-1.0f
, -1.0f
, -1.0f
, -1.0f
}},
18421 {LAYOUT_SINT8
, sizeof(sint8_data
), sint8_data
,
18422 {-128.0f
, 0.0f
, 127.0f
, 64.0f
}},
18423 {LAYOUT_UNORM8
, sizeof(uint32_zero
), &uint32_zero
,
18424 {0.0f
, 0.0f
, 0.0f
, 0.0f
}},
18425 {LAYOUT_UNORM8
, sizeof(uint32_max
), &uint32_max
,
18426 {1.0f
, 1.0f
, 1.0f
, 1.0f
}},
18427 {LAYOUT_UNORM8
, sizeof(uint8_data
), uint8_data
,
18428 {0.0f
, 64.0f
/ 255.0f
, 128.0f
/ 255.0f
, 1.0f
}},
18429 {LAYOUT_SNORM8
, sizeof(uint32_zero
), &uint32_zero
,
18430 {0.0f
, 0.0f
, 0.0f
, 0.0f
}},
18431 {LAYOUT_SNORM8
, sizeof(sint8_data
), sint8_data
,
18432 {-1.0f
, 0.0f
, 1.0f
, 64.0f
/ 127.0f
}},
18433 {LAYOUT_UNORM10_2
, sizeof(uint32_zero
), &uint32_zero
,
18434 {0.0f
, 0.0f
, 0.0f
, 0.0f
}},
18435 {LAYOUT_UNORM10_2
, sizeof(uint32_max
), &uint32_max
,
18436 {1.0f
, 1.0f
, 1.0f
, 1.0f
}},
18437 {LAYOUT_UNORM10_2
, sizeof(g10_data
), &g10_data
,
18438 {0.0f
, 1.0f
, 0.0f
, 0.0f
}},
18439 {LAYOUT_UNORM10_2
, sizeof(a2_data
), &a2_data
,
18440 {0.0f
, 0.0f
, 0.0f
, 1.0f
}},
18441 {LAYOUT_UNORM10_2
, sizeof(unorm10_2_data
), &unorm10_2_data
,
18442 {1.0f
, 0.0f
, 512.0f
/ 1023.0f
, 2.0f
/ 3.0f
}},
18443 {LAYOUT_UINT10_2
, sizeof(uint32_zero
), &uint32_zero
,
18444 {0.0f
, 0.0f
, 0.0f
, 0.0f
}},
18445 {LAYOUT_UINT10_2
, sizeof(uint32_max
), &uint32_max
,
18446 {1023.0f
, 1023.0f
, 1023.0f
, 3.0f
}},
18447 {LAYOUT_UINT10_2
, sizeof(g10_data
), &g10_data
,
18448 {0.0f
, 1023.0f
, 0.0f
, 0.0f
}},
18449 {LAYOUT_UINT10_2
, sizeof(a2_data
), &a2_data
,
18450 {0.0f
, 0.0f
, 0.0f
, 3.0f
}},
18451 {LAYOUT_UINT10_2
, sizeof(unorm10_2_data
), &unorm10_2_data
,
18452 {1023.0f
, 0.0f
, 512.0f
, 2.0f
}},
18455 if (!init_test_context(&test_context
, NULL
))
18458 device
= test_context
.device
;
18459 context
= test_context
.immediate_context
;
18461 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
18462 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
18464 hr
= ID3D11Device_CreateVertexShader(device
, vs_float_code
, sizeof(vs_float_code
), NULL
, &vs_float
);
18465 ok(SUCCEEDED(hr
), "Failed to create float vertex shader, hr %#x.\n", hr
);
18466 hr
= ID3D11Device_CreateVertexShader(device
, vs_uint_code
, sizeof(vs_uint_code
), NULL
, &vs_uint
);
18467 ok(SUCCEEDED(hr
), "Failed to create uint vertex shader, hr %#x.\n", hr
);
18468 hr
= ID3D11Device_CreateVertexShader(device
, vs_sint_code
, sizeof(vs_sint_code
), NULL
, &vs_sint
);
18469 ok(SUCCEEDED(hr
), "Failed to create sint vertex shader, hr %#x.\n", hr
);
18471 for (i
= 0; i
< LAYOUT_COUNT
; ++i
)
18473 input_layout_desc
[1].Format
= layout_formats
[i
];
18474 input_layout
[i
] = NULL
;
18475 hr
= ID3D11Device_CreateInputLayout(device
, input_layout_desc
, ARRAY_SIZE(input_layout_desc
),
18476 vs_float_code
, sizeof(vs_float_code
), &input_layout
[i
]);
18477 todo_wine_if(input_layout_desc
[1].Format
== DXGI_FORMAT_R10G10B10A2_UINT
)
18478 ok(SUCCEEDED(hr
), "Failed to create input layout for format %#x, hr %#x.\n", layout_formats
[i
], hr
);
18481 vb_position
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(quad
), quad
);
18482 vb_attribute
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, 1024, NULL
);
18484 texture_desc
.Width
= 640;
18485 texture_desc
.Height
= 480;
18486 texture_desc
.MipLevels
= 1;
18487 texture_desc
.ArraySize
= 1;
18488 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
18489 texture_desc
.SampleDesc
.Count
= 1;
18490 texture_desc
.SampleDesc
.Quality
= 0;
18491 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
18492 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
18493 texture_desc
.CPUAccessFlags
= 0;
18494 texture_desc
.MiscFlags
= 0;
18496 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &render_target
);
18497 ok(SUCCEEDED(hr
), "Failed to create 2d texture, hr %#x.\n", hr
);
18499 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)render_target
, NULL
, &rtv
);
18500 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
18502 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
18504 stride
= sizeof(*quad
);
18505 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb_position
, &stride
, &offset
);
18506 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
18507 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
18509 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
18511 D3D11_BOX box
= {0, 0, 0, 1, 1, 1};
18513 if (tests
[i
].layout_id
== LAYOUT_UINT10_2
)
18516 assert(tests
[i
].layout_id
< LAYOUT_COUNT
);
18517 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
[tests
[i
].layout_id
]);
18519 assert(4 * tests
[i
].stride
<= 1024);
18520 box
.right
= tests
[i
].stride
;
18521 for (j
= 0; j
< 4; ++j
)
18523 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb_attribute
, 0,
18524 &box
, tests
[i
].data
, 0, 0);
18525 box
.left
+= tests
[i
].stride
;
18526 box
.right
+= tests
[i
].stride
;
18529 stride
= tests
[i
].stride
;
18530 ID3D11DeviceContext_IASetVertexBuffers(context
, 1, 1, &vb_attribute
, &stride
, &offset
);
18532 switch (layout_formats
[tests
[i
].layout_id
])
18534 case DXGI_FORMAT_R16G16B16A16_UINT
:
18535 case DXGI_FORMAT_R10G10B10A2_UINT
:
18536 case DXGI_FORMAT_R8G8B8A8_UINT
:
18537 ID3D11DeviceContext_VSSetShader(context
, vs_uint
, NULL
, 0);
18539 case DXGI_FORMAT_R16G16B16A16_SINT
:
18540 case DXGI_FORMAT_R8G8B8A8_SINT
:
18541 ID3D11DeviceContext_VSSetShader(context
, vs_sint
, NULL
, 0);
18545 trace("Unhandled format %#x.\n", layout_formats
[tests
[i
].layout_id
]);
18546 /* Fall through. */
18547 case DXGI_FORMAT_R32G32B32A32_FLOAT
:
18548 case DXGI_FORMAT_R16G16B16A16_UNORM
:
18549 case DXGI_FORMAT_R16G16B16A16_SNORM
:
18550 case DXGI_FORMAT_R10G10B10A2_UNORM
:
18551 case DXGI_FORMAT_R8G8B8A8_UNORM
:
18552 case DXGI_FORMAT_R8G8B8A8_SNORM
:
18553 ID3D11DeviceContext_VSSetShader(context
, vs_float
, NULL
, 0);
18557 ID3D11DeviceContext_Draw(context
, 4, 0);
18558 check_texture_vec4(render_target
, &tests
[i
].expected_color
, 2);
18561 ID3D11Texture2D_Release(render_target
);
18562 ID3D11RenderTargetView_Release(rtv
);
18563 ID3D11Buffer_Release(vb_attribute
);
18564 ID3D11Buffer_Release(vb_position
);
18565 for (i
= 0; i
< LAYOUT_COUNT
; ++i
)
18567 if (input_layout
[i
])
18568 ID3D11InputLayout_Release(input_layout
[i
]);
18570 ID3D11PixelShader_Release(ps
);
18571 ID3D11VertexShader_Release(vs_float
);
18572 ID3D11VertexShader_Release(vs_uint
);
18573 ID3D11VertexShader_Release(vs_sint
);
18574 release_test_context(&test_context
);
18577 static void test_null_sampler(void)
18579 struct d3d11_test_context test_context
;
18580 D3D11_TEXTURE2D_DESC texture_desc
;
18581 ID3D11ShaderResourceView
*srv
;
18582 ID3D11DeviceContext
*context
;
18583 ID3D11RenderTargetView
*rtv
;
18584 ID3D11SamplerState
*sampler
;
18585 ID3D11Texture2D
*texture
;
18586 ID3D11PixelShader
*ps
;
18587 ID3D11Device
*device
;
18590 static const DWORD ps_code
[] =
18596 float4
main(float4 position
: SV_POSITION
) : SV_Target
18598 return t
.Sample(s
, float2(position
.x
/ 640.0f
, position
.y
/ 480.0f
));
18601 0x43425844, 0x1ce9b612, 0xc8176faa, 0xd37844af, 0xdb515605, 0x00000001, 0x00000134, 0x00000003,
18602 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
18603 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
18604 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
18605 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
18606 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
18607 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
18608 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
18609 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
18610 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
18612 static const float blue
[] = {0.0f
, 0.0f
, 1.0f
, 1.0f
};
18614 if (!init_test_context(&test_context
, NULL
))
18617 device
= test_context
.device
;
18618 context
= test_context
.immediate_context
;
18620 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
18621 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
18623 texture_desc
.Width
= 64;
18624 texture_desc
.Height
= 64;
18625 texture_desc
.MipLevels
= 1;
18626 texture_desc
.ArraySize
= 1;
18627 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
18628 texture_desc
.SampleDesc
.Count
= 1;
18629 texture_desc
.SampleDesc
.Quality
= 0;
18630 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
18631 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
;
18632 texture_desc
.CPUAccessFlags
= 0;
18633 texture_desc
.MiscFlags
= 0;
18635 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
18636 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
18638 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
18639 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
18641 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
18642 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
18644 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, blue
);
18646 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
18647 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
18649 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler
);
18650 draw_quad(&test_context
);
18651 check_texture_color(test_context
.backbuffer
, 0xffff0000, 0);
18653 ID3D11ShaderResourceView_Release(srv
);
18654 ID3D11RenderTargetView_Release(rtv
);
18655 ID3D11Texture2D_Release(texture
);
18656 ID3D11PixelShader_Release(ps
);
18657 release_test_context(&test_context
);
18660 static void test_check_feature_support(void)
18662 D3D11_FEATURE_DATA_THREADING threading
[2];
18663 D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS hwopts
;
18664 D3D11_FEATURE_DATA_ARCHITECTURE_INFO archinfo
;
18665 ID3D11Device
*device
;
18669 if (!(device
= create_device(NULL
)))
18671 skip("Failed to create device.\n");
18675 memset(threading
, 0xef, sizeof(threading
));
18677 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_THREADING
, NULL
, 0);
18678 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
18679 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_THREADING
, threading
, 0);
18680 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
18681 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_THREADING
, threading
, sizeof(*threading
) - 1);
18682 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
18683 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_THREADING
, threading
, sizeof(*threading
) / 2);
18684 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
18685 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_THREADING
, threading
, sizeof(*threading
) + 1);
18686 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
18687 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_THREADING
, threading
, sizeof(*threading
) * 2);
18688 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
18690 ok(threading
[0].DriverConcurrentCreates
== 0xefefefef,
18691 "Got unexpected concurrent creates %#x.\n", threading
[0].DriverConcurrentCreates
);
18692 ok(threading
[0].DriverCommandLists
== 0xefefefef,
18693 "Got unexpected command lists %#x.\n", threading
[0].DriverCommandLists
);
18694 ok(threading
[1].DriverConcurrentCreates
== 0xefefefef,
18695 "Got unexpected concurrent creates %#x.\n", threading
[1].DriverConcurrentCreates
);
18696 ok(threading
[1].DriverCommandLists
== 0xefefefef,
18697 "Got unexpected command lists %#x.\n", threading
[1].DriverCommandLists
);
18699 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_THREADING
, threading
, sizeof(*threading
));
18700 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
18701 ok(threading
->DriverConcurrentCreates
== TRUE
|| threading
->DriverConcurrentCreates
== FALSE
,
18702 "Got unexpected concurrent creates %#x.\n", threading
->DriverConcurrentCreates
);
18703 ok(threading
->DriverCommandLists
== TRUE
|| threading
->DriverCommandLists
== FALSE
,
18704 "Got unexpected command lists %#x.\n", threading
->DriverCommandLists
);
18706 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
, NULL
, 0);
18707 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
18708 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
, &hwopts
, 0);
18709 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
18710 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
, &hwopts
, sizeof(hwopts
) - 1);
18711 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
18712 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
, &hwopts
, sizeof(hwopts
) / 2);
18713 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
18714 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
, &hwopts
, sizeof(hwopts
) + 1);
18715 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
18716 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
, &hwopts
, sizeof(hwopts
) * 2);
18717 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
18719 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS
, &hwopts
, sizeof(hwopts
));
18720 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
18721 trace("Compute shader support via SM4 %#x.\n", hwopts
.ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x
);
18723 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_ARCHITECTURE_INFO
, &archinfo
, sizeof(archinfo
));
18724 ok(hr
== S_OK
|| broken(hr
== E_INVALIDARG
) /* Not available on all Windows versions. */,
18725 "Got unexpected hr %#x.\n", hr
);
18726 hr
= ID3D11Device_CheckFeatureSupport(device
, D3D11_FEATURE_ARCHITECTURE_INFO
, &archinfo
, sizeof(archinfo
)*2);
18727 ok(hr
== E_INVALIDARG
/* Not available on all Windows versions but they will return E_INVALIDARG anyways. */,
18728 "Got unexpected hr %#x.\n", hr
);
18730 refcount
= ID3D11Device_Release(device
);
18731 ok(!refcount
, "Device has %u references left.\n", refcount
);
18734 static void test_create_unordered_access_view(void)
18736 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
18737 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
18738 D3D11_TEXTURE3D_DESC texture3d_desc
;
18739 D3D11_TEXTURE2D_DESC texture2d_desc
;
18740 ULONG refcount
, expected_refcount
;
18741 D3D11_SUBRESOURCE_DATA data
= {0};
18742 ID3D11UnorderedAccessView
*uav
;
18743 struct device_desc device_desc
;
18744 D3D11_BUFFER_DESC buffer_desc
;
18745 ID3D11Device
*device
, *tmp
;
18746 ID3D11Texture3D
*texture3d
;
18747 ID3D11Texture2D
*texture2d
;
18748 ID3D11Resource
*texture
;
18749 ID3D11Buffer
*buffer
;
18753 #define FMT_UNKNOWN DXGI_FORMAT_UNKNOWN
18754 #define RGBA8_UNORM DXGI_FORMAT_R8G8B8A8_UNORM
18755 #define RGBA8_SRGB DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
18756 #define RGBA8_UINT DXGI_FORMAT_R8G8B8A8_UINT
18757 #define RGBA8_TL DXGI_FORMAT_R8G8B8A8_TYPELESS
18758 #define DIM_UNKNOWN D3D11_UAV_DIMENSION_UNKNOWN
18759 #define TEX_1D D3D11_UAV_DIMENSION_TEXTURE1D
18760 #define TEX_1D_ARRAY D3D11_UAV_DIMENSION_TEXTURE1DARRAY
18761 #define TEX_2D D3D11_UAV_DIMENSION_TEXTURE2D
18762 #define TEX_2D_ARRAY D3D11_UAV_DIMENSION_TEXTURE2DARRAY
18763 #define TEX_3D D3D11_UAV_DIMENSION_TEXTURE3D
18764 static const struct
18768 unsigned int miplevel_count
;
18769 unsigned int depth_or_array_size
;
18770 DXGI_FORMAT format
;
18772 struct uav_desc uav_desc
;
18773 struct uav_desc expected_uav_desc
;
18777 {{ 1, 1, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D
, 0}},
18778 {{10, 1, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D
, 0}},
18779 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D
, 0}, {RGBA8_UNORM
, TEX_2D
, 0}},
18780 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D
, 1}, {RGBA8_UNORM
, TEX_2D
, 1}},
18781 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D
, 9}, {RGBA8_UNORM
, TEX_2D
, 9}},
18782 {{ 1, 1, RGBA8_TL
}, {RGBA8_UNORM
, TEX_2D
, 0}, {RGBA8_UNORM
, TEX_2D
, 0}},
18783 {{10, 1, RGBA8_TL
}, {RGBA8_UNORM
, TEX_2D
, 0}, {RGBA8_UNORM
, TEX_2D
, 0}},
18784 {{ 1, 1, RGBA8_UINT
}, {0}, {RGBA8_UINT
, TEX_2D
, 0, 0, 1}},
18785 {{ 1, 1, RGBA8_TL
}, {RGBA8_UINT
, TEX_2D
, 0, 0, ~0u}, {RGBA8_UINT
, TEX_2D
, 0, 0, 1}},
18786 {{ 1, 4, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 4}},
18787 {{10, 4, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 4}},
18788 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 4}},
18789 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 1, 0, 4}},
18790 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 3, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 3, 0, 4}},
18791 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 5, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 5, 0, 4}},
18792 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 9, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 9, 0, 4}},
18793 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 1, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 3}},
18794 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 2, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 2, 2}},
18795 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 3, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 3, 1}},
18796 {{ 1, 6, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 6}},
18797 {{ 2, 6, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 6}},
18798 {{ 2, 6, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 6}},
18799 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 2}},
18800 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 2}},
18801 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 1, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 1, 3}},
18802 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 2, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 2, 2}},
18803 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 3, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 3, 1}},
18804 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 1, 1}, {RGBA8_UNORM
, TEX_3D
, 0, 1, 1}},
18805 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 1, 1}, {RGBA8_UNORM
, TEX_3D
, 1, 1, 1}},
18806 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 1, ~0u}, {RGBA8_UNORM
, TEX_3D
, 1, 1, 1}},
18807 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 8}},
18808 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 4}},
18809 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 2, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 2, 0, 2}},
18810 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 3, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 3, 0, 1}},
18811 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 4, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 4, 0, 1}},
18812 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 5, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 5, 0, 1}},
18814 static const struct
18818 D3D11_UAV_DIMENSION dimension
;
18819 unsigned int miplevel_count
;
18820 unsigned int depth_or_array_size
;
18821 DXGI_FORMAT format
;
18823 struct uav_desc uav_desc
;
18825 invalid_desc_tests
[] =
18827 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, DIM_UNKNOWN
}},
18828 {{TEX_2D
, 6, 4, RGBA8_UNORM
}, {RGBA8_UNORM
, DIM_UNKNOWN
}},
18829 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0}},
18830 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 0, 1}},
18831 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 1}},
18832 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, ~0u}},
18833 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_2D
, 0}},
18834 {{TEX_2D
, 1, 1, RGBA8_TL
}, {FMT_UNKNOWN
, TEX_2D
, 0}},
18835 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 1}},
18836 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 0}},
18837 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 1, 0, 1}},
18838 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 2}},
18839 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 1}},
18840 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UINT
, TEX_2D
, 0, 0, 1}},
18841 {{TEX_2D
, 1, 1, RGBA8_UINT
}, {RGBA8_UNORM
, TEX_2D
, 0, 0, 1}},
18842 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_SRGB
, TEX_2D
, 0, 0, 1}},
18843 {{TEX_2D
, 1, 1, RGBA8_SRGB
}, {RGBA8_UNORM
, TEX_2D
, 0, 0, 1}},
18844 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0}},
18845 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 0, 1}},
18846 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0}},
18847 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 1}},
18848 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0}},
18849 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 0, 1}},
18850 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0}},
18851 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 1}},
18852 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 0}},
18853 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 1}},
18854 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_3D
, 0, 0, 1}},
18855 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_TL
, TEX_3D
, 0, 0, 1}},
18856 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 9}},
18857 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 3, 0, 2}},
18858 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 2, 0, 4}},
18859 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 8}},
18860 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 8, ~0u}},
18861 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 4, ~0u}},
18862 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 2, 2, ~0u}},
18863 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 3, 1, ~0u}},
18872 #undef TEX_1D_ARRAY
18874 #undef TEX_2D_ARRAY
18877 device_desc
.feature_level
= &feature_level
;
18878 device_desc
.flags
= 0;
18879 if (!(device
= create_device(&device_desc
)))
18881 skip("Failed to create device.\n");
18885 buffer_desc
.ByteWidth
= 1024;
18886 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
18887 buffer_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
18888 buffer_desc
.CPUAccessFlags
= 0;
18889 buffer_desc
.MiscFlags
= 0;
18890 buffer_desc
.StructureByteStride
= 0;
18892 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &data
, &buffer
);
18893 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
18895 expected_refcount
= get_refcount(device
) + 1;
18896 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
18897 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
18898 refcount
= get_refcount(device
);
18899 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
18901 expected_refcount
= refcount
+ 1;
18902 ID3D11Buffer_GetDevice(buffer
, &tmp
);
18903 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
18904 refcount
= get_refcount(device
);
18905 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
18906 ID3D11Device_Release(tmp
);
18908 uav_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
18909 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
18910 U(uav_desc
).Buffer
.FirstElement
= 0;
18911 U(uav_desc
).Buffer
.NumElements
= 64;
18912 U(uav_desc
).Buffer
.Flags
= 0;
18914 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, NULL
, &uav
);
18915 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
18917 expected_refcount
= get_refcount(device
) + 1;
18918 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
18919 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
18920 refcount
= get_refcount(device
);
18921 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
18923 expected_refcount
= refcount
+ 1;
18924 ID3D11UnorderedAccessView_GetDevice(uav
, &tmp
);
18925 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
18926 refcount
= get_refcount(device
);
18927 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
18928 ID3D11Device_Release(tmp
);
18930 ID3D11UnorderedAccessView_Release(uav
);
18931 ID3D11Buffer_Release(buffer
);
18933 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
;
18934 buffer_desc
.StructureByteStride
= 4;
18936 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
18937 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
18939 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, NULL
, &uav
);
18940 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
18942 memset(&uav_desc
, 0, sizeof(uav_desc
));
18943 ID3D11UnorderedAccessView_GetDesc(uav
, &uav_desc
);
18945 ok(uav_desc
.Format
== DXGI_FORMAT_UNKNOWN
, "Got unexpected format %#x.\n", uav_desc
.Format
);
18946 ok(uav_desc
.ViewDimension
== D3D11_UAV_DIMENSION_BUFFER
, "Got unexpected view dimension %#x.\n",
18947 uav_desc
.ViewDimension
);
18948 ok(!U(uav_desc
).Buffer
.FirstElement
, "Got unexpected first element %u.\n", U(uav_desc
).Buffer
.FirstElement
);
18949 ok(U(uav_desc
).Buffer
.NumElements
== 256, "Got unexpected num elements %u.\n", U(uav_desc
).Buffer
.NumElements
);
18950 ok(!U(uav_desc
).Buffer
.Flags
, "Got unexpected flags %u.\n", U(uav_desc
).Buffer
.Flags
);
18952 ID3D11UnorderedAccessView_Release(uav
);
18953 ID3D11Buffer_Release(buffer
);
18955 /* Without D3D11_BIND_UNORDERED_ACCESS. */
18956 buffer
= create_buffer(device
, 0, 1024, NULL
);
18958 uav_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
18959 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
18960 U(uav_desc
).Buffer
.FirstElement
= 0;
18961 U(uav_desc
).Buffer
.NumElements
= 64;
18962 U(uav_desc
).Buffer
.Flags
= 0;
18964 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
18965 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
18967 ID3D11Buffer_Release(buffer
);
18969 texture2d_desc
.Width
= 512;
18970 texture2d_desc
.Height
= 512;
18971 texture2d_desc
.SampleDesc
.Count
= 1;
18972 texture2d_desc
.SampleDesc
.Quality
= 0;
18973 texture2d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
18974 texture2d_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
18975 texture2d_desc
.CPUAccessFlags
= 0;
18976 texture2d_desc
.MiscFlags
= 0;
18978 texture3d_desc
.Width
= 64;
18979 texture3d_desc
.Height
= 64;
18980 texture3d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
18981 texture3d_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
18982 texture3d_desc
.CPUAccessFlags
= 0;
18983 texture3d_desc
.MiscFlags
= 0;
18985 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
18987 D3D11_UNORDERED_ACCESS_VIEW_DESC
*current_desc
;
18989 if (tests
[i
].expected_uav_desc
.dimension
!= D3D11_UAV_DIMENSION_TEXTURE3D
)
18991 texture2d_desc
.MipLevels
= tests
[i
].texture
.miplevel_count
;
18992 texture2d_desc
.ArraySize
= tests
[i
].texture
.depth_or_array_size
;
18993 texture2d_desc
.Format
= tests
[i
].texture
.format
;
18995 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, &texture2d
);
18996 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
18997 texture
= (ID3D11Resource
*)texture2d
;
19001 texture3d_desc
.MipLevels
= tests
[i
].texture
.miplevel_count
;
19002 texture3d_desc
.Depth
= tests
[i
].texture
.depth_or_array_size
;
19003 texture3d_desc
.Format
= tests
[i
].texture
.format
;
19005 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &texture3d
);
19006 ok(SUCCEEDED(hr
), "Test %u: Failed to create 3d texture, hr %#x.\n", i
, hr
);
19007 texture
= (ID3D11Resource
*)texture3d
;
19010 if (tests
[i
].uav_desc
.dimension
== D3D11_UAV_DIMENSION_UNKNOWN
)
19012 current_desc
= NULL
;
19016 current_desc
= &uav_desc
;
19017 get_uav_desc(current_desc
, &tests
[i
].uav_desc
);
19020 expected_refcount
= get_refcount(texture
);
19021 hr
= ID3D11Device_CreateUnorderedAccessView(device
, texture
, current_desc
, &uav
);
19022 ok(SUCCEEDED(hr
), "Test %u: Failed to create unordered access view, hr %#x.\n", i
, hr
);
19023 refcount
= get_refcount(texture
);
19024 ok(refcount
== expected_refcount
, "Got refcount %u, expected %u.\n", refcount
, expected_refcount
);
19026 memset(&uav_desc
, 0, sizeof(uav_desc
));
19027 ID3D11UnorderedAccessView_GetDesc(uav
, &uav_desc
);
19028 check_uav_desc(&uav_desc
, &tests
[i
].expected_uav_desc
);
19030 ID3D11UnorderedAccessView_Release(uav
);
19031 ID3D11Resource_Release(texture
);
19034 for (i
= 0; i
< ARRAY_SIZE(invalid_desc_tests
); ++i
)
19036 assert(invalid_desc_tests
[i
].texture
.dimension
== D3D11_UAV_DIMENSION_TEXTURE2D
19037 || invalid_desc_tests
[i
].texture
.dimension
== D3D11_UAV_DIMENSION_TEXTURE3D
);
19039 if (invalid_desc_tests
[i
].texture
.dimension
!= D3D11_UAV_DIMENSION_TEXTURE3D
)
19041 texture2d_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
19042 texture2d_desc
.ArraySize
= invalid_desc_tests
[i
].texture
.depth_or_array_size
;
19043 texture2d_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
19045 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, &texture2d
);
19046 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
19047 texture
= (ID3D11Resource
*)texture2d
;
19051 texture3d_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
19052 texture3d_desc
.Depth
= invalid_desc_tests
[i
].texture
.depth_or_array_size
;
19053 texture3d_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
19055 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &texture3d
);
19056 ok(SUCCEEDED(hr
), "Test %u: Failed to create 3d texture, hr %#x.\n", i
, hr
);
19057 texture
= (ID3D11Resource
*)texture3d
;
19060 get_uav_desc(&uav_desc
, &invalid_desc_tests
[i
].uav_desc
);
19061 hr
= ID3D11Device_CreateUnorderedAccessView(device
, texture
, &uav_desc
, &uav
);
19062 ok(hr
== E_INVALIDARG
, "Test %u: Got unexpected hr %#x.\n", i
, hr
);
19064 ID3D11Resource_Release(texture
);
19067 refcount
= ID3D11Device_Release(device
);
19068 ok(!refcount
, "Device has %u references left.\n", refcount
);
19071 static void test_immediate_constant_buffer(void)
19073 struct d3d11_test_context test_context
;
19074 D3D11_TEXTURE2D_DESC texture_desc
;
19075 ID3D11DeviceContext
*context
;
19076 ID3D11RenderTargetView
*rtv
;
19077 unsigned int index
[4] = {0};
19078 ID3D11Texture2D
*texture
;
19079 ID3D11PixelShader
*ps
;
19080 ID3D11Device
*device
;
19085 static const DWORD ps_code
[] =
19090 static const int int_array
[6] =
19092 310, 111, 212, -513, -318, 0,
19095 static const uint uint_array
[6] =
19097 2, 7, 0x7f800000, 0xff800000, 0x7fc00000, 0
19100 static const float float_array
[6] =
19102 76, 83.5f
, 0.5f
, 0.75f
, -0.5f
, 0.0f
,
19105 float4
main() : SV_Target
19107 return float4(int_array
[index
], uint_array
[index
], float_array
[index
], 1.0f
);
19110 0x43425844, 0xbad068da, 0xd631ea3c, 0x41648374, 0x3ccd0120, 0x00000001, 0x00000184, 0x00000003,
19111 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19112 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
19113 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x0000010c, 0x00000040, 0x00000043,
19114 0x00001835, 0x0000001a, 0x00000136, 0x00000002, 0x42980000, 0x00000000, 0x0000006f, 0x00000007,
19115 0x42a70000, 0x00000000, 0x000000d4, 0x7f800000, 0x3f000000, 0x00000000, 0xfffffdff, 0xff800000,
19116 0x3f400000, 0x00000000, 0xfffffec2, 0x7fc00000, 0xbf000000, 0x00000000, 0x00000000, 0x00000000,
19117 0x00000000, 0x00000000, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2,
19118 0x00000000, 0x02000068, 0x00000001, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x3f800000,
19119 0x06000036, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x06000056, 0x00102022,
19120 0x00000000, 0x0090901a, 0x0010000a, 0x00000000, 0x0600002b, 0x00102012, 0x00000000, 0x0090900a,
19121 0x0010000a, 0x00000000, 0x06000036, 0x00102042, 0x00000000, 0x0090902a, 0x0010000a, 0x00000000,
19124 static struct vec4 expected_result
[] =
19126 { 310.0f
, 2.0f
, 76.00f
, 1.0f
},
19127 { 111.0f
, 7.0f
, 83.50f
, 1.0f
},
19128 { 212.0f
, 2139095040.0f
, 0.50f
, 1.0f
},
19129 {-513.0f
, 4286578688.0f
, 0.75f
, 1.0f
},
19130 {-318.0f
, 2143289344.0f
, -0.50f
, 1.0f
},
19131 { 0.0f
, 0.0f
, 0.0f
, 1.0f
},
19134 if (!init_test_context(&test_context
, NULL
))
19137 device
= test_context
.device
;
19138 context
= test_context
.immediate_context
;
19140 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
19141 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
19142 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
19144 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(index
), NULL
);
19145 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
19147 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
19148 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
19149 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
19150 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
19152 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
19153 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
19154 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
19156 for (i
= 0; i
< ARRAY_SIZE(expected_result
); ++i
)
19159 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, index
, 0, 0);
19161 draw_quad(&test_context
);
19162 check_texture_vec4(texture
, &expected_result
[i
], 0);
19165 ID3D11Buffer_Release(cb
);
19166 ID3D11PixelShader_Release(ps
);
19167 ID3D11Texture2D_Release(texture
);
19168 ID3D11RenderTargetView_Release(rtv
);
19169 release_test_context(&test_context
);
19172 static void test_fp_specials(void)
19174 struct d3d11_test_context test_context
;
19175 D3D11_TEXTURE2D_DESC texture_desc
;
19176 ID3D11DeviceContext
*context
;
19177 ID3D11RenderTargetView
*rtv
;
19178 ID3D11Texture2D
*texture
;
19179 ID3D11PixelShader
*ps
;
19180 ID3D11Device
*device
;
19183 static const DWORD ps_code
[] =
19186 float4
main() : SV_Target
19188 return float4(0.0f
/ 0.0f
, 1.0f
/ 0.0f
, -1.0f
/ 0.0f
, 1.0f
);
19191 0x43425844, 0x86d7f319, 0x14cde598, 0xe7ce83a8, 0x0e06f3f0, 0x00000001, 0x000000b0, 0x00000003,
19192 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19193 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
19194 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
19195 0x03000065, 0x001020f2, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0xffc00000,
19196 0x7f800000, 0xff800000, 0x3f800000, 0x0100003e,
19198 static const struct uvec4 expected_result
= {BITS_NNAN
, BITS_INF
, BITS_NINF
, BITS_1_0
};
19200 if (!init_test_context(&test_context
, NULL
))
19203 device
= test_context
.device
;
19204 context
= test_context
.immediate_context
;
19206 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
19207 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
19208 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
19210 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
19211 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
19212 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
19213 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
19215 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
19216 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
19218 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
19220 draw_quad(&test_context
);
19221 check_texture_uvec4(texture
, &expected_result
);
19223 ID3D11PixelShader_Release(ps
);
19224 ID3D11Texture2D_Release(texture
);
19225 ID3D11RenderTargetView_Release(rtv
);
19226 release_test_context(&test_context
);
19229 static void test_uint_shader_instructions(void)
19235 D3D_FEATURE_LEVEL required_feature_level
;
19238 struct d3d11_test_context test_context
;
19239 D3D11_TEXTURE2D_DESC texture_desc
;
19240 D3D_FEATURE_LEVEL feature_level
;
19241 ID3D11DeviceContext
*context
;
19242 ID3D11RenderTargetView
*rtv
;
19243 ID3D11Texture2D
*texture
;
19244 ID3D11PixelShader
*ps
;
19245 ID3D11Device
*device
;
19250 static const DWORD ps_bfi_code
[] =
19253 uint bits
, offset
, insert
, base
;
19255 uint4
main() : SV_Target
19257 uint mask
= ((1 << bits
) - 1) << offset
;
19258 return ((insert
<< offset
) & mask
) | (base
& ~mask
);
19261 0x43425844, 0xbe9af688, 0xf5caec6f, 0x63ed2522, 0x5f91f209, 0x00000001, 0x000000e0, 0x00000003,
19262 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19263 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
19264 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000068, 0x00000050, 0x0000001a,
19265 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
19266 0x0f00008c, 0x001020f2, 0x00000000, 0x00208006, 0x00000000, 0x00000000, 0x00208556, 0x00000000,
19267 0x00000000, 0x00208aa6, 0x00000000, 0x00000000, 0x00208ff6, 0x00000000, 0x00000000, 0x0100003e,
19269 static const DWORD ps_bfi2_code
[] =
19273 dcl_globalFlags refactoringAllowed
19274 dcl_constantbuffer cb0
[1], immediateIndexed
19277 mov r0
.xyzw
, cb0
[0].xyzw
19278 bfi r0
.xyzw
, r0
.xxxx
, r0
.yyyy
, r0
.zzzz
, r0
.wwww
19279 mov o0
.xyzw
, r0
.xyzw
19282 0x43425844, 0x900f86b6, 0x73f4dabf, 0xea1b1106, 0x591ac790, 0x00000001, 0x00000104, 0x00000003,
19283 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19284 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
19285 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000008c, 0x00000050, 0x00000023,
19286 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
19287 0x02000068, 0x00000001, 0x06000036, 0x001000f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000000,
19288 0x0b00008c, 0x001000f2, 0x00000000, 0x00100006, 0x00000000, 0x00100556, 0x00000000, 0x00100aa6,
19289 0x00000000, 0x00100ff6, 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
19292 static const DWORD ps_ibfe_code
[] =
19296 dcl_globalFlags refactoringAllowed
19297 dcl_constantbuffer cb0
[1], immediateIndexed
19299 ibfe o0
.xyzw
, cb0
[0].xxxx
, cb0
[0].yyyy
, cb0
[0].zzzz
19302 0x43425844, 0x4b2225f7, 0xd0860f66, 0xe38775bb, 0x6d23d1d2, 0x00000001, 0x000000d4, 0x00000003,
19303 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19304 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
19305 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000005c, 0x00000050, 0x00000017,
19306 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
19307 0x0c00008b, 0x001020f2, 0x00000000, 0x00208006, 0x00000000, 0x00000000, 0x00208556, 0x00000000,
19308 0x00000000, 0x00208aa6, 0x00000000, 0x00000000, 0x0100003e,
19310 static const DWORD ps_ibfe2_code
[] =
19314 dcl_globalFlags refactoringAllowed
19315 dcl_constantbuffer cb0
[1], immediateIndexed
19318 mov r0
.xyzw
, cb0
[0].xyzw
19319 ibfe r0
.xyzw
, r0
.xxxx
, r0
.yyyy
, r0
.zzzz
19320 mov o0
.xyzw
, r0
.xyzw
19323 0x43425844, 0x347a9c0e, 0x3eff39a4, 0x3dd41cc5, 0xff87ec8d, 0x00000001, 0x000000fc, 0x00000003,
19324 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19325 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
19326 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000084, 0x00000050, 0x00000021,
19327 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
19328 0x02000068, 0x00000001, 0x06000036, 0x001000f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000000,
19329 0x0900008b, 0x001000f2, 0x00000000, 0x00100006, 0x00000000, 0x00100556, 0x00000000, 0x00100aa6,
19330 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x0100003e,
19332 static const DWORD ps_ubfe_code
[] =
19337 uint4
main() : SV_Target
19339 return uint4((u
& 0xf0) >> 4, (u
& 0x7fffff00) >> 8, (u
& 0xfe) >> 1, (u
& 0x7fffffff) >> 1);
19342 0x43425844, 0xc4ac0509, 0xaea83154, 0xf1fb3b80, 0x4c22e3cc, 0x00000001, 0x000000e4, 0x00000003,
19343 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19344 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
19345 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000006c, 0x00000050, 0x0000001b,
19346 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
19347 0x1000008a, 0x001020f2, 0x00000000, 0x00004002, 0x00000004, 0x00000017, 0x00000007, 0x0000001e,
19348 0x00004002, 0x00000004, 0x00000008, 0x00000001, 0x00000001, 0x00208006, 0x00000000, 0x00000000,
19351 static const DWORD ps_ubfe2_code
[] =
19355 dcl_globalFlags refactoringAllowed
19356 dcl_constantbuffer cb0
[1], immediateIndexed
19359 mov r0
.xyzw
, cb0
[0].xyzw
19360 ubfe r0
.xyzw
, r0
.xxxx
, r0
.yyyy
, r0
.zzzz
19361 mov o0
.xyzw
, r0
.xyzw
19364 0x43425844, 0xf377b7fc, 0x1e4cb9e7, 0xb9b1020d, 0xde484388, 0x00000001, 0x000000fc, 0x00000003,
19365 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19366 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
19367 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000084, 0x00000050, 0x00000021,
19368 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
19369 0x02000068, 0x00000001, 0x06000036, 0x001000f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000000,
19370 0x0900008a, 0x001000f2, 0x00000000, 0x00100006, 0x00000000, 0x00100556, 0x00000000, 0x00100aa6,
19371 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x0100003e,
19373 static const DWORD ps_bfrev_code
[] =
19378 uint4
main() : SV_Target
19380 return uint4(reversebits(bits
), reversebits(reversebits(bits
)),
19381 reversebits(bits
& 0xFFFF), reversebits(bits
>> 16));
19384 0x43425844, 0x73daef82, 0xe52befa3, 0x8504d5f0, 0xebdb321d, 0x00000001, 0x00000154, 0x00000003,
19385 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19386 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
19387 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000dc, 0x00000050, 0x00000037,
19388 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
19389 0x02000068, 0x00000001, 0x08000001, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000,
19390 0x00004001, 0x0000ffff, 0x0500008d, 0x00102042, 0x00000000, 0x0010000a, 0x00000000, 0x08000055,
19391 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x00004001, 0x00000010, 0x0500008d,
19392 0x00102082, 0x00000000, 0x0010000a, 0x00000000, 0x0600008d, 0x00100012, 0x00000000, 0x0020800a,
19393 0x00000000, 0x00000000, 0x0500008d, 0x00102022, 0x00000000, 0x0010000a, 0x00000000, 0x05000036,
19394 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0100003e,
19396 static const DWORD ps_bits_code
[] =
19402 uint4
main() : SV_Target
19404 return uint4(countbits(u
), firstbitlow(u
), firstbithigh(u
), firstbithigh(i
));
19407 0x43425844, 0x23fee911, 0x145287d1, 0xea904419, 0x8aa59a6a, 0x00000001, 0x000001b4, 0x00000003,
19408 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19409 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
19410 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000013c, 0x00000050, 0x0000004f,
19411 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
19412 0x02000068, 0x00000001, 0x06000089, 0x00100012, 0x00000000, 0x0020801a, 0x00000000, 0x00000000,
19413 0x07000020, 0x00100022, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0xffffffff, 0x0800001e,
19414 0x00100012, 0x00000000, 0x00004001, 0x0000001f, 0x8010000a, 0x00000041, 0x00000000, 0x09000037,
19415 0x00102082, 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0xffffffff, 0x0010000a, 0x00000000,
19416 0x06000087, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x0800001e, 0x00100012,
19417 0x00000000, 0x00004001, 0x0000001f, 0x8010000a, 0x00000041, 0x00000000, 0x0a000037, 0x00102042,
19418 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0xffffffff,
19419 0x06000086, 0x00102012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x06000088, 0x00102022,
19420 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x0100003e,
19422 static const DWORD ps_ftou_code
[] =
19427 uint4
main() : SV_Target
19429 return uint4(f
, -f
, 0, 0);
19432 0x43425844, 0xfde0ee2d, 0x812b339a, 0xb9fc36d2, 0x5820bec6, 0x00000001, 0x000000f4, 0x00000003,
19433 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19434 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
19435 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x0000007c, 0x00000040, 0x0000001f,
19436 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x0600001c,
19437 0x00102012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x0700001c, 0x00102022, 0x00000000,
19438 0x8020800a, 0x00000041, 0x00000000, 0x00000000, 0x08000036, 0x001020c2, 0x00000000, 0x00004002,
19439 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0100003e,
19441 static const DWORD ps_f16tof32_code
[] =
19446 uint4
main() : SV_Target
19448 return f16tof32(hf
);
19451 0x43425844, 0xc1816e6e, 0x27562d96, 0x56980fa2, 0x421e6640, 0x00000001, 0x000000d8, 0x00000003,
19452 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19453 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
19454 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000060, 0x00000050, 0x00000018,
19455 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
19456 0x02000068, 0x00000001, 0x06000083, 0x001000f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000000,
19457 0x0500001c, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x0100003e,
19459 static const DWORD ps_f32tof16_code
[] =
19464 uint4
main() : SV_Target
19466 return f32tof16(f
);
19469 0x43425844, 0x523a765c, 0x1a5be3a9, 0xaed69c80, 0xd26fe296, 0x00000001, 0x000000bc, 0x00000003,
19470 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19471 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
19472 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000044, 0x00000050, 0x00000011,
19473 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
19474 0x06000082, 0x001020f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x0100003e,
19476 static const DWORD ps_not_code
[] =
19481 uint4
main() : SV_Target
19483 return uint4(~bits
.x
, ~(bits
.x
^ ~0u), ~bits
.y
, ~(bits
.y
^ ~0u));
19486 0x43425844, 0xaed0fd26, 0xf719a878, 0xc832efd6, 0xba03c264, 0x00000001, 0x00000100, 0x00000003,
19487 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
19488 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
19489 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000088, 0x00000040, 0x00000022,
19490 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
19491 0x00000001, 0x0b000057, 0x00100032, 0x00000000, 0x00208046, 0x00000000, 0x00000000, 0x00004002,
19492 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x0500003b, 0x001020a2, 0x00000000, 0x00100406,
19493 0x00000000, 0x0600003b, 0x00102052, 0x00000000, 0x00208106, 0x00000000, 0x00000000, 0x0100003e,
19495 static const struct shader ps_bfi
= {ps_bfi_code
, sizeof(ps_bfi_code
), D3D_FEATURE_LEVEL_11_0
};
19496 static const struct shader ps_bfi2
= {ps_bfi2_code
, sizeof(ps_bfi2_code
), D3D_FEATURE_LEVEL_11_0
};
19497 static const struct shader ps_ibfe
= {ps_ibfe_code
, sizeof(ps_ibfe_code
), D3D_FEATURE_LEVEL_11_0
};
19498 static const struct shader ps_ibfe2
= {ps_ibfe2_code
, sizeof(ps_ibfe2_code
), D3D_FEATURE_LEVEL_11_0
};
19499 static const struct shader ps_ubfe
= {ps_ubfe_code
, sizeof(ps_ubfe_code
), D3D_FEATURE_LEVEL_11_0
};
19500 static const struct shader ps_ubfe2
= {ps_ubfe2_code
, sizeof(ps_ubfe2_code
), D3D_FEATURE_LEVEL_11_0
};
19501 static const struct shader ps_bfrev
= {ps_bfrev_code
, sizeof(ps_bfrev_code
), D3D_FEATURE_LEVEL_11_0
};
19502 static const struct shader ps_bits
= {ps_bits_code
, sizeof(ps_bits_code
), D3D_FEATURE_LEVEL_11_0
};
19503 static const struct shader ps_ftou
= {ps_ftou_code
, sizeof(ps_ftou_code
), D3D_FEATURE_LEVEL_10_0
};
19504 static const struct shader ps_f16tof32
= {ps_f16tof32_code
, sizeof(ps_f16tof32_code
), D3D_FEATURE_LEVEL_11_0
};
19505 static const struct shader ps_f32tof16
= {ps_f32tof16_code
, sizeof(ps_f32tof16_code
), D3D_FEATURE_LEVEL_11_0
};
19506 static const struct shader ps_not
= {ps_not_code
, sizeof(ps_not_code
), D3D_FEATURE_LEVEL_10_0
};
19507 static const struct
19509 const struct shader
*ps
;
19510 unsigned int bits
[4];
19511 struct uvec4 expected_result
;
19515 {&ps_bfi
, { 0, 0, 0, 0}, { 0, 0, 0, 0}},
19516 {&ps_bfi
, { 0, 0, 0, 1}, { 1, 1, 1, 1}},
19517 {&ps_bfi
, { ~0u, 0, ~0u, 0}, {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff}},
19518 {&ps_bfi
, { ~0u, ~0u, ~0u, 0}, {0x80000000, 0x80000000, 0x80000000, 0x80000000}},
19519 {&ps_bfi
, { ~0u, 0x1fu
, ~0u, 0}, {0x80000000, 0x80000000, 0x80000000, 0x80000000}},
19520 {&ps_bfi
, { ~0u, ~0x1fu
, ~0u, 0}, {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff}},
19521 {&ps_bfi
, { 0, 0, 0xff, 1}, { 1, 1, 1, 1}},
19522 {&ps_bfi
, { 0, 0, 0xff, 2}, { 2, 2, 2, 2}},
19523 {&ps_bfi
, { 16, 16, 0xff, 0xff}, {0x00ff00ff, 0x00ff00ff, 0x00ff00ff, 0x00ff00ff}},
19524 {&ps_bfi
, { 0, 0, ~0u, ~0u}, { ~0u, ~0u, ~0u, ~0u}},
19525 {&ps_bfi
, {~0x1fu
, 0, ~0u, 0}, { 0, 0, 0, 0}},
19526 {&ps_bfi
, {~0x1fu
, 0, ~0u, 1}, { 1, 1, 1, 1}},
19527 {&ps_bfi
, {~0x1fu
, 0, ~0u, 2}, { 2, 2, 2, 2}},
19528 {&ps_bfi
, { 0, ~0x1fu
, ~0u, 0}, { 0, 0, 0, 0}},
19529 {&ps_bfi
, { 0, ~0x1fu
, ~0u, 1}, { 1, 1, 1, 1}},
19530 {&ps_bfi
, { 0, ~0x1fu
, ~0u, 2}, { 2, 2, 2, 2}},
19531 {&ps_bfi
, {~0x1fu
, ~0x1fu
, ~0u, 0}, { 0, 0, 0, 0}},
19532 {&ps_bfi
, {~0x1fu
, ~0x1fu
, ~0u, 1}, { 1, 1, 1, 1}},
19533 {&ps_bfi
, {~0x1fu
, ~0x1fu
, ~0u, 2}, { 2, 2, 2, 2}},
19535 {&ps_bfi2
, { ~0u, 0, ~0u, 0}, {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff}},
19536 {&ps_bfi2
, { ~0u, ~0u, ~0u, 0}, {0x80000000, 0x80000000, 0x80000000, 0x80000000}},
19537 {&ps_bfi2
, { ~0u, 0x1fu
, ~0u, 0}, {0x80000000, 0x80000000, 0x80000000, 0x80000000}},
19538 {&ps_bfi2
, { ~0u, ~0x1fu
, ~0u, 0}, {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff}},
19540 {&ps_ibfe
, { 0, 4, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}},
19541 {&ps_ibfe
, { 0, 4, 0xffffffff}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}},
19542 {&ps_ibfe
, { 0, 4, 0x7fffffff}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}},
19543 {&ps_ibfe
, { 4, 0, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}},
19544 {&ps_ibfe
, { 4, 0, 0xfffffffa}, {0xfffffffa, 0xfffffffa, 0xfffffffa, 0xfffffffa}},
19545 {&ps_ibfe
, { 4, 0, 0x7ffffffc}, {0xfffffffc, 0xfffffffc, 0xfffffffc, 0xfffffffc}},
19546 {&ps_ibfe
, { 4, 4, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}},
19547 {&ps_ibfe
, { 4, 4, 0xffffffff}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
19548 {&ps_ibfe
, { 4, 4, 0xffffff1f}, {0x00000001, 0x00000001, 0x00000001, 0x00000001}},
19549 {&ps_ibfe
, { 4, 4, 0x7fffffff}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
19550 {&ps_ibfe
, {23, 8, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}},
19551 {&ps_ibfe
, {23, 8, 0xffffffff}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
19552 {&ps_ibfe
, {23, 8, 0x7fffffff}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
19553 {&ps_ibfe
, {30, 1, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}},
19554 {&ps_ibfe
, {30, 1, 0xffffffff}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
19555 {&ps_ibfe
, {30, 1, 0x7fffffff}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
19556 {&ps_ibfe
, {15, 15, 0x7fffffff}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
19557 {&ps_ibfe
, {15, 15, 0x3fffffff}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
19558 {&ps_ibfe
, {15, 15, 0x1fffffff}, {0x00003fff, 0x00003fff, 0x00003fff, 0x00003fff}},
19559 {&ps_ibfe
, {15, 15, 0xffff00ff}, {0xfffffffe, 0xfffffffe, 0xfffffffe, 0xfffffffe}},
19560 {&ps_ibfe
, {16, 15, 0xffffffff}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
19561 {&ps_ibfe
, {16, 15, 0x3fffffff}, {0x00007fff, 0x00007fff, 0x00007fff, 0x00007fff}},
19562 {&ps_ibfe
, {20, 15, 0xffffffff}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
19563 {&ps_ibfe
, {31, 31, 0xffffffff}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
19564 {&ps_ibfe
, {31, 31, 0x80000000}, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
19565 {&ps_ibfe
, {31, 31, 0x7fffffff}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}},
19567 {&ps_ibfe2
, {16, 15, 0x3fffffff}, {0x00007fff, 0x00007fff, 0x00007fff, 0x00007fff}},
19569 {&ps_ubfe
, {0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}},
19570 {&ps_ubfe
, {0xffffffff}, {0x0000000f, 0x007fffff, 0x0000007f, 0x3fffffff}},
19571 {&ps_ubfe
, {0xff000000}, {0x00000000, 0x007f0000, 0x00000000, 0x3f800000}},
19572 {&ps_ubfe
, {0x00ff0000}, {0x00000000, 0x0000ff00, 0x00000000, 0x007f8000}},
19573 {&ps_ubfe
, {0x000000ff}, {0x0000000f, 0x00000000, 0x0000007f, 0x0000007f}},
19574 {&ps_ubfe
, {0x80000001}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}},
19575 {&ps_ubfe
, {0xc0000003}, {0x00000000, 0x00400000, 0x00000001, 0x20000001}},
19577 {&ps_ubfe2
, { 4, 4, 0x7fffffff}, {0x0000000f, 0x0000000f, 0x0000000f, 0x0000000f}},
19578 {&ps_ubfe2
, {23, 8, 0xffffffff}, {0x007fffff, 0x007fffff, 0x007fffff, 0x007fffff}},
19579 {&ps_ubfe2
, {30, 1, 0xffffffff}, {0x3fffffff, 0x3fffffff, 0x3fffffff, 0x3fffffff}},
19580 {&ps_ubfe2
, {15, 15, 0x7fffffff}, {0x00007fff, 0x00007fff, 0x00007fff, 0x00007fff}},
19581 {&ps_ubfe2
, {15, 15, 0xffff00ff}, {0x00007ffe, 0x00007ffe, 0x00007ffe, 0x00007ffe}},
19582 {&ps_ubfe2
, {16, 15, 0xffffffff}, {0x0000ffff, 0x0000ffff, 0x0000ffff, 0x0000ffff}},
19583 {&ps_ubfe2
, {16, 15, 0x3fffffff}, {0x00007fff, 0x00007fff, 0x00007fff, 0x00007fff}},
19584 {&ps_ubfe2
, {20, 15, 0xffffffff}, {0x0001ffff, 0x0001ffff, 0x0001ffff, 0x0001ffff}},
19585 {&ps_ubfe2
, {31, 31, 0xffffffff}, {0x00000001, 0x00000001, 0x00000001, 0x00000001}},
19586 {&ps_ubfe2
, {31, 31, 0x80000000}, {0x00000001, 0x00000001, 0x00000001, 0x00000001}},
19587 {&ps_ubfe2
, {31, 31, 0x7fffffff}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}},
19589 {&ps_bfrev
, {0x12345678}, {0x1e6a2c48, 0x12345678, 0x1e6a0000, 0x2c480000}},
19590 {&ps_bfrev
, {0xffff0000}, {0x0000ffff, 0xffff0000, 0x00000000, 0xffff0000}},
19591 {&ps_bfrev
, {0xffffffff}, {0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000}},
19593 {&ps_bits
, { 0, 0}, { 0, ~0u, ~0u, ~0u}},
19594 {&ps_bits
, { ~0u, ~0u}, {32, 0, 31, ~0u}},
19595 {&ps_bits
, {0x7fffffff, 0x7fffffff}, {31, 0, 30, 30}},
19596 {&ps_bits
, {0x80000000, 0x80000000}, { 1, 31, 31, 30}},
19597 {&ps_bits
, {0x00000001, 0x00000001}, { 1, 0, 0, 0}},
19598 {&ps_bits
, {0x80000001, 0x80000001}, { 2, 0, 31, 30}},
19599 {&ps_bits
, {0x88888888, 0x88888888}, { 8, 3, 31, 30}},
19600 {&ps_bits
, {0xcccccccc, 0xcccccccc}, {16, 2, 31, 29}},
19601 {&ps_bits
, {0x11111111, 0x11111c11}, { 8, 0, 28, 28}},
19602 {&ps_bits
, {0x0000000f, 0x0000000f}, { 4, 0, 3, 3}},
19603 {&ps_bits
, {0x8000000f, 0x8000000f}, { 5, 0, 31, 30}},
19604 {&ps_bits
, {0x00080000, 0x00080000}, { 1, 19, 19, 19}},
19606 {&ps_ftou
, {BITS_NNAN
}, { 0, 0}},
19607 {&ps_ftou
, {BITS_NAN
}, { 0, 0}},
19608 {&ps_ftou
, {BITS_NINF
}, { 0, ~0u}},
19609 {&ps_ftou
, {BITS_INF
}, {~0u, 0}},
19610 {&ps_ftou
, {BITS_N1_0
}, { 0, 1}},
19611 {&ps_ftou
, {BITS_1_0
}, { 1, 0}},
19613 {&ps_f16tof32
, {0x00000000, 0x00003c00, 0x00005640, 0x00005bd0}, {0, 1, 100, 250}},
19614 {&ps_f16tof32
, {0x00010000, 0x00013c00, 0x00015640, 0x00015bd0}, {0, 1, 100, 250}},
19615 {&ps_f16tof32
, {0x000f0000, 0x000f3c00, 0x000f5640, 0x000f5bd0}, {0, 1, 100, 250}},
19616 {&ps_f16tof32
, {0xffff0000, 0xffff3c00, 0xffff5640, 0xffff5bd0}, {0, 1, 100, 250}},
19618 {&ps_f32tof16
, {0, BITS_1_0
, BITS_N1_0
, 0x44268000}, {0, 0x3c00, 0xbc00, 0x6134}},
19620 {&ps_not
, {0x00000000, 0xffffffff}, {0xffffffff, 0x00000000, 0x00000000, 0xffffffff}},
19621 {&ps_not
, {0xf0f0f0f0, 0x0f0f0f0f}, {0x0f0f0f0f, 0xf0f0f0f0, 0xf0f0f0f0, 0x0f0f0f0f}},
19624 if (!init_test_context(&test_context
, NULL
))
19627 device
= test_context
.device
;
19628 context
= test_context
.immediate_context
;
19629 feature_level
= ID3D11Device_GetFeatureLevel(device
);
19631 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(tests
[0].bits
), NULL
);
19632 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
19634 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
19635 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_UINT
;
19636 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
19637 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
19639 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
19640 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
19642 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
19644 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
19646 if (feature_level
< tests
[i
].ps
->required_feature_level
)
19649 hr
= ID3D11Device_CreatePixelShader(device
, tests
[i
].ps
->code
, tests
[i
].ps
->size
, NULL
, &ps
);
19650 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
19651 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
19653 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, tests
[i
].bits
, 0, 0);
19655 draw_quad(&test_context
);
19656 check_texture_uvec4(texture
, &tests
[i
].expected_result
);
19658 ID3D11PixelShader_Release(ps
);
19661 ID3D11Buffer_Release(cb
);
19662 ID3D11Texture2D_Release(texture
);
19663 ID3D11RenderTargetView_Release(rtv
);
19664 release_test_context(&test_context
);
19667 static void test_index_buffer_offset(void)
19669 ID3D11Buffer
*vb
, *ib
, *so_buffer
, *args_buffer
;
19670 struct d3d11_test_context test_context
;
19671 ID3D11InputLayout
*input_layout
;
19672 ID3D11DeviceContext
*context
;
19673 struct resource_readback rb
;
19674 ID3D11GeometryShader
*gs
;
19675 const struct vec4
*data
;
19676 ID3D11VertexShader
*vs
;
19677 ID3D11Device
*device
;
19678 UINT stride
, offset
;
19682 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
19683 static const DWORD vs_code
[] =
19686 void main(float4 position
: SV_POSITION
, float4 attrib
: ATTRIB
,
19687 out float4 out_position
: SV_Position
, out float4 out_attrib
: ATTRIB
)
19689 out_position
= position
;
19690 out_attrib
= attrib
;
19693 0x43425844, 0xd7716716, 0xe23207f3, 0xc8af57c0, 0x585e2919, 0x00000001, 0x00000144, 0x00000003,
19694 0x0000002c, 0x00000080, 0x000000d4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
19695 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000044, 0x00000000, 0x00000000,
19696 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52545441, 0xab004249,
19697 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
19698 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
19699 0x505f5653, 0x7469736f, 0x006e6f69, 0x52545441, 0xab004249, 0x52444853, 0x00000068, 0x00010040,
19700 0x0000001a, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067,
19701 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2,
19702 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001,
19705 static const DWORD gs_code
[] =
19710 float4 position
: SV_POSITION
;
19711 float4 attrib
: ATTRIB
;
19714 [maxvertexcount(1)]
19715 void main(point vertex input
[1], inout PointStream
<vertex
> output
)
19717 output
.Append(input
[0]);
19718 output
.RestartStrip();
19721 0x43425844, 0x3d1dc497, 0xdf450406, 0x284ab03b, 0xa4ec0fd6, 0x00000001, 0x00000170, 0x00000003,
19722 0x0000002c, 0x00000080, 0x000000d4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
19723 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x00000044, 0x00000000, 0x00000000,
19724 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52545441, 0xab004249,
19725 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
19726 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
19727 0x505f5653, 0x5449534f, 0x004e4f49, 0x52545441, 0xab004249, 0x52444853, 0x00000094, 0x00020040,
19728 0x00000025, 0x05000061, 0x002010f2, 0x00000001, 0x00000000, 0x00000001, 0x0400005f, 0x002010f2,
19729 0x00000001, 0x00000001, 0x0100085d, 0x0100085c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
19730 0x03000065, 0x001020f2, 0x00000001, 0x0200005e, 0x00000001, 0x06000036, 0x001020f2, 0x00000000,
19731 0x00201e46, 0x00000000, 0x00000000, 0x06000036, 0x001020f2, 0x00000001, 0x00201e46, 0x00000000,
19732 0x00000001, 0x01000013, 0x01000009, 0x0100003e,
19734 static const D3D11_INPUT_ELEMENT_DESC input_desc
[] =
19736 {"SV_POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
19737 {"ATTRIB", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 16, D3D11_INPUT_PER_VERTEX_DATA
, 0},
19739 static const D3D11_SO_DECLARATION_ENTRY so_declaration
[] =
19741 {0, "SV_Position", 0, 0, 4, 0},
19742 {0, "ATTRIB", 0, 0, 4, 0},
19744 static const struct
19746 struct vec4 position
;
19747 struct vec4 attrib
;
19751 {{-1.0f
, -1.0f
, 0.0f
, 1.0f
}, {1.0f
}},
19752 {{-1.0f
, 1.0f
, 0.0f
, 1.0f
}, {2.0f
}},
19753 {{ 1.0f
, -1.0f
, 0.0f
, 1.0f
}, {3.0f
}},
19754 {{ 1.0f
, 1.0f
, 0.0f
, 1.0f
}, {4.0f
}},
19756 static const unsigned int indices
[] =
19762 static const struct vec4 expected_data
[] =
19764 {-1.0f
, -1.0f
, 0.0f
, 1.0f
}, {1.0f
},
19765 {-1.0f
, 1.0f
, 0.0f
, 1.0f
}, {2.0f
},
19766 { 1.0f
, -1.0f
, 0.0f
, 1.0f
}, {3.0f
},
19767 { 1.0f
, 1.0f
, 0.0f
, 1.0f
}, {4.0f
},
19769 { 1.0f
, 1.0f
, 0.0f
, 1.0f
}, {4.0f
},
19770 { 1.0f
, -1.0f
, 0.0f
, 1.0f
}, {3.0f
},
19771 {-1.0f
, 1.0f
, 0.0f
, 1.0f
}, {2.0f
},
19772 {-1.0f
, -1.0f
, 0.0f
, 1.0f
}, {1.0f
},
19774 {-1.0f
, 1.0f
, 0.0f
, 1.0f
}, {2.0f
},
19775 { 1.0f
, 1.0f
, 0.0f
, 1.0f
}, {4.0f
},
19776 { 1.0f
, -1.0f
, 0.0f
, 1.0f
}, {3.0f
},
19777 {-1.0f
, -1.0f
, 0.0f
, 1.0f
}, {1.0f
},
19779 static const struct vec4 broken_result
= {0.0f
, 0.0f
, 0.0f
, 1.0f
};
19780 static const D3D11_DRAW_INDEXED_INSTANCED_INDIRECT_ARGS argument_data
[] =
19785 if (!init_test_context(&test_context
, &feature_level
))
19788 device
= test_context
.device
;
19789 context
= test_context
.immediate_context
;
19791 hr
= ID3D11Device_CreateInputLayout(device
, input_desc
, ARRAY_SIZE(input_desc
),
19792 vs_code
, sizeof(vs_code
), &input_layout
);
19793 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
19796 hr
= ID3D11Device_CreateGeometryShaderWithStreamOutput(device
, gs_code
, sizeof(gs_code
),
19797 so_declaration
, ARRAY_SIZE(so_declaration
),
19798 &stride
, 1, D3D11_SO_NO_RASTERIZED_STREAM
, NULL
, &gs
);
19799 ok(SUCCEEDED(hr
), "Failed to create geometry shader with stream output, hr %#x.\n", hr
);
19801 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
19802 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
19804 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(vertices
), vertices
);
19805 ib
= create_buffer(device
, D3D11_BIND_INDEX_BUFFER
, sizeof(indices
), indices
);
19806 so_buffer
= create_buffer(device
, D3D11_BIND_STREAM_OUTPUT
, 1024, NULL
);
19808 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
19809 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
19811 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
19812 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST
);
19813 stride
= sizeof(*vertices
);
19815 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, &stride
, &offset
);
19818 ID3D11DeviceContext_SOSetTargets(context
, 1, &so_buffer
, &offset
);
19820 ID3D11DeviceContext_IASetIndexBuffer(context
, ib
, DXGI_FORMAT_R32_UINT
, 0);
19821 ID3D11DeviceContext_DrawIndexed(context
, 4, 0, 0);
19823 ID3D11DeviceContext_IASetIndexBuffer(context
, ib
, DXGI_FORMAT_R32_UINT
, 4 * sizeof(*indices
));
19824 ID3D11DeviceContext_DrawIndexed(context
, 4, 0, 0);
19826 ID3D11DeviceContext_IASetIndexBuffer(context
, ib
, DXGI_FORMAT_R32_UINT
, 8 * sizeof(*indices
));
19827 ID3D11DeviceContext_DrawIndexed(context
, 4, 0, 0);
19829 get_buffer_readback(so_buffer
, &rb
);
19830 for (i
= 0; i
< ARRAY_SIZE(expected_data
); ++i
)
19832 data
= get_readback_vec4(&rb
, i
, 0);
19833 ok(compare_vec4(data
, &expected_data
[i
], 0)
19834 || broken(is_nvidia_device(device
) && !(i
% 2) && compare_vec4(data
, &broken_result
, 0)),
19835 "Got unexpected result {%.8e, %.8e, %.8e, %.8e} at %u.\n",
19836 data
->x
, data
->y
, data
->z
, data
->w
, i
);
19838 release_resource_readback(&rb
);
19840 /* indirect draws */
19841 args_buffer
= create_buffer_misc(device
, 0, D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS
,
19842 sizeof(argument_data
), argument_data
);
19845 ID3D11DeviceContext_SOSetTargets(context
, 1, &so_buffer
, &offset
);
19847 ID3D11DeviceContext_IASetIndexBuffer(context
, ib
, DXGI_FORMAT_R32_UINT
, 0);
19848 ID3D11DeviceContext_DrawIndexedInstancedIndirect(context
, args_buffer
, 0);
19850 ID3D11DeviceContext_IASetIndexBuffer(context
, ib
, DXGI_FORMAT_R32_UINT
, 4 * sizeof(*indices
));
19851 ID3D11DeviceContext_DrawIndexedInstancedIndirect(context
, args_buffer
, 0);
19853 ID3D11DeviceContext_IASetIndexBuffer(context
, ib
, DXGI_FORMAT_R32_UINT
, 8 * sizeof(*indices
));
19854 ID3D11DeviceContext_DrawIndexedInstancedIndirect(context
, args_buffer
, 0);
19856 get_buffer_readback(so_buffer
, &rb
);
19857 for (i
= 0; i
< ARRAY_SIZE(expected_data
); ++i
)
19859 data
= get_readback_vec4(&rb
, i
, 0);
19860 todo_wine_if(i
>= 8 && i
!= 20 && i
!= 21)
19861 ok(compare_vec4(data
, &expected_data
[i
], 0)
19862 || broken(is_nvidia_device(device
) && !(i
% 2) && compare_vec4(data
, &broken_result
, 0)),
19863 "Got unexpected result {%.8e, %.8e, %.8e, %.8e} at %u.\n",
19864 data
->x
, data
->y
, data
->z
, data
->w
, i
);
19866 release_resource_readback(&rb
);
19868 ID3D11Buffer_Release(so_buffer
);
19869 ID3D11Buffer_Release(args_buffer
);
19870 ID3D11Buffer_Release(ib
);
19871 ID3D11Buffer_Release(vb
);
19872 ID3D11VertexShader_Release(vs
);
19873 ID3D11GeometryShader_Release(gs
);
19874 ID3D11InputLayout_Release(input_layout
);
19875 release_test_context(&test_context
);
19878 static void test_face_culling(void)
19880 struct d3d11_test_context test_context
;
19881 D3D11_RASTERIZER_DESC rasterizer_desc
;
19882 ID3D11RasterizerState
*state
;
19883 ID3D11DeviceContext
*context
;
19884 ID3D11Buffer
*cw_vb
, *ccw_vb
;
19885 ID3D11Device
*device
;
19890 static const struct vec4 red
= {1.0f
, 0.0f
, 0.0f
, 1.0f
};
19891 static const struct vec4 green
= {0.0f
, 1.0f
, 0.0f
, 1.0f
};
19892 static const DWORD ps_code
[] =
19895 float4
main(uint front
: SV_IsFrontFace
) : SV_Target
19897 return (front
== ~0u) ? float4(0.0f
, 1.0f
, 0.0f
, 1.0f
) : float4(0.0f
, 0.0f
, 1.0f
, 1.0f
);
19900 0x43425844, 0x92002fad, 0xc5c620b9, 0xe7a154fb, 0x78b54e63, 0x00000001, 0x00000128, 0x00000003,
19901 0x0000002c, 0x00000064, 0x00000098, 0x4e475349, 0x00000030, 0x00000001, 0x00000008, 0x00000020,
19902 0x00000000, 0x00000009, 0x00000001, 0x00000000, 0x00000101, 0x495f5653, 0x6f724673, 0x6146746e,
19903 0xab006563, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
19904 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000088,
19905 0x00000040, 0x00000022, 0x04000863, 0x00101012, 0x00000000, 0x00000009, 0x03000065, 0x001020f2,
19906 0x00000000, 0x02000068, 0x00000001, 0x07000020, 0x00100012, 0x00000000, 0x0010100a, 0x00000000,
19907 0x00004001, 0xffffffff, 0x0f000037, 0x001020f2, 0x00000000, 0x00100006, 0x00000000, 0x00004002,
19908 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x00004002, 0x00000000, 0x00000000, 0x3f800000,
19909 0x3f800000, 0x0100003e,
19911 static const struct vec3 ccw_quad
[] =
19913 {-1.0f
, 1.0f
, 0.0f
},
19914 {-1.0f
, -1.0f
, 0.0f
},
19915 { 1.0f
, 1.0f
, 0.0f
},
19916 { 1.0f
, -1.0f
, 0.0f
},
19918 static const struct
19920 D3D11_CULL_MODE cull_mode
;
19927 {D3D11_CULL_NONE
, FALSE
, TRUE
, TRUE
},
19928 {D3D11_CULL_NONE
, TRUE
, TRUE
, TRUE
},
19929 {D3D11_CULL_FRONT
, FALSE
, FALSE
, TRUE
},
19930 {D3D11_CULL_FRONT
, TRUE
, TRUE
, FALSE
},
19931 {D3D11_CULL_BACK
, FALSE
, TRUE
, FALSE
},
19932 {D3D11_CULL_BACK
, TRUE
, FALSE
, TRUE
},
19935 if (!init_test_context(&test_context
, NULL
))
19938 device
= test_context
.device
;
19939 context
= test_context
.immediate_context
;
19941 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &red
.x
);
19942 draw_color_quad(&test_context
, &green
);
19943 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
19945 cw_vb
= test_context
.vb
;
19946 ccw_vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(ccw_quad
), ccw_quad
);
19948 test_context
.vb
= ccw_vb
;
19949 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &red
.x
);
19950 draw_color_quad(&test_context
, &green
);
19951 check_texture_color(test_context
.backbuffer
, 0xff0000ff, 0);
19953 rasterizer_desc
.FillMode
= D3D11_FILL_SOLID
;
19954 rasterizer_desc
.CullMode
= D3D11_CULL_BACK
;
19955 rasterizer_desc
.FrontCounterClockwise
= FALSE
;
19956 rasterizer_desc
.DepthBias
= 0;
19957 rasterizer_desc
.DepthBiasClamp
= 0.0f
;
19958 rasterizer_desc
.SlopeScaledDepthBias
= 0.0f
;
19959 rasterizer_desc
.DepthClipEnable
= TRUE
;
19960 rasterizer_desc
.ScissorEnable
= FALSE
;
19961 rasterizer_desc
.MultisampleEnable
= FALSE
;
19962 rasterizer_desc
.AntialiasedLineEnable
= FALSE
;
19964 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
19966 rasterizer_desc
.CullMode
= tests
[i
].cull_mode
;
19967 rasterizer_desc
.FrontCounterClockwise
= tests
[i
].front_ccw
;
19968 hr
= ID3D11Device_CreateRasterizerState(device
, &rasterizer_desc
, &state
);
19969 ok(SUCCEEDED(hr
), "Test %u: Failed to create rasterizer state, hr %#x.\n", i
, hr
);
19971 ID3D11DeviceContext_RSSetState(context
, state
);
19973 test_context
.vb
= cw_vb
;
19974 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &red
.x
);
19975 draw_color_quad(&test_context
, &green
);
19976 check_texture_color(test_context
.backbuffer
, tests
[i
].expected_cw
? 0xff00ff00 : 0xff0000ff, 0);
19978 test_context
.vb
= ccw_vb
;
19979 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &red
.x
);
19980 draw_color_quad(&test_context
, &green
);
19981 check_texture_color(test_context
.backbuffer
, tests
[i
].expected_ccw
? 0xff00ff00 : 0xff0000ff, 0);
19983 ID3D11RasterizerState_Release(state
);
19986 broken_warp
= is_warp_device(device
) && ID3D11Device_GetFeatureLevel(device
) < D3D_FEATURE_LEVEL_11_0
;
19988 /* Test SV_IsFrontFace. */
19989 ID3D11PixelShader_Release(test_context
.ps
);
19990 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &test_context
.ps
);
19991 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
19993 rasterizer_desc
.CullMode
= D3D11_CULL_NONE
;
19994 rasterizer_desc
.FrontCounterClockwise
= FALSE
;
19995 hr
= ID3D11Device_CreateRasterizerState(device
, &rasterizer_desc
, &state
);
19996 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
19997 ID3D11DeviceContext_RSSetState(context
, state
);
19999 test_context
.vb
= cw_vb
;
20000 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &red
.x
);
20001 draw_color_quad(&test_context
, &green
);
20002 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
20003 test_context
.vb
= ccw_vb
;
20004 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &red
.x
);
20005 draw_color_quad(&test_context
, &green
);
20007 check_texture_color(test_context
.backbuffer
, 0xffff0000, 0);
20009 win_skip("Broken WARP.\n");
20011 ID3D11RasterizerState_Release(state
);
20013 rasterizer_desc
.CullMode
= D3D11_CULL_NONE
;
20014 rasterizer_desc
.FrontCounterClockwise
= TRUE
;
20015 hr
= ID3D11Device_CreateRasterizerState(device
, &rasterizer_desc
, &state
);
20016 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
20017 ID3D11DeviceContext_RSSetState(context
, state
);
20019 test_context
.vb
= cw_vb
;
20020 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &red
.x
);
20021 draw_color_quad(&test_context
, &green
);
20023 check_texture_color(test_context
.backbuffer
, 0xffff0000 , 0);
20025 win_skip("Broken WARP.\n");
20026 test_context
.vb
= ccw_vb
;
20027 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &red
.x
);
20028 draw_color_quad(&test_context
, &green
);
20029 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
20031 ID3D11RasterizerState_Release(state
);
20033 test_context
.vb
= cw_vb
;
20034 ID3D11Buffer_Release(ccw_vb
);
20035 release_test_context(&test_context
);
20038 static void test_line_antialiasing_blending(void)
20040 ID3D11RasterizerState
*rasterizer_state
;
20041 struct d3d11_test_context test_context
;
20042 D3D11_RASTERIZER_DESC rasterizer_desc
;
20043 ID3D11BlendState
*blend_state
;
20044 ID3D11DeviceContext
*context
;
20045 D3D11_BLEND_DESC blend_desc
;
20046 ID3D11Device
*device
;
20049 static const struct vec4 red
= {1.0f
, 0.0f
, 0.0f
, 0.8f
};
20050 static const struct vec4 green
= {0.0f
, 1.0f
, 0.0f
, 0.5f
};
20052 if (!init_test_context(&test_context
, NULL
))
20055 device
= test_context
.device
;
20056 context
= test_context
.immediate_context
;
20058 memset(&blend_desc
, 0, sizeof(blend_desc
));
20059 blend_desc
.AlphaToCoverageEnable
= FALSE
;
20060 blend_desc
.IndependentBlendEnable
= FALSE
;
20061 blend_desc
.RenderTarget
[0].BlendEnable
= TRUE
;
20062 blend_desc
.RenderTarget
[0].SrcBlend
= D3D11_BLEND_SRC_ALPHA
;
20063 blend_desc
.RenderTarget
[0].DestBlend
= D3D11_BLEND_DEST_ALPHA
;
20064 blend_desc
.RenderTarget
[0].BlendOp
= D3D11_BLEND_OP_ADD
;
20065 blend_desc
.RenderTarget
[0].SrcBlendAlpha
= D3D11_BLEND_SRC_ALPHA
;
20066 blend_desc
.RenderTarget
[0].DestBlendAlpha
= D3D11_BLEND_DEST_ALPHA
;
20067 blend_desc
.RenderTarget
[0].BlendOpAlpha
= D3D11_BLEND_OP_ADD
;
20068 blend_desc
.RenderTarget
[0].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_ALL
;
20070 hr
= ID3D11Device_CreateBlendState(device
, &blend_desc
, &blend_state
);
20071 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
20072 ID3D11DeviceContext_OMSetBlendState(context
, blend_state
, NULL
, D3D11_DEFAULT_SAMPLE_MASK
);
20074 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &red
.x
);
20075 draw_color_quad(&test_context
, &green
);
20076 check_texture_color(test_context
.backbuffer
, 0xe2007fcc, 1);
20078 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &green
.x
);
20079 draw_color_quad(&test_context
, &red
);
20080 check_texture_color(test_context
.backbuffer
, 0xe2007fcc, 1);
20082 ID3D11DeviceContext_OMSetBlendState(context
, NULL
, NULL
, D3D11_DEFAULT_SAMPLE_MASK
);
20083 ID3D11BlendState_Release(blend_state
);
20085 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &red
.x
);
20086 draw_color_quad(&test_context
, &green
);
20087 check_texture_color(test_context
.backbuffer
, 0x7f00ff00, 1);
20089 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &green
.x
);
20090 draw_color_quad(&test_context
, &red
);
20091 check_texture_color(test_context
.backbuffer
, 0xcc0000ff, 1);
20093 rasterizer_desc
.FillMode
= D3D11_FILL_SOLID
;
20094 rasterizer_desc
.CullMode
= D3D11_CULL_BACK
;
20095 rasterizer_desc
.FrontCounterClockwise
= FALSE
;
20096 rasterizer_desc
.DepthBias
= 0;
20097 rasterizer_desc
.DepthBiasClamp
= 0.0f
;
20098 rasterizer_desc
.SlopeScaledDepthBias
= 0.0f
;
20099 rasterizer_desc
.DepthClipEnable
= TRUE
;
20100 rasterizer_desc
.ScissorEnable
= FALSE
;
20101 rasterizer_desc
.MultisampleEnable
= FALSE
;
20102 rasterizer_desc
.AntialiasedLineEnable
= TRUE
;
20104 hr
= ID3D11Device_CreateRasterizerState(device
, &rasterizer_desc
, &rasterizer_state
);
20105 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
20106 ID3D11DeviceContext_RSSetState(context
, rasterizer_state
);
20108 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &red
.x
);
20109 draw_color_quad(&test_context
, &green
);
20110 check_texture_color(test_context
.backbuffer
, 0x7f00ff00, 1);
20112 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &green
.x
);
20113 draw_color_quad(&test_context
, &red
);
20114 check_texture_color(test_context
.backbuffer
, 0xcc0000ff, 1);
20116 ID3D11RasterizerState_Release(rasterizer_state
);
20117 release_test_context(&test_context
);
20120 static void check_format_support(const unsigned int *format_support
, D3D_FEATURE_LEVEL feature_level
,
20121 const struct format_support
*formats
, unsigned int format_count
, unsigned int feature_flag
,
20122 const char *feature_name
)
20126 for (i
= 0; i
< format_count
; ++i
)
20128 DXGI_FORMAT format
= formats
[i
].format
;
20129 unsigned int supported
= format_support
[format
] & feature_flag
;
20131 if (formats
[i
].fl_required
<= feature_level
)
20133 todo_wine
ok(supported
, "Format %#x - %s not supported, feature_level %#x, format support %#x.\n",
20134 format
, feature_name
, feature_level
, format_support
[format
]);
20138 if (formats
[i
].fl_optional
&& formats
[i
].fl_optional
<= feature_level
)
20141 trace("Optional format %#x - %s supported, feature level %#x.\n",
20142 format
, feature_name
, feature_level
);
20146 ok(!supported
, "Format %#x - %s supported, feature level %#x, format support %#x.\n",
20147 format
, feature_name
, feature_level
, format_support
[format
]);
20151 static void test_format_support(const D3D_FEATURE_LEVEL feature_level
)
20153 unsigned int format_support
[DXGI_FORMAT_B4G4R4A4_UNORM
+ 1];
20154 struct device_desc device_desc
;
20155 ID3D11Device
*device
;
20156 DXGI_FORMAT format
;
20161 static const struct format_support index_buffers
[] =
20163 {DXGI_FORMAT_R32_UINT
, D3D_FEATURE_LEVEL_9_2
},
20164 {DXGI_FORMAT_R16_UINT
, D3D_FEATURE_LEVEL_9_1
},
20167 device_desc
.feature_level
= &feature_level
;
20168 device_desc
.flags
= 0;
20169 if (!(device
= create_device(&device_desc
)))
20171 skip("Failed to create device for feature level %#x.\n", feature_level
);
20175 support
= 0xdeadbeef;
20176 hr
= ID3D11Device_CheckFormatSupport(device
, ~0u, &support
);
20177 ok(hr
== E_FAIL
, "Got unexpected hr %#x.\n", hr
);
20178 ok(!support
, "Got unexpected format support %#x.\n", support
);
20180 memset(format_support
, 0, sizeof(format_support
));
20181 for (format
= DXGI_FORMAT_UNKNOWN
; format
<= DXGI_FORMAT_B4G4R4A4_UNORM
; ++format
)
20183 hr
= ID3D11Device_CheckFormatSupport(device
, format
, &format_support
[format
]);
20184 ok(hr
== S_OK
|| (hr
== E_FAIL
&& !format_support
[format
]),
20185 "Got unexpected result for format %#x: hr %#x, format_support %#x.\n",
20186 format
, hr
, format_support
[format
]);
20187 if (format_support
[format
] & D3D11_FORMAT_SUPPORT_MIP_AUTOGEN
)
20189 ok(format_support
[format
] & D3D11_FORMAT_SUPPORT_TEXTURE2D
,
20190 "Got unexpected format support %#x for format %#x", format_support
[format
], format
);
20194 for (format
= DXGI_FORMAT_UNKNOWN
; format
<= DXGI_FORMAT_B4G4R4A4_UNORM
; ++format
)
20196 if (feature_level
< D3D_FEATURE_LEVEL_10_0
)
20198 /* SHADER_SAMPLE_COMPARISON is never advertised as supported on feature level 9. */
20199 ok(!(format_support
[format
] & D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON
),
20200 "Unexpected SHADER_SAMPLE_COMPARISON for format %#x, feature level %#x.\n",
20201 format
, feature_level
);
20202 ok(!(format_support
[format
] & D3D11_FORMAT_SUPPORT_BUFFER
),
20203 "Unexpected BUFFER for format %#x, feature level %#x.\n",
20204 format
, feature_level
);
20206 if (feature_level
< D3D_FEATURE_LEVEL_10_1
)
20208 ok(!(format_support
[format
] & D3D11_FORMAT_SUPPORT_SHADER_GATHER
),
20209 "Unexpected SHADER_GATHER for format %#x, feature level %#x.\n",
20210 format
, feature_level
);
20211 ok(!(format_support
[format
] & D3D11_FORMAT_SUPPORT_SHADER_GATHER_COMPARISON
),
20212 "Unexpected SHADER_GATHER_COMPARISON for format %#x, feature level %#x.\n",
20213 format
, feature_level
);
20217 ok(format_support
[DXGI_FORMAT_R8G8B8A8_UNORM
] & D3D11_FORMAT_SUPPORT_SHADER_SAMPLE
,
20218 "SHADER_SAMPLE is not supported for R8G8B8A8_UNORM.\n");
20220 ok(!(format_support
[DXGI_FORMAT_R32G32B32A32_UINT
] & D3D11_FORMAT_SUPPORT_SHADER_SAMPLE
),
20221 "SHADER_SAMPLE is supported for R32G32B32A32_UINT.\n");
20222 if (feature_level
>= D3D_FEATURE_LEVEL_10_0
)
20224 ok(format_support
[DXGI_FORMAT_R32G32B32A32_UINT
] & D3D11_FORMAT_SUPPORT_SHADER_LOAD
,
20225 "SHADER_LOAD is not supported for R32G32B32A32_UINT.\n");
20228 check_format_support(format_support
, feature_level
,
20229 index_buffers
, ARRAY_SIZE(index_buffers
),
20230 D3D11_FORMAT_SUPPORT_IA_INDEX_BUFFER
, "index buffer");
20232 check_format_support(format_support
, feature_level
,
20233 display_format_support
, ARRAY_SIZE(display_format_support
),
20234 D3D11_FORMAT_SUPPORT_DISPLAY
, "display");
20236 refcount
= ID3D11Device_Release(device
);
20237 ok(!refcount
, "Device has %u references left.\n", refcount
);
20240 static void test_fl9_draw(const D3D_FEATURE_LEVEL feature_level
)
20242 struct d3d11_test_context test_context
;
20243 D3D11_SUBRESOURCE_DATA resource_data
;
20244 D3D11_TEXTURE2D_DESC texture_desc
;
20245 ID3D11ShaderResourceView
*srv
;
20246 ID3D11DeviceContext
*context
;
20247 ID3D11Texture2D
*texture
;
20248 ID3D11PixelShader
*ps
;
20249 ID3D11Device
*device
;
20252 static const struct vec4 color
= {0.2f
, 0.3f
, 0.0f
, 1.0f
};
20253 static const DWORD ps_code
[] =
20256 float4
main() : SV_TARGET
20258 return float4(1.0f
, 0.0f
, 0.0f
, 0.5f
);
20261 0x43425844, 0xb70eda74, 0xc9a7f982, 0xebc31bbf, 0x952a1360, 0x00000001, 0x00000168, 0x00000005,
20262 0x00000034, 0x0000008c, 0x000000e4, 0x00000124, 0x00000134, 0x53414e58, 0x00000050, 0x00000050,
20263 0xffff0200, 0x0000002c, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0x00240000,
20264 0xffff0200, 0x05000051, 0xa00f0000, 0x3f800000, 0x00000000, 0x00000000, 0x3f000000, 0x02000001,
20265 0x800f0800, 0xa0e40000, 0x0000ffff, 0x396e6f41, 0x00000050, 0x00000050, 0xffff0200, 0x0000002c,
20266 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0xffff0200, 0x05000051,
20267 0xa00f0000, 0x3f800000, 0x00000000, 0x00000000, 0x3f000000, 0x02000001, 0x800f0800, 0xa0e40000,
20268 0x0000ffff, 0x52444853, 0x00000038, 0x00000040, 0x0000000e, 0x03000065, 0x001020f2, 0x00000000,
20269 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f000000,
20270 0x0100003e, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, 0x0000002c, 0x00000001,
20271 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653,
20272 0x45475241, 0xabab0054,
20274 static const DWORD ps_texture_code
[] =
20280 float4
main() : SV_TARGET
20282 return t
.Sample(s
, (float2
)0);
20285 0x43425844, 0xf876c2db, 0x13725f1f, 0xcb6d3d65, 0x9994473f, 0x00000001, 0x000001d4, 0x00000005,
20286 0x00000034, 0x000000a0, 0x00000124, 0x00000190, 0x000001a0, 0x53414e58, 0x00000064, 0x00000064,
20287 0xffff0200, 0x0000003c, 0x00000028, 0x00280000, 0x00280000, 0x00280000, 0x00240001, 0x00280000,
20288 0x00000000, 0xffff0200, 0x05000051, 0xa00f0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
20289 0x0200001f, 0x90000000, 0xa00f0800, 0x03000042, 0x800f0800, 0xa0000000, 0xa0e40800, 0x0000ffff,
20290 0x396e6f41, 0x0000007c, 0x0000007c, 0xffff0200, 0x00000054, 0x00000028, 0x00280000, 0x00280000,
20291 0x00280000, 0x00240001, 0x00280000, 0x00000000, 0xffff0200, 0x05000051, 0xa00f0000, 0x00000000,
20292 0x00000000, 0x00000000, 0x00000000, 0x0200001f, 0x90000000, 0xa00f0800, 0x02000001, 0x80030000,
20293 0xa0000000, 0x03000042, 0x800f0000, 0x80e40000, 0xa0e40800, 0x02000001, 0x800f0800, 0x80e40000,
20294 0x0000ffff, 0x52444853, 0x00000064, 0x00000040, 0x00000019, 0x0300005a, 0x00106000, 0x00000000,
20295 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x03000065, 0x001020f2, 0x00000000, 0x0c000045,
20296 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00107e46,
20297 0x00000000, 0x00106000, 0x00000000, 0x0100003e, 0x4e475349, 0x00000008, 0x00000000, 0x00000008,
20298 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
20299 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054,
20301 static const DWORD texture_data
[] = {0xffffff00};
20303 if (!init_test_context(&test_context
, &feature_level
))
20306 device
= test_context
.device
;
20307 context
= test_context
.immediate_context
;
20309 texture_desc
.Width
= 1;
20310 texture_desc
.Height
= 1;
20311 texture_desc
.MipLevels
= 0;
20312 texture_desc
.ArraySize
= 1;
20313 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
20314 texture_desc
.SampleDesc
.Count
= 1;
20315 texture_desc
.SampleDesc
.Quality
= 0;
20316 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
20317 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
20318 texture_desc
.CPUAccessFlags
= 0;
20319 texture_desc
.MiscFlags
= 0;
20320 resource_data
.pSysMem
= texture_data
;
20321 resource_data
.SysMemPitch
= sizeof(texture_data
);
20322 resource_data
.SysMemSlicePitch
= 0;
20323 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &texture
);
20324 ok(SUCCEEDED(hr
), "Failed to create 2d texture, hr %#x.\n", hr
);
20325 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
20326 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
20328 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
20329 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
20330 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
20331 draw_quad(&test_context
);
20332 check_texture_color(test_context
.backbuffer
, 0x7f0000ff, 1);
20333 ID3D11PixelShader_Release(ps
);
20335 draw_color_quad(&test_context
, &color
);
20336 todo_wine
check_texture_color(test_context
.backbuffer
, 0xff004c33, 1);
20338 hr
= ID3D11Device_CreatePixelShader(device
, ps_texture_code
, sizeof(ps_texture_code
), NULL
, &ps
);
20339 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x, feature level %#x.\n", hr
, feature_level
);
20340 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
20341 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
20342 draw_quad(&test_context
);
20343 check_texture_color(test_context
.backbuffer
, 0xffffff00, 1);
20344 ID3D11PixelShader_Release(ps
);
20346 ID3D11ShaderResourceView_Release(srv
);
20347 ID3D11Texture2D_Release(texture
);
20348 release_test_context(&test_context
);
20351 static void queue_for_each_feature_level_in_range(D3D_FEATURE_LEVEL begin
,
20352 D3D_FEATURE_LEVEL end
, void (*test_func
)(const D3D_FEATURE_LEVEL fl
))
20354 static const D3D_FEATURE_LEVEL feature_levels
[] =
20356 D3D_FEATURE_LEVEL_11_1
,
20357 D3D_FEATURE_LEVEL_11_0
,
20358 D3D_FEATURE_LEVEL_10_1
,
20359 D3D_FEATURE_LEVEL_10_0
,
20360 D3D_FEATURE_LEVEL_9_3
,
20361 D3D_FEATURE_LEVEL_9_2
,
20362 D3D_FEATURE_LEVEL_9_1
20366 assert(begin
<= end
);
20367 for (i
= 0; i
< ARRAY_SIZE(feature_levels
); ++i
)
20369 if (begin
<= feature_levels
[i
] && feature_levels
[i
] <= end
)
20370 queue_test_fl(test_func
, feature_levels
[i
]);
20374 static void queue_for_each_feature_level(void (*test_func
)(const D3D_FEATURE_LEVEL fl
))
20376 queue_for_each_feature_level_in_range(D3D_FEATURE_LEVEL_9_1
,
20377 D3D_FEATURE_LEVEL_11_1
, test_func
);
20380 static void queue_for_each_9_x_feature_level(void (*test_func
)(const D3D_FEATURE_LEVEL fl
))
20382 queue_for_each_feature_level_in_range(D3D_FEATURE_LEVEL_9_1
,
20383 D3D_FEATURE_LEVEL_9_3
, test_func
);
20386 static void test_ddy(void)
20388 static const struct
20390 struct vec4 position
;
20391 unsigned int color
;
20395 {{-1.0f
, -1.0f
, 0.0f
, 1.0f
}, 0x00ff0000},
20396 {{-1.0f
, 1.0f
, 0.0f
, 1.0f
}, 0x0000ff00},
20397 {{ 1.0f
, -1.0f
, 0.0f
, 1.0f
}, 0x00ff0000},
20398 {{ 1.0f
, 1.0f
, 0.0f
, 1.0f
}, 0x0000ff00},
20400 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
20402 {"SV_POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
20403 {"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, 16, D3D11_INPUT_PER_VERTEX_DATA
, 0},
20408 float4 pos
: SV_POSITION
;
20409 float4 color
: COLOR
;
20412 void main(in
struct vs_data vs_input
, out
struct vs_data vs_output
)
20414 vs_output
.pos
= vs_input
.pos
;
20415 vs_output
.color
= vs_input
.color
;
20418 static const DWORD vs_code
[] =
20420 0x43425844, 0xd5b32785, 0x35332906, 0x4d05e031, 0xf66a58af, 0x00000001, 0x00000144, 0x00000003,
20421 0x0000002c, 0x00000080, 0x000000d4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
20422 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000044, 0x00000000, 0x00000000,
20423 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
20424 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
20425 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
20426 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000068, 0x00010040,
20427 0x0000001a, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067,
20428 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2,
20429 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001,
20435 float4 pos
: SV_POSITION
;
20436 float4 color
: COLOR
;
20439 float4
main(struct ps_data ps_input
) : SV_Target
20441 return ddy(ps_input
.color
) * 240.0 + 0.5;
20444 static const DWORD ps_code_ddy
[] =
20446 0x43425844, 0x423712f6, 0x786c59c2, 0xa6023c60, 0xb79faad2, 0x00000001, 0x00000138, 0x00000003,
20447 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
20448 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
20449 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
20450 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
20451 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x0000007c, 0x00000040,
20452 0x0000001f, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
20453 0x00000001, 0x0500000c, 0x001000f2, 0x00000000, 0x00101e46, 0x00000001, 0x0f000032, 0x001020f2,
20454 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x43700000, 0x43700000, 0x43700000, 0x43700000,
20455 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, 0x0100003e,
20460 float4 pos
: SV_POSITION
;
20461 float4 color
: COLOR
;
20464 float4
main(struct ps_data ps_input
) : SV_Target
20466 return ddy_coarse(ps_input
.color
) * 240.0 + 0.5;
20469 static const DWORD ps_code_ddy_coarse
[] =
20471 0x43425844, 0xbf9a31cb, 0xb42695b6, 0x629119b8, 0x6962d5dd, 0x00000001, 0x0000013c, 0x00000003,
20472 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
20473 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
20474 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
20475 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
20476 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000080, 0x00000050,
20477 0x00000020, 0x0100086a, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
20478 0x02000068, 0x00000001, 0x0500007c, 0x001000f2, 0x00000000, 0x00101e46, 0x00000001, 0x0f000032,
20479 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x43700000, 0x43700000, 0x43700000,
20480 0x43700000, 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, 0x0100003e,
20485 float4 pos
: SV_POSITION
;
20486 float4 color
: COLOR
;
20489 float4
main(struct ps_data ps_input
) : SV_Target
20491 return ddy_fine(ps_input
.color
) * 240.0 + 0.5;
20494 static const DWORD ps_code_ddy_fine
[] =
20496 0x43425844, 0xea6563ae, 0x3ee0da50, 0x4c2b3ef3, 0xa69a4077, 0x00000001, 0x0000013c, 0x00000003,
20497 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
20498 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
20499 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
20500 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
20501 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000080, 0x00000050,
20502 0x00000020, 0x0100086a, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
20503 0x02000068, 0x00000001, 0x0500007d, 0x001000f2, 0x00000000, 0x00101e46, 0x00000001, 0x0f000032,
20504 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x43700000, 0x43700000, 0x43700000,
20505 0x43700000, 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, 0x0100003e,
20507 static const struct
20509 D3D_FEATURE_LEVEL min_feature_level
;
20510 const DWORD
*ps_code
;
20511 unsigned int ps_code_size
;
20515 {D3D_FEATURE_LEVEL_10_0
, ps_code_ddy
, sizeof(ps_code_ddy
)},
20516 {D3D_FEATURE_LEVEL_11_0
, ps_code_ddy_coarse
, sizeof(ps_code_ddy_coarse
)},
20517 {D3D_FEATURE_LEVEL_11_0
, ps_code_ddy_fine
, sizeof(ps_code_ddy_fine
)},
20519 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 1.0f
};
20520 struct d3d11_test_context test_context
;
20521 D3D11_TEXTURE2D_DESC texture_desc
;
20522 D3D_FEATURE_LEVEL feature_level
;
20523 ID3D11InputLayout
*input_layout
;
20524 ID3D11DeviceContext
*context
;
20525 unsigned int stride
, offset
;
20526 struct resource_readback rb
;
20527 ID3D11RenderTargetView
*rtv
;
20528 ID3D11Texture2D
*texture
;
20529 ID3D11VertexShader
*vs
;
20530 ID3D11PixelShader
*ps
;
20531 ID3D11Device
*device
;
20537 if (!init_test_context(&test_context
, NULL
))
20540 device
= test_context
.device
;
20541 context
= test_context
.immediate_context
;
20542 feature_level
= ID3D11Device_GetFeatureLevel(device
);
20544 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
20545 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
20546 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
20548 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
20549 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
20551 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
20552 vs_code
, sizeof(vs_code
), &input_layout
);
20553 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
20555 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(quad
), quad
);
20557 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
20558 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
20560 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
20561 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
20562 stride
= sizeof(*quad
);
20564 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, &stride
, &offset
);
20565 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
20567 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
20569 if (feature_level
< tests
[i
].min_feature_level
)
20571 skip("Skipping test %u, feature_level %#x lower than minimum required %#x.\n", i
,
20572 feature_level
, tests
[i
].min_feature_level
);
20576 hr
= ID3D11Device_CreatePixelShader(device
, tests
[i
].ps_code
, tests
[i
].ps_code_size
, NULL
, &ps
);
20577 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
20579 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
20581 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
20582 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, red
);
20583 ID3D11DeviceContext_Draw(context
, 4, 0);
20585 get_texture_readback(texture
, 0, &rb
);
20586 color
= get_readback_color(&rb
, 320, 190, 0);
20587 ok(compare_color(color
, 0x7fff007f, 1), "Got unexpected color 0x%08x.\n", color
);
20588 color
= get_readback_color(&rb
, 255, 240, 0);
20589 ok(compare_color(color
, 0x7fff007f, 1), "Got unexpected color 0x%08x.\n", color
);
20590 color
= get_readback_color(&rb
, 320, 240, 0);
20591 ok(compare_color(color
, 0x7fff007f, 1), "Got unexpected color 0x%08x.\n", color
);
20592 color
= get_readback_color(&rb
, 385, 240, 0);
20593 ok(compare_color(color
, 0x7fff007f, 1), "Got unexpected color 0x%08x.\n", color
);
20594 color
= get_readback_color(&rb
, 320, 290, 0);
20595 ok(compare_color(color
, 0x7fff007f, 1), "Got unexpected color 0x%08x.\n", color
);
20596 release_resource_readback(&rb
);
20598 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &test_context
.backbuffer_rtv
, NULL
);
20599 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
20600 ID3D11DeviceContext_Draw(context
, 4, 0);
20602 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
20603 color
= get_readback_color(&rb
, 320, 190, 0);
20604 ok(compare_color(color
, 0x7fff007f, 1), "Got unexpected color 0x%08x.\n", color
);
20605 color
= get_readback_color(&rb
, 255, 240, 0);
20606 ok(compare_color(color
, 0x7fff007f, 1), "Got unexpected color 0x%08x.\n", color
);
20607 color
= get_readback_color(&rb
, 320, 240, 0);
20608 ok(compare_color(color
, 0x7fff007f, 1), "Got unexpected color 0x%08x.\n", color
);
20609 color
= get_readback_color(&rb
, 385, 240, 0);
20610 ok(compare_color(color
, 0x7fff007f, 1), "Got unexpected color 0x%08x.\n", color
);
20611 color
= get_readback_color(&rb
, 320, 290, 0);
20612 ok(compare_color(color
, 0x7fff007f, 1), "Got unexpected color 0x%08x.\n", color
);
20613 release_resource_readback(&rb
);
20615 ID3D11PixelShader_Release(ps
);
20618 ID3D11VertexShader_Release(vs
);
20619 ID3D11Buffer_Release(vb
);
20620 ID3D11InputLayout_Release(input_layout
);
20621 ID3D11Texture2D_Release(texture
);
20622 ID3D11RenderTargetView_Release(rtv
);
20623 release_test_context(&test_context
);
20626 static void test_shader_input_registers_limits(void)
20628 struct d3d11_test_context test_context
;
20629 D3D11_SUBRESOURCE_DATA resource_data
;
20630 D3D11_TEXTURE2D_DESC texture_desc
;
20631 D3D11_SAMPLER_DESC sampler_desc
;
20632 ID3D11ShaderResourceView
*srv
;
20633 ID3D11DeviceContext
*context
;
20634 ID3D11SamplerState
*sampler
;
20635 ID3D11Texture2D
*texture
;
20636 ID3D11PixelShader
*ps
;
20637 ID3D11Device
*device
;
20640 static const DWORD ps_last_register_code
[] =
20643 Texture2D t
: register(t127
);
20644 SamplerState s
: register(s15
);
20646 void main(out float4 target
: SV_Target
)
20648 target
= t
.Sample(s
, float2(0, 0));
20651 0x43425844, 0xd81ff2f8, 0x8c704b9c, 0x8c6f4857, 0xd02949ac, 0x00000001, 0x000000dc, 0x00000003,
20652 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
20653 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
20654 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000064, 0x00000040, 0x00000019,
20655 0x0300005a, 0x00106000, 0x0000000f, 0x04001858, 0x00107000, 0x0000007f, 0x00005555, 0x03000065,
20656 0x001020f2, 0x00000000, 0x0c000045, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000,
20657 0x00000000, 0x00000000, 0x00107e46, 0x0000007f, 0x00106000, 0x0000000f, 0x0100003e,
20659 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
20660 static const DWORD texture_data
[] = {0xff00ff00};
20662 if (!init_test_context(&test_context
, NULL
))
20665 device
= test_context
.device
;
20666 context
= test_context
.immediate_context
;
20668 texture_desc
.Width
= 1;
20669 texture_desc
.Height
= 1;
20670 texture_desc
.MipLevels
= 0;
20671 texture_desc
.ArraySize
= 1;
20672 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
20673 texture_desc
.SampleDesc
.Count
= 1;
20674 texture_desc
.SampleDesc
.Quality
= 0;
20675 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
20676 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
20677 texture_desc
.CPUAccessFlags
= 0;
20678 texture_desc
.MiscFlags
= 0;
20680 resource_data
.pSysMem
= texture_data
;
20681 resource_data
.SysMemPitch
= sizeof(texture_data
);
20682 resource_data
.SysMemSlicePitch
= 0;
20684 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &texture
);
20685 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
20687 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
20688 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
20690 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
20691 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
20692 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
20693 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
20694 sampler_desc
.MipLODBias
= 0.0f
;
20695 sampler_desc
.MaxAnisotropy
= 0;
20696 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
20697 sampler_desc
.BorderColor
[0] = 0.0f
;
20698 sampler_desc
.BorderColor
[1] = 0.0f
;
20699 sampler_desc
.BorderColor
[2] = 0.0f
;
20700 sampler_desc
.BorderColor
[3] = 0.0f
;
20701 sampler_desc
.MinLOD
= 0.0f
;
20702 sampler_desc
.MaxLOD
= 0.0f
;
20704 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler
);
20705 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
20707 hr
= ID3D11Device_CreatePixelShader(device
, ps_last_register_code
, sizeof(ps_last_register_code
), NULL
, &ps
);
20708 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
20709 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
20711 ID3D11DeviceContext_PSSetShaderResources(context
,
20712 D3D11_COMMONSHADER_INPUT_RESOURCE_REGISTER_COUNT
- 1, 1, &srv
);
20713 ID3D11DeviceContext_PSSetSamplers(context
, D3D11_COMMONSHADER_SAMPLER_REGISTER_COUNT
- 1, 1, &sampler
);
20714 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
20715 draw_quad(&test_context
);
20716 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
20718 ID3D11PixelShader_Release(ps
);
20719 ID3D11SamplerState_Release(sampler
);
20720 ID3D11ShaderResourceView_Release(srv
);
20721 ID3D11Texture2D_Release(texture
);
20722 release_test_context(&test_context
);
20725 static void test_unbind_shader_resource_view(void)
20727 struct d3d11_test_context test_context
;
20728 D3D11_SUBRESOURCE_DATA resource_data
;
20729 ID3D11ShaderResourceView
*srv
, *srv2
;
20730 D3D11_TEXTURE2D_DESC texture_desc
;
20731 ID3D11DeviceContext
*context
;
20732 ID3D11Texture2D
*texture
;
20733 ID3D11PixelShader
*ps
;
20734 ID3D11Device
*device
;
20737 static const DWORD ps_code
[] =
20744 float4
main() : SV_Target
20746 return min(t0
.Sample(s
, float2(0, 0)) + t1
.Sample(s
, float2(0, 0)), 1.0f
);
20749 0x43425844, 0x698dc0cb, 0x0bf322b8, 0xee127418, 0xfe9214ce, 0x00000001, 0x00000168, 0x00000003,
20750 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
20751 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
20752 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000f0, 0x00000040, 0x0000003c,
20753 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858,
20754 0x00107000, 0x00000001, 0x00005555, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002,
20755 0x0c000045, 0x001000f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
20756 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0c000045, 0x001000f2, 0x00000001, 0x00004002,
20757 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00107e46, 0x00000001, 0x00106000, 0x00000000,
20758 0x07000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00100e46, 0x00000001, 0x0a000033,
20759 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3f800000, 0x3f800000, 0x3f800000,
20760 0x3f800000, 0x0100003e,
20762 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
20763 static const DWORD texture_data
[] = {0xff00ff00};
20765 if (!init_test_context(&test_context
, NULL
))
20768 device
= test_context
.device
;
20769 context
= test_context
.immediate_context
;
20771 texture_desc
.Width
= 1;
20772 texture_desc
.Height
= 1;
20773 texture_desc
.MipLevels
= 0;
20774 texture_desc
.ArraySize
= 1;
20775 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
20776 texture_desc
.SampleDesc
.Count
= 1;
20777 texture_desc
.SampleDesc
.Quality
= 0;
20778 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
20779 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
20780 texture_desc
.CPUAccessFlags
= 0;
20781 texture_desc
.MiscFlags
= 0;
20783 resource_data
.pSysMem
= texture_data
;
20784 resource_data
.SysMemPitch
= sizeof(texture_data
);
20785 resource_data
.SysMemSlicePitch
= 0;
20787 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &texture
);
20788 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
20789 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
20790 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
20791 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
20792 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
20793 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
20795 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
20796 ID3D11DeviceContext_PSSetShaderResources(context
, 1, 1, &srv
);
20797 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
20798 draw_quad(&test_context
);
20799 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
20802 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv2
);
20803 ID3D11DeviceContext_PSSetShaderResources(context
, 1, 1, &srv2
);
20804 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
20805 draw_quad(&test_context
);
20806 todo_wine
check_texture_color(test_context
.backbuffer
, 0x00000000, 1);
20808 ID3D11PixelShader_Release(ps
);
20809 ID3D11ShaderResourceView_Release(srv
);
20810 ID3D11Texture2D_Release(texture
);
20811 release_test_context(&test_context
);
20814 static void test_stencil_separate(void)
20816 struct d3d11_test_context test_context
;
20817 D3D11_TEXTURE2D_DESC texture_desc
;
20818 D3D11_DEPTH_STENCIL_DESC ds_desc
;
20819 ID3D11DepthStencilState
*ds_state
;
20820 ID3D11DepthStencilView
*ds_view
;
20821 D3D11_RASTERIZER_DESC rs_desc
;
20822 ID3D11DeviceContext
*context
;
20823 ID3D11RasterizerState
*rs
;
20824 ID3D11Texture2D
*texture
;
20825 ID3D11Device
*device
;
20828 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 1.0f
};
20829 static const struct vec4 green
= {0.0f
, 1.0f
, 0.0f
, 1.0f
};
20830 static const struct vec3 ccw_quad
[] =
20832 {-1.0f
, -1.0f
, 0.0f
},
20833 { 1.0f
, -1.0f
, 0.0f
},
20834 {-1.0f
, 1.0f
, 0.0f
},
20835 { 1.0f
, 1.0f
, 0.0f
},
20838 if (!init_test_context(&test_context
, NULL
))
20841 device
= test_context
.device
;
20842 context
= test_context
.immediate_context
;
20844 texture_desc
.Width
= 640;
20845 texture_desc
.Height
= 480;
20846 texture_desc
.MipLevels
= 1;
20847 texture_desc
.ArraySize
= 1;
20848 texture_desc
.Format
= DXGI_FORMAT_D24_UNORM_S8_UINT
;
20849 texture_desc
.SampleDesc
.Count
= 1;
20850 texture_desc
.SampleDesc
.Quality
= 0;
20851 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
20852 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
20853 texture_desc
.CPUAccessFlags
= 0;
20854 texture_desc
.MiscFlags
= 0;
20855 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
20856 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
20857 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, NULL
, &ds_view
);
20858 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
20860 ds_desc
.DepthEnable
= TRUE
;
20861 ds_desc
.DepthWriteMask
= D3D11_DEPTH_WRITE_MASK_ALL
;
20862 ds_desc
.DepthFunc
= D3D11_COMPARISON_LESS
;
20863 ds_desc
.StencilEnable
= TRUE
;
20864 ds_desc
.StencilReadMask
= D3D11_DEFAULT_STENCIL_READ_MASK
;
20865 ds_desc
.StencilWriteMask
= D3D11_DEFAULT_STENCIL_WRITE_MASK
;
20866 ds_desc
.FrontFace
.StencilFailOp
= D3D11_STENCIL_OP_ZERO
;
20867 ds_desc
.FrontFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_ZERO
;
20868 ds_desc
.FrontFace
.StencilPassOp
= D3D11_STENCIL_OP_ZERO
;
20869 ds_desc
.FrontFace
.StencilFunc
= D3D11_COMPARISON_NEVER
;
20870 ds_desc
.BackFace
.StencilFailOp
= D3D11_STENCIL_OP_ZERO
;
20871 ds_desc
.BackFace
.StencilDepthFailOp
= D3D11_STENCIL_OP_ZERO
;
20872 ds_desc
.BackFace
.StencilPassOp
= D3D11_STENCIL_OP_ZERO
;
20873 ds_desc
.BackFace
.StencilFunc
= D3D11_COMPARISON_ALWAYS
;
20874 hr
= ID3D11Device_CreateDepthStencilState(device
, &ds_desc
, &ds_state
);
20875 ok(SUCCEEDED(hr
), "Failed to create depth stencil state, hr %#x.\n", hr
);
20877 rs_desc
.FillMode
= D3D11_FILL_SOLID
;
20878 rs_desc
.CullMode
= D3D11_CULL_NONE
;
20879 rs_desc
.FrontCounterClockwise
= FALSE
;
20880 rs_desc
.DepthBias
= 0;
20881 rs_desc
.DepthBiasClamp
= 0.0f
;
20882 rs_desc
.SlopeScaledDepthBias
= 0.0f
;
20883 rs_desc
.DepthClipEnable
= TRUE
;
20884 rs_desc
.ScissorEnable
= FALSE
;
20885 rs_desc
.MultisampleEnable
= FALSE
;
20886 rs_desc
.AntialiasedLineEnable
= FALSE
;
20887 ID3D11Device_CreateRasterizerState(device
, &rs_desc
, &rs
);
20888 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
20890 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
20891 ID3D11DeviceContext_ClearDepthStencilView(context
, ds_view
, D3D11_CLEAR_DEPTH
| D3D11_CLEAR_STENCIL
, 1.0f
, 0);
20892 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &test_context
.backbuffer_rtv
, ds_view
);
20893 ID3D11DeviceContext_OMSetDepthStencilState(context
, ds_state
, 0);
20894 ID3D11DeviceContext_RSSetState(context
, rs
);
20896 draw_color_quad(&test_context
, &green
);
20897 check_texture_color(test_context
.backbuffer
, 0xff0000ff, 1);
20899 ID3D11Buffer_Release(test_context
.vb
);
20900 test_context
.vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(ccw_quad
), ccw_quad
);
20902 draw_color_quad(&test_context
, &green
);
20903 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
20905 ID3D11RasterizerState_Release(rs
);
20906 rs_desc
.FrontCounterClockwise
= TRUE
;
20907 ID3D11Device_CreateRasterizerState(device
, &rs_desc
, &rs
);
20908 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
20909 ID3D11DeviceContext_RSSetState(context
, rs
);
20911 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
20912 draw_color_quad(&test_context
, &green
);
20913 check_texture_color(test_context
.backbuffer
, 0xff0000ff, 1);
20915 ID3D11DepthStencilState_Release(ds_state
);
20916 ID3D11DepthStencilView_Release(ds_view
);
20917 ID3D11RasterizerState_Release(rs
);
20918 ID3D11Texture2D_Release(texture
);
20919 release_test_context(&test_context
);
20922 static void test_uav_load(void)
20933 UINT miplevel_count
;
20935 DXGI_FORMAT format
;
20936 D3D11_SUBRESOURCE_DATA data
[3];
20939 ID3D11RenderTargetView
*rtv_float
, *rtv_uint
, *rtv_sint
;
20940 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
20941 D3D11_RENDER_TARGET_VIEW_DESC rtv_desc
;
20942 struct d3d11_test_context test_context
;
20943 const struct texture
*current_texture
;
20944 ID3D11Texture2D
*texture
, *rt_texture
;
20945 D3D11_TEXTURE2D_DESC texture_desc
;
20946 const struct shader
*current_ps
;
20947 ID3D11UnorderedAccessView
*uav
;
20948 ID3D11DeviceContext
*context
;
20949 struct resource_readback rb
;
20950 ID3D11PixelShader
*ps
;
20951 ID3D11Device
*device
;
20952 unsigned int i
, x
, y
;
20956 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
20957 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
20958 static const DWORD ps_ld_2d_float_code
[] =
20961 RWTexture2D
<float> u
;
20963 float main(float4 position
: SV_Position
) : SV_Target
20966 u
.GetDimensions(s
.x
, s
.y
);
20967 return u
[s
* float2(position
.x
/ 640.0f
, position
.y
/ 480.0f
)];
20970 0x43425844, 0xd5996e04, 0x6bede909, 0x0a7ad18e, 0x5eb277fb, 0x00000001, 0x00000194, 0x00000003,
20971 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
20972 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
20973 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
20974 0x00000000, 0x00000e01, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000f8, 0x00000050,
20975 0x0000003e, 0x0100086a, 0x0400189c, 0x0011e000, 0x00000001, 0x00005555, 0x04002064, 0x00101032,
20976 0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000000, 0x02000068, 0x00000001, 0x8900003d,
20977 0x800000c2, 0x00155543, 0x00100032, 0x00000000, 0x00004001, 0x00000000, 0x0011ee46, 0x00000001,
20978 0x07000038, 0x001000f2, 0x00000000, 0x00100546, 0x00000000, 0x00101546, 0x00000000, 0x0a000038,
20979 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x3b088889,
20980 0x3b088889, 0x0500001c, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x890000a3, 0x800000c2,
20981 0x00155543, 0x00100012, 0x00000000, 0x00100e46, 0x00000000, 0x0011ee46, 0x00000001, 0x05000036,
20982 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0100003e,
20984 static const struct shader ps_ld_2d_float
= {ps_ld_2d_float_code
, sizeof(ps_ld_2d_float_code
)};
20985 static const DWORD ps_ld_2d_uint_code
[] =
20988 RWTexture2D
<uint
> u
;
20990 uint
main(float4 position
: SV_Position
) : SV_Target
20993 u
.GetDimensions(s
.x
, s
.y
);
20994 return u
[s
* float2(position
.x
/ 640.0f
, position
.y
/ 480.0f
)];
20997 0x43425844, 0x2cc0af18, 0xb28eca73, 0x9651215b, 0xebe3f361, 0x00000001, 0x00000194, 0x00000003,
20998 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
20999 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
21000 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001,
21001 0x00000000, 0x00000e01, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000f8, 0x00000050,
21002 0x0000003e, 0x0100086a, 0x0400189c, 0x0011e000, 0x00000001, 0x00004444, 0x04002064, 0x00101032,
21003 0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000000, 0x02000068, 0x00000001, 0x8900003d,
21004 0x800000c2, 0x00111103, 0x00100032, 0x00000000, 0x00004001, 0x00000000, 0x0011ee46, 0x00000001,
21005 0x07000038, 0x001000f2, 0x00000000, 0x00100546, 0x00000000, 0x00101546, 0x00000000, 0x0a000038,
21006 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x3b088889,
21007 0x3b088889, 0x0500001c, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x890000a3, 0x800000c2,
21008 0x00111103, 0x00100012, 0x00000000, 0x00100e46, 0x00000000, 0x0011ee46, 0x00000001, 0x05000036,
21009 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0100003e,
21011 static const struct shader ps_ld_2d_uint
= {ps_ld_2d_uint_code
, sizeof(ps_ld_2d_uint_code
)};
21012 static const DWORD ps_ld_2d_int_code
[] =
21015 RWTexture2D
<int> u
;
21017 int main(float4 position
: SV_Position
) : SV_Target
21020 u
.GetDimensions(s
.x
, s
.y
);
21021 return u
[s
* float2(position
.x
/ 640.0f
, position
.y
/ 480.0f
)];
21024 0x43425844, 0x7deee248, 0xe7c48698, 0x9454db00, 0x921810e7, 0x00000001, 0x00000194, 0x00000003,
21025 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
21026 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
21027 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000002,
21028 0x00000000, 0x00000e01, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000f8, 0x00000050,
21029 0x0000003e, 0x0100086a, 0x0400189c, 0x0011e000, 0x00000001, 0x00003333, 0x04002064, 0x00101032,
21030 0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000000, 0x02000068, 0x00000001, 0x8900003d,
21031 0x800000c2, 0x000cccc3, 0x00100032, 0x00000000, 0x00004001, 0x00000000, 0x0011ee46, 0x00000001,
21032 0x07000038, 0x001000f2, 0x00000000, 0x00100546, 0x00000000, 0x00101546, 0x00000000, 0x0a000038,
21033 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x3b088889,
21034 0x3b088889, 0x0500001c, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x890000a3, 0x800000c2,
21035 0x000cccc3, 0x00100012, 0x00000000, 0x00100e46, 0x00000000, 0x0011ee46, 0x00000001, 0x05000036,
21036 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0100003e,
21038 static const struct shader ps_ld_2d_int
= {ps_ld_2d_int_code
, sizeof(ps_ld_2d_int_code
)};
21039 static const DWORD ps_ld_2d_uint_arr_code
[] =
21042 RWTexture2DArray
<uint
> u
;
21046 uint
main(float4 position
: SV_Position
) : SV_Target
21049 u
.GetDimensions(s
.x
, s
.y
, s
.z
);
21051 return u
[s
* float3(position
.x
/ 640.0f
, position
.y
/ 480.0f
, 1.0f
)];
21054 0x43425844, 0xa7630358, 0xd7e7228f, 0xa9f1be03, 0x838554f1, 0x00000001, 0x000001bc, 0x00000003,
21055 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
21056 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
21057 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001,
21058 0x00000000, 0x00000e01, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000120, 0x00000050,
21059 0x00000048, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0400409c, 0x0011e000,
21060 0x00000001, 0x00004444, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x00102012,
21061 0x00000000, 0x02000068, 0x00000001, 0x8900003d, 0x80000202, 0x00111103, 0x00100032, 0x00000000,
21062 0x00004001, 0x00000000, 0x0011ee46, 0x00000001, 0x07000038, 0x00100032, 0x00000000, 0x00100046,
21063 0x00000000, 0x00101046, 0x00000000, 0x06000056, 0x001000c2, 0x00000000, 0x00208006, 0x00000000,
21064 0x00000000, 0x0a000038, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3acccccd,
21065 0x3b088889, 0x3f800000, 0x3f800000, 0x0500001c, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
21066 0x890000a3, 0x80000202, 0x00111103, 0x00100012, 0x00000000, 0x00100e46, 0x00000000, 0x0011ee46,
21067 0x00000001, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0100003e,
21069 static const struct shader ps_ld_2d_uint_arr
= {ps_ld_2d_uint_arr_code
, sizeof(ps_ld_2d_uint_arr_code
)};
21070 static const float float_data
[] =
21072 0.50f
, 0.25f
, 1.00f
, 0.00f
,
21073 -1.00f
, -2.00f
, -3.00f
, -4.00f
,
21074 -0.50f
, -0.25f
, -1.00f
, -0.00f
,
21075 1.00f
, 2.00f
, 3.00f
, 4.00f
,
21077 static const unsigned int uint_data
[] =
21079 0x00, 0x10, 0x20, 0x30,
21080 0x40, 0x50, 0x60, 0x70,
21081 0x80, 0x90, 0xa0, 0xb0,
21082 0xc0, 0xd0, 0xe0, 0xf0,
21084 static const unsigned int uint_data2
[] =
21086 0xffff, 0xffff, 0xffff, 0xffff,
21087 0xffff, 0xc000, 0xc000, 0xffff,
21088 0xffff, 0xc000, 0xc000, 0xffff,
21089 0xffff, 0xffff, 0xffff, 0xffff,
21091 static const unsigned int uint_data3
[] =
21093 0xaa, 0xaa, 0xcc, 0xcc,
21094 0xaa, 0xaa, 0xdd, 0xdd,
21095 0xbb, 0xbb, 0xee, 0xee,
21096 0xbb, 0xbb, 0xff, 0xff,
21098 static const int int_data
[] =
21100 -1, 0x10, 0x20, 0x30,
21101 0x40, 0x50, 0x60, -777,
21102 -666, 0x90, -555, 0xb0,
21103 0xc0, 0xd0, 0xe0, -101,
21105 static const struct texture float_2d
= {4, 4, 1, 1, DXGI_FORMAT_R32_FLOAT
,
21106 {{float_data
, 4 * sizeof(*float_data
), 0}}};
21107 static const struct texture uint_2d
= {4, 4, 1, 1, DXGI_FORMAT_R32_UINT
,
21108 {{uint_data
, 4 * sizeof(*uint_data
), 0}}};
21109 static const struct texture uint2d_arr
= {4, 4, 1, 3, DXGI_FORMAT_R32_UINT
,
21110 {{uint_data
, 4 * sizeof(*uint_data
), 0},
21111 {uint_data2
, 4 * sizeof(*uint_data2
), 0},
21112 {uint_data3
, 4 * sizeof(*uint_data3
), 0}}};
21113 static const struct texture int_2d
= {4, 4, 1, 1, DXGI_FORMAT_R32_SINT
,
21114 {{int_data
, 4 * sizeof(*int_data
), 0}}};
21116 static const struct test
21118 const struct shader
*ps
;
21119 const struct texture
*texture
;
21120 struct uav_desc uav_desc
;
21121 struct uvec4 constant
;
21122 const DWORD
*expected_colors
;
21126 #define TEX_2D D3D11_UAV_DIMENSION_TEXTURE2D
21127 #define TEX_2D_ARRAY D3D11_UAV_DIMENSION_TEXTURE2DARRAY
21128 #define R32_FLOAT DXGI_FORMAT_R32_FLOAT
21129 #define R32_UINT DXGI_FORMAT_R32_UINT
21130 #define R32_SINT DXGI_FORMAT_R32_SINT
21131 {&ps_ld_2d_float
, &float_2d
, {R32_FLOAT
, TEX_2D
, 0}, {0}, (const DWORD
*)float_data
},
21132 {&ps_ld_2d_uint
, &uint_2d
, {R32_UINT
, TEX_2D
, 0}, {0}, (const DWORD
*)uint_data
},
21133 {&ps_ld_2d_int
, &int_2d
, {R32_SINT
, TEX_2D
, 0}, {0}, (const DWORD
*)int_data
},
21134 {&ps_ld_2d_uint_arr
, &uint2d_arr
, {R32_UINT
, TEX_2D_ARRAY
, 0, 0, ~0u}, {0}, (const DWORD
*)uint_data
},
21135 {&ps_ld_2d_uint_arr
, &uint2d_arr
, {R32_UINT
, TEX_2D_ARRAY
, 0, 0, ~0u}, {1}, (const DWORD
*)uint_data2
},
21136 {&ps_ld_2d_uint_arr
, &uint2d_arr
, {R32_UINT
, TEX_2D_ARRAY
, 0, 0, ~0u}, {2}, (const DWORD
*)uint_data3
},
21137 {&ps_ld_2d_uint_arr
, &uint2d_arr
, {R32_UINT
, TEX_2D_ARRAY
, 0, 1, ~0u}, {0}, (const DWORD
*)uint_data2
},
21138 {&ps_ld_2d_uint_arr
, &uint2d_arr
, {R32_UINT
, TEX_2D_ARRAY
, 0, 1, ~0u}, {1}, (const DWORD
*)uint_data3
},
21139 {&ps_ld_2d_uint_arr
, &uint2d_arr
, {R32_UINT
, TEX_2D_ARRAY
, 0, 2, ~0u}, {0}, (const DWORD
*)uint_data3
},
21141 #undef TEX_2D_ARRAY
21147 if (!init_test_context(&test_context
, &feature_level
))
21150 device
= test_context
.device
;
21151 context
= test_context
.immediate_context
;
21153 texture_desc
.Width
= 640;
21154 texture_desc
.Height
= 480;
21155 texture_desc
.MipLevels
= 1;
21156 texture_desc
.ArraySize
= 1;
21157 texture_desc
.Format
= DXGI_FORMAT_R32_TYPELESS
;
21158 texture_desc
.SampleDesc
.Count
= 1;
21159 texture_desc
.SampleDesc
.Quality
= 0;
21160 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
21161 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
21162 texture_desc
.CPUAccessFlags
= 0;
21163 texture_desc
.MiscFlags
= 0;
21164 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rt_texture
);
21165 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
21167 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_TEXTURE2D
;
21168 U(rtv_desc
).Texture2D
.MipSlice
= 0;
21170 rtv_desc
.Format
= DXGI_FORMAT_R32_FLOAT
;
21171 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rt_texture
, &rtv_desc
, &rtv_float
);
21172 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
21174 rtv_desc
.Format
= DXGI_FORMAT_R32_UINT
;
21175 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rt_texture
, &rtv_desc
, &rtv_uint
);
21176 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
21178 rtv_desc
.Format
= DXGI_FORMAT_R32_SINT
;
21179 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rt_texture
, &rtv_desc
, &rtv_sint
);
21180 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
21182 texture_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
21184 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(struct uvec4
), NULL
);
21185 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
21191 current_texture
= NULL
;
21192 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
21194 const struct test
*test
= &tests
[i
];
21195 ID3D11RenderTargetView
*current_rtv
;
21197 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
21198 NULL
, &test
->constant
, 0, 0);
21200 if (current_ps
!= test
->ps
)
21203 ID3D11PixelShader_Release(ps
);
21205 current_ps
= test
->ps
;
21207 hr
= ID3D11Device_CreatePixelShader(device
, current_ps
->code
, current_ps
->size
, NULL
, &ps
);
21208 ok(SUCCEEDED(hr
), "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
21210 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
21213 if (current_texture
!= test
->texture
)
21216 ID3D11Texture2D_Release(texture
);
21218 current_texture
= test
->texture
;
21220 texture_desc
.Width
= current_texture
->width
;
21221 texture_desc
.Height
= current_texture
->height
;
21222 texture_desc
.MipLevels
= current_texture
->miplevel_count
;
21223 texture_desc
.ArraySize
= current_texture
->array_size
;
21224 texture_desc
.Format
= current_texture
->format
;
21226 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, current_texture
->data
, &texture
);
21227 ok(SUCCEEDED(hr
), "Test %u: Failed to create texture, hr %#x.\n", i
, hr
);
21231 ID3D11UnorderedAccessView_Release(uav
);
21233 get_uav_desc(&uav_desc
, &test
->uav_desc
);
21234 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)texture
, &uav_desc
, &uav
);
21235 ok(SUCCEEDED(hr
), "Test %u: Failed to create unordered access view, hr %#x.\n", i
, hr
);
21237 switch (uav_desc
.Format
)
21239 case DXGI_FORMAT_R32_FLOAT
:
21240 current_rtv
= rtv_float
;
21242 case DXGI_FORMAT_R32_UINT
:
21243 current_rtv
= rtv_uint
;
21245 case DXGI_FORMAT_R32_SINT
:
21246 current_rtv
= rtv_sint
;
21249 trace("Unhandled format %#x.\n", uav_desc
.Format
);
21250 current_rtv
= NULL
;
21254 ID3D11DeviceContext_ClearRenderTargetView(context
, current_rtv
, white
);
21256 ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context
, 1, ¤t_rtv
, NULL
,
21259 draw_quad(&test_context
);
21261 get_texture_readback(rt_texture
, 0, &rb
);
21262 for (y
= 0; y
< 4; ++y
)
21264 for (x
= 0; x
< 4; ++x
)
21266 DWORD expected
= test
->expected_colors
[y
* 4 + x
];
21267 DWORD color
= get_readback_color(&rb
, 80 + x
* 160, 60 + y
* 120, 0);
21268 ok(compare_color(color
, expected
, 0),
21269 "Test %u: Got 0x%08x, expected 0x%08x at (%u, %u).\n",
21270 i
, color
, expected
, x
, y
);
21273 release_resource_readback(&rb
);
21275 ID3D11PixelShader_Release(ps
);
21276 ID3D11Texture2D_Release(texture
);
21277 ID3D11UnorderedAccessView_Release(uav
);
21279 ID3D11Buffer_Release(cb
);
21280 ID3D11RenderTargetView_Release(rtv_float
);
21281 ID3D11RenderTargetView_Release(rtv_sint
);
21282 ID3D11RenderTargetView_Release(rtv_uint
);
21283 ID3D11Texture2D_Release(rt_texture
);
21284 release_test_context(&test_context
);
21287 static void test_cs_uav_store(void)
21289 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
21290 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
21291 static const float zero
[4] = {0.0f
};
21292 D3D11_TEXTURE2D_DESC texture_desc
;
21293 ID3D11UnorderedAccessView
*uav
;
21294 struct device_desc device_desc
;
21295 ID3D11DeviceContext
*context
;
21296 struct vec4 input
= {1.0f
};
21297 ID3D11Texture2D
*texture
;
21298 ID3D11ComputeShader
*cs
;
21299 ID3D11Device
*device
;
21305 static const DWORD cs_1_thread_code
[] =
21308 RWTexture2D
<float> u
;
21312 [numthreads(1, 1, 1)]
21315 uint x
, y
, width
, height
;
21316 u
.GetDimensions(width
, height
);
21317 for (y
= 0; y
< height
; ++y
)
21319 for (x
= 0; x
< width
; ++x
)
21320 u
[uint2(x
, y
)] = value
;
21324 0x43425844, 0x6503503a, 0x4cd524e6, 0x2473915d, 0x93cf1201, 0x00000001, 0x000001c8, 0x00000003,
21325 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
21326 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000174, 0x00050050, 0x0000005d, 0x0100086a,
21327 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0400189c, 0x0011e000, 0x00000000, 0x00005555,
21328 0x02000068, 0x00000003, 0x0400009b, 0x00000001, 0x00000001, 0x00000001, 0x8900103d, 0x800000c2,
21329 0x00155543, 0x00100032, 0x00000000, 0x00004001, 0x00000000, 0x0011ee46, 0x00000000, 0x05000036,
21330 0x00100042, 0x00000000, 0x00004001, 0x00000000, 0x01000030, 0x07000050, 0x00100082, 0x00000000,
21331 0x0010002a, 0x00000000, 0x0010001a, 0x00000000, 0x03040003, 0x0010003a, 0x00000000, 0x05000036,
21332 0x001000e2, 0x00000001, 0x00100aa6, 0x00000000, 0x05000036, 0x00100082, 0x00000000, 0x00004001,
21333 0x00000000, 0x01000030, 0x07000050, 0x00100012, 0x00000002, 0x0010003a, 0x00000000, 0x0010000a,
21334 0x00000000, 0x03040003, 0x0010000a, 0x00000002, 0x05000036, 0x00100012, 0x00000001, 0x0010003a,
21335 0x00000000, 0x080000a4, 0x0011e0f2, 0x00000000, 0x00100e46, 0x00000001, 0x00208006, 0x00000000,
21336 0x00000000, 0x0700001e, 0x00100082, 0x00000000, 0x0010003a, 0x00000000, 0x00004001, 0x00000001,
21337 0x01000016, 0x0700001e, 0x00100042, 0x00000000, 0x0010002a, 0x00000000, 0x00004001, 0x00000001,
21338 0x01000016, 0x0100003e,
21340 static const DWORD cs_1_group_code
[] =
21343 RWTexture2D
<float> u
;
21347 [numthreads(16, 16, 1)]
21348 void main(uint3 threadID
: SV_GroupThreadID
)
21350 uint2 count
, size
;
21351 u
.GetDimensions(size
.x
, size
.y
);
21352 count
= size
/ (uint2
)16;
21353 for (uint y
= 0; y
< count
.y
; ++y
)
21354 for (uint x
= 0; x
< count
.x
; ++x
)
21355 u
[count
* threadID
.xy
+ uint2(x
, y
)] = value
;
21358 0x43425844, 0x9fb86044, 0x352c196d, 0x92e14094, 0x46bb95a7, 0x00000001, 0x00000218, 0x00000003,
21359 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
21360 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x000001c4, 0x00050050, 0x00000071, 0x0100086a,
21361 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0400189c, 0x0011e000, 0x00000000, 0x00005555,
21362 0x0200005f, 0x00022032, 0x02000068, 0x00000004, 0x0400009b, 0x00000010, 0x00000010, 0x00000001,
21363 0x8900103d, 0x800000c2, 0x00155543, 0x00100032, 0x00000000, 0x00004001, 0x00000000, 0x0011ee46,
21364 0x00000000, 0x0a000055, 0x001000f2, 0x00000000, 0x00100546, 0x00000000, 0x00004002, 0x00000004,
21365 0x00000004, 0x00000004, 0x00000004, 0x05000036, 0x00100012, 0x00000001, 0x00004001, 0x00000000,
21366 0x01000030, 0x07000050, 0x00100022, 0x00000001, 0x0010000a, 0x00000001, 0x0010003a, 0x00000000,
21367 0x03040003, 0x0010001a, 0x00000001, 0x05000036, 0x001000e2, 0x00000002, 0x00100006, 0x00000001,
21368 0x05000036, 0x00100022, 0x00000001, 0x00004001, 0x00000000, 0x01000030, 0x07000050, 0x00100042,
21369 0x00000001, 0x0010001a, 0x00000001, 0x0010000a, 0x00000000, 0x03040003, 0x0010002a, 0x00000001,
21370 0x05000036, 0x00100012, 0x00000002, 0x0010001a, 0x00000001, 0x08000023, 0x001000f2, 0x00000003,
21371 0x00100e46, 0x00000000, 0x00022546, 0x00100e46, 0x00000002, 0x080000a4, 0x0011e0f2, 0x00000000,
21372 0x00100e46, 0x00000003, 0x00208006, 0x00000000, 0x00000000, 0x0700001e, 0x00100022, 0x00000001,
21373 0x0010001a, 0x00000001, 0x00004001, 0x00000001, 0x01000016, 0x0700001e, 0x00100012, 0x00000001,
21374 0x0010000a, 0x00000001, 0x00004001, 0x00000001, 0x01000016, 0x0100003e,
21376 static const DWORD cs_1_store_code
[] =
21379 RWTexture2D
<float> u
;
21383 [numthreads(1, 1, 1)]
21384 void main(uint3 groupID
: SV_GroupID
)
21386 u
[groupID
.xy
] = value
;
21389 0x43425844, 0xc3add41b, 0x67df51b1, 0x2b887930, 0xcb1ee991, 0x00000001, 0x000000b8, 0x00000003,
21390 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
21391 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000064, 0x00050050, 0x00000019, 0x0100086a,
21392 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0400189c, 0x0011e000, 0x00000000, 0x00005555,
21393 0x0200005f, 0x00021032, 0x0400009b, 0x00000001, 0x00000001, 0x00000001, 0x070000a4, 0x0011e0f2,
21394 0x00000000, 0x00021546, 0x00208006, 0x00000000, 0x00000000, 0x0100003e,
21396 static const DWORD cs_dispatch_id_code
[] =
21399 RWTexture2D
<float> u
;
21403 [numthreads(4, 4, 1)]
21404 void main(uint3 id
: SV_DispatchThreadID
)
21409 0x43425844, 0x60166991, 0x4b595266, 0x7fb67d79, 0x485c4f0d, 0x00000001, 0x000000b8, 0x00000003,
21410 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
21411 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000064, 0x00050050, 0x00000019, 0x0100086a,
21412 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0400189c, 0x0011e000, 0x00000000, 0x00005555,
21413 0x0200005f, 0x00020032, 0x0400009b, 0x00000004, 0x00000004, 0x00000001, 0x070000a4, 0x0011e0f2,
21414 0x00000000, 0x00020546, 0x00208006, 0x00000000, 0x00000000, 0x0100003e,
21416 static const DWORD cs_group_index_code
[] =
21419 RWTexture2D
<float> u
;
21423 [numthreads(32, 1, 1)]
21424 void main(uint index
: SV_GroupIndex
)
21427 u
.GetDimensions(size
.x
, size
.y
);
21428 uint count
= size
.x
* size
.y
/ 32;
21430 for (uint i
= 0; i
< count
; ++i
, ++index
)
21431 u
[uint2(index
% size
.x
, index
/ size
.x
)] = value
;
21434 0x43425844, 0xb685a70f, 0x94c2f263, 0x4f1d8eaa, 0xeab65731, 0x00000001, 0x000001f8, 0x00000003,
21435 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
21436 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x000001a4, 0x00050050, 0x00000069, 0x0100086a,
21437 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0400189c, 0x0011e000, 0x00000000, 0x00005555,
21438 0x0200005f, 0x00024000, 0x02000068, 0x00000004, 0x0400009b, 0x00000020, 0x00000001, 0x00000001,
21439 0x8900103d, 0x800000c2, 0x00155543, 0x00100032, 0x00000000, 0x00004001, 0x00000000, 0x0011ee46,
21440 0x00000000, 0x08000026, 0x0000d000, 0x00100022, 0x00000000, 0x0010000a, 0x00000000, 0x0010001a,
21441 0x00000000, 0x07000055, 0x00100022, 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0x00000005,
21442 0x07000026, 0x0000d000, 0x00100042, 0x00000000, 0x0002400a, 0x0010001a, 0x00000000, 0x05000036,
21443 0x00100012, 0x00000001, 0x0010002a, 0x00000000, 0x05000036, 0x00100022, 0x00000001, 0x00004001,
21444 0x00000000, 0x01000030, 0x07000050, 0x00100082, 0x00000000, 0x0010001a, 0x00000001, 0x0010001a,
21445 0x00000000, 0x03040003, 0x0010003a, 0x00000000, 0x0900004e, 0x00100012, 0x00000002, 0x00100012,
21446 0x00000003, 0x0010000a, 0x00000001, 0x0010000a, 0x00000000, 0x05000036, 0x001000e2, 0x00000003,
21447 0x00100006, 0x00000002, 0x080000a4, 0x0011e0f2, 0x00000000, 0x00100e46, 0x00000003, 0x00208006,
21448 0x00000000, 0x00000000, 0x0a00001e, 0x00100032, 0x00000001, 0x00100046, 0x00000001, 0x00004002,
21449 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x01000016, 0x0100003e,
21452 device_desc
.feature_level
= &feature_level
;
21453 device_desc
.flags
= 0;
21454 if (!(device
= create_device(&device_desc
)))
21456 skip("Failed to create device for feature level %#x.\n", feature_level
);
21460 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(input
), &input
.x
);
21462 texture_desc
.Width
= 64;
21463 texture_desc
.Height
= 64;
21464 texture_desc
.MipLevels
= 1;
21465 texture_desc
.ArraySize
= 1;
21466 texture_desc
.Format
= DXGI_FORMAT_R32_FLOAT
;
21467 texture_desc
.SampleDesc
.Count
= 1;
21468 texture_desc
.SampleDesc
.Quality
= 0;
21469 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
21470 texture_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
21471 texture_desc
.CPUAccessFlags
= 0;
21472 texture_desc
.MiscFlags
= 0;
21474 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
21475 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
21477 uav_desc
.Format
= texture_desc
.Format
;
21478 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_TEXTURE2D
;
21479 U(uav_desc
).Texture2D
.MipSlice
= 0;
21481 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)texture
, &uav_desc
, &uav
);
21482 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
21484 ID3D11Device_GetImmediateContext(device
, &context
);
21486 ID3D11DeviceContext_CSSetConstantBuffers(context
, 0, 1, &cb
);
21487 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
21489 ID3D11DeviceContext_ClearUnorderedAccessViewFloat(context
, uav
, zero
);
21490 check_texture_float(texture
, 0.0f
, 2);
21492 hr
= ID3D11Device_CreateComputeShader(device
, cs_1_thread_code
, sizeof(cs_1_thread_code
), NULL
, &cs
);
21493 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
21494 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
21496 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
21497 check_texture_float(texture
, 1.0f
, 2);
21500 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &input
, 0, 0);
21501 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
21502 check_texture_float(texture
, 0.5f
, 2);
21504 ID3D11ComputeShader_Release(cs
);
21507 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &input
, 0, 0);
21508 ID3D11DeviceContext_CSSetShader(context
, NULL
, NULL
, 0);
21509 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
21510 check_texture_float(texture
, 0.5f
, 2);
21512 hr
= ID3D11Device_CreateComputeShader(device
, cs_1_group_code
, sizeof(cs_1_group_code
), NULL
, &cs
);
21513 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
21514 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
21516 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
21517 check_texture_float(texture
, 2.0f
, 2);
21520 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &input
, 0, 0);
21521 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
21522 check_texture_float(texture
, 4.0f
, 2);
21524 ID3D11ComputeShader_Release(cs
);
21526 hr
= ID3D11Device_CreateComputeShader(device
, cs_1_store_code
, sizeof(cs_1_store_code
), NULL
, &cs
);
21527 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
21528 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
21531 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &input
, 0, 0);
21532 ID3D11DeviceContext_Dispatch(context
, texture_desc
.Width
, texture_desc
.Height
, 1);
21533 check_texture_float(texture
, 1.0f
, 2);
21536 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &input
, 0, 0);
21537 ID3D11DeviceContext_Dispatch(context
, 16, 32, 1);
21538 SetRect(&rect
, 0, 0, 16, 32);
21539 check_texture_sub_resource_float(texture
, 0, &rect
, 0.5f
, 2);
21540 SetRect(&rect
, 0, 32, texture_desc
.Width
, texture_desc
.Height
);
21541 check_texture_sub_resource_float(texture
, 0, &rect
, 1.0f
, 2);
21542 SetRect(&rect
, 16, 0, texture_desc
.Width
, texture_desc
.Height
);
21543 check_texture_sub_resource_float(texture
, 0, &rect
, 1.0f
, 2);
21545 ID3D11ComputeShader_Release(cs
);
21547 hr
= ID3D11Device_CreateComputeShader(device
, cs_dispatch_id_code
, sizeof(cs_dispatch_id_code
), NULL
, &cs
);
21548 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
21549 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
21552 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &input
, 0, 0);
21553 ID3D11DeviceContext_Dispatch(context
, 15, 15, 1);
21554 SetRect(&rect
, 0, 0, 60, 60);
21555 check_texture_sub_resource_float(texture
, 0, &rect
, 0.6f
, 2);
21556 SetRect(&rect
, 0, 60, texture_desc
.Width
, texture_desc
.Height
);
21557 check_texture_sub_resource_float(texture
, 0, &rect
, 1.0f
, 2);
21558 SetRect(&rect
, 60, 0, texture_desc
.Width
, texture_desc
.Height
);
21559 check_texture_sub_resource_float(texture
, 0, &rect
, 1.0f
, 2);
21562 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &input
, 0, 0);
21563 ID3D11DeviceContext_Dispatch(context
, 16, 16, 1);
21564 check_texture_float(texture
, 0.7f
, 2);
21566 ID3D11ComputeShader_Release(cs
);
21568 hr
= ID3D11Device_CreateComputeShader(device
, cs_group_index_code
, sizeof(cs_group_index_code
), NULL
, &cs
);
21569 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
21570 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
21573 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &input
, 0, 0);
21574 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
21575 check_texture_float(texture
, 0.3f
, 2);
21578 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &input
, 0, 0);
21579 ID3D11DeviceContext_Dispatch(context
, 2, 2, 2);
21580 check_texture_float(texture
, 0.1f
, 2);
21582 ID3D11ComputeShader_Release(cs
);
21584 ID3D11Buffer_Release(cb
);
21585 ID3D11Texture2D_Release(texture
);
21586 ID3D11UnorderedAccessView_Release(uav
);
21587 ID3D11DeviceContext_Release(context
);
21588 refcount
= ID3D11Device_Release(device
);
21589 ok(!refcount
, "Device has %u references left.\n", refcount
);
21592 static void test_uav_store_immediate_constant(void)
21594 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
21595 struct d3d11_test_context test_context
;
21596 D3D11_TEXTURE2D_DESC texture_desc
;
21597 ID3D11UnorderedAccessView
*uav
;
21598 ID3D11DeviceContext
*context
;
21599 struct resource_readback rb
;
21600 ID3D11Texture2D
*texture
;
21601 ID3D11ComputeShader
*cs
;
21602 unsigned int uint_data
;
21603 ID3D11Device
*device
;
21604 ID3D11Buffer
*buffer
;
21609 static const DWORD cs_store_int_code
[] =
21614 [numthreads(1, 1, 1)]
21620 0x43425844, 0x7246d785, 0x3f4ccbd6, 0x6a7cdbc0, 0xe2b58c72, 0x00000001, 0x000000b8, 0x00000003,
21621 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
21622 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000064, 0x00050050, 0x00000019, 0x0100086a,
21623 0x0400089c, 0x0011e000, 0x00000000, 0x00003333, 0x0400009b, 0x00000001, 0x00000001, 0x00000001,
21624 0x0d0000a4, 0x0011e0f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
21625 0x00004002, 0x0000002a, 0x0000002a, 0x0000002a, 0x0000002a, 0x0100003e,
21627 static const DWORD cs_store_float_code
[] =
21632 [numthreads(1, 1, 1)]
21638 0x43425844, 0x525eea68, 0xc4cd5716, 0xc588f9c4, 0x0da27c5a, 0x00000001, 0x000000b8, 0x00000003,
21639 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
21640 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000064, 0x00050050, 0x00000019, 0x0100086a,
21641 0x0400089c, 0x0011e000, 0x00000000, 0x00005555, 0x0400009b, 0x00000001, 0x00000001, 0x00000001,
21642 0x0d0000a4, 0x0011e0f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
21643 0x00004002, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000, 0x0100003e,
21645 static const DWORD cs_store_unorm_code
[] =
21648 RWTexture2D
<unorm
float> u
;
21650 [numthreads(1, 1, 1)]
21653 u
[uint2(0, 0)] = 0.5f
;
21656 0x43425844, 0x3623f1de, 0xe847109e, 0x8e3da13f, 0xb6787b06, 0x00000001, 0x000000b8, 0x00000003,
21657 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
21658 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000064, 0x00050050, 0x00000019, 0x0100086a,
21659 0x0400189c, 0x0011e000, 0x00000000, 0x00001111, 0x0400009b, 0x00000001, 0x00000001, 0x00000001,
21660 0x0d0000a4, 0x0011e0f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
21661 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, 0x0100003e,
21663 static const DWORD cs_store_snorm_code
[] =
21666 RWTexture2D
<snorm
float> u
;
21668 [numthreads(1, 1, 1)]
21671 u
[uint2(0, 0)] = -0.5f
;
21674 0x43425844, 0xce5397fc, 0x7464bc06, 0xc79aa56c, 0x881bd7ef, 0x00000001, 0x000000b8, 0x00000003,
21675 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
21676 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000064, 0x00050050, 0x00000019, 0x0100086a,
21677 0x0400189c, 0x0011e000, 0x00000000, 0x00002222, 0x0400009b, 0x00000001, 0x00000001, 0x00000001,
21678 0x0d0000a4, 0x0011e0f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
21679 0x00004002, 0xbf000000, 0xbf000000, 0xbf000000, 0xbf000000, 0x0100003e,
21681 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
21682 static const unsigned int zero
[4] = {0};
21684 if (!init_test_context(&test_context
, &feature_level
))
21687 device
= test_context
.device
;
21688 context
= test_context
.immediate_context
;
21690 buffer
= create_buffer(device
, D3D11_BIND_UNORDERED_ACCESS
, 1024, NULL
);
21692 uav_desc
.Format
= DXGI_FORMAT_R32_SINT
;
21693 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
21694 U(uav_desc
).Buffer
.FirstElement
= 0;
21695 U(uav_desc
).Buffer
.NumElements
= 1;
21696 U(uav_desc
).Buffer
.Flags
= 0;
21697 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
21698 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
21699 hr
= ID3D11Device_CreateComputeShader(device
, cs_store_int_code
, sizeof(cs_store_int_code
), NULL
, &cs
);
21700 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
21702 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, zero
);
21703 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
21704 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
21705 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
21706 get_buffer_readback(buffer
, &rb
);
21707 int_data
= get_readback_color(&rb
, 0, 0, 0);
21708 ok(int_data
== 42, "Got unexpected value %u.\n", int_data
);
21709 release_resource_readback(&rb
);
21711 ID3D11ComputeShader_Release(cs
);
21712 ID3D11UnorderedAccessView_Release(uav
);
21713 uav_desc
.Format
= DXGI_FORMAT_R32_FLOAT
;
21714 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
21715 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
21716 hr
= ID3D11Device_CreateComputeShader(device
, cs_store_float_code
, sizeof(cs_store_float_code
), NULL
, &cs
);
21717 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
21719 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, zero
);
21720 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
21721 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
21722 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
21723 get_buffer_readback(buffer
, &rb
);
21724 float_data
= get_readback_float(&rb
, 0, 0);
21725 ok(float_data
== 1.0f
, "Got unexpected value %.8e.\n", float_data
);
21726 release_resource_readback(&rb
);
21728 texture_desc
.Width
= 64;
21729 texture_desc
.Height
= 64;
21730 texture_desc
.MipLevels
= 1;
21731 texture_desc
.ArraySize
= 1;
21732 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
21733 texture_desc
.SampleDesc
.Count
= 1;
21734 texture_desc
.SampleDesc
.Quality
= 0;
21735 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
21736 texture_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
21737 texture_desc
.CPUAccessFlags
= 0;
21738 texture_desc
.MiscFlags
= 0;
21739 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
21740 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
21741 ID3D11UnorderedAccessView_Release(uav
);
21742 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)texture
, NULL
, &uav
);
21743 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
21745 ID3D11ComputeShader_Release(cs
);
21746 hr
= ID3D11Device_CreateComputeShader(device
, cs_store_unorm_code
, sizeof(cs_store_unorm_code
), NULL
, &cs
);
21747 ok(hr
== S_OK
, "Failed to create compute shader, hr %#x.\n", hr
);
21748 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, zero
);
21749 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
21750 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
21751 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
21752 get_texture_readback(texture
, 0, &rb
);
21753 uint_data
= get_readback_color(&rb
, 0, 0, 0);
21754 ok(compare_color(uint_data
, 0x80808080, 1), "Got unexpected color 0x%08x.\n", uint_data
);
21755 release_resource_readback(&rb
);
21757 ID3D11Texture2D_Release(texture
);
21758 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_SNORM
;
21759 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
21760 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
21761 ID3D11UnorderedAccessView_Release(uav
);
21762 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)texture
, NULL
, &uav
);
21763 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
21765 ID3D11ComputeShader_Release(cs
);
21766 hr
= ID3D11Device_CreateComputeShader(device
, cs_store_snorm_code
, sizeof(cs_store_snorm_code
), NULL
, &cs
);
21767 ok(hr
== S_OK
, "Failed to create compute shader, hr %#x.\n", hr
);
21768 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, zero
);
21769 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
21770 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
21771 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
21772 get_texture_readback(texture
, 0, &rb
);
21773 uint_data
= get_readback_color(&rb
, 0, 0, 0);
21774 ok(compare_color(uint_data
, 0xc0c0c0c0, 1), "Got unexpected color 0x%08x.\n", uint_data
);
21775 release_resource_readback(&rb
);
21777 ID3D11Buffer_Release(buffer
);
21778 ID3D11Texture2D_Release(texture
);
21779 ID3D11ComputeShader_Release(cs
);
21780 ID3D11UnorderedAccessView_Release(uav
);
21781 release_test_context(&test_context
);
21784 static void test_ps_cs_uav_binding(void)
21786 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
21787 ID3D11UnorderedAccessView
*cs_uav
, *ps_uav
;
21788 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
21789 ID3D11Texture2D
*cs_texture
, *ps_texture
;
21790 struct d3d11_test_context test_context
;
21791 static const float zero
[4] = {0.0f
};
21792 D3D11_TEXTURE2D_DESC texture_desc
;
21793 ID3D11DeviceContext
*context
;
21794 ID3D11Buffer
*cs_cb
, *ps_cb
;
21795 struct vec4 input
= {1.0f
};
21796 ID3D11ComputeShader
*cs
;
21797 ID3D11PixelShader
*ps
;
21798 ID3D11Device
*device
;
21801 static const DWORD cs_code
[] =
21804 RWTexture2D
<float> u
;
21808 [numthreads(1, 1, 1)]
21811 uint x
, y
, width
, height
;
21812 u
.GetDimensions(width
, height
);
21813 for (y
= 0; y
< height
; ++y
)
21815 for (x
= 0; x
< width
; ++x
)
21816 u
[uint2(x
, y
)] = value
;
21820 0x43425844, 0x6503503a, 0x4cd524e6, 0x2473915d, 0x93cf1201, 0x00000001, 0x000001c8, 0x00000003,
21821 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
21822 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000174, 0x00050050, 0x0000005d, 0x0100086a,
21823 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0400189c, 0x0011e000, 0x00000000, 0x00005555,
21824 0x02000068, 0x00000003, 0x0400009b, 0x00000001, 0x00000001, 0x00000001, 0x8900103d, 0x800000c2,
21825 0x00155543, 0x00100032, 0x00000000, 0x00004001, 0x00000000, 0x0011ee46, 0x00000000, 0x05000036,
21826 0x00100042, 0x00000000, 0x00004001, 0x00000000, 0x01000030, 0x07000050, 0x00100082, 0x00000000,
21827 0x0010002a, 0x00000000, 0x0010001a, 0x00000000, 0x03040003, 0x0010003a, 0x00000000, 0x05000036,
21828 0x001000e2, 0x00000001, 0x00100aa6, 0x00000000, 0x05000036, 0x00100082, 0x00000000, 0x00004001,
21829 0x00000000, 0x01000030, 0x07000050, 0x00100012, 0x00000002, 0x0010003a, 0x00000000, 0x0010000a,
21830 0x00000000, 0x03040003, 0x0010000a, 0x00000002, 0x05000036, 0x00100012, 0x00000001, 0x0010003a,
21831 0x00000000, 0x080000a4, 0x0011e0f2, 0x00000000, 0x00100e46, 0x00000001, 0x00208006, 0x00000000,
21832 0x00000000, 0x0700001e, 0x00100082, 0x00000000, 0x0010003a, 0x00000000, 0x00004001, 0x00000001,
21833 0x01000016, 0x0700001e, 0x00100042, 0x00000000, 0x0010002a, 0x00000000, 0x00004001, 0x00000001,
21834 0x01000016, 0x0100003e,
21836 static const DWORD ps_code
[] =
21839 RWTexture2D
<float> u
: register(u1
);
21845 uint x
, y
, width
, height
;
21846 u
.GetDimensions(width
, height
);
21847 for (y
= 0; y
< height
; ++y
)
21849 for (x
= 0; x
< width
; ++x
)
21850 u
[uint2(x
, y
)] = value
;
21854 0x43425844, 0x2e14423b, 0x62c015c8, 0x5ea5ab9f, 0x514f1e22, 0x00000001, 0x000001b8, 0x00000003,
21855 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
21856 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000164, 0x00000050, 0x00000059, 0x0100086a,
21857 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0400189c, 0x0011e000, 0x00000001, 0x00005555,
21858 0x02000068, 0x00000003, 0x8900103d, 0x800000c2, 0x00155543, 0x00100032, 0x00000000, 0x00004001,
21859 0x00000000, 0x0011ee46, 0x00000001, 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0x00000000,
21860 0x01000030, 0x07000050, 0x00100082, 0x00000000, 0x0010002a, 0x00000000, 0x0010001a, 0x00000000,
21861 0x03040003, 0x0010003a, 0x00000000, 0x05000036, 0x001000e2, 0x00000001, 0x00100aa6, 0x00000000,
21862 0x05000036, 0x00100082, 0x00000000, 0x00004001, 0x00000000, 0x01000030, 0x07000050, 0x00100012,
21863 0x00000002, 0x0010003a, 0x00000000, 0x0010000a, 0x00000000, 0x03040003, 0x0010000a, 0x00000002,
21864 0x05000036, 0x00100012, 0x00000001, 0x0010003a, 0x00000000, 0x080000a4, 0x0011e0f2, 0x00000001,
21865 0x00100e46, 0x00000001, 0x00208006, 0x00000000, 0x00000000, 0x0700001e, 0x00100082, 0x00000000,
21866 0x0010003a, 0x00000000, 0x00004001, 0x00000001, 0x01000016, 0x0700001e, 0x00100042, 0x00000000,
21867 0x0010002a, 0x00000000, 0x00004001, 0x00000001, 0x01000016, 0x0100003e,
21870 if (!init_test_context(&test_context
, &feature_level
))
21873 device
= test_context
.device
;
21874 context
= test_context
.immediate_context
;
21876 ps_cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(input
), &input
.x
);
21877 cs_cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(input
), &input
.x
);
21879 texture_desc
.Width
= 64;
21880 texture_desc
.Height
= 64;
21881 texture_desc
.MipLevels
= 1;
21882 texture_desc
.ArraySize
= 1;
21883 texture_desc
.Format
= DXGI_FORMAT_R32_FLOAT
;
21884 texture_desc
.SampleDesc
.Count
= 1;
21885 texture_desc
.SampleDesc
.Quality
= 0;
21886 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
21887 texture_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
21888 texture_desc
.CPUAccessFlags
= 0;
21889 texture_desc
.MiscFlags
= 0;
21890 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &cs_texture
);
21891 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
21892 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &ps_texture
);
21893 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
21895 uav_desc
.Format
= texture_desc
.Format
;
21896 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_TEXTURE2D
;
21897 U(uav_desc
).Texture2D
.MipSlice
= 0;
21898 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)cs_texture
, &uav_desc
, &cs_uav
);
21899 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
21900 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)ps_texture
, &uav_desc
, &ps_uav
);
21901 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
21903 ID3D11Device_GetImmediateContext(device
, &context
);
21905 ID3D11DeviceContext_CSSetConstantBuffers(context
, 0, 1, &cs_cb
);
21906 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &cs_uav
, NULL
);
21907 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &ps_cb
);
21908 ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context
,
21909 0, NULL
, NULL
, 1, 1, &ps_uav
, NULL
);
21911 ID3D11DeviceContext_ClearUnorderedAccessViewFloat(context
, cs_uav
, zero
);
21912 check_texture_float(cs_texture
, 0.0f
, 2);
21913 ID3D11DeviceContext_ClearUnorderedAccessViewFloat(context
, ps_uav
, zero
);
21914 check_texture_float(ps_texture
, 0.0f
, 2);
21916 hr
= ID3D11Device_CreateComputeShader(device
, cs_code
, sizeof(cs_code
), NULL
, &cs
);
21917 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
21918 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
21919 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
21920 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
21921 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
21923 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
21924 check_texture_float(cs_texture
, 1.0f
, 2);
21925 check_texture_float(ps_texture
, 0.0f
, 2);
21926 draw_quad(&test_context
);
21927 check_texture_float(cs_texture
, 1.0f
, 2);
21928 check_texture_float(ps_texture
, 1.0f
, 2);
21931 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cs_cb
, 0, NULL
, &input
, 0, 0);
21932 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
21933 check_texture_float(cs_texture
, 0.5f
, 2);
21934 check_texture_float(ps_texture
, 1.0f
, 2);
21936 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)ps_cb
, 0, NULL
, &input
, 0, 0);
21937 draw_quad(&test_context
);
21938 check_texture_float(cs_texture
, 0.5f
, 2);
21939 check_texture_float(ps_texture
, 2.0f
, 2);
21942 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cs_cb
, 0, NULL
, &input
, 0, 0);
21944 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)ps_cb
, 0, NULL
, &input
, 0, 0);
21945 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
21946 check_texture_float(cs_texture
, 8.0f
, 2);
21947 check_texture_float(ps_texture
, 2.0f
, 2);
21948 draw_quad(&test_context
);
21949 check_texture_float(cs_texture
, 8.0f
, 2);
21950 check_texture_float(ps_texture
, 4.0f
, 2);
21952 ID3D11ComputeShader_Release(cs
);
21953 ID3D11PixelShader_Release(ps
);
21954 ID3D11Buffer_Release(cs_cb
);
21955 ID3D11Buffer_Release(ps_cb
);
21956 ID3D11Texture2D_Release(cs_texture
);
21957 ID3D11Texture2D_Release(ps_texture
);
21958 ID3D11UnorderedAccessView_Release(cs_uav
);
21959 ID3D11UnorderedAccessView_Release(ps_uav
);
21960 ID3D11DeviceContext_Release(context
);
21961 release_test_context(&test_context
);
21964 static void test_atomic_instructions(void)
21966 ID3D11UnorderedAccessView
*in_uav
, *out_uav
;
21967 ID3D11Buffer
*cb
, *in_buffer
, *out_buffer
;
21968 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
21969 struct d3d11_test_context test_context
;
21970 struct resource_readback rb
, out_rb
;
21971 D3D11_BUFFER_DESC buffer_desc
;
21972 ID3D11DeviceContext
*context
;
21973 ID3D11ComputeShader
*cs
;
21974 ID3D11PixelShader
*ps
;
21975 ID3D11Device
*device
;
21979 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
21980 static const unsigned int zero
[4] = {0, 0, 0, 0};
21981 static const DWORD ps_atomics_code
[] =
21984 RWByteAddressBuffer u
;
21991 u
.InterlockedAnd(0 * 4, v
.x
);
21992 u
.InterlockedCompareStore(1 * 4, v
.y
, v
.x
);
21993 u
.InterlockedAdd(2 * 4, v
.x
);
21994 u
.InterlockedOr(3 * 4, v
.x
);
21995 u
.InterlockedMax(4 * 4, i
.x
);
21996 u
.InterlockedMin(5 * 4, i
.x
);
21997 u
.InterlockedMax(6 * 4, v
.x
);
21998 u
.InterlockedMin(7 * 4, v
.x
);
21999 u
.InterlockedXor(8 * 4, v
.x
);
22002 0x43425844, 0x24c6a30c, 0x2ce4437d, 0xdee8a0df, 0xd18cb4bc, 0x00000001, 0x000001ac, 0x00000003,
22003 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22004 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000158, 0x00000050, 0x00000056, 0x0100086a,
22005 0x04000059, 0x00208e46, 0x00000000, 0x00000002, 0x0300009d, 0x0011e000, 0x00000000, 0x080000a9,
22006 0x0011e000, 0x00000000, 0x00004001, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x0b0000ac,
22007 0x0011e000, 0x00000000, 0x00004001, 0x00000004, 0x0020801a, 0x00000000, 0x00000000, 0x0020800a,
22008 0x00000000, 0x00000000, 0x080000ad, 0x0011e000, 0x00000000, 0x00004001, 0x00000008, 0x0020800a,
22009 0x00000000, 0x00000000, 0x080000aa, 0x0011e000, 0x00000000, 0x00004001, 0x0000000c, 0x0020800a,
22010 0x00000000, 0x00000000, 0x080000ae, 0x0011e000, 0x00000000, 0x00004001, 0x00000010, 0x0020800a,
22011 0x00000000, 0x00000001, 0x080000af, 0x0011e000, 0x00000000, 0x00004001, 0x00000014, 0x0020800a,
22012 0x00000000, 0x00000001, 0x080000b0, 0x0011e000, 0x00000000, 0x00004001, 0x00000018, 0x0020800a,
22013 0x00000000, 0x00000000, 0x080000b1, 0x0011e000, 0x00000000, 0x00004001, 0x0000001c, 0x0020800a,
22014 0x00000000, 0x00000000, 0x080000ab, 0x0011e000, 0x00000000, 0x00004001, 0x00000020, 0x0020800a,
22015 0x00000000, 0x00000000, 0x0100003e,
22017 static const DWORD cs_atomics_code
[] =
22020 RWByteAddressBuffer u
;
22021 RWByteAddressBuffer u2
;
22026 [numthreads(1, 1, 1)]
22030 u
.InterlockedAnd(0 * 4, v
.x
, r
);
22031 u2
.Store(0 * 4, r
);
22032 u
.InterlockedCompareExchange(1 * 4, v
.y
, v
.x
, r
);
22033 u2
.Store(1 * 4, r
);
22034 u
.InterlockedAdd(2 * 4, v
.x
, r
);
22035 u2
.Store(2 * 4, r
);
22036 u
.InterlockedOr(3 * 4, v
.x
, r
);
22037 u2
.Store(3 * 4, r
);
22038 u
.InterlockedMax(4 * 4, i
.x
, r
);
22039 u2
.Store(4 * 4, r
);
22040 u
.InterlockedMin(5 * 4, i
.x
, r
);
22041 u2
.Store(5 * 4, r
);
22042 u
.InterlockedMax(6 * 4, v
.x
, r
);
22043 u2
.Store(6 * 4, r
);
22044 u
.InterlockedMin(7 * 4, v
.x
, r
);
22045 u2
.Store(7 * 4, r
);
22046 u
.InterlockedXor(8 * 4, v
.x
, r
);
22047 u2
.Store(8 * 4, r
);
22050 0x43425844, 0x859a96e3, 0x1a35e463, 0x1e89ce58, 0x5cfe430a, 0x00000001, 0x0000026c, 0x00000003,
22051 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22052 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000218, 0x00050050, 0x00000086, 0x0100086a,
22053 0x04000059, 0x00208e46, 0x00000000, 0x00000002, 0x0300009d, 0x0011e000, 0x00000000, 0x0300009d,
22054 0x0011e000, 0x00000001, 0x02000068, 0x00000001, 0x0400009b, 0x00000001, 0x00000001, 0x00000001,
22055 0x0a0000b5, 0x00100012, 0x00000000, 0x0011e000, 0x00000000, 0x00004001, 0x00000000, 0x0020800a,
22056 0x00000000, 0x00000000, 0x0d0000b9, 0x00100022, 0x00000000, 0x0011e000, 0x00000000, 0x00004001,
22057 0x00000004, 0x0020801a, 0x00000000, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x0a0000b4,
22058 0x00100042, 0x00000000, 0x0011e000, 0x00000000, 0x00004001, 0x00000008, 0x0020800a, 0x00000000,
22059 0x00000000, 0x0a0000b6, 0x00100082, 0x00000000, 0x0011e000, 0x00000000, 0x00004001, 0x0000000c,
22060 0x0020800a, 0x00000000, 0x00000000, 0x070000a6, 0x0011e0f2, 0x00000001, 0x00004001, 0x00000000,
22061 0x00100e46, 0x00000000, 0x0a0000ba, 0x00100012, 0x00000000, 0x0011e000, 0x00000000, 0x00004001,
22062 0x00000010, 0x0020800a, 0x00000000, 0x00000001, 0x0a0000bb, 0x00100022, 0x00000000, 0x0011e000,
22063 0x00000000, 0x00004001, 0x00000014, 0x0020800a, 0x00000000, 0x00000001, 0x0a0000bc, 0x00100042,
22064 0x00000000, 0x0011e000, 0x00000000, 0x00004001, 0x00000018, 0x0020800a, 0x00000000, 0x00000000,
22065 0x0a0000bd, 0x00100082, 0x00000000, 0x0011e000, 0x00000000, 0x00004001, 0x0000001c, 0x0020800a,
22066 0x00000000, 0x00000000, 0x070000a6, 0x0011e0f2, 0x00000001, 0x00004001, 0x00000010, 0x00100e46,
22067 0x00000000, 0x0a0000b7, 0x00100012, 0x00000000, 0x0011e000, 0x00000000, 0x00004001, 0x00000020,
22068 0x0020800a, 0x00000000, 0x00000000, 0x070000a6, 0x0011e012, 0x00000001, 0x00004001, 0x00000020,
22069 0x0010000a, 0x00000000, 0x0100003e,
22072 static const char * const instructions
[] =
22074 "atomic_and", "atomic_cmp_store", "atomic_iadd", "atomic_or",
22075 "atomic_imax", "atomic_imin", "atomic_umax", "atomic_umin", "atomic_xor",
22077 static const char * const imm_instructions
[] =
22079 "imm_atomic_and", "imm_atomic_cmp_exch", "imm_atomic_iadd", "imm_atomic_or",
22080 "imm_atomic_imax", "imm_atomic_imin", "imm_atomic_umax", "imm_atomic_umin", "imm_atomic_xor",
22082 static const struct test
22086 unsigned int input
[ARRAY_SIZE(instructions
)];
22087 unsigned int expected_result
[ARRAY_SIZE(instructions
)];
22091 {{1, 0}, {-1}, {0xffff, 0, 1, 0, 0, 0, 0, 0, 0xff}, { 1, 1, 2, 1, 0, ~0u, 1, 0, 0xfe}},
22092 {{~0u, ~0u}, { 0}, {0xffff, 0xf, 1, 0, 0, 0, 0, 9, ~0u}, {0xffff, 0xf, 0, ~0u, 0, 0, ~0u, 9, 0}},
22095 if (!init_test_context(&test_context
, &feature_level
))
22098 device
= test_context
.device
;
22099 context
= test_context
.immediate_context
;
22101 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, 2 * sizeof(struct uvec4
), NULL
);
22102 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
22103 ID3D11DeviceContext_CSSetConstantBuffers(context
, 0, 1, &cb
);
22105 buffer_desc
.ByteWidth
= sizeof(tests
->input
);
22106 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
22107 buffer_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
22108 buffer_desc
.CPUAccessFlags
= 0;
22109 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
;
22110 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &in_buffer
);
22111 ok(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
22112 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &out_buffer
);
22113 ok(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
22115 uav_desc
.Format
= DXGI_FORMAT_R32_TYPELESS
;
22116 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
22117 U(uav_desc
).Buffer
.FirstElement
= 0;
22118 U(uav_desc
).Buffer
.NumElements
= buffer_desc
.ByteWidth
/ sizeof(*tests
->input
);
22119 U(uav_desc
).Buffer
.Flags
= D3D11_BUFFER_UAV_FLAG_RAW
;
22120 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)in_buffer
, &uav_desc
, &in_uav
);
22121 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
22122 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)out_buffer
, &uav_desc
, &out_uav
);
22123 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
22125 set_viewport(context
, 0.0f
, 0.0f
, 1.0f
, 1.0f
, 0.0f
, 1.0f
);
22127 hr
= ID3D11Device_CreatePixelShader(device
, ps_atomics_code
, sizeof(ps_atomics_code
), NULL
, &ps
);
22128 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
22129 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
22131 hr
= ID3D11Device_CreateComputeShader(device
, cs_atomics_code
, sizeof(cs_atomics_code
), NULL
, &cs
);
22132 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
22133 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
22135 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
22137 const struct test
*test
= &tests
[i
];
22139 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
22140 NULL
, &test
->v
, 0, 0);
22142 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)in_buffer
, 0,
22143 NULL
, test
->input
, 0, 0);
22145 ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context
, 0, NULL
, NULL
,
22146 0, 1, &in_uav
, NULL
);
22148 draw_quad(&test_context
);
22149 get_buffer_readback(in_buffer
, &rb
);
22150 for (j
= 0; j
< ARRAY_SIZE(instructions
); ++j
)
22152 unsigned int value
= get_readback_color(&rb
, j
, 0, 0);
22153 unsigned int expected
= test
->expected_result
[j
];
22155 todo_wine_if(expected
!= test
->input
[j
]
22156 && (!strcmp(instructions
[j
], "atomic_imax")
22157 || !strcmp(instructions
[j
], "atomic_imin")))
22158 ok(value
== expected
, "Test %u: Got %#x (%d), expected %#x (%d) for '%s' "
22159 "with inputs (%u, %u), (%d), %#x (%d).\n",
22160 i
, value
, value
, expected
, expected
, instructions
[j
],
22161 test
->v
.x
, test
->v
.y
, test
->i
.x
, test
->input
[j
], test
->input
[j
]);
22163 release_resource_readback(&rb
);
22165 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)in_buffer
, 0,
22166 NULL
, test
->input
, 0, 0);
22167 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, out_uav
, zero
);
22169 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &in_uav
, NULL
);
22170 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 1, 1, &out_uav
, NULL
);
22172 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
22173 get_buffer_readback(in_buffer
, &rb
);
22174 get_buffer_readback(out_buffer
, &out_rb
);
22175 for (j
= 0; j
< ARRAY_SIZE(instructions
); ++j
)
22177 BOOL todo_instruction
= !strcmp(imm_instructions
[j
], "imm_atomic_imax")
22178 || !strcmp(imm_instructions
[j
], "imm_atomic_imin");
22179 unsigned int out_value
= get_readback_color(&out_rb
, j
, 0, 0);
22180 unsigned int value
= get_readback_color(&rb
, j
, 0, 0);
22181 unsigned int expected
= test
->expected_result
[j
];
22183 todo_wine_if(expected
!= test
->input
[j
] && todo_instruction
)
22184 ok(value
== expected
, "Test %u: Got %#x (%d), expected %#x (%d) for '%s' "
22185 "with inputs (%u, %u), (%d), %#x (%d).\n",
22186 i
, value
, value
, expected
, expected
, imm_instructions
[j
],
22187 test
->v
.x
, test
->v
.y
, test
->i
.x
, test
->input
[j
], test
->input
[j
]);
22189 todo_wine_if(todo_instruction
&& out_value
!= test
->input
[j
])
22190 ok(out_value
== test
->input
[j
], "Got original value %u, expected %u for '%s'.\n",
22191 out_value
, test
->input
[j
], imm_instructions
[j
]);
22193 release_resource_readback(&out_rb
);
22194 release_resource_readback(&rb
);
22197 ID3D11Buffer_Release(cb
);
22198 ID3D11Buffer_Release(in_buffer
);
22199 ID3D11Buffer_Release(out_buffer
);
22200 ID3D11ComputeShader_Release(cs
);
22201 ID3D11PixelShader_Release(ps
);
22202 ID3D11UnorderedAccessView_Release(in_uav
);
22203 ID3D11UnorderedAccessView_Release(out_uav
);
22204 release_test_context(&test_context
);
22207 static void test_sm4_ret_instruction(void)
22209 struct d3d11_test_context test_context
;
22210 ID3D11DeviceContext
*context
;
22211 ID3D11PixelShader
*ps
;
22212 struct uvec4 constant
;
22213 ID3D11Device
*device
;
22217 static const DWORD ps_code
[] =
22222 float4
main() : SV_TARGET
22225 return float4(1, 0, 0, 1);
22227 return float4(0, 1, 0, 1);
22229 return float4(0, 0, 1, 1);
22230 return float4(1, 1, 1, 1);
22233 0x43425844, 0x9ee6f808, 0xe74009f3, 0xbb1adaf2, 0x432e97b5, 0x00000001, 0x000001c4, 0x00000003,
22234 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22235 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
22236 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x0000014c, 0x00000040, 0x00000053,
22237 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
22238 0x00000001, 0x08000020, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x00004001,
22239 0x00000001, 0x0304001f, 0x0010000a, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002,
22240 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000015, 0x08000020, 0x00100012,
22241 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x00004001, 0x00000002, 0x0304001f, 0x0010000a,
22242 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x00000000,
22243 0x3f800000, 0x0100003e, 0x01000015, 0x08000020, 0x00100012, 0x00000000, 0x0020800a, 0x00000000,
22244 0x00000000, 0x00004001, 0x00000003, 0x0304001f, 0x0010000a, 0x00000000, 0x08000036, 0x001020f2,
22245 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x3f800000, 0x3f800000, 0x0100003e, 0x01000015,
22246 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000,
22250 if (!init_test_context(&test_context
, NULL
))
22253 device
= test_context
.device
;
22254 context
= test_context
.immediate_context
;
22256 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
22257 ok(SUCCEEDED(hr
), "Failed to create shader, hr %#x.\n", hr
);
22258 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
22259 memset(&constant
, 0, sizeof(constant
));
22260 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(constant
), &constant
);
22261 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
22263 draw_quad(&test_context
);
22264 check_texture_color(test_context
.backbuffer
, 0xffffffff, 0);
22267 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
22268 draw_quad(&test_context
);
22269 check_texture_color(test_context
.backbuffer
, 0xff0000ff, 0);
22272 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
22273 draw_quad(&test_context
);
22274 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
22277 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
22278 draw_quad(&test_context
);
22279 check_texture_color(test_context
.backbuffer
, 0xffff0000, 0);
22282 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
22283 draw_quad(&test_context
);
22284 check_texture_color(test_context
.backbuffer
, 0xffffffff, 0);
22286 ID3D11Buffer_Release(cb
);
22287 ID3D11PixelShader_Release(ps
);
22288 release_test_context(&test_context
);
22291 static void test_primitive_restart(void)
22293 struct d3d11_test_context test_context
;
22294 ID3D11Buffer
*ib32
, *ib16
, *vb
;
22295 ID3D11DeviceContext
*context
;
22296 unsigned int stride
, offset
;
22297 ID3D11InputLayout
*layout
;
22298 ID3D11VertexShader
*vs
;
22299 ID3D11PixelShader
*ps
;
22300 ID3D11Device
*device
;
22305 static const DWORD ps_code
[] =
22310 float4 position
: SV_Position
;
22311 float4 color
: color
;
22314 float4
main(vs_out input
) : SV_TARGET
22316 return input
.color
;
22319 0x43425844, 0x119e48d1, 0x468aecb3, 0x0a405be5, 0x4e203b82, 0x00000001, 0x000000f4, 0x00000003,
22320 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
22321 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
22322 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x7469736f, 0x006e6f69, 0x6f6c6f63, 0xabab0072,
22323 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
22324 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040,
22325 0x0000000e, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
22326 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
22328 static const DWORD vs_code
[] =
22333 float4 position
: SV_Position
;
22334 float4 color
: color
;
22337 void main(float4 position
: POSITION
, uint vertex_id
: SV_VertexID
, out vs_out output
)
22339 output
.position
= position
;
22340 output
.color
= vertex_id
< 4 ? float4(0.0, 1.0, 1.0, 1.0) : float4(1.0, 0.0, 0.0, 1.0);
22343 0x43425844, 0x2fa57573, 0xdb71c15f, 0x2641b028, 0xa8f87ccc, 0x00000001, 0x00000198, 0x00000003,
22344 0x0000002c, 0x00000084, 0x000000d8, 0x4e475349, 0x00000050, 0x00000002, 0x00000008, 0x00000038,
22345 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000006,
22346 0x00000001, 0x00000001, 0x00000101, 0x49534f50, 0x4e4f4954, 0x5f565300, 0x74726556, 0x44497865,
22347 0xababab00, 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001,
22348 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001,
22349 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69, 0x6f6c6f63, 0xabab0072, 0x52444853, 0x000000b8,
22350 0x00010040, 0x0000002e, 0x0300005f, 0x001010f2, 0x00000000, 0x04000060, 0x00101012, 0x00000001,
22351 0x00000006, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001,
22352 0x02000068, 0x00000001, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0700004f,
22353 0x00100012, 0x00000000, 0x0010100a, 0x00000001, 0x00004001, 0x00000004, 0x0f000037, 0x001020f2,
22354 0x00000001, 0x00100006, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x3f800000, 0x3f800000,
22355 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e,
22357 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
22359 {"position", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
22361 static const struct vec2 vertices
[] =
22372 static const float black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
22373 static const unsigned short indices16
[] =
22375 0, 1, 2, 3, 0xffff, 4, 5, 6, 7
22377 static const unsigned int indices32
[] =
22379 0, 1, 2, 3, 0xffffffff, 4, 5, 6, 7
22382 if (!init_test_context(&test_context
, NULL
))
22385 device
= test_context
.device
;
22386 context
= test_context
.immediate_context
;
22388 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
22389 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
22390 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
22391 ok(SUCCEEDED(hr
), "Failed to create return pixel shader, hr %#x.\n", hr
);
22393 ib16
= create_buffer(device
, D3D11_BIND_INDEX_BUFFER
, sizeof(indices16
), indices16
);
22394 ib32
= create_buffer(device
, D3D11_BIND_INDEX_BUFFER
, sizeof(indices32
), indices32
);
22396 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
22397 vs_code
, sizeof(vs_code
), &layout
);
22398 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
22400 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(vertices
), vertices
);
22402 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
22403 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
22405 ID3D11DeviceContext_IASetInputLayout(context
, layout
);
22406 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
22407 stride
= sizeof(*vertices
);
22409 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, &stride
, &offset
);
22411 for (i
= 0; i
< 2; ++i
)
22414 ID3D11DeviceContext_IASetIndexBuffer(context
, ib32
, DXGI_FORMAT_R32_UINT
, 0);
22416 ID3D11DeviceContext_IASetIndexBuffer(context
, ib16
, DXGI_FORMAT_R16_UINT
, 0);
22418 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, black
);
22419 ID3D11DeviceContext_DrawIndexed(context
, 9, 0, 0);
22420 SetRect(&rect
, 0, 0, 240, 480);
22421 check_texture_sub_resource_color(test_context
.backbuffer
, 0, &rect
, 0xffffff00, 1);
22422 SetRect(&rect
, 240, 0, 400, 480);
22423 check_texture_sub_resource_color(test_context
.backbuffer
, 0, &rect
, 0x00000000, 1);
22424 SetRect(&rect
, 400, 0, 640, 480);
22425 check_texture_sub_resource_color(test_context
.backbuffer
, 0, &rect
, 0xff0000ff, 1);
22428 ID3D11Buffer_Release(ib16
);
22429 ID3D11Buffer_Release(ib32
);
22430 ID3D11Buffer_Release(vb
);
22431 ID3D11InputLayout_Release(layout
);
22432 ID3D11PixelShader_Release(ps
);
22433 ID3D11VertexShader_Release(vs
);
22434 release_test_context(&test_context
);
22437 static void test_resinfo_instruction(void)
22445 struct d3d11_test_context test_context
;
22446 D3D11_TEXTURE3D_DESC texture3d_desc
;
22447 D3D11_TEXTURE2D_DESC texture_desc
;
22448 const struct shader
*current_ps
;
22449 D3D_FEATURE_LEVEL feature_level
;
22450 ID3D11ShaderResourceView
*srv
;
22451 ID3D11DeviceContext
*context
;
22452 ID3D11Texture2D
*rtv_texture
;
22453 ID3D11RenderTargetView
*rtv
;
22454 ID3D11Resource
*texture
;
22455 struct uvec4 constant
;
22456 ID3D11PixelShader
*ps
;
22457 ID3D11Device
*device
;
22458 unsigned int i
, type
;
22462 static const DWORD ps_2d_code
[] =
22470 float4
main() : SV_TARGET
22474 float width
, height
, miplevels
;
22475 t
.GetDimensions(level
, width
, height
, miplevels
);
22476 return float4(width
, height
, miplevels
, 0);
22480 uint width
, height
, miplevels
;
22481 t
.GetDimensions(level
, width
, height
, miplevels
);
22482 return float4(width
, height
, miplevels
, 0);
22486 0x43425844, 0x9c2db58d, 0x7218d757, 0x23255414, 0xaa86938e, 0x00000001, 0x00000168, 0x00000003,
22487 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22488 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
22489 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000f0, 0x00000040, 0x0000003c,
22490 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
22491 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0400001f, 0x0020800a, 0x00000000,
22492 0x00000000, 0x0800003d, 0x001000f2, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x00107e46,
22493 0x00000000, 0x05000036, 0x00102072, 0x00000000, 0x00100346, 0x00000000, 0x05000036, 0x00102082,
22494 0x00000000, 0x00004001, 0x00000000, 0x0100003e, 0x01000012, 0x0800103d, 0x001000f2, 0x00000000,
22495 0x0020801a, 0x00000000, 0x00000000, 0x00107e46, 0x00000000, 0x05000056, 0x00102072, 0x00000000,
22496 0x00100346, 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x00000000, 0x0100003e,
22497 0x01000015, 0x0100003e,
22499 static const struct shader ps_2d
= {ps_2d_code
, sizeof(ps_2d_code
)};
22500 static const DWORD ps_2d_array_code
[] =
22508 float4
main() : SV_TARGET
22512 float width
, height
, elements
, miplevels
;
22513 t
.GetDimensions(level
, width
, height
, elements
, miplevels
);
22514 return float4(width
, height
, elements
, miplevels
);
22518 uint width
, height
, elements
, miplevels
;
22519 t
.GetDimensions(level
, width
, height
, elements
, miplevels
);
22520 return float4(width
, height
, elements
, miplevels
);
22524 0x43425844, 0x92cd8789, 0x38e359ac, 0xd65ab502, 0xa018a5ae, 0x00000001, 0x0000012c, 0x00000003,
22525 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22526 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
22527 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000b4, 0x00000040, 0x0000002d,
22528 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04004058, 0x00107000, 0x00000000, 0x00005555,
22529 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0400001f, 0x0020800a, 0x00000000,
22530 0x00000000, 0x0800003d, 0x001020f2, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x00107e46,
22531 0x00000000, 0x0100003e, 0x01000012, 0x0800103d, 0x001000f2, 0x00000000, 0x0020801a, 0x00000000,
22532 0x00000000, 0x00107e46, 0x00000000, 0x05000056, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
22533 0x0100003e, 0x01000015, 0x0100003e,
22535 static const struct shader ps_2d_array
= {ps_2d_array_code
, sizeof(ps_2d_array_code
)};
22536 static const DWORD ps_3d_code
[] =
22544 float4
main() : SV_TARGET
22548 float width
, height
, depth
, miplevels
;
22549 t
.GetDimensions(level
, width
, height
, depth
, miplevels
);
22550 return float4(width
, height
, depth
, miplevels
);
22554 uint width
, height
, depth
, miplevels
;
22555 t
.GetDimensions(level
, width
, height
, depth
, miplevels
);
22556 return float4(width
, height
, depth
, miplevels
);
22560 0x43425844, 0xac1f73b9, 0x2bce1322, 0x82c599e6, 0xbff0d681, 0x00000001, 0x0000012c, 0x00000003,
22561 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22562 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
22563 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000b4, 0x00000040, 0x0000002d,
22564 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04002858, 0x00107000, 0x00000000, 0x00005555,
22565 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0400001f, 0x0020800a, 0x00000000,
22566 0x00000000, 0x0800003d, 0x001020f2, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x00107e46,
22567 0x00000000, 0x0100003e, 0x01000012, 0x0800103d, 0x001000f2, 0x00000000, 0x0020801a, 0x00000000,
22568 0x00000000, 0x00107e46, 0x00000000, 0x05000056, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
22569 0x0100003e, 0x01000015, 0x0100003e,
22571 static const struct shader ps_3d
= {ps_3d_code
, sizeof(ps_3d_code
)};
22572 static const DWORD ps_cube_code
[] =
22580 float4
main() : SV_TARGET
22584 float width
, height
, miplevels
;
22585 t
.GetDimensions(level
, width
, height
, miplevels
);
22586 return float4(width
, height
, miplevels
, 0);
22590 uint width
, height
, miplevels
;
22591 t
.GetDimensions(level
, width
, height
, miplevels
);
22592 return float4(width
, height
, miplevels
, 0);
22596 0x43425844, 0x795eb161, 0xb8291400, 0xcc531086, 0x2a8143ce, 0x00000001, 0x00000168, 0x00000003,
22597 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22598 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
22599 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000f0, 0x00000040, 0x0000003c,
22600 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04003058, 0x00107000, 0x00000000, 0x00005555,
22601 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0400001f, 0x0020800a, 0x00000000,
22602 0x00000000, 0x0800003d, 0x001000f2, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x00107e46,
22603 0x00000000, 0x05000036, 0x00102072, 0x00000000, 0x00100346, 0x00000000, 0x05000036, 0x00102082,
22604 0x00000000, 0x00004001, 0x00000000, 0x0100003e, 0x01000012, 0x0800103d, 0x001000f2, 0x00000000,
22605 0x0020801a, 0x00000000, 0x00000000, 0x00107e46, 0x00000000, 0x05000056, 0x00102072, 0x00000000,
22606 0x00100346, 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x00000000, 0x0100003e,
22607 0x01000015, 0x0100003e,
22609 static const struct shader ps_cube
= {ps_cube_code
, sizeof(ps_cube_code
)};
22610 static const DWORD ps_cube_array_code
[] =
22613 TextureCubeArray t
;
22618 float4
main() : SV_TARGET
22622 float width
, height
, elements
, miplevels
;
22623 t
.GetDimensions(level
, width
, height
, elements
, miplevels
);
22624 return float4(width
, height
, miplevels
, 0);
22628 uint width
, height
, elements
, miplevels
;
22629 t
.GetDimensions(level
, width
, height
, elements
, miplevels
);
22630 return float4(width
, height
, miplevels
, 0);
22634 0x43425844, 0x894d136f, 0xa1f5c746, 0xd771ac09, 0x6914e044, 0x00000001, 0x0000016c, 0x00000003,
22635 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22636 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
22637 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000f4, 0x00000041, 0x0000003d,
22638 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04005058, 0x00107000, 0x00000000,
22639 0x00005555, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0400001f, 0x0020800a,
22640 0x00000000, 0x00000000, 0x0800003d, 0x00100072, 0x00000000, 0x0020801a, 0x00000000, 0x00000000,
22641 0x00107b46, 0x00000000, 0x05000036, 0x00102072, 0x00000000, 0x00100246, 0x00000000, 0x05000036,
22642 0x00102082, 0x00000000, 0x00004001, 0x00000000, 0x0100003e, 0x01000012, 0x0800103d, 0x00100072,
22643 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x00107b46, 0x00000000, 0x05000056, 0x00102072,
22644 0x00000000, 0x00100246, 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x00000000,
22645 0x0100003e, 0x01000015, 0x0100003e,
22647 static const struct shader ps_cube_array
= {ps_cube_array_code
, sizeof(ps_cube_array_code
)};
22648 static const struct ps_test
22650 const struct shader
*ps
;
22653 unsigned int width
;
22654 unsigned int height
;
22655 unsigned int depth
;
22656 unsigned int miplevel_count
;
22657 unsigned int array_size
;
22658 unsigned int cube_count
;
22660 unsigned int miplevel
;
22661 struct vec4 expected_result
;
22665 {&ps_2d
, {64, 64, 1, 1, 1, 0}, 0, {64.0f
, 64.0f
, 1.0f
, 0.0f
}},
22666 {&ps_2d
, {32, 16, 1, 3, 1, 0}, 0, {32.0f
, 16.0f
, 3.0f
, 0.0f
}},
22667 {&ps_2d
, {32, 16, 1, 3, 1, 0}, 1, {16.0f
, 8.0f
, 3.0f
, 0.0f
}},
22668 {&ps_2d
, {32, 16, 1, 3, 1, 0}, 2, { 8.0f
, 4.0f
, 3.0f
, 0.0f
}},
22670 {&ps_2d_array
, {64, 64, 1, 1, 6, 0}, 0, {64.0f
, 64.0f
, 6.0f
, 1.0f
}},
22671 {&ps_2d_array
, {32, 16, 1, 3, 9, 0}, 0, {32.0f
, 16.0f
, 9.0f
, 3.0f
}},
22672 {&ps_2d_array
, {32, 16, 1, 3, 7, 0}, 1, {16.0f
, 8.0f
, 7.0f
, 3.0f
}},
22673 {&ps_2d_array
, {32, 16, 1, 3, 3, 0}, 2, { 8.0f
, 4.0f
, 3.0f
, 3.0f
}},
22675 {&ps_3d
, {64, 64, 2, 1, 1, 0}, 0, {64.0f
, 64.0f
, 2.0f
, 1.0f
}},
22676 {&ps_3d
, {64, 64, 2, 2, 1, 0}, 1, {32.0f
, 32.0f
, 1.0f
, 2.0f
}},
22677 {&ps_3d
, {64, 64, 4, 1, 1, 0}, 0, {64.0f
, 64.0f
, 4.0f
, 1.0f
}},
22678 {&ps_3d
, {64, 64, 4, 2, 1, 0}, 1, {32.0f
, 32.0f
, 2.0f
, 2.0f
}},
22679 {&ps_3d
, { 8, 8, 8, 1, 1, 0}, 0, { 8.0f
, 8.0f
, 8.0f
, 1.0f
}},
22680 {&ps_3d
, { 8, 8, 8, 4, 1, 0}, 0, { 8.0f
, 8.0f
, 8.0f
, 4.0f
}},
22681 {&ps_3d
, { 8, 8, 8, 4, 1, 0}, 1, { 4.0f
, 4.0f
, 4.0f
, 4.0f
}},
22682 {&ps_3d
, { 8, 8, 8, 4, 1, 0}, 2, { 2.0f
, 2.0f
, 2.0f
, 4.0f
}},
22683 {&ps_3d
, { 8, 8, 8, 4, 1, 0}, 3, { 1.0f
, 1.0f
, 1.0f
, 4.0f
}},
22685 {&ps_cube
, { 4, 4, 1, 1, 6, 1}, 0, { 4.0f
, 4.0f
, 1.0f
, 0.0f
}},
22686 {&ps_cube
, {32, 32, 1, 1, 6, 1}, 0, {32.0f
, 32.0f
, 1.0f
, 0.0f
}},
22687 {&ps_cube
, {32, 32, 1, 3, 6, 1}, 0, {32.0f
, 32.0f
, 3.0f
, 0.0f
}},
22688 {&ps_cube
, {32, 32, 1, 3, 6, 1}, 1, {16.0f
, 16.0f
, 3.0f
, 0.0f
}},
22689 {&ps_cube
, {32, 32, 1, 3, 6, 1}, 2, { 8.0f
, 8.0f
, 3.0f
, 0.0f
}},
22691 {&ps_cube_array
, { 4, 4, 1, 1, 12, 2}, 0, { 4.0f
, 4.0f
, 1.0f
, 0.0f
}},
22692 {&ps_cube_array
, {32, 32, 1, 1, 12, 2}, 0, {32.0f
, 32.0f
, 1.0f
, 0.0f
}},
22693 {&ps_cube_array
, {32, 32, 1, 3, 12, 2}, 0, {32.0f
, 32.0f
, 3.0f
, 0.0f
}},
22696 if (!init_test_context(&test_context
, NULL
))
22699 device
= test_context
.device
;
22700 context
= test_context
.immediate_context
;
22701 feature_level
= ID3D11Device_GetFeatureLevel(device
);
22703 texture_desc
.Width
= 64;
22704 texture_desc
.Height
= 64;
22705 texture_desc
.MipLevels
= 1;
22706 texture_desc
.ArraySize
= 1;
22707 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
22708 texture_desc
.SampleDesc
.Count
= 1;
22709 texture_desc
.SampleDesc
.Quality
= 0;
22710 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
22711 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
22712 texture_desc
.CPUAccessFlags
= 0;
22713 texture_desc
.MiscFlags
= 0;
22714 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rtv_texture
);
22715 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
22716 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rtv_texture
, NULL
, &rtv
);
22717 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
22719 memset(&constant
, 0, sizeof(constant
));
22720 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(constant
), &constant
);
22722 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
22723 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
22727 for (i
= 0; i
< ARRAY_SIZE(ps_tests
); ++i
)
22729 const struct ps_test
*test
= &ps_tests
[i
];
22731 if (test
->texture_desc
.cube_count
> 1 && feature_level
< D3D_FEATURE_LEVEL_10_1
)
22733 skip("Test %u: Cube map array textures require feature level 10_1.\n", i
);
22737 if (current_ps
!= test
->ps
)
22740 ID3D11PixelShader_Release(ps
);
22742 current_ps
= test
->ps
;
22744 hr
= ID3D11Device_CreatePixelShader(device
, current_ps
->code
, current_ps
->size
, NULL
, &ps
);
22745 ok(SUCCEEDED(hr
), "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
22746 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
22749 if (test
->texture_desc
.depth
!= 1)
22751 texture3d_desc
.Width
= test
->texture_desc
.width
;
22752 texture3d_desc
.Height
= test
->texture_desc
.height
;
22753 texture3d_desc
.Depth
= test
->texture_desc
.depth
;
22754 texture3d_desc
.MipLevels
= test
->texture_desc
.miplevel_count
;
22755 texture3d_desc
.Format
= DXGI_FORMAT_R8_UNORM
;
22756 texture3d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
22757 texture3d_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
22758 texture3d_desc
.CPUAccessFlags
= 0;
22759 texture3d_desc
.MiscFlags
= 0;
22760 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, (ID3D11Texture3D
**)&texture
);
22761 ok(SUCCEEDED(hr
), "Test %u: Failed to create 3d texture, hr %#x.\n", i
, hr
);
22765 texture_desc
.Width
= test
->texture_desc
.width
;
22766 texture_desc
.Height
= test
->texture_desc
.height
;
22767 texture_desc
.MipLevels
= test
->texture_desc
.miplevel_count
;
22768 texture_desc
.ArraySize
= test
->texture_desc
.array_size
;
22769 texture_desc
.Format
= DXGI_FORMAT_R8_UNORM
;
22770 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
22771 texture_desc
.MiscFlags
= 0;
22772 if (test
->texture_desc
.cube_count
)
22773 texture_desc
.MiscFlags
|= D3D11_RESOURCE_MISC_TEXTURECUBE
;
22774 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, (ID3D11Texture2D
**)&texture
);
22775 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
22778 hr
= ID3D11Device_CreateShaderResourceView(device
, texture
, NULL
, &srv
);
22779 ok(SUCCEEDED(hr
), "Test %u: Failed to create shader resource view, hr %#x.\n", i
, hr
);
22780 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
22782 for (type
= 0; type
< 2; ++type
)
22785 constant
.y
= test
->miplevel
;
22786 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
22788 draw_quad(&test_context
);
22789 check_texture_vec4(rtv_texture
, &test
->expected_result
, 0);
22792 ID3D11Resource_Release(texture
);
22793 ID3D11ShaderResourceView_Release(srv
);
22795 ID3D11PixelShader_Release(ps
);
22797 ID3D11Buffer_Release(cb
);
22798 ID3D11RenderTargetView_Release(rtv
);
22799 ID3D11Texture2D_Release(rtv_texture
);
22800 release_test_context(&test_context
);
22803 static void test_sm5_bufinfo_instruction(void)
22811 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
22812 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
22813 struct d3d11_test_context test_context
;
22814 D3D11_TEXTURE2D_DESC texture_desc
;
22815 const struct shader
*current_ps
;
22816 ID3D11UnorderedAccessView
*uav
;
22817 ID3D11ShaderResourceView
*srv
;
22818 D3D11_BUFFER_DESC buffer_desc
;
22819 ID3D11DeviceContext
*context
;
22820 ID3D11RenderTargetView
*rtv
;
22821 ID3D11Texture2D
*texture
;
22822 ID3D11PixelShader
*ps
;
22823 ID3D11Buffer
*buffer
;
22824 ID3D11Device
*device
;
22828 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
22829 static const DWORD ps_uav_structured_code
[] =
22838 RWStructuredBuffer
<s
> b
;
22840 uint4
main(void) : SV_Target
22842 uint count
, stride
;
22843 b
.GetDimensions(count
, stride
);
22844 return uint4(count
, stride
, 0, 1);
22847 0x43425844, 0xe1900f85, 0x13c1f338, 0xbb19865e, 0x366df28f, 0x00000001, 0x000000fc, 0x00000003,
22848 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22849 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
22850 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000084, 0x00000050, 0x00000021,
22851 0x0100086a, 0x0400009e, 0x0011e000, 0x00000001, 0x00000014, 0x03000065, 0x001020f2, 0x00000000,
22852 0x02000068, 0x00000001, 0x87000079, 0x8000a302, 0x00199983, 0x00100012, 0x00000000, 0x0011ee46,
22853 0x00000001, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x08000036, 0x001020e2,
22854 0x00000000, 0x00004002, 0x00000000, 0x00000014, 0x00000000, 0x00000001, 0x0100003e,
22856 static const struct shader ps_uav_structured
= {ps_uav_structured_code
, sizeof(ps_uav_structured_code
)};
22857 static const DWORD ps_uav_structured32_code
[] =
22866 RWStructuredBuffer
<s
> b
;
22868 uint4
main(void) : SV_Target
22870 uint count
, stride
;
22871 b
.GetDimensions(count
, stride
);
22872 return uint4(count
, stride
, 0, 1);
22875 0x43425844, 0xdd87a805, 0x28090470, 0xe4fa7c4d, 0x57963f52, 0x00000001, 0x000000fc, 0x00000003,
22876 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22877 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
22878 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000084, 0x00000050, 0x00000021,
22879 0x0100086a, 0x0400009e, 0x0011e000, 0x00000001, 0x00000020, 0x03000065, 0x001020f2, 0x00000000,
22880 0x02000068, 0x00000001, 0x87000079, 0x80010302, 0x00199983, 0x00100012, 0x00000000, 0x0011ee46,
22881 0x00000001, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x08000036, 0x001020e2,
22882 0x00000000, 0x00004002, 0x00000000, 0x00000020, 0x00000000, 0x00000001, 0x0100003e,
22884 static const struct shader ps_uav_structured32
= {ps_uav_structured32_code
, sizeof(ps_uav_structured32_code
)};
22885 static const DWORD ps_srv_structured_code
[] =
22888 StructuredBuffer
<bool> b
;
22890 uint4
main(void) : SV_Target
22892 uint count
, stride
;
22893 b
.GetDimensions(count
, stride
);
22894 return uint4(count
, stride
, 0, 1);
22897 0x43425844, 0x313f910c, 0x2f60c646, 0x2d87455c, 0xb9988c2c, 0x00000001, 0x000000fc, 0x00000003,
22898 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22899 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
22900 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000084, 0x00000050, 0x00000021,
22901 0x0100086a, 0x040000a2, 0x00107000, 0x00000000, 0x00000004, 0x03000065, 0x001020f2, 0x00000000,
22902 0x02000068, 0x00000001, 0x87000079, 0x80002302, 0x00199983, 0x00100012, 0x00000000, 0x00107e46,
22903 0x00000000, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x08000036, 0x001020e2,
22904 0x00000000, 0x00004002, 0x00000000, 0x00000004, 0x00000000, 0x00000001, 0x0100003e,
22906 static const struct shader ps_srv_structured
= {ps_srv_structured_code
, sizeof(ps_srv_structured_code
)};
22907 static const DWORD ps_uav_raw_code
[] =
22910 RWByteAddressBuffer b
;
22912 uint4
main(void) : SV_Target
22915 b
.GetDimensions(width
);
22919 0x43425844, 0xb06e9715, 0x99733b00, 0xaa536550, 0x703a01c5, 0x00000001, 0x000000d8, 0x00000003,
22920 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22921 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
22922 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000060, 0x00000050, 0x00000018,
22923 0x0100086a, 0x0300009d, 0x0011e000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
22924 0x00000001, 0x87000079, 0x800002c2, 0x00199983, 0x00100012, 0x00000000, 0x0011ee46, 0x00000001,
22925 0x05000036, 0x001020f2, 0x00000000, 0x00100006, 0x00000000, 0x0100003e,
22927 static const struct shader ps_uav_raw
= {ps_uav_raw_code
, sizeof(ps_uav_raw_code
)};
22928 static const DWORD ps_srv_raw_code
[] =
22931 ByteAddressBuffer b
;
22933 uint4
main(void) : SV_Target
22936 b
.GetDimensions(width
);
22940 0x43425844, 0x934bc27a, 0x3251cc9d, 0xa129bdd3, 0xf7cedcc4, 0x00000001, 0x000000d8, 0x00000003,
22941 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22942 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
22943 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000060, 0x00000050, 0x00000018,
22944 0x0100086a, 0x030000a1, 0x00107000, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
22945 0x00000001, 0x87000079, 0x800002c2, 0x00199983, 0x00100012, 0x00000000, 0x00107e46, 0x00000000,
22946 0x05000036, 0x001020f2, 0x00000000, 0x00100006, 0x00000000, 0x0100003e,
22948 static const struct shader ps_srv_raw
= {ps_srv_raw_code
, sizeof(ps_srv_raw_code
)};
22949 static const DWORD ps_uav_typed_code
[] =
22954 uint4
main(void) : SV_Target
22957 b
.GetDimensions(width
);
22961 0x43425844, 0x96b39f5f, 0x5fef24c7, 0xed404a41, 0x01c9d4fe, 0x00000001, 0x000000dc, 0x00000003,
22962 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22963 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
22964 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000064, 0x00000050, 0x00000019,
22965 0x0100086a, 0x0400089c, 0x0011e000, 0x00000001, 0x00005555, 0x03000065, 0x001020f2, 0x00000000,
22966 0x02000068, 0x00000001, 0x87000079, 0x80000042, 0x00155543, 0x00100012, 0x00000000, 0x0011ee46,
22967 0x00000001, 0x05000036, 0x001020f2, 0x00000000, 0x00100006, 0x00000000, 0x0100003e,
22969 static const struct shader ps_uav_typed
= {ps_uav_typed_code
, sizeof(ps_uav_typed_code
)};
22970 static const DWORD ps_srv_typed_code
[] =
22975 uint4
main(void) : SV_Target
22978 b
.GetDimensions(width
);
22982 0x43425844, 0x6ae6dbb0, 0x6289d227, 0xaf4e708e, 0x111efed1, 0x00000001, 0x000000dc, 0x00000003,
22983 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
22984 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
22985 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000064, 0x00000050, 0x00000019,
22986 0x0100086a, 0x04000858, 0x00107000, 0x00000000, 0x00005555, 0x03000065, 0x001020f2, 0x00000000,
22987 0x02000068, 0x00000001, 0x87000079, 0x80000042, 0x00155543, 0x00100012, 0x00000000, 0x00107e46,
22988 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100006, 0x00000000, 0x0100003e,
22990 static const struct shader ps_srv_typed
= {ps_srv_typed_code
, sizeof(ps_srv_typed_code
)};
22991 static const struct test
22993 const struct shader
*ps
;
22995 unsigned int buffer_size
;
22996 unsigned int buffer_misc_flags
;
22997 unsigned int buffer_structure_byte_stride
;
22998 DXGI_FORMAT view_format
;
22999 unsigned int view_element_idx
;
23000 unsigned int view_element_count
;
23001 struct uvec4 expected_result
;
23005 #define RAW D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
23006 #define STRUCTURED D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
23007 {&ps_uav_raw
, TRUE
, 100, RAW
, 0, DXGI_FORMAT_R32_TYPELESS
, 0, 25, {100, 100, 100, 100}},
23008 {&ps_uav_raw
, TRUE
, 512, RAW
, 0, DXGI_FORMAT_R32_TYPELESS
, 64, 64, {256, 256, 256, 256}},
23009 {&ps_srv_raw
, FALSE
, 100, RAW
, 0, DXGI_FORMAT_R32_TYPELESS
, 0, 25, {100, 100, 100, 100}},
23010 {&ps_srv_raw
, FALSE
, 500, RAW
, 0, DXGI_FORMAT_R32_TYPELESS
, 64, 4, { 16, 16, 16, 16}},
23011 {&ps_uav_structured
, TRUE
, 100, STRUCTURED
, 20, DXGI_FORMAT_UNKNOWN
, 0, 5, { 5, 20, 0, 1}},
23012 {&ps_uav_structured
, TRUE
, 100, STRUCTURED
, 20, DXGI_FORMAT_UNKNOWN
, 0, 2, { 2, 20, 0, 1}},
23013 {&ps_uav_structured32
, TRUE
, 320, STRUCTURED
, 32, DXGI_FORMAT_UNKNOWN
, 8, 2, { 2, 32, 0, 1}},
23014 {&ps_srv_structured
, FALSE
, 100, STRUCTURED
, 4, DXGI_FORMAT_UNKNOWN
, 0, 5, { 5, 4, 0, 1}},
23015 {&ps_srv_structured
, FALSE
, 100, STRUCTURED
, 4, DXGI_FORMAT_UNKNOWN
, 0, 2, { 2, 4, 0, 1}},
23016 {&ps_srv_structured
, FALSE
, 400, STRUCTURED
, 4, DXGI_FORMAT_UNKNOWN
, 64, 2, { 2, 4, 0, 1}},
23017 {&ps_uav_typed
, TRUE
, 200, 0, 0, DXGI_FORMAT_R32_FLOAT
, 0, 50, { 50, 50, 50, 50}},
23018 {&ps_uav_typed
, TRUE
, 400, 0, 0, DXGI_FORMAT_R32_FLOAT
, 64, 1, { 1, 1, 1, 1}},
23019 {&ps_uav_typed
, TRUE
, 100, 0, 0, DXGI_FORMAT_R16_FLOAT
, 0, 50, { 50, 50, 50, 50}},
23020 {&ps_uav_typed
, TRUE
, 400, 0, 0, DXGI_FORMAT_R16_FLOAT
, 128, 1, { 1, 1, 1, 1}},
23021 {&ps_srv_typed
, FALSE
, 200, 0, 0, DXGI_FORMAT_R32_FLOAT
, 0, 50, { 50, 50, 50, 50}},
23022 {&ps_srv_typed
, FALSE
, 400, 0, 0, DXGI_FORMAT_R32_FLOAT
, 64, 1, { 1, 1, 1, 1}},
23023 {&ps_srv_typed
, FALSE
, 100, 0, 0, DXGI_FORMAT_R16_FLOAT
, 0, 50, { 50, 50, 50, 50}},
23024 {&ps_srv_typed
, FALSE
, 400, 0, 0, DXGI_FORMAT_R16_FLOAT
, 128, 2, { 2, 2, 2, 2}},
23029 if (!init_test_context(&test_context
, &feature_level
))
23032 device
= test_context
.device
;
23033 context
= test_context
.immediate_context
;
23035 texture_desc
.Width
= 64;
23036 texture_desc
.Height
= 64;
23037 texture_desc
.MipLevels
= 1;
23038 texture_desc
.ArraySize
= 1;
23039 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_UINT
;
23040 texture_desc
.SampleDesc
.Count
= 1;
23041 texture_desc
.SampleDesc
.Quality
= 0;
23042 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
23043 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
23044 texture_desc
.CPUAccessFlags
= 0;
23045 texture_desc
.MiscFlags
= 0;
23046 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
23047 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
23048 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
23049 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
23053 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
23055 const struct test
*test
= &tests
[i
];
23057 if (current_ps
!= test
->ps
)
23060 ID3D11PixelShader_Release(ps
);
23062 current_ps
= test
->ps
;
23064 hr
= ID3D11Device_CreatePixelShader(device
, current_ps
->code
, current_ps
->size
, NULL
, &ps
);
23065 ok(SUCCEEDED(hr
), "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
23066 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
23069 buffer_desc
.ByteWidth
= test
->buffer_size
;
23070 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
23071 buffer_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
| D3D11_BIND_UNORDERED_ACCESS
;
23072 buffer_desc
.CPUAccessFlags
= 0;
23073 buffer_desc
.MiscFlags
= test
->buffer_misc_flags
;
23074 buffer_desc
.StructureByteStride
= test
->buffer_structure_byte_stride
;
23075 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
23076 ok(SUCCEEDED(hr
), "Test %u: Failed to create buffer, hr %#x.\n", i
, hr
);
23080 uav_desc
.Format
= test
->view_format
;
23081 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
23082 U(uav_desc
).Buffer
.FirstElement
= test
->view_element_idx
;
23083 U(uav_desc
).Buffer
.NumElements
= test
->view_element_count
;
23084 U(uav_desc
).Buffer
.Flags
= 0;
23085 if (buffer_desc
.MiscFlags
& D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
)
23086 U(uav_desc
).Buffer
.Flags
|= D3D11_BUFFER_UAV_FLAG_RAW
;
23087 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
23088 ok(SUCCEEDED(hr
), "Test %u: Failed to create unordered access view, hr %#x.\n", i
, hr
);
23091 ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context
, 1, &rtv
, NULL
,
23096 srv_desc
.Format
= test
->view_format
;
23097 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_BUFFEREX
;
23098 U(srv_desc
).BufferEx
.FirstElement
= test
->view_element_idx
;
23099 U(srv_desc
).BufferEx
.NumElements
= test
->view_element_count
;
23100 U(srv_desc
).BufferEx
.Flags
= 0;
23101 if (buffer_desc
.MiscFlags
& D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
)
23102 U(srv_desc
).BufferEx
.Flags
|= D3D11_BUFFEREX_SRV_FLAG_RAW
;
23103 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)buffer
, &srv_desc
, &srv
);
23104 ok(SUCCEEDED(hr
), "Test %u: Failed to create shader resource view, hr %#x.\n", i
, hr
);
23107 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
23108 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
23111 draw_quad(&test_context
);
23112 check_texture_uvec4(texture
, &test
->expected_result
);
23115 ID3D11ShaderResourceView_Release(srv
);
23117 ID3D11UnorderedAccessView_Release(uav
);
23118 ID3D11Buffer_Release(buffer
);
23120 ID3D11PixelShader_Release(ps
);
23122 ID3D11RenderTargetView_Release(rtv
);
23123 ID3D11Texture2D_Release(texture
);
23124 release_test_context(&test_context
);
23127 static void test_sampleinfo_instruction(void)
23129 ID3D11Texture2D
*float_rt_texture
, *uint_rt_texture
;
23130 ID3D11RenderTargetView
*float_rtv
, *uint_rtv
, *rtv
;
23131 ID3D11PixelShader
*ps_float
, *ps_uint
, *ps_rt
;
23132 ID3D11Texture2D
*texture
, *readback_texture
;
23133 struct d3d11_test_context test_context
;
23134 unsigned int sample_count
, quality
;
23135 D3D11_TEXTURE2D_DESC texture_desc
;
23136 ID3D11RenderTargetView
*rtvs
[2];
23137 ID3D11ShaderResourceView
*srv
;
23138 ID3D11DeviceContext
*context
;
23139 struct uvec4 expected_uint
;
23140 struct vec4 expected_float
;
23141 ID3D11Device
*device
;
23144 static const DWORD ps_uint_code
[] =
23147 Texture2DMS
<float> t
;
23149 uint4
main() : SV_Target1
23151 uint width
, height
, sample_count
;
23152 t
.GetDimensions(width
, height
, sample_count
);
23153 return sample_count
;
23156 0x43425844, 0x4342ad12, 0x19addd8c, 0x5cb87c48, 0xe604a242, 0x00000001, 0x000000d4, 0x00000003,
23157 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
23158 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000001, 0x00000000, 0x00000001, 0x00000001,
23159 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000005c, 0x00000050, 0x00000017,
23160 0x0100086a, 0x04002058, 0x00107000, 0x00000000, 0x00005555, 0x03000065, 0x001020f2, 0x00000001,
23161 0x02000068, 0x00000001, 0x0500086f, 0x00100012, 0x00000000, 0x0010700a, 0x00000000, 0x05000036,
23162 0x001020f2, 0x00000001, 0x00100006, 0x00000000, 0x0100003e,
23164 static const DWORD ps_float_code
[] =
23167 Texture2DMS
<float> t
;
23169 float4
main() : SV_Target
23171 uint width
, height
, sample_count
;
23172 t
.GetDimensions(width
, height
, sample_count
);
23173 return sample_count
;
23176 0x43425844, 0x2b8aea46, 0x34ceda6f, 0xf98d222b, 0x235ebc0b, 0x00000001, 0x000000b8, 0x00000003,
23177 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
23178 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
23179 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000040, 0x00000050, 0x00000010,
23180 0x0100086a, 0x04002058, 0x00107000, 0x00000000, 0x00005555, 0x03000065, 0x001020f2, 0x00000000,
23181 0x0500006f, 0x001020f2, 0x00000000, 0x0010700a, 0x00000000, 0x0100003e,
23183 static const DWORD ps_rt_code
[] =
23186 float4
main() : SV_Target
23188 return GetRenderTargetSampleCount();
23191 0x43425844, 0x74404d37, 0xad6f88e4, 0xb006ea57, 0xf07d9e2a, 0x00000001, 0x000000a4, 0x00000003,
23192 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
23193 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
23194 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000002c, 0x00000050, 0x0000000b,
23195 0x0100086a, 0x03000065, 0x001020f2, 0x00000000, 0x0400006f, 0x001020f2, 0x00000000, 0x0000e00a,
23198 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
23200 if (!init_test_context(&test_context
, &feature_level
))
23203 device
= test_context
.device
;
23204 context
= test_context
.immediate_context
;
23206 texture_desc
.Width
= 64;
23207 texture_desc
.Height
= 64;
23208 texture_desc
.MipLevels
= 1;
23209 texture_desc
.ArraySize
= 1;
23210 texture_desc
.SampleDesc
.Count
= 1;
23211 texture_desc
.SampleDesc
.Quality
= 0;
23212 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
23213 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
23214 texture_desc
.CPUAccessFlags
= 0;
23215 texture_desc
.MiscFlags
= 0;
23217 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
23218 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &float_rt_texture
);
23219 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
23220 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)float_rt_texture
, NULL
, &float_rtv
);
23221 ok(hr
== S_OK
, "Failed to create rendertarget view, hr %#x.\n", hr
);
23222 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_UINT
;
23223 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &uint_rt_texture
);
23224 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
23225 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)uint_rt_texture
, NULL
, &uint_rtv
);
23226 ok(hr
== S_OK
, "Failed to create rendertarget view, hr %#x.\n", hr
);
23228 rtvs
[0] = float_rtv
;
23229 rtvs
[1] = uint_rtv
;
23230 ID3D11DeviceContext_OMSetRenderTargets(context
, ARRAY_SIZE(rtvs
), rtvs
, NULL
);
23232 hr
= ID3D11Device_CreatePixelShader(device
, ps_float_code
, sizeof(ps_float_code
), NULL
, &ps_float
);
23233 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
23234 hr
= ID3D11Device_CreatePixelShader(device
, ps_uint_code
, sizeof(ps_uint_code
), NULL
, &ps_uint
);
23235 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
23237 for (sample_count
= 2; sample_count
<= 8; sample_count
*= 2)
23239 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
23240 texture_desc
.SampleDesc
.Count
= sample_count
;
23241 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
| D3D11_BIND_RENDER_TARGET
;
23243 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, texture_desc
.Format
, sample_count
, &quality
);
23244 ok(hr
== S_OK
, "Failed to check multisample quality levels, hr %#x.\n", hr
);
23247 skip("Sample count %u not supported.\n", sample_count
);
23251 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
23252 ok(hr
== S_OK
, "Failed to create texture, hr %#x, sample count %u.\n", hr
, sample_count
);
23253 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
23254 ok(hr
== S_OK
, "Failed to create shader resource view, hr %#x.\n", hr
);
23255 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
23257 ID3D11DeviceContext_PSSetShader(context
, ps_float
, NULL
, 0);
23258 draw_quad(&test_context
);
23259 ID3D11DeviceContext_PSSetShader(context
, ps_uint
, NULL
, 0);
23260 draw_quad(&test_context
);
23262 expected_float
.x
= expected_float
.y
= expected_float
.z
= expected_float
.w
= sample_count
;
23263 check_texture_vec4(float_rt_texture
, &expected_float
, 0);
23264 expected_uint
.x
= expected_uint
.y
= expected_uint
.z
= expected_uint
.w
= sample_count
;
23265 check_texture_uvec4(uint_rt_texture
, &expected_uint
);
23267 ID3D11Texture2D_Release(texture
);
23268 ID3D11ShaderResourceView_Release(srv
);
23271 hr
= ID3D11Device_CreatePixelShader(device
, ps_rt_code
, sizeof(ps_rt_code
), NULL
, &ps_rt
);
23272 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
23273 for (sample_count
= 1; sample_count
<= 8; sample_count
*= 2)
23275 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
23276 texture_desc
.SampleDesc
.Count
= sample_count
;
23277 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
23279 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, texture_desc
.Format
, sample_count
, &quality
);
23280 ok(hr
== S_OK
, "Failed to check multisample quality levels, hr %#x.\n", hr
);
23283 skip("Sample count %u not supported.\n", sample_count
);
23287 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
23288 ok(hr
== S_OK
, "Failed to create texture, hr %#x, sample count %u.\n", hr
, sample_count
);
23289 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
23290 ok(hr
== S_OK
, "Failed to create render target view, hr %#x.\n", hr
);
23291 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
23293 /* Some drivers (AMD Radeon HD 6310) return stale sample counts if we
23294 * don't rebind the pixel shader between runs with different sample
23296 ID3D11DeviceContext_PSSetShader(context
, NULL
, NULL
, 0);
23297 ID3D11DeviceContext_PSSetShader(context
, ps_rt
, NULL
, 0);
23298 draw_quad(&test_context
);
23300 if (sample_count
!= 1)
23302 texture_desc
.SampleDesc
.Count
= 1;
23303 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &readback_texture
);
23304 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
23305 ID3D11DeviceContext_ResolveSubresource(context
, (ID3D11Resource
*)readback_texture
, 0,
23306 (ID3D11Resource
*)texture
, 0, texture_desc
.Format
);
23310 readback_texture
= texture
;
23311 ID3D11Texture2D_AddRef(readback_texture
);
23314 expected_float
.x
= expected_float
.y
= expected_float
.z
= expected_float
.w
= sample_count
;
23315 check_texture_vec4(readback_texture
, &expected_float
, 0);
23317 ID3D11Texture2D_Release(readback_texture
);
23318 ID3D11Texture2D_Release(texture
);
23319 ID3D11RenderTargetView_Release(rtv
);
23322 ID3D11RenderTargetView_Release(float_rtv
);
23323 ID3D11RenderTargetView_Release(uint_rtv
);
23324 ID3D11Texture2D_Release(float_rt_texture
);
23325 ID3D11Texture2D_Release(uint_rt_texture
);
23326 ID3D11PixelShader_Release(ps_float
);
23327 ID3D11PixelShader_Release(ps_uint
);
23328 ID3D11PixelShader_Release(ps_rt
);
23329 release_test_context(&test_context
);
23332 static void test_render_target_device_mismatch(void)
23334 struct d3d11_test_context test_context
;
23335 struct device_desc device_desc
= {0};
23336 ID3D11DeviceContext
*context
;
23337 ID3D11RenderTargetView
*rtv
;
23338 ID3D11Device
*device
;
23341 if (!init_test_context(&test_context
, NULL
))
23344 device
= create_device(&device_desc
);
23345 ok(!!device
, "Failed to create device.\n");
23347 ID3D11Device_GetImmediateContext(device
, &context
);
23349 rtv
= (ID3D11RenderTargetView
*)0xdeadbeef;
23350 ID3D11DeviceContext_OMGetRenderTargets(context
, 1, &rtv
, NULL
);
23351 ok(!rtv
, "Got unexpected render target view %p.\n", rtv
);
23352 if (!enable_debug_layer
)
23354 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &test_context
.backbuffer_rtv
, NULL
);
23355 ID3D11DeviceContext_OMGetRenderTargets(context
, 1, &rtv
, NULL
);
23356 ok(rtv
== test_context
.backbuffer_rtv
, "Got unexpected render target view %p.\n", rtv
);
23357 ID3D11RenderTargetView_Release(rtv
);
23361 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
23363 ID3D11DeviceContext_Release(context
);
23364 refcount
= ID3D11Device_Release(device
);
23365 ok(!refcount
, "Device has %u references left.\n", refcount
);
23366 release_test_context(&test_context
);
23369 static void test_buffer_srv(void)
23375 BOOL requires_raw_and_structured_buffers
;
23379 unsigned int byte_count
;
23380 unsigned int data_offset
;
23382 unsigned int structure_byte_stride
;
23385 BOOL raw_and_structured_buffers_supported
;
23386 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
23387 struct d3d11_test_context test_context
;
23388 D3D11_SUBRESOURCE_DATA resource_data
;
23389 const struct buffer
*current_buffer
;
23390 const struct shader
*current_shader
;
23391 ID3D11ShaderResourceView
*srv
;
23392 D3D11_BUFFER_DESC buffer_desc
;
23393 ID3D11DeviceContext
*context
;
23394 DWORD color
, expected_color
;
23395 struct resource_readback rb
;
23396 ID3D11Buffer
*cb
, *buffer
;
23397 ID3D11PixelShader
*ps
;
23398 ID3D11Device
*device
;
23399 unsigned int i
, x
, y
;
23400 struct vec4 cb_size
;
23403 static const DWORD ps_float4_code
[] =
23410 float4
main(float4 position
: SV_POSITION
) : SV_Target
23414 p
.x
= position
.x
/ 640.0f
;
23415 p
.y
= position
.y
/ 480.0f
;
23416 coords
= int2(p
.x
* size
.x
, p
.y
* size
.y
);
23417 return b
.Load(coords
.y
* size
.x
+ coords
.x
);
23420 0x43425844, 0xf10ea650, 0x311f5c38, 0x3a888b7f, 0x58230334, 0x00000001, 0x000001a0, 0x00000003,
23421 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
23422 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
23423 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
23424 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000104, 0x00000040,
23425 0x00000041, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04000858, 0x00107000, 0x00000000,
23426 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
23427 0x02000068, 0x00000001, 0x08000038, 0x00100032, 0x00000000, 0x00101516, 0x00000000, 0x00208516,
23428 0x00000000, 0x00000000, 0x0a000038, 0x00100032, 0x00000000, 0x00100046, 0x00000000, 0x00004002,
23429 0x3b088889, 0x3acccccd, 0x00000000, 0x00000000, 0x05000043, 0x00100032, 0x00000000, 0x00100046,
23430 0x00000000, 0x0a000032, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x0020800a, 0x00000000,
23431 0x00000000, 0x0010001a, 0x00000000, 0x0500001b, 0x00100012, 0x00000000, 0x0010000a, 0x00000000,
23432 0x0700002d, 0x001020f2, 0x00000000, 0x00100006, 0x00000000, 0x00107e46, 0x00000000, 0x0100003e,
23434 static const struct shader ps_float4
= {ps_float4_code
, sizeof(ps_float4_code
)};
23435 static const DWORD ps_structured_code
[] =
23438 StructuredBuffer
<float4
> b
;
23442 float4
main(float4 position
: SV_POSITION
) : SV_Target
23446 p
.x
= position
.x
/ 640.0f
;
23447 p
.y
= position
.y
/ 480.0f
;
23448 coords
= int2(p
.x
* size
.x
, p
.y
* size
.y
);
23449 return b
[coords
.y
* size
.x
+ coords
.x
];
23452 0x43425844, 0x246caabb, 0xf1e7d6b9, 0xcbe720dc, 0xcdc23036, 0x00000001, 0x000001c0, 0x00000004,
23453 0x00000030, 0x00000064, 0x00000098, 0x000001b0, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008,
23454 0x00000020, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f,
23455 0x004e4f49, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
23456 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000110,
23457 0x00000040, 0x00000044, 0x0100486a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x040000a2,
23458 0x00107000, 0x00000000, 0x00000010, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065,
23459 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x08000038, 0x00100032, 0x00000000, 0x00101516,
23460 0x00000000, 0x00208516, 0x00000000, 0x00000000, 0x0a000038, 0x00100032, 0x00000000, 0x00100046,
23461 0x00000000, 0x00004002, 0x3b088889, 0x3acccccd, 0x00000000, 0x00000000, 0x05000043, 0x00100032,
23462 0x00000000, 0x00100046, 0x00000000, 0x0a000032, 0x00100012, 0x00000000, 0x0010000a, 0x00000000,
23463 0x0020800a, 0x00000000, 0x00000000, 0x0010001a, 0x00000000, 0x0500001c, 0x00100012, 0x00000000,
23464 0x0010000a, 0x00000000, 0x090000a7, 0x001020f2, 0x00000000, 0x0010000a, 0x00000000, 0x00004001,
23465 0x00000000, 0x00107e46, 0x00000000, 0x0100003e, 0x30494653, 0x00000008, 0x00000002, 0x00000000,
23467 static const struct shader ps_structured
= {ps_structured_code
, sizeof(ps_structured_code
), TRUE
};
23468 static const DWORD rgba16
[] =
23470 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
23471 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
23472 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
23473 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
23475 static const DWORD rgba4
[] =
23477 0xffffffff, 0xff0000ff,
23478 0xff000000, 0xff00ff00,
23480 static const BYTE r4
[] =
23485 static const struct vec4 rgba_float
[] =
23487 {1.0f
, 1.0f
, 1.0f
, 1.0f
}, {1.0f
, 0.0f
, 0.0f
, 1.0f
},
23488 {0.0f
, 0.0f
, 0.0f
, 1.0f
}, {0.0f
, 1.0f
, 0.0f
, 1.0f
},
23490 static const struct buffer rgba16_buffer
= {sizeof(rgba16
), 0, &rgba16
};
23491 static const struct buffer rgba16_offset_buffer
= {256 + sizeof(rgba16
), 256, &rgba16
};
23492 static const struct buffer rgba4_buffer
= {sizeof(rgba4
), 0, &rgba4
};
23493 static const struct buffer r4_buffer
= {sizeof(r4
), 0, &r4
};
23494 static const struct buffer r4_offset_buffer
= {256 + sizeof(r4
), 256, &r4
};
23495 static const struct buffer float_buffer
= {sizeof(rgba_float
), 0, &rgba_float
, sizeof(*rgba_float
)};
23496 static const struct buffer float_offset_buffer
= {256 + sizeof(rgba_float
), 256,
23497 &rgba_float
, sizeof(*rgba_float
)};
23498 static const DWORD rgba16_colors2x2
[] =
23500 0xff0000ff, 0xff0000ff, 0xff00ffff, 0xff00ffff,
23501 0xff0000ff, 0xff0000ff, 0xff00ffff, 0xff00ffff,
23502 0xff00ff00, 0xff00ff00, 0xffffff00, 0xffffff00,
23503 0xff00ff00, 0xff00ff00, 0xffffff00, 0xffffff00,
23505 static const DWORD rgba16_colors1x1
[] =
23507 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff,
23508 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff,
23509 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff,
23510 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff,
23512 static const DWORD rgba4_colors
[] =
23514 0xffffffff, 0xffffffff, 0xff0000ff, 0xff0000ff,
23515 0xffffffff, 0xffffffff, 0xff0000ff, 0xff0000ff,
23516 0xff000000, 0xff000000, 0xff00ff00, 0xff00ff00,
23517 0xff000000, 0xff000000, 0xff00ff00, 0xff00ff00,
23519 static const DWORD r4_colors
[] =
23521 0xff0000de, 0xff0000de, 0xff0000ad, 0xff0000ad,
23522 0xff0000de, 0xff0000de, 0xff0000ad, 0xff0000ad,
23523 0xff0000ba, 0xff0000ba, 0xff0000be, 0xff0000be,
23524 0xff0000ba, 0xff0000ba, 0xff0000be, 0xff0000be,
23526 static const DWORD zero_colors
[16] = {0};
23527 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
23529 static const struct test
23531 const struct shader
*shader
;
23532 const struct buffer
*buffer
;
23533 DXGI_FORMAT srv_format
;
23534 unsigned int srv_first_element
;
23535 unsigned int srv_element_count
;
23537 const DWORD
*expected_colors
;
23541 {&ps_float4
, &rgba16_buffer
, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, 16, {4.0f
, 4.0f
}, rgba16
},
23542 {&ps_float4
, &rgba16_offset_buffer
, DXGI_FORMAT_R8G8B8A8_UNORM
, 64, 16, {4.0f
, 4.0f
}, rgba16
},
23543 {&ps_float4
, &rgba16_buffer
, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, 4, {2.0f
, 2.0f
}, rgba16_colors2x2
},
23544 {&ps_float4
, &rgba16_buffer
, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, 1, {1.0f
, 1.0f
}, rgba16_colors1x1
},
23545 {&ps_float4
, &rgba4_buffer
, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, 4, {2.0f
, 2.0f
}, rgba4_colors
},
23546 {&ps_float4
, &r4_buffer
, DXGI_FORMAT_R8_UNORM
, 0, 4, {2.0f
, 2.0f
}, r4_colors
},
23547 {&ps_float4
, &r4_offset_buffer
, DXGI_FORMAT_R8_UNORM
, 256, 4, {2.0f
, 2.0f
}, r4_colors
},
23548 {&ps_structured
, &float_buffer
, DXGI_FORMAT_UNKNOWN
, 0, 4, {2.0f
, 2.0f
}, rgba4_colors
},
23549 {&ps_structured
, &float_offset_buffer
, DXGI_FORMAT_UNKNOWN
, 16, 4, {2.0f
, 2.0f
}, rgba4_colors
},
23550 {&ps_float4
, NULL
, 0, 0, 0, {2.0f
, 2.0f
}, zero_colors
},
23551 {&ps_float4
, NULL
, 0, 0, 0, {1.0f
, 1.0f
}, zero_colors
},
23554 if (!init_test_context(&test_context
, NULL
))
23557 device
= test_context
.device
;
23558 context
= test_context
.immediate_context
;
23559 raw_and_structured_buffers_supported
= ID3D11Device_GetFeatureLevel(device
) >= D3D_FEATURE_LEVEL_11_0
23560 || check_compute_shaders_via_sm4_support(device
);
23562 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(cb_size
), NULL
);
23563 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
23565 buffer_desc
.ByteWidth
= 256;
23566 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
23567 buffer_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
23568 buffer_desc
.CPUAccessFlags
= 0;
23569 buffer_desc
.MiscFlags
= 0;
23570 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
23571 ok(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
23572 srv_desc
.Format
= DXGI_FORMAT_R8_UNORM
;
23573 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_BUFFER
;
23574 U(srv_desc
).Buffer
.FirstElement
= 0;
23575 U(srv_desc
).Buffer
.NumElements
= 0;
23576 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)buffer
, &srv_desc
, &srv
);
23577 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
23578 ID3D11Buffer_Release(buffer
);
23583 current_shader
= NULL
;
23584 current_buffer
= NULL
;
23585 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
23587 const struct test
*test
= &tests
[i
];
23589 if (test
->shader
->requires_raw_and_structured_buffers
&& !raw_and_structured_buffers_supported
)
23591 skip("Test %u: Raw and structured buffers are not supported.\n", i
);
23594 /* Structured buffer views with an offset don't seem to work on WARP. */
23595 if (test
->srv_format
== DXGI_FORMAT_UNKNOWN
&& test
->srv_first_element
23596 && is_warp_device(device
))
23598 skip("Test %u: Broken WARP.\n", i
);
23602 if (current_shader
!= test
->shader
)
23605 ID3D11PixelShader_Release(ps
);
23607 current_shader
= test
->shader
;
23609 hr
= ID3D11Device_CreatePixelShader(device
, current_shader
->code
, current_shader
->size
, NULL
, &ps
);
23610 ok(SUCCEEDED(hr
), "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
23611 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
23614 if (current_buffer
!= test
->buffer
)
23617 ID3D11Buffer_Release(buffer
);
23619 current_buffer
= test
->buffer
;
23620 if (current_buffer
)
23624 buffer_desc
.ByteWidth
= current_buffer
->byte_count
;
23625 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
23626 buffer_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
23627 buffer_desc
.CPUAccessFlags
= 0;
23628 buffer_desc
.MiscFlags
= 0;
23629 if ((buffer_desc
.StructureByteStride
= current_buffer
->structure_byte_stride
))
23630 buffer_desc
.MiscFlags
|= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
;
23631 resource_data
.SysMemPitch
= 0;
23632 resource_data
.SysMemSlicePitch
= 0;
23633 if (current_buffer
->data_offset
)
23635 data
= heap_alloc_zero(current_buffer
->byte_count
);
23636 ok(!!data
, "Failed to allocate memory.\n");
23637 memcpy(data
+ current_buffer
->data_offset
, current_buffer
->data
,
23638 current_buffer
->byte_count
- current_buffer
->data_offset
);
23639 resource_data
.pSysMem
= data
;
23643 resource_data
.pSysMem
= current_buffer
->data
;
23645 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &resource_data
, &buffer
);
23646 ok(SUCCEEDED(hr
), "Test %u: Failed to create buffer, hr %#x.\n", i
, hr
);
23656 ID3D11ShaderResourceView_Release(srv
);
23657 if (current_buffer
)
23659 srv_desc
.Format
= test
->srv_format
;
23660 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_BUFFER
;
23661 U(srv_desc
).Buffer
.FirstElement
= test
->srv_first_element
;
23662 U(srv_desc
).Buffer
.NumElements
= test
->srv_element_count
;
23663 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)buffer
, &srv_desc
, &srv
);
23664 ok(SUCCEEDED(hr
), "Test %u: Failed to create shader resource view, hr %#x.\n", i
, hr
);
23670 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
23672 cb_size
.x
= test
->size
.x
;
23673 cb_size
.y
= test
->size
.y
;
23674 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &cb_size
, 0, 0);
23676 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
23677 draw_quad(&test_context
);
23679 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
23680 for (y
= 0; y
< 4; ++y
)
23682 for (x
= 0; x
< 4; ++x
)
23684 color
= get_readback_color(&rb
, 80 + x
* 160, 60 + y
* 120, 0);
23685 expected_color
= test
->expected_colors
[y
* 4 + x
];
23686 ok(compare_color(color
, expected_color
, 1),
23687 "Test %u: Got 0x%08x, expected 0x%08x at (%u, %u).\n",
23688 i
, color
, expected_color
, x
, y
);
23691 release_resource_readback(&rb
);
23694 ID3D11ShaderResourceView_Release(srv
);
23696 ID3D11Buffer_Release(buffer
);
23698 ID3D11Buffer_Release(cb
);
23699 ID3D11PixelShader_Release(ps
);
23700 release_test_context(&test_context
);
23703 static void test_unaligned_raw_buffer_access(const D3D_FEATURE_LEVEL feature_level
)
23705 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
23706 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
23707 struct d3d11_test_context test_context
;
23708 D3D11_SUBRESOURCE_DATA resource_data
;
23709 D3D11_TEXTURE2D_DESC texture_desc
;
23710 ID3D11UnorderedAccessView
*uav
;
23711 ID3D11ShaderResourceView
*srv
;
23712 D3D11_BUFFER_DESC buffer_desc
;
23713 ID3D11Buffer
*cb
, *raw_buffer
;
23714 ID3D11DeviceContext
*context
;
23715 struct resource_readback rb
;
23716 ID3D11RenderTargetView
*rtv
;
23717 ID3D11Texture2D
*texture
;
23718 ID3D11ComputeShader
*cs
;
23719 ID3D11PixelShader
*ps
;
23720 ID3D11Device
*device
;
23721 unsigned int i
, data
;
23722 struct uvec4 offset
;
23725 static const unsigned int buffer_data
[] =
23727 0xffffffff, 0x00000000,
23729 static const DWORD ps_code
[] =
23732 ByteAddressBuffer buffer
;
23736 uint
main() : SV_Target0
23738 return buffer
.Load(offset
);
23741 0x43425844, 0xda171175, 0xb001721f, 0x60ef80eb, 0xe1fa7e75, 0x00000001, 0x000000e4, 0x00000004,
23742 0x00000030, 0x00000040, 0x00000074, 0x000000d4, 0x4e475349, 0x00000008, 0x00000000, 0x00000008,
23743 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001,
23744 0x00000000, 0x00000e01, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000058, 0x00000040,
23745 0x00000016, 0x0100486a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x030000a1, 0x00107000,
23746 0x00000000, 0x03000065, 0x00102012, 0x00000000, 0x080000a5, 0x00102012, 0x00000000, 0x0020800a,
23747 0x00000000, 0x00000000, 0x00107006, 0x00000000, 0x0100003e, 0x30494653, 0x00000008, 0x00000002,
23750 static const DWORD cs_code
[] =
23753 RWByteAddressBuffer buffer
;
23757 [numthreads(1, 1, 1)]
23760 buffer
.Store(input
.x
, input
.y
);
23763 0x43425844, 0x3c7103b0, 0xe6313979, 0xbcfb0c11, 0x3958af0c, 0x00000001, 0x000000b4, 0x00000003,
23764 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
23765 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000060, 0x00050050, 0x00000018, 0x0100086a,
23766 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300009d, 0x0011e000, 0x00000000, 0x0400009b,
23767 0x00000001, 0x00000001, 0x00000001, 0x090000a6, 0x0011e012, 0x00000000, 0x0020800a, 0x00000000,
23768 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0100003e,
23770 static const float black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
23772 if (!init_test_context(&test_context
, &feature_level
))
23775 device
= test_context
.device
;
23776 context
= test_context
.immediate_context
;
23778 if (feature_level
< D3D_FEATURE_LEVEL_11_0
&& !check_compute_shaders_via_sm4_support(device
))
23780 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
23781 todo_wine
ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
23783 ID3D11PixelShader_Release(ps
);
23784 skip("Raw buffers are not supported.\n");
23785 release_test_context(&test_context
);
23789 if (is_intel_device(device
))
23791 /* Offsets for raw buffer reads and writes should be 4 bytes aligned.
23792 * This test checks what happens when offsets are not properly aligned.
23793 * The behavior seems to be undefined on Intel hardware. */
23794 win_skip("Skipping the test on Intel hardware.\n");
23795 release_test_context(&test_context
);
23799 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
23800 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
23802 memset(&offset
, 0, sizeof(offset
));
23803 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(offset
), &offset
.x
);
23805 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
23806 texture_desc
.Format
= DXGI_FORMAT_R32_UINT
;
23807 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
23808 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
23809 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
23810 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
23812 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
23814 buffer_desc
.ByteWidth
= sizeof(buffer_data
);
23815 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
23816 buffer_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
23817 buffer_desc
.CPUAccessFlags
= 0;
23818 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
;
23819 resource_data
.pSysMem
= buffer_data
;
23820 resource_data
.SysMemPitch
= 0;
23821 resource_data
.SysMemSlicePitch
= 0;
23822 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &resource_data
, &raw_buffer
);
23823 ok(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
23825 srv_desc
.Format
= DXGI_FORMAT_R32_TYPELESS
;
23826 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_BUFFEREX
;
23827 U(srv_desc
).BufferEx
.FirstElement
= 0;
23828 U(srv_desc
).BufferEx
.NumElements
= buffer_desc
.ByteWidth
/ sizeof(unsigned int);
23829 U(srv_desc
).BufferEx
.Flags
= D3D11_BUFFEREX_SRV_FLAG_RAW
;
23830 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)raw_buffer
, &srv_desc
, &srv
);
23831 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
23833 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
23834 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
23835 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
23838 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
23839 NULL
, &offset
, 0, 0);
23840 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, black
);
23841 draw_quad(&test_context
);
23842 check_texture_color(texture
, buffer_data
[0], 0);
23844 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
23845 NULL
, &offset
, 0, 0);
23846 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, black
);
23847 draw_quad(&test_context
);
23848 check_texture_color(texture
, buffer_data
[0], 0);
23850 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
23851 NULL
, &offset
, 0, 0);
23852 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, black
);
23853 draw_quad(&test_context
);
23854 check_texture_color(texture
, buffer_data
[0], 0);
23856 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
23857 NULL
, &offset
, 0, 0);
23858 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, black
);
23859 draw_quad(&test_context
);
23860 check_texture_color(texture
, buffer_data
[0], 0);
23863 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
23864 NULL
, &offset
, 0, 0);
23865 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, black
);
23866 draw_quad(&test_context
);
23867 check_texture_color(texture
, buffer_data
[1], 0);
23869 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
23870 NULL
, &offset
, 0, 0);
23871 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, black
);
23872 draw_quad(&test_context
);
23873 check_texture_color(texture
, buffer_data
[1], 0);
23875 if (feature_level
< D3D_FEATURE_LEVEL_11_0
)
23877 skip("Feature level 11_0 required for unaligned UAV test.\n");
23881 ID3D11Buffer_Release(raw_buffer
);
23882 buffer_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
23883 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &raw_buffer
);
23884 ok(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
23886 uav_desc
.Format
= DXGI_FORMAT_R32_TYPELESS
;
23887 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
23888 U(uav_desc
).Buffer
.FirstElement
= 0;
23889 U(uav_desc
).Buffer
.NumElements
= buffer_desc
.ByteWidth
/ sizeof(unsigned int);
23890 U(uav_desc
).Buffer
.Flags
= D3D11_BUFFER_UAV_FLAG_RAW
;
23891 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)raw_buffer
, &uav_desc
, &uav
);
23892 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
23894 hr
= ID3D11Device_CreateComputeShader(device
, cs_code
, sizeof(cs_code
), NULL
, &cs
);
23895 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
23897 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
23898 ID3D11DeviceContext_CSSetConstantBuffers(context
, 0, 1, &cb
);
23899 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
23902 offset
.y
= 0xffffffff;
23903 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
23904 NULL
, &offset
, 0, 0);
23905 ID3D11DeviceContext_ClearUnorderedAccessViewFloat(context
, uav
, black
);
23906 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
23907 get_buffer_readback(raw_buffer
, &rb
);
23908 for (i
= 0; i
< ARRAY_SIZE(buffer_data
); ++i
)
23910 data
= get_readback_color(&rb
, i
, 0, 0);
23911 ok(data
== buffer_data
[i
], "Got unexpected result %#x at %u.\n", data
, i
);
23913 release_resource_readback(&rb
);
23916 offset
.y
= 0xffffffff;
23917 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
23918 NULL
, &offset
, 0, 0);
23919 ID3D11DeviceContext_ClearUnorderedAccessViewFloat(context
, uav
, black
);
23920 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
23921 get_buffer_readback(raw_buffer
, &rb
);
23922 for (i
= 0; i
< ARRAY_SIZE(buffer_data
); ++i
)
23924 data
= get_readback_color(&rb
, i
, 0, 0);
23925 ok(data
== buffer_data
[i
], "Got unexpected result %#x at %u.\n", data
, i
);
23927 release_resource_readback(&rb
);
23930 offset
.y
= 0xffffffff;
23931 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
23932 NULL
, &offset
, 0, 0);
23933 ID3D11DeviceContext_ClearUnorderedAccessViewFloat(context
, uav
, black
);
23934 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
23935 get_buffer_readback(raw_buffer
, &rb
);
23936 for (i
= 0; i
< ARRAY_SIZE(buffer_data
); ++i
)
23938 data
= get_readback_color(&rb
, i
, 0, 0);
23939 ok(data
== buffer_data
[i
], "Got unexpected result %#x at %u.\n", data
, i
);
23941 release_resource_readback(&rb
);
23944 offset
.y
= 0xffffffff;
23945 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
23946 NULL
, &offset
, 0, 0);
23947 ID3D11DeviceContext_ClearUnorderedAccessViewFloat(context
, uav
, black
);
23948 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
23949 get_buffer_readback(raw_buffer
, &rb
);
23950 for (i
= 0; i
< ARRAY_SIZE(buffer_data
); ++i
)
23952 data
= get_readback_color(&rb
, i
, 0, 0);
23953 ok(data
== buffer_data
[i
], "Got unexpected result %#x at %u.\n", data
, i
);
23955 release_resource_readback(&rb
);
23957 ID3D11DeviceContext_ClearUnorderedAccessViewFloat(context
, uav
, black
);
23960 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
23961 NULL
, &offset
, 0, 0);
23962 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
23965 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
23966 NULL
, &offset
, 0, 0);
23967 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
23968 get_buffer_readback(raw_buffer
, &rb
);
23969 data
= get_readback_color(&rb
, 0, 0, 0);
23970 ok(data
== 0xffff, "Got unexpected result %#x.\n", data
);
23971 data
= get_readback_color(&rb
, 1, 0, 0);
23972 ok(data
== 0xa, "Got unexpected result %#x.\n", data
);
23973 release_resource_readback(&rb
);
23975 ID3D11ComputeShader_Release(cs
);
23976 ID3D11UnorderedAccessView_Release(uav
);
23979 ID3D11Buffer_Release(cb
);
23980 ID3D11Buffer_Release(raw_buffer
);
23981 ID3D11PixelShader_Release(ps
);
23982 ID3D11RenderTargetView_Release(rtv
);
23983 ID3D11ShaderResourceView_Release(srv
);
23984 ID3D11Texture2D_Release(texture
);
23985 release_test_context(&test_context
);
23988 static unsigned int read_uav_counter(ID3D11DeviceContext
*context
,
23989 ID3D11Buffer
*staging_buffer
, ID3D11UnorderedAccessView
*uav
)
23991 D3D11_MAPPED_SUBRESOURCE map_desc
;
23992 unsigned int counter
;
23994 ID3D11DeviceContext_CopyStructureCount(context
, staging_buffer
, 0, uav
);
23996 if (FAILED(ID3D11DeviceContext_Map(context
, (ID3D11Resource
*)staging_buffer
, 0,
23997 D3D11_MAP_READ
, 0, &map_desc
)))
23999 counter
= *(unsigned int *)map_desc
.pData
;
24000 ID3D11DeviceContext_Unmap(context
, (ID3D11Resource
*)staging_buffer
, 0);
24004 static int compare_id(const void *a
, const void *b
)
24006 return *(int *)a
- *(int *)b
;
24009 static void test_uav_counters(void)
24011 ID3D11Buffer
*buffer
, *buffer2
, *staging_buffer
;
24012 ID3D11ComputeShader
*cs_producer
, *cs_consumer
;
24013 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
24014 struct d3d11_test_context test_context
;
24015 ID3D11UnorderedAccessView
*uav
, *uav2
;
24016 unsigned int data
, id
[128], i
;
24017 D3D11_BUFFER_DESC buffer_desc
;
24018 ID3D11DeviceContext
*context
;
24019 struct resource_readback rb
;
24020 ID3D11Device
*device
;
24024 static const DWORD cs_producer_code
[] =
24027 RWStructuredBuffer
<uint
> u
;
24029 [numthreads(4, 1, 1)]
24030 void main(uint3 dispatch_id
: SV_DispatchThreadID
)
24032 uint counter
= u
.IncrementCounter();
24033 u
[counter
] = dispatch_id
.x
;
24036 0x43425844, 0x013163a8, 0xe7d371b8, 0x4f71e39a, 0xd479e584, 0x00000001, 0x000000c8, 0x00000003,
24037 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
24038 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000074, 0x00050050, 0x0000001d, 0x0100086a,
24039 0x0480009e, 0x0011e000, 0x00000000, 0x00000004, 0x0200005f, 0x00020012, 0x02000068, 0x00000001,
24040 0x0400009b, 0x00000004, 0x00000001, 0x00000001, 0x050000b2, 0x00100012, 0x00000000, 0x0011e000,
24041 0x00000000, 0x080000a8, 0x0011e012, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000000,
24042 0x0002000a, 0x0100003e,
24044 static const DWORD cs_consumer_code
[] =
24047 RWStructuredBuffer
<uint
> u
;
24048 RWStructuredBuffer
<uint
> u2
;
24050 [numthreads(4, 1, 1)]
24053 uint counter
= u
.DecrementCounter();
24054 u2
[counter
] = u
[counter
];
24057 0x43425844, 0x957ef3dd, 0x9f317559, 0x09c8f12d, 0xdbfd98c8, 0x00000001, 0x00000100, 0x00000003,
24058 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
24059 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x000000ac, 0x00050050, 0x0000002b, 0x0100086a,
24060 0x0480009e, 0x0011e000, 0x00000000, 0x00000004, 0x0400009e, 0x0011e000, 0x00000001, 0x00000004,
24061 0x02000068, 0x00000001, 0x0400009b, 0x00000004, 0x00000001, 0x00000001, 0x050000b3, 0x00100012,
24062 0x00000000, 0x0011e000, 0x00000000, 0x8b0000a7, 0x80002302, 0x00199983, 0x00100022, 0x00000000,
24063 0x0010000a, 0x00000000, 0x00004001, 0x00000000, 0x0011e006, 0x00000000, 0x090000a8, 0x0011e012,
24064 0x00000001, 0x0010000a, 0x00000000, 0x00004001, 0x00000000, 0x0010001a, 0x00000000, 0x0100003e,
24066 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
24068 if (!init_test_context(&test_context
, &feature_level
))
24071 device
= test_context
.device
;
24072 context
= test_context
.immediate_context
;
24074 hr
= ID3D11Device_CreateComputeShader(device
, cs_producer_code
, sizeof(cs_producer_code
), NULL
, &cs_producer
);
24075 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
24076 hr
= ID3D11Device_CreateComputeShader(device
, cs_consumer_code
, sizeof(cs_consumer_code
), NULL
, &cs_consumer
);
24077 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
24079 memset(&buffer_desc
, 0, sizeof(buffer_desc
));
24080 buffer_desc
.ByteWidth
= sizeof(unsigned int);
24081 buffer_desc
.Usage
= D3D11_USAGE_STAGING
;
24082 buffer_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
;
24083 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &staging_buffer
);
24084 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
24086 buffer_desc
.ByteWidth
= 1024;
24087 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
24088 buffer_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
24089 buffer_desc
.CPUAccessFlags
= 0;
24090 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
;
24091 buffer_desc
.StructureByteStride
= sizeof(unsigned int);
24092 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
24093 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
24094 uav_desc
.Format
= DXGI_FORMAT_UNKNOWN
;
24095 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
24096 U(uav_desc
).Buffer
.FirstElement
= 0;
24097 U(uav_desc
).Buffer
.NumElements
= buffer_desc
.ByteWidth
/ sizeof(unsigned int);
24098 U(uav_desc
).Buffer
.Flags
= D3D11_BUFFER_UAV_FLAG_COUNTER
;
24099 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
24100 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
24101 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer2
);
24102 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
24103 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer2
, NULL
, &uav2
);
24104 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
24106 data
= read_uav_counter(context
, staging_buffer
, uav
);
24107 ok(!data
, "Got unexpected initial value %u.\n", data
);
24109 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, &data
);
24110 data
= read_uav_counter(context
, staging_buffer
, uav
);
24111 ok(data
== 8, "Got unexpected value %u.\n", data
);
24113 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, &data
);
24114 data
= read_uav_counter(context
, staging_buffer
, uav
);
24115 ok(data
== 8, "Got unexpected value %u.\n", data
);
24116 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
24117 data
= read_uav_counter(context
, staging_buffer
, uav
);
24118 ok(data
== 8, "Got unexpected value %u.\n", data
);
24120 ID3D11DeviceContext_CSSetShader(context
, cs_producer
, NULL
, 0);
24122 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, &data
);
24123 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 1, 1, &uav2
, NULL
);
24124 data
= read_uav_counter(context
, staging_buffer
, uav
);
24125 ok(!data
, "Got unexpected value %u.\n", data
);
24128 ID3D11DeviceContext_Dispatch(context
, 16, 1, 1);
24129 data
= read_uav_counter(context
, staging_buffer
, uav
);
24130 ok(data
== 64, "Got unexpected value %u.\n", data
);
24131 get_buffer_readback(buffer
, &rb
);
24132 memcpy(id
, rb
.map_desc
.pData
, 64 * sizeof(*id
));
24133 release_resource_readback(&rb
);
24134 qsort(id
, 64, sizeof(*id
), compare_id
);
24135 for (i
= 0; i
< 64; ++i
)
24140 ok(i
== 64, "Got unexpected id %u at %u.\n", id
[i
], i
);
24143 ID3D11DeviceContext_CSSetShader(context
, cs_consumer
, NULL
, 0);
24144 ID3D11DeviceContext_Dispatch(context
, 16, 1, 1);
24145 data
= read_uav_counter(context
, staging_buffer
, uav
);
24146 ok(!data
, "Got unexpected value %u.\n", data
);
24147 get_buffer_readback(buffer2
, &rb
);
24148 memcpy(id
, rb
.map_desc
.pData
, 64 * sizeof(*id
));
24149 release_resource_readback(&rb
);
24150 qsort(id
, 64, sizeof(*id
), compare_id
);
24151 for (i
= 0; i
< 64; ++i
)
24156 ok(i
== 64, "Got unexpected id %u at %u.\n", id
[i
], i
);
24158 /* produce on CPU */
24159 for (i
= 0; i
< 8; ++i
)
24160 id
[i
] = 0xdeadbeef;
24161 set_box(&box
, 0, 0, 0, 8 * sizeof(*id
), 1, 1);
24162 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)buffer
, 0, &box
, id
, 0, 0);
24164 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, &data
);
24165 data
= read_uav_counter(context
, staging_buffer
, uav
);
24166 ok(data
== 8, "Got unexpected value %u.\n", data
);
24169 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
24170 data
= read_uav_counter(context
, staging_buffer
, uav
);
24171 ok(data
== 4, "Got unexpected value %u.\n", data
);
24172 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
24173 data
= read_uav_counter(context
, staging_buffer
, uav
);
24174 ok(!data
, "Got unexpected value %u.\n", data
);
24175 get_buffer_readback(buffer2
, &rb
);
24176 for (i
= 0; i
< 8; ++i
)
24178 data
= get_readback_color(&rb
, i
, 0, 0);
24179 ok(data
== 0xdeadbeef, "Got data %u at %u.\n", data
, i
);
24181 release_resource_readback(&rb
);
24183 ID3D11Buffer_Release(buffer
);
24184 ID3D11Buffer_Release(buffer2
);
24185 ID3D11Buffer_Release(staging_buffer
);
24186 ID3D11ComputeShader_Release(cs_producer
);
24187 ID3D11ComputeShader_Release(cs_consumer
);
24188 ID3D11UnorderedAccessView_Release(uav
);
24189 ID3D11UnorderedAccessView_Release(uav2
);
24190 release_test_context(&test_context
);
24193 static void test_dispatch_indirect(void)
24197 unsigned int dispatch_count
;
24198 unsigned int thread_count
;
24199 unsigned int max_x
;
24200 unsigned int max_y
;
24201 unsigned int max_z
;
24204 ID3D11Buffer
*append_buffer
, *stats_buffer
, *args_buffer
, *staging_buffer
;
24205 ID3D11UnorderedAccessView
*uav
, *stats_uav
;
24206 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
24207 ID3D11ComputeShader
*cs_append
, *cs_stats
;
24208 struct d3d11_test_context test_context
;
24209 D3D11_BUFFER_DESC buffer_desc
;
24210 ID3D11DeviceContext
*context
;
24211 struct resource_readback rb
;
24212 ID3D11Device
*device
;
24213 unsigned int data
, i
;
24214 struct stats
*stats
;
24217 static const DWORD cs_append_code
[] =
24220 struct dispatch_args
24225 AppendStructuredBuffer
<dispatch_args
> u
;
24227 [numthreads(1, 1, 1)]
24230 dispatch_args args
= {4, 2, 1};
24238 0x43425844, 0x954de75a, 0x8bb1b78b, 0x84ded464, 0x9d9532b7, 0x00000001, 0x00000158, 0x00000003,
24239 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
24240 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000104, 0x00050050, 0x00000041, 0x0100086a,
24241 0x0400009e, 0x0011e000, 0x00000000, 0x0000000c, 0x02000068, 0x00000001, 0x0400009b, 0x00000001,
24242 0x00000001, 0x00000001, 0x050000b2, 0x00100012, 0x00000000, 0x0011e000, 0x00000000, 0x0c0000a8,
24243 0x0011e072, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000000, 0x00004002, 0x00000004,
24244 0x00000002, 0x00000001, 0x00000000, 0x050000b2, 0x00100012, 0x00000000, 0x0011e000, 0x00000000,
24245 0x0c0000a8, 0x0011e072, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000000, 0x00004002,
24246 0x00000004, 0x00000001, 0x00000001, 0x00000000, 0x050000b2, 0x00100012, 0x00000000, 0x0011e000,
24247 0x00000000, 0x0c0000a8, 0x0011e072, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000000,
24248 0x00004002, 0x00000003, 0x00000001, 0x00000001, 0x00000000, 0x0100003e,
24250 static const DWORD cs_stats_code
[] =
24255 uint dispatch_count
;
24262 RWStructuredBuffer
<stats
> u
;
24264 [numthreads(1, 1, 1)]
24265 void main(uint3 id
: SV_DispatchThreadID
)
24268 InterlockedAdd(u
[0].dispatch_count
, 1);
24269 InterlockedAdd(u
[0].thread_count
, 1);
24270 InterlockedMax(u
[0].max_x
, id
.x
);
24271 InterlockedMax(u
[0].max_y
, id
.y
);
24272 InterlockedMax(u
[0].max_z
, id
.z
);
24275 0x43425844, 0xbd3f2e4e, 0xb0f61ff7, 0xa8e10584, 0x2f61aec9, 0x00000001, 0x000001bc, 0x00000003,
24276 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
24277 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000168, 0x00050050, 0x0000005a, 0x0100086a,
24278 0x0400009e, 0x0011e000, 0x00000000, 0x00000014, 0x0200005f, 0x00020072, 0x02000068, 0x00000001,
24279 0x0400009b, 0x00000001, 0x00000001, 0x00000001, 0x09000020, 0x00100072, 0x00000000, 0x00020246,
24280 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07000001, 0x00100012, 0x00000000,
24281 0x0010001a, 0x00000000, 0x0010000a, 0x00000000, 0x07000001, 0x00100012, 0x00000000, 0x0010002a,
24282 0x00000000, 0x0010000a, 0x00000000, 0x0304001f, 0x0010000a, 0x00000000, 0x0a0000ad, 0x0011e000,
24283 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00004001, 0x00000001,
24284 0x01000015, 0x0a0000ad, 0x0011e000, 0x00000000, 0x00004002, 0x00000000, 0x00000004, 0x00000000,
24285 0x00000000, 0x00004001, 0x00000001, 0x090000b0, 0x0011e000, 0x00000000, 0x00004002, 0x00000000,
24286 0x00000008, 0x00000000, 0x00000000, 0x0002000a, 0x090000b0, 0x0011e000, 0x00000000, 0x00004002,
24287 0x00000000, 0x0000000c, 0x00000000, 0x00000000, 0x0002001a, 0x090000b0, 0x0011e000, 0x00000000,
24288 0x00004002, 0x00000000, 0x00000010, 0x00000000, 0x00000000, 0x0002002a, 0x0100003e,
24290 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
24291 static const unsigned int zero
[4] = {0, 0, 0, 0};
24293 if (!init_test_context(&test_context
, &feature_level
))
24296 device
= test_context
.device
;
24297 context
= test_context
.immediate_context
;
24299 hr
= ID3D11Device_CreateComputeShader(device
, cs_append_code
, sizeof(cs_append_code
), NULL
, &cs_append
);
24300 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
24301 hr
= ID3D11Device_CreateComputeShader(device
, cs_stats_code
, sizeof(cs_stats_code
), NULL
, &cs_stats
);
24302 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
24304 memset(&buffer_desc
, 0, sizeof(buffer_desc
));
24305 buffer_desc
.ByteWidth
= sizeof(unsigned int);
24306 buffer_desc
.Usage
= D3D11_USAGE_STAGING
;
24307 buffer_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_READ
;
24308 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &staging_buffer
);
24309 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
24311 buffer_desc
.ByteWidth
= 60;
24312 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
24313 buffer_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
24314 buffer_desc
.CPUAccessFlags
= 0;
24315 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
;
24316 buffer_desc
.StructureByteStride
= 3 * sizeof(unsigned int);
24317 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &append_buffer
);
24318 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
24319 uav_desc
.Format
= DXGI_FORMAT_UNKNOWN
;
24320 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
24321 U(uav_desc
).Buffer
.FirstElement
= 0;
24322 U(uav_desc
).Buffer
.NumElements
= 5;
24323 U(uav_desc
).Buffer
.Flags
= D3D11_BUFFER_UAV_FLAG_APPEND
;
24324 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)append_buffer
, &uav_desc
, &uav
);
24325 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
24327 /* We use a separate buffer because D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS
24328 * and D3D11_RESOURCE_MISC_BUFFER_STRUCTURED are mutually exclusive flags.
24330 buffer_desc
.BindFlags
= 0;
24331 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS
;
24332 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &args_buffer
);
24333 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
24335 buffer_desc
.ByteWidth
= sizeof(*stats
);
24336 buffer_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
24337 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
;
24338 buffer_desc
.StructureByteStride
= sizeof(*stats
);
24339 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &stats_buffer
);
24340 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
24341 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)stats_buffer
, NULL
, &stats_uav
);
24342 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
24344 data
= read_uav_counter(context
, staging_buffer
, uav
);
24345 ok(!data
, "Got unexpected initial value %u.\n", data
);
24347 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, &data
);
24348 data
= read_uav_counter(context
, staging_buffer
, uav
);
24349 ok(data
== 8, "Got unexpected value %u.\n", data
);
24351 ID3D11DeviceContext_CSSetShader(context
, cs_append
, NULL
, 0);
24353 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, &data
);
24354 ID3D11DeviceContext_Dispatch(context
, 1, 1, 1);
24355 data
= read_uav_counter(context
, staging_buffer
, uav
);
24356 ok(data
== 3, "Got unexpected value %u.\n", data
);
24357 ID3D11DeviceContext_CopyResource(context
, (ID3D11Resource
*)args_buffer
, (ID3D11Resource
*)append_buffer
);
24359 ID3D11DeviceContext_CSSetShader(context
, cs_stats
, NULL
, 0);
24360 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, stats_uav
, zero
);
24361 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &stats_uav
, NULL
);
24362 data
= read_uav_counter(context
, staging_buffer
, uav
);
24363 for (i
= 0; i
< data
; ++i
)
24364 ID3D11DeviceContext_DispatchIndirect(context
, args_buffer
, i
* 3 * sizeof(unsigned int));
24365 get_buffer_readback(stats_buffer
, &rb
);
24366 stats
= rb
.map_desc
.pData
;
24367 ok(stats
->dispatch_count
== 3, "Got unexpected dispatch count %u.\n", stats
->dispatch_count
);
24368 ok(stats
->thread_count
== 15, "Got unexpected thread count %u.\n", stats
->thread_count
);
24369 ok(stats
->max_x
== 3, "Got unexpected max x %u.\n", stats
->max_x
);
24370 ok(stats
->max_y
== 1, "Got unexpected max y %u.\n", stats
->max_y
);
24371 ok(stats
->max_z
== 0, "Got unexpected max z %u.\n", stats
->max_z
);
24372 release_resource_readback(&rb
);
24374 ID3D11Buffer_Release(append_buffer
);
24375 ID3D11Buffer_Release(args_buffer
);
24376 ID3D11Buffer_Release(staging_buffer
);
24377 ID3D11Buffer_Release(stats_buffer
);
24378 ID3D11ComputeShader_Release(cs_append
);
24379 ID3D11ComputeShader_Release(cs_stats
);
24380 ID3D11UnorderedAccessView_Release(uav
);
24381 ID3D11UnorderedAccessView_Release(stats_uav
);
24382 release_test_context(&test_context
);
24385 static void test_compute_shader_registers(void)
24389 unsigned int group_id
[3];
24390 unsigned int group_index
;
24391 unsigned int dispatch_id
[3];
24392 unsigned int thread_id
[3];
24395 struct d3d11_test_context test_context
;
24396 unsigned int i
, x
, y
, group_x
, group_y
;
24397 ID3D11UnorderedAccessView
*uav
;
24398 D3D11_BUFFER_DESC buffer_desc
;
24399 ID3D11DeviceContext
*context
;
24400 struct resource_readback rb
;
24401 ID3D11Buffer
*cb
, *buffer
;
24402 struct uvec4 dimensions
;
24403 ID3D11ComputeShader
*cs
;
24404 const struct data
*data
;
24405 ID3D11Device
*device
;
24408 static const DWORD cs_code
[] =
24416 uint3 group_thread_id
;
24419 RWStructuredBuffer
<data
> u
;
24423 [numthreads(3, 2, 1)]
24424 void main(uint3 group_id
: SV_GroupID
,
24425 uint group_index
: SV_GroupIndex
,
24426 uint3 dispatch_id
: SV_DispatchThreadID
,
24427 uint3 group_thread_id
: SV_GroupThreadID
)
24429 uint i
= dispatch_id
.x
+ dispatch_id
.y
* 3 * dim
.x
;
24430 u
[i
].group_id
= group_id
;
24431 u
[i
].group_index
= group_index
;
24432 u
[i
].dispatch_id
= dispatch_id
;
24433 u
[i
].group_thread_id
= group_thread_id
;
24436 0x43425844, 0xf0bce218, 0xfc1e8267, 0xe6d57544, 0x342df592, 0x00000001, 0x000001a4, 0x00000003,
24437 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
24438 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000150, 0x00050050, 0x00000054, 0x0100086a,
24439 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0400009e, 0x0011e000, 0x00000000, 0x00000028,
24440 0x0200005f, 0x00024000, 0x0200005f, 0x00021072, 0x0200005f, 0x00022072, 0x0200005f, 0x00020072,
24441 0x02000068, 0x00000002, 0x0400009b, 0x00000003, 0x00000002, 0x00000001, 0x04000036, 0x00100072,
24442 0x00000000, 0x00021246, 0x04000036, 0x00100082, 0x00000000, 0x0002400a, 0x08000026, 0x0000d000,
24443 0x00100012, 0x00000001, 0x0002001a, 0x0020800a, 0x00000000, 0x00000000, 0x08000023, 0x00100012,
24444 0x00000001, 0x0010000a, 0x00000001, 0x00004001, 0x00000003, 0x0002000a, 0x090000a8, 0x0011e0f2,
24445 0x00000000, 0x0010000a, 0x00000001, 0x00004001, 0x00000000, 0x00100e46, 0x00000000, 0x04000036,
24446 0x00100072, 0x00000000, 0x00020246, 0x04000036, 0x00100082, 0x00000000, 0x0002200a, 0x090000a8,
24447 0x0011e0f2, 0x00000000, 0x0010000a, 0x00000001, 0x00004001, 0x00000010, 0x00100e46, 0x00000000,
24448 0x080000a8, 0x0011e032, 0x00000000, 0x0010000a, 0x00000001, 0x00004001, 0x00000020, 0x00022596,
24451 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
24453 if (!init_test_context(&test_context
, &feature_level
))
24456 device
= test_context
.device
;
24457 context
= test_context
.immediate_context
;
24459 buffer_desc
.ByteWidth
= 10240;
24460 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
24461 buffer_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
24462 buffer_desc
.CPUAccessFlags
= 0;
24463 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
;
24464 buffer_desc
.StructureByteStride
= 40;
24465 assert(sizeof(struct data
) == buffer_desc
.StructureByteStride
);
24466 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
24467 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
24468 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, NULL
, &uav
);
24469 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
24471 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(dimensions
), NULL
);
24473 hr
= ID3D11Device_CreateComputeShader(device
, cs_code
, sizeof(cs_code
), NULL
, &cs
);
24474 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
24476 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
24477 ID3D11DeviceContext_CSSetConstantBuffers(context
, 0, 1, &cb
);
24478 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
24484 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0,
24485 NULL
, &dimensions
, 0, 0);
24486 ID3D11DeviceContext_Dispatch(context
, dimensions
.x
, dimensions
.y
, dimensions
.z
);
24488 get_buffer_readback(buffer
, &rb
);
24490 data
= rb
.map_desc
.pData
;
24491 for (y
= 0; y
< dimensions
.y
; ++y
)
24493 for (group_y
= 0; group_y
< 2; ++group_y
)
24495 for (x
= 0; x
< dimensions
.x
; ++x
)
24497 for (group_x
= 0; group_x
< 3; ++group_x
)
24499 const unsigned int dispatch_id
[2] = {x
* 3 + group_x
, y
* 2 + group_y
};
24500 const unsigned int group_index
= group_y
* 3 + group_x
;
24501 const struct data
*d
= &data
[i
];
24503 ok(d
->group_id
[0] == x
&& d
->group_id
[1] == y
&& !d
->group_id
[2],
24504 "Got group id (%u, %u, %u), expected (%u, %u, %u) at %u (%u, %u, %u, %u).\n",
24505 d
->group_id
[0], d
->group_id
[1], d
->group_id
[2], x
, y
, 0,
24506 i
, x
, y
, group_x
, group_y
);
24507 ok(d
->group_index
== group_index
,
24508 "Got group index %u, expected %u at %u (%u, %u, %u, %u).\n",
24509 d
->group_index
, group_index
, i
, x
, y
, group_x
, group_y
);
24510 ok(d
->dispatch_id
[0] == dispatch_id
[0] && d
->dispatch_id
[1] == dispatch_id
[1]
24511 && !d
->dispatch_id
[2],
24512 "Got dispatch id (%u, %u, %u), expected (%u, %u, %u) "
24513 "at %u (%u, %u, %u, %u).\n",
24514 d
->dispatch_id
[0], d
->dispatch_id
[1], d
->dispatch_id
[2],
24515 dispatch_id
[0], dispatch_id
[1], 0,
24516 i
, x
, y
, group_x
, group_y
);
24517 ok(d
->thread_id
[0] == group_x
&& d
->thread_id
[1] == group_y
&& !d
->thread_id
[2],
24518 "Got group thread id (%u, %u, %u), expected (%u, %u, %u) "
24519 "at %u (%u, %u, %u, %u).\n",
24520 d
->thread_id
[0], d
->thread_id
[1], d
->thread_id
[2], group_x
, group_y
, 0,
24521 i
, x
, y
, group_x
, group_y
);
24527 release_resource_readback(&rb
);
24529 ID3D11Buffer_Release(cb
);
24530 ID3D11Buffer_Release(buffer
);
24531 ID3D11ComputeShader_Release(cs
);
24532 ID3D11UnorderedAccessView_Release(uav
);
24533 release_test_context(&test_context
);
24536 static void test_tgsm(void)
24538 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
24539 struct d3d11_test_context test_context
;
24540 ID3D11UnorderedAccessView
*uav
, *uav2
;
24541 struct resource_readback rb
, rb2
;
24542 unsigned int i
, data
, expected
;
24543 ID3D11Buffer
*buffer
, *buffer2
;
24544 D3D11_BUFFER_DESC buffer_desc
;
24545 ID3D11DeviceContext
*context
;
24546 ID3D11ComputeShader
*cs
;
24547 ID3D11Device
*device
;
24551 static const DWORD raw_tgsm_code
[] =
24554 RWByteAddressBuffer u
;
24555 groupshared uint m
;
24557 [numthreads(32, 1, 1)]
24558 void main(uint local_idx
: SV_GroupIndex
, uint group_id
: SV_GroupID
)
24562 GroupMemoryBarrierWithGroupSync();
24563 InterlockedAdd(m
, group_id
.x
);
24564 GroupMemoryBarrierWithGroupSync();
24566 u
.Store(4 * group_id
.x
, m
);
24569 0x43425844, 0x467df6d9, 0x5f56edda, 0x5c96b787, 0x60c91fb8, 0x00000001, 0x00000148, 0x00000003,
24570 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
24571 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x000000f4, 0x00050050, 0x0000003d, 0x0100086a,
24572 0x0300009d, 0x0011e000, 0x00000000, 0x0200005f, 0x00024000, 0x0200005f, 0x00021012, 0x02000068,
24573 0x00000001, 0x0400009f, 0x0011f000, 0x00000000, 0x00000004, 0x0400009b, 0x00000020, 0x00000001,
24574 0x00000001, 0x0200001f, 0x0002400a, 0x060000a6, 0x0011f012, 0x00000000, 0x00004001, 0x00000000,
24575 0x0002100a, 0x01000015, 0x010018be, 0x060000ad, 0x0011f000, 0x00000000, 0x00004001, 0x00000000,
24576 0x0002100a, 0x010018be, 0x0200001f, 0x0002400a, 0x06000029, 0x00100012, 0x00000000, 0x0002100a,
24577 0x00004001, 0x00000002, 0x070000a5, 0x00100022, 0x00000000, 0x00004001, 0x00000000, 0x0011f006,
24578 0x00000000, 0x070000a6, 0x0011e012, 0x00000000, 0x0010000a, 0x00000000, 0x0010001a, 0x00000000,
24579 0x01000015, 0x0100003e,
24581 static const DWORD structured_tgsm_code
[] =
24584 #define GROUP_SIZE 32
24586 RWByteAddressBuffer u
;
24587 RWByteAddressBuffer u2
;
24588 groupshared uint m
[GROUP_SIZE
];
24590 [numthreads(GROUP_SIZE
, 1, 1)]
24591 void main(uint local_idx
: SV_GroupIndex
, uint group_id
: SV_GroupID
)
24593 uint sum
, original
, i
;
24597 for (i
= 0; i
< GROUP_SIZE
; ++i
)
24598 m
[i
] = 2 * group_id
.x
;
24600 GroupMemoryBarrierWithGroupSync();
24601 InterlockedAdd(m
[local_idx
], 1);
24602 GroupMemoryBarrierWithGroupSync();
24603 for (i
= 0, sum
= 0; i
< GROUP_SIZE
; sum
+= m
[i
++]);
24604 u
.InterlockedExchange(4 * group_id
.x
, sum
, original
);
24605 u2
.Store(4 * group_id
.x
, original
);
24608 0x43425844, 0x9d906c94, 0x81f5ad92, 0x11e860b2, 0x3623c824, 0x00000001, 0x000002c0, 0x00000003,
24609 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
24610 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x0000026c, 0x00050050, 0x0000009b, 0x0100086a,
24611 0x0300009d, 0x0011e000, 0x00000000, 0x0300009d, 0x0011e000, 0x00000001, 0x0200005f, 0x00024000,
24612 0x0200005f, 0x00021012, 0x02000068, 0x00000002, 0x050000a0, 0x0011f000, 0x00000000, 0x00000004,
24613 0x00000020, 0x0400009b, 0x00000020, 0x00000001, 0x00000001, 0x0200001f, 0x0002400a, 0x06000029,
24614 0x00100012, 0x00000000, 0x0002100a, 0x00004001, 0x00000001, 0x05000036, 0x00100022, 0x00000000,
24615 0x00004001, 0x00000000, 0x01000030, 0x07000050, 0x00100042, 0x00000000, 0x0010001a, 0x00000000,
24616 0x00004001, 0x00000020, 0x03040003, 0x0010002a, 0x00000000, 0x090000a8, 0x0011f012, 0x00000000,
24617 0x0010001a, 0x00000000, 0x00004001, 0x00000000, 0x0010000a, 0x00000000, 0x0700001e, 0x00100022,
24618 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0x00000001, 0x01000016, 0x01000015, 0x010018be,
24619 0x04000036, 0x00100012, 0x00000000, 0x0002400a, 0x05000036, 0x00100022, 0x00000000, 0x00004001,
24620 0x00000000, 0x070000ad, 0x0011f000, 0x00000000, 0x00100046, 0x00000000, 0x00004001, 0x00000001,
24621 0x010018be, 0x08000036, 0x00100032, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000,
24622 0x00000000, 0x01000030, 0x07000050, 0x00100042, 0x00000000, 0x0010001a, 0x00000000, 0x00004001,
24623 0x00000020, 0x03040003, 0x0010002a, 0x00000000, 0x0700001e, 0x00100022, 0x00000001, 0x0010001a,
24624 0x00000000, 0x00004001, 0x00000001, 0x090000a7, 0x00100042, 0x00000000, 0x0010001a, 0x00000000,
24625 0x00004001, 0x00000000, 0x0011f006, 0x00000000, 0x0700001e, 0x00100012, 0x00000001, 0x0010000a,
24626 0x00000000, 0x0010002a, 0x00000000, 0x05000036, 0x00100032, 0x00000000, 0x00100046, 0x00000001,
24627 0x01000016, 0x06000029, 0x00100022, 0x00000000, 0x0002100a, 0x00004001, 0x00000002, 0x090000b8,
24628 0x00100012, 0x00000001, 0x0011e000, 0x00000000, 0x0010001a, 0x00000000, 0x0010000a, 0x00000000,
24629 0x070000a6, 0x0011e012, 0x00000001, 0x0010001a, 0x00000000, 0x0010000a, 0x00000001, 0x0100003e,
24631 static const DWORD structured_tgsm_float_code
[] =
24634 #define GROUP_SIZE 32
24644 groupshared data m
[GROUP_SIZE
];
24646 [numthreads(GROUP_SIZE
, 1, 1)]
24647 void main(uint local_idx
: SV_GroupIndex
, uint group_id
: SV_GroupID
,
24648 uint thread_id
: SV_DispatchThreadID
)
24653 for (i
= 0; i
< GROUP_SIZE
; ++i
)
24655 m
[i
].f
= group_id
.x
;
24656 m
[i
].u
= group_id
.x
;
24659 GroupMemoryBarrierWithGroupSync();
24660 for (i
= 0; i
< local_idx
; ++i
)
24662 m
[local_idx
].f
+= group_id
.x
;
24663 m
[local_idx
].u
+= group_id
.x
;
24665 u
[thread_id
.x
] = m
[local_idx
].f
;
24666 u2
[thread_id
.x
] = m
[local_idx
].u
;
24669 0x43425844, 0xaadf1a71, 0x16f60224, 0x89b6ce76, 0xb66fb96f, 0x00000001, 0x000002ac, 0x00000003,
24670 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
24671 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000258, 0x00050050, 0x00000096, 0x0100086a,
24672 0x0400089c, 0x0011e000, 0x00000000, 0x00005555, 0x0400089c, 0x0011e000, 0x00000001, 0x00004444,
24673 0x0200005f, 0x00024000, 0x0200005f, 0x00021012, 0x0200005f, 0x00020012, 0x02000068, 0x00000002,
24674 0x050000a0, 0x0011f000, 0x00000000, 0x00000008, 0x00000020, 0x0400009b, 0x00000020, 0x00000001,
24675 0x00000001, 0x0200001f, 0x0002400a, 0x04000056, 0x00100012, 0x00000000, 0x0002100a, 0x04000036,
24676 0x00100022, 0x00000000, 0x0002100a, 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0x00000000,
24677 0x01000030, 0x07000050, 0x00100082, 0x00000000, 0x0010002a, 0x00000000, 0x00004001, 0x00000020,
24678 0x03040003, 0x0010003a, 0x00000000, 0x090000a8, 0x0011f032, 0x00000000, 0x0010002a, 0x00000000,
24679 0x00004001, 0x00000000, 0x00100046, 0x00000000, 0x0700001e, 0x00100042, 0x00000000, 0x0010002a,
24680 0x00000000, 0x00004001, 0x00000001, 0x01000016, 0x01000015, 0x010018be, 0x04000056, 0x00100012,
24681 0x00000000, 0x0002100a, 0x05000036, 0x00100022, 0x00000000, 0x00004001, 0x00000000, 0x01000030,
24682 0x06000050, 0x00100042, 0x00000000, 0x0010001a, 0x00000000, 0x0002400a, 0x03040003, 0x0010002a,
24683 0x00000000, 0x080000a7, 0x001000c2, 0x00000000, 0x0002400a, 0x00004001, 0x00000000, 0x0011f406,
24684 0x00000000, 0x07000000, 0x00100012, 0x00000001, 0x0010000a, 0x00000000, 0x0010002a, 0x00000000,
24685 0x0600001e, 0x00100022, 0x00000001, 0x0010003a, 0x00000000, 0x0002100a, 0x080000a8, 0x0011f032,
24686 0x00000000, 0x0002400a, 0x00004001, 0x00000000, 0x00100046, 0x00000001, 0x0700001e, 0x00100022,
24687 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0x00000001, 0x01000016, 0x080000a7, 0x00100032,
24688 0x00000000, 0x0002400a, 0x00004001, 0x00000000, 0x0011f046, 0x00000000, 0x060000a4, 0x0011e0f2,
24689 0x00000000, 0x00020006, 0x00100006, 0x00000000, 0x060000a4, 0x0011e0f2, 0x00000001, 0x00020006,
24690 0x00100556, 0x00000000, 0x0100003e,
24692 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
24693 static const unsigned int zero
[4] = {0};
24695 if (!init_test_context(&test_context
, &feature_level
))
24698 device
= test_context
.device
;
24699 context
= test_context
.immediate_context
;
24701 buffer_desc
.ByteWidth
= 1024;
24702 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
24703 buffer_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
24704 buffer_desc
.CPUAccessFlags
= 0;
24705 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
;
24706 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
24707 ok(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
24709 uav_desc
.Format
= DXGI_FORMAT_R32_TYPELESS
;
24710 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
24711 U(uav_desc
).Buffer
.FirstElement
= 0;
24712 U(uav_desc
).Buffer
.NumElements
= buffer_desc
.ByteWidth
/ sizeof(unsigned int);
24713 U(uav_desc
).Buffer
.Flags
= D3D11_BUFFER_UAV_FLAG_RAW
;
24714 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
24715 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
24717 hr
= ID3D11Device_CreateComputeShader(device
, raw_tgsm_code
, sizeof(raw_tgsm_code
), NULL
, &cs
);
24718 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
24720 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
24721 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
24723 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, zero
);
24724 ID3D11DeviceContext_Dispatch(context
, 64, 1, 1);
24725 get_buffer_readback(buffer
, &rb
);
24726 for (i
= 0; i
< 64; ++i
)
24728 data
= get_readback_color(&rb
, i
, 0, 0);
24730 ok(data
== expected
, "Got %u, expected %u (index %u).\n", data
, expected
, i
);
24732 release_resource_readback(&rb
);
24734 ID3D11Buffer_Release(buffer
);
24735 ID3D11ComputeShader_Release(cs
);
24736 ID3D11UnorderedAccessView_Release(uav
);
24738 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
24739 ok(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
24740 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
24741 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
24742 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer2
);
24743 ok(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
24744 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer2
, &uav_desc
, &uav2
);
24745 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
24746 hr
= ID3D11Device_CreateComputeShader(device
, structured_tgsm_code
, sizeof(structured_tgsm_code
), NULL
, &cs
);
24747 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
24749 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
24750 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
24751 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 1, 1, &uav2
, NULL
);
24753 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, zero
);
24754 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav2
, zero
);
24755 ID3D11DeviceContext_Dispatch(context
, 32, 1, 1);
24756 get_buffer_readback(buffer
, &rb
);
24757 get_buffer_readback(buffer2
, &rb2
);
24758 for (i
= 0; i
< 32; ++i
)
24760 expected
= 64 * i
+ 32;
24761 data
= get_readback_color(&rb
, i
, 0, 0);
24762 ok(data
== expected
, "Got %u, expected %u (index %u).\n", data
, expected
, i
);
24763 data
= get_readback_color(&rb2
, i
, 0, 0);
24764 ok(data
== expected
|| !data
, "Got %u, expected %u (index %u).\n", data
, expected
, i
);
24766 release_resource_readback(&rb
);
24767 release_resource_readback(&rb2
);
24769 ID3D11Buffer_Release(buffer
);
24770 ID3D11Buffer_Release(buffer2
);
24771 ID3D11ComputeShader_Release(cs
);
24772 ID3D11UnorderedAccessView_Release(uav
);
24773 ID3D11UnorderedAccessView_Release(uav2
);
24775 buffer_desc
.MiscFlags
= 0;
24776 U(uav_desc
).Buffer
.Flags
= 0;
24777 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
24778 ok(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
24779 uav_desc
.Format
= DXGI_FORMAT_R32_FLOAT
;
24780 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
24781 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
24782 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer2
);
24783 ok(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
24784 uav_desc
.Format
= DXGI_FORMAT_R32_UINT
;
24785 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer2
, &uav_desc
, &uav2
);
24786 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
24787 hr
= ID3D11Device_CreateComputeShader(device
, structured_tgsm_float_code
,
24788 sizeof(structured_tgsm_float_code
), NULL
, &cs
);
24789 ok(SUCCEEDED(hr
), "Failed to create compute shader, hr %#x.\n", hr
);
24791 ID3D11DeviceContext_CSSetShader(context
, cs
, NULL
, 0);
24792 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 0, 1, &uav
, NULL
);
24793 ID3D11DeviceContext_CSSetUnorderedAccessViews(context
, 1, 1, &uav2
, NULL
);
24795 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, zero
);
24796 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav2
, zero
);
24797 ID3D11DeviceContext_Dispatch(context
, 3, 1, 1);
24798 get_buffer_readback(buffer
, &rb
);
24799 get_buffer_readback(buffer2
, &rb2
);
24800 for (i
= 0; i
< 96; ++i
)
24802 expected
= (i
% 32 + 1) * (i
/ 32);
24803 float_data
= get_readback_float(&rb
, i
, 0);
24804 ok(float_data
== expected
, "Got %.8e, expected %u (index %u).\n", float_data
, expected
, i
);
24805 data
= get_readback_color(&rb2
, i
, 0, 0);
24806 ok(data
== expected
, "Got %u, expected %u (index %u).\n", data
, expected
, i
);
24808 release_resource_readback(&rb
);
24809 release_resource_readback(&rb2
);
24811 ID3D11Buffer_Release(buffer
);
24812 ID3D11Buffer_Release(buffer2
);
24813 ID3D11ComputeShader_Release(cs
);
24814 ID3D11UnorderedAccessView_Release(uav
);
24815 ID3D11UnorderedAccessView_Release(uav2
);
24816 release_test_context(&test_context
);
24819 static void test_geometry_shader(void)
24821 static const struct
24823 struct vec4 position
;
24824 unsigned int color
;
24828 {{0.0f
, 0.0f
, 1.0f
, 1.0f
}, 0xffffff00},
24830 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
24832 {"SV_POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
24833 {"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, 16, D3D11_INPUT_PER_VERTEX_DATA
, 0},
24838 float4 pos
: SV_POSITION
;
24839 float4 color
: COLOR
;
24842 void main(in
struct vs_data vs_input
, out
struct vs_data vs_output
)
24844 vs_output
.pos
= vs_input
.pos
;
24845 vs_output
.color
= vs_input
.color
;
24848 static const DWORD vs_code
[] =
24850 0x43425844, 0xd5b32785, 0x35332906, 0x4d05e031, 0xf66a58af, 0x00000001, 0x00000144, 0x00000003,
24851 0x0000002c, 0x00000080, 0x000000d4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
24852 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000044, 0x00000000, 0x00000000,
24853 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
24854 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
24855 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
24856 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000068, 0x00010040,
24857 0x0000001a, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067,
24858 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2,
24859 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001,
24865 float4 pos
: SV_POSITION
;
24866 float4 color
: COLOR
;
24869 [maxvertexcount(4)]
24870 void main(point
struct gs_data vin
[1], inout TriangleStream
<gs_data
> vout
)
24872 float offset
= 0.2 * vin
[0].pos
.w
;
24875 v
.color
= vin
[0].color
;
24877 v
.pos
= float4(vin
[0].pos
.x
- offset
, vin
[0].pos
.y
- offset
, vin
[0].pos
.z
, 1.0);
24879 v
.pos
= float4(vin
[0].pos
.x
- offset
, vin
[0].pos
.y
+ offset
, vin
[0].pos
.z
, 1.0);
24881 v
.pos
= float4(vin
[0].pos
.x
+ offset
, vin
[0].pos
.y
- offset
, vin
[0].pos
.z
, 1.0);
24883 v
.pos
= float4(vin
[0].pos
.x
+ offset
, vin
[0].pos
.y
+ offset
, vin
[0].pos
.z
, 1.0);
24887 static const DWORD gs_code
[] =
24889 0x43425844, 0x70616045, 0x96756e1f, 0x1caeecb8, 0x3749528c, 0x00000001, 0x0000034c, 0x00000003,
24890 0x0000002c, 0x00000080, 0x000000d4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
24891 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x00000044, 0x00000000, 0x00000000,
24892 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
24893 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
24894 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
24895 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000270, 0x00020040,
24896 0x0000009c, 0x05000061, 0x002010f2, 0x00000001, 0x00000000, 0x00000001, 0x0400005f, 0x002010f2,
24897 0x00000001, 0x00000001, 0x02000068, 0x00000001, 0x0100085d, 0x0100285c, 0x04000067, 0x001020f2,
24898 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x0200005e, 0x00000004, 0x0f000032,
24899 0x00100032, 0x00000000, 0x80201ff6, 0x00000041, 0x00000000, 0x00000000, 0x00004002, 0x3e4ccccd,
24900 0x3e4ccccd, 0x00000000, 0x00000000, 0x00201046, 0x00000000, 0x00000000, 0x05000036, 0x00102032,
24901 0x00000000, 0x00100046, 0x00000000, 0x06000036, 0x00102042, 0x00000000, 0x0020102a, 0x00000000,
24902 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x3f800000, 0x06000036, 0x001020f2,
24903 0x00000001, 0x00201e46, 0x00000000, 0x00000001, 0x01000013, 0x05000036, 0x00102012, 0x00000000,
24904 0x0010000a, 0x00000000, 0x0e000032, 0x00100052, 0x00000000, 0x00201ff6, 0x00000000, 0x00000000,
24905 0x00004002, 0x3e4ccccd, 0x00000000, 0x3e4ccccd, 0x00000000, 0x00201106, 0x00000000, 0x00000000,
24906 0x05000036, 0x00102022, 0x00000000, 0x0010002a, 0x00000000, 0x06000036, 0x00102042, 0x00000000,
24907 0x0020102a, 0x00000000, 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x3f800000,
24908 0x06000036, 0x001020f2, 0x00000001, 0x00201e46, 0x00000000, 0x00000001, 0x01000013, 0x05000036,
24909 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x05000036, 0x00102022, 0x00000000, 0x0010001a,
24910 0x00000000, 0x06000036, 0x00102042, 0x00000000, 0x0020102a, 0x00000000, 0x00000000, 0x05000036,
24911 0x00102082, 0x00000000, 0x00004001, 0x3f800000, 0x06000036, 0x001020f2, 0x00000001, 0x00201e46,
24912 0x00000000, 0x00000001, 0x01000013, 0x05000036, 0x00102032, 0x00000000, 0x00100086, 0x00000000,
24913 0x06000036, 0x00102042, 0x00000000, 0x0020102a, 0x00000000, 0x00000000, 0x05000036, 0x00102082,
24914 0x00000000, 0x00004001, 0x3f800000, 0x06000036, 0x001020f2, 0x00000001, 0x00201e46, 0x00000000,
24915 0x00000001, 0x01000013, 0x0100003e,
24917 static const DWORD gs_5_0_code
[] =
24919 0x43425844, 0x57251c23, 0x4971d115, 0x8fee0b13, 0xba149ea1, 0x00000001, 0x00000384, 0x00000003,
24920 0x0000002c, 0x00000080, 0x000000dc, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
24921 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x00000044, 0x00000000, 0x00000000,
24922 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
24923 0x3547534f, 0x00000054, 0x00000002, 0x00000008, 0x00000000, 0x00000040, 0x00000000, 0x00000001,
24924 0x00000003, 0x00000000, 0x0000000f, 0x00000000, 0x0000004c, 0x00000000, 0x00000000, 0x00000003,
24925 0x00000001, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x58454853,
24926 0x000002a0, 0x00020050, 0x000000a8, 0x0100086a, 0x05000061, 0x002010f2, 0x00000001, 0x00000000,
24927 0x00000001, 0x0400005f, 0x002010f2, 0x00000001, 0x00000001, 0x02000068, 0x00000001, 0x0100085d,
24928 0x0300008f, 0x00110000, 0x00000000, 0x0100285c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
24929 0x03000065, 0x001020f2, 0x00000001, 0x0200005e, 0x00000004, 0x0f000032, 0x00100032, 0x00000000,
24930 0x80201ff6, 0x00000041, 0x00000000, 0x00000000, 0x00004002, 0x3e4ccccd, 0x3e4ccccd, 0x00000000,
24931 0x00000000, 0x00201046, 0x00000000, 0x00000000, 0x05000036, 0x00102032, 0x00000000, 0x00100046,
24932 0x00000000, 0x06000036, 0x00102042, 0x00000000, 0x0020102a, 0x00000000, 0x00000000, 0x05000036,
24933 0x00102082, 0x00000000, 0x00004001, 0x3f800000, 0x06000036, 0x001020f2, 0x00000001, 0x00201e46,
24934 0x00000000, 0x00000001, 0x03000075, 0x00110000, 0x00000000, 0x05000036, 0x00102012, 0x00000000,
24935 0x0010000a, 0x00000000, 0x0e000032, 0x00100052, 0x00000000, 0x00201ff6, 0x00000000, 0x00000000,
24936 0x00004002, 0x3e4ccccd, 0x00000000, 0x3e4ccccd, 0x00000000, 0x00201106, 0x00000000, 0x00000000,
24937 0x05000036, 0x00102022, 0x00000000, 0x0010002a, 0x00000000, 0x06000036, 0x00102042, 0x00000000,
24938 0x0020102a, 0x00000000, 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x3f800000,
24939 0x06000036, 0x001020f2, 0x00000001, 0x00201e46, 0x00000000, 0x00000001, 0x03000075, 0x00110000,
24940 0x00000000, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x05000036, 0x00102022,
24941 0x00000000, 0x0010001a, 0x00000000, 0x06000036, 0x00102042, 0x00000000, 0x0020102a, 0x00000000,
24942 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x3f800000, 0x06000036, 0x001020f2,
24943 0x00000001, 0x00201e46, 0x00000000, 0x00000001, 0x03000075, 0x00110000, 0x00000000, 0x05000036,
24944 0x00102032, 0x00000000, 0x00100086, 0x00000000, 0x06000036, 0x00102042, 0x00000000, 0x0020102a,
24945 0x00000000, 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x3f800000, 0x06000036,
24946 0x001020f2, 0x00000001, 0x00201e46, 0x00000000, 0x00000001, 0x03000075, 0x00110000, 0x00000000,
24952 float4 pos
: SV_POSITION
;
24953 float4 color
: COLOR
;
24956 float4
main(struct ps_data ps_input
) : SV_Target
24958 return ps_input
.color
;
24961 static const DWORD ps_code
[] =
24963 0x43425844, 0x89803e59, 0x3f798934, 0xf99181df, 0xf5556512, 0x00000001, 0x000000f4, 0x00000003,
24964 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
24965 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
24966 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
24967 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
24968 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000038, 0x00000040,
24969 0x0000000e, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
24970 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
24972 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 1.0f
};
24973 struct d3d11_test_context test_context
;
24974 ID3D11InputLayout
*input_layout
;
24975 ID3D11DeviceContext
*context
;
24976 unsigned int stride
, offset
;
24977 struct resource_readback rb
;
24978 ID3D11GeometryShader
*gs
;
24979 ID3D11VertexShader
*vs
;
24980 ID3D11PixelShader
*ps
;
24981 ID3D11Device
*device
;
24986 if (!init_test_context(&test_context
, NULL
))
24989 device
= test_context
.device
;
24990 context
= test_context
.immediate_context
;
24992 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
24993 vs_code
, sizeof(vs_code
), &input_layout
);
24994 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
24996 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(vertex
), vertex
);
24998 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
24999 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
25000 if (ID3D11Device_GetFeatureLevel(device
) >= D3D_FEATURE_LEVEL_11_0
)
25001 hr
= ID3D11Device_CreateGeometryShader(device
, gs_5_0_code
, sizeof(gs_5_0_code
), NULL
, &gs
);
25003 hr
= ID3D11Device_CreateGeometryShader(device
, gs_code
, sizeof(gs_code
), NULL
, &gs
);
25004 ok(SUCCEEDED(hr
), "Failed to create geometry shader, hr %#x.\n", hr
);
25005 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
25006 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
25008 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
25009 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST
);
25010 stride
= sizeof(*vertex
);
25012 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, &stride
, &offset
);
25013 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
25014 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
25015 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
25017 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
25018 ID3D11DeviceContext_Draw(context
, 1, 0);
25020 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
25021 color
= get_readback_color(&rb
, 320, 190, 0);
25022 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
25023 color
= get_readback_color(&rb
, 255, 240, 0);
25024 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
25025 color
= get_readback_color(&rb
, 320, 240, 0);
25026 ok(compare_color(color
, 0xffffff00, 1), "Got unexpected color 0x%08x.\n", color
);
25027 color
= get_readback_color(&rb
, 385, 240, 0);
25028 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
25029 color
= get_readback_color(&rb
, 320, 290, 0);
25030 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
25031 release_resource_readback(&rb
);
25033 ID3D11PixelShader_Release(ps
);
25034 ID3D11GeometryShader_Release(gs
);
25035 ID3D11VertexShader_Release(vs
);
25036 ID3D11Buffer_Release(vb
);
25037 ID3D11InputLayout_Release(input_layout
);
25038 release_test_context(&test_context
);
25046 #define check_triangles(buffer, triangles, count) check_triangles_(__LINE__, buffer, triangles, count)
25047 static void check_triangles_(unsigned int line
, ID3D11Buffer
*buffer
,
25048 const struct triangle
*triangles
, unsigned int triangle_count
)
25050 const struct triangle
*current
, *expected
;
25051 struct resource_readback rb
;
25052 unsigned int i
, j
, offset
;
25053 BOOL all_match
= TRUE
;
25055 get_buffer_readback(buffer
, &rb
);
25057 for (i
= 0; i
< triangle_count
; ++i
)
25059 current
= get_readback_data(&rb
, i
, 0, 0, sizeof(*current
));
25060 expected
= &triangles
[i
];
25063 for (j
= 0; j
< ARRAY_SIZE(expected
->v
); ++j
)
25065 if (compare_vec4(¤t
->v
[0], &expected
->v
[j
], 0))
25078 for (j
= 0; j
< ARRAY_SIZE(expected
->v
); ++j
)
25080 if (!compare_vec4(¤t
->v
[j
], &expected
->v
[(j
+ offset
) % 3], 0))
25090 ok_(__FILE__
, line
)(all_match
, "Triangle %u vertices {%.8e, %.8e, %.8e, %.8e}, "
25091 "{%.8e, %.8e, %.8e, %.8e}, {%.8e, %.8e, %.8e, %.8e} "
25092 "do not match {%.8e, %.8e, %.8e, %.8e}, {%.8e, %.8e, %.8e, %.8e}, "
25093 "{%.8e, %.8e, %.8e, %.8e}.\n", i
,
25094 current
->v
[0].x
, current
->v
[0].y
, current
->v
[0].z
, current
->v
[0].w
,
25095 current
->v
[1].x
, current
->v
[1].y
, current
->v
[1].z
, current
->v
[1].w
,
25096 current
->v
[2].x
, current
->v
[2].y
, current
->v
[2].z
, current
->v
[2].w
,
25097 expected
->v
[0].x
, expected
->v
[0].y
, expected
->v
[0].z
, expected
->v
[0].w
,
25098 expected
->v
[1].x
, expected
->v
[1].y
, expected
->v
[1].z
, expected
->v
[1].w
,
25099 expected
->v
[2].x
, expected
->v
[2].y
, expected
->v
[2].z
, expected
->v
[2].w
);
25101 release_resource_readback(&rb
);
25104 static void test_quad_tessellation(void)
25109 float4 position
: SV_POSITION
;
25112 struct patch_constant_data
25114 float edges
[4] : SV_TessFactor
;
25115 float inside
[2] : SV_InsideTessFactor
;
25118 float4 tess_factors
;
25119 float2 inside_tess_factors
;
25121 patch_constant_data
patch_constant(InputPatch
<point_data
, 4> input
)
25123 patch_constant_data output
;
25125 output
.edges
[0] = tess_factors
.x
;
25126 output
.edges
[1] = tess_factors
.y
;
25127 output
.edges
[2] = tess_factors
.z
;
25128 output
.edges
[3] = tess_factors
.w
;
25129 output
.inside
[0] = inside_tess_factors
.x
;
25130 output
.inside
[1] = inside_tess_factors
.y
;
25136 [outputcontrolpoints(4)]
25137 [outputtopology("triangle_ccw")]
25138 [partitioning("integer")]
25139 [patchconstantfunc("patch_constant")]
25140 point_data
hs_main(InputPatch
<point_data
, 4> input
,
25141 uint i
: SV_OutputControlPointID
)
25147 point_data
ds_main(patch_constant_data input
,
25148 float2 tess_coord
: SV_DomainLocation
,
25149 const OutputPatch
<point_data
, 4> patch
)
25153 float4 a
= lerp(patch
[0].position
, patch
[1].position
, tess_coord
.x
);
25154 float4 b
= lerp(patch
[2].position
, patch
[3].position
, tess_coord
.x
);
25155 output
.position
= lerp(a
, b
, tess_coord
.y
);
25160 static const DWORD hs_quad_ccw_code
[] =
25162 0x43425844, 0xdf8df700, 0x58b08fb1, 0xbd23d2c3, 0xcf884094, 0x00000001, 0x000002b8, 0x00000004,
25163 0x00000030, 0x00000064, 0x00000098, 0x0000015c, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008,
25164 0x00000020, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x5449534f,
25165 0x004e4f49, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
25166 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x47534350, 0x000000bc,
25167 0x00000006, 0x00000008, 0x00000098, 0x00000000, 0x0000000b, 0x00000003, 0x00000000, 0x00000e01,
25168 0x00000098, 0x00000001, 0x0000000b, 0x00000003, 0x00000001, 0x00000e01, 0x00000098, 0x00000002,
25169 0x0000000b, 0x00000003, 0x00000002, 0x00000e01, 0x00000098, 0x00000003, 0x0000000b, 0x00000003,
25170 0x00000003, 0x00000e01, 0x000000a6, 0x00000000, 0x0000000c, 0x00000003, 0x00000004, 0x00000e01,
25171 0x000000a6, 0x00000001, 0x0000000c, 0x00000003, 0x00000005, 0x00000e01, 0x545f5653, 0x46737365,
25172 0x6f746361, 0x56530072, 0x736e495f, 0x54656469, 0x46737365, 0x6f746361, 0xabab0072, 0x58454853,
25173 0x00000154, 0x00030050, 0x00000055, 0x01000071, 0x01002093, 0x01002094, 0x01001895, 0x01000896,
25174 0x01002097, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000002, 0x01000073, 0x04000067,
25175 0x00102012, 0x00000000, 0x0000000b, 0x06000036, 0x00102012, 0x00000000, 0x0020800a, 0x00000000,
25176 0x00000000, 0x0100003e, 0x01000073, 0x04000067, 0x00102012, 0x00000001, 0x0000000c, 0x06000036,
25177 0x00102012, 0x00000001, 0x0020801a, 0x00000000, 0x00000000, 0x0100003e, 0x01000073, 0x04000067,
25178 0x00102012, 0x00000002, 0x0000000d, 0x06000036, 0x00102012, 0x00000002, 0x0020802a, 0x00000000,
25179 0x00000000, 0x0100003e, 0x01000073, 0x04000067, 0x00102012, 0x00000003, 0x0000000e, 0x06000036,
25180 0x00102012, 0x00000003, 0x0020803a, 0x00000000, 0x00000000, 0x0100003e, 0x01000073, 0x04000067,
25181 0x00102012, 0x00000004, 0x0000000f, 0x06000036, 0x00102012, 0x00000004, 0x0020800a, 0x00000000,
25182 0x00000001, 0x0100003e, 0x01000073, 0x04000067, 0x00102012, 0x00000005, 0x00000010, 0x06000036,
25183 0x00102012, 0x00000005, 0x0020801a, 0x00000000, 0x00000001, 0x0100003e,
25185 static const DWORD ds_quad_code
[] =
25187 0x43425844, 0xeb6b7631, 0x07f5469e, 0xed0cbf4a, 0x7158b3a6, 0x00000001, 0x00000284, 0x00000004,
25188 0x00000030, 0x00000064, 0x00000128, 0x0000015c, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008,
25189 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x5449534f,
25190 0x004e4f49, 0x47534350, 0x000000bc, 0x00000006, 0x00000008, 0x00000098, 0x00000000, 0x0000000b,
25191 0x00000003, 0x00000000, 0x00000001, 0x00000098, 0x00000001, 0x0000000b, 0x00000003, 0x00000001,
25192 0x00000001, 0x00000098, 0x00000002, 0x0000000b, 0x00000003, 0x00000002, 0x00000001, 0x00000098,
25193 0x00000003, 0x0000000b, 0x00000003, 0x00000003, 0x00000001, 0x000000a6, 0x00000000, 0x0000000c,
25194 0x00000003, 0x00000004, 0x00000001, 0x000000a6, 0x00000001, 0x0000000c, 0x00000003, 0x00000005,
25195 0x00000001, 0x545f5653, 0x46737365, 0x6f746361, 0x56530072, 0x736e495f, 0x54656469, 0x46737365,
25196 0x6f746361, 0xabab0072, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000,
25197 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x58454853,
25198 0x00000120, 0x00040050, 0x00000048, 0x01002093, 0x01001895, 0x0100086a, 0x0200005f, 0x0001c032,
25199 0x0400005f, 0x002190f2, 0x00000004, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
25200 0x02000068, 0x00000002, 0x0a000000, 0x001000f2, 0x00000000, 0x80219e46, 0x00000041, 0x00000002,
25201 0x00000000, 0x00219e46, 0x00000003, 0x00000000, 0x09000032, 0x001000f2, 0x00000000, 0x0001c006,
25202 0x00100e46, 0x00000000, 0x00219e46, 0x00000002, 0x00000000, 0x0a000000, 0x001000f2, 0x00000001,
25203 0x80219e46, 0x00000041, 0x00000000, 0x00000000, 0x00219e46, 0x00000001, 0x00000000, 0x09000032,
25204 0x001000f2, 0x00000001, 0x0001c006, 0x00100e46, 0x00000001, 0x00219e46, 0x00000000, 0x00000000,
25205 0x08000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x80100e46, 0x00000041, 0x00000001,
25206 0x08000032, 0x001020f2, 0x00000000, 0x0001c556, 0x00100e46, 0x00000000, 0x00100e46, 0x00000001,
25211 [outputtopology("triangle_cw")]
25214 static const DWORD hs_quad_cw_code
[] =
25216 0x43425844, 0x1ab30cc8, 0x94174771, 0x61f4cdd0, 0xa287f62c, 0x00000001, 0x000002b8, 0x00000004,
25217 0x00000030, 0x00000064, 0x00000098, 0x0000015c, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008,
25218 0x00000020, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x5449534f,
25219 0x004e4f49, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
25220 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x47534350, 0x000000bc,
25221 0x00000006, 0x00000008, 0x00000098, 0x00000000, 0x0000000b, 0x00000003, 0x00000000, 0x00000e01,
25222 0x00000098, 0x00000001, 0x0000000b, 0x00000003, 0x00000001, 0x00000e01, 0x00000098, 0x00000002,
25223 0x0000000b, 0x00000003, 0x00000002, 0x00000e01, 0x00000098, 0x00000003, 0x0000000b, 0x00000003,
25224 0x00000003, 0x00000e01, 0x000000a6, 0x00000000, 0x0000000c, 0x00000003, 0x00000004, 0x00000e01,
25225 0x000000a6, 0x00000001, 0x0000000c, 0x00000003, 0x00000005, 0x00000e01, 0x545f5653, 0x46737365,
25226 0x6f746361, 0x56530072, 0x736e495f, 0x54656469, 0x46737365, 0x6f746361, 0xabab0072, 0x58454853,
25227 0x00000154, 0x00030050, 0x00000055, 0x01000071, 0x01002093, 0x01002094, 0x01001895, 0x01000896,
25228 0x01001897, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000002, 0x01000073, 0x04000067,
25229 0x00102012, 0x00000000, 0x0000000b, 0x06000036, 0x00102012, 0x00000000, 0x0020800a, 0x00000000,
25230 0x00000000, 0x0100003e, 0x01000073, 0x04000067, 0x00102012, 0x00000001, 0x0000000c, 0x06000036,
25231 0x00102012, 0x00000001, 0x0020801a, 0x00000000, 0x00000000, 0x0100003e, 0x01000073, 0x04000067,
25232 0x00102012, 0x00000002, 0x0000000d, 0x06000036, 0x00102012, 0x00000002, 0x0020802a, 0x00000000,
25233 0x00000000, 0x0100003e, 0x01000073, 0x04000067, 0x00102012, 0x00000003, 0x0000000e, 0x06000036,
25234 0x00102012, 0x00000003, 0x0020803a, 0x00000000, 0x00000000, 0x0100003e, 0x01000073, 0x04000067,
25235 0x00102012, 0x00000004, 0x0000000f, 0x06000036, 0x00102012, 0x00000004, 0x0020800a, 0x00000000,
25236 0x00000001, 0x0100003e, 0x01000073, 0x04000067, 0x00102012, 0x00000005, 0x00000010, 0x06000036,
25237 0x00102012, 0x00000005, 0x0020801a, 0x00000000, 0x00000001, 0x0100003e,
25242 float4 pos
: SV_POSITION
;
25245 [maxvertexcount(3)]
25246 void main(triangle point_data vin
[3], inout TriangleStream
<point_data
> vout
)
25248 for (uint i
= 0; i
< 3; ++i
)
25249 vout
.Append(vin
[i
]);
25252 static const DWORD gs_code
[] =
25254 0x43425844, 0x8e49d18d, 0x6d08d6e5, 0xb7015628, 0xf9351fdd, 0x00000001, 0x00000164, 0x00000003,
25255 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
25256 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49,
25257 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
25258 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x000000c8, 0x00020040,
25259 0x00000032, 0x05000061, 0x002010f2, 0x00000003, 0x00000000, 0x00000001, 0x02000068, 0x00000001,
25260 0x0100185d, 0x0100285c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x0200005e, 0x00000003,
25261 0x05000036, 0x00100012, 0x00000000, 0x00004001, 0x00000000, 0x01000030, 0x07000050, 0x00100022,
25262 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000003, 0x03040003, 0x0010001a, 0x00000000,
25263 0x07000036, 0x001020f2, 0x00000000, 0x00a01e46, 0x0010000a, 0x00000000, 0x00000000, 0x01000013,
25264 0x0700001e, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000001, 0x01000016,
25267 static const D3D11_SO_DECLARATION_ENTRY so_declaration
[] =
25269 {0, "SV_POSITION", 0, 0, 4, 0},
25271 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
25272 static const struct vec4 green
= {0.0f
, 1.0f
, 0.0f
, 1.0f
};
25273 static const struct vec4 white
= {1.0f
, 1.0f
, 1.0f
, 1.0f
};
25274 static const BYTE zero_data
[1024];
25275 static const struct triangle expected_quad_ccw
[] =
25277 {{{-1.0f
, -1.0f
, 0.0f
, 1.0f
},
25278 { 1.0f
, -1.0f
, 0.0f
, 1.0f
},
25279 {-1.0f
, 1.0f
, 0.0f
, 1.0f
}}},
25280 {{{-1.0f
, 1.0f
, 0.0f
, 1.0f
},
25281 { 1.0f
, -1.0f
, 0.0f
, 1.0f
},
25282 { 1.0f
, 1.0f
, 0.0f
, 1.0f
}}},
25283 {{{ 0.0f
, 0.0f
, 0.0f
, 0.0f
},
25284 { 0.0f
, 0.0f
, 0.0f
, 0.0f
},
25285 { 0.0f
, 0.0f
, 0.0f
, 0.0f
}}},
25287 static const struct triangle expected_quad_cw
[] =
25289 {{{-1.0f
, -1.0f
, 0.0f
, 1.0f
},
25290 {-1.0f
, 1.0f
, 0.0f
, 1.0f
},
25291 { 1.0f
, -1.0f
, 0.0f
, 1.0f
}}},
25292 {{{-1.0f
, 1.0f
, 0.0f
, 1.0f
},
25293 { 1.0f
, 1.0f
, 0.0f
, 1.0f
},
25294 { 1.0f
, -1.0f
, 0.0f
, 1.0f
}}},
25295 {{{ 0.0f
, 0.0f
, 0.0f
, 0.0f
},
25296 { 0.0f
, 0.0f
, 0.0f
, 0.0f
},
25297 { 0.0f
, 0.0f
, 0.0f
, 0.0f
}}},
25301 float tess_factors
[4];
25302 float inside_tess_factors
[2];
25306 D3D11_QUERY_DATA_SO_STATISTICS so_statistics
;
25307 struct d3d11_test_context test_context
;
25308 ID3D11DeviceContext
*context
;
25309 ID3D11Buffer
*cb
, *so_buffer
;
25310 D3D11_QUERY_DESC query_desc
;
25311 ID3D11Asynchronous
*query
;
25312 ID3D11GeometryShader
*gs
;
25313 ID3D11DomainShader
*ds
;
25314 const UINT offset
= 0;
25315 ID3D11HullShader
*hs
;
25316 ID3D11Device
*device
;
25320 if (!init_test_context(&test_context
, &feature_level
))
25323 device
= test_context
.device
;
25324 context
= test_context
.immediate_context
;
25326 draw_color_quad(&test_context
, &white
);
25327 check_texture_color(test_context
.backbuffer
, 0xffffffff, 0);
25329 set_quad_color(&test_context
, &green
);
25330 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST
);
25332 so_buffer
= create_buffer(device
, D3D11_BIND_STREAM_OUTPUT
, sizeof(zero_data
), zero_data
);
25333 hr
= ID3D11Device_CreateGeometryShaderWithStreamOutput(device
, gs_code
, sizeof(gs_code
),
25334 so_declaration
, ARRAY_SIZE(so_declaration
), NULL
, 0, 0, NULL
, &gs
);
25335 ok(SUCCEEDED(hr
), "Failed to create geometry shader with stream output, hr %#x.\n", hr
);
25336 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
25338 for (i
= 0; i
< ARRAY_SIZE(constant
.tess_factors
); ++i
)
25339 constant
.tess_factors
[i
] = 1.0f
;
25340 for (i
= 0; i
< ARRAY_SIZE(constant
.inside_tess_factors
); ++i
)
25341 constant
.inside_tess_factors
[i
] = 1.0f
;
25342 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(constant
), &constant
);
25343 ID3D11DeviceContext_HSSetConstantBuffers(context
, 0, 1, &cb
);
25344 hr
= ID3D11Device_CreateHullShader(device
, hs_quad_ccw_code
, sizeof(hs_quad_ccw_code
), NULL
, &hs
);
25345 ok(SUCCEEDED(hr
), "Failed to create hull shader, hr %#x.\n", hr
);
25346 ID3D11DeviceContext_HSSetShader(context
, hs
, NULL
, 0);
25347 hr
= ID3D11Device_CreateDomainShader(device
, ds_quad_code
, sizeof(ds_quad_code
), NULL
, &ds
);
25348 ok(SUCCEEDED(hr
), "Failed to create domain shader, hr %#x.\n", hr
);
25349 ID3D11DeviceContext_DSSetShader(context
, ds
, NULL
, 0);
25351 ID3D11DeviceContext_SOSetTargets(context
, 1, &so_buffer
, &offset
);
25352 ID3D11DeviceContext_Draw(context
, 4, 0);
25353 check_texture_color(test_context
.backbuffer
, 0xffffffff, 0);
25354 ID3D11DeviceContext_SOSetTargets(context
, 0, NULL
, NULL
);
25355 check_triangles(so_buffer
, expected_quad_ccw
, ARRAY_SIZE(expected_quad_ccw
));
25357 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)so_buffer
, 0, NULL
, zero_data
, 0, 0);
25359 ID3D11HullShader_Release(hs
);
25360 hr
= ID3D11Device_CreateHullShader(device
, hs_quad_cw_code
, sizeof(hs_quad_cw_code
), NULL
, &hs
);
25361 ok(SUCCEEDED(hr
), "Failed to create hull shader, hr %#x.\n", hr
);
25362 ID3D11DeviceContext_HSSetShader(context
, hs
, NULL
, 0);
25364 ID3D11DeviceContext_SOSetTargets(context
, 1, &so_buffer
, &offset
);
25365 ID3D11DeviceContext_Draw(context
, 4, 0);
25366 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
25367 ID3D11DeviceContext_SOSetTargets(context
, 0, NULL
, NULL
);
25368 check_triangles(so_buffer
, expected_quad_cw
, ARRAY_SIZE(expected_quad_cw
));
25370 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)so_buffer
, 0, NULL
, zero_data
, 0, 0);
25372 ID3D11DeviceContext_SOSetTargets(context
, 1, &so_buffer
, &offset
);
25373 query_desc
.Query
= D3D11_QUERY_SO_STATISTICS_STREAM0
;
25374 query_desc
.MiscFlags
= 0;
25375 hr
= ID3D11Device_CreateQuery(device
, &query_desc
, (ID3D11Query
**)&query
);
25376 ok(hr
== S_OK
, "Failed to create query, hr %#x.\n", hr
);
25377 ID3D11DeviceContext_Begin(context
, query
);
25379 set_quad_color(&test_context
, &white
);
25380 for (i
= 0; i
< ARRAY_SIZE(constant
.tess_factors
); ++i
)
25381 constant
.tess_factors
[i
] = 2.0f
;
25382 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
25383 ID3D11DeviceContext_Draw(context
, 4, 0);
25384 check_texture_color(test_context
.backbuffer
, 0xffffffff, 0);
25386 set_quad_color(&test_context
, &green
);
25387 constant
.tess_factors
[0] = 0.0f
; /* A patch is discarded. */
25388 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
25389 ID3D11DeviceContext_Draw(context
, 4, 0);
25390 check_texture_color(test_context
.backbuffer
, 0xffffffff, 0);
25392 ID3D11DeviceContext_End(context
, query
);
25393 get_query_data(context
, query
, &so_statistics
, sizeof(so_statistics
));
25394 ok(so_statistics
.NumPrimitivesWritten
== 8, "Got unexpected primitives written %u.\n",
25395 (unsigned int)so_statistics
.NumPrimitivesWritten
);
25396 ok(so_statistics
.PrimitivesStorageNeeded
== 8, "Got unexpected primitives storage needed %u.\n",
25397 (unsigned int)so_statistics
.PrimitivesStorageNeeded
);
25398 ID3D11DeviceContext_Begin(context
, query
);
25400 constant
.tess_factors
[0] = 5.0f
;
25401 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
25402 ID3D11DeviceContext_Draw(context
, 4, 0);
25403 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
25405 ID3D11DeviceContext_End(context
, query
);
25406 get_query_data(context
, query
, &so_statistics
, sizeof(so_statistics
));
25407 ok(so_statistics
.NumPrimitivesWritten
== 11, "Got unexpected primitives written %u.\n",
25408 (unsigned int)so_statistics
.NumPrimitivesWritten
);
25409 ok(so_statistics
.PrimitivesStorageNeeded
== 11, "Got unexpected primitives storage needed %u.\n",
25410 (unsigned int)so_statistics
.PrimitivesStorageNeeded
);
25411 ID3D11Asynchronous_Release(query
);
25413 ID3D11Buffer_Release(so_buffer
);
25414 ID3D11GeometryShader_Release(gs
);
25415 ID3D11DomainShader_Release(ds
);
25416 ID3D11HullShader_Release(hs
);
25417 ID3D11Buffer_Release(cb
);
25418 release_test_context(&test_context
);
25421 #define check_so_desc(a, b, c, d, e, f, g, h) check_so_desc_(__LINE__, a, b, c, d, e, f, g, h)
25422 static void check_so_desc_(unsigned int line
, ID3D11Device
*device
,
25423 const DWORD
*code
, size_t code_size
, const D3D11_SO_DECLARATION_ENTRY
*entry
,
25424 unsigned int entry_count
, unsigned int *strides
, unsigned int stride_count
,
25425 unsigned int rasterizer_stream
)
25427 ID3D11GeometryShader
*gs
;
25430 hr
= ID3D11Device_CreateGeometryShaderWithStreamOutput(device
, code
, code_size
,
25431 entry
, entry_count
, strides
, stride_count
, rasterizer_stream
, NULL
, &gs
);
25432 ok_(__FILE__
, line
)(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
25434 ID3D11GeometryShader_Release(gs
);
25437 #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)
25438 static void check_invalid_so_desc_(unsigned int line
, ID3D11Device
*device
,
25439 const DWORD
*code
, size_t code_size
, const D3D11_SO_DECLARATION_ENTRY
*entry
,
25440 unsigned int entry_count
, unsigned int *strides
, unsigned int stride_count
,
25441 unsigned int rasterizer_stream
)
25443 ID3D11GeometryShader
*gs
= (ID3D11GeometryShader
*)0xdeadbeef;
25446 hr
= ID3D11Device_CreateGeometryShaderWithStreamOutput(device
, code
, code_size
,
25447 entry
, entry_count
, strides
, stride_count
, rasterizer_stream
, NULL
, &gs
);
25448 ok_(__FILE__
, line
)(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
25449 ok_(__FILE__
, line
)(!gs
, "Got unexpected geometry shader %p.\n", gs
);
25451 ID3D11GeometryShader_Release(gs
);
25454 static void test_stream_output(void)
25456 UINT stride
[D3D11_SO_BUFFER_SLOT_COUNT
];
25457 struct d3d11_test_context test_context
;
25458 unsigned int i
, count
;
25459 ID3D11Device
*device
;
25461 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
25462 static const DWORD vs_code
[] =
25467 float4 position
: SV_Position
;
25468 float4 attrib1
: ATTRIB1
;
25469 float3 attrib2
: attrib2
;
25470 float2 attrib3
: ATTriB3
;
25471 float attrib4
: ATTRIB4
;
25474 void main(in data i
, out data o
)
25479 0x43425844, 0x3f5b621f, 0x8f390786, 0x7235c8d6, 0xc1181ad3, 0x00000001, 0x00000278, 0x00000003,
25480 0x0000002c, 0x000000d8, 0x00000184, 0x4e475349, 0x000000a4, 0x00000005, 0x00000008, 0x00000080,
25481 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x0000008c, 0x00000001, 0x00000000,
25482 0x00000003, 0x00000001, 0x00000f0f, 0x00000093, 0x00000002, 0x00000000, 0x00000003, 0x00000002,
25483 0x00000707, 0x0000009a, 0x00000003, 0x00000000, 0x00000003, 0x00000003, 0x00000303, 0x0000008c,
25484 0x00000004, 0x00000000, 0x00000003, 0x00000004, 0x00000101, 0x505f5653, 0x7469736f, 0x006e6f69,
25485 0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254, 0xababab00, 0x4e47534f, 0x000000a4,
25486 0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
25487 0x0000008c, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x00000093, 0x00000002,
25488 0x00000000, 0x00000003, 0x00000002, 0x00000807, 0x0000009a, 0x00000003, 0x00000000, 0x00000003,
25489 0x00000003, 0x00000c03, 0x0000008c, 0x00000004, 0x00000000, 0x00000003, 0x00000003, 0x00000b04,
25490 0x505f5653, 0x7469736f, 0x006e6f69, 0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254,
25491 0xababab00, 0x52444853, 0x000000ec, 0x00010040, 0x0000003b, 0x0300005f, 0x001010f2, 0x00000000,
25492 0x0300005f, 0x001010f2, 0x00000001, 0x0300005f, 0x00101072, 0x00000002, 0x0300005f, 0x00101032,
25493 0x00000003, 0x0300005f, 0x00101012, 0x00000004, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
25494 0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x00102072, 0x00000002, 0x03000065, 0x00102032,
25495 0x00000003, 0x03000065, 0x00102042, 0x00000003, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46,
25496 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001, 0x05000036, 0x00102072,
25497 0x00000002, 0x00101246, 0x00000002, 0x05000036, 0x00102032, 0x00000003, 0x00101046, 0x00000003,
25498 0x05000036, 0x00102042, 0x00000003, 0x0010100a, 0x00000004, 0x0100003e,
25500 static const DWORD gs_code
[] =
25505 float4 position
: SV_Position
;
25506 float4 attrib1
: ATTRIB1
;
25507 float3 attrib2
: attrib2
;
25508 float2 attrib3
: ATTriB3
;
25509 float attrib4
: ATTRIB4
;
25512 [maxvertexcount(1)]
25513 void main(point data i
[1], inout PointStream
<data
> o
)
25518 0x43425844, 0x59c61884, 0x3eef167b, 0x82618c33, 0x243cb630, 0x00000001, 0x000002a0, 0x00000003,
25519 0x0000002c, 0x000000d8, 0x00000184, 0x4e475349, 0x000000a4, 0x00000005, 0x00000008, 0x00000080,
25520 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x0000008c, 0x00000001, 0x00000000,
25521 0x00000003, 0x00000001, 0x00000f0f, 0x00000093, 0x00000002, 0x00000000, 0x00000003, 0x00000002,
25522 0x00000707, 0x0000009a, 0x00000003, 0x00000000, 0x00000003, 0x00000003, 0x00000303, 0x0000008c,
25523 0x00000004, 0x00000000, 0x00000003, 0x00000003, 0x00000404, 0x505f5653, 0x7469736f, 0x006e6f69,
25524 0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254, 0xababab00, 0x4e47534f, 0x000000a4,
25525 0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
25526 0x0000008c, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x00000093, 0x00000002,
25527 0x00000000, 0x00000003, 0x00000002, 0x00000807, 0x0000009a, 0x00000003, 0x00000000, 0x00000003,
25528 0x00000003, 0x00000c03, 0x0000008c, 0x00000004, 0x00000000, 0x00000003, 0x00000003, 0x00000b04,
25529 0x505f5653, 0x7469736f, 0x006e6f69, 0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254,
25530 0xababab00, 0x52444853, 0x00000114, 0x00020040, 0x00000045, 0x05000061, 0x002010f2, 0x00000001,
25531 0x00000000, 0x00000001, 0x0400005f, 0x002010f2, 0x00000001, 0x00000001, 0x0400005f, 0x00201072,
25532 0x00000001, 0x00000002, 0x0400005f, 0x00201032, 0x00000001, 0x00000003, 0x0400005f, 0x00201042,
25533 0x00000001, 0x00000003, 0x0100085d, 0x0100085c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
25534 0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x00102072, 0x00000002, 0x03000065, 0x00102032,
25535 0x00000003, 0x03000065, 0x00102042, 0x00000003, 0x0200005e, 0x00000001, 0x06000036, 0x001020f2,
25536 0x00000000, 0x00201e46, 0x00000000, 0x00000000, 0x06000036, 0x001020f2, 0x00000001, 0x00201e46,
25537 0x00000000, 0x00000001, 0x06000036, 0x00102072, 0x00000002, 0x00201246, 0x00000000, 0x00000002,
25538 0x06000036, 0x00102072, 0x00000003, 0x00201246, 0x00000000, 0x00000003, 0x01000013, 0x0100003e,
25540 static const D3D11_SO_DECLARATION_ENTRY so_declaration
[] =
25542 {0, "SV_Position", 0, 0, 4, 0},
25544 static const D3D11_SO_DECLARATION_ENTRY invalid_gap_declaration
[] =
25546 {0, "SV_Position", 0, 0, 4, 0},
25547 {0, NULL
, 0, 0, 0, 0},
25549 static const D3D11_SO_DECLARATION_ENTRY valid_so_declarations
[][12] =
25551 /* SemanticName and SemanticIndex */
25553 {0, "sv_position", 0, 0, 4, 0},
25554 {0, "attrib", 1, 0, 4, 0},
25557 {0, "sv_position", 0, 0, 4, 0},
25558 {0, "ATTRIB", 1, 0, 4, 0},
25562 {0, "SV_POSITION", 0, 0, 4, 0},
25563 {0, NULL
, 0, 0, 8, 0},
25564 {0, "ATTRIB", 1, 0, 4, 0},
25567 {0, "SV_POSITION", 0, 0, 4, 0},
25568 {0, NULL
, 0, 0, 4, 0},
25569 {0, NULL
, 0, 0, 4, 0},
25570 {0, "ATTRIB", 1, 0, 4, 0},
25572 /* ComponentCount */
25574 {0, "ATTRIB", 1, 0, 4, 0},
25577 {0, "ATTRIB", 2, 0, 3, 0},
25580 {0, "ATTRIB", 3, 0, 2, 0},
25583 {0, "ATTRIB", 4, 0, 1, 0},
25585 /* ComponentIndex */
25587 {0, "ATTRIB", 1, 1, 3, 0},
25590 {0, "ATTRIB", 1, 2, 2, 0},
25593 {0, "ATTRIB", 1, 3, 1, 0},
25596 {0, "ATTRIB", 3, 1, 1, 0},
25600 {0, "attrib", 1, 0, 4, 0},
25603 {0, "attrib", 1, 0, 4, 1},
25606 {0, "attrib", 1, 0, 4, 2},
25609 {0, "attrib", 1, 0, 4, 3},
25612 {0, "attrib", 1, 0, 4, 0},
25613 {0, "attrib", 2, 0, 3, 1},
25614 {0, NULL
, 0, 0, 1, 1},
25615 {0, "attrib", 3, 0, 2, 2},
25616 {0, NULL
, 0, 0, 2, 2},
25617 {0, "attrib", 4, 0, 1, 3},
25618 {0, NULL
, 0, 0, 7, 3},
25621 {0, "attrib", 1, 0, 4, 0},
25622 {0, "attrib", 2, 0, 3, 1},
25623 {0, NULL
, 0, 0, 1, 1},
25624 {0, "attrib", 3, 0, 2, 2},
25625 {0, NULL
, 0, 0, 1, 2},
25626 {0, NULL
, 0, 0, 1, 2},
25627 {0, "attrib", 4, 0, 1, 3},
25628 {0, NULL
, 0, 0, 3, 3},
25629 {0, NULL
, 0, 0, 1, 3},
25630 {0, NULL
, 0, 0, 1, 3},
25631 {0, NULL
, 0, 0, 1, 3},
25632 {0, NULL
, 0, 0, 1, 3},
25635 {0, "attrib", 1, 0, 4, 0},
25636 {0, "attrib", 2, 0, 3, 0},
25637 {0, "attrib", 3, 0, 2, 0},
25638 {0, NULL
, 0, 0, 1, 0},
25639 {0, "attrib", 4, 0, 1, 0},
25642 {0, "attrib", 1, 0, 4, 0},
25643 {0, "attrib", 2, 0, 3, 0},
25644 {0, "attrib", 3, 0, 2, 3},
25645 {0, NULL
, 0, 0, 1, 3},
25646 {0, "attrib", 4, 0, 1, 3},
25648 /* Multiple occurrences of the same output */
25650 {0, "ATTRIB", 1, 0, 2, 0},
25651 {0, "ATTRIB", 1, 2, 2, 1},
25654 {0, "ATTRIB", 1, 0, 1, 0},
25655 {0, "ATTRIB", 1, 1, 3, 0},
25658 static const D3D11_SO_DECLARATION_ENTRY invalid_so_declarations
[][12] =
25660 /* SemanticName and SemanticIndex */
25662 {0, "SV_Position", 0, 0, 4, 0},
25663 {0, "ATTRIB", 0, 0, 4, 0},
25666 {0, "sv_position", 0, 0, 4, 0},
25667 {0, "ATTRIB_", 1, 0, 4, 0},
25671 {0, "SV_POSITION", 0, 0, 4, 0},
25672 {0, NULL
, 0, 1, 8, 0},
25673 {0, "ATTRIB", 1, 0, 4, 0},
25676 {0, "SV_POSITION", 0, 0, 4, 0},
25677 {0, NULL
, 1, 0, 8, 0},
25678 {0, "ATTRIB", 1, 0, 4, 0},
25680 /* Buffer stride */
25682 {0, "SV_POSITION", 0, 0, 4, 0},
25683 {0, NULL
, 0, 0, 8, 0},
25684 {0, NULL
, 0, 0, 8, 0},
25685 {0, "ATTRIB", 1, 0, 4, 0},
25687 /* ComponentCount */
25689 {0, "ATTRIB", 2, 0, 5, 0},
25692 {0, "ATTRIB", 2, 0, 4, 0},
25695 {0, "ATTRIB", 3, 0, 3, 0},
25698 {0, "ATTRIB", 4, 0, 2, 0},
25700 /* ComponentIndex */
25702 {0, "ATTRIB", 1, 1, 4, 0},
25705 {0, "ATTRIB", 1, 2, 3, 0},
25708 {0, "ATTRIB", 1, 3, 2, 0},
25711 {0, "ATTRIB", 1, 4, 0, 0},
25714 {0, "ATTRIB", 1, 4, 1, 0},
25717 {0, "ATTRIB", 3, 2, 1, 0},
25720 {0, "ATTRIB", 3, 2, 0, 0},
25724 {0, "attrib", 1, 0, 4, 4},
25727 {0, "attrib", 1, 0, 4, 4},
25730 {0, "attrib", 1, 0, 4, 4},
25733 {0, "attrib", 1, 0, 4, 4},
25736 {0, "attrib", 1, 0, 4, 0},
25737 {0, "attrib", 2, 0, 3, 1},
25738 {0, NULL
, 0, 0, 1, 1},
25739 {0, "attrib", 3, 0, 2, 2},
25740 {0, NULL
, 0, 0, 2, 2},
25741 {0, "attrib", 4, 0, 1, 3},
25742 {0, NULL
, 0, 0, 3, 4},
25745 {0, "attrib", 1, 0, 4, 0},
25746 {0, "attrib", 2, 0, 3, 0},
25747 {0, "attrib", 3, 0, 2, 0},
25748 {0, NULL
, 0, 0, 1, 0},
25749 {0, "attrib", 4, 0, 1, 0},
25750 {0, NULL
, 0, 0, 3, 3},
25751 {0, NULL
, 0, 0, 1, 3},
25752 {0, NULL
, 0, 0, 1, 3},
25753 {0, NULL
, 0, 0, 1, 3},
25754 {0, NULL
, 0, 0, 1, 3},
25757 {0, "attrib", 1, 0, 4, 0},
25758 {0, NULL
, 0, 0, 3, 1},
25759 {0, NULL
, 0, 0, 1, 1},
25760 {0, NULL
, 0, 0, 1, 2},
25761 {0, "attrib", 2, 0, 3, 3},
25762 {0, NULL
, 0, 0, 1, 3},
25765 {0, "attrib", 2, 0, 3, 3},
25766 {0, NULL
, 0, 0, 3, 1},
25767 {0, NULL
, 0, 0, 1, 3},
25768 {0, "attrib", 1, 0, 4, 0},
25769 {0, NULL
, 0, 0, 1, 2},
25770 {0, NULL
, 0, 0, 1, 1},
25774 {1, "attrib", 1, 0, 4, 0},
25777 {4, "attrib", 1, 0, 4, 0},
25779 /* Multiple occurrences of the same output */
25781 {0, "ATTRIB", 1, 0, 4, 0},
25782 {0, "ATTRIB", 1, 0, 4, 1},
25785 {0, "ATTRIB", 1, 0, 4, 0},
25786 {0, "ATTRIB", 1, 0, 3, 0},
25790 if (!init_test_context(&test_context
, &feature_level
))
25793 device
= test_context
.device
;
25795 for (i
= 0; i
< ARRAY_SIZE(stride
); ++i
)
25798 check_so_desc(device
, gs_code
, sizeof(gs_code
), NULL
, 0, NULL
, 0, D3D11_SO_NO_RASTERIZED_STREAM
);
25799 check_so_desc(device
, gs_code
, sizeof(gs_code
), NULL
, 0, stride
, 1, D3D11_SO_NO_RASTERIZED_STREAM
);
25800 check_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
25801 NULL
, 0, D3D11_SO_NO_RASTERIZED_STREAM
);
25802 check_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
25803 stride
, 1, D3D11_SO_NO_RASTERIZED_STREAM
);
25805 check_so_desc(device
, vs_code
, sizeof(vs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
25806 NULL
, 0, D3D11_SO_NO_RASTERIZED_STREAM
);
25807 check_so_desc(device
, vs_code
, sizeof(vs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
25808 stride
, 1, D3D11_SO_NO_RASTERIZED_STREAM
);
25810 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, 0,
25811 stride
, 1, D3D11_SO_NO_RASTERIZED_STREAM
);
25812 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
),
25813 invalid_gap_declaration
, ARRAY_SIZE(invalid_gap_declaration
),
25814 stride
, 1, D3D11_SO_NO_RASTERIZED_STREAM
);
25816 check_invalid_so_desc(device
, vs_code
, sizeof(vs_code
), so_declaration
, 0,
25817 NULL
, 0, D3D11_SO_NO_RASTERIZED_STREAM
);
25818 check_invalid_so_desc(device
, vs_code
, sizeof(vs_code
), NULL
, 0,
25819 NULL
, 0, D3D11_SO_NO_RASTERIZED_STREAM
);
25821 for (i
= 0; i
< ARRAY_SIZE(valid_so_declarations
); ++i
)
25823 unsigned int max_output_slot
= 0;
25824 for (count
= 0; count
< ARRAY_SIZE(valid_so_declarations
[i
]); ++count
)
25826 const D3D11_SO_DECLARATION_ENTRY
*e
= &valid_so_declarations
[i
][count
];
25827 max_output_slot
= max(max_output_slot
, e
->OutputSlot
);
25828 if (!e
->Stream
&& !e
->SemanticName
&& !e
->SemanticIndex
&& !e
->ComponentCount
)
25832 /* Buffer strides are required for all buffers. */
25833 if (!max_output_slot
)
25835 check_so_desc(device
, gs_code
, sizeof(gs_code
), valid_so_declarations
[i
], count
,
25836 NULL
, 0, D3D11_SO_NO_RASTERIZED_STREAM
);
25837 check_so_desc(device
, gs_code
, sizeof(gs_code
), valid_so_declarations
[i
], count
,
25838 stride
, 1, D3D11_SO_NO_RASTERIZED_STREAM
);
25839 check_so_desc(device
, gs_code
, sizeof(gs_code
), valid_so_declarations
[i
], count
,
25840 stride
, 2, D3D11_SO_NO_RASTERIZED_STREAM
);
25841 check_so_desc(device
, gs_code
, sizeof(gs_code
), valid_so_declarations
[i
], count
,
25842 stride
, 3, D3D11_SO_NO_RASTERIZED_STREAM
);
25843 check_so_desc(device
, gs_code
, sizeof(gs_code
), valid_so_declarations
[i
], count
,
25844 stride
, 4, D3D11_SO_NO_RASTERIZED_STREAM
);
25848 check_so_desc(device
, gs_code
, sizeof(gs_code
), valid_so_declarations
[i
], count
,
25849 NULL
, 0, D3D11_SO_NO_RASTERIZED_STREAM
);
25850 check_so_desc(device
, gs_code
, sizeof(gs_code
), valid_so_declarations
[i
], count
,
25851 stride
, max_output_slot
+ 1, D3D11_SO_NO_RASTERIZED_STREAM
);
25855 for (i
= 0; i
< ARRAY_SIZE(invalid_so_declarations
); ++i
)
25857 for (count
= 0; count
< ARRAY_SIZE(invalid_so_declarations
[i
]); ++count
)
25859 const D3D11_SO_DECLARATION_ENTRY
*e
= &invalid_so_declarations
[i
][count
];
25860 if (!e
->Stream
&& !e
->SemanticName
&& !e
->SemanticIndex
&& !e
->ComponentCount
)
25864 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), invalid_so_declarations
[i
], count
,
25865 stride
, 1, D3D11_SO_NO_RASTERIZED_STREAM
);
25866 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), invalid_so_declarations
[i
], count
,
25867 stride
, 2, D3D11_SO_NO_RASTERIZED_STREAM
);
25868 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), invalid_so_declarations
[i
], count
,
25869 stride
, 3, D3D11_SO_NO_RASTERIZED_STREAM
);
25870 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), invalid_so_declarations
[i
], count
,
25871 stride
, 4, D3D11_SO_NO_RASTERIZED_STREAM
);
25874 /* Buffer strides */
25876 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
25877 &stride
[1], 1, D3D11_SO_NO_RASTERIZED_STREAM
);
25878 check_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
25879 stride
, 2, D3D11_SO_NO_RASTERIZED_STREAM
);
25881 check_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
25882 stride
, 2, D3D11_SO_NO_RASTERIZED_STREAM
);
25884 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
25885 stride
, 1, D3D11_SO_NO_RASTERIZED_STREAM
);
25887 /* Rasterizer stream */
25888 for (i
= 0; i
< D3D11_SO_STREAM_COUNT
; ++i
)
25889 check_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
), NULL
, 0, i
);
25890 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
25891 NULL
, 0, D3D11_SO_STREAM_COUNT
);
25893 release_test_context(&test_context
);
25896 static void test_fl10_stream_output_desc(void)
25898 UINT stride
[D3D11_SO_BUFFER_SLOT_COUNT
];
25899 struct d3d11_test_context test_context
;
25900 unsigned int i
, count
;
25901 ID3D11Device
*device
;
25903 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_10_0
;
25904 static const DWORD vs_code
[] =
25909 float4 position
: SV_Position
;
25910 float4 attrib1
: ATTRIB1
;
25911 float3 attrib2
: attrib2
;
25912 float2 attrib3
: ATTriB3
;
25913 float attrib4
: ATTRIB4
;
25916 void main(in data i
, out data o
)
25921 0x43425844, 0x3f5b621f, 0x8f390786, 0x7235c8d6, 0xc1181ad3, 0x00000001, 0x00000278, 0x00000003,
25922 0x0000002c, 0x000000d8, 0x00000184, 0x4e475349, 0x000000a4, 0x00000005, 0x00000008, 0x00000080,
25923 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x0000008c, 0x00000001, 0x00000000,
25924 0x00000003, 0x00000001, 0x00000f0f, 0x00000093, 0x00000002, 0x00000000, 0x00000003, 0x00000002,
25925 0x00000707, 0x0000009a, 0x00000003, 0x00000000, 0x00000003, 0x00000003, 0x00000303, 0x0000008c,
25926 0x00000004, 0x00000000, 0x00000003, 0x00000004, 0x00000101, 0x505f5653, 0x7469736f, 0x006e6f69,
25927 0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254, 0xababab00, 0x4e47534f, 0x000000a4,
25928 0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
25929 0x0000008c, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x00000093, 0x00000002,
25930 0x00000000, 0x00000003, 0x00000002, 0x00000807, 0x0000009a, 0x00000003, 0x00000000, 0x00000003,
25931 0x00000003, 0x00000c03, 0x0000008c, 0x00000004, 0x00000000, 0x00000003, 0x00000003, 0x00000b04,
25932 0x505f5653, 0x7469736f, 0x006e6f69, 0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254,
25933 0xababab00, 0x52444853, 0x000000ec, 0x00010040, 0x0000003b, 0x0300005f, 0x001010f2, 0x00000000,
25934 0x0300005f, 0x001010f2, 0x00000001, 0x0300005f, 0x00101072, 0x00000002, 0x0300005f, 0x00101032,
25935 0x00000003, 0x0300005f, 0x00101012, 0x00000004, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
25936 0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x00102072, 0x00000002, 0x03000065, 0x00102032,
25937 0x00000003, 0x03000065, 0x00102042, 0x00000003, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46,
25938 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001, 0x05000036, 0x00102072,
25939 0x00000002, 0x00101246, 0x00000002, 0x05000036, 0x00102032, 0x00000003, 0x00101046, 0x00000003,
25940 0x05000036, 0x00102042, 0x00000003, 0x0010100a, 0x00000004, 0x0100003e,
25942 static const DWORD gs_code
[] =
25947 float4 position
: SV_Position
;
25948 float4 attrib1
: ATTRIB1
;
25949 float3 attrib2
: attrib2
;
25950 float2 attrib3
: ATTriB3
;
25951 float attrib4
: ATTRIB4
;
25954 [maxvertexcount(1)]
25955 void main(point data i
[1], inout PointStream
<data
> o
)
25960 0x43425844, 0x59c61884, 0x3eef167b, 0x82618c33, 0x243cb630, 0x00000001, 0x000002a0, 0x00000003,
25961 0x0000002c, 0x000000d8, 0x00000184, 0x4e475349, 0x000000a4, 0x00000005, 0x00000008, 0x00000080,
25962 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x0000008c, 0x00000001, 0x00000000,
25963 0x00000003, 0x00000001, 0x00000f0f, 0x00000093, 0x00000002, 0x00000000, 0x00000003, 0x00000002,
25964 0x00000707, 0x0000009a, 0x00000003, 0x00000000, 0x00000003, 0x00000003, 0x00000303, 0x0000008c,
25965 0x00000004, 0x00000000, 0x00000003, 0x00000003, 0x00000404, 0x505f5653, 0x7469736f, 0x006e6f69,
25966 0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254, 0xababab00, 0x4e47534f, 0x000000a4,
25967 0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
25968 0x0000008c, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x00000093, 0x00000002,
25969 0x00000000, 0x00000003, 0x00000002, 0x00000807, 0x0000009a, 0x00000003, 0x00000000, 0x00000003,
25970 0x00000003, 0x00000c03, 0x0000008c, 0x00000004, 0x00000000, 0x00000003, 0x00000003, 0x00000b04,
25971 0x505f5653, 0x7469736f, 0x006e6f69, 0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254,
25972 0xababab00, 0x52444853, 0x00000114, 0x00020040, 0x00000045, 0x05000061, 0x002010f2, 0x00000001,
25973 0x00000000, 0x00000001, 0x0400005f, 0x002010f2, 0x00000001, 0x00000001, 0x0400005f, 0x00201072,
25974 0x00000001, 0x00000002, 0x0400005f, 0x00201032, 0x00000001, 0x00000003, 0x0400005f, 0x00201042,
25975 0x00000001, 0x00000003, 0x0100085d, 0x0100085c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
25976 0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x00102072, 0x00000002, 0x03000065, 0x00102032,
25977 0x00000003, 0x03000065, 0x00102042, 0x00000003, 0x0200005e, 0x00000001, 0x06000036, 0x001020f2,
25978 0x00000000, 0x00201e46, 0x00000000, 0x00000000, 0x06000036, 0x001020f2, 0x00000001, 0x00201e46,
25979 0x00000000, 0x00000001, 0x06000036, 0x00102072, 0x00000002, 0x00201246, 0x00000000, 0x00000002,
25980 0x06000036, 0x00102072, 0x00000003, 0x00201246, 0x00000000, 0x00000003, 0x01000013, 0x0100003e,
25982 static const D3D11_SO_DECLARATION_ENTRY so_declaration
[] =
25984 {0, "SV_Position", 0, 0, 4, 0},
25986 static const D3D11_SO_DECLARATION_ENTRY invalid_gap_declaration
[] =
25988 {0, "SV_Position", 0, 0, 4, 0},
25989 {0, NULL
, 0, 0, 0, 0},
25991 static const D3D11_SO_DECLARATION_ENTRY valid_so_declarations
[][12] =
25995 {0, "SV_POSITION", 0, 0, 4, 0},
25996 {0, NULL
, 0, 0, 8, 0},
25997 {0, "ATTRIB", 1, 0, 4, 0},
26000 {0, "SV_POSITION", 0, 0, 4, 0},
26001 {0, NULL
, 0, 0, 4, 0},
26002 {0, NULL
, 0, 0, 4, 0},
26003 {0, "ATTRIB", 1, 0, 4, 0},
26007 {0, "attrib", 1, 0, 4, 0},
26008 {0, "attrib", 2, 0, 3, 0},
26009 {0, "attrib", 3, 0, 2, 0},
26010 {0, "attrib", 4, 0, 1, 0},
26013 {0, "attrib", 1, 0, 4, 0},
26014 {0, "attrib", 2, 0, 3, 1},
26015 {0, "attrib", 3, 0, 2, 2},
26016 {0, "attrib", 4, 0, 1, 3},
26019 {0, "attrib", 1, 0, 4, 0},
26020 {0, "attrib", 2, 0, 3, 3},
26023 {0, "attrib", 1, 0, 4, 0},
26024 {0, "attrib", 2, 0, 3, 0},
26025 {0, "attrib", 3, 0, 2, 0},
26026 {0, NULL
, 0, 0, 1, 0},
26027 {0, "attrib", 4, 0, 1, 0},
26029 /* Multiple occurrences of the same output */
26031 {0, "ATTRIB", 1, 0, 2, 0},
26032 {0, "ATTRIB", 1, 2, 2, 1},
26035 {0, "ATTRIB", 1, 0, 1, 0},
26036 {0, "ATTRIB", 1, 1, 3, 0},
26039 static const D3D11_SO_DECLARATION_ENTRY invalid_so_declarations
[][12] =
26043 {0, "attrib", 1, 0, 4, 0},
26044 {0, NULL
, 0, 0, 4, 0},
26045 {0, "attrib", 4, 0, 1, 3},
26048 {0, "attrib", 1, 0, 4, 0},
26049 {0, NULL
, 0, 0, 4, 0},
26050 {0, NULL
, 0, 0, 4, 0},
26051 {0, "attrib", 4, 0, 1, 3},
26054 {0, "attrib", 1, 0, 4, 0},
26055 {0, "attrib", 2, 0, 3, 0},
26056 {0, "attrib", 3, 0, 2, 0},
26057 {0, "attrib", 4, 0, 1, 1},
26060 {0, "attrib", 1, 0, 4, 0},
26061 {0, "attrib", 2, 0, 3, 0},
26062 {0, "attrib", 3, 0, 2, 3},
26063 {0, NULL
, 0, 0, 1, 3},
26064 {0, "attrib", 4, 0, 1, 3},
26067 {0, "attrib", 1, 0, 4, 0},
26068 {0, "attrib", 1, 0, 3, 1},
26069 {0, "attrib", 1, 0, 2, 2},
26070 {0, "attrib", 1, 0, 1, 3},
26071 {0, NULL
, 0, 0, 3, 3},
26075 if (!init_test_context(&test_context
, &feature_level
))
26078 device
= test_context
.device
;
26080 for (i
= 0; i
< ARRAY_SIZE(stride
); ++i
)
26083 check_so_desc(device
, gs_code
, sizeof(gs_code
), NULL
, 0, NULL
, 0, 0);
26084 todo_wine
check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), NULL
, 0, stride
, 1, 0);
26085 check_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
), NULL
, 0, 0);
26086 check_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
), stride
, 1, 0);
26088 check_so_desc(device
, vs_code
, sizeof(vs_code
), so_declaration
, ARRAY_SIZE(so_declaration
), NULL
, 0, 0);
26089 check_so_desc(device
, vs_code
, sizeof(vs_code
), so_declaration
, ARRAY_SIZE(so_declaration
), stride
, 1, 0);
26091 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, 0, stride
, 1, 0);
26092 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
),
26093 invalid_gap_declaration
, ARRAY_SIZE(invalid_gap_declaration
), stride
, 1, 0);
26094 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
),
26095 invalid_gap_declaration
, ARRAY_SIZE(invalid_gap_declaration
), NULL
, 0, 0);
26097 check_invalid_so_desc(device
, vs_code
, sizeof(vs_code
), so_declaration
, 0, NULL
, 0, 0);
26098 check_invalid_so_desc(device
, vs_code
, sizeof(vs_code
), NULL
, 0, NULL
, 0, 0);
26100 for (i
= 0; i
< ARRAY_SIZE(valid_so_declarations
); ++i
)
26102 for (count
= 0; count
< ARRAY_SIZE(valid_so_declarations
[i
]); ++count
)
26104 const D3D11_SO_DECLARATION_ENTRY
*e
= &valid_so_declarations
[i
][count
];
26105 if (!e
->Stream
&& !e
->SemanticName
&& !e
->SemanticIndex
&& !e
->ComponentCount
)
26109 check_so_desc(device
, gs_code
, sizeof(gs_code
), valid_so_declarations
[i
], count
, NULL
, 0, 0);
26112 for (i
= 0; i
< ARRAY_SIZE(invalid_so_declarations
); ++i
)
26114 for (count
= 0; count
< ARRAY_SIZE(invalid_so_declarations
[i
]); ++count
)
26116 const D3D11_SO_DECLARATION_ENTRY
*e
= &invalid_so_declarations
[i
][count
];
26117 if (!e
->Stream
&& !e
->SemanticName
&& !e
->SemanticIndex
&& !e
->ComponentCount
)
26121 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), invalid_so_declarations
[i
], count
,
26123 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), invalid_so_declarations
[i
], count
,
26125 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), invalid_so_declarations
[i
], count
,
26127 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), invalid_so_declarations
[i
], count
,
26131 /* Buffer strides */
26133 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
26135 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
26138 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
26141 /* Rasterizer stream */
26142 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
26143 NULL
, 0, D3D11_SO_NO_RASTERIZED_STREAM
);
26144 for (i
= 1; i
< D3D11_SO_STREAM_COUNT
; ++i
)
26145 check_invalid_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
),
26147 check_so_desc(device
, gs_code
, sizeof(gs_code
), so_declaration
, ARRAY_SIZE(so_declaration
), NULL
, 0, 0);
26149 release_test_context(&test_context
);
26152 static void test_stream_output_resume(void)
26154 struct d3d11_test_context test_context
;
26155 ID3D11Buffer
*cb
, *so_buffer
, *buffer
;
26156 unsigned int i
, j
, idx
, offset
;
26157 ID3D11DeviceContext
*context
;
26158 struct resource_readback rb
;
26159 ID3D11GeometryShader
*gs
;
26160 const struct vec4
*data
;
26161 ID3D11Device
*device
;
26164 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
26165 static const DWORD gs_code
[] =
26172 float4 position
: SV_POSITION
;
26177 float4 position
: SV_POSITION
;
26178 float4 so_output
: so_output
;
26181 [maxvertexcount(3)]
26182 void main(triangle vertex input
[3], inout PointStream
<element
> output
)
26185 o
.so_output
= constant
;
26186 o
.position
= input
[0].position
;
26188 o
.position
= input
[1].position
;
26190 o
.position
= input
[2].position
;
26194 0x43425844, 0x4c16e500, 0xa0dc6126, 0x261156f3, 0xf01eedc8, 0x00000001, 0x000001b8, 0x00000003,
26195 0x0000002c, 0x00000060, 0x000000b8, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
26196 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49,
26197 0x4e47534f, 0x00000050, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
26198 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
26199 0x505f5653, 0x5449534f, 0x004e4f49, 0x6f5f6f73, 0x75707475, 0xabab0074, 0x52444853, 0x000000f8,
26200 0x00020040, 0x0000003e, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x05000061, 0x002010f2,
26201 0x00000003, 0x00000000, 0x00000001, 0x0100185d, 0x0100085c, 0x04000067, 0x001020f2, 0x00000000,
26202 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x0200005e, 0x00000003, 0x06000036, 0x001020f2,
26203 0x00000000, 0x00201e46, 0x00000000, 0x00000000, 0x06000036, 0x001020f2, 0x00000001, 0x00208e46,
26204 0x00000000, 0x00000000, 0x01000013, 0x06000036, 0x001020f2, 0x00000000, 0x00201e46, 0x00000001,
26205 0x00000000, 0x06000036, 0x001020f2, 0x00000001, 0x00208e46, 0x00000000, 0x00000000, 0x01000013,
26206 0x06000036, 0x001020f2, 0x00000000, 0x00201e46, 0x00000002, 0x00000000, 0x06000036, 0x001020f2,
26207 0x00000001, 0x00208e46, 0x00000000, 0x00000000, 0x01000013, 0x0100003e,
26209 static const D3D11_SO_DECLARATION_ENTRY so_declaration
[] =
26211 {0, "so_output", 0, 0, 4, 0},
26213 static const struct vec4 constants
[] =
26215 {0.5f
, 0.250f
, 0.0f
, 0.0f
},
26216 {0.0f
, 0.125f
, 0.0f
, 1.0f
},
26217 {1.0f
, 1.000f
, 1.0f
, 0.0f
}
26219 static const struct vec4 green
= {0.0f
, 1.0f
, 0.0f
, 1.0f
};
26220 static const struct vec4 white
= {1.0f
, 1.0f
, 1.0f
, 1.0f
};
26221 static const struct vec4 red
= {1.0f
, 0.0f
, 0.0f
, 1.0f
};
26223 if (!init_test_context(&test_context
, &feature_level
))
26226 device
= test_context
.device
;
26227 context
= test_context
.immediate_context
;
26229 hr
= ID3D11Device_CreateGeometryShaderWithStreamOutput(device
, gs_code
, sizeof(gs_code
),
26230 so_declaration
, ARRAY_SIZE(so_declaration
), NULL
, 0, D3D11_SO_NO_RASTERIZED_STREAM
, NULL
, &gs
);
26231 ok(SUCCEEDED(hr
), "Failed to create geometry shader with stream output, hr %#x.\n", hr
);
26233 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(constants
[0]), &constants
[0]);
26234 so_buffer
= create_buffer(device
, D3D11_BIND_STREAM_OUTPUT
, 1024, NULL
);
26236 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
26237 ID3D11DeviceContext_GSSetConstantBuffers(context
, 0, 1, &cb
);
26240 ID3D11DeviceContext_SOSetTargets(context
, 1, &so_buffer
, &offset
);
26242 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &white
.x
);
26243 check_texture_color(test_context
.backbuffer
, 0xffffffff, 0);
26245 draw_color_quad(&test_context
, &red
);
26246 check_texture_color(test_context
.backbuffer
, 0xffffffff, 0);
26248 ID3D11DeviceContext_GSSetShader(context
, NULL
, NULL
, 0);
26249 draw_color_quad(&test_context
, &green
);
26250 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
26252 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constants
[1], 0, 0);
26253 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
26254 draw_color_quad(&test_context
, &red
);
26255 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
26257 ID3D11DeviceContext_GSSetShader(context
, NULL
, NULL
, 0);
26258 draw_color_quad(&test_context
, &red
);
26259 check_texture_color(test_context
.backbuffer
, 0xff0000ff, 0);
26261 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constants
[2], 0, 0);
26262 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
26263 draw_color_quad(&test_context
, &white
);
26264 check_texture_color(test_context
.backbuffer
, 0xff0000ff, 0);
26266 ID3D11DeviceContext_GSSetShader(context
, NULL
, NULL
, 0);
26267 draw_color_quad(&test_context
, &green
);
26268 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
26271 ID3D11DeviceContext_SOSetTargets(context
, 1, &buffer
, &offset
);
26272 ID3D11DeviceContext_GSSetShader(context
, NULL
, NULL
, 0);
26273 draw_color_quad(&test_context
, &white
);
26274 check_texture_color(test_context
.backbuffer
, 0xffffffff, 0);
26277 get_buffer_readback(so_buffer
, &rb
);
26278 for (i
= 0; i
< ARRAY_SIZE(constants
); ++i
)
26280 for (j
= 0; j
< 6; ++j
) /* 2 triangles */
26282 data
= get_readback_vec4(&rb
, idx
++, 0);
26283 ok(compare_vec4(data
, &constants
[i
], 0),
26284 "Got unexpected result {%.8e, %.8e, %.8e, %.8e} at %u (%u, %u).\n",
26285 data
->x
, data
->y
, data
->z
, data
->w
, idx
, i
, j
);
26288 release_resource_readback(&rb
);
26290 ID3D11Buffer_Release(cb
);
26291 ID3D11Buffer_Release(so_buffer
);
26292 ID3D11GeometryShader_Release(gs
);
26293 release_test_context(&test_context
);
26296 static void test_stream_output_components(void)
26298 const D3D11_SO_DECLARATION_ENTRY
*current_so_declaration
;
26299 struct d3d11_test_context test_context
;
26300 ID3D11InputLayout
*input_layout
[2];
26301 ID3D11Buffer
*vb
[2], *so_buffer
;
26302 ID3D11DeviceContext
*context
;
26303 struct resource_readback rb
;
26304 unsigned int stride
, offset
;
26305 ID3D11GeometryShader
*gs
;
26306 ID3D11VertexShader
*vs
;
26307 ID3D11PixelShader
*ps
;
26308 ID3D11Device
*device
;
26309 const float *result
;
26313 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
26314 static const DWORD vs_code
[] =
26319 float4 position
: POSITION
;
26320 float4 color
: COLOR
;
26321 float4 color2
: COLOR2
;
26324 void main(in vertex i
, out vertex o
)
26329 0x43425844, 0x95991b76, 0x4898640b, 0xe36ad9d6, 0xfbfe78b4, 0x00000001, 0x00000194, 0x00000003,
26330 0x0000002c, 0x00000094, 0x000000fc, 0x4e475349, 0x00000060, 0x00000003, 0x00000008, 0x00000050,
26331 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000059, 0x00000000, 0x00000000,
26332 0x00000003, 0x00000001, 0x00000f0f, 0x00000059, 0x00000002, 0x00000000, 0x00000003, 0x00000002,
26333 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x00000060, 0x00000003,
26334 0x00000008, 0x00000050, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x00000059,
26335 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x00000059, 0x00000002, 0x00000000,
26336 0x00000003, 0x00000002, 0x0000000f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x52444853,
26337 0x00000090, 0x00010040, 0x00000024, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2,
26338 0x00000001, 0x0300005f, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x03000065,
26339 0x001020f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x05000036, 0x001020f2, 0x00000000,
26340 0x00101e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001, 0x05000036,
26341 0x001020f2, 0x00000002, 0x00101e46, 0x00000002, 0x0100003e,
26343 static const DWORD gs_code
[] =
26348 float4 position
: POSITION
;
26349 float4 color
: COLOR
;
26350 float4 color2
: COLOR2
;
26353 [maxvertexcount(1)]
26354 void main(point vertex input
[1], inout PointStream
<vertex
> output
)
26356 output
.Append(input
[0]);
26359 0x43425844, 0x218f7d27, 0x555fa7f1, 0x282c545f, 0x3989c843, 0x00000001, 0x000001c0, 0x00000003,
26360 0x0000002c, 0x00000094, 0x000000fc, 0x4e475349, 0x00000060, 0x00000003, 0x00000008, 0x00000050,
26361 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000059, 0x00000000, 0x00000000,
26362 0x00000003, 0x00000001, 0x00000f0f, 0x00000059, 0x00000002, 0x00000000, 0x00000003, 0x00000002,
26363 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x00000060, 0x00000003,
26364 0x00000008, 0x00000050, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x00000059,
26365 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x00000059, 0x00000002, 0x00000000,
26366 0x00000003, 0x00000002, 0x0000000f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x52444853,
26367 0x000000bc, 0x00020040, 0x0000002f, 0x0400005f, 0x002010f2, 0x00000001, 0x00000000, 0x0400005f,
26368 0x002010f2, 0x00000001, 0x00000001, 0x0400005f, 0x002010f2, 0x00000001, 0x00000002, 0x0100085d,
26369 0x0100085c, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000001, 0x03000065,
26370 0x001020f2, 0x00000002, 0x0200005e, 0x00000001, 0x06000036, 0x001020f2, 0x00000000, 0x00201e46,
26371 0x00000000, 0x00000000, 0x06000036, 0x001020f2, 0x00000001, 0x00201e46, 0x00000000, 0x00000001,
26372 0x06000036, 0x001020f2, 0x00000002, 0x00201e46, 0x00000000, 0x00000002, 0x01000013, 0x0100003e,
26374 static const DWORD ps_code
[] =
26377 float4
main(float4 position
: SV_Position
,
26378 float2 texcoord
: TEXCOORD
) : SV_Target
26380 return float4(position
.xy
, texcoord
);
26383 0x43425844, 0xa15616bc, 0x6862ab1c, 0x28b915c0, 0xdb0df67c, 0x00000001, 0x0000011c, 0x00000003,
26384 0x0000002c, 0x00000084, 0x000000b8, 0x4e475349, 0x00000050, 0x00000002, 0x00000008, 0x00000038,
26385 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x00000044, 0x00000000, 0x00000000,
26386 0x00000003, 0x00000001, 0x00000303, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f,
26387 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
26388 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x0000005c,
26389 0x00000040, 0x00000017, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03001062, 0x00101032,
26390 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036, 0x00102032, 0x00000000, 0x00101046,
26391 0x00000000, 0x05000036, 0x001020c2, 0x00000000, 0x00101406, 0x00000001, 0x0100003e,
26393 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
26395 {"POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
26396 {"COLOR", 0, DXGI_FORMAT_R32G32B32_FLOAT
, 0, 16, D3D11_INPUT_PER_VERTEX_DATA
, 0},
26397 {"COLOR", 2, DXGI_FORMAT_R32G32_FLOAT
, 0, 28, D3D11_INPUT_PER_VERTEX_DATA
, 0},
26399 static const D3D11_INPUT_ELEMENT_DESC layout_desc2
[] =
26401 {"POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
26402 {"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 16, D3D11_INPUT_PER_VERTEX_DATA
, 0},
26403 {"COLOR", 2, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 32, D3D11_INPUT_PER_VERTEX_DATA
, 0},
26405 static const D3D11_SO_DECLARATION_ENTRY so_declaration
[] =
26407 {0, "POSITION", 0, 0, 4, 0},
26408 {0, "COLOR", 0, 0, 3, 0},
26409 {0, "COLOR", 2, 0, 2, 0},
26411 static const D3D11_SO_DECLARATION_ENTRY so_declaration2
[] =
26413 {0, "POSITION", 0, 0, 1, 0},
26414 {0, "POSITION", 0, 1, 1, 0},
26415 {0, "POSITION", 0, 2, 1, 0},
26416 {0, "POSITION", 0, 3, 1, 0},
26417 {0, "COLOR", 0, 0, 1, 0},
26418 {0, "COLOR", 0, 1, 1, 0},
26419 {0, "COLOR", 0, 2, 1, 0},
26420 {0, "COLOR", 2, 0, 1, 0},
26421 {0, "COLOR", 2, 1, 1, 0},
26423 static const D3D11_SO_DECLARATION_ENTRY so_declaration3
[] =
26425 {0, "COLOR", 0, 2, 2, 0},
26426 {0, "COLOR", 2, 3, 1, 0},
26428 static const struct
26430 struct vec4 position
;
26432 struct vec2 color2
;
26436 {{-1.0f
, -1.0f
, 0.0f
, 1.0f
}, {1.0f
, 0.0f
, 0.0f
}, {0.5f
, 1.0f
}},
26437 {{-1.0f
, 1.0f
, 0.0f
, 1.0f
}, {0.0f
, 1.0f
, 0.0f
}, {0.0f
, 0.0f
}},
26438 {{ 1.0f
, -1.0f
, 0.0f
, 1.0f
}, {1.0f
, 0.0f
, 1.0f
}, {0.5f
, 0.4f
}},
26439 {{ 1.0f
, 1.0f
, 0.0f
, 1.0f
}, {1.0f
, 1.0f
, 0.0f
}, {0.1f
, 0.6f
}},
26441 static const struct
26443 struct vec4 position
;
26445 struct vec4 color2
;
26449 {{-1.0f
, -1.0f
, 0.0f
, 1.0f
}, {1.0f
, 2.0f
, 3.0f
, 4.0f
}, {5.0f
, 6.0f
, 7.0f
, 8.0f
}},
26450 {{-1.0f
, 1.0f
, 0.0f
, 1.0f
}, {9.0f
, 1.1f
, 1.2f
, 1.3f
}, {1.4f
, 1.5f
, 1.6f
, 1.7f
}},
26451 {{ 1.0f
, -1.0f
, 0.0f
, 1.0f
}, {1.8f
, 1.9f
, 2.0f
, 2.1f
}, {2.2f
, 2.3f
, 2.4f
, 2.5f
}},
26452 {{ 1.0f
, 1.0f
, 0.0f
, 1.0f
}, {2.5f
, 2.6f
, 2.7f
, 2.8f
}, {2.9f
, 3.0f
, 3.1f
, 3.2f
}},
26454 static const unsigned int vb_stride
[] = {sizeof(*vb_data
), sizeof(*vb_data2
)};
26455 static const float expected_data
[] =
26457 -1.0f
, -1.0f
, 0.0f
, 1.0f
, 1.0f
, 0.0f
, 0.0f
, 0.5f
, 1.0f
,
26458 -1.0f
, 1.0f
, 0.0f
, 1.0f
, 0.0f
, 1.0f
, 0.0f
, 0.0f
, 0.0f
,
26459 1.0f
, -1.0f
, 0.0f
, 1.0f
, 1.0f
, 0.0f
, 1.0f
, 0.5f
, 0.4f
,
26460 1.0f
, 1.0f
, 0.0f
, 1.0f
, 1.0f
, 1.0f
, 0.0f
, 0.1f
, 0.6f
,
26462 static const float expected_data2
[] =
26464 -1.0f
, -1.0f
, 0.0f
, 1.0f
, 1.0f
, 2.0f
, 3.0f
, 5.0f
, 6.0f
,
26465 -1.0f
, 1.0f
, 0.0f
, 1.0f
, 9.0f
, 1.1f
, 1.2f
, 1.4f
, 1.5f
,
26466 1.0f
, -1.0f
, 0.0f
, 1.0f
, 1.8f
, 1.9f
, 2.0f
, 2.2f
, 2.3f
,
26467 1.0f
, 1.0f
, 0.0f
, 1.0f
, 2.5f
, 2.6f
, 2.7f
, 2.9f
, 3.0f
,
26469 static const float expected_data3
[] =
26471 3.0f
, 4.0f
, 8.0f
, 1.2f
, 1.3f
, 1.7f
, 2.0f
, 2.1f
, 2.5f
, 2.7f
, 2.8f
, 3.2f
,
26473 static const struct
26476 unsigned int vb_idx
;
26477 const D3D11_SO_DECLARATION_ENTRY
*so_declaration
;
26478 unsigned int so_entry_count
;
26479 const float *expected_data
;
26480 unsigned int expected_data_size
;
26484 {TRUE
, 0, so_declaration
, ARRAY_SIZE(so_declaration
), expected_data
, ARRAY_SIZE(expected_data
)},
26485 {TRUE
, 1, so_declaration
, ARRAY_SIZE(so_declaration
), expected_data2
, ARRAY_SIZE(expected_data2
)},
26486 {TRUE
, 0, so_declaration2
, ARRAY_SIZE(so_declaration2
), expected_data
, ARRAY_SIZE(expected_data
)},
26487 {TRUE
, 1, so_declaration2
, ARRAY_SIZE(so_declaration2
), expected_data2
, ARRAY_SIZE(expected_data2
)},
26488 {TRUE
, 1, so_declaration3
, ARRAY_SIZE(so_declaration3
), expected_data3
, ARRAY_SIZE(expected_data3
)},
26490 {FALSE
, 0, so_declaration
, ARRAY_SIZE(so_declaration
), expected_data
, ARRAY_SIZE(expected_data
)},
26491 {FALSE
, 1, so_declaration
, ARRAY_SIZE(so_declaration
), expected_data2
, ARRAY_SIZE(expected_data2
)},
26492 {FALSE
, 0, so_declaration2
, ARRAY_SIZE(so_declaration2
), expected_data
, ARRAY_SIZE(expected_data
)},
26493 {FALSE
, 1, so_declaration2
, ARRAY_SIZE(so_declaration2
), expected_data2
, ARRAY_SIZE(expected_data2
)},
26494 {FALSE
, 1, so_declaration3
, ARRAY_SIZE(so_declaration3
), expected_data3
, ARRAY_SIZE(expected_data3
)},
26497 if (!init_test_context(&test_context
, &feature_level
))
26500 device
= test_context
.device
;
26501 context
= test_context
.immediate_context
;
26503 vb
[0] = create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(vb_data
), vb_data
);
26504 vb
[1] = create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(vb_data2
), vb_data2
);
26506 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
26507 vs_code
, sizeof(vs_code
), &input_layout
[0]);
26508 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
26509 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc2
, ARRAY_SIZE(layout_desc2
),
26510 vs_code
, sizeof(vs_code
), &input_layout
[1]);
26511 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
26513 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
26514 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
26515 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
26516 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
26518 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
26519 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST
);
26521 so_buffer
= create_buffer(device
, D3D11_BIND_STREAM_OUTPUT
, 1024, NULL
);
26524 current_so_declaration
= NULL
;
26525 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
26527 ID3D11DeviceContext_PSSetShader(context
, tests
[i
].with_ps
? ps
: NULL
, NULL
, 0);
26529 if (current_so_declaration
!= tests
[i
].so_declaration
)
26532 ID3D11GeometryShader_Release(gs
);
26534 hr
= ID3D11Device_CreateGeometryShaderWithStreamOutput(device
, gs_code
, sizeof(gs_code
),
26535 tests
[i
].so_declaration
, tests
[i
].so_entry_count
, NULL
, 0,
26536 D3D11_SO_NO_RASTERIZED_STREAM
, NULL
, &gs
);
26537 ok(SUCCEEDED(hr
), "Failed to create geometry shader with stream output, hr %#x.\n", hr
);
26538 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
26539 current_so_declaration
= tests
[i
].so_declaration
;
26542 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
[tests
[i
].vb_idx
]);
26543 stride
= vb_stride
[tests
[i
].vb_idx
];
26545 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
[tests
[i
].vb_idx
], &stride
, &offset
);
26548 ID3D11DeviceContext_SOSetTargets(context
, 1, &so_buffer
, &offset
);
26550 ID3D11DeviceContext_Draw(context
, 4, 0);
26552 get_buffer_readback(so_buffer
, &rb
);
26553 result
= rb
.map_desc
.pData
;
26554 for (j
= 0; j
< tests
[i
].expected_data_size
; ++j
)
26556 float expected_value
= tests
[i
].expected_data
[j
];
26557 ok(compare_float(result
[j
], expected_value
, 2),
26558 "Test %u: Got %.8e, expected %.8e at %u.\n",
26559 i
, result
[j
], expected_value
, j
);
26561 release_resource_readback(&rb
);
26564 for (i
= 0; i
< ARRAY_SIZE(vb
); ++i
)
26565 ID3D11Buffer_Release(vb
[i
]);
26566 ID3D11Buffer_Release(so_buffer
);
26567 ID3D11VertexShader_Release(vs
);
26568 ID3D11GeometryShader_Release(gs
);
26569 ID3D11PixelShader_Release(ps
);
26570 for (i
= 0; i
< ARRAY_SIZE(input_layout
); ++i
)
26571 ID3D11InputLayout_Release(input_layout
[i
]);
26572 release_test_context(&test_context
);
26575 static void test_stream_output_vs(void)
26577 const D3D11_SO_DECLARATION_ENTRY
*current_so_declaration
;
26578 struct d3d11_test_context test_context
;
26579 ID3D11InputLayout
*input_layout
;
26580 ID3D11Buffer
*vb
, *so_buffer
;
26581 ID3D11DeviceContext
*context
;
26582 struct resource_readback rb
;
26583 ID3D11GeometryShader
*gs
;
26584 ID3D11VertexShader
*vs
;
26585 ID3D11Device
*device
;
26586 const float *result
;
26587 unsigned int offset
;
26591 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
26592 static const DWORD vs_code
[] =
26597 float4 position
: POSITION
;
26598 float4 color0
: COLOR0
;
26599 float4 color1
: COLOR1
;
26602 vertex
main(in vertex i
)
26607 0x43425844, 0xa67e993e, 0x1632c139, 0x02a7725f, 0xfb0221cd, 0x00000001, 0x00000194, 0x00000003,
26608 0x0000002c, 0x00000094, 0x000000fc, 0x4e475349, 0x00000060, 0x00000003, 0x00000008, 0x00000050,
26609 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000059, 0x00000000, 0x00000000,
26610 0x00000003, 0x00000001, 0x00000f0f, 0x00000059, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
26611 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x00000060, 0x00000003,
26612 0x00000008, 0x00000050, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x00000059,
26613 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x00000059, 0x00000001, 0x00000000,
26614 0x00000003, 0x00000002, 0x0000000f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x52444853,
26615 0x00000090, 0x00010040, 0x00000024, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2,
26616 0x00000001, 0x0300005f, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x03000065,
26617 0x001020f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x05000036, 0x001020f2, 0x00000000,
26618 0x00101e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001, 0x05000036,
26619 0x001020f2, 0x00000002, 0x00101e46, 0x00000002, 0x0100003e,
26621 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
26623 {"POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
26624 {"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 16, D3D11_INPUT_PER_VERTEX_DATA
, 0},
26625 {"COLOR", 1, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 32, D3D11_INPUT_PER_VERTEX_DATA
, 0},
26627 static const D3D11_SO_DECLARATION_ENTRY all_so_decl
[] =
26629 {0, "POSITION", 0, 0, 4, 0},
26630 {0, "COLOR", 0, 0, 3, 0},
26631 {0, "COLOR", 1, 0, 2, 0},
26633 static const D3D11_SO_DECLARATION_ENTRY position_so_decl
[] =
26635 {0, "POSITION", 0, 0, 4, 0},
26637 static const D3D11_SO_DECLARATION_ENTRY position2_so_decl
[] =
26639 {0, "POSITION", 0, 0, 2, 0},
26641 static const struct
26643 struct vec4 position
;
26644 struct vec4 color0
;
26645 struct vec4 color1
;
26649 {{-1.0f
, -1.0f
, 0.0f
, 1.0f
}, {1.0f
, 2.0f
, 3.0f
, 4.0f
}, {5.0f
, 6.0f
, 7.0f
, 8.0f
}},
26650 {{-1.0f
, 1.0f
, 0.0f
, 1.0f
}, {9.0f
, 1.1f
, 1.2f
, 1.3f
}, {1.4f
, 1.5f
, 1.6f
, 1.7f
}},
26651 {{ 1.0f
, -1.0f
, 0.0f
, 1.0f
}, {1.8f
, 1.9f
, 2.0f
, 2.1f
}, {2.2f
, 2.3f
, 2.4f
, 2.5f
}},
26652 {{ 1.0f
, 1.0f
, 0.0f
, 1.0f
}, {2.5f
, 2.6f
, 2.7f
, 2.8f
}, {2.9f
, 3.0f
, 3.1f
, 3.2f
}},
26654 static const unsigned int vb_stride
[] = {sizeof(*vb_data
)};
26655 static const float expected_data
[] =
26657 -1.0f
, -1.0f
, 0.0f
, 1.0f
, 1.0f
, 2.0f
, 3.0f
, 5.0f
, 6.0f
,
26658 -1.0f
, 1.0f
, 0.0f
, 1.0f
, 9.0f
, 1.1f
, 1.2f
, 1.4f
, 1.5f
,
26659 1.0f
, -1.0f
, 0.0f
, 1.0f
, 1.8f
, 1.9f
, 2.0f
, 2.2f
, 2.3f
,
26660 1.0f
, 1.0f
, 0.0f
, 1.0f
, 2.5f
, 2.6f
, 2.7f
, 2.9f
, 3.0f
,
26662 static const float expected_data2
[] =
26664 -1.0f
, -1.0f
, 0.0f
, 1.0f
,
26665 -1.0f
, 1.0f
, 0.0f
, 1.0f
,
26666 1.0f
, -1.0f
, 0.0f
, 1.0f
,
26667 1.0f
, 1.0f
, 0.0f
, 1.0f
,
26669 static const float expected_data3
[] =
26676 static const struct
26678 const D3D11_SO_DECLARATION_ENTRY
*so_declaration
;
26679 unsigned int so_entry_count
;
26680 const float *expected_data
;
26681 unsigned int expected_data_size
;
26685 {all_so_decl
, ARRAY_SIZE(all_so_decl
), expected_data
, ARRAY_SIZE(expected_data
)},
26686 {position_so_decl
, ARRAY_SIZE(position_so_decl
), expected_data2
, ARRAY_SIZE(expected_data2
)},
26687 {position2_so_decl
, ARRAY_SIZE(position2_so_decl
), expected_data3
, ARRAY_SIZE(expected_data3
)},
26690 if (!init_test_context(&test_context
, &feature_level
))
26693 device
= test_context
.device
;
26694 context
= test_context
.immediate_context
;
26696 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(vb_data
), vb_data
);
26698 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
26699 vs_code
, sizeof(vs_code
), &input_layout
);
26700 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
26702 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
26703 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
26705 so_buffer
= create_buffer(device
, D3D11_BIND_STREAM_OUTPUT
, 1024, NULL
);
26707 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
26709 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, vb_stride
, &offset
);
26710 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
26712 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST
);
26715 current_so_declaration
= NULL
;
26716 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
26718 if (current_so_declaration
!= tests
[i
].so_declaration
)
26721 ID3D11GeometryShader_Release(gs
);
26723 hr
= ID3D11Device_CreateGeometryShaderWithStreamOutput(device
, vs_code
, sizeof(vs_code
),
26724 tests
[i
].so_declaration
, tests
[i
].so_entry_count
, NULL
, 0,
26725 D3D11_SO_NO_RASTERIZED_STREAM
, NULL
, &gs
);
26726 ok(hr
== S_OK
, "Failed to create geometry shader with stream output, hr %#x.\n", hr
);
26727 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
26728 current_so_declaration
= tests
[i
].so_declaration
;
26732 ID3D11DeviceContext_SOSetTargets(context
, 1, &so_buffer
, &offset
);
26734 ID3D11DeviceContext_Draw(context
, 4, 0);
26736 get_buffer_readback(so_buffer
, &rb
);
26737 result
= rb
.map_desc
.pData
;
26738 for (j
= 0; j
< tests
[i
].expected_data_size
; ++j
)
26740 float expected_value
= tests
[i
].expected_data
[j
];
26741 ok(compare_float(result
[j
], expected_value
, 2),
26742 "Test %u: Got %.8e, expected %.8e at %u.\n",
26743 i
, result
[j
], expected_value
, j
);
26745 release_resource_readback(&rb
);
26748 ID3D11Buffer_Release(vb
);
26749 ID3D11Buffer_Release(so_buffer
);
26750 ID3D11VertexShader_Release(vs
);
26751 ID3D11GeometryShader_Release(gs
);
26752 ID3D11InputLayout_Release(input_layout
);
26753 release_test_context(&test_context
);
26756 static void test_gather(void)
26761 int offset_x
, offset_y
;
26763 struct d3d11_test_context test_context
;
26764 D3D11_TEXTURE2D_DESC texture_desc
;
26765 ID3D11ShaderResourceView
*srv
;
26766 ID3D11Texture2D
*texture
, *rt
;
26767 ID3D11DeviceContext
*context
;
26768 ID3D11RenderTargetView
*rtv
;
26769 struct resource_readback rb
;
26770 ID3D11PixelShader
*ps
;
26771 ID3D11Device
*device
;
26776 static const DWORD gather4_code
[] =
26780 Texture2D
<float4
> t
;
26784 float4
main(float4 position
: SV_Position
) : SV_Target
26786 return t
.Gather(s
, position
.xy
/ size
);
26789 0x43425844, 0xca1ee692, 0xb122f477, 0x8c467d38, 0x0f5a233a, 0x00000001, 0x00000154, 0x00000003,
26790 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
26791 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
26792 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
26793 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000b8, 0x00000041,
26794 0x0000002e, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000,
26795 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000,
26796 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0600002b, 0x00100032,
26797 0x00000000, 0x00208046, 0x00000000, 0x00000000, 0x0700000e, 0x00100032, 0x00000000, 0x00101046,
26798 0x00000000, 0x00100046, 0x00000000, 0x0900006d, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
26799 0x00107e46, 0x00000000, 0x0010600a, 0x00000000, 0x0100003e,
26801 static const DWORD gather4_offset_code
[] =
26805 Texture2D
<float4
> t
;
26809 float4
main(float4 position
: SV_Position
) : SV_Target
26811 return t
.Gather(s
, position
.xy
/ size
, int2(1, 1));
26814 0x43425844, 0xe5ab2216, 0x90748ece, 0x7ccf2123, 0x4edbba7c, 0x00000001, 0x00000158, 0x00000003,
26815 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
26816 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
26817 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
26818 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000bc, 0x00000041,
26819 0x0000002f, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000,
26820 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000,
26821 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0600002b, 0x00100032,
26822 0x00000000, 0x00208046, 0x00000000, 0x00000000, 0x0700000e, 0x00100032, 0x00000000, 0x00101046,
26823 0x00000000, 0x00100046, 0x00000000, 0x8a00006d, 0x00002201, 0x001020f2, 0x00000000, 0x00100046,
26824 0x00000000, 0x00107e46, 0x00000000, 0x0010600a, 0x00000000, 0x0100003e,
26826 static const DWORD gather4_green_code
[] =
26830 Texture2D
<float4
> t
;
26834 float4
main(float4 position
: SV_Position
) : SV_Target
26836 return t
.GatherGreen(s
, position
.xy
/ size
);
26839 0x43425844, 0x2b0ad2d9, 0x8ad30b52, 0xc418477f, 0xe5211693, 0x00000001, 0x0000015c, 0x00000003,
26840 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
26841 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
26842 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
26843 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000c0, 0x00000050,
26844 0x00000030, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000,
26845 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000,
26846 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0600002b, 0x00100032,
26847 0x00000000, 0x00208046, 0x00000000, 0x00000000, 0x0700000e, 0x00100032, 0x00000000, 0x00101046,
26848 0x00000000, 0x00100046, 0x00000000, 0x8b00006d, 0x800000c2, 0x00155543, 0x001020f2, 0x00000000,
26849 0x00100046, 0x00000000, 0x00107e46, 0x00000000, 0x0010601a, 0x00000000, 0x0100003e,
26851 static const DWORD gather4_po_code
[] =
26855 Texture2D
<float4
> t
;
26860 float4
main(float4 position
: SV_Position
) : SV_Target
26862 return t
.Gather(s
, position
.xy
/ size
, offset
);
26865 0x43425844, 0xe19bdd35, 0x44514fb3, 0xfaa8727f, 0xc1092da0, 0x00000001, 0x00000168, 0x00000003,
26866 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
26867 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
26868 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
26869 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000cc, 0x00000050,
26870 0x00000033, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000,
26871 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000,
26872 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0600002b, 0x00100032,
26873 0x00000000, 0x00208046, 0x00000000, 0x00000000, 0x0700000e, 0x00100032, 0x00000000, 0x00101046,
26874 0x00000000, 0x00100046, 0x00000000, 0x8e00007f, 0x800000c2, 0x00155543, 0x001020f2, 0x00000000,
26875 0x00100046, 0x00000000, 0x00208ae6, 0x00000000, 0x00000000, 0x00107e46, 0x00000000, 0x0010600a,
26876 0x00000000, 0x0100003e,
26878 static const struct vec4 texture_data
[] =
26880 {0.0f
, 0.0f
}, {1.0f
, 1.0f
}, {2.0f
, 2.0f
}, {3.0f
, 3.0f
},
26881 {4.0f
, 0.1f
}, {5.0f
, 1.1f
}, {6.0f
, 2.1f
}, {7.0f
, 3.1f
},
26882 {8.0f
, 0.2f
}, {9.0f
, 1.2f
}, {0.5f
, 2.2f
}, {1.5f
, 3.2f
},
26883 {2.5f
, 0.3f
}, {3.5f
, 1.3f
}, {4.5f
, 2.3f
}, {5.5f
, 3.3f
},
26885 static const struct vec4 expected_gather4
[] =
26887 {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
},
26888 {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
},
26889 {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
},
26890 {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
},
26892 static const struct vec4 expected_gather4_offset
[] =
26894 {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
},
26895 {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
},
26896 {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
},
26897 {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
},
26899 static const struct vec4 expected_gather4_green
[] =
26901 {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
},
26902 {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
},
26903 {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
},
26904 {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
},
26906 static const struct vec4 white
= {1.0f
, 1.0f
, 1.0f
, 1.0f
};
26907 static const D3D11_SUBRESOURCE_DATA resource_data
= {&texture_data
, sizeof(texture_data
) / 4};
26909 if (!init_test_context(&test_context
, NULL
))
26912 device
= test_context
.device
;
26913 context
= test_context
.immediate_context
;
26915 if (ID3D11Device_GetFeatureLevel(device
) < D3D_FEATURE_LEVEL_10_1
)
26917 skip("Shader model 4.1 required for gather4 instruction.\n");
26918 release_test_context(&test_context
);
26922 texture_desc
.Width
= 4;
26923 texture_desc
.Height
= 4;
26924 texture_desc
.MipLevels
= 1;
26925 texture_desc
.ArraySize
= 1;
26926 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
26927 texture_desc
.SampleDesc
.Count
= 1;
26928 texture_desc
.SampleDesc
.Quality
= 0;
26929 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
26930 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
26931 texture_desc
.CPUAccessFlags
= 0;
26932 texture_desc
.MiscFlags
= 0;
26933 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rt
);
26934 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
26935 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rt
, NULL
, &rtv
);
26936 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
26937 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
26939 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
26940 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &texture
);
26941 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
26942 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
26943 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
26944 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
26946 constant
.width
= texture_desc
.Width
;
26947 constant
.height
= texture_desc
.Height
;
26948 constant
.offset_x
= 1;
26949 constant
.offset_y
= 1;
26950 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(constant
), &constant
);
26951 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
26953 hr
= ID3D11Device_CreatePixelShader(device
, gather4_code
, sizeof(gather4_code
), NULL
, &ps
);
26954 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
26955 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
26957 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, &white
.x
);
26958 draw_quad(&test_context
);
26959 get_texture_readback(rt
, 0, &rb
);
26960 for (y
= 0; y
< texture_desc
.Height
; ++y
)
26962 for (x
= 0; x
< texture_desc
.Width
; ++x
)
26964 const struct vec4
*expected
= &expected_gather4
[y
* texture_desc
.Width
+ x
];
26965 const struct vec4
*got
= get_readback_vec4(&rb
, x
, y
);
26966 ok(compare_vec4(got
, expected
, 0),
26967 "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
26968 got
->x
, got
->y
, got
->z
, got
->w
, expected
->x
, expected
->y
, expected
->z
, expected
->w
);
26971 release_resource_readback(&rb
);
26973 ID3D11PixelShader_Release(ps
);
26974 hr
= ID3D11Device_CreatePixelShader(device
, gather4_offset_code
, sizeof(gather4_offset_code
), NULL
, &ps
);
26975 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
26976 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
26978 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, &white
.x
);
26979 draw_quad(&test_context
);
26980 get_texture_readback(rt
, 0, &rb
);
26981 for (y
= 0; y
< texture_desc
.Height
; ++y
)
26983 for (x
= 0; x
< texture_desc
.Width
; ++x
)
26985 const struct vec4
*expected
= &expected_gather4_offset
[y
* texture_desc
.Width
+ x
];
26986 const struct vec4
*got
= get_readback_vec4(&rb
, x
, y
);
26987 ok(compare_vec4(got
, expected
, 0),
26988 "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
26989 got
->x
, got
->y
, got
->z
, got
->w
, expected
->x
, expected
->y
, expected
->z
, expected
->w
);
26992 release_resource_readback(&rb
);
26994 ID3D11PixelShader_Release(ps
);
26996 if (ID3D11Device_GetFeatureLevel(device
) < D3D_FEATURE_LEVEL_11_0
)
26998 skip("Shader model 5 required for GatherGreen()/gather4_po.\n");
27002 hr
= ID3D11Device_CreatePixelShader(device
, gather4_green_code
, sizeof(gather4_green_code
), NULL
, &ps
);
27003 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
27004 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
27006 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, &white
.x
);
27007 draw_quad(&test_context
);
27008 get_texture_readback(rt
, 0, &rb
);
27009 for (y
= 0; y
< texture_desc
.Height
; ++y
)
27011 for (x
= 0; x
< texture_desc
.Width
; ++x
)
27013 const struct vec4
*expected
= &expected_gather4_green
[y
* texture_desc
.Width
+ x
];
27014 const struct vec4
*got
= get_readback_vec4(&rb
, x
, y
);
27015 ok(compare_vec4(got
, expected
, 0),
27016 "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
27017 got
->x
, got
->y
, got
->z
, got
->w
, expected
->x
, expected
->y
, expected
->z
, expected
->w
);
27020 release_resource_readback(&rb
);
27022 ID3D11PixelShader_Release(ps
);
27023 hr
= ID3D11Device_CreatePixelShader(device
, gather4_po_code
, sizeof(gather4_po_code
), NULL
, &ps
);
27024 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
27025 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
27027 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, &white
.x
);
27028 draw_quad(&test_context
);
27029 get_texture_readback(rt
, 0, &rb
);
27030 for (y
= 0; y
< texture_desc
.Height
; ++y
)
27032 for (x
= 0; x
< texture_desc
.Width
; ++x
)
27034 const struct vec4
*expected
= &expected_gather4_offset
[y
* texture_desc
.Width
+ x
];
27035 const struct vec4
*got
= get_readback_vec4(&rb
, x
, y
);
27036 ok(compare_vec4(got
, expected
, 0),
27037 "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
27038 got
->x
, got
->y
, got
->z
, got
->w
, expected
->x
, expected
->y
, expected
->z
, expected
->w
);
27041 release_resource_readback(&rb
);
27043 constant
.offset_x
= 0;
27044 constant
.offset_y
= 0;
27045 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
27046 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, &white
.x
);
27047 draw_quad(&test_context
);
27048 get_texture_readback(rt
, 0, &rb
);
27049 for (y
= 0; y
< texture_desc
.Height
; ++y
)
27051 for (x
= 0; x
< texture_desc
.Width
; ++x
)
27053 const struct vec4
*expected
= &expected_gather4
[y
* texture_desc
.Width
+ x
];
27054 const struct vec4
*got
= get_readback_vec4(&rb
, x
, y
);
27055 ok(compare_vec4(got
, expected
, 0),
27056 "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
27057 got
->x
, got
->y
, got
->z
, got
->w
, expected
->x
, expected
->y
, expected
->z
, expected
->w
);
27060 release_resource_readback(&rb
);
27062 ID3D11PixelShader_Release(ps
);
27065 ID3D11Buffer_Release(cb
);
27066 ID3D11Texture2D_Release(rt
);
27067 ID3D11Texture2D_Release(texture
);
27068 ID3D11RenderTargetView_Release(rtv
);
27069 ID3D11ShaderResourceView_Release(srv
);
27070 release_test_context(&test_context
);
27073 static void test_gather_c(void)
27078 int offset_x
, offset_y
;
27079 float compare_value
;
27082 struct d3d11_test_context test_context
;
27083 D3D11_TEXTURE2D_DESC texture_desc
;
27084 D3D11_SAMPLER_DESC sampler_desc
;
27085 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
27086 ID3D11ShaderResourceView
*srv
;
27087 ID3D11Texture2D
*texture
, *rt
;
27088 ID3D11DeviceContext
*context
;
27089 ID3D11SamplerState
*sampler
;
27090 ID3D11RenderTargetView
*rtv
;
27091 struct resource_readback rb
;
27092 ID3D11PixelShader
*ps
;
27093 ID3D11Device
*device
;
27098 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
27099 static const DWORD gather4_c_code
[] =
27102 SamplerComparisonState s
;
27103 Texture2D
<float4
> t
;
27109 float4
main(float4 position
: SV_Position
) : SV_Target
27111 return t
.GatherCmp(s
, position
.xy
/ size
, compare
);
27114 0x43425844, 0xd3d04479, 0x901e9208, 0x7074fd0c, 0xbcadb2da, 0x00000001, 0x00000168, 0x00000003,
27115 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
27116 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
27117 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
27118 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000cc, 0x00000050,
27119 0x00000033, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000002, 0x0300085a, 0x00106000,
27120 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000,
27121 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0600002b, 0x00100032,
27122 0x00000000, 0x00208046, 0x00000000, 0x00000000, 0x0700000e, 0x00100032, 0x00000000, 0x00101046,
27123 0x00000000, 0x00100046, 0x00000000, 0x8e00007e, 0x800000c2, 0x00155543, 0x001020f2, 0x00000000,
27124 0x00100046, 0x00000000, 0x00107e46, 0x00000000, 0x0010600a, 0x00000000, 0x0020800a, 0x00000000,
27125 0x00000001, 0x0100003e,
27127 static const DWORD gather4_po_c_code
[] =
27130 SamplerComparisonState s
;
27131 Texture2D
<float4
> t
;
27137 float4
main(float4 position
: SV_Position
) : SV_Target
27139 return t
.GatherCmp(s
, position
.xy
/ size
, compare
, offset
);
27142 0x43425844, 0x501de13e, 0x472d2d20, 0x6df0fee4, 0xef27d9e6, 0x00000001, 0x00000174, 0x00000003,
27143 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
27144 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
27145 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
27146 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000d8, 0x00000050,
27147 0x00000036, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000002, 0x0300085a, 0x00106000,
27148 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000,
27149 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0600002b, 0x00100032,
27150 0x00000000, 0x00208046, 0x00000000, 0x00000000, 0x0700000e, 0x00100032, 0x00000000, 0x00101046,
27151 0x00000000, 0x00100046, 0x00000000, 0x91000080, 0x800000c2, 0x00155543, 0x001020f2, 0x00000000,
27152 0x00100046, 0x00000000, 0x00208ae6, 0x00000000, 0x00000000, 0x00107e46, 0x00000000, 0x0010600a,
27153 0x00000000, 0x0020800a, 0x00000000, 0x00000001, 0x0100003e,
27155 static const float texture_data
[] =
27157 0.00f
, 0.10f
, 0.20f
, 0.30f
,
27158 0.40f
, 0.50f
, 0.60f
, 0.70f
,
27159 0.80f
, 0.90f
, 0.05f
, 0.15f
,
27160 0.25f
, 0.35f
, 0.45f
, 0.55f
,
27162 static const struct vec4 expected_gather4_c
[] =
27164 {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
},
27165 {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
},
27166 {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
},
27167 {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
},
27169 static const struct vec4 expected_gather4_po_c
[] =
27171 {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
},
27172 {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
},
27173 {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
},
27174 {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
},
27176 static const struct vec4 white
= {1.0f
, 1.0f
, 1.0f
, 1.0f
};
27177 static const D3D11_SUBRESOURCE_DATA resource_data
= {&texture_data
, sizeof(texture_data
) / 4};
27179 if (!init_test_context(&test_context
, &feature_level
))
27182 device
= test_context
.device
;
27183 context
= test_context
.immediate_context
;
27185 sampler_desc
.Filter
= D3D11_FILTER_COMPARISON_MIN_MAG_MIP_POINT
;
27186 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
27187 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
27188 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
27189 sampler_desc
.MipLODBias
= 0.0f
;
27190 sampler_desc
.MaxAnisotropy
= 0;
27191 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_LESS_EQUAL
;
27192 sampler_desc
.BorderColor
[0] = 0.0f
;
27193 sampler_desc
.BorderColor
[1] = 0.0f
;
27194 sampler_desc
.BorderColor
[2] = 0.0f
;
27195 sampler_desc
.BorderColor
[3] = 0.0f
;
27196 sampler_desc
.MinLOD
= 0.0f
;
27197 sampler_desc
.MaxLOD
= D3D11_FLOAT32_MAX
;
27199 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler
);
27200 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
27201 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler
);
27203 texture_desc
.Width
= 4;
27204 texture_desc
.Height
= 4;
27205 texture_desc
.MipLevels
= 1;
27206 texture_desc
.ArraySize
= 1;
27207 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
27208 texture_desc
.SampleDesc
.Count
= 1;
27209 texture_desc
.SampleDesc
.Quality
= 0;
27210 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
27211 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
27212 texture_desc
.CPUAccessFlags
= 0;
27213 texture_desc
.MiscFlags
= 0;
27214 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rt
);
27215 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
27216 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rt
, NULL
, &rtv
);
27217 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
27218 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
27220 constant
.width
= texture_desc
.Width
;
27221 constant
.height
= texture_desc
.Height
;
27222 constant
.offset_x
= 1;
27223 constant
.offset_y
= 1;
27224 constant
.compare_value
= 0.5f
;
27225 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(constant
), &constant
);
27226 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
27228 texture_desc
.Format
= DXGI_FORMAT_R32_TYPELESS
;
27229 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
| D3D11_BIND_DEPTH_STENCIL
;
27230 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &texture
);
27231 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
27233 srv_desc
.Format
= DXGI_FORMAT_R32_FLOAT
;
27234 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_TEXTURE2D
;
27235 U(srv_desc
).Texture2D
.MostDetailedMip
= 0;
27236 U(srv_desc
).Texture2D
.MipLevels
= 1;
27237 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, &srv_desc
, &srv
);
27238 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
27239 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
27241 hr
= ID3D11Device_CreatePixelShader(device
, gather4_c_code
, sizeof(gather4_c_code
), NULL
, &ps
);
27242 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
27243 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
27245 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, &white
.x
);
27246 draw_quad(&test_context
);
27247 get_texture_readback(rt
, 0, &rb
);
27248 for (y
= 0; y
< texture_desc
.Height
; ++y
)
27250 for (x
= 0; x
< texture_desc
.Width
; ++x
)
27252 const struct vec4
*expected
= &expected_gather4_c
[y
* texture_desc
.Width
+ x
];
27253 const struct vec4
*got
= get_readback_vec4(&rb
, x
, y
);
27254 ok(compare_vec4(got
, expected
, 0),
27255 "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
27256 got
->x
, got
->y
, got
->z
, got
->w
, expected
->x
, expected
->y
, expected
->z
, expected
->w
);
27259 release_resource_readback(&rb
);
27260 ID3D11PixelShader_Release(ps
);
27262 hr
= ID3D11Device_CreatePixelShader(device
, gather4_po_c_code
, sizeof(gather4_po_c_code
), NULL
, &ps
);
27263 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
27264 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
27266 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, &white
.x
);
27267 draw_quad(&test_context
);
27268 get_texture_readback(rt
, 0, &rb
);
27269 for (y
= 0; y
< texture_desc
.Height
; ++y
)
27271 for (x
= 0; x
< texture_desc
.Width
; ++x
)
27273 const struct vec4
*expected
= &expected_gather4_po_c
[y
* texture_desc
.Width
+ x
];
27274 const struct vec4
*got
= get_readback_vec4(&rb
, x
, y
);
27275 ok(compare_vec4(got
, expected
, 0),
27276 "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
27277 got
->x
, got
->y
, got
->z
, got
->w
, expected
->x
, expected
->y
, expected
->z
, expected
->w
);
27280 release_resource_readback(&rb
);
27281 ID3D11PixelShader_Release(ps
);
27283 ID3D11ShaderResourceView_Release(srv
);
27284 ID3D11Texture2D_Release(texture
);
27286 ID3D11Buffer_Release(cb
);
27287 ID3D11Texture2D_Release(rt
);
27288 ID3D11RenderTargetView_Release(rtv
);
27289 ID3D11SamplerState_Release(sampler
);
27290 release_test_context(&test_context
);
27293 static float clamp_depth_bias(float bias
, float clamp
)
27296 return min(bias
, clamp
);
27298 return max(bias
, clamp
);
27302 static void test_depth_bias(void)
27304 struct vec3 vertices
[] =
27306 {-1.0f
, -1.0f
, 0.5f
},
27307 {-1.0f
, 1.0f
, 0.5f
},
27308 { 1.0f
, -1.0f
, 0.5f
},
27309 { 1.0f
, 1.0f
, 0.5f
},
27311 struct d3d11_test_context test_context
;
27312 D3D11_RASTERIZER_DESC rasterizer_desc
;
27313 struct swapchain_desc swapchain_desc
;
27314 D3D11_TEXTURE2D_DESC texture_desc
;
27315 ID3D11DeviceContext
*context
;
27316 double m
, bias
, depth
, data
;
27317 struct resource_readback rb
;
27318 ID3D11DepthStencilView
*dsv
;
27319 unsigned int expected_value
;
27320 ID3D11RasterizerState
*rs
;
27321 ID3D11Texture2D
*texture
;
27322 unsigned int format_idx
;
27323 unsigned int y
, i
, j
, k
;
27324 unsigned int shift
= 0;
27325 ID3D11Device
*device
;
27326 float *depth_values
;
27327 DXGI_FORMAT format
;
27333 static const struct
27345 static const int bias_tests
[] =
27347 -10000, -1000, -100, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
27348 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 50, 100, 200, 500, 1000, 10000,
27350 static const float bias_clamp_tests
[] =
27352 0.0f
, -1e-5f
, 1e-5f
,
27354 static const float quad_slopes
[] =
27358 static const float slope_scaled_bias_tests
[] =
27360 0.0f
, 0.5f
, 1.0f
, 2.0f
, 128.0f
, 1000.0f
, 10000.0f
,
27362 static const DXGI_FORMAT formats
[] =
27364 DXGI_FORMAT_D32_FLOAT
,
27365 DXGI_FORMAT_D24_UNORM_S8_UINT
,
27366 DXGI_FORMAT_D16_UNORM
,
27369 swapchain_desc
.windowed
= TRUE
;
27370 swapchain_desc
.buffer_count
= 1;
27371 swapchain_desc
.width
= 200;
27372 swapchain_desc
.height
= 200;
27373 swapchain_desc
.swap_effect
= DXGI_SWAP_EFFECT_DISCARD
;
27374 swapchain_desc
.flags
= 0;
27375 if (!init_test_context_ext(&test_context
, NULL
, &swapchain_desc
))
27378 device
= test_context
.device
;
27379 context
= test_context
.immediate_context
;
27381 memset(&rasterizer_desc
, 0, sizeof(rasterizer_desc
));
27382 rasterizer_desc
.FillMode
= D3D11_FILL_SOLID
;
27383 rasterizer_desc
.CullMode
= D3D11_CULL_NONE
;
27384 rasterizer_desc
.FrontCounterClockwise
= FALSE
;
27385 rasterizer_desc
.DepthBias
= 0;
27386 rasterizer_desc
.DepthBiasClamp
= 0.0f
;
27387 rasterizer_desc
.SlopeScaledDepthBias
= 0.0f
;
27388 rasterizer_desc
.DepthClipEnable
= TRUE
;
27390 depth_values
= heap_calloc(swapchain_desc
.height
, sizeof(*depth_values
));
27391 ok(!!depth_values
, "Failed to allocate memory.\n");
27393 for (format_idx
= 0; format_idx
< ARRAY_SIZE(formats
); ++format_idx
)
27395 format
= formats
[format_idx
];
27397 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
27398 texture_desc
.Format
= format
;
27399 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
27400 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
27401 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
27402 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, NULL
, &dsv
);
27403 ok(SUCCEEDED(hr
), "Failed to create render depth stencil view, hr %#x.\n", hr
);
27404 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &test_context
.backbuffer_rtv
, dsv
);
27405 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
| D3D11_CLEAR_STENCIL
, 1.0f
, 0);
27406 draw_quad_z(&test_context
, 1.0f
);
27409 case DXGI_FORMAT_D32_FLOAT
:
27410 check_texture_float(texture
, 1.0f
, 0);
27412 case DXGI_FORMAT_D24_UNORM_S8_UINT
:
27413 /* FIXME: Depth/stencil byte order is reversed in wined3d. */
27414 shift
= get_texture_color(texture
, 0, 0) == 0xffffff ? 0 : 8;
27416 check_texture_color(texture
, 0xffffff, 1);
27418 case DXGI_FORMAT_D16_UNORM
:
27419 get_texture_readback(texture
, 0, &rb
);
27420 check_readback_data_u16(&rb
, NULL
, 0xffffu
, 0);
27421 release_resource_readback(&rb
);
27424 trace("Unhandled format %#x.\n", format
);
27427 draw_quad(&test_context
);
27430 for (i
= 0; i
< ARRAY_SIZE(quads
); ++i
)
27432 for (j
= 0; j
< ARRAY_SIZE(vertices
); ++j
)
27433 vertices
[j
].z
= quads
[i
].z
;
27434 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)test_context
.vb
,
27435 0, NULL
, vertices
, 0, 0);
27437 for (j
= 0; j
< ARRAY_SIZE(bias_tests
); ++j
)
27439 rasterizer_desc
.DepthBias
= bias_tests
[j
];
27441 for (k
= 0; k
< ARRAY_SIZE(bias_clamp_tests
); ++k
)
27443 rasterizer_desc
.DepthBiasClamp
= bias_clamp_tests
[k
];
27444 ID3D11Device_CreateRasterizerState(device
, &rasterizer_desc
, &rs
);
27445 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
27446 ID3D11DeviceContext_RSSetState(context
, rs
);
27447 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
27448 draw_quad(&test_context
);
27451 case DXGI_FORMAT_D32_FLOAT
:
27452 bias
= rasterizer_desc
.DepthBias
* pow(2.0f
, quads
[i
].exponent
- 23.0f
);
27453 bias
= clamp_depth_bias(bias
, rasterizer_desc
.DepthBiasClamp
);
27454 depth
= min(max(0.0f
, quads
[i
].z
+ bias
), 1.0f
);
27456 check_texture_float(texture
, depth
, 2);
27458 case DXGI_FORMAT_D24_UNORM_S8_UINT
:
27459 bias
= clamp_depth_bias(rasterizer_desc
.DepthBias
/ 16777215.0f
,
27460 rasterizer_desc
.DepthBiasClamp
);
27461 depth
= min(max(0.0f
, quads
[i
].z
+ bias
), 1.0f
);
27463 get_texture_readback(texture
, 0, &rb
);
27464 check_readback_data_u24(&rb
, NULL
, shift
, depth
* 16777215.0f
+ 0.5f
, 1);
27465 release_resource_readback(&rb
);
27467 case DXGI_FORMAT_D16_UNORM
:
27468 bias
= clamp_depth_bias(rasterizer_desc
.DepthBias
/ 65535.0f
,
27469 rasterizer_desc
.DepthBiasClamp
);
27470 depth
= min(max(0.0f
, quads
[i
].z
+ bias
), 1.0f
);
27472 get_texture_readback(texture
, 0, &rb
);
27473 check_readback_data_u16(&rb
, NULL
, depth
* 65535.0f
+ 0.5f
, 1);
27474 release_resource_readback(&rb
);
27479 ID3D11RasterizerState_Release(rs
);
27484 /* SlopeScaledDepthBias */
27485 rasterizer_desc
.DepthBias
= 0;
27486 for (i
= 0; i
< ARRAY_SIZE(quad_slopes
); ++i
)
27488 for (j
= 0; j
< ARRAY_SIZE(vertices
); ++j
)
27489 vertices
[j
].z
= j
== 1 || j
== 3 ? 0.0f
: quad_slopes
[i
];
27490 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)test_context
.vb
,
27491 0, NULL
, vertices
, 0, 0);
27493 ID3D11DeviceContext_RSSetState(context
, NULL
);
27494 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
27495 draw_quad(&test_context
);
27496 get_texture_readback(texture
, 0, &rb
);
27497 for (y
= 0; y
< texture_desc
.Height
; ++y
)
27501 case DXGI_FORMAT_D32_FLOAT
:
27502 depth_values
[y
] = get_readback_float(&rb
, 0, y
);
27504 case DXGI_FORMAT_D24_UNORM_S8_UINT
:
27505 u32
= get_readback_data(&rb
, 0, y
, 0, sizeof(*u32
));
27506 u32_value
= *u32
>> shift
;
27507 depth_values
[y
] = u32_value
/ 16777215.0f
;
27509 case DXGI_FORMAT_D16_UNORM
:
27510 u16
= get_readback_data(&rb
, 0, y
, 0, sizeof(*u16
));
27511 depth_values
[y
] = *u16
/ 65535.0f
;
27517 release_resource_readback(&rb
);
27519 for (j
= 0; j
< ARRAY_SIZE(slope_scaled_bias_tests
); ++j
)
27521 rasterizer_desc
.SlopeScaledDepthBias
= slope_scaled_bias_tests
[j
];
27523 for (k
= 0; k
< ARRAY_SIZE(bias_clamp_tests
); ++k
)
27525 BOOL all_match
= TRUE
;
27526 rasterizer_desc
.DepthBiasClamp
= bias_clamp_tests
[k
];
27527 ID3D11Device_CreateRasterizerState(device
, &rasterizer_desc
, &rs
);
27528 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
27529 ID3D11DeviceContext_RSSetState(context
, rs
);
27530 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
27531 draw_quad(&test_context
);
27533 m
= quad_slopes
[i
] / texture_desc
.Height
;
27534 bias
= clamp_depth_bias(rasterizer_desc
.SlopeScaledDepthBias
* m
, rasterizer_desc
.DepthBiasClamp
);
27535 get_texture_readback(texture
, 0, &rb
);
27536 for (y
= 0; y
< texture_desc
.Height
&& all_match
; ++y
)
27538 depth
= min(max(0.0f
, depth_values
[y
] + bias
), 1.0f
);
27541 case DXGI_FORMAT_D32_FLOAT
:
27542 data
= get_readback_float(&rb
, 0, y
);
27543 all_match
= compare_float(data
, depth
, 64);
27545 "Got depth %.8e, expected %.8e.\n", data
, depth
);
27547 case DXGI_FORMAT_D24_UNORM_S8_UINT
:
27548 u32
= get_readback_data(&rb
, 0, y
, 0, sizeof(*u32
));
27549 u32_value
= *u32
>> shift
;
27550 expected_value
= depth
* 16777215.0f
+ 0.5f
;
27551 all_match
= compare_uint(u32_value
, expected_value
, 3);
27553 "Got value %#x (%.8e), expected %#x (%.8e).\n",
27554 u32_value
, u32_value
/ 16777215.0f
,
27555 expected_value
, expected_value
/ 16777215.0f
);
27557 case DXGI_FORMAT_D16_UNORM
:
27558 u16
= get_readback_data(&rb
, 0, y
, 0, sizeof(*u16
));
27559 expected_value
= depth
* 65535.0f
+ 0.5f
;
27560 all_match
= compare_uint(*u16
, expected_value
, 1);
27562 "Got value %#x (%.8e), expected %#x (%.8e).\n",
27563 *u16
, *u16
/ 65535.0f
, expected_value
, expected_value
/ 65535.0f
);
27569 release_resource_readback(&rb
);
27570 ID3D11RasterizerState_Release(rs
);
27575 ID3D11Texture2D_Release(texture
);
27576 ID3D11DepthStencilView_Release(dsv
);
27579 heap_free(depth_values
);
27580 release_test_context(&test_context
);
27583 static void test_fractional_viewports(void)
27585 struct d3d11_test_context test_context
;
27586 D3D11_TEXTURE2D_DESC texture_desc
;
27587 ID3D11InputLayout
*input_layout
;
27588 ID3D11DeviceContext
*context
;
27589 struct resource_readback rb
;
27590 ID3D11RenderTargetView
*rtv
;
27591 ID3D11VertexShader
*vs
;
27592 ID3D11PixelShader
*ps
;
27593 unsigned int i
, x
, y
;
27594 ID3D11Device
*device
;
27595 ID3D11Texture2D
*rt
;
27596 UINT offset
, stride
;
27600 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
27601 static const DWORD vs_code
[] =
27604 void main(in float4 in_position
: POSITION
,
27605 in float2 in_texcoord
: TEXCOORD
,
27606 out float4 position
: SV_Position
,
27607 out float2 texcoord
: TEXCOORD
)
27609 position
= in_position
;
27610 texcoord
= in_texcoord
;
27613 0x43425844, 0x4df282ca, 0x85c8bbfc, 0xd44ad19f, 0x1158be97, 0x00000001, 0x00000148, 0x00000003,
27614 0x0000002c, 0x00000080, 0x000000d8, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
27615 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
27616 0x00000003, 0x00000001, 0x00000303, 0x49534f50, 0x4e4f4954, 0x58455400, 0x524f4f43, 0xabab0044,
27617 0x4e47534f, 0x00000050, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
27618 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000c03,
27619 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f, 0xababab00, 0x52444853, 0x00000068,
27620 0x00010040, 0x0000001a, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x00101032, 0x00000001,
27621 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102032, 0x00000001, 0x05000036,
27622 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x00102032, 0x00000001, 0x00101046,
27623 0x00000001, 0x0100003e,
27625 static const DWORD ps_code
[] =
27628 float4
main(float4 position
: SV_Position
,
27629 float2 texcoord
: TEXCOORD
) : SV_Target
27631 return float4(position
.xy
, texcoord
);
27634 0x43425844, 0xa15616bc, 0x6862ab1c, 0x28b915c0, 0xdb0df67c, 0x00000001, 0x0000011c, 0x00000003,
27635 0x0000002c, 0x00000084, 0x000000b8, 0x4e475349, 0x00000050, 0x00000002, 0x00000008, 0x00000038,
27636 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x00000044, 0x00000000, 0x00000000,
27637 0x00000003, 0x00000001, 0x00000303, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f,
27638 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
27639 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x0000005c,
27640 0x00000040, 0x00000017, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03001062, 0x00101032,
27641 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036, 0x00102032, 0x00000000, 0x00101046,
27642 0x00000000, 0x05000036, 0x001020c2, 0x00000000, 0x00101406, 0x00000001, 0x0100003e,
27644 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
27646 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
27647 {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 8, D3D11_INPUT_PER_VERTEX_DATA
, 0},
27649 static const struct
27651 struct vec2 position
;
27652 struct vec2 texcoord
;
27656 {{-1.0f
, -1.0f
}, {0.0f
, 0.0f
}},
27657 {{-1.0f
, 1.0f
}, {0.0f
, 1.0f
}},
27658 {{ 1.0f
, -1.0f
}, {1.0f
, 0.0f
}},
27659 {{ 1.0f
, 1.0f
}, {1.0f
, 1.0f
}},
27661 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
27662 static const float viewport_offsets
[] =
27664 0.0f
, 1.0f
/ 2.0f
, 1.0f
/ 4.0f
, 1.0f
/ 8.0f
, 1.0f
/ 16.0f
, 1.0f
/ 32.0f
,
27665 1.0f
/ 64.0f
, 1.0f
/ 128.0f
, 1.0f
/ 256.0f
, 63.0f
/ 128.0f
,
27668 if (!init_test_context(&test_context
, &feature_level
))
27670 device
= test_context
.device
;
27671 context
= test_context
.immediate_context
;
27673 texture_desc
.Width
= 4;
27674 texture_desc
.Height
= 4;
27675 texture_desc
.MipLevels
= 1;
27676 texture_desc
.ArraySize
= 1;
27677 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
27678 texture_desc
.SampleDesc
.Count
= 1;
27679 texture_desc
.SampleDesc
.Quality
= 0;
27680 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
27681 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
27682 texture_desc
.CPUAccessFlags
= 0;
27683 texture_desc
.MiscFlags
= 0;
27684 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rt
);
27685 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
27686 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rt
, NULL
, &rtv
);
27687 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
27688 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
27690 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
27691 vs_code
, sizeof(vs_code
), &input_layout
);
27692 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
27693 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(quad
), quad
);
27695 ID3D11DeviceContext_IASetInputLayout(context
, input_layout
);
27696 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
27697 stride
= sizeof(*quad
);
27699 ID3D11DeviceContext_IASetVertexBuffers(context
, 0, 1, &vb
, &stride
, &offset
);
27701 hr
= ID3D11Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), NULL
, &vs
);
27702 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
27703 ID3D11DeviceContext_VSSetShader(context
, vs
, NULL
, 0);
27705 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
27706 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
27707 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
27709 for (i
= 0; i
< ARRAY_SIZE(viewport_offsets
); ++i
)
27711 set_viewport(context
, viewport_offsets
[i
], viewport_offsets
[i
],
27712 texture_desc
.Width
, texture_desc
.Height
, 0.0f
, 1.0f
);
27713 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, white
);
27714 ID3D11DeviceContext_Draw(context
, 4, 0);
27715 get_texture_readback(rt
, 0, &rb
);
27716 for (y
= 0; y
< texture_desc
.Height
; ++y
)
27718 for (x
= 0; x
< texture_desc
.Width
; ++x
)
27720 const struct vec4
*v
= get_readback_vec4(&rb
, x
, y
);
27721 struct vec4 expected
= {x
+ 0.5f
, y
+ 0.5f
,
27722 (x
+ 0.5f
- viewport_offsets
[i
]) / texture_desc
.Width
,
27723 1.0f
- (y
+ 0.5f
- viewport_offsets
[i
]) / texture_desc
.Height
};
27724 ok(compare_float(v
->x
, expected
.x
, 0) && compare_float(v
->y
, expected
.y
, 0),
27725 "Got fragcoord {%.8e, %.8e}, expected {%.8e, %.8e} at (%u, %u), offset %.8e.\n",
27726 v
->x
, v
->y
, expected
.x
, expected
.y
, x
, y
, viewport_offsets
[i
]);
27728 ok(compare_float(v
->z
, expected
.z
, 2) && compare_float(v
->w
, expected
.w
, 2),
27729 "Got texcoord {%.8e, %.8e}, expected {%.8e, %.8e} at (%u, %u), offset %.8e.\n",
27730 v
->z
, v
->w
, expected
.z
, expected
.w
, x
, y
, viewport_offsets
[i
]);
27733 release_resource_readback(&rb
);
27736 ID3D11InputLayout_Release(input_layout
);
27737 ID3D11Buffer_Release(vb
);
27738 ID3D11VertexShader_Release(vs
);
27739 ID3D11PixelShader_Release(ps
);
27740 ID3D11RenderTargetView_Release(rtv
);
27741 ID3D11Texture2D_Release(rt
);
27742 release_test_context(&test_context
);
27745 static void test_negative_viewports(const D3D_FEATURE_LEVEL feature_level
)
27747 struct d3d11_test_context test_context
;
27748 ID3D11DeviceContext
*context
;
27752 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
27753 static const struct vec4 green
= {0.0f
, 1.0f
, 0.0f
, 1.0f
};
27755 if (!init_test_context(&test_context
, &feature_level
))
27757 context
= test_context
.immediate_context
;
27759 set_viewport(context
, 0.0f
, 0.0f
, 640.0f
, 480.0f
, 0.0f
, 1.0f
);
27760 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
27761 draw_color_quad(&test_context
, &green
);
27762 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
27764 set_viewport(context
, -0.0f
, -0.0f
, 640.0f
, 480.0f
, 0.0f
, 1.0f
);
27765 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
27766 draw_color_quad(&test_context
, &green
);
27767 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
27769 /* For feature levels greater than or equal to 11_0, a negative top left
27770 * corner shifts the bottom right corner by a whole integer. It seems that
27771 * floor() is used to round viewport corners to integers.
27773 quirk
= feature_level
>= D3D_FEATURE_LEVEL_11_0
;
27775 set_viewport(context
, -0.4f
, -0.4f
, 640.0f
, 480.0f
, 0.0f
, 1.0f
);
27776 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
27777 draw_color_quad(&test_context
, &green
);
27778 SetRect(&rect
, 0, 0, 639, 479);
27779 check_texture_sub_resource_color(test_context
.backbuffer
, 0, &rect
, 0xff00ff00, 1);
27780 SetRect(&rect
, 639, 479, 640, 480);
27781 todo_wine_if(quirk
)
27782 check_texture_sub_resource_color(test_context
.backbuffer
, 0, &rect
, quirk
? 0xffffffff : 0xff00ff00, 1);
27784 set_viewport(context
, -1.0f
/ 128.0f
, -1.0 / 128.0f
, 640.0f
, 480.0f
, 0.0f
, 1.0f
);
27785 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
27786 draw_color_quad(&test_context
, &green
);
27787 SetRect(&rect
, 0, 0, 639, 479);
27788 check_texture_sub_resource_color(test_context
.backbuffer
, 0, &rect
, 0xff00ff00, 1);
27789 SetRect(&rect
, 639, 479, 640, 480);
27790 todo_wine_if(quirk
)
27791 check_texture_sub_resource_color(test_context
.backbuffer
, 0, &rect
, quirk
? 0xffffffff : 0xff00ff00, 1);
27793 release_test_context(&test_context
);
27796 static void test_early_depth_stencil(void)
27798 ID3D11DepthStencilState
*depth_stencil_state
;
27799 D3D11_DEPTH_STENCIL_DESC depth_stencil_desc
;
27800 ID3D11Texture2D
*texture
, *depth_texture
;
27801 struct d3d11_test_context test_context
;
27802 D3D11_TEXTURE2D_DESC texture_desc
;
27803 ID3D11UnorderedAccessView
*uav
;
27804 ID3D11DeviceContext
*context
;
27805 ID3D11DepthStencilView
*dsv
;
27806 ID3D11PixelShader
*ps
;
27807 ID3D11Device
*device
;
27810 static const DWORD ps_code
[] =
27813 RWTexture2D
<int> u
;
27815 [earlydepthstencil
]
27816 float4
main() : SV_Target
27818 InterlockedAdd(u
[uint2(0, 0)], 1);
27819 return float4(1.0f
, 1.0f
, 1.0f
, 1.0f
);
27822 0x43425844, 0xda4325ad, 0xc01d3815, 0xfd610cc9, 0x8ed1e351, 0x00000001, 0x000000ec, 0x00000003,
27823 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
27824 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
27825 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000074, 0x00000050, 0x0000001d,
27826 0x0100286a, 0x0400189c, 0x0011e000, 0x00000001, 0x00003333, 0x03000065, 0x001020f2, 0x00000000,
27827 0x0a0000ad, 0x0011e000, 0x00000001, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
27828 0x00004001, 0x00000001, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x3f800000,
27829 0x3f800000, 0x3f800000, 0x0100003e,
27831 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
27832 static const UINT values
[4] = {0};
27834 if (!init_test_context(&test_context
, &feature_level
))
27837 device
= test_context
.device
;
27838 context
= test_context
.immediate_context
;
27840 depth_stencil_desc
.DepthEnable
= TRUE
;
27841 depth_stencil_desc
.DepthWriteMask
= D3D11_DEPTH_WRITE_MASK_ZERO
;
27842 depth_stencil_desc
.DepthFunc
= D3D11_COMPARISON_LESS_EQUAL
;
27843 depth_stencil_desc
.StencilEnable
= FALSE
;
27844 hr
= ID3D11Device_CreateDepthStencilState(device
, &depth_stencil_desc
, &depth_stencil_state
);
27845 ok(SUCCEEDED(hr
), "Failed to create depth stencil state, hr %#x.\n", hr
);
27847 texture_desc
.Width
= 1;
27848 texture_desc
.Height
= 1;
27849 texture_desc
.MipLevels
= 1;
27850 texture_desc
.ArraySize
= 1;
27851 texture_desc
.Format
= DXGI_FORMAT_R32_SINT
;
27852 texture_desc
.SampleDesc
.Count
= 1;
27853 texture_desc
.SampleDesc
.Quality
= 0;
27854 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
27855 texture_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
27856 texture_desc
.CPUAccessFlags
= 0;
27857 texture_desc
.MiscFlags
= 0;
27858 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
27859 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
27860 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)texture
, NULL
, &uav
);
27861 ok(SUCCEEDED(hr
), "Failed to create unordered access view, hr %#x.\n", hr
);
27863 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
27864 texture_desc
.Format
= DXGI_FORMAT_D32_FLOAT
;
27865 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
27866 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
27867 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &depth_texture
);
27868 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
27869 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)depth_texture
, NULL
, &dsv
);
27870 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
27872 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
27873 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
27874 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
27876 set_viewport(context
, 0.0f
, 0.0f
, 1.0f
, 100.0f
, 0.5f
, 0.5f
);
27877 ID3D11DeviceContext_OMSetDepthStencilState(context
, depth_stencil_state
, 0);
27878 ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context
,
27879 1, &test_context
.backbuffer_rtv
, dsv
, 1, 1, &uav
, NULL
);
27881 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, values
);
27883 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 0.6f
, 0);
27884 draw_quad(&test_context
);
27885 check_texture_color(texture
, 100, 1);
27886 draw_quad(&test_context
);
27887 check_texture_color(texture
, 200, 1);
27888 check_texture_float(depth_texture
, 0.6f
, 1);
27890 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 0.3f
, 0);
27891 draw_quad(&test_context
);
27892 draw_quad(&test_context
);
27893 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 0.55f
, 0);
27894 draw_quad(&test_context
);
27895 check_texture_color(texture
, 300, 1);
27897 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 0.5f
, 0);
27898 draw_quad(&test_context
);
27899 check_texture_color(texture
, 400, 1);
27900 check_texture_float(depth_texture
, 0.5f
, 1);
27902 ID3D11Texture2D_Release(depth_texture
);
27903 ID3D11DepthStencilView_Release(dsv
);
27904 ID3D11DepthStencilState_Release(depth_stencil_state
);
27905 ID3D11PixelShader_Release(ps
);
27906 ID3D11Texture2D_Release(texture
);
27907 ID3D11UnorderedAccessView_Release(uav
);
27908 release_test_context(&test_context
);
27911 static void test_conservative_depth_output(void)
27919 ID3D11DepthStencilState
*depth_stencil_state
;
27920 D3D11_DEPTH_STENCIL_DESC depth_stencil_desc
;
27921 struct d3d11_test_context test_context
;
27922 const struct shader
*current_shader
;
27923 D3D11_TEXTURE2D_DESC texture_desc
;
27924 ID3D11DeviceContext
*context
;
27925 ID3D11DepthStencilView
*dsv
;
27926 ID3D11Texture2D
*texture
;
27927 ID3D11PixelShader
*ps
;
27928 DWORD expected_color
;
27929 float expected_depth
;
27930 ID3D11Device
*device
;
27931 struct vec4 ps_depth
;
27936 static const DWORD ps_depth_le_code
[] =
27941 float4
main(out
float out_depth
: SV_DepthLessEqual
) : SV_Target0
27944 return float4(0.0f
, 1.0f
, 0.f
, 1.0f
);
27947 0x43425844, 0x045c8d00, 0xc49e2ebe, 0x76f6022a, 0xf6996ecc, 0x00000001, 0x00000108, 0x00000003,
27948 0x0000002c, 0x0000003c, 0x00000098, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
27949 0x00000054, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
27950 0x0000000f, 0x00000042, 0x00000000, 0x00000000, 0x00000003, 0xffffffff, 0x00000e01, 0x545f5653,
27951 0x65677261, 0x56530074, 0x7065445f, 0x654c6874, 0x71457373, 0x006c6175, 0x58454853, 0x00000068,
27952 0x00000050, 0x0000001a, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065,
27953 0x001020f2, 0x00000000, 0x02000065, 0x00027001, 0x08000036, 0x001020f2, 0x00000000, 0x00004002,
27954 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x05000036, 0x00027001, 0x0020800a, 0x00000000,
27955 0x00000000, 0x0100003e,
27957 static const struct shader ps_depth_le
= {ps_depth_le_code
, sizeof(ps_depth_le_code
)};
27958 static const DWORD ps_depth_ge_code
[] =
27963 float4
main(out
float out_depth
: SV_DepthGreaterEqual
) : SV_Target0
27966 return float4(0.0f
, 1.0f
, 0.f
, 1.0f
);
27969 0x43425844, 0xd17af83e, 0xa32c01cc, 0x0d8e9665, 0xe6dc17c2, 0x00000001, 0x0000010c, 0x00000003,
27970 0x0000002c, 0x0000003c, 0x0000009c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
27971 0x00000058, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
27972 0x0000000f, 0x00000042, 0x00000000, 0x00000000, 0x00000003, 0xffffffff, 0x00000e01, 0x545f5653,
27973 0x65677261, 0x56530074, 0x7065445f, 0x72476874, 0x65746165, 0x75714572, 0xab006c61, 0x58454853,
27974 0x00000068, 0x00000050, 0x0000001a, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001,
27975 0x03000065, 0x001020f2, 0x00000000, 0x02000065, 0x00026001, 0x08000036, 0x001020f2, 0x00000000,
27976 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x05000036, 0x00026001, 0x0020800a,
27977 0x00000000, 0x00000000, 0x0100003e,
27979 static const struct shader ps_depth_ge
= {ps_depth_ge_code
, sizeof(ps_depth_ge_code
)};
27980 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
27981 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
27982 static const struct
27984 const struct shader
*ps
;
27987 BOOL passes_depth_test
;
27991 {&ps_depth_le
, 0.7f
, 0.7f
, TRUE
},
27992 {&ps_depth_le
, 0.7f
, 0.4f
, FALSE
},
27993 {&ps_depth_le
, 0.4f
, 0.4f
, FALSE
},
27994 /* {&ps_depth_le, 0.4f, 0.6f, FALSE}, undefined result */
27995 {&ps_depth_ge
, 0.7f
, 0.7f
, TRUE
},
27996 /* {&ps_depth_ge, 0.7f, 0.4f, TRUE}, undefined result */
27997 {&ps_depth_ge
, 0.4f
, 0.4f
, FALSE
},
27998 {&ps_depth_ge
, 0.4f
, 0.6f
, TRUE
},
28001 if (!init_test_context(&test_context
, &feature_level
))
28004 device
= test_context
.device
;
28005 context
= test_context
.immediate_context
;
28007 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(ps_depth
), NULL
);
28009 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
28010 texture_desc
.Format
= DXGI_FORMAT_D32_FLOAT
;
28011 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
28012 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
28013 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
28014 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
28015 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, NULL
, &dsv
);
28016 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
28018 depth_stencil_desc
.DepthEnable
= TRUE
;
28019 depth_stencil_desc
.DepthWriteMask
= D3D11_DEPTH_WRITE_MASK_ALL
;
28020 depth_stencil_desc
.DepthFunc
= D3D11_COMPARISON_GREATER_EQUAL
;
28021 depth_stencil_desc
.StencilEnable
= FALSE
;
28022 hr
= ID3D11Device_CreateDepthStencilState(device
, &depth_stencil_desc
, &depth_stencil_state
);
28023 ok(SUCCEEDED(hr
), "Failed to create depth stencil state, hr %#x.\n", hr
);
28025 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
28026 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &test_context
.backbuffer_rtv
, dsv
);
28027 ID3D11DeviceContext_OMSetDepthStencilState(context
, depth_stencil_state
, 0);
28030 current_shader
= NULL
;
28031 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
28033 if (current_shader
!= tests
[i
].ps
)
28036 ID3D11PixelShader_Release(ps
);
28038 current_shader
= tests
[i
].ps
;
28039 hr
= ID3D11Device_CreatePixelShader(device
, current_shader
->code
, current_shader
->size
, NULL
, &ps
);
28040 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
28041 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
28044 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
28045 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 0.5f
, 0);
28046 ps_depth
.x
= tests
[i
].ps_depth
;
28047 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &ps_depth
, 0, 0);
28048 draw_quad_z(&test_context
, tests
[i
].vs_depth
);
28050 expected_color
= tests
[i
].passes_depth_test
? 0xff00ff00 : 0xffffffff;
28051 expected_depth
= tests
[i
].passes_depth_test
? max(tests
[i
].vs_depth
, tests
[i
].ps_depth
) : 0.5f
;
28052 check_texture_color(test_context
.backbuffer
, expected_color
, 0);
28053 check_texture_float(texture
, expected_depth
, 1);
28056 ID3D11Buffer_Release(cb
);
28057 ID3D11PixelShader_Release(ps
);
28058 ID3D11DepthStencilView_Release(dsv
);
28059 ID3D11DepthStencilState_Release(depth_stencil_state
);
28060 ID3D11Texture2D_Release(texture
);
28061 release_test_context(&test_context
);
28064 static void test_format_compatibility(void)
28066 ID3D11Texture2D
*dst_texture
, *src_texture
;
28067 D3D11_SUBRESOURCE_DATA resource_data
;
28068 D3D11_TEXTURE2D_DESC texture_desc
;
28069 ID3D11DeviceContext
*context
;
28070 struct resource_readback rb
;
28071 DWORD colour
, expected
;
28072 ID3D11Device
*device
;
28077 static const struct
28079 DXGI_FORMAT src_format
;
28080 DXGI_FORMAT dst_format
;
28086 {DXGI_FORMAT_R8G8B8A8_TYPELESS
, DXGI_FORMAT_R8G8B8A8_UNORM
, 4, TRUE
},
28087 {DXGI_FORMAT_R8G8B8A8_UNORM
, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
, 4, TRUE
},
28088 {DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
, DXGI_FORMAT_R8G8B8A8_UINT
, 4, TRUE
},
28089 {DXGI_FORMAT_R8G8B8A8_UINT
, DXGI_FORMAT_R8G8B8A8_SNORM
, 4, TRUE
},
28090 {DXGI_FORMAT_R8G8B8A8_SNORM
, DXGI_FORMAT_R8G8B8A8_SINT
, 4, TRUE
},
28091 {DXGI_FORMAT_R8G8B8A8_SINT
, DXGI_FORMAT_R8G8B8A8_TYPELESS
, 4, TRUE
},
28092 {DXGI_FORMAT_R8G8B8A8_UNORM
, DXGI_FORMAT_B8G8R8A8_UNORM
, 4, FALSE
},
28093 {DXGI_FORMAT_R8G8B8A8_UINT
, DXGI_FORMAT_R16G16_UINT
, 4, FALSE
},
28094 {DXGI_FORMAT_R16G16_TYPELESS
, DXGI_FORMAT_R16G16_FLOAT
, 4, TRUE
},
28095 {DXGI_FORMAT_R16G16_FLOAT
, DXGI_FORMAT_R16G16_UNORM
, 4, TRUE
},
28096 {DXGI_FORMAT_R16G16_UNORM
, DXGI_FORMAT_R16G16_UINT
, 4, TRUE
},
28097 {DXGI_FORMAT_R16G16_UINT
, DXGI_FORMAT_R16G16_SNORM
, 4, TRUE
},
28098 {DXGI_FORMAT_R16G16_SNORM
, DXGI_FORMAT_R16G16_SINT
, 4, TRUE
},
28099 {DXGI_FORMAT_R16G16_SINT
, DXGI_FORMAT_R16G16_TYPELESS
, 4, TRUE
},
28100 {DXGI_FORMAT_R16G16_TYPELESS
, DXGI_FORMAT_R32_TYPELESS
, 4, FALSE
},
28101 {DXGI_FORMAT_R9G9B9E5_SHAREDEXP
, DXGI_FORMAT_R32_TYPELESS
, 4, TRUE
},
28102 {DXGI_FORMAT_R9G9B9E5_SHAREDEXP
, DXGI_FORMAT_R32_FLOAT
, 4, TRUE
},
28103 {DXGI_FORMAT_R9G9B9E5_SHAREDEXP
, DXGI_FORMAT_R32_UINT
, 4, TRUE
},
28104 {DXGI_FORMAT_R9G9B9E5_SHAREDEXP
, DXGI_FORMAT_R32_SINT
, 4, TRUE
},
28105 {DXGI_FORMAT_R9G9B9E5_SHAREDEXP
, DXGI_FORMAT_R8G8B8A8_TYPELESS
, 4, FALSE
},
28106 {DXGI_FORMAT_R9G9B9E5_SHAREDEXP
, DXGI_FORMAT_B8G8R8A8_TYPELESS
, 4, FALSE
},
28107 {DXGI_FORMAT_R9G9B9E5_SHAREDEXP
, DXGI_FORMAT_R16G16_TYPELESS
, 4, FALSE
},
28108 {DXGI_FORMAT_R32G32_TYPELESS
, DXGI_FORMAT_R32G32_FLOAT
, 8, TRUE
},
28109 {DXGI_FORMAT_R32G32_FLOAT
, DXGI_FORMAT_R32G32_UINT
, 8, TRUE
},
28110 {DXGI_FORMAT_R32G32_UINT
, DXGI_FORMAT_R32G32_SINT
, 8, TRUE
},
28111 {DXGI_FORMAT_R32G32_SINT
, DXGI_FORMAT_R32G32_TYPELESS
, 8, TRUE
},
28113 static const DWORD initial_data
[16] = {0};
28114 static const DWORD bitmap_data
[] =
28116 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
28117 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
28118 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
28119 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
28122 if (!(device
= create_device(NULL
)))
28124 skip("Failed to create device.\n");
28127 ID3D11Device_GetImmediateContext(device
, &context
);
28129 texture_desc
.Height
= 4;
28130 texture_desc
.MipLevels
= 1;
28131 texture_desc
.ArraySize
= 1;
28132 texture_desc
.SampleDesc
.Count
= 1;
28133 texture_desc
.SampleDesc
.Quality
= 0;
28134 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
28135 texture_desc
.CPUAccessFlags
= 0;
28136 texture_desc
.MiscFlags
= 0;
28138 for (i
= 0; i
< ARRAY_SIZE(test_data
); ++i
)
28140 unsigned int x
, y
, texel_dwords
;
28141 BOOL broken
= FALSE
;
28144 texture_desc
.Width
= sizeof(bitmap_data
) / (texture_desc
.Height
* test_data
[i
].texel_size
);
28145 texture_desc
.Format
= test_data
[i
].src_format
;
28146 texture_desc
.Usage
= D3D11_USAGE_IMMUTABLE
;
28148 resource_data
.pSysMem
= bitmap_data
;
28149 resource_data
.SysMemPitch
= texture_desc
.Width
* test_data
[i
].texel_size
;
28150 resource_data
.SysMemSlicePitch
= 0;
28152 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &src_texture
);
28153 ok(SUCCEEDED(hr
), "Failed to create source texture, hr %#x.\n", hr
);
28155 texture_desc
.Format
= test_data
[i
].dst_format
;
28156 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
28158 resource_data
.pSysMem
= initial_data
;
28160 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &dst_texture
);
28161 ok(SUCCEEDED(hr
), "Failed to create destination texture, hr %#x.\n", hr
);
28163 set_box(&box
, 0, 0, 0, texture_desc
.Width
- 1, texture_desc
.Height
- 1, 1);
28164 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0, 1, 1, 0,
28165 (ID3D11Resource
*)src_texture
, 0, &box
);
28167 texel_dwords
= test_data
[i
].texel_size
/ sizeof(DWORD
);
28168 get_texture_readback(dst_texture
, 0, &rb
);
28169 colour
= get_readback_color(&rb
, 0, 0, 0);
28170 if (test_data
[i
].src_format
== DXGI_FORMAT_R9G9B9E5_SHAREDEXP
&& colour
== bitmap_data
[0])
28172 win_skip("Broken destination offset for %#x -> %#x copy.\n",
28173 test_data
[i
].src_format
, test_data
[i
].dst_format
);
28176 for (j
= 0; j
< ARRAY_SIZE(bitmap_data
) && !broken
; ++j
)
28180 colour
= get_readback_color(&rb
, x
, y
, 0);
28181 expected
= test_data
[i
].success
&& x
>= texel_dwords
&& y
28182 ? bitmap_data
[j
- (4 + texel_dwords
)] : initial_data
[j
];
28183 ok(colour
== expected
, "Test %u: Got unexpected colour 0x%08x at (%u, %u), expected 0x%08x.\n",
28184 i
, colour
, x
, y
, expected
);
28186 release_resource_readback(&rb
);
28188 ID3D11DeviceContext_CopyResource(context
, (ID3D11Resource
*)dst_texture
, (ID3D11Resource
*)src_texture
);
28190 get_texture_readback(dst_texture
, 0, &rb
);
28191 for (j
= 0; j
< ARRAY_SIZE(bitmap_data
); ++j
)
28195 colour
= get_readback_color(&rb
, x
, y
, 0);
28196 expected
= test_data
[i
].success
? bitmap_data
[j
] : initial_data
[j
];
28197 ok(colour
== expected
, "Test %u: Got unexpected colour 0x%08x at (%u, %u), expected 0x%08x.\n",
28198 i
, colour
, x
, y
, expected
);
28200 release_resource_readback(&rb
);
28202 ID3D11Texture2D_Release(dst_texture
);
28203 ID3D11Texture2D_Release(src_texture
);
28206 ID3D11DeviceContext_Release(context
);
28207 refcount
= ID3D11Device_Release(device
);
28208 ok(!refcount
, "Device has %u references left.\n", refcount
);
28211 static void test_compressed_format_compatibility(const D3D_FEATURE_LEVEL feature_level
)
28213 const struct format_info
*src_format
, *dst_format
;
28214 unsigned int row_block_count
, row_count
, i
, j
, k
;
28215 ID3D11Texture2D
*src_texture
, *dst_texture
;
28216 BOOL supported
, broken_dst_offset
= FALSE
;
28217 D3D11_SUBRESOURCE_DATA resource_data
;
28218 D3D11_TEXTURE2D_DESC texture_desc
;
28219 ID3D11DeviceContext
*context
;
28220 unsigned int block_idx
, x
, y
;
28221 struct resource_readback rb
;
28222 DWORD colour
, expected
;
28223 ID3D11Device
*device
;
28224 UINT format_support
;
28229 const struct device_desc device_desc
=
28231 .feature_level
= &feature_level
,
28234 static const struct format_info
28240 BOOL skip_if_broken
;
28244 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 16, 1, TRUE
},
28245 {DXGI_FORMAT_R32G32B32A32_FLOAT
, 16, 1, TRUE
},
28246 {DXGI_FORMAT_R32G32B32A32_UINT
, 16, 1, TRUE
},
28247 {DXGI_FORMAT_R32G32B32A32_SINT
, 16, 1, TRUE
},
28249 {DXGI_FORMAT_R16G16B16A16_TYPELESS
, 8, 1, TRUE
},
28250 {DXGI_FORMAT_R16G16B16A16_FLOAT
, 8, 1, TRUE
},
28251 {DXGI_FORMAT_R16G16B16A16_UNORM
, 8, 1, TRUE
},
28252 {DXGI_FORMAT_R16G16B16A16_UINT
, 8, 1, TRUE
},
28253 {DXGI_FORMAT_R16G16B16A16_SNORM
, 8, 1, TRUE
},
28254 {DXGI_FORMAT_R16G16B16A16_SINT
, 8, 1, TRUE
},
28256 {DXGI_FORMAT_R32G32_TYPELESS
, 8, 1, TRUE
},
28257 {DXGI_FORMAT_R32G32_FLOAT
, 8, 1, TRUE
},
28258 {DXGI_FORMAT_R32G32_UINT
, 8, 1, TRUE
},
28259 {DXGI_FORMAT_R32G32_SINT
, 8, 1, TRUE
},
28261 {DXGI_FORMAT_R32_TYPELESS
, 4, 1, TRUE
},
28262 {DXGI_FORMAT_R32_FLOAT
, 4, 1, TRUE
},
28263 {DXGI_FORMAT_R32_UINT
, 4, 1, TRUE
},
28264 {DXGI_FORMAT_R32_SINT
, 4, 1, TRUE
},
28266 {DXGI_FORMAT_R32G8X24_TYPELESS
, 8, 1},
28267 {DXGI_FORMAT_R10G10B10A2_TYPELESS
, 4, 1},
28268 {DXGI_FORMAT_R8G8B8A8_TYPELESS
, 4, 1},
28269 {DXGI_FORMAT_R16G16_TYPELESS
, 4, 1},
28270 {DXGI_FORMAT_R24G8_TYPELESS
, 4, 1},
28271 {DXGI_FORMAT_R9G9B9E5_SHAREDEXP
, 4, 1},
28272 {DXGI_FORMAT_B8G8R8A8_TYPELESS
, 4, 1},
28273 {DXGI_FORMAT_R8G8_TYPELESS
, 2, 1},
28274 {DXGI_FORMAT_R16_TYPELESS
, 2, 1},
28275 {DXGI_FORMAT_R8_TYPELESS
, 1, 1},
28277 {DXGI_FORMAT_BC1_TYPELESS
, 8, 4},
28278 {DXGI_FORMAT_BC1_UNORM
, 8, 4},
28279 {DXGI_FORMAT_BC1_UNORM_SRGB
, 8, 4},
28281 {DXGI_FORMAT_BC2_TYPELESS
, 16, 4},
28282 {DXGI_FORMAT_BC2_UNORM
, 16, 4},
28283 {DXGI_FORMAT_BC2_UNORM_SRGB
, 16, 4},
28285 {DXGI_FORMAT_BC3_TYPELESS
, 16, 4},
28286 {DXGI_FORMAT_BC3_UNORM
, 16, 4},
28287 {DXGI_FORMAT_BC3_UNORM_SRGB
, 16, 4},
28289 {DXGI_FORMAT_BC4_TYPELESS
, 8, 4},
28290 {DXGI_FORMAT_BC4_UNORM
, 8, 4},
28291 {DXGI_FORMAT_BC4_SNORM
, 8, 4},
28293 {DXGI_FORMAT_BC5_TYPELESS
, 16, 4},
28294 {DXGI_FORMAT_BC5_UNORM
, 16, 4},
28295 {DXGI_FORMAT_BC5_SNORM
, 16, 4},
28297 {DXGI_FORMAT_BC6H_TYPELESS
, 16, 4, FALSE
, TRUE
},
28298 {DXGI_FORMAT_BC6H_UF16
, 16, 4, FALSE
, TRUE
},
28299 {DXGI_FORMAT_BC6H_SF16
, 16, 4, FALSE
, TRUE
},
28301 {DXGI_FORMAT_BC7_TYPELESS
, 16, 4, FALSE
, TRUE
},
28302 {DXGI_FORMAT_BC7_UNORM
, 16, 4, FALSE
, TRUE
},
28303 {DXGI_FORMAT_BC7_UNORM_SRGB
, 16, 4, FALSE
, TRUE
},
28306 static const DWORD initial_data
[64] = {0};
28307 static const DWORD texture_data
[] =
28309 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
28310 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
28311 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
28312 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
28314 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
28315 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
28316 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
28317 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
28319 0xff00ff00, 0xffffff00, 0xff0000ff, 0xff00ffff,
28320 0xff000000, 0xff7f7f7f, 0xffff0000, 0xffff00ff,
28321 0xffffffff, 0xff000000, 0xffffffff, 0xffffffff,
28322 0xff000000, 0xff000000, 0xffffffff, 0xff000000,
28324 0xff000000, 0xff000000, 0xffffffff, 0xff000000,
28325 0xffffffff, 0xff000000, 0xffffffff, 0xffffffff,
28326 0xff000000, 0xff7f7f7f, 0xffff0000, 0xffff00ff,
28327 0xff00ff00, 0xffffff00, 0xff0000ff, 0xff00ffff,
28330 if (!(device
= create_device(&device_desc
)))
28332 skip("Failed to create device for feature level %#x.\n", feature_level
);
28335 ID3D11Device_GetImmediateContext(device
, &context
);
28337 row_block_count
= 4;
28339 texture_desc
.MipLevels
= 1;
28340 texture_desc
.ArraySize
= 1;
28341 texture_desc
.SampleDesc
.Count
= 1;
28342 texture_desc
.SampleDesc
.Quality
= 0;
28343 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
;
28344 texture_desc
.CPUAccessFlags
= 0;
28345 texture_desc
.MiscFlags
= 0;
28347 resource_data
.SysMemSlicePitch
= 0;
28349 for (i
= 0; i
< ARRAY_SIZE(formats
); ++i
)
28351 src_format
= &formats
[i
];
28352 row_count
= sizeof(texture_data
) / (row_block_count
* src_format
->block_size
);
28353 texture_desc
.Width
= row_block_count
* src_format
->block_edge
;
28354 texture_desc
.Height
= row_count
* src_format
->block_edge
;
28355 texture_desc
.Format
= src_format
->id
;
28356 texture_desc
.Usage
= D3D11_USAGE_IMMUTABLE
;
28358 resource_data
.pSysMem
= texture_data
;
28359 resource_data
.SysMemPitch
= row_block_count
* src_format
->block_size
;
28361 hr
= ID3D11Device_CheckFormatSupport(device
, src_format
->id
, &format_support
);
28362 if (hr
== E_FAIL
|| !(format_support
& D3D11_FORMAT_SUPPORT_TEXTURE2D
))
28365 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &src_texture
);
28366 ok(hr
== S_OK
, "Source format %#x: Got unexpected hr %#x.\n", src_format
->id
, hr
);
28368 for (j
= 0; j
< ARRAY_SIZE(formats
); ++j
)
28370 dst_format
= &formats
[j
];
28372 if ((src_format
->block_edge
== 1 && dst_format
->block_edge
== 1)
28373 || (src_format
->block_edge
!= 1 && dst_format
->block_edge
!= 1))
28376 hr
= ID3D11Device_CheckFormatSupport(device
, dst_format
->id
, &format_support
);
28377 if (hr
== E_FAIL
|| !(format_support
& D3D11_FORMAT_SUPPORT_TEXTURE2D
))
28380 supported
= ((src_format
->block_edge
!= 1 && dst_format
->supported
)
28381 || (src_format
->supported
&& dst_format
->block_edge
!= 1))
28382 && src_format
->block_size
== dst_format
->block_size
28383 && feature_level
>= D3D_FEATURE_LEVEL_10_1
;
28385 /* These cause the device to be removed on some versions of Windows. */
28386 if (supported
&& broken_dst_offset
&& (src_format
->skip_if_broken
|| dst_format
->skip_if_broken
))
28388 win_skip("Skipping %#x -> %#x tests because of broken destination offset.\n",
28389 src_format
->id
, dst_format
->id
);
28393 row_count
= sizeof(initial_data
) / (row_block_count
* dst_format
->block_size
);
28394 texture_desc
.Width
= row_block_count
* dst_format
->block_edge
;
28395 texture_desc
.Height
= row_count
* dst_format
->block_edge
;
28396 texture_desc
.Format
= dst_format
->id
;
28397 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
28399 resource_data
.pSysMem
= initial_data
;
28400 resource_data
.SysMemPitch
= row_block_count
* dst_format
->block_size
;
28402 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &dst_texture
);
28403 ok(hr
== S_OK
, "%#x -> %#x: Got unexpected hr %#x.\n", src_format
->id
, dst_format
->id
, hr
);
28405 if (supported
&& broken_dst_offset
)
28407 win_skip("Skipping %#x -> %#x CopySubresourceRegion() test because of broken destination offset.\n",
28408 src_format
->id
, dst_format
->id
);
28412 set_box(&box
, 0, 0, 0, src_format
->block_edge
, src_format
->block_edge
, 1);
28413 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)dst_texture
, 0,
28414 dst_format
->block_edge
, dst_format
->block_edge
, 0, (ID3D11Resource
*)src_texture
, 0, &box
);
28415 get_texture_readback(dst_texture
, 0, &rb
);
28416 colour
= get_readback_color(&rb
, 0, 0, 0);
28417 if (supported
&& colour
== texture_data
[0])
28419 win_skip("Detected broken destination offset for %#x -> %#x copy.\n",
28420 src_format
->id
, dst_format
->id
);
28421 broken_dst_offset
= TRUE
;
28423 for (k
= 0; k
< ARRAY_SIZE(texture_data
) && (!supported
|| !broken_dst_offset
); ++k
)
28425 block_idx
= (k
* sizeof(colour
)) / dst_format
->block_size
;
28426 x
= block_idx
% row_block_count
;
28427 y
= block_idx
/ row_block_count
;
28429 row
= rb
.map_desc
.pData
;
28430 row
+= y
* rb
.map_desc
.RowPitch
;
28431 colour
= ((DWORD
*)row
)[k
% ((row_block_count
* dst_format
->block_size
) / sizeof(colour
))];
28433 if (supported
&& x
== 1 && y
== 1)
28434 expected
= texture_data
[k
- ((row_block_count
+ 1) * dst_format
->block_size
) / sizeof(colour
)];
28436 expected
= initial_data
[k
];
28437 ok(colour
== expected
, "%#x -> %#x: Got unexpected colour 0x%08x at %u, expected 0x%08x.\n",
28438 src_format
->id
, dst_format
->id
, colour
, k
, expected
);
28439 if (colour
!= expected
)
28442 release_resource_readback(&rb
);
28445 ID3D11DeviceContext_CopyResource(context
, (ID3D11Resource
*)dst_texture
, (ID3D11Resource
*)src_texture
);
28446 get_texture_readback(dst_texture
, 0, &rb
);
28447 for (k
= 0; k
< ARRAY_SIZE(texture_data
); ++k
)
28449 block_idx
= (k
* sizeof(colour
)) / dst_format
->block_size
;
28450 y
= block_idx
/ row_block_count
;
28452 row
= rb
.map_desc
.pData
;
28453 row
+= y
* rb
.map_desc
.RowPitch
;
28454 colour
= ((DWORD
*)row
)[k
% ((row_block_count
* dst_format
->block_size
) / sizeof(colour
))];
28457 expected
= texture_data
[k
];
28459 expected
= initial_data
[k
];
28460 ok(colour
== expected
, "%#x -> %#x: Got unexpected colour 0x%08x at %u, expected 0x%08x.\n",
28461 src_format
->id
, dst_format
->id
, colour
, k
, expected
);
28462 if (colour
!= expected
)
28465 release_resource_readback(&rb
);
28467 ID3D11Texture2D_Release(dst_texture
);
28470 ID3D11Texture2D_Release(src_texture
);
28473 ID3D11DeviceContext_Release(context
);
28474 refcount
= ID3D11Device_Release(device
);
28475 ok(!refcount
, "Device has %u references left.\n", refcount
);
28478 static void check_clip_distance(struct d3d11_test_context
*test_context
, ID3D11Buffer
*vb
)
28480 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
28483 float clip_distance0
;
28484 float clip_distance1
;
28487 ID3D11DeviceContext
*context
= test_context
->immediate_context
;
28488 struct resource_readback rb
;
28489 struct vertex vertices
[4];
28493 for (i
= 0; i
< ARRAY_SIZE(vertices
); ++i
)
28494 vertices
[i
].clip_distance0
= 1.0f
;
28495 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb
, 0, NULL
, vertices
, 0, 0);
28496 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
->backbuffer_rtv
, white
);
28497 ID3D11DeviceContext_Draw(context
, 4, 0);
28498 check_texture_color(test_context
->backbuffer
, 0xff00ff00, 1);
28500 for (i
= 0; i
< ARRAY_SIZE(vertices
); ++i
)
28501 vertices
[i
].clip_distance0
= 0.0f
;
28502 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb
, 0, NULL
, vertices
, 0, 0);
28503 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
->backbuffer_rtv
, white
);
28504 ID3D11DeviceContext_Draw(context
, 4, 0);
28505 check_texture_color(test_context
->backbuffer
, 0xff00ff00, 1);
28507 for (i
= 0; i
< ARRAY_SIZE(vertices
); ++i
)
28508 vertices
[i
].clip_distance0
= -1.0f
;
28509 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb
, 0, NULL
, vertices
, 0, 0);
28510 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
->backbuffer_rtv
, white
);
28511 ID3D11DeviceContext_Draw(context
, 4, 0);
28512 check_texture_color(test_context
->backbuffer
, 0xffffffff, 1);
28514 for (i
= 0; i
< ARRAY_SIZE(vertices
); ++i
)
28515 vertices
[i
].clip_distance0
= i
< 2 ? 1.0f
: -1.0f
;
28516 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb
, 0, NULL
, vertices
, 0, 0);
28517 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
->backbuffer_rtv
, white
);
28518 ID3D11DeviceContext_Draw(context
, 4, 0);
28519 get_texture_readback(test_context
->backbuffer
, 0, &rb
);
28520 SetRect(&rect
, 0, 0, 320, 480);
28521 check_readback_data_color(&rb
, &rect
, 0xff00ff00, 1);
28522 SetRect(&rect
, 320, 0, 320, 480);
28523 check_readback_data_color(&rb
, &rect
, 0xffffffff, 1);
28524 release_resource_readback(&rb
);
28526 for (i
= 0; i
< ARRAY_SIZE(vertices
); ++i
)
28527 vertices
[i
].clip_distance0
= i
% 2 ? 1.0f
: -1.0f
;
28528 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb
, 0, NULL
, vertices
, 0, 0);
28529 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
->backbuffer_rtv
, white
);
28530 ID3D11DeviceContext_Draw(context
, 4, 0);
28531 get_texture_readback(test_context
->backbuffer
, 0, &rb
);
28532 SetRect(&rect
, 0, 0, 640, 240);
28533 check_readback_data_color(&rb
, &rect
, 0xff00ff00, 1);
28534 SetRect(&rect
, 0, 240, 640, 240);
28535 check_readback_data_color(&rb
, &rect
, 0xffffffff, 1);
28536 release_resource_readback(&rb
);
28539 static void test_clip_distance(void)
28541 struct d3d11_test_context test_context
;
28542 ID3D11Buffer
*vs_cb
, *tess_cb
, *gs_cb
;
28543 D3D_FEATURE_LEVEL feature_level
;
28544 ID3D11DomainShader
*ds
= NULL
;
28545 ID3D11DeviceContext
*context
;
28546 struct resource_readback rb
;
28547 unsigned int offset
, stride
;
28548 ID3D11HullShader
*hs
= NULL
;
28549 ID3D11GeometryShader
*gs
;
28550 ID3D11Device
*device
;
28556 static const DWORD vs_code
[] =
28560 float clip_distance
;
28564 float4 position
: POSITION
;
28565 float distance0
: CLIP_DISTANCE0
;
28566 float distance1
: CLIP_DISTANCE1
;
28571 float4 position
: SV_POSITION
;
28572 float user_clip
: CLIP_DISTANCE
;
28573 float clip
: SV_ClipDistance
;
28576 void main(input vin
, out vertex vertex
)
28578 vertex
.position
= vin
.position
;
28579 vertex
.user_clip
= vin
.distance0
;
28580 vertex
.clip
= vin
.distance0
;
28582 vertex
.clip
= clip_distance
;
28585 0x43425844, 0x09dfef58, 0x88570f2e, 0x1ebcf953, 0x9f97e22a, 0x00000001, 0x000001dc, 0x00000003,
28586 0x0000002c, 0x0000009c, 0x00000120, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050,
28587 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000059, 0x00000000, 0x00000000,
28588 0x00000003, 0x00000001, 0x00000101, 0x00000059, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
28589 0x00000001, 0x49534f50, 0x4e4f4954, 0x494c4300, 0x49445f50, 0x4e415453, 0xab004543, 0x4e47534f,
28590 0x0000007c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000,
28591 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000e01, 0x0000006a,
28592 0x00000000, 0x00000002, 0x00000003, 0x00000002, 0x00000e01, 0x505f5653, 0x5449534f, 0x004e4f49,
28593 0x50494c43, 0x5349445f, 0x434e4154, 0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065,
28594 0x52444853, 0x000000b4, 0x00010040, 0x0000002d, 0x04000059, 0x00208e46, 0x00000000, 0x00000001,
28595 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x00101012, 0x00000001, 0x04000067, 0x001020f2,
28596 0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000001, 0x04000067, 0x00102012, 0x00000002,
28597 0x00000002, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x00102012,
28598 0x00000001, 0x0010100a, 0x00000001, 0x0b000037, 0x00102012, 0x00000002, 0x0020800a, 0x00000000,
28599 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0010100a, 0x00000001, 0x0100003e,
28601 static const DWORD vs_multiple_code
[] =
28605 float clip_distance0
;
28606 float clip_distance1
;
28610 float4 position
: POSITION
;
28611 float distance0
: CLIP_DISTANCE0
;
28612 float distance1
: CLIP_DISTANCE1
;
28617 float4 position
: SV_POSITION
;
28618 float user_clip
: CLIP_DISTANCE
;
28619 float2 clip
: SV_ClipDistance
;
28622 void main(input vin
, out vertex vertex
)
28624 vertex
.position
= vin
.position
;
28625 vertex
.user_clip
= vin
.distance0
;
28626 vertex
.clip
.x
= vin
.distance0
;
28628 vertex
.clip
.x
= clip_distance0
;
28629 vertex
.clip
.y
= vin
.distance1
;
28631 vertex
.clip
.y
= clip_distance1
;
28634 0x43425844, 0xef5cc236, 0xe2fbfa69, 0x560b6591, 0x23037999, 0x00000001, 0x00000214, 0x00000003,
28635 0x0000002c, 0x0000009c, 0x00000120, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050,
28636 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000059, 0x00000000, 0x00000000,
28637 0x00000003, 0x00000001, 0x00000101, 0x00000059, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
28638 0x00000101, 0x49534f50, 0x4e4f4954, 0x494c4300, 0x49445f50, 0x4e415453, 0xab004543, 0x4e47534f,
28639 0x0000007c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000,
28640 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000e01, 0x0000006a,
28641 0x00000000, 0x00000002, 0x00000003, 0x00000002, 0x00000c03, 0x505f5653, 0x5449534f, 0x004e4f49,
28642 0x50494c43, 0x5349445f, 0x434e4154, 0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065,
28643 0x52444853, 0x000000ec, 0x00010040, 0x0000003b, 0x04000059, 0x00208e46, 0x00000000, 0x00000001,
28644 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x00101012, 0x00000001, 0x0300005f, 0x00101012,
28645 0x00000002, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000001,
28646 0x04000067, 0x00102032, 0x00000002, 0x00000002, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46,
28647 0x00000000, 0x05000036, 0x00102012, 0x00000001, 0x0010100a, 0x00000001, 0x0b000037, 0x00102012,
28648 0x00000002, 0x0020800a, 0x00000000, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0010100a,
28649 0x00000001, 0x0b000037, 0x00102022, 0x00000002, 0x0020800a, 0x00000000, 0x00000000, 0x0020802a,
28650 0x00000000, 0x00000000, 0x0010100a, 0x00000002, 0x0100003e,
28654 float clip_distance0
;
28655 float clip_distance1
;
28656 float tessellation_factor
;
28660 float4 position
: SV_POSITION
;
28661 float user_clip
: CLIP_DISTANCE
;
28662 float clip
: SV_ClipDistance
;
28665 struct patch_constant_data
28667 float edges
[4] : SV_TessFactor
;
28668 float inside
[2] : SV_InsideTessFactor
;
28671 patch_constant_data
patch_constant()
28673 patch_constant_data output
;
28675 output
.edges
[0] = tessellation_factor
;
28676 output
.edges
[1] = tessellation_factor
;
28677 output
.edges
[2] = tessellation_factor
;
28678 output
.edges
[3] = tessellation_factor
;
28679 output
.inside
[0] = tessellation_factor
;
28680 output
.inside
[1] = tessellation_factor
;
28686 [outputcontrolpoints(4)]
28687 [outputtopology("triangle_cw")]
28688 [partitioning("pow2")]
28689 [patchconstantfunc("patch_constant")]
28690 vertex
hs_main(InputPatch
<vertex
, 4> input
,
28691 uint i
: SV_OutputControlPointID
)
28694 o
.position
= input
[i
].position
;
28695 o
.user_clip
= input
[i
].user_clip
;
28696 o
.clip
= input
[i
].user_clip
;
28700 float4
interpolate_vec(float4 a
, float4 b
, float4 c
, float4 d
, float2 tess_coord
)
28702 float4 e
= lerp(a
, b
, tess_coord
.x
);
28703 float4 f
= lerp(c
, d
, tess_coord
.x
);
28704 return lerp(e
, f
, tess_coord
.y
);
28707 float interpolate(float a
, float b
, float c
, float d
, float2 tess_coord
)
28709 float e
= lerp(a
, b
, tess_coord
.x
);
28710 float f
= lerp(c
, d
, tess_coord
.x
);
28711 return lerp(e
, f
, tess_coord
.y
);
28715 vertex
ds_main(patch_constant_data input
,
28716 float2 tess_coord
: SV_DomainLocation
,
28717 const OutputPatch
<vertex
, 4> patch
)
28721 output
.position
= interpolate_vec(patch
[0].position
, patch
[1].position
,
28722 patch
[2].position
, patch
[3].position
, tess_coord
);
28723 output
.user_clip
= interpolate(patch
[0].user_clip
, patch
[1].user_clip
,
28724 patch
[2].user_clip
, patch
[3].user_clip
, tess_coord
);
28725 output
.clip
= interpolate(patch
[0].clip
, patch
[1].clip
,
28726 patch
[2].clip
, patch
[3].clip
, tess_coord
);
28728 output
.clip
= clip_distance0
;
28733 static const DWORD hs_code
[] =
28735 0x43425844, 0x5a6d7564, 0x5f30a6c9, 0x2cf3b848, 0x5b4c6dca, 0x00000001, 0x00000414, 0x00000004,
28736 0x00000030, 0x000000b4, 0x00000138, 0x000001fc, 0x4e475349, 0x0000007c, 0x00000003, 0x00000008,
28737 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x0000005c, 0x00000000,
28738 0x00000000, 0x00000003, 0x00000001, 0x00000101, 0x0000006a, 0x00000000, 0x00000002, 0x00000003,
28739 0x00000002, 0x00000001, 0x505f5653, 0x5449534f, 0x004e4f49, 0x50494c43, 0x5349445f, 0x434e4154,
28740 0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065, 0x4e47534f, 0x0000007c, 0x00000003,
28741 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c,
28742 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000e01, 0x0000006a, 0x00000000, 0x00000002,
28743 0x00000003, 0x00000002, 0x00000e01, 0x505f5653, 0x5449534f, 0x004e4f49, 0x50494c43, 0x5349445f,
28744 0x434e4154, 0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065, 0x47534350, 0x000000bc,
28745 0x00000006, 0x00000008, 0x00000098, 0x00000000, 0x0000000b, 0x00000003, 0x00000000, 0x00000e01,
28746 0x00000098, 0x00000001, 0x0000000b, 0x00000003, 0x00000001, 0x00000e01, 0x00000098, 0x00000002,
28747 0x0000000b, 0x00000003, 0x00000002, 0x00000e01, 0x00000098, 0x00000003, 0x0000000b, 0x00000003,
28748 0x00000003, 0x00000e01, 0x000000a6, 0x00000000, 0x0000000c, 0x00000003, 0x00000004, 0x00000e01,
28749 0x000000a6, 0x00000001, 0x0000000c, 0x00000003, 0x00000005, 0x00000e01, 0x545f5653, 0x46737365,
28750 0x6f746361, 0x56530072, 0x736e495f, 0x54656469, 0x46737365, 0x6f746361, 0xabab0072, 0x58454853,
28751 0x00000210, 0x00030050, 0x00000084, 0x01000071, 0x01002093, 0x01002094, 0x01001895, 0x01001096,
28752 0x01001897, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x01000072, 0x0200005f,
28753 0x00016000, 0x0400005f, 0x002010f2, 0x00000004, 0x00000000, 0x0400005f, 0x00201012, 0x00000004,
28754 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x00102012, 0x00000001, 0x03000065,
28755 0x00102012, 0x00000002, 0x02000068, 0x00000001, 0x04000036, 0x00100012, 0x00000000, 0x00016001,
28756 0x07000036, 0x001020f2, 0x00000000, 0x00a01e46, 0x0010000a, 0x00000000, 0x00000000, 0x07000036,
28757 0x00102012, 0x00000001, 0x00a0100a, 0x0010000a, 0x00000000, 0x00000001, 0x07000036, 0x00102012,
28758 0x00000002, 0x00a0100a, 0x0010000a, 0x00000000, 0x00000001, 0x0100003e, 0x01000073, 0x02000099,
28759 0x00000004, 0x0200005f, 0x00017000, 0x04000067, 0x00102012, 0x00000000, 0x0000000b, 0x04000067,
28760 0x00102012, 0x00000001, 0x0000000c, 0x04000067, 0x00102012, 0x00000002, 0x0000000d, 0x04000067,
28761 0x00102012, 0x00000003, 0x0000000e, 0x02000068, 0x00000001, 0x0400005b, 0x00102012, 0x00000000,
28762 0x00000004, 0x04000036, 0x00100012, 0x00000000, 0x0001700a, 0x07000036, 0x00902012, 0x0010000a,
28763 0x00000000, 0x0020803a, 0x00000000, 0x00000000, 0x0100003e, 0x01000073, 0x02000099, 0x00000002,
28764 0x0200005f, 0x00017000, 0x04000067, 0x00102012, 0x00000004, 0x0000000f, 0x04000067, 0x00102012,
28765 0x00000005, 0x00000010, 0x02000068, 0x00000001, 0x0400005b, 0x00102012, 0x00000004, 0x00000002,
28766 0x04000036, 0x00100012, 0x00000000, 0x0001700a, 0x08000036, 0x00d02012, 0x00000004, 0x0010000a,
28767 0x00000000, 0x0020803a, 0x00000000, 0x00000000, 0x0100003e,
28769 static const DWORD ds_code
[] =
28771 0x43425844, 0xc54dc020, 0x063a9622, 0x6f649eb9, 0xceb1dd36, 0x00000001, 0x0000054c, 0x00000004,
28772 0x00000030, 0x000000b4, 0x00000178, 0x000001fc, 0x4e475349, 0x0000007c, 0x00000003, 0x00000008,
28773 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x0000005c, 0x00000000,
28774 0x00000000, 0x00000003, 0x00000001, 0x00000101, 0x0000006a, 0x00000000, 0x00000002, 0x00000003,
28775 0x00000002, 0x00000101, 0x505f5653, 0x5449534f, 0x004e4f49, 0x50494c43, 0x5349445f, 0x434e4154,
28776 0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065, 0x47534350, 0x000000bc, 0x00000006,
28777 0x00000008, 0x00000098, 0x00000000, 0x0000000b, 0x00000003, 0x00000000, 0x00000001, 0x00000098,
28778 0x00000001, 0x0000000b, 0x00000003, 0x00000001, 0x00000001, 0x00000098, 0x00000002, 0x0000000b,
28779 0x00000003, 0x00000002, 0x00000001, 0x00000098, 0x00000003, 0x0000000b, 0x00000003, 0x00000003,
28780 0x00000001, 0x000000a6, 0x00000000, 0x0000000c, 0x00000003, 0x00000004, 0x00000001, 0x000000a6,
28781 0x00000001, 0x0000000c, 0x00000003, 0x00000005, 0x00000001, 0x545f5653, 0x46737365, 0x6f746361,
28782 0x56530072, 0x736e495f, 0x54656469, 0x46737365, 0x6f746361, 0xabab0072, 0x4e47534f, 0x0000007c,
28783 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
28784 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000e01, 0x0000006a, 0x00000000,
28785 0x00000002, 0x00000003, 0x00000002, 0x00000e01, 0x505f5653, 0x5449534f, 0x004e4f49, 0x50494c43,
28786 0x5349445f, 0x434e4154, 0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065, 0x58454853,
28787 0x00000348, 0x00040050, 0x000000d2, 0x01002093, 0x01001895, 0x0100086a, 0x04000059, 0x00208e46,
28788 0x00000000, 0x00000001, 0x0200005f, 0x0001c032, 0x0400005f, 0x002190f2, 0x00000004, 0x00000000,
28789 0x0400005f, 0x00219012, 0x00000004, 0x00000001, 0x0400005f, 0x00219012, 0x00000004, 0x00000002,
28790 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000001, 0x04000067,
28791 0x00102012, 0x00000002, 0x00000002, 0x02000068, 0x00000002, 0x0a000000, 0x001000f2, 0x00000000,
28792 0x80219e46, 0x00000041, 0x00000002, 0x00000000, 0x00219e46, 0x00000003, 0x00000000, 0x09000032,
28793 0x001000f2, 0x00000000, 0x0001c006, 0x00100e46, 0x00000000, 0x00219e46, 0x00000002, 0x00000000,
28794 0x0a000000, 0x001000f2, 0x00000001, 0x80219e46, 0x00000041, 0x00000000, 0x00000000, 0x00219e46,
28795 0x00000001, 0x00000000, 0x09000032, 0x001000f2, 0x00000001, 0x0001c006, 0x00100e46, 0x00000001,
28796 0x00219e46, 0x00000000, 0x00000000, 0x08000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
28797 0x80100e46, 0x00000041, 0x00000001, 0x08000032, 0x001020f2, 0x00000000, 0x0001c556, 0x00100e46,
28798 0x00000000, 0x00100e46, 0x00000001, 0x0a000000, 0x00100012, 0x00000000, 0x8021900a, 0x00000041,
28799 0x00000002, 0x00000001, 0x0021900a, 0x00000003, 0x00000001, 0x09000032, 0x00100012, 0x00000000,
28800 0x0001c00a, 0x0010000a, 0x00000000, 0x0021900a, 0x00000002, 0x00000001, 0x0a000000, 0x00100022,
28801 0x00000000, 0x8021900a, 0x00000041, 0x00000000, 0x00000001, 0x0021900a, 0x00000001, 0x00000001,
28802 0x09000032, 0x00100022, 0x00000000, 0x0001c00a, 0x0010001a, 0x00000000, 0x0021900a, 0x00000000,
28803 0x00000001, 0x08000000, 0x00100012, 0x00000000, 0x8010001a, 0x00000041, 0x00000000, 0x0010000a,
28804 0x00000000, 0x08000032, 0x00102012, 0x00000001, 0x0001c01a, 0x0010000a, 0x00000000, 0x0010001a,
28805 0x00000000, 0x0a000000, 0x00100012, 0x00000000, 0x8021900a, 0x00000041, 0x00000002, 0x00000002,
28806 0x0021900a, 0x00000003, 0x00000002, 0x09000032, 0x00100012, 0x00000000, 0x0001c00a, 0x0010000a,
28807 0x00000000, 0x0021900a, 0x00000002, 0x00000002, 0x0a000000, 0x00100022, 0x00000000, 0x8021900a,
28808 0x00000041, 0x00000000, 0x00000002, 0x0021900a, 0x00000001, 0x00000002, 0x09000032, 0x00100022,
28809 0x00000000, 0x0001c00a, 0x0010001a, 0x00000000, 0x0021900a, 0x00000000, 0x00000002, 0x08000000,
28810 0x00100012, 0x00000000, 0x8010001a, 0x00000041, 0x00000000, 0x0010000a, 0x00000000, 0x08000032,
28811 0x00100012, 0x00000000, 0x0001c01a, 0x0010000a, 0x00000000, 0x0010001a, 0x00000000, 0x0b000037,
28812 0x00102012, 0x00000002, 0x0020800a, 0x00000000, 0x00000000, 0x0020801a, 0x00000000, 0x00000000,
28813 0x0010000a, 0x00000000, 0x0100003e,
28815 static const DWORD gs_code
[] =
28819 float clip_distance
;
28823 float4 position
: SV_POSITION
;
28824 float user_clip
: CLIP_DISTANCE
;
28825 float clip
: SV_ClipDistance
;
28828 [maxvertexcount(3)]
28829 void main(triangle vertex input
[3], inout TriangleStream
<vertex
> output
)
28833 o
.clip
= input
[0].user_clip
;
28835 o
.clip
= clip_distance
;
28838 o
.clip
= input
[1].user_clip
;
28840 o
.clip
= clip_distance
;
28843 o
.clip
= input
[2].user_clip
;
28845 o
.clip
= clip_distance
;
28849 0x43425844, 0x9b0823e9, 0xab3ed100, 0xba0ff618, 0x1bbd1cb8, 0x00000001, 0x00000338, 0x00000003,
28850 0x0000002c, 0x000000b0, 0x00000134, 0x4e475349, 0x0000007c, 0x00000003, 0x00000008, 0x00000050,
28851 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x0000005c, 0x00000000, 0x00000000,
28852 0x00000003, 0x00000001, 0x00000101, 0x0000006a, 0x00000000, 0x00000002, 0x00000003, 0x00000002,
28853 0x00000001, 0x505f5653, 0x5449534f, 0x004e4f49, 0x50494c43, 0x5349445f, 0x434e4154, 0x56530045,
28854 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065, 0x4e47534f, 0x0000007c, 0x00000003, 0x00000008,
28855 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
28856 0x00000000, 0x00000003, 0x00000001, 0x00000e01, 0x0000006a, 0x00000000, 0x00000002, 0x00000003,
28857 0x00000002, 0x00000e01, 0x505f5653, 0x5449534f, 0x004e4f49, 0x50494c43, 0x5349445f, 0x434e4154,
28858 0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065, 0x52444853, 0x000001fc, 0x00020040,
28859 0x0000007f, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x05000061, 0x002010f2, 0x00000003,
28860 0x00000000, 0x00000001, 0x0400005f, 0x00201012, 0x00000003, 0x00000001, 0x0400005f, 0x00201012,
28861 0x00000003, 0x00000002, 0x02000068, 0x00000001, 0x0100185d, 0x0100285c, 0x04000067, 0x001020f2,
28862 0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000001, 0x04000067, 0x00102012, 0x00000002,
28863 0x00000002, 0x0200005e, 0x00000003, 0x06000036, 0x001020f2, 0x00000000, 0x00201e46, 0x00000000,
28864 0x00000000, 0x06000036, 0x00102012, 0x00000001, 0x0020100a, 0x00000000, 0x00000001, 0x0c000037,
28865 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x0020801a, 0x00000000, 0x00000000,
28866 0x0020100a, 0x00000000, 0x00000001, 0x05000036, 0x00102012, 0x00000002, 0x0010000a, 0x00000000,
28867 0x01000013, 0x06000036, 0x001020f2, 0x00000000, 0x00201e46, 0x00000001, 0x00000000, 0x06000036,
28868 0x00102012, 0x00000001, 0x0020100a, 0x00000001, 0x00000001, 0x0c000037, 0x00100012, 0x00000000,
28869 0x0020800a, 0x00000000, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0020100a, 0x00000001,
28870 0x00000001, 0x05000036, 0x00102012, 0x00000002, 0x0010000a, 0x00000000, 0x01000013, 0x06000036,
28871 0x001020f2, 0x00000000, 0x00201e46, 0x00000002, 0x00000000, 0x06000036, 0x00102012, 0x00000001,
28872 0x0020100a, 0x00000002, 0x00000001, 0x0c000037, 0x00100012, 0x00000000, 0x0020800a, 0x00000000,
28873 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0020100a, 0x00000002, 0x00000001, 0x05000036,
28874 0x00102012, 0x00000002, 0x0010000a, 0x00000000, 0x01000013, 0x0100003e,
28876 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
28878 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
28879 {"CLIP_DISTANCE", 0, DXGI_FORMAT_R32_FLOAT
, 1, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
28880 {"CLIP_DISTANCE", 1, DXGI_FORMAT_R32_FLOAT
, 1, 4, D3D11_INPUT_PER_VERTEX_DATA
, 0},
28884 float clip_distance0
;
28885 float clip_distance1
;
28894 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
28895 static const struct vec4 green
= {0.0f
, 1.0f
, 0.0f
, 1.0f
};
28899 float clip_distance0
;
28900 float clip_distance1
;
28901 float tessellation_factor
;
28904 if (!init_test_context(&test_context
, NULL
))
28906 device
= test_context
.device
;
28907 context
= test_context
.immediate_context
;
28908 feature_level
= ID3D11Device_GetFeatureLevel(device
);
28910 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
28911 vs_code
, sizeof(vs_code
), &test_context
.input_layout
);
28912 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
28914 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(vertices
), vertices
);
28915 stride
= sizeof(*vertices
);
28917 ID3D11DeviceContext_IASetVertexBuffers(context
, 1, 1, &vb
, &stride
, &offset
);
28919 memset(&cb_data
, 0, sizeof(cb_data
));
28920 cb_data
.tessellation_factor
= 1.0f
;
28921 vs_cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(cb_data
), &cb_data
);
28922 ID3D11DeviceContext_VSSetConstantBuffers(context
, 0, 1, &vs_cb
);
28923 tess_cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(cb_data
), &cb_data
);
28924 ID3D11DeviceContext_HSSetConstantBuffers(context
, 0, 1, &tess_cb
);
28925 ID3D11DeviceContext_DSSetConstantBuffers(context
, 0, 1, &tess_cb
);
28926 gs_cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(cb_data
), &cb_data
);
28927 ID3D11DeviceContext_GSSetConstantBuffers(context
, 0, 1, &gs_cb
);
28929 /* vertex shader */
28930 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
28931 draw_color_quad_vs(&test_context
, &green
, vs_code
, sizeof(vs_code
));
28932 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
28934 check_clip_distance(&test_context
, vb
);
28936 cb_data
.use_constant
= TRUE
;
28937 cb_data
.clip_distance0
= -1.0f
;
28938 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vs_cb
, 0, NULL
, &cb_data
, 0, 0);
28940 /* tessellation shaders */
28941 if (feature_level
>= D3D_FEATURE_LEVEL_11_0
)
28943 ID3D11DeviceContext_IASetPrimitiveTopology(context
, D3D11_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST
);
28945 hr
= ID3D11Device_CreateHullShader(device
, hs_code
, sizeof(hs_code
), NULL
, &hs
);
28946 ok(SUCCEEDED(hr
), "Failed to create hull shader, hr %#x.\n", hr
);
28947 ID3D11DeviceContext_HSSetShader(context
, hs
, NULL
, 0);
28948 hr
= ID3D11Device_CreateDomainShader(device
, ds_code
, sizeof(ds_code
), NULL
, &ds
);
28949 ok(SUCCEEDED(hr
), "Failed to create domain shader, hr %#x.\n", hr
);
28950 ID3D11DeviceContext_DSSetShader(context
, ds
, NULL
, 0);
28952 check_clip_distance(&test_context
, vb
);
28954 cb_data
.use_constant
= FALSE
;
28955 cb_data
.tessellation_factor
= 2.0f
;
28956 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)tess_cb
, 0, NULL
, &cb_data
, 0, 0);
28958 for (i
= 0; i
< ARRAY_SIZE(vertices
); ++i
)
28959 vertices
[i
].clip_distance0
= 1.0f
;
28960 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb
, 0, NULL
, vertices
, 0, 0);
28961 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
28962 ID3D11DeviceContext_Draw(context
, 4, 0);
28963 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
28965 cb_data
.use_constant
= TRUE
;
28966 cb_data
.clip_distance0
= -1.0f
;
28967 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)tess_cb
, 0, NULL
, &cb_data
, 0, 0);
28971 skip("Tessellation shaders are not supported.\n");
28974 /* geometry shader */
28975 hr
= ID3D11Device_CreateGeometryShader(device
, gs_code
, sizeof(gs_code
), NULL
, &gs
);
28976 ok(SUCCEEDED(hr
), "Failed to create geometry shader, hr %#x.\n", hr
);
28977 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
28979 check_clip_distance(&test_context
, vb
);
28981 cb_data
.use_constant
= TRUE
;
28982 cb_data
.clip_distance0
= 1.0f
;
28983 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)gs_cb
, 0, NULL
, &cb_data
, 0, 0);
28984 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
28985 ID3D11DeviceContext_Draw(context
, 4, 0);
28986 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
28988 /* multiple clip distances */
28989 ID3D11DeviceContext_HSSetShader(context
, NULL
, NULL
, 0);
28990 ID3D11DeviceContext_DSSetShader(context
, NULL
, NULL
, 0);
28991 ID3D11DeviceContext_GSSetShader(context
, NULL
, NULL
, 0);
28993 cb_data
.use_constant
= FALSE
;
28994 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vs_cb
, 0, NULL
, &cb_data
, 0, 0);
28996 for (i
= 0; i
< ARRAY_SIZE(vertices
); ++i
)
28997 vertices
[i
].clip_distance0
= 1.0f
;
28998 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb
, 0, NULL
, vertices
, 0, 0);
28999 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
29000 draw_color_quad_vs(&test_context
, &green
, vs_multiple_code
, sizeof(vs_multiple_code
));
29001 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
29003 for (i
= 0; i
< ARRAY_SIZE(vertices
); ++i
)
29005 vertices
[i
].clip_distance0
= i
< 2 ? 1.0f
: -1.0f
;
29006 vertices
[i
].clip_distance1
= i
% 2 ? 1.0f
: -1.0f
;
29008 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb
, 0, NULL
, vertices
, 0, 0);
29009 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
29010 draw_color_quad_vs(&test_context
, &green
, vs_multiple_code
, sizeof(vs_multiple_code
));
29011 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
29012 SetRect(&rect
, 0, 0, 320, 240);
29013 check_readback_data_color(&rb
, &rect
, 0xff00ff00, 1);
29014 SetRect(&rect
, 0, 240, 320, 480);
29015 check_readback_data_color(&rb
, &rect
, 0xffffffff, 1);
29016 SetRect(&rect
, 320, 0, 640, 480);
29017 check_readback_data_color(&rb
, &rect
, 0xffffffff, 1);
29018 release_resource_readback(&rb
);
29020 cb_data
.use_constant
= TRUE
;
29021 cb_data
.clip_distance0
= 0.0f
;
29022 cb_data
.clip_distance1
= 0.0f
;
29023 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vs_cb
, 0, NULL
, &cb_data
, 0, 0);
29024 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
29025 draw_color_quad_vs(&test_context
, &green
, vs_multiple_code
, sizeof(vs_multiple_code
));
29026 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
29029 ID3D11HullShader_Release(hs
);
29031 ID3D11DomainShader_Release(ds
);
29032 ID3D11GeometryShader_Release(gs
);
29033 ID3D11Buffer_Release(vb
);
29034 ID3D11Buffer_Release(vs_cb
);
29035 ID3D11Buffer_Release(tess_cb
);
29036 ID3D11Buffer_Release(gs_cb
);
29037 release_test_context(&test_context
);
29040 static void test_combined_clip_and_cull_distances(void)
29042 struct d3d11_test_context test_context
;
29043 ID3D11DeviceContext
*context
;
29044 struct resource_readback rb
;
29045 unsigned int offset
, stride
;
29046 ID3D11Device
*device
;
29047 unsigned int i
, j
, k
;
29051 static const DWORD vs_code
[] =
29056 float4 position
: POSITION
;
29057 float clip0
: CLIP_DISTANCE0
;
29058 float clip1
: CLIP_DISTANCE1
;
29059 float clip2
: CLIP_DISTANCE2
;
29060 float clip3
: CLIP_DISTANCE3
;
29061 float cull0
: CULL_DISTANCE0
;
29062 float cull1
: CULL_DISTANCE1
;
29063 float cull2
: CULL_DISTANCE2
;
29064 float cull3
: CULL_DISTANCE3
;
29069 float4 position
: SV_Position
;
29070 float3 clip0
: SV_ClipDistance1
;
29071 float3 cull0
: SV_CullDistance1
;
29072 float clip1
: SV_ClipDistance2
;
29073 float cull1
: SV_CullDistance2
;
29076 void main(input vin
, out vertex vertex
)
29078 vertex
.position
= vin
.position
;
29079 vertex
.clip0
= float3(vin
.clip0
, vin
.clip1
, vin
.clip2
);
29080 vertex
.cull0
= float3(vin
.cull0
, vin
.cull1
, vin
.cull2
);
29081 vertex
.clip1
= vin
.clip3
;
29082 vertex
.cull1
= vin
.cull3
;
29085 0x43425844, 0xa24fb3ea, 0x92e2c2b0, 0xb599b1b9, 0xd671f830, 0x00000001, 0x00000374, 0x00000003,
29086 0x0000002c, 0x0000013c, 0x000001f0, 0x4e475349, 0x00000108, 0x00000009, 0x00000008, 0x000000e0,
29087 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x000000e9, 0x00000000, 0x00000000,
29088 0x00000003, 0x00000001, 0x00000101, 0x000000e9, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
29089 0x00000101, 0x000000e9, 0x00000002, 0x00000000, 0x00000003, 0x00000003, 0x00000101, 0x000000e9,
29090 0x00000003, 0x00000000, 0x00000003, 0x00000004, 0x00000101, 0x000000f7, 0x00000000, 0x00000000,
29091 0x00000003, 0x00000005, 0x00000101, 0x000000f7, 0x00000001, 0x00000000, 0x00000003, 0x00000006,
29092 0x00000101, 0x000000f7, 0x00000002, 0x00000000, 0x00000003, 0x00000007, 0x00000101, 0x000000f7,
29093 0x00000003, 0x00000000, 0x00000003, 0x00000008, 0x00000101, 0x49534f50, 0x4e4f4954, 0x494c4300,
29094 0x49445f50, 0x4e415453, 0x43004543, 0x5f4c4c55, 0x54534944, 0x45434e41, 0xababab00, 0x4e47534f,
29095 0x000000ac, 0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000001, 0x00000003, 0x00000000,
29096 0x0000000f, 0x0000008c, 0x00000000, 0x00000002, 0x00000003, 0x00000001, 0x00000807, 0x0000008c,
29097 0x00000001, 0x00000002, 0x00000003, 0x00000001, 0x00000708, 0x0000009c, 0x00000000, 0x00000003,
29098 0x00000003, 0x00000002, 0x00000807, 0x0000009c, 0x00000001, 0x00000003, 0x00000003, 0x00000002,
29099 0x00000708, 0x505f5653, 0x7469736f, 0x006e6f69, 0x435f5653, 0x4470696c, 0x61747369, 0x0065636e,
29100 0x435f5653, 0x446c6c75, 0x61747369, 0x0065636e, 0x52444853, 0x0000017c, 0x00010040, 0x0000005f,
29101 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x00101012, 0x00000001, 0x0300005f, 0x00101012,
29102 0x00000002, 0x0300005f, 0x00101012, 0x00000003, 0x0300005f, 0x00101012, 0x00000004, 0x0300005f,
29103 0x00101012, 0x00000005, 0x0300005f, 0x00101012, 0x00000006, 0x0300005f, 0x00101012, 0x00000007,
29104 0x0300005f, 0x00101012, 0x00000008, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x04000067,
29105 0x00102072, 0x00000001, 0x00000002, 0x04000067, 0x00102082, 0x00000001, 0x00000002, 0x04000067,
29106 0x00102072, 0x00000002, 0x00000003, 0x04000067, 0x00102082, 0x00000002, 0x00000003, 0x05000036,
29107 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x00102012, 0x00000001, 0x0010100a,
29108 0x00000001, 0x05000036, 0x00102022, 0x00000001, 0x0010100a, 0x00000002, 0x05000036, 0x00102042,
29109 0x00000001, 0x0010100a, 0x00000003, 0x05000036, 0x00102082, 0x00000001, 0x0010100a, 0x00000004,
29110 0x05000036, 0x00102012, 0x00000002, 0x0010100a, 0x00000005, 0x05000036, 0x00102022, 0x00000002,
29111 0x0010100a, 0x00000006, 0x05000036, 0x00102042, 0x00000002, 0x0010100a, 0x00000007, 0x05000036,
29112 0x00102082, 0x00000002, 0x0010100a, 0x00000008, 0x0100003e,
29114 static const D3D11_INPUT_ELEMENT_DESC layout_desc
[] =
29116 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
29117 {"CLIP_DISTANCE", 0, DXGI_FORMAT_R32_FLOAT
, 1, 0, D3D11_INPUT_PER_VERTEX_DATA
, 0},
29118 {"CLIP_DISTANCE", 1, DXGI_FORMAT_R32_FLOAT
, 1, 4, D3D11_INPUT_PER_VERTEX_DATA
, 0},
29119 {"CLIP_DISTANCE", 2, DXGI_FORMAT_R32_FLOAT
, 1, 8, D3D11_INPUT_PER_VERTEX_DATA
, 0},
29120 {"CLIP_DISTANCE", 3, DXGI_FORMAT_R32_FLOAT
, 1, 12, D3D11_INPUT_PER_VERTEX_DATA
, 0},
29121 {"CULL_DISTANCE", 0, DXGI_FORMAT_R32_FLOAT
, 1, 16, D3D11_INPUT_PER_VERTEX_DATA
, 0},
29122 {"CULL_DISTANCE", 1, DXGI_FORMAT_R32_FLOAT
, 1, 20, D3D11_INPUT_PER_VERTEX_DATA
, 0},
29123 {"CULL_DISTANCE", 2, DXGI_FORMAT_R32_FLOAT
, 1, 24, D3D11_INPUT_PER_VERTEX_DATA
, 0},
29124 {"CULL_DISTANCE", 3, DXGI_FORMAT_R32_FLOAT
, 1, 28, D3D11_INPUT_PER_VERTEX_DATA
, 0},
29128 float clip_distance
[4];
29129 float cull_distance
[4];
29133 {{1.0f
, 1.0f
, 1.0f
, 1.0f
}, {1.0f
, 1.0f
, 1.0f
, 1.0f
}},
29134 {{1.0f
, 1.0f
, 1.0f
, 1.0f
}, {1.0f
, 1.0f
, 1.0f
, 1.0f
}},
29135 {{1.0f
, 1.0f
, 1.0f
, 1.0f
}, {1.0f
, 1.0f
, 1.0f
, 1.0f
}},
29136 {{1.0f
, 1.0f
, 1.0f
, 1.0f
}, {1.0f
, 1.0f
, 1.0f
, 1.0f
}},
29138 static const struct test
29141 BOOL triangle_visible
[2];
29143 cull_distance_tests
[] =
29145 {{-1.0f
, 1.0f
, 1.0f
, 1.0f
}, {TRUE
, TRUE
}},
29146 {{ 1.0f
, -1.0f
, 1.0f
, 1.0f
}, {TRUE
, TRUE
}},
29147 {{ 1.0f
, 1.0f
, 1.0f
, -1.0f
}, {TRUE
, TRUE
}},
29148 {{-1.0f
, -1.0f
, 1.0f
, 1.0f
}, {TRUE
, TRUE
}},
29149 {{-1.0f
, 1.0f
, -1.0f
, 1.0f
}, {TRUE
, TRUE
}},
29150 {{-1.0f
, 1.0f
, 1.0f
, -1.0f
}, {TRUE
, TRUE
}},
29151 {{ 1.0f
, -1.0f
, -1.0f
, 1.0f
}, {TRUE
, TRUE
}},
29152 {{ 1.0f
, -1.0f
, 1.0f
, -1.0f
}, {TRUE
, TRUE
}},
29153 {{ 1.0f
, 1.0f
, -1.0f
, -1.0f
}, {TRUE
, TRUE
}},
29155 {{-1.0f
, -1.0f
, -1.0f
, 1.0f
}, {FALSE
, TRUE
}},
29156 {{-1.0f
, -1.0f
, 1.0f
, -1.0f
}, {TRUE
, TRUE
}},
29157 {{-1.0f
, -1.0f
, 1.0f
, -1.0f
}, {TRUE
, TRUE
}},
29158 {{-1.0f
, 1.0f
, -1.0f
, -1.0f
}, {TRUE
, TRUE
}},
29159 {{ 1.0f
, -1.0f
, -1.0f
, -1.0f
}, {TRUE
, FALSE
}},
29161 {{-1.0f
, -1.0f
, -1.0f
, -1.0f
}, {FALSE
, FALSE
}},
29163 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
29164 static const struct vec4 green
= {0.0f
, 1.0f
, 0.0f
, 1.0f
};
29166 if (!init_test_context(&test_context
, NULL
))
29168 device
= test_context
.device
;
29169 context
= test_context
.immediate_context
;
29171 hr
= ID3D11Device_CreateInputLayout(device
, layout_desc
, ARRAY_SIZE(layout_desc
),
29172 vs_code
, sizeof(vs_code
), &test_context
.input_layout
);
29173 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
29175 vb
= create_buffer(device
, D3D11_BIND_VERTEX_BUFFER
, sizeof(vertices
), vertices
);
29176 stride
= sizeof(*vertices
);
29178 ID3D11DeviceContext_IASetVertexBuffers(context
, 1, 1, &vb
, &stride
, &offset
);
29180 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
29181 draw_color_quad(&test_context
, &green
);
29182 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
29184 for (i
= 0; i
< ARRAY_SIZE(vertices
->cull_distance
); ++i
)
29186 for (j
= 0; j
< ARRAY_SIZE(cull_distance_tests
); ++j
)
29188 const struct test
*test
= &cull_distance_tests
[j
];
29189 unsigned int expected_color
[ARRAY_SIZE(test
->triangle_visible
)];
29190 unsigned int color
;
29192 for (k
= 0; k
< ARRAY_SIZE(vertices
); ++k
)
29193 vertices
[k
].cull_distance
[i
] = test
->vertices
[k
];
29194 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb
, 0, NULL
, vertices
, 0, 0);
29196 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
29197 draw_color_quad_vs(&test_context
, &green
, vs_code
, sizeof(vs_code
));
29199 for (k
= 0; k
< ARRAY_SIZE(expected_color
); ++k
)
29200 expected_color
[k
] = test
->triangle_visible
[k
] ? 0xff00ff00 : 0xffffffff;
29202 if (expected_color
[0] == expected_color
[1])
29204 check_texture_color(test_context
.backbuffer
, *expected_color
, 1);
29208 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
29209 color
= get_readback_color(&rb
, 160, 240, 0);
29210 ok(color
== expected_color
[0], "Got unexpected color 0x%08x.\n", color
);
29211 color
= get_readback_color(&rb
, 480, 240, 0);
29212 ok(color
== expected_color
[1], "Got unexpected color 0x%08x.\n", color
);
29213 release_resource_readback(&rb
);
29217 for (j
= 0; j
< ARRAY_SIZE(vertices
); ++j
)
29218 vertices
[j
].cull_distance
[i
] = 1.0f
;
29221 for (i
= 0; i
< ARRAY_SIZE(vertices
->clip_distance
); ++i
)
29223 for (j
= 0; j
< ARRAY_SIZE(vertices
); ++j
)
29224 vertices
[j
].clip_distance
[i
] = -1.0f
;
29225 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb
, 0, NULL
, vertices
, 0, 0);
29227 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
29228 draw_color_quad_vs(&test_context
, &green
, vs_code
, sizeof(vs_code
));
29229 check_texture_color(test_context
.backbuffer
, 0xffffffff, 1);
29231 for (j
= 0; j
< ARRAY_SIZE(vertices
); ++j
)
29232 vertices
[j
].clip_distance
[i
] = 1.0f
;
29235 memset(vertices
, 0, sizeof(vertices
));
29236 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)vb
, 0, NULL
, vertices
, 0, 0);
29237 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
29238 draw_color_quad_vs(&test_context
, &green
, vs_code
, sizeof(vs_code
));
29239 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 1);
29241 ID3D11Buffer_Release(vb
);
29242 release_test_context(&test_context
);
29245 static void test_generate_mips(void)
29247 static const DWORD ps_code
[] =
29253 float4
main(float4 position
: SV_POSITION
) : SV_Target
29257 p
.x
= position
.x
/ 640.0f
;
29258 p
.y
= position
.y
/ 480.0f
;
29259 return t
.Sample(s
, p
);
29262 0x43425844, 0x1ce9b612, 0xc8176faa, 0xd37844af, 0xdb515605, 0x00000001, 0x00000134, 0x00000003,
29263 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
29264 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
29265 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
29266 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
29267 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
29268 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
29269 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
29270 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
29271 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
29273 static const DWORD ps_code_3d
[] =
29279 float4
main(float4 position
: SV_POSITION
) : SV_Target
29283 p
.x
= position
.x
/ 640.0f
;
29284 p
.y
= position
.y
/ 480.0f
;
29286 return t
.Sample(s
, p
);
29289 0x43425844, 0xa1e26083, 0xeb45763e, 0x1e5a5089, 0xdfbbe0df, 0x00000001, 0x00000148, 0x00000003,
29290 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
29291 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
29292 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
29293 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000ac, 0x00000040,
29294 0x0000002b, 0x0300005a, 0x00106000, 0x00000000, 0x04002858, 0x00107000, 0x00000000, 0x00005555,
29295 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
29296 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
29297 0x3b088889, 0x00000000, 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0x3f000000,
29298 0x09000045, 0x001020f2, 0x00000000, 0x00100246, 0x00000000, 0x00107e46, 0x00000000, 0x00106000,
29299 0x00000000, 0x0100003e,
29301 static const struct
29303 D3D11_RESOURCE_DIMENSION dim
;
29304 D3D11_SRV_DIMENSION srv_dim
;
29305 unsigned int array_size
;
29309 {D3D11_RESOURCE_DIMENSION_BUFFER
, D3D11_SRV_DIMENSION_BUFFER
, 1},
29310 {D3D11_RESOURCE_DIMENSION_TEXTURE2D
, D3D11_SRV_DIMENSION_TEXTURE2D
, 1},
29311 {D3D11_RESOURCE_DIMENSION_TEXTURE2D
, D3D11_SRV_DIMENSION_TEXTURE2DARRAY
, 4},
29312 {D3D11_RESOURCE_DIMENSION_TEXTURE3D
, D3D11_SRV_DIMENSION_TEXTURE3D
, 1},
29314 static const struct
29316 DXGI_FORMAT texture_format
;
29321 BOOL expected_creation
;
29322 BOOL expected_mips
;
29326 {DXGI_FORMAT_R8G8B8A8_UNORM
, D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
,
29328 {DXGI_FORMAT_R8G8B8A8_UNORM
, D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
, 0, TRUE
,
29330 {DXGI_FORMAT_R8G8B8A8_UNORM
, D3D11_BIND_SHADER_RESOURCE
, 0, FALSE
,
29332 {DXGI_FORMAT_R8G8B8A8_UNORM
, D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
, 0, FALSE
,
29334 {DXGI_FORMAT_R8G8B8A8_UNORM
, D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_GENERATE_MIPS
, FALSE
,
29336 {DXGI_FORMAT_R8G8B8A8_UNORM
, D3D11_BIND_RENDER_TARGET
, D3D11_RESOURCE_MISC_GENERATE_MIPS
, FALSE
,
29338 {DXGI_FORMAT_R8G8B8A8_UNORM
, D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_GENERATE_MIPS
, FALSE
,
29340 {DXGI_FORMAT_R8G8B8A8_UNORM
, D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_GENERATE_MIPS
, FALSE
,
29342 {DXGI_FORMAT_R8G8B8A8_TYPELESS
, D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_GENERATE_MIPS
, FALSE
,
29344 {DXGI_FORMAT_R8G8B8A8_UINT
, D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
, D3D11_RESOURCE_MISC_GENERATE_MIPS
, TRUE
,
29347 static const struct
29354 {{200, 200}, 0xffff0000},
29355 {{280, 200}, 0xffff0000},
29356 {{360, 200}, 0xff00ff00},
29357 {{440, 200}, 0xff00ff00},
29358 {{200, 270}, 0xff0000ff},
29359 {{280, 270}, 0xff0000ff},
29360 {{360, 270}, 0xff000000},
29361 {{440, 270}, 0xff000000},
29363 static const struct vec4 white
= {1.0f
, 1.0f
, 1.0f
, 1.0f
};
29364 static const RECT r1
= {8, 8, 16, 16};
29365 static const RECT r2
= {16, 8, 24, 16};
29366 static const RECT r3
= {8, 16, 16, 24};
29367 static const RECT r4
= {16, 16, 24, 24};
29368 DWORD
*data
, *zero_data
, color
, expected_color
;
29369 ID3D11ShaderResourceView
*srv
, *srv_sampling
;
29370 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
;
29371 struct d3d11_test_context test_context
;
29372 D3D11_TEXTURE2D_DESC texture2d_desc
;
29373 D3D11_TEXTURE3D_DESC texture3d_desc
;
29374 ID3D11SamplerState
*sampler_state
;
29375 D3D11_SAMPLER_DESC sampler_desc
;
29376 D3D11_BUFFER_DESC buffer_desc
;
29377 unsigned int i
, j
, k
, x
, y
, z
;
29378 ID3D11PixelShader
*ps
, *ps_3d
;
29379 ID3D11DeviceContext
*context
;
29380 struct resource_readback rb
;
29381 ID3D11Resource
*resource
;
29382 ID3D11Device
*device
;
29385 if (!init_test_context(&test_context
, NULL
))
29388 device
= test_context
.device
;
29389 context
= test_context
.immediate_context
;
29391 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
29392 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
29394 hr
= ID3D11Device_CreatePixelShader(device
, ps_code_3d
, sizeof(ps_code_3d
), NULL
, &ps_3d
);
29395 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
29397 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
29398 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
29399 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
29400 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
29401 sampler_desc
.MipLODBias
= 0.0f
;
29402 sampler_desc
.MaxAnisotropy
= 0;
29403 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
29404 sampler_desc
.BorderColor
[0] = 0.0f
;
29405 sampler_desc
.BorderColor
[1] = 0.0f
;
29406 sampler_desc
.BorderColor
[2] = 0.0f
;
29407 sampler_desc
.BorderColor
[3] = 0.0f
;
29408 sampler_desc
.MinLOD
= 0.0f
;
29409 sampler_desc
.MaxLOD
= D3D11_FLOAT32_MAX
;
29411 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler_state
);
29412 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
29413 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler_state
);
29415 data
= heap_alloc(sizeof(*data
) * 32 * 32 * 32);
29417 for (z
= 0; z
< 32; ++z
)
29419 for (y
= 0; y
< 32; ++y
)
29421 for (x
= 0; x
< 32; ++x
)
29423 DWORD
*dst
= &data
[z
* 32 * 32 + y
* 32 + x
];
29428 if (PtInRect(&r1
, pt
))
29430 else if (PtInRect(&r2
, pt
))
29432 else if (PtInRect(&r3
, pt
))
29434 else if (PtInRect(&r4
, pt
))
29442 zero_data
= heap_alloc_zero(sizeof(*zero_data
) * 16 * 16 * 16);
29444 for (i
= 0; i
< ARRAY_SIZE(resource_types
); ++i
)
29446 for (j
= 0; j
< ARRAY_SIZE(tests
); ++j
)
29448 unsigned int base_multiplier
= 1u << tests
[j
].base_level
;
29450 if (is_warp_device(device
) && tests
[j
].texture_format
== DXGI_FORMAT_R8G8B8A8_UINT
)
29452 /* Testing this format seems to break the WARP device. */
29453 skip("Skipping test with DXGI_FORMAT_R8G8B8A8_UINT on WARP.\n");
29457 switch (resource_types
[i
].dim
)
29459 case D3D11_RESOURCE_DIMENSION_BUFFER
:
29460 buffer_desc
.ByteWidth
= 32 * base_multiplier
;
29461 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
29462 buffer_desc
.BindFlags
= tests
[j
].bind_flags
;
29463 buffer_desc
.CPUAccessFlags
= 0;
29464 buffer_desc
.MiscFlags
= tests
[j
].misc_flags
;
29465 buffer_desc
.StructureByteStride
= 0;
29467 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
,
29468 (ID3D11Buffer
**)&resource
);
29470 case D3D11_RESOURCE_DIMENSION_TEXTURE2D
:
29471 texture2d_desc
.Width
= 32 * base_multiplier
;
29472 texture2d_desc
.Height
= 32 * base_multiplier
;
29473 texture2d_desc
.MipLevels
= 0;
29474 texture2d_desc
.ArraySize
= resource_types
[i
].array_size
;
29475 texture2d_desc
.Format
= tests
[j
].texture_format
;
29476 texture2d_desc
.SampleDesc
.Count
= 1;
29477 texture2d_desc
.SampleDesc
.Quality
= 0;
29478 texture2d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
29479 texture2d_desc
.BindFlags
= tests
[j
].bind_flags
;
29480 texture2d_desc
.CPUAccessFlags
= 0;
29481 texture2d_desc
.MiscFlags
= tests
[j
].misc_flags
;
29483 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, NULL
,
29484 (ID3D11Texture2D
**)&resource
);
29486 case D3D11_RESOURCE_DIMENSION_TEXTURE3D
:
29487 texture3d_desc
.Width
= 32 * base_multiplier
;
29488 texture3d_desc
.Height
= 32 * base_multiplier
;
29489 texture3d_desc
.Depth
= 32 * base_multiplier
;
29490 texture3d_desc
.MipLevels
= 0;
29491 texture3d_desc
.Format
= tests
[j
].texture_format
;
29492 texture3d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
29493 texture3d_desc
.BindFlags
= tests
[j
].bind_flags
;
29494 texture3d_desc
.CPUAccessFlags
= 0;
29495 texture3d_desc
.MiscFlags
= tests
[j
].misc_flags
;
29497 hr
= ID3D11Device_CreateTexture3D(device
, &texture3d_desc
, NULL
,
29498 (ID3D11Texture3D
**)&resource
);
29503 if (tests
[j
].expected_creation
&& (resource_types
[i
].dim
!= D3D11_RESOURCE_DIMENSION_BUFFER
29504 || !(tests
[j
].misc_flags
& D3D11_RESOURCE_MISC_GENERATE_MIPS
)))
29506 ok(SUCCEEDED(hr
), "Resource type %u, test %u: failed to create resource, hr %#x.\n", i
, j
, hr
);
29510 ok(hr
== E_INVALIDARG
, "Resource type %u, test %u: unexpectedly succeeded "
29511 "to create resource, hr %#x.\n", i
, j
, hr
);
29515 if (tests
[j
].null_srv
)
29517 hr
= ID3D11Device_CreateShaderResourceView(device
, resource
, NULL
, &srv
);
29521 srv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
29522 srv_desc
.ViewDimension
= resource_types
[i
].srv_dim
;
29523 switch (resource_types
[i
].srv_dim
)
29525 case D3D11_SRV_DIMENSION_BUFFER
:
29526 srv_desc
.Buffer
.ElementOffset
= 0;
29527 srv_desc
.Buffer
.ElementWidth
= 0;
29529 case D3D11_SRV_DIMENSION_TEXTURE2D
:
29530 srv_desc
.Texture2D
.MostDetailedMip
= tests
[j
].base_level
;
29531 srv_desc
.Texture2D
.MipLevels
= ~0u;
29533 case D3D11_SRV_DIMENSION_TEXTURE2DARRAY
:
29534 srv_desc
.Texture2DArray
.MostDetailedMip
= tests
[j
].base_level
;
29535 srv_desc
.Texture2DArray
.MipLevels
= ~0u;
29536 srv_desc
.Texture2DArray
.FirstArraySlice
= 0;
29537 srv_desc
.Texture2DArray
.ArraySize
= resource_types
[i
].array_size
;
29539 case D3D11_SRV_DIMENSION_TEXTURE3D
:
29540 srv_desc
.Texture3D
.MostDetailedMip
= tests
[j
].base_level
;
29541 srv_desc
.Texture3D
.MipLevels
= ~0u;
29546 hr
= ID3D11Device_CreateShaderResourceView(device
, resource
, &srv_desc
, &srv
);
29548 if (resource_types
[i
].dim
== D3D11_RESOURCE_DIMENSION_BUFFER
)
29550 ok(FAILED(hr
), "Test %u: unexpectedly succeeded to create shader resource view, "
29551 "hr %#x.\n", j
, hr
);
29552 ID3D11Resource_Release(resource
);
29557 ok(SUCCEEDED(hr
), "Resource type %u, test %u: failed to create "
29558 "shader resource view, hr %#x.\n", i
, j
, hr
);
29561 ID3D11DeviceContext_UpdateSubresource(context
, resource
, tests
[j
].base_level
,
29562 NULL
, data
, sizeof(*data
) * 32, sizeof(*data
) * 32 * 32);
29563 ID3D11DeviceContext_UpdateSubresource(context
, resource
, tests
[j
].base_level
+ 1,
29564 NULL
, zero_data
, sizeof(*zero_data
) * 16, sizeof(*zero_data
) * 16 * 16);
29566 ID3D11DeviceContext_GenerateMips(context
, srv
);
29568 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &white
.x
);
29570 srv_desc
.Format
= tests
[j
].texture_format
== DXGI_FORMAT_R8G8B8A8_UINT
29571 ? DXGI_FORMAT_R8G8B8A8_UINT
: DXGI_FORMAT_R8G8B8A8_UNORM
;
29572 srv_desc
.ViewDimension
= resource_types
[i
].dim
== D3D11_RESOURCE_DIMENSION_TEXTURE3D
29573 ? D3D11_SRV_DIMENSION_TEXTURE3D
: D3D11_SRV_DIMENSION_TEXTURE2D
;
29574 srv_desc
.Texture2D
.MostDetailedMip
= tests
[j
].base_level
+ 1;
29575 srv_desc
.Texture2D
.MipLevels
= ~0u;
29576 hr
= ID3D11Device_CreateShaderResourceView(device
, resource
, &srv_desc
, &srv_sampling
);
29577 ok(SUCCEEDED(hr
), "Resource type %u, test %u: failed to create shader resource view, "
29578 "hr %#x.\n", i
, j
, hr
);
29579 ID3D11DeviceContext_PSSetShader(context
, resource_types
[i
].dim
29580 == D3D11_RESOURCE_DIMENSION_TEXTURE3D
? ps_3d
: ps
, NULL
, 0);
29581 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv_sampling
);
29583 draw_quad(&test_context
);
29585 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
29586 for (k
= 0; k
< ARRAY_SIZE(expected
); ++k
)
29588 color
= get_readback_color(&rb
, expected
[k
].pos
.x
, expected
[k
].pos
.y
, 0);
29589 expected_color
= tests
[j
].expected_mips
? expected
[k
].color
: 0;
29590 ok(color
== expected_color
, "Resource type %u, test %u: pixel (%u, %u) "
29591 "has color %08x, expected %08x.\n",
29592 i
, j
, expected
[k
].pos
.x
, expected
[k
].pos
.y
, color
, expected_color
);
29594 release_resource_readback(&rb
);
29596 ID3D11ShaderResourceView_Release(srv_sampling
);
29597 ID3D11ShaderResourceView_Release(srv
);
29598 ID3D11Resource_Release(resource
);
29602 /* Test the effect of sRGB views. */
29603 for (y
= 0; y
< 32; ++y
)
29605 for (x
= 0; x
< 32; ++x
)
29607 DWORD
*dst
= &data
[y
* 32 + x
];
29609 *dst
= (x
+ y
) % 2 * 0xffffffff;
29612 texture2d_desc
.Width
= 32;
29613 texture2d_desc
.Height
= 32;
29614 texture2d_desc
.MipLevels
= 0;
29615 texture2d_desc
.ArraySize
= 1;
29616 texture2d_desc
.Format
= DXGI_FORMAT_R8G8B8A8_TYPELESS
;
29617 texture2d_desc
.SampleDesc
.Count
= 1;
29618 texture2d_desc
.SampleDesc
.Quality
= 0;
29619 texture2d_desc
.Usage
= D3D11_USAGE_DEFAULT
;
29620 texture2d_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE
;
29621 texture2d_desc
.CPUAccessFlags
= 0;
29622 texture2d_desc
.MiscFlags
= D3D11_RESOURCE_MISC_GENERATE_MIPS
;
29624 hr
= ID3D11Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, (ID3D11Texture2D
**)&resource
);
29625 ok(SUCCEEDED(hr
), "Failed to create resource, hr %#x.\n", hr
);
29626 hr
= ID3D11Device_CreateShaderResourceView(device
, resource
, NULL
, &srv
);
29627 ok(hr
== E_INVALIDARG
, "Unexpected hr %#x.\n", hr
);
29628 srv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
;
29629 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_TEXTURE2D
;
29630 srv_desc
.Texture2D
.MostDetailedMip
= 0;
29631 srv_desc
.Texture2D
.MipLevels
= ~0u;
29632 hr
= ID3D11Device_CreateShaderResourceView(device
, resource
, &srv_desc
, &srv
);
29633 ID3D11DeviceContext_UpdateSubresource(context
, resource
,
29634 0, NULL
, data
, sizeof(*data
) * 32, sizeof(*data
) * 32 * 32);
29636 ID3D11DeviceContext_GenerateMips(context
, srv
);
29638 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &white
.w
);
29640 srv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
29641 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_TEXTURE2D
;
29642 srv_desc
.Texture2D
.MostDetailedMip
= 1;
29643 srv_desc
.Texture2D
.MipLevels
= ~0u;
29644 hr
= ID3D11Device_CreateShaderResourceView(device
, resource
, &srv_desc
, &srv_sampling
);
29645 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
29646 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
29647 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv_sampling
);
29649 draw_quad(&test_context
);
29651 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
29652 color
= get_readback_color(&rb
, 320, 240, 0);
29653 ok(compare_color(color
, 0x7fbcbcbc, 1) || broken(compare_color(color
, 0x7f7f7f7f, 1)), /* AMD */
29654 "Unexpected color %08x.\n", color
);
29655 release_resource_readback(&rb
);
29657 ID3D11ShaderResourceView_Release(srv_sampling
);
29658 ID3D11ShaderResourceView_Release(srv
);
29660 srv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
29661 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_TEXTURE2D
;
29662 srv_desc
.Texture2D
.MostDetailedMip
= 0;
29663 srv_desc
.Texture2D
.MipLevels
= ~0u;
29664 hr
= ID3D11Device_CreateShaderResourceView(device
, resource
, &srv_desc
, &srv
);
29665 ID3D11DeviceContext_UpdateSubresource(context
, resource
,
29666 0, NULL
, data
, sizeof(*data
) * 32, sizeof(*data
) * 32 * 32);
29668 ID3D11DeviceContext_GenerateMips(context
, srv
);
29670 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, &white
.w
);
29672 srv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
29673 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_TEXTURE2D
;
29674 srv_desc
.Texture2D
.MostDetailedMip
= 1;
29675 srv_desc
.Texture2D
.MipLevels
= ~0u;
29676 hr
= ID3D11Device_CreateShaderResourceView(device
, resource
, &srv_desc
, &srv_sampling
);
29677 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
29678 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
29679 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv_sampling
);
29681 draw_quad(&test_context
);
29683 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
29684 check_readback_data_color(&rb
, NULL
, 0x7f7f7f7f, 1);
29685 release_resource_readback(&rb
);
29687 ID3D11ShaderResourceView_Release(srv_sampling
);
29688 ID3D11ShaderResourceView_Release(srv
);
29690 ID3D11Resource_Release(resource
);
29692 heap_free(zero_data
);
29695 ID3D11SamplerState_Release(sampler_state
);
29696 ID3D11PixelShader_Release(ps_3d
);
29697 ID3D11PixelShader_Release(ps
);
29698 release_test_context(&test_context
);
29701 static void test_alpha_to_coverage(void)
29706 struct vec2 bottom
;
29711 struct d3d11_test_context test_context
;
29712 ID3D11Texture2D
*render_targets
[3];
29713 D3D11_TEXTURE2D_DESC texture_desc
;
29714 ID3D11Texture2D
*readback_texture
;
29715 ID3D11RenderTargetView
*rtvs
[3];
29716 ID3D11BlendState
*blend_state
;
29717 ID3D11DeviceContext
*context
;
29718 D3D11_BLEND_DESC blend_desc
;
29719 struct resource_readback rb
;
29720 UINT quality_level_count
;
29721 ID3D11PixelShader
*ps
;
29722 struct ps_cb cb_data
;
29723 ID3D11Device
*device
;
29729 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
29730 static const DWORD ps_code
[] =
29738 void main(float4 position
: SV_Position
,
29739 out float4 target0
: SV_Target0
,
29740 out float4 target1
: SV_Target1
,
29741 out float4 target2
: SV_Target2
)
29743 float alpha
= all(top
<= position
.xy
) && all(position
.xy
<= bottom
) ? 1.0f
: 0.0f
;
29744 target0
= float4(0.0f
, 1.0f
, 0.0f
, alpha
);
29745 target1
= float4(0.0f
, 0.0f
, 1.0f
, alpha1
);
29746 target2
= float4(0.0f
, 1.0f
, 0.0f
, alpha2
);
29749 0x43425844, 0x771ff802, 0xca927279, 0x5bdd75ae, 0xf53cb31b, 0x00000001, 0x00000264, 0x00000003,
29750 0x0000002c, 0x00000060, 0x000000c4, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
29751 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
29752 0x4e47534f, 0x0000005c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000000, 0x00000003,
29753 0x00000000, 0x0000000f, 0x00000050, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
29754 0x00000050, 0x00000002, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x545f5653, 0x65677261,
29755 0xabab0074, 0x52444853, 0x00000198, 0x00000040, 0x00000066, 0x04000059, 0x00208e46, 0x00000000,
29756 0x00000002, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
29757 0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068, 0x00000001,
29758 0x0800001d, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00208046, 0x00000000, 0x00000000,
29759 0x07000001, 0x00100012, 0x00000000, 0x0010001a, 0x00000000, 0x0010000a, 0x00000000, 0x0800001d,
29760 0x00100062, 0x00000000, 0x00208ba6, 0x00000000, 0x00000000, 0x00101106, 0x00000000, 0x07000001,
29761 0x00100022, 0x00000000, 0x0010002a, 0x00000000, 0x0010001a, 0x00000000, 0x07000001, 0x00100012,
29762 0x00000000, 0x0010001a, 0x00000000, 0x0010000a, 0x00000000, 0x07000001, 0x00102082, 0x00000000,
29763 0x0010000a, 0x00000000, 0x00004001, 0x3f800000, 0x08000036, 0x00102072, 0x00000000, 0x00004002,
29764 0x00000000, 0x3f800000, 0x00000000, 0x00000000, 0x08000036, 0x00102072, 0x00000001, 0x00004002,
29765 0x00000000, 0x00000000, 0x3f800000, 0x00000000, 0x06000036, 0x00102082, 0x00000001, 0x0020800a,
29766 0x00000000, 0x00000001, 0x08000036, 0x00102072, 0x00000002, 0x00004002, 0x00000000, 0x3f800000,
29767 0x00000000, 0x00000000, 0x06000036, 0x00102082, 0x00000002, 0x0020801a, 0x00000000, 0x00000001,
29770 static const DWORD colors
[] = {0xff00ff00, 0xbfff0000, 0x8000ff00};
29772 if (!init_test_context(&test_context
, NULL
))
29774 device
= test_context
.device
;
29775 context
= test_context
.immediate_context
;
29777 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
29778 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
29779 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
29781 memset(&blend_desc
, 0, sizeof(blend_desc
));
29782 blend_desc
.AlphaToCoverageEnable
= TRUE
;
29783 blend_desc
.RenderTarget
[0].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_ALL
;
29784 hr
= ID3D11Device_CreateBlendState(device
, &blend_desc
, &blend_state
);
29785 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
29786 ID3D11DeviceContext_OMSetBlendState(context
, blend_state
, NULL
, D3D11_DEFAULT_SAMPLE_MASK
);
29788 render_targets
[0] = test_context
.backbuffer
;
29789 rtvs
[0] = test_context
.backbuffer_rtv
;
29790 for (i
= 1; i
< ARRAY_SIZE(render_targets
); ++i
)
29792 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
29793 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &render_targets
[i
]);
29794 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
29795 hr
= ID3D11Device_CreateRenderTargetView(device
,
29796 (ID3D11Resource
*)render_targets
[i
], NULL
, &rtvs
[i
]);
29797 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
29799 ID3D11DeviceContext_OMSetRenderTargets(context
, ARRAY_SIZE(rtvs
), rtvs
, NULL
);
29801 cb_data
.top
.x
= cb_data
.top
.y
= 0.0f
;
29802 cb_data
.bottom
.x
= cb_data
.bottom
.y
= 200.0f
;
29803 cb_data
.alpha
[0] = 0.75;
29804 cb_data
.alpha
[1] = 0.5f
;
29805 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(cb_data
), &cb_data
);
29806 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
29808 for (i
= 0; i
< ARRAY_SIZE(rtvs
); ++i
)
29809 ID3D11DeviceContext_ClearRenderTargetView(context
, rtvs
[i
], white
);
29810 draw_quad(&test_context
);
29811 for (i
= 0; i
< ARRAY_SIZE(render_targets
); ++i
)
29813 DWORD expected_color
;
29815 assert(i
< ARRAY_SIZE(colors
));
29816 expected_color
= colors
[i
];
29817 get_texture_readback(render_targets
[i
], 0, &rb
);
29818 SetRect(&rect
, 0, 0, 200, 200);
29819 check_readback_data_color(&rb
, &rect
, expected_color
, 1);
29820 SetRect(&rect
, 200, 0, 640, 200);
29822 check_readback_data_color(&rb
, &rect
, 0xffffffff, 1);
29823 SetRect(&rect
, 0, 200, 640, 480);
29825 check_readback_data_color(&rb
, &rect
, 0xffffffff, 1);
29826 release_resource_readback(&rb
);
29829 ID3D11Texture2D_Release(render_targets
[i
]);
29830 render_targets
[i
] = NULL
;
29833 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
29834 texture_desc
.Format
= DXGI_FORMAT_R16G16_UNORM
;
29835 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &render_targets
[0]);
29836 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
29837 hr
= ID3D11Device_CreateRenderTargetView(device
,
29838 (ID3D11Resource
*)render_targets
[0], NULL
, &rtvs
[0]);
29839 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
29840 ID3D11DeviceContext_OMSetRenderTargets(context
, ARRAY_SIZE(rtvs
), rtvs
, NULL
);
29842 ID3D11DeviceContext_ClearRenderTargetView(context
, rtvs
[0], white
);
29843 draw_quad(&test_context
);
29844 get_texture_readback(render_targets
[0], 0, &rb
);
29845 SetRect(&rect
, 0, 0, 200, 200);
29846 check_readback_data_color(&rb
, &rect
, 0xffff0000, 1);
29847 SetRect(&rect
, 200, 0, 640, 200);
29849 check_readback_data_color(&rb
, &rect
, 0xffffffff, 1);
29850 SetRect(&rect
, 0, 200, 640, 480);
29852 check_readback_data_color(&rb
, &rect
, 0xffffffff, 1);
29853 release_resource_readback(&rb
);
29855 ID3D11Texture2D_Release(render_targets
[0]);
29856 for (i
= 0; i
< ARRAY_SIZE(rtvs
); ++i
)
29857 ID3D11RenderTargetView_Release(rtvs
[i
]);
29859 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
29860 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
,
29861 texture_desc
.Format
, 4, &quality_level_count
);
29862 ok(hr
== S_OK
, "Failed to check multisample quality levels, hr %#x.\n", hr
);
29863 if (!quality_level_count
)
29865 skip("4xMSAA not supported.\n");
29868 texture_desc
.SampleDesc
.Count
= 4;
29869 texture_desc
.SampleDesc
.Quality
= 0;
29871 for (i
= 0; i
< ARRAY_SIZE(render_targets
); ++i
)
29873 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &render_targets
[i
]);
29874 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
29875 hr
= ID3D11Device_CreateRenderTargetView(device
,
29876 (ID3D11Resource
*)render_targets
[i
], NULL
, &rtvs
[i
]);
29877 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
29879 ID3D11DeviceContext_OMSetRenderTargets(context
, ARRAY_SIZE(rtvs
), rtvs
, NULL
);
29881 for (i
= 0; i
< ARRAY_SIZE(rtvs
); ++i
)
29882 ID3D11DeviceContext_ClearRenderTargetView(context
, rtvs
[i
], white
);
29883 draw_quad(&test_context
);
29884 texture_desc
.SampleDesc
.Count
= 1;
29885 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &readback_texture
);
29886 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
29887 for (i
= 0; i
< ARRAY_SIZE(render_targets
); ++i
)
29889 DWORD expected_color
;
29891 assert(i
< ARRAY_SIZE(colors
));
29892 expected_color
= colors
[i
];
29894 ID3D11DeviceContext_ResolveSubresource(context
, (ID3D11Resource
*)readback_texture
, 0,
29895 (ID3D11Resource
*)render_targets
[i
], 0, texture_desc
.Format
);
29897 get_texture_readback(readback_texture
, 0, &rb
);
29898 SetRect(&rect
, 0, 0, 200, 200);
29899 check_readback_data_color(&rb
, &rect
, expected_color
, 1);
29900 SetRect(&rect
, 200, 0, 640, 200);
29901 check_readback_data_color(&rb
, &rect
, 0xffffffff, 1);
29902 SetRect(&rect
, 0, 200, 640, 480);
29903 check_readback_data_color(&rb
, &rect
, 0xffffffff, 1);
29904 release_resource_readback(&rb
);
29906 ID3D11Texture2D_Release(readback_texture
);
29908 for (i
= 0; i
< ARRAY_SIZE(render_targets
); ++i
)
29910 ID3D11Texture2D_Release(render_targets
[i
]);
29911 ID3D11RenderTargetView_Release(rtvs
[i
]);
29915 ID3D11Buffer_Release(cb
);
29916 ID3D11PixelShader_Release(ps
);
29917 ID3D11BlendState_Release(blend_state
);
29918 release_test_context(&test_context
);
29921 static void test_unbound_multisample_texture(void)
29923 struct d3d11_test_context test_context
;
29924 ID3D11DeviceContext
*context
;
29925 ID3D11PixelShader
*ps
;
29926 struct uvec4 cb_data
;
29927 ID3D11Device
*device
;
29932 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
29933 static const DWORD ps_code
[] =
29936 Texture2DMS
<float4
, 4> t
;
29940 float4
main(float4 position
: SV_Position
) : SV_Target
29943 t
.GetDimensions(p
.x
, p
.y
, p
.z
);
29944 p
*= float3(position
.x
/ 640.0f
, position
.y
/ 480.0f
, 0.0f
);
29945 /* sample index must be a literal */
29946 switch (sample_index
)
29948 case 1: return t
.Load(int2(p
.xy
), 1);
29949 case 2: return t
.Load(int2(p
.xy
), 2);
29950 case 3: return t
.Load(int2(p
.xy
), 3);
29951 default: return t
.Load(int2(p
.xy
), 0);
29955 0x43425844, 0x03d62416, 0x1914ee8b, 0xccd08d68, 0x27f42136, 0x00000001, 0x000002f8, 0x00000003,
29956 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
29957 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
29958 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
29959 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x0000025c, 0x00000040,
29960 0x00000097, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04042058, 0x00107000, 0x00000000,
29961 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
29962 0x02000068, 0x00000002, 0x0700003d, 0x001000f2, 0x00000000, 0x00004001, 0x00000000, 0x00107e46,
29963 0x00000000, 0x07000038, 0x00100032, 0x00000000, 0x00100046, 0x00000000, 0x00101046, 0x00000000,
29964 0x0a000038, 0x00100032, 0x00000000, 0x00100046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889,
29965 0x00000000, 0x00000000, 0x0400004c, 0x0020800a, 0x00000000, 0x00000000, 0x03000006, 0x00004001,
29966 0x00000001, 0x0500001b, 0x00100032, 0x00000001, 0x00100046, 0x00000000, 0x08000036, 0x001000c2,
29967 0x00000001, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0900002e, 0x001020f2,
29968 0x00000000, 0x00100e46, 0x00000001, 0x00107e46, 0x00000000, 0x00004001, 0x00000001, 0x0100003e,
29969 0x03000006, 0x00004001, 0x00000002, 0x0500001b, 0x00100032, 0x00000001, 0x00100046, 0x00000000,
29970 0x08000036, 0x001000c2, 0x00000001, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
29971 0x0900002e, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00107e46, 0x00000000, 0x00004001,
29972 0x00000002, 0x0100003e, 0x03000006, 0x00004001, 0x00000003, 0x0500001b, 0x00100032, 0x00000001,
29973 0x00100046, 0x00000000, 0x08000036, 0x001000c2, 0x00000001, 0x00004002, 0x00000000, 0x00000000,
29974 0x00000000, 0x00000000, 0x0900002e, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00107e46,
29975 0x00000000, 0x00004001, 0x00000003, 0x0100003e, 0x0100000a, 0x0500001b, 0x00100032, 0x00000000,
29976 0x00100046, 0x00000000, 0x08000036, 0x001000c2, 0x00000000, 0x00004002, 0x00000000, 0x00000000,
29977 0x00000000, 0x00000000, 0x0900002e, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00107e46,
29978 0x00000000, 0x00004001, 0x00000000, 0x0100003e, 0x01000017, 0x0100003e,
29981 if (!init_test_context(&test_context
, NULL
))
29983 device
= test_context
.device
;
29984 context
= test_context
.immediate_context
;
29986 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
29987 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
29988 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
29990 memset(&cb_data
, 0, sizeof(cb_data
));
29991 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(cb_data
), &cb_data
);
29992 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
29994 for (i
= 0; i
< 4; ++i
)
29997 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &cb_data
, 0, 0);
29998 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
29999 draw_quad(&test_context
);
30000 check_texture_color(test_context
.backbuffer
, 0x00000000, 1);
30003 ID3D11Buffer_Release(cb
);
30004 ID3D11PixelShader_Release(ps
);
30005 release_test_context(&test_context
);
30008 static void test_multiple_viewports(void)
30012 unsigned int draw_id
;
30013 unsigned int padding
[3];
30015 D3D11_VIEWPORT vp
[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
+ 1];
30016 struct d3d11_test_context test_context
;
30017 D3D11_TEXTURE2D_DESC texture_desc
;
30018 ID3D11DeviceContext
*context
;
30019 ID3D11RenderTargetView
*rtv
;
30020 ID3D11Texture2D
*texture
;
30021 ID3D11GeometryShader
*gs
;
30022 ID3D11PixelShader
*ps
;
30023 ID3D11Device
*device
;
30027 static const DWORD gs_code
[] =
30032 float4 pos
: SV_Position
;
30037 float4 pos
: SV_Position
;
30038 uint viewport
: SV_ViewportArrayIndex
;
30041 [maxvertexcount(6)]
30042 void main(triangle gs_in vin
[3], inout TriangleStream
<gs_out
> vout
)
30045 for (uint instance_id
= 0; instance_id
< 2; ++instance_id
)
30047 o
.viewport
= instance_id
;
30048 for (uint i
= 0; i
< 3; ++i
)
30050 o
.pos
= vin
[i
].pos
;
30053 vout
.RestartStrip();
30057 0x43425844, 0xabbb660f, 0x0729bf23, 0x14a9a104, 0x1b454917, 0x00000001, 0x0000021c, 0x00000003,
30058 0x0000002c, 0x00000060, 0x000000c4, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
30059 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x7469736f, 0x006e6f69,
30060 0x4e47534f, 0x0000005c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
30061 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000005, 0x00000001, 0x00000001, 0x00000e01,
30062 0x505f5653, 0x7469736f, 0x006e6f69, 0x565f5653, 0x70776569, 0x4174726f, 0x79617272, 0x65646e49,
30063 0xabab0078, 0x52444853, 0x00000150, 0x00020040, 0x00000054, 0x05000061, 0x002010f2, 0x00000003,
30064 0x00000000, 0x00000001, 0x02000068, 0x00000001, 0x0100185d, 0x0100285c, 0x04000067, 0x001020f2,
30065 0x00000000, 0x00000001, 0x04000067, 0x00102012, 0x00000001, 0x00000005, 0x0200005e, 0x00000006,
30066 0x05000036, 0x00100012, 0x00000000, 0x00004001, 0x00000000, 0x01000030, 0x07000050, 0x00100022,
30067 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000002, 0x03040003, 0x0010001a, 0x00000000,
30068 0x05000036, 0x00100022, 0x00000000, 0x00004001, 0x00000000, 0x01000030, 0x07000050, 0x00100042,
30069 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0x00000003, 0x03040003, 0x0010002a, 0x00000000,
30070 0x07000036, 0x001020f2, 0x00000000, 0x00a01e46, 0x0010001a, 0x00000000, 0x00000000, 0x05000036,
30071 0x00102012, 0x00000001, 0x0010000a, 0x00000000, 0x01000013, 0x0700001e, 0x00100022, 0x00000000,
30072 0x0010001a, 0x00000000, 0x00004001, 0x00000001, 0x01000016, 0x01000009, 0x0700001e, 0x00100012,
30073 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000001, 0x01000016, 0x0100003e,
30075 static const DWORD ps_code
[] =
30080 float4
main(in float4 pos
: SV_Position
,
30081 in uint viewport
: SV_ViewportArrayIndex
) : SV_Target
30083 return float4(viewport
, draw_id
, 0, 0);
30086 0x43425844, 0x77334c0f, 0x5df3ca7a, 0xc53c00db, 0x3e6e5750, 0x00000001, 0x00000150, 0x00000003,
30087 0x0000002c, 0x00000090, 0x000000c4, 0x4e475349, 0x0000005c, 0x00000002, 0x00000008, 0x00000038,
30088 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000005,
30089 0x00000001, 0x00000001, 0x00000101, 0x505f5653, 0x7469736f, 0x006e6f69, 0x565f5653, 0x70776569,
30090 0x4174726f, 0x79617272, 0x65646e49, 0xabab0078, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008,
30091 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261,
30092 0xabab0074, 0x52444853, 0x00000084, 0x00000040, 0x00000021, 0x04000059, 0x00208e46, 0x00000000,
30093 0x00000001, 0x04000864, 0x00101012, 0x00000001, 0x00000005, 0x03000065, 0x001020f2, 0x00000000,
30094 0x05000056, 0x00102012, 0x00000000, 0x0010100a, 0x00000001, 0x06000056, 0x00102022, 0x00000000,
30095 0x0020800a, 0x00000000, 0x00000000, 0x08000036, 0x001020c2, 0x00000000, 0x00004002, 0x00000000,
30096 0x00000000, 0x00000000, 0x00000000, 0x0100003e,
30098 static const struct vec4 expected_values
[] =
30100 {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
},
30101 {0.0f
, 5.0f
}, {0.5f
, 0.5f
}, {1.0f
, 5.0f
}, {0.5f
, 0.5f
},
30103 static const float clear_color
[] = {0.5f
, 0.5f
, 0.0f
, 0.0f
};
30104 ID3D11RasterizerState
*rasterizer_state
;
30105 D3D11_RASTERIZER_DESC rasterizer_desc
;
30106 unsigned int count
, i
;
30107 D3D11_RECT rects
[2];
30111 if (!init_test_context(&test_context
, NULL
))
30114 device
= test_context
.device
;
30115 context
= test_context
.immediate_context
;
30117 memset(&constant
, 0, sizeof(constant
));
30118 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(constant
), &constant
);
30119 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
30121 hr
= ID3D11Device_CreateGeometryShader(device
, gs_code
, sizeof(gs_code
), NULL
, &gs
);
30122 ok(SUCCEEDED(hr
), "Failed to create geometry shader, hr %#x.\n", hr
);
30123 ID3D11DeviceContext_GSSetShader(context
, gs
, NULL
, 0);
30125 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
30126 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
30127 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
30129 texture_desc
.Width
= 32;
30130 texture_desc
.Height
= 32;
30131 texture_desc
.MipLevels
= 1;
30132 texture_desc
.ArraySize
= 1;
30133 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
30134 texture_desc
.SampleDesc
.Count
= 1;
30135 texture_desc
.SampleDesc
.Quality
= 0;
30136 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
30137 texture_desc
.BindFlags
= D3D11_BIND_RENDER_TARGET
;
30138 texture_desc
.CPUAccessFlags
= 0;
30139 texture_desc
.MiscFlags
= 0;
30140 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
30141 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
30143 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
30144 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
30145 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
30147 width
= texture_desc
.Width
/ 2;
30149 vp
[0].TopLeftX
= 0.0f
;
30150 vp
[0].TopLeftY
= 0.0f
;
30151 vp
[0].Width
= width
;
30152 vp
[0].Height
= texture_desc
.Height
;
30153 vp
[0].MinDepth
= 0.0f
;
30154 vp
[0].MaxDepth
= 1.0f
;
30157 vp
[1].TopLeftX
= width
;
30158 vp
[1].Width
= width
;
30159 ID3D11DeviceContext_RSSetViewports(context
, 2, vp
);
30161 count
= enable_debug_layer
? ARRAY_SIZE(vp
) - 1 : ARRAY_SIZE(vp
);
30162 ID3D11DeviceContext_RSGetViewports(context
, &count
, vp
);
30163 ok(count
== 2, "Unexpected viewport count %d.\n", count
);
30165 constant
.draw_id
= 0;
30166 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
30167 draw_quad(&test_context
);
30168 constant
.draw_id
= 1;
30169 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
30170 draw_quad(&test_context
);
30172 SetRect(&rect
, 0, 0, width
- 1, texture_desc
.Height
- 1);
30173 check_texture_sub_resource_vec4(texture
, 0, &rect
, &expected_values
[0], 1);
30174 SetRect(&rect
, width
, 0, 2 * width
- 1, texture_desc
.Height
- 1);
30175 check_texture_sub_resource_vec4(texture
, 0, &rect
, &expected_values
[1], 1);
30177 /* One viewport. */
30178 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, clear_color
);
30179 ID3D11DeviceContext_RSSetViewports(context
, 1, vp
);
30180 constant
.draw_id
= 2;
30181 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
30182 draw_quad(&test_context
);
30183 SetRect(&rect
, 0, 0, width
- 1, texture_desc
.Height
- 1);
30184 check_texture_sub_resource_vec4(texture
, 0, &rect
, &expected_values
[2], 1);
30185 SetRect(&rect
, width
, 0, 2 * width
- 1, texture_desc
.Height
- 1);
30186 check_texture_sub_resource_vec4(texture
, 0, &rect
, &expected_values
[3], 1);
30188 /* Reset viewports. */
30189 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, clear_color
);
30190 ID3D11DeviceContext_RSSetViewports(context
, 0, NULL
);
30191 constant
.draw_id
= 3;
30192 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
30193 draw_quad(&test_context
);
30194 check_texture_sub_resource_vec4(texture
, 0, NULL
, &expected_values
[4], 1);
30196 /* Two viewports, only first scissor rectangle set. */
30197 memset(&rasterizer_desc
, 0, sizeof(rasterizer_desc
));
30198 rasterizer_desc
.FillMode
= D3D11_FILL_SOLID
;
30199 rasterizer_desc
.CullMode
= D3D11_CULL_BACK
;
30200 rasterizer_desc
.DepthClipEnable
= TRUE
;
30201 rasterizer_desc
.ScissorEnable
= TRUE
;
30202 hr
= ID3D11Device_CreateRasterizerState(device
, &rasterizer_desc
, &rasterizer_state
);
30203 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
30205 ID3D11DeviceContext_RSSetState(context
, rasterizer_state
);
30206 ID3D11RasterizerState_Release(rasterizer_state
);
30208 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, clear_color
);
30209 ID3D11DeviceContext_RSSetViewports(context
, 2, vp
);
30211 SetRect(&rects
[0], 0, 0, width
, texture_desc
.Height
/ 2);
30212 memset(&rects
[1], 0, sizeof(*rects
));
30213 ID3D11DeviceContext_RSSetScissorRects(context
, 1, rects
);
30214 constant
.draw_id
= 4;
30215 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
30216 draw_quad(&test_context
);
30218 SetRect(&rect
, 0, 0, width
- 1, texture_desc
.Height
/ 2 - 1);
30219 check_texture_sub_resource_vec4(texture
, 0, &rect
, &expected_values
[5], 1);
30220 SetRect(&rect
, 0, texture_desc
.Height
/ 2, width
- 1, texture_desc
.Height
- 1);
30221 check_texture_sub_resource_vec4(texture
, 0, &rect
, &expected_values
[6], 1);
30222 SetRect(&rect
, width
, 0, 2 * width
- 1, texture_desc
.Height
- 1);
30223 check_texture_sub_resource_vec4(texture
, 0, &rect
, &expected_values
[7], 1);
30225 /* Set both rectangles. */
30226 SetRect(&rects
[0], 0, 0, width
, texture_desc
.Height
/ 2);
30227 SetRect(&rects
[1], width
, 0, 2 * width
, texture_desc
.Height
/ 2);
30228 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, clear_color
);
30229 ID3D11DeviceContext_RSSetScissorRects(context
, 2, rects
);
30230 constant
.draw_id
= 5;
30231 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &constant
, 0, 0);
30232 draw_quad(&test_context
);
30234 SetRect(&rect
, 0, 0, width
- 1, texture_desc
.Height
/ 2 - 1);
30235 check_texture_sub_resource_vec4(texture
, 0, &rect
, &expected_values
[8], 1);
30236 SetRect(&rect
, 0, texture_desc
.Height
/ 2, width
- 1, texture_desc
.Height
- 1);
30237 check_texture_sub_resource_vec4(texture
, 0, &rect
, &expected_values
[9], 1);
30239 SetRect(&rect
, width
, 0, 2 * width
- 1, texture_desc
.Height
/ 2 - 1);
30240 check_texture_sub_resource_vec4(texture
, 0, &rect
, &expected_values
[10], 1);
30241 SetRect(&rect
, width
, texture_desc
.Height
/ 2, 2 * width
- 1, texture_desc
.Height
- 1);
30242 check_texture_sub_resource_vec4(texture
, 0, &rect
, &expected_values
[11], 1);
30244 if (enable_debug_layer
)
30247 /* Viewport count exceeding maximum value. */
30248 ID3D11DeviceContext_RSSetViewports(context
, 1, vp
);
30250 vp
[0].TopLeftX
= 1.0f
;
30251 vp
[0].TopLeftY
= 0.0f
;
30252 vp
[0].Width
= width
;
30253 vp
[0].Height
= texture_desc
.Height
;
30254 vp
[0].MinDepth
= 0.0f
;
30255 vp
[0].MaxDepth
= 1.0f
;
30256 for (i
= 1; i
< ARRAY_SIZE(vp
); ++i
)
30260 ID3D11DeviceContext_RSSetViewports(context
, ARRAY_SIZE(vp
), vp
);
30262 count
= ARRAY_SIZE(vp
);
30263 memset(vp
, 0, sizeof(vp
));
30264 ID3D11DeviceContext_RSGetViewports(context
, &count
, vp
);
30265 ok(count
== 1, "Unexpected viewport count %d.\n", count
);
30266 ok(vp
[0].TopLeftX
== 0.0f
&& vp
[0].Width
== width
, "Unexpected viewport.\n");
30269 ID3D11RenderTargetView_Release(rtv
);
30270 ID3D11Texture2D_Release(texture
);
30272 ID3D11Buffer_Release(cb
);
30273 ID3D11GeometryShader_Release(gs
);
30274 ID3D11PixelShader_Release(ps
);
30275 release_test_context(&test_context
);
30278 static void test_multisample_resolve(void)
30280 struct d3d11_test_context test_context
;
30281 D3D11_RENDER_TARGET_VIEW_DESC rtv_desc
;
30282 ID3D11Texture2D
*texture
, *ms_texture
;
30283 D3D11_TEXTURE2D_DESC texture_desc
;
30284 ID3D11DeviceContext
*context
;
30285 ID3D11RenderTargetView
*rtv
;
30286 ID3D11Device
*device
;
30290 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
30291 static const struct vec4 green
= {0.0f
, 1.0f
, 0.0f
, 1.0f
};
30292 static const struct vec4 color
= {0.25f
, 0.5f
, 0.75f
, 1.0f
};
30293 static const struct
30295 DXGI_FORMAT src_format
;
30296 DXGI_FORMAT dst_format
;
30297 DXGI_FORMAT format
;
30299 DXGI_FORMAT rtv_format
;
30301 const struct vec4
*color
;
30302 DWORD expected_color
;
30308 {DXGI_FORMAT_R8G8B8A8_UNORM
,
30309 DXGI_FORMAT_R8G8B8A8_UNORM
,
30310 DXGI_FORMAT_R8G8B8A8_UNORM
,
30311 DXGI_FORMAT_R8G8B8A8_UNORM
,
30312 &green
, 0xff80ff80},
30313 {DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30314 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30315 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30316 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30317 &green
, 0xffbcffbc},
30318 {DXGI_FORMAT_R8G8B8A8_UNORM
,
30319 DXGI_FORMAT_R8G8B8A8_UNORM
,
30320 DXGI_FORMAT_R8G8B8A8_UNORM
,
30321 DXGI_FORMAT_R8G8B8A8_UNORM
,
30322 &color
, 0xffdfc0a0},
30323 {DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30324 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30325 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30326 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30327 &color
, 0xfff1e1cf},
30329 {DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30330 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30331 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30332 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30333 &green
, 0xffbcffbc, TRUE
},
30334 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30335 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30336 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30337 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30338 &green
, 0xffbcffbc, TRUE
},
30339 {DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30340 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30341 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30342 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30343 &color
, 0xfff1e1cf, TRUE
},
30344 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30345 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30346 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30347 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30348 &color
, 0xfff1e1cf, TRUE
},
30350 {DXGI_FORMAT_R8G8B8A8_UNORM
,
30351 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30352 DXGI_FORMAT_R8G8B8A8_UNORM
,
30353 DXGI_FORMAT_R8G8B8A8_UNORM
,
30354 &green
, 0xff80ff80},
30355 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30356 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30357 DXGI_FORMAT_R8G8B8A8_UNORM
,
30358 DXGI_FORMAT_R8G8B8A8_UNORM
,
30359 &green
, 0xff80ff80},
30360 {DXGI_FORMAT_R8G8B8A8_UNORM
,
30361 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30362 DXGI_FORMAT_R8G8B8A8_UNORM
,
30363 DXGI_FORMAT_R8G8B8A8_UNORM
,
30364 &color
, 0xffdfc0a0},
30365 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30366 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30367 DXGI_FORMAT_R8G8B8A8_UNORM
,
30368 DXGI_FORMAT_R8G8B8A8_UNORM
,
30369 &color
, 0xffdfc0a0},
30371 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30372 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30373 DXGI_FORMAT_R8G8B8A8_UNORM
,
30374 DXGI_FORMAT_R8G8B8A8_UNORM
,
30375 &green
, 0xff80ff80},
30376 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30377 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30378 DXGI_FORMAT_R8G8B8A8_UNORM
,
30379 DXGI_FORMAT_R8G8B8A8_UNORM
,
30380 &color
, 0xffdfc0a0},
30381 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30382 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30383 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30384 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30385 &green
, 0xffbcffbc, TRUE
},
30386 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30387 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30388 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30389 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30390 &color
, 0xfff1e1cf, TRUE
},
30391 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30392 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30393 DXGI_FORMAT_R8G8B8A8_UNORM
,
30394 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30395 &green
, 0xff80ff80},
30396 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30397 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30398 DXGI_FORMAT_R8G8B8A8_UNORM
,
30399 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30400 &color
, 0xfff0dec4},
30401 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30402 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30403 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30404 DXGI_FORMAT_R8G8B8A8_UNORM
,
30405 &green
, 0xffbcffbc, TRUE
},
30406 {DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30407 DXGI_FORMAT_R8G8B8A8_TYPELESS
,
30408 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
30409 DXGI_FORMAT_R8G8B8A8_UNORM
,
30410 &color
, 0xffe2cdc0, TRUE
},
30413 if (!init_test_context(&test_context
, NULL
))
30415 device
= test_context
.device
;
30416 context
= test_context
.immediate_context
;
30418 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_TYPELESS
, 4, &i
);
30419 ok(hr
== S_OK
, "Failed to check multisample quality levels, hr %#x.\n", hr
);
30422 skip("4xMSAA not supported.\n");
30423 release_test_context(&test_context
);
30427 ID3D11DeviceContext_OMSetBlendState(context
, NULL
, NULL
, 3);
30429 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
30431 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
30432 texture_desc
.Format
= tests
[i
].dst_format
;
30433 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
30434 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
30436 texture_desc
.Format
= tests
[i
].src_format
;
30437 texture_desc
.SampleDesc
.Count
= 4;
30438 texture_desc
.SampleDesc
.Quality
= 0;
30439 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &ms_texture
);
30440 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
30441 rtv_desc
.Format
= tests
[i
].rtv_format
;
30442 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_TEXTURE2DMS
;
30443 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)ms_texture
, &rtv_desc
, &rtv
);
30444 ok(hr
== S_OK
, "Failed to create render target view, hr %#x.\n", hr
);
30446 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
30447 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, white
);
30448 draw_color_quad(&test_context
, tests
[i
].color
);
30449 ID3D11DeviceContext_ResolveSubresource(context
, (ID3D11Resource
*)texture
, 0,
30450 (ID3D11Resource
*)ms_texture
, 0, tests
[i
].format
);
30452 /* Found broken on AMD Radeon HD 6310 */
30453 if (!broken(is_amd_device(device
) && tests
[i
].format
== DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
))
30454 todo_wine_if(tests
[i
].todo
) check_texture_color(texture
, tests
[i
].expected_color
, 2);
30456 ID3D11RenderTargetView_Release(rtv
);
30457 ID3D11Texture2D_Release(ms_texture
);
30458 ID3D11Texture2D_Release(texture
);
30461 release_test_context(&test_context
);
30464 static void test_sample_shading(void)
30472 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
30473 struct d3d11_test_context test_context
;
30474 struct swapchain_desc swapchain_desc
;
30475 D3D11_TEXTURE2D_DESC texture_desc
;
30476 ID3D11UnorderedAccessView
*uav
;
30477 D3D11_BUFFER_DESC buffer_desc
;
30478 ID3D11ShaderResourceView
*srv
;
30479 ID3D11DeviceContext
*context
;
30480 ID3D11RenderTargetView
*rtv
;
30481 struct resource_readback rb
;
30482 ID3D11Buffer
*buffer
, *cb
;
30483 ID3D11Texture2D
*texture
;
30484 struct uvec4 ps_constant
;
30485 ID3D11PixelShader
*ps
;
30486 ID3D11Device
*device
;
30491 static const DWORD ps_unused_sample_index_code
[] =
30494 RWByteAddressBuffer u
;
30496 float4
main(uint id
: SV_SampleIndex
) : SV_Target
30498 u
.InterlockedAdd(0, 1);
30499 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
30502 0x43425844, 0x41e4574b, 0x1e6441d6, 0x5e756375, 0xacd5dc27, 0x00000001, 0x00000104, 0x00000003,
30503 0x0000002c, 0x00000064, 0x00000098, 0x4e475349, 0x00000030, 0x00000001, 0x00000008, 0x00000020,
30504 0x00000000, 0x0000000a, 0x00000001, 0x00000000, 0x00000001, 0x535f5653, 0x6c706d61, 0x646e4965,
30505 0xab007865, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
30506 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000064,
30507 0x00000050, 0x00000019, 0x0100086a, 0x0300009d, 0x0011e000, 0x00000001, 0x03000065, 0x001020f2,
30508 0x00000000, 0x070000ad, 0x0011e000, 0x00000001, 0x00004001, 0x00000000, 0x00004001, 0x00000001,
30509 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x3f800000,
30512 static const struct shader ps_unused_sample_index
30513 = {ps_unused_sample_index_code
, sizeof(ps_unused_sample_index_code
)};
30514 static const DWORD ps_sample_index_code
[] =
30517 RWByteAddressBuffer u
;
30519 float4
main(uint id
: SV_SampleIndex
) : SV_Target
30521 u
.InterlockedAdd(0, 1);
30522 u
.InterlockedAdd(4, id
);
30523 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
30526 0x43425844, 0x943ab9ed, 0x91520b4a, 0xb75df9d0, 0x692cd3e6, 0x00000001, 0x00000130, 0x00000003,
30527 0x0000002c, 0x00000064, 0x00000098, 0x4e475349, 0x00000030, 0x00000001, 0x00000008, 0x00000020,
30528 0x00000000, 0x0000000a, 0x00000001, 0x00000000, 0x00000101, 0x535f5653, 0x6c706d61, 0x646e4965,
30529 0xab007865, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
30530 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000090,
30531 0x00000050, 0x00000024, 0x0100086a, 0x0300009d, 0x0011e000, 0x00000001, 0x04000863, 0x00101012,
30532 0x00000000, 0x0000000a, 0x03000065, 0x001020f2, 0x00000000, 0x070000ad, 0x0011e000, 0x00000001,
30533 0x00004001, 0x00000000, 0x00004001, 0x00000001, 0x070000ad, 0x0011e000, 0x00000001, 0x00004001,
30534 0x00000004, 0x0010100a, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000,
30535 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e,
30537 static const struct shader ps_sample_index
= {ps_sample_index_code
, sizeof(ps_sample_index_code
)};
30538 static const DWORD ps_samplepos_code
[] =
30541 Texture2DMS
<float> t
;
30542 RWByteAddressBuffer u
;
30544 float4
main() : SV_Target
30546 float2 sample_position
= t
.GetSamplePosition(0);
30547 u
.InterlockedAdd(0, 1);
30548 u
.InterlockedAdd(4, sample_position
.x
+ sample_position
.y
);
30549 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
30552 0x43425844, 0x9ec7f344, 0x588f5863, 0x436c0531, 0x69dc54bb, 0x00000001, 0x00000160, 0x00000003,
30553 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
30554 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
30555 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000e8, 0x00000050, 0x0000003a,
30556 0x0100086a, 0x04002058, 0x00107000, 0x00000000, 0x00005555, 0x0300009d, 0x0011e000, 0x00000001,
30557 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x070000ad, 0x0011e000, 0x00000001,
30558 0x00004001, 0x00000000, 0x00004001, 0x00000001, 0x0800006e, 0x00100032, 0x00000000, 0x00107046,
30559 0x00000000, 0x00004001, 0x00000000, 0x00000000, 0x07000000, 0x00100012, 0x00000000, 0x0010001a,
30560 0x00000000, 0x0010000a, 0x00000000, 0x0500001c, 0x00100012, 0x00000000, 0x0010000a, 0x00000000,
30561 0x070000ad, 0x0011e000, 0x00000001, 0x00004001, 0x00000004, 0x0010000a, 0x00000000, 0x08000036,
30562 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e,
30564 static const struct shader ps_samplepos
= {ps_samplepos_code
, sizeof(ps_samplepos_code
)};
30565 static const DWORD ps_samplepos_rasterizer_code
[] =
30568 RWByteAddressBuffer u
;
30570 float4
main() : SV_Target
30572 float2 sample_position
= GetRenderTargetSamplePosition(0);
30573 u
.InterlockedAdd(0, 1);
30574 u
.InterlockedAdd(4, sample_position
.x
+ sample_position
.y
);
30575 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
30578 0x43425844, 0xe31795d9, 0x4e9951da, 0xc1713913, 0xfb12da31, 0x00000001, 0x00000148, 0x00000003,
30579 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
30580 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
30581 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000d0, 0x00000050, 0x00000034,
30582 0x0100086a, 0x0300009d, 0x0011e000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
30583 0x00000001, 0x070000ad, 0x0011e000, 0x00000001, 0x00004001, 0x00000000, 0x00004001, 0x00000001,
30584 0x0600006e, 0x00100032, 0x00000000, 0x0000e046, 0x00004001, 0x00000000, 0x07000000, 0x00100012,
30585 0x00000000, 0x0010001a, 0x00000000, 0x0010000a, 0x00000000, 0x0500001c, 0x00100012, 0x00000000,
30586 0x0010000a, 0x00000000, 0x070000ad, 0x0011e000, 0x00000001, 0x00004001, 0x00000004, 0x0010000a,
30587 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x00000000,
30588 0x3f800000, 0x0100003e,
30590 static const struct shader ps_samplepos_rasterizer
30591 = {ps_samplepos_rasterizer_code
, sizeof(ps_samplepos_rasterizer_code
)};
30592 static const DWORD ps_samplepos_indexed_code
[] =
30595 RWByteAddressBuffer u
;
30597 float4
main(uint id
: SV_SampleIndex
) : SV_Target
30599 float2 sample_position
= GetRenderTargetSamplePosition(id
);
30600 u
.InterlockedAdd(0, 1);
30601 u
.InterlockedAdd(4, sample_position
.x
+ sample_position
.y
);
30602 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
30605 0x43425844, 0x4b501464, 0x0cd4f636, 0x36428677, 0x6db6b4fb, 0x00000001, 0x00000180, 0x00000003,
30606 0x0000002c, 0x00000064, 0x00000098, 0x4e475349, 0x00000030, 0x00000001, 0x00000008, 0x00000020,
30607 0x00000000, 0x0000000a, 0x00000001, 0x00000000, 0x00000101, 0x535f5653, 0x6c706d61, 0x646e4965,
30608 0xab007865, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
30609 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000e0,
30610 0x00000050, 0x00000038, 0x0100086a, 0x0300009d, 0x0011e000, 0x00000001, 0x04000863, 0x00101012,
30611 0x00000000, 0x0000000a, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x070000ad,
30612 0x0011e000, 0x00000001, 0x00004001, 0x00000000, 0x00004001, 0x00000001, 0x0600006e, 0x00100032,
30613 0x00000000, 0x0000e046, 0x0010100a, 0x00000000, 0x07000000, 0x00100012, 0x00000000, 0x0010001a,
30614 0x00000000, 0x0010000a, 0x00000000, 0x0500001c, 0x00100012, 0x00000000, 0x0010000a, 0x00000000,
30615 0x070000ad, 0x0011e000, 0x00000001, 0x00004001, 0x00000004, 0x0010000a, 0x00000000, 0x08000036,
30616 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e,
30618 static const struct shader ps_samplepos_indexed
30619 = {ps_samplepos_indexed_code
, sizeof(ps_samplepos_indexed_code
)};
30620 static const DWORD ps_sampleinfo_code
[] =
30623 Texture2DMS
<float> t
;
30624 RWByteAddressBuffer u
;
30626 float4
main() : SV_Target
30628 uint width
, height
, sample_count
;
30629 t
.GetDimensions(width
, height
, sample_count
);
30630 u
.InterlockedAdd(0, 1);
30631 u
.InterlockedAdd(4, sample_count
);
30632 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
30635 0x43425844, 0x4e4f4065, 0x20d88902, 0xd4750e8c, 0x652b8c04, 0x00000001, 0x00000124, 0x00000003,
30636 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
30637 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
30638 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000ac, 0x00000050, 0x0000002b,
30639 0x0100086a, 0x04002058, 0x00107000, 0x00000000, 0x00005555, 0x0300009d, 0x0011e000, 0x00000001,
30640 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x070000ad, 0x0011e000, 0x00000001,
30641 0x00004001, 0x00000000, 0x00004001, 0x00000001, 0x0500086f, 0x00100012, 0x00000000, 0x0010700a,
30642 0x00000000, 0x070000ad, 0x0011e000, 0x00000001, 0x00004001, 0x00000004, 0x0010000a, 0x00000000,
30643 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x3f800000,
30646 static const struct shader ps_sampleinfo
= {ps_sampleinfo_code
, sizeof(ps_sampleinfo_code
)};
30647 static const DWORD ps_sampleinfo_rasterizer_code
[] =
30650 RWByteAddressBuffer u
;
30652 float4
main() : SV_Target
30654 uint sample_count
= GetRenderTargetSampleCount();
30655 u
.InterlockedAdd(0, 1);
30656 u
.InterlockedAdd(4, sample_count
);
30657 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
30660 0x43425844, 0xfbbd8619, 0x9c2654c8, 0xb385363a, 0x4aacd10f, 0x00000001, 0x00000110, 0x00000003,
30661 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
30662 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
30663 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000098, 0x00000050, 0x00000026,
30664 0x0100086a, 0x0300009d, 0x0011e000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
30665 0x00000001, 0x070000ad, 0x0011e000, 0x00000001, 0x00004001, 0x00000000, 0x00004001, 0x00000001,
30666 0x0400086f, 0x00100012, 0x00000000, 0x0000e00a, 0x070000ad, 0x0011e000, 0x00000001, 0x00004001,
30667 0x00000004, 0x0010000a, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000,
30668 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e,
30670 static const struct shader ps_sampleinfo_rasterizer
30671 = {ps_sampleinfo_rasterizer_code
, sizeof(ps_sampleinfo_rasterizer_code
)};
30672 static const DWORD ps_sample_code
[] =
30675 RWByteAddressBuffer u
;
30677 float4
main(sample float4 position
: SV_Position
) : SV_Target
30679 u
.InterlockedAdd(0, 1);
30680 u
.InterlockedAdd(4, position
.x
);
30681 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
30684 0x43425844, 0x46ecbadb, 0xedccbea6, 0x236d7923, 0x0c356c8c, 0x00000001, 0x00000148, 0x00000003,
30685 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
30686 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000010f, 0x505f5653, 0x7469736f, 0x006e6f69,
30687 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
30688 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000ac, 0x00000050,
30689 0x0000002b, 0x0100086a, 0x0300009d, 0x0011e000, 0x00000001, 0x04003864, 0x00101012, 0x00000000,
30690 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x070000ad, 0x0011e000,
30691 0x00000001, 0x00004001, 0x00000000, 0x00004001, 0x00000001, 0x0500001c, 0x00100012, 0x00000000,
30692 0x0010100a, 0x00000000, 0x070000ad, 0x0011e000, 0x00000001, 0x00004001, 0x00000004, 0x0010000a,
30693 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x00000000,
30694 0x3f800000, 0x0100003e,
30696 static const struct shader ps_sample
= {ps_sample_code
, sizeof(ps_sample_code
)};
30697 static const DWORD ps_color_code
[] =
30700 float4
main(uint id
: SV_SampleIndex
) : SV_Target
30704 case 0: return float4(1.0f
, 0.0f
, 0.0f
, 1.0f
);
30705 case 1: return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
30706 case 2: return float4(0.0f
, 0.0f
, 1.0f
, 1.0f
);
30707 default: return float4(0.0f
, 0.0f
, 0.0f
, 1.0f
);
30711 0x43425844, 0x94c35f48, 0x04c6b0f7, 0x407d8214, 0xc24f01e5, 0x00000001, 0x00000194, 0x00000003,
30712 0x0000002c, 0x00000064, 0x00000098, 0x4e475349, 0x00000030, 0x00000001, 0x00000008, 0x00000020,
30713 0x00000000, 0x0000000a, 0x00000001, 0x00000000, 0x00000101, 0x535f5653, 0x6c706d61, 0x646e4965,
30714 0xab007865, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
30715 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000f4,
30716 0x00000050, 0x0000003d, 0x0100086a, 0x04000863, 0x00101012, 0x00000000, 0x0000000a, 0x03000065,
30717 0x001020f2, 0x00000000, 0x0300004c, 0x0010100a, 0x00000000, 0x03000006, 0x00004001, 0x00000000,
30718 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000,
30719 0x0100003e, 0x03000006, 0x00004001, 0x00000001, 0x08000036, 0x001020f2, 0x00000000, 0x00004002,
30720 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e, 0x03000006, 0x00004001, 0x00000002,
30721 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x3f800000, 0x3f800000,
30722 0x0100003e, 0x0100000a, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000,
30723 0x00000000, 0x3f800000, 0x0100003e, 0x01000017, 0x0100003e,
30725 static const DWORD ps_resolve_code
[] =
30728 Texture2DMS
<float4
> t
;
30733 float4
main(float4 position
: SV_Position
) : SV_Target
30736 t
.GetDimensions(p
.x
, p
.y
, p
.z
);
30737 p
*= float3(position
.x
/ rt_size
, position
.y
/ rt_size
, 0);
30738 return t
.Load((int2
)p
.xy
, sample
);
30741 0x43425844, 0x68a4590b, 0xc1ec3070, 0x1b957c43, 0x0c080741, 0x00000001, 0x000001c8, 0x00000003,
30742 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
30743 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
30744 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
30745 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000012c, 0x00000050,
30746 0x0000004b, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04002058, 0x00107000,
30747 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2,
30748 0x00000000, 0x02000068, 0x00000001, 0x06000056, 0x00100012, 0x00000000, 0x0020801a, 0x00000000,
30749 0x00000000, 0x0700000e, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00100006, 0x00000000,
30750 0x8900003d, 0x80000102, 0x00155543, 0x001000c2, 0x00000000, 0x00004001, 0x00000000, 0x001074e6,
30751 0x00000000, 0x07000038, 0x00100032, 0x00000000, 0x00100046, 0x00000000, 0x00100ae6, 0x00000000,
30752 0x0500001b, 0x00100032, 0x00000000, 0x00100046, 0x00000000, 0x08000036, 0x001000c2, 0x00000000,
30753 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8c00002e, 0x80000102, 0x00155543,
30754 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00107e46, 0x00000000, 0x0020800a, 0x00000000,
30755 0x00000000, 0x0100003e,
30757 static const struct
30759 const struct shader
*ps
;
30760 BOOL sample_shading
;
30766 {&ps_unused_sample_index
, FALSE
, FALSE
, TRUE
/* broken on Nvidia */},
30767 {&ps_sample_index
, TRUE
},
30768 {&ps_samplepos
, FALSE
},
30769 {&ps_samplepos_rasterizer
, FALSE
},
30770 {&ps_samplepos_indexed
, TRUE
, TRUE
},
30771 {&ps_sampleinfo
, FALSE
},
30772 {&ps_sampleinfo_rasterizer
, FALSE
},
30773 {&ps_sample
, TRUE
, TRUE
, TRUE
/* broken on Intel */},
30775 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
30776 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
30777 static const unsigned int zero
[4] = {0};
30779 swapchain_desc
.windowed
= TRUE
;
30780 swapchain_desc
.buffer_count
= 1;
30781 swapchain_desc
.width
= 32;
30782 swapchain_desc
.height
= 32;
30783 swapchain_desc
.swap_effect
= DXGI_SWAP_EFFECT_DISCARD
;
30784 swapchain_desc
.flags
= 0;
30785 if (!init_test_context_ext(&test_context
, &feature_level
, &swapchain_desc
))
30787 device
= test_context
.device
;
30788 context
= test_context
.immediate_context
;
30790 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
30791 texture_desc
.SampleDesc
.Count
= 4;
30792 texture_desc
.SampleDesc
.Quality
= 0;
30793 texture_desc
.BindFlags
|= D3D11_BIND_SHADER_RESOURCE
;
30794 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
30795 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
30796 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
30797 ok(hr
== S_OK
, "Failed to create render target view, hr %#x.\n", hr
);
30798 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
30799 ok(hr
== S_OK
, "Failed to create shader resource view, hr %#x.\n", hr
);
30801 buffer_desc
.ByteWidth
= 1024;
30802 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
30803 buffer_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
30804 buffer_desc
.CPUAccessFlags
= 0;
30805 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
;
30806 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
30807 ok(hr
== S_OK
, "Failed to create buffer, hr %#x.\n", hr
);
30808 uav_desc
.Format
= DXGI_FORMAT_R32_TYPELESS
;
30809 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
30810 U(uav_desc
).Buffer
.FirstElement
= 0;
30811 U(uav_desc
).Buffer
.NumElements
= 256;
30812 U(uav_desc
).Buffer
.Flags
= D3D11_BUFFER_UAV_FLAG_RAW
;
30813 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
30814 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
30816 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
30818 hr
= ID3D11Device_CreatePixelShader(device
, tests
[i
].ps
->code
, tests
[i
].ps
->size
, NULL
, &ps
);
30819 ok(hr
== S_OK
, "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
30820 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
30822 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, zero
);
30823 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
30824 ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context
,
30825 1, &test_context
.backbuffer_rtv
, NULL
, 1, 1, &uav
, NULL
);
30826 draw_quad(&test_context
);
30827 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
30828 get_buffer_readback(buffer
, &rb
);
30829 data
= get_readback_color(&rb
, 0, 0, 0);
30830 ok(1024 <= data
&& data
<= 1056, "Test %u: Got unexpected value %u.\n", i
, data
);
30831 release_resource_readback(&rb
);
30833 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, zero
);
30834 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, white
);
30835 ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context
,
30836 1, &rtv
, NULL
, 1, 1, &uav
, NULL
);
30837 draw_quad(&test_context
);
30838 get_buffer_readback(buffer
, &rb
);
30839 data
= get_readback_color(&rb
, 0, 0, 0);
30840 todo_wine_if(tests
[i
].todo
)
30842 if (tests
[i
].sample_shading
)
30844 ok(4096 <= data
|| broken(tests
[i
].broken
&& data
>= 1024),
30845 "Test %u: Got unexpected value %u.\n", i
, data
);
30849 ok((1024 <= data
&& data
<= 1056) || broken(tests
[i
].broken
&& data
>= 4096),
30850 "Test %u: Got unexpected value %u.\n", i
, data
);
30853 release_resource_readback(&rb
);
30855 ID3D11PixelShader_Release(ps
);
30858 if (is_warp_device(device
))
30860 skip("Sample shading tests fail on WARP.\n");
30864 hr
= ID3D11Device_CreatePixelShader(device
, ps_color_code
, sizeof(ps_color_code
), NULL
, &ps
);
30865 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
30866 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
30867 ID3D11PixelShader_Release(ps
);
30869 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, white
);
30870 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
30871 draw_quad(&test_context
);
30872 ID3D11DeviceContext_ResolveSubresource(context
, (ID3D11Resource
*)test_context
.backbuffer
, 0,
30873 (ID3D11Resource
*)texture
, 0, texture_desc
.Format
);
30874 check_texture_color(test_context
.backbuffer
, 0xff404040, 2);
30876 hr
= ID3D11Device_CreatePixelShader(device
, ps_resolve_code
, sizeof(ps_resolve_code
), NULL
, &ps
);
30877 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
30878 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
30879 ID3D11PixelShader_Release(ps
);
30881 ps_constant
.y
= texture_desc
.Width
;
30882 cb
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(ps_constant
), &ps_constant
);
30883 ID3D11DeviceContext_PSSetConstantBuffers(context
, 0, 1, &cb
);
30885 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
30886 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &test_context
.backbuffer_rtv
, NULL
);
30887 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
30888 draw_quad(&test_context
);
30889 check_texture_color(test_context
.backbuffer
, 0xff0000ff, 0);
30891 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &ps_constant
, 0, 0);
30892 draw_quad(&test_context
);
30893 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
30895 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &ps_constant
, 0, 0);
30896 draw_quad(&test_context
);
30897 check_texture_color(test_context
.backbuffer
, 0xffff0000, 0);
30899 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)cb
, 0, NULL
, &ps_constant
, 0, 0);
30900 draw_quad(&test_context
);
30901 check_texture_color(test_context
.backbuffer
, 0xff000000, 0);
30903 ID3D11Buffer_Release(cb
);
30905 ID3D11Buffer_Release(buffer
);
30906 ID3D11UnorderedAccessView_Release(uav
);
30907 ID3D11RenderTargetView_Release(rtv
);
30908 ID3D11ShaderResourceView_Release(srv
);
30909 ID3D11Texture2D_Release(texture
);
30910 release_test_context(&test_context
);
30913 static void test_sample_mask(void)
30915 static const DWORD ps_code
[] =
30918 float4
main(in float4 pos
: SV_Position
, out uint sample_mask
: SV_Coverage
) : SV_Target
30921 return float4(1.0, 1.0, 1.0, 1.0);
30924 0x43425844, 0x196779a9, 0xda85988a, 0xb7f0a0b6, 0xb30dd6ba, 0x00000001, 0x00000114, 0x00000003,
30925 0x0000002c, 0x00000060, 0x000000b8, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
30926 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69,
30927 0x4e47534f, 0x00000050, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003,
30928 0x00000000, 0x0000000f, 0x00000042, 0x00000000, 0x00000000, 0x00000001, 0xffffffff, 0x00000e01,
30929 0x545f5653, 0x65677261, 0x56530074, 0x766f435f, 0x67617265, 0xabab0065, 0x58454853, 0x00000054,
30930 0x00000050, 0x00000015, 0x0100086a, 0x03000065, 0x001020f2, 0x00000000, 0x02000065, 0x0000f000,
30931 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000,
30932 0x04000036, 0x0000f001, 0x00004001, 0x00000005, 0x0100003e,
30934 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
30935 static const float black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
30936 struct d3d11_test_context test_context
;
30937 D3D11_TEXTURE2D_DESC texture_desc
;
30938 ID3D11DeviceContext
*context
;
30939 ID3D11RenderTargetView
*rtv
;
30940 ID3D11Texture2D
*texture
;
30941 ID3D11PixelShader
*ps
;
30942 ID3D11Device
*device
;
30943 UINT quality_levels
;
30946 if (!init_test_context(&test_context
, &feature_level
))
30948 device
= test_context
.device
;
30949 context
= test_context
.immediate_context
;
30951 hr
= ID3D11Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_TYPELESS
, 4, &quality_levels
);
30952 ok(hr
== S_OK
, "Failed to check multisample quality levels, hr %#x.\n", hr
);
30953 if (!quality_levels
)
30955 skip("4xMSAA not supported.\n");
30956 release_test_context(&test_context
);
30960 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
30961 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
30962 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
30964 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
30965 texture_desc
.SampleDesc
.Count
= 4;
30966 texture_desc
.SampleDesc
.Quality
= 0;
30967 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
30968 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
30969 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
30970 ok(hr
== S_OK
, "Failed to create render target view, hr %#x.\n", hr
);
30972 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
30973 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
30974 draw_quad(&test_context
);
30975 ID3D11DeviceContext_ResolveSubresource(context
, (ID3D11Resource
*)test_context
.backbuffer
, 0,
30976 (ID3D11Resource
*)texture
, 0, texture_desc
.Format
);
30977 check_texture_color(test_context
.backbuffer
, 0x7f7f7f7f, 1);
30979 ID3D11DeviceContext_OMSetBlendState(context
, NULL
, NULL
, 0xb);
30980 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
30981 draw_quad(&test_context
);
30982 ID3D11DeviceContext_ResolveSubresource(context
, (ID3D11Resource
*)test_context
.backbuffer
, 0,
30983 (ID3D11Resource
*)texture
, 0, texture_desc
.Format
);
30984 check_texture_color(test_context
.backbuffer
, 0x3f3f3f3f, 1);
30986 ID3D11RenderTargetView_Release(rtv
);
30987 ID3D11Texture2D_Release(texture
);
30988 ID3D11PixelShader_Release(ps
);
30989 release_test_context(&test_context
);
30992 static void test_depth_clip(void)
30994 struct d3d11_test_context test_context
;
30995 D3D11_TEXTURE2D_DESC texture_desc
;
30996 D3D11_RASTERIZER_DESC rs_desc
;
30997 ID3D11DeviceContext
*context
;
30998 ID3D11DepthStencilView
*dsv
;
30999 ID3D11RasterizerState
*rs
;
31000 ID3D11Texture2D
*texture
;
31001 ID3D11Device
*device
;
31002 unsigned int count
;
31006 if (!init_test_context(&test_context
, NULL
))
31008 device
= test_context
.device
;
31009 context
= test_context
.immediate_context
;
31011 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
31012 texture_desc
.Format
= DXGI_FORMAT_D32_FLOAT
;
31013 texture_desc
.BindFlags
= D3D11_BIND_DEPTH_STENCIL
;
31015 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
31016 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
31017 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)texture
, NULL
, &dsv
);
31018 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
31019 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &test_context
.backbuffer_rtv
, dsv
);
31022 ID3D11DeviceContext_RSGetViewports(context
, &count
, &vp
);
31024 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
31025 set_viewport(context
, vp
.TopLeftX
, vp
.TopLeftY
, vp
.Width
, vp
.Height
, 0.4f
, 0.6f
);
31026 draw_quad_z(&test_context
, 2.0f
);
31027 check_texture_float(texture
, 1.0f
, 1);
31028 draw_quad_z(&test_context
, 0.5f
);
31029 check_texture_float(texture
, 0.5f
, 1);
31030 draw_quad_z(&test_context
, -1.0f
);
31031 check_texture_float(texture
, 0.5f
, 1);
31033 rs_desc
.FillMode
= D3D11_FILL_SOLID
;
31034 rs_desc
.CullMode
= D3D11_CULL_BACK
;
31035 rs_desc
.FrontCounterClockwise
= FALSE
;
31036 rs_desc
.DepthBias
= 0;
31037 rs_desc
.DepthBiasClamp
= 0.0f
;
31038 rs_desc
.SlopeScaledDepthBias
= 0.0f
;
31039 rs_desc
.DepthClipEnable
= FALSE
;
31040 rs_desc
.ScissorEnable
= FALSE
;
31041 rs_desc
.MultisampleEnable
= FALSE
;
31042 rs_desc
.AntialiasedLineEnable
= FALSE
;
31043 hr
= ID3D11Device_CreateRasterizerState(device
, &rs_desc
, &rs
);
31044 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
31046 ID3D11DeviceContext_RSSetState(context
, rs
);
31048 ID3D11DeviceContext_ClearDepthStencilView(context
, dsv
, D3D11_CLEAR_DEPTH
, 1.0f
, 0);
31049 set_viewport(context
, vp
.TopLeftX
, vp
.TopLeftY
, vp
.Width
, vp
.Height
, 0.4f
, 0.6f
);
31050 draw_quad_z(&test_context
, 2.0f
);
31051 check_texture_float(texture
, 0.6f
, 1);
31052 draw_quad_z(&test_context
, 0.5f
);
31053 check_texture_float(texture
, 0.5f
, 1);
31054 draw_quad_z(&test_context
, -1.0f
);
31055 check_texture_float(texture
, 0.4f
, 1);
31057 ID3D11DepthStencilView_Release(dsv
);
31058 ID3D11Texture2D_Release(texture
);
31059 ID3D11RasterizerState_Release(rs
);
31060 release_test_context(&test_context
);
31063 static void test_staging_buffers(void)
31065 struct d3d11_test_context test_context
;
31066 ID3D11Buffer
*dst_buffer
, *src_buffer
;
31067 D3D11_SUBRESOURCE_DATA resource_data
;
31068 D3D11_BUFFER_DESC buffer_desc
;
31069 ID3D11DeviceContext
*context
;
31070 struct resource_readback rb
;
31071 float data
[16], value
;
31072 ID3D11Device
*device
;
31076 if (!init_test_context(&test_context
, NULL
))
31078 device
= test_context
.device
;
31079 context
= test_context
.immediate_context
;
31081 buffer_desc
.ByteWidth
= sizeof(data
);
31082 buffer_desc
.Usage
= D3D11_USAGE_STAGING
;
31083 buffer_desc
.BindFlags
= 0;
31084 buffer_desc
.CPUAccessFlags
= D3D11_CPU_ACCESS_WRITE
;
31085 buffer_desc
.MiscFlags
= 0;
31086 buffer_desc
.StructureByteStride
= 0;
31088 for (i
= 0; i
< ARRAY_SIZE(data
); ++i
)
31090 resource_data
.pSysMem
= data
;
31091 resource_data
.SysMemPitch
= 0;
31092 resource_data
.SysMemSlicePitch
= 0;
31094 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, &resource_data
, &src_buffer
);
31095 ok(hr
== S_OK
, "Failed to create buffer, hr %#x.\n", hr
);
31097 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
31098 buffer_desc
.BindFlags
= D3D11_BIND_CONSTANT_BUFFER
;
31099 buffer_desc
.CPUAccessFlags
= 0;
31100 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &dst_buffer
);
31101 ok(hr
== S_OK
, "Failed to create buffer, hr %#x.\n", hr
);
31103 ID3D11DeviceContext_CopyResource(context
, (ID3D11Resource
*)dst_buffer
, (ID3D11Resource
*)src_buffer
);
31104 get_buffer_readback(dst_buffer
, &rb
);
31105 for (i
= 0; i
< ARRAY_SIZE(data
); ++i
)
31107 value
= get_readback_float(&rb
, i
, 0);
31108 ok(value
== data
[i
], "Got unexpected value %.8e at %u.\n", value
, i
);
31110 release_resource_readback(&rb
);
31112 for (i
= 0; i
< ARRAY_SIZE(data
); ++i
)
31114 ID3D11DeviceContext_UpdateSubresource(context
, (ID3D11Resource
*)src_buffer
, 0, NULL
, data
, 0, 0);
31115 ID3D11DeviceContext_CopyResource(context
, (ID3D11Resource
*)dst_buffer
, (ID3D11Resource
*)src_buffer
);
31116 get_buffer_readback(dst_buffer
, &rb
);
31117 for (i
= 0; i
< ARRAY_SIZE(data
); ++i
)
31119 value
= get_readback_float(&rb
, i
, 0);
31120 ok(value
== i
, "Got unexpected value %.8e at %u.\n", value
, i
);
31122 release_resource_readback(&rb
);
31124 ID3D11Buffer_Release(dst_buffer
);
31125 ID3D11Buffer_Release(src_buffer
);
31126 release_test_context(&test_context
);
31129 static void test_render_a8(void)
31131 static const float black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
31132 struct d3d11_test_context test_context
;
31133 D3D11_TEXTURE2D_DESC texture_desc
;
31134 ID3D11DeviceContext
*context
;
31135 ID3D11RenderTargetView
*rtv
;
31136 struct resource_readback rb
;
31137 ID3D11Texture2D
*texture
;
31138 ID3D11PixelShader
*ps
;
31139 ID3D11Device
*device
;
31143 static const DWORD ps_code
[] =
31146 void main(out float4 target
: SV_Target
)
31148 target
= float4(0.0f
, 0.25f
, 0.5f
, 1.0f
);
31151 0x43425844, 0x8a06129f, 0x3041bde2, 0x09389749, 0xb339ba8b, 0x00000001, 0x000000b0, 0x00000003,
31152 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
31153 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
31154 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
31155 0x03000065, 0x001020f2, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000,
31156 0x3e800000, 0x3f000000, 0x3f800000, 0x0100003e,
31159 if (!init_test_context(&test_context
, NULL
))
31161 device
= test_context
.device
;
31162 context
= test_context
.immediate_context
;
31164 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
31165 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
31166 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
31168 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
31169 texture_desc
.Format
= DXGI_FORMAT_A8_UNORM
;
31170 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
31171 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
31172 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
31173 ok(hr
== S_OK
, "Failed to create render target view, hr %#x.\n", hr
);
31175 for (i
= 0; i
< 2; ++i
)
31177 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, black
);
31178 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &rtv
, NULL
);
31179 draw_quad(&test_context
);
31180 get_texture_readback(texture
, 0, &rb
);
31181 check_readback_data_u8(&rb
, NULL
, 0xff, 0);
31182 release_resource_readback(&rb
);
31184 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, black
);
31185 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &test_context
.backbuffer_rtv
, NULL
);
31186 draw_quad(&test_context
);
31187 check_texture_sub_resource_color(test_context
.backbuffer
, 0, NULL
, 0xff7f4000, 1);
31190 ID3D11PixelShader_Release(ps
);
31191 ID3D11Texture2D_Release(texture
);
31192 ID3D11RenderTargetView_Release(rtv
);
31193 release_test_context(&test_context
);
31196 static void test_standard_pattern(void)
31198 D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc
;
31199 struct d3d11_test_context test_context
;
31200 struct swapchain_desc swapchain_desc
;
31201 D3D11_TEXTURE2D_DESC texture_desc
;
31202 ID3D11UnorderedAccessView
*uav
;
31203 D3D11_BUFFER_DESC buffer_desc
;
31204 ID3D11ShaderResourceView
*srv
;
31205 ID3D11DeviceContext
*context
;
31206 struct resource_readback rb
;
31207 ID3D11Texture2D
*texture
;
31208 ID3D11PixelShader
*ps
;
31209 ID3D11Buffer
*buffer
;
31210 ID3D11Device
*device
;
31214 static const DWORD ps_samplepos
[] =
31217 Texture2DMS
<float> t
;
31218 RWByteAddressBuffer u
;
31220 float4
main() : SV_Target
31222 u
.Store2(0, asuint(t
.GetSamplePosition(0)));
31223 u
.Store2(8, asuint(t
.GetSamplePosition(1)));
31224 u
.Store2(16, asuint(t
.GetSamplePosition(2)));
31225 u
.Store2(24, asuint(t
.GetSamplePosition(3)));
31226 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
31229 0x43425844, 0xa1db77e8, 0x804d8862, 0x0e3c213d, 0x2703dec6, 0x00000001, 0x00000190, 0x00000003,
31230 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
31231 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
31232 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000118, 0x00000050, 0x00000046,
31233 0x0100086a, 0x04002058, 0x00107000, 0x00000000, 0x00005555, 0x0300009d, 0x0011e000, 0x00000001,
31234 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0800006e, 0x00100032, 0x00000000,
31235 0x00107046, 0x00000000, 0x00004001, 0x00000000, 0x00000000, 0x0800006e, 0x001000c2, 0x00000000,
31236 0x00107406, 0x00000000, 0x00004001, 0x00000001, 0x00000000, 0x070000a6, 0x0011e0f2, 0x00000001,
31237 0x00004001, 0x00000000, 0x00100e46, 0x00000000, 0x0800006e, 0x00100032, 0x00000000, 0x00107046,
31238 0x00000000, 0x00004001, 0x00000002, 0x00000000, 0x0800006e, 0x001000c2, 0x00000000, 0x00107406,
31239 0x00000000, 0x00004001, 0x00000003, 0x00000000, 0x070000a6, 0x0011e0f2, 0x00000001, 0x00004001,
31240 0x00000010, 0x00100e46, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000,
31241 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e
31243 static const D3D_FEATURE_LEVEL feature_level
= D3D_FEATURE_LEVEL_11_0
;
31244 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
31245 static const unsigned int zero
[4] = {0};
31246 static const float standard_pos4
[] =
31248 -2 / 16.0f
, -6 / 16.0f
,
31249 6 / 16.0f
, -2 / 16.0f
,
31250 -6 / 16.0f
, 2 / 16.0f
,
31251 2 / 16.0f
, 6 / 16.0f
,
31254 swapchain_desc
.windowed
= TRUE
;
31255 swapchain_desc
.buffer_count
= 1;
31256 swapchain_desc
.width
= 32;
31257 swapchain_desc
.height
= 32;
31258 swapchain_desc
.swap_effect
= DXGI_SWAP_EFFECT_DISCARD
;
31259 swapchain_desc
.flags
= 0;
31260 if (!init_test_context_ext(&test_context
, &feature_level
, &swapchain_desc
))
31262 device
= test_context
.device
;
31263 context
= test_context
.immediate_context
;
31265 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
31266 texture_desc
.SampleDesc
.Count
= 4;
31267 texture_desc
.SampleDesc
.Quality
= D3D11_STANDARD_MULTISAMPLE_PATTERN
;
31268 texture_desc
.BindFlags
|= D3D11_BIND_SHADER_RESOURCE
;
31269 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
31270 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
31271 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, NULL
, &srv
);
31272 ok(hr
== S_OK
, "Failed to create shader resource view, hr %#x.\n", hr
);
31274 buffer_desc
.ByteWidth
= 1024;
31275 buffer_desc
.Usage
= D3D11_USAGE_DEFAULT
;
31276 buffer_desc
.BindFlags
= D3D11_BIND_UNORDERED_ACCESS
;
31277 buffer_desc
.CPUAccessFlags
= 0;
31278 buffer_desc
.MiscFlags
= D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
;
31279 hr
= ID3D11Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
31280 ok(hr
== S_OK
, "Failed to create buffer, hr %#x.\n", hr
);
31281 uav_desc
.Format
= DXGI_FORMAT_R32_TYPELESS
;
31282 uav_desc
.ViewDimension
= D3D11_UAV_DIMENSION_BUFFER
;
31283 U(uav_desc
).Buffer
.FirstElement
= 0;
31284 U(uav_desc
).Buffer
.NumElements
= 256;
31285 U(uav_desc
).Buffer
.Flags
= D3D11_BUFFER_UAV_FLAG_RAW
;
31286 hr
= ID3D11Device_CreateUnorderedAccessView(device
, (ID3D11Resource
*)buffer
, &uav_desc
, &uav
);
31287 ok(hr
== S_OK
, "Failed to create unordered access view, hr %#x.\n", hr
);
31289 hr
= ID3D11Device_CreatePixelShader(device
, ps_samplepos
, sizeof(ps_samplepos
), NULL
, &ps
);
31290 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
31291 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
31293 ID3D11DeviceContext_ClearUnorderedAccessViewUint(context
, uav
, zero
);
31294 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, white
);
31295 ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context
,
31296 1, &test_context
.backbuffer_rtv
, NULL
, 1, 1, &uav
, NULL
);
31297 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
31298 draw_quad(&test_context
);
31299 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
31300 get_buffer_readback(buffer
, &rb
);
31301 for (i
= 0; i
< ARRAY_SIZE(standard_pos4
); ++i
)
31303 float data
= get_readback_float(&rb
, i
, 0);
31304 /* Wine does not support GetSamplePosition. */
31305 todo_wine
ok(data
== standard_pos4
[i
], "Got sample position %.8e, expected %.8e.\n", data
, standard_pos4
[i
]);
31307 release_resource_readback(&rb
);
31309 ID3D11PixelShader_Release(ps
);
31310 ID3D11Buffer_Release(buffer
);
31311 ID3D11UnorderedAccessView_Release(uav
);
31312 ID3D11ShaderResourceView_Release(srv
);
31313 ID3D11Texture2D_Release(texture
);
31314 release_test_context(&test_context
);
31317 static void test_desktop_window(void)
31319 ID3D11RenderTargetView
*backbuffer_rtv
;
31320 DXGI_SWAP_CHAIN_DESC swapchain_desc
;
31321 ID3D11DeviceContext
*context
;
31322 ID3D11Texture2D
*backbuffer
;
31323 IDXGISwapChain
*swapchain
;
31324 IDXGIDevice
*dxgi_device
;
31325 IDXGIAdapter
*adapter
;
31326 IDXGIFactory
*factory
;
31327 ID3D11Device
*device
;
31331 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 1.0f
};
31333 if (!(device
= create_device(NULL
)))
31335 skip("Failed to create device.\n");
31339 hr
= ID3D11Device_QueryInterface(device
, &IID_IDXGIDevice
, (void **)&dxgi_device
);
31340 ok(SUCCEEDED(hr
), "Failed to get DXGI device, hr %#x.\n", hr
);
31341 hr
= IDXGIDevice_GetAdapter(dxgi_device
, &adapter
);
31342 ok(SUCCEEDED(hr
), "Failed to get adapter, hr %#x.\n", hr
);
31343 IDXGIDevice_Release(dxgi_device
);
31344 hr
= IDXGIAdapter_GetParent(adapter
, &IID_IDXGIFactory
, (void **)&factory
);
31345 ok(SUCCEEDED(hr
), "Failed to get factory, hr %#x.\n", hr
);
31346 IDXGIAdapter_Release(adapter
);
31348 swapchain_desc
.BufferDesc
.Width
= 640;
31349 swapchain_desc
.BufferDesc
.Height
= 480;
31350 swapchain_desc
.BufferDesc
.RefreshRate
.Numerator
= 60;
31351 swapchain_desc
.BufferDesc
.RefreshRate
.Denominator
= 1;
31352 swapchain_desc
.BufferDesc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
31353 swapchain_desc
.BufferDesc
.ScanlineOrdering
= DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED
;
31354 swapchain_desc
.BufferDesc
.Scaling
= DXGI_MODE_SCALING_UNSPECIFIED
;
31355 swapchain_desc
.SampleDesc
.Count
= 1;
31356 swapchain_desc
.SampleDesc
.Quality
= 0;
31357 swapchain_desc
.BufferUsage
= DXGI_USAGE_RENDER_TARGET_OUTPUT
;
31358 swapchain_desc
.BufferCount
= 1;
31359 swapchain_desc
.OutputWindow
= GetDesktopWindow();
31360 swapchain_desc
.Windowed
= TRUE
;
31361 swapchain_desc
.SwapEffect
= DXGI_SWAP_EFFECT_DISCARD
;
31362 swapchain_desc
.Flags
= 0;
31364 hr
= IDXGIFactory_CreateSwapChain(factory
, (IUnknown
*)device
, &swapchain_desc
, &swapchain
);
31365 ok(hr
== S_OK
|| broken(hr
== DXGI_ERROR_INVALID_CALL
) /* Not available on all Windows versions. */,
31366 "Failed to create swapchain, hr %#x.\n", hr
);
31367 IDXGIFactory_Release(factory
);
31370 ID3D11Device_Release(device
);
31374 hr
= IDXGISwapChain_GetBuffer(swapchain
, 0, &IID_ID3D11Texture2D
, (void **)&backbuffer
);
31375 ok(SUCCEEDED(hr
), "Failed to get buffer, hr %#x.\n", hr
);
31377 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)backbuffer
, NULL
, &backbuffer_rtv
);
31378 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
31380 ID3D11Device_GetImmediateContext(device
, &context
);
31382 ID3D11DeviceContext_ClearRenderTargetView(context
, backbuffer_rtv
, red
);
31383 check_texture_color(backbuffer
, 0xff0000ff, 1);
31385 hr
= IDXGISwapChain_Present(swapchain
, 0, 0);
31386 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
31388 ID3D11RenderTargetView_Release(backbuffer_rtv
);
31389 ID3D11Texture2D_Release(backbuffer
);
31390 IDXGISwapChain_Release(swapchain
);
31391 ID3D11DeviceContext_Release(context
);
31392 refcount
= ID3D11Device_Release(device
);
31393 ok(!refcount
, "Device has %u references left.\n", refcount
);
31396 static void test_sample_attached_rtv(void)
31398 ID3D11ShaderResourceView
*srv
, *srv2
, *srv_test
, *srv_ds
;
31399 D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc
, srvds_desc
;
31400 ID3D11Texture2D
*texture
, *texture2
, *dstexture
;
31401 ID3D11RenderTargetView
*rtv
, *rtv2
, *rtvs
[2];
31402 D3D11_DEPTH_STENCIL_VIEW_DESC dsview_desc
;
31403 struct d3d11_test_context test_context
;
31404 D3D11_RENDER_TARGET_VIEW_DESC rtv_desc
;
31405 D3D11_TEXTURE2D_DESC texture_desc
;
31406 D3D_FEATURE_LEVEL feature_level
;
31407 D3D11_SAMPLER_DESC sampler_desc
;
31408 ID3D11DepthStencilView
*dsview
;
31409 ID3D11BlendState
*blend_state
;
31410 ID3D11DeviceContext
*context
;
31411 D3D11_BLEND_DESC blend_desc
;
31412 ID3D11SamplerState
*sampler
;
31413 struct resource_readback rb
;
31414 ID3D11PixelShader
*ps
;
31415 ID3D11Device
*device
;
31422 static const DWORD ps_ld_code
[] =
31429 float4 color0
: SV_Target0
;
31430 float4 color1
: SV_Target1
;
31433 PS_OUTPUT
main(float4 position
: SV_POSITION
)
31438 t
.GetDimensions(0, p
.x
, p
.y
, p
.z
);
31440 p
*= float3(position
.x
/ 640.0f
, position
.y
/ 480.0f
, 1.0f
);
31441 output
.color0
= output
.color1
= t
.Load(int3(p
)) + float4(0.25, 0.25, 0.25, 0.25);
31445 0x43425844, 0x08dd0517, 0x07d7e538, 0x4cad261f, 0xa2ae5942, 0x00000001, 0x00000200, 0x00000003,
31446 0x0000002c, 0x00000060, 0x000000ac, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
31447 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
31448 0x4e47534f, 0x00000044, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003,
31449 0x00000000, 0x0000000f, 0x00000038, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
31450 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x0000014c, 0x00000040, 0x00000053, 0x04001858,
31451 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065,
31452 0x001020f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000001, 0x02000068, 0x00000001, 0x0700003d,
31453 0x001000f2, 0x00000000, 0x00004001, 0x00000000, 0x00107e46, 0x00000000, 0x07000038, 0x00100032,
31454 0x00000000, 0x00100046, 0x00000000, 0x00101046, 0x00000000, 0x0a000038, 0x00100032, 0x00000000,
31455 0x00100046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x08000036,
31456 0x001000c2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0500001b,
31457 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x0700002d, 0x001000f2, 0x00000000, 0x00100e46,
31458 0x00000000, 0x00107e46, 0x00000000, 0x0a000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
31459 0x00004002, 0x3e800000, 0x3e800000, 0x3e800000, 0x3e800000, 0x05000036, 0x001020f2, 0x00000000,
31460 0x00100e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00100e46, 0x00000000, 0x0100003e,
31462 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
31463 static const struct
31465 DXGI_FORMAT texture_format
, dsv_format
, srv_format
;
31467 BOOL srv_bind_allowed
;
31471 {DXGI_FORMAT_R24G8_TYPELESS
, DXGI_FORMAT_D24_UNORM_S8_UINT
, DXGI_FORMAT_R24_UNORM_X8_TYPELESS
,
31473 {DXGI_FORMAT_R24G8_TYPELESS
, DXGI_FORMAT_D24_UNORM_S8_UINT
, DXGI_FORMAT_R24_UNORM_X8_TYPELESS
,
31474 D3D11_DSV_READ_ONLY_DEPTH
, TRUE
},
31475 {DXGI_FORMAT_R24G8_TYPELESS
, DXGI_FORMAT_D24_UNORM_S8_UINT
, DXGI_FORMAT_X24_TYPELESS_G8_UINT
,
31476 D3D11_DSV_READ_ONLY_DEPTH
, FALSE
},
31477 {DXGI_FORMAT_R24G8_TYPELESS
, DXGI_FORMAT_D24_UNORM_S8_UINT
, DXGI_FORMAT_X24_TYPELESS_G8_UINT
,
31478 D3D11_DSV_READ_ONLY_STENCIL
, TRUE
},
31479 {DXGI_FORMAT_R32_TYPELESS
, DXGI_FORMAT_D32_FLOAT
, DXGI_FORMAT_R32_FLOAT
,
31481 {DXGI_FORMAT_R32_TYPELESS
, DXGI_FORMAT_D32_FLOAT
, DXGI_FORMAT_R32_FLOAT
,
31482 D3D11_DSV_READ_ONLY_DEPTH
, TRUE
},
31485 if (!init_test_context(&test_context
, NULL
))
31488 device
= test_context
.device
;
31489 context
= test_context
.immediate_context
;
31491 feature_level
= ID3D11Device_GetFeatureLevel(device
);
31493 texture_desc
.SampleDesc
.Count
= 1;
31494 texture_desc
.SampleDesc
.Quality
= 0;
31495 texture_desc
.Usage
= D3D11_USAGE_DEFAULT
;
31496 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
| D3D11_BIND_RENDER_TARGET
;
31497 texture_desc
.CPUAccessFlags
= 0;
31498 texture_desc
.MiscFlags
= 0;
31500 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
31501 sampler_desc
.AddressU
= D3D11_TEXTURE_ADDRESS_CLAMP
;
31502 sampler_desc
.AddressV
= D3D11_TEXTURE_ADDRESS_CLAMP
;
31503 sampler_desc
.AddressW
= D3D11_TEXTURE_ADDRESS_CLAMP
;
31504 sampler_desc
.MipLODBias
= 0.0f
;
31505 sampler_desc
.MaxAnisotropy
= 0;
31506 sampler_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
31507 sampler_desc
.BorderColor
[0] = 0.0f
;
31508 sampler_desc
.BorderColor
[1] = 0.0f
;
31509 sampler_desc
.BorderColor
[2] = 0.0f
;
31510 sampler_desc
.BorderColor
[3] = 0.0f
;
31511 sampler_desc
.MinLOD
= 0.0f
;
31512 sampler_desc
.MaxLOD
= D3D11_FLOAT32_MAX
;
31514 hr
= ID3D11Device_CreatePixelShader(device
, ps_ld_code
, sizeof(ps_ld_code
), NULL
, &ps
);
31515 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
31517 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
31519 texture_desc
.Width
= 64;
31520 texture_desc
.Height
= 64;
31521 texture_desc
.MipLevels
= 2;
31522 texture_desc
.ArraySize
= 1;
31523 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
31525 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
31526 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
31528 texture_desc
.Width
= 640;
31529 texture_desc
.Height
= 480;
31530 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture2
);
31531 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
31533 sampler_desc
.Filter
= D3D11_FILTER_MIN_MAG_MIP_POINT
;
31534 sampler_desc
.MipLODBias
= 0.0f
;
31535 sampler_desc
.MinLOD
= 0.0f
;
31536 sampler_desc
.MaxLOD
= 0.0f
;
31538 hr
= ID3D11Device_CreateSamplerState(device
, &sampler_desc
, &sampler
);
31539 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
31541 ID3D11DeviceContext_PSSetSamplers(context
, 0, 1, &sampler
);
31543 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
31545 memset(&rtv_desc
, 0, sizeof(rtv_desc
));
31546 rtv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
31547 rtv_desc
.ViewDimension
= D3D11_RTV_DIMENSION_TEXTURE2D
;
31548 U(rtv_desc
).Texture2D
.MipSlice
= 0;
31550 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture2
, &rtv_desc
, &rtv
);
31551 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
31552 U(rtv_desc
).Texture2D
.MipSlice
= 1;
31553 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture2
, &rtv_desc
, &rtv2
);
31554 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
31556 rtvs
[0] = test_context
.backbuffer_rtv
;
31559 ID3D11DeviceContext_OMSetRenderTargets(context
, 2, rtvs
, NULL
);
31561 memset(&srv_desc
, 0, sizeof(srv_desc
));
31562 srv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
31563 srv_desc
.ViewDimension
= D3D11_SRV_DIMENSION_TEXTURE2D
;
31564 U(srv_desc
).Texture2D
.MipLevels
= 1;
31566 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture
, &srv_desc
, &srv
);
31567 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
31568 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
31570 draw_quad(&test_context
);
31572 set_box(&box
, 0, 0, 0, 320, 240, 1);
31573 ID3D11DeviceContext_CopySubresourceRegion(context
, (ID3D11Resource
*)texture2
, 1, 0, 0, 0, (ID3D11Resource
*)texture2
, 0, &box
);
31575 get_texture_readback(texture2
, 0, &rb
);
31576 for (y
= 0; y
< 4; ++y
)
31578 for (x
= 0; x
< 4; ++x
)
31580 color
= get_readback_color(&rb
, 80 + x
* 160, 60 + y
* 120, 0);
31581 ok(compare_color(color
, 0x40404040, 2),
31582 "Got unexpected color 0x%08x at (%u, %u).\n", color
, x
, y
);
31585 release_resource_readback(&rb
);
31586 get_texture_readback(texture2
, 1, &rb
);
31587 for (y
= 0; y
< 4; ++y
)
31589 for (x
= 0; x
< 4; ++x
)
31591 color
= get_readback_color(&rb
, 40 + x
* 80, 30 + y
* 60, 0);
31592 ok(compare_color(color
, 0x40404040, 2),
31593 "Got unexpected color 0x%08x at (%u, %u).\n", color
, x
, y
);
31596 release_resource_readback(&rb
);
31598 ID3D11ShaderResourceView_Release(srv
);
31599 ID3D11DeviceContext_OMSetRenderTargets(context
, 2, rtvs
, NULL
);
31601 ID3D11DeviceContext_ClearRenderTargetView(context
, rtv
, red
);
31603 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture2
, &srv_desc
, &srv
);
31604 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
31606 U(srv_desc
).Texture2D
.MostDetailedMip
= 1;
31607 U(srv_desc
).Texture2D
.MipLevels
= 1;
31608 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)texture2
, &srv_desc
, &srv2
);
31609 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
31611 memset(&blend_desc
, 0, sizeof(blend_desc
));
31612 blend_desc
.IndependentBlendEnable
= TRUE
;
31613 blend_desc
.RenderTarget
[0].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_ALL
;
31614 blend_desc
.RenderTarget
[1].RenderTargetWriteMask
= 0;
31615 hr
= ID3D11Device_CreateBlendState(device
, &blend_desc
, &blend_state
);
31616 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
31617 ID3D11DeviceContext_OMSetBlendState(context
, blend_state
, NULL
, D3D11_DEFAULT_SAMPLE_MASK
);
31618 ID3D11BlendState_Release(blend_state
);
31620 /* SRV does not get bound if resource is attached as render target, even if write mask is 0. */
31621 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
31622 ID3D11DeviceContext_PSGetShaderResources(context
, 0, 1, &srv_test
);
31623 ok(!srv_test
, "Unexpected SRV %p.\n", srv_test
);
31625 blend_desc
.RenderTarget
[1].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_ALL
;
31626 hr
= ID3D11Device_CreateBlendState(device
, &blend_desc
, &blend_state
);
31627 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
31628 ID3D11DeviceContext_OMSetBlendState(context
, blend_state
, NULL
, D3D11_DEFAULT_SAMPLE_MASK
);
31629 ID3D11BlendState_Release(blend_state
);
31631 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, red
);
31633 draw_quad(&test_context
);
31634 draw_quad(&test_context
);
31636 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
31637 for (y
= 0; y
< 4; ++y
)
31639 for (x
= 0; x
< 4; ++x
)
31641 color
= get_readback_color(&rb
, 80 + x
* 160, 60 + y
* 120, 0);
31642 ok(compare_color(color
, 0x40404040, 2),
31643 "Got unexpected color 0x%08x at (%u, %u).\n", color
, x
, y
);
31646 release_resource_readback(&rb
);
31648 get_texture_readback(texture2
, 0, &rb
);
31649 for (y
= 0; y
< 4; ++y
)
31651 for (x
= 0; x
< 4; ++x
)
31653 color
= get_readback_color(&rb
, 80 + x
* 160, 60 + y
* 120, 0);
31654 ok(compare_color(color
, 0x40404040, 2),
31655 "Got unexpected color 0x%08x at (%u, %u).\n", color
, x
, y
);
31658 release_resource_readback(&rb
);
31660 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, &test_context
.backbuffer_rtv
, NULL
);
31661 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv
);
31662 ID3D11DeviceContext_PSGetShaderResources(context
, 0, 1, &srv_test
);
31663 ok(!!srv_test
, "Unexpected SRV %p.\n", srv_test
);
31664 ID3D11ShaderResourceView_Release(srv_test
);
31666 draw_quad(&test_context
);
31667 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
31668 for (y
= 0; y
< 4; ++y
)
31670 for (x
= 0; x
< 4; ++x
)
31672 color
= get_readback_color(&rb
, 80 + x
* 160, 60 + y
* 120, 0);
31673 ok(compare_color(color
, 0x80808080, 2),
31674 "Got unexpected color 0x%08x at (%u, %u).\n", color
, x
, y
);
31677 release_resource_readback(&rb
);
31679 ID3D11DeviceContext_OMSetRenderTargets(context
, 2, rtvs
, NULL
);
31681 /* SRV is reset when the same resource is set as render target. */
31682 ID3D11DeviceContext_PSGetShaderResources(context
, 0, 1, &srv_test
);
31683 ok(!srv_test
, "Unexpected SRV %p.\n", srv_test
);
31685 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv2
);
31686 ID3D11DeviceContext_OMSetRenderTargets(context
, 2, rtvs
, NULL
);
31687 ID3D11DeviceContext_PSGetShaderResources(context
, 0, 1, &srv_test
);
31688 ok(!!srv_test
, "Unexpected SRV %p.\n", srv_test
);
31689 ID3D11ShaderResourceView_Release(srv_test
);
31691 draw_quad(&test_context
);
31692 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
31693 for (y
= 0; y
< 4; ++y
)
31695 for (x
= 0; x
< 4; ++x
)
31697 color
= get_readback_color(&rb
, 80 + x
* 160, 60 + y
* 120, 0);
31698 ok(compare_color(color
, 0x80808080, 2),
31699 "Got unexpected color 0x%08x at (%u, %u).\n", color
, x
, y
);
31702 release_resource_readback(&rb
);
31704 texture_desc
.BindFlags
= D3D11_BIND_SHADER_RESOURCE
| D3D11_BIND_DEPTH_STENCIL
;
31705 memset(&dsview_desc
, 0, sizeof(dsview_desc
));
31706 dsview_desc
.ViewDimension
= D3D11_DSV_DIMENSION_TEXTURE2D
;
31708 memset(&srvds_desc
, 0, sizeof(srvds_desc
));
31709 srvds_desc
.ViewDimension
= D3D11_SRV_DIMENSION_TEXTURE2D
;
31710 U(srvds_desc
).Texture2D
.MipLevels
= 1;
31712 for (i
= 0; i
< ARRAY_SIZE(ds_tests
); ++i
)
31714 if (ds_tests
[i
].dsv_flags
&& feature_level
< D3D_FEATURE_LEVEL_11_0
)
31716 static unsigned int skip_once
;
31719 skip("Read only depths or stencils are not supported.\n");
31724 texture_desc
.Format
= ds_tests
[i
].texture_format
;
31725 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &dstexture
);
31726 ok(hr
== S_OK
, "Test %u, got unexpected hr %#x.\n", i
, hr
);
31727 dsview_desc
.Format
= ds_tests
[i
].dsv_format
;
31728 dsview_desc
.Flags
= ds_tests
[i
].dsv_flags
;
31729 hr
= ID3D11Device_CreateDepthStencilView(device
, (ID3D11Resource
*)dstexture
, &dsview_desc
, &dsview
);
31730 ok(hr
== S_OK
, "Test %u, got unexpected hr %#x.\n", i
, hr
);
31732 srvds_desc
.Format
= ds_tests
[i
].srv_format
;
31733 hr
= ID3D11Device_CreateShaderResourceView(device
, (ID3D11Resource
*)dstexture
, &srvds_desc
, &srv_ds
);
31734 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
31736 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, rtvs
, NULL
);
31737 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv_ds
);
31738 ID3D11DeviceContext_PSGetShaderResources(context
, 0, 1, &srv_test
);
31739 ok(!!srv_test
, "Test %u, unexpected SRV %p.\n", i
, srv_test
);
31740 ID3D11ShaderResourceView_Release(srv_test
);
31742 ID3D11DeviceContext_OMSetRenderTargets(context
, 1, rtvs
, dsview
);
31743 ID3D11DeviceContext_PSGetShaderResources(context
, 0, 1, &srv_test
);
31744 ok(!!srv_test
== ds_tests
[i
].srv_bind_allowed
, "Test %u, unexpected SRV %p.\n", i
, srv_test
);
31746 ID3D11ShaderResourceView_Release(srv_test
);
31748 ID3D11DeviceContext_PSSetShaderResources(context
, 0, 1, &srv_ds
);
31749 ID3D11DeviceContext_PSGetShaderResources(context
, 0, 1, &srv_test
);
31750 ok(!!srv_test
== ds_tests
[i
].srv_bind_allowed
, "Test %u, unexpected SRV %p.\n", i
, srv_test
);
31752 ID3D11ShaderResourceView_Release(srv_test
);
31754 ID3D11Texture2D_Release(dstexture
);
31755 ID3D11DepthStencilView_Release(dsview
);
31756 ID3D11ShaderResourceView_Release(srv_ds
);
31759 ID3D11DeviceContext_OMSetRenderTargets(context
, 2, rtvs
, NULL
);
31761 ID3D11RenderTargetView_Release(rtv2
);
31762 ID3D11RenderTargetView_Release(rtv
);
31763 ID3D11ShaderResourceView_Release(srv2
);
31764 ID3D11ShaderResourceView_Release(srv
);
31765 ID3D11SamplerState_Release(sampler
);
31766 ID3D11PixelShader_Release(ps
);
31767 ID3D11Texture2D_Release(texture2
);
31768 ID3D11Texture2D_Release(texture
);
31769 ID3D11SamplerState_Release(sampler
);
31771 release_test_context(&test_context
);
31774 static void test_color_mask(void)
31776 struct d3d11_test_context test_context
;
31777 D3D11_TEXTURE2D_DESC texture_desc
;
31778 ID3D11RenderTargetView
*rtvs
[8];
31779 ID3D11BlendState
*blend_state
;
31780 ID3D11DeviceContext
*context
;
31781 struct resource_readback rb
;
31782 D3D11_BLEND_DESC blend_desc
;
31783 ID3D11Texture2D
*rts
[8];
31784 ID3D11PixelShader
*ps
;
31785 ID3D11Device
*device
;
31790 static const DWORD expected_colors
[] =
31791 {0xff000080, 0xff0080ff, 0xff8000ff, 0x80808080, 0x800000ff, 0xff008080, 0x800080ff, 0xff0000ff};
31793 static const DWORD ps_code
[] =
31796 void main(float4 position
: SV_Position
,
31797 out float4 t0
: SV_Target0
, out float4 t1
: SV_Target1
,
31798 out float4 t2
: SV_Target2
, out float4 t3
: SV_Target3
,
31799 out float4 t4
: SV_Target4
, out float4 t5
: SV_Target5
,
31800 out float4 t6
: SV_Target6
, out float4 t7
: SV_Target7
)
31802 t0
= t1
= t2
= t3
= t4
= t5
= t6
= t7
= float4(0.5f
, 0.5f
, 0.5f
, 0.5f
);
31805 0x43425844, 0x7b1ab233, 0xdbe32d3b, 0x77084cc5, 0xe874d2b5, 0x00000001, 0x000002b0, 0x00000003,
31806 0x0000002c, 0x00000060, 0x0000013c, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
31807 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69,
31808 0x4e47534f, 0x000000d4, 0x00000008, 0x00000008, 0x000000c8, 0x00000000, 0x00000000, 0x00000003,
31809 0x00000000, 0x0000000f, 0x000000c8, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
31810 0x000000c8, 0x00000002, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x000000c8, 0x00000003,
31811 0x00000000, 0x00000003, 0x00000003, 0x0000000f, 0x000000c8, 0x00000004, 0x00000000, 0x00000003,
31812 0x00000004, 0x0000000f, 0x000000c8, 0x00000005, 0x00000000, 0x00000003, 0x00000005, 0x0000000f,
31813 0x000000c8, 0x00000006, 0x00000000, 0x00000003, 0x00000006, 0x0000000f, 0x000000c8, 0x00000007,
31814 0x00000000, 0x00000003, 0x00000007, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853,
31815 0x0000016c, 0x00000040, 0x0000005b, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x001020f2,
31816 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000003, 0x03000065,
31817 0x001020f2, 0x00000004, 0x03000065, 0x001020f2, 0x00000005, 0x03000065, 0x001020f2, 0x00000006,
31818 0x03000065, 0x001020f2, 0x00000007, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f000000,
31819 0x3f000000, 0x3f000000, 0x3f000000, 0x08000036, 0x001020f2, 0x00000001, 0x00004002, 0x3f000000,
31820 0x3f000000, 0x3f000000, 0x3f000000, 0x08000036, 0x001020f2, 0x00000002, 0x00004002, 0x3f000000,
31821 0x3f000000, 0x3f000000, 0x3f000000, 0x08000036, 0x001020f2, 0x00000003, 0x00004002, 0x3f000000,
31822 0x3f000000, 0x3f000000, 0x3f000000, 0x08000036, 0x001020f2, 0x00000004, 0x00004002, 0x3f000000,
31823 0x3f000000, 0x3f000000, 0x3f000000, 0x08000036, 0x001020f2, 0x00000005, 0x00004002, 0x3f000000,
31824 0x3f000000, 0x3f000000, 0x3f000000, 0x08000036, 0x001020f2, 0x00000006, 0x00004002, 0x3f000000,
31825 0x3f000000, 0x3f000000, 0x3f000000, 0x08000036, 0x001020f2, 0x00000007, 0x00004002, 0x3f000000,
31826 0x3f000000, 0x3f000000, 0x3f000000, 0x0100003e,
31829 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 1.0f
};
31831 if (!init_test_context(&test_context
, NULL
))
31834 device
= test_context
.device
;
31835 context
= test_context
.immediate_context
;
31837 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
31838 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
31839 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
31841 memset(&blend_desc
, 0, sizeof(blend_desc
));
31842 blend_desc
.IndependentBlendEnable
= TRUE
;
31843 blend_desc
.RenderTarget
[0].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_RED
;
31844 blend_desc
.RenderTarget
[1].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_GREEN
;
31845 blend_desc
.RenderTarget
[2].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_BLUE
;
31846 blend_desc
.RenderTarget
[3].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_ALL
;
31847 blend_desc
.RenderTarget
[4].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_ALPHA
;
31848 blend_desc
.RenderTarget
[5].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_RED
| D3D11_COLOR_WRITE_ENABLE_GREEN
;
31849 blend_desc
.RenderTarget
[6].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_GREEN
| D3D11_COLOR_WRITE_ENABLE_ALPHA
;
31850 blend_desc
.RenderTarget
[7].RenderTargetWriteMask
= 0;
31852 hr
= ID3D11Device_CreateBlendState(device
, &blend_desc
, &blend_state
);
31853 ok(hr
== S_OK
, "Failed to create blend state, hr %#x.\n", hr
);
31854 ID3D11DeviceContext_OMSetBlendState(context
, blend_state
, NULL
, D3D11_DEFAULT_SAMPLE_MASK
);
31855 ID3D11BlendState_Release(blend_state
);
31857 for (i
= 0; i
< 8; ++i
)
31859 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
31860 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rts
[i
]);
31861 ok(hr
== S_OK
, "Failed to create texture %u, hr %#x.\n", i
, hr
);
31863 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rts
[i
], NULL
, &rtvs
[i
]);
31864 ok(hr
== S_OK
, "Failed to create rendertarget view %u, hr %#x.\n", i
, hr
);
31867 ID3D11DeviceContext_OMSetRenderTargets(context
, 8, rtvs
, NULL
);
31869 for (i
= 0; i
< 8; ++i
)
31870 ID3D11DeviceContext_ClearRenderTargetView(context
, rtvs
[i
], red
);
31871 draw_quad(&test_context
);
31873 for (i
= 0; i
< 8; ++i
)
31875 get_texture_readback(rts
[i
], 0, &rb
);
31876 color
= get_readback_color(&rb
, 320, 240, 0);
31877 ok(compare_color(color
, expected_colors
[i
], 1), "%u: Got unexpected color 0x%08x.\n", i
, color
);
31878 release_resource_readback(&rb
);
31881 blend_desc
.IndependentBlendEnable
= FALSE
;
31882 hr
= ID3D11Device_CreateBlendState(device
, &blend_desc
, &blend_state
);
31883 ok(hr
== S_OK
, "Failed to create blend state, hr %#x.\n", hr
);
31884 ID3D11DeviceContext_OMSetBlendState(context
, blend_state
, NULL
, D3D11_DEFAULT_SAMPLE_MASK
);
31885 ID3D11BlendState_Release(blend_state
);
31887 for (i
= 0; i
< 8; ++i
)
31888 ID3D11DeviceContext_ClearRenderTargetView(context
, rtvs
[i
], red
);
31889 draw_quad(&test_context
);
31891 for (i
= 0; i
< 8; ++i
)
31893 get_texture_readback(rts
[i
], 0, &rb
);
31894 color
= get_readback_color(&rb
, 320, 240, 0);
31895 ok(compare_color(color
, expected_colors
[0], 1), "%u: Got unexpected color 0x%08x.\n", i
, color
);
31896 release_resource_readback(&rb
);
31898 ID3D11Texture2D_Release(rts
[i
]);
31899 ID3D11RenderTargetView_Release(rtvs
[i
]);
31902 ID3D11PixelShader_Release(ps
);
31903 release_test_context(&test_context
);
31906 static void test_independent_blend(void)
31908 struct d3d11_test_context test_context
;
31909 D3D11_TEXTURE2D_DESC texture_desc
;
31910 ID3D11RenderTargetView
*rtvs
[8];
31911 ID3D11BlendState
*blend_state
;
31912 ID3D11DeviceContext
*context
;
31913 struct resource_readback rb
;
31914 ID3D11Texture2D
*rts
[8];
31915 ID3D11PixelShader
*ps
;
31916 ID3D11Device
*device
;
31921 static const DWORD ps_code
[] =
31924 void main(float4 position
: SV_Position
,
31925 out float4 t0
: SV_Target0
, out float4 t1
: SV_Target1
,
31926 out float4 t2
: SV_Target2
, out float4 t3
: SV_Target3
,
31927 out float4 t4
: SV_Target4
, out float4 t5
: SV_Target5
,
31928 out float4 t6
: SV_Target6
, out float4 t7
: SV_Target7
)
31930 t0
= t1
= t2
= t3
= t4
= t5
= t6
= t7
= float4(0.1f
, 0.2f
, 0.3f
, 0.4f
);
31933 0x43425844, 0xb3dca7dc, 0x4a31f0f1, 0x747569cb, 0xae7af5ce, 0x00000001, 0x000002b0, 0x00000003,
31934 0x0000002c, 0x00000060, 0x0000013c, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
31935 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69,
31936 0x4e47534f, 0x000000d4, 0x00000008, 0x00000008, 0x000000c8, 0x00000000, 0x00000000, 0x00000003,
31937 0x00000000, 0x0000000f, 0x000000c8, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
31938 0x000000c8, 0x00000002, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x000000c8, 0x00000003,
31939 0x00000000, 0x00000003, 0x00000003, 0x0000000f, 0x000000c8, 0x00000004, 0x00000000, 0x00000003,
31940 0x00000004, 0x0000000f, 0x000000c8, 0x00000005, 0x00000000, 0x00000003, 0x00000005, 0x0000000f,
31941 0x000000c8, 0x00000006, 0x00000000, 0x00000003, 0x00000006, 0x0000000f, 0x000000c8, 0x00000007,
31942 0x00000000, 0x00000003, 0x00000007, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853,
31943 0x0000016c, 0x00000040, 0x0000005b, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x001020f2,
31944 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000003, 0x03000065,
31945 0x001020f2, 0x00000004, 0x03000065, 0x001020f2, 0x00000005, 0x03000065, 0x001020f2, 0x00000006,
31946 0x03000065, 0x001020f2, 0x00000007, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3dcccccd,
31947 0x3e4ccccd, 0x3e99999a, 0x3ecccccd, 0x08000036, 0x001020f2, 0x00000001, 0x00004002, 0x3dcccccd,
31948 0x3e4ccccd, 0x3e99999a, 0x3ecccccd, 0x08000036, 0x001020f2, 0x00000002, 0x00004002, 0x3dcccccd,
31949 0x3e4ccccd, 0x3e99999a, 0x3ecccccd, 0x08000036, 0x001020f2, 0x00000003, 0x00004002, 0x3dcccccd,
31950 0x3e4ccccd, 0x3e99999a, 0x3ecccccd, 0x08000036, 0x001020f2, 0x00000004, 0x00004002, 0x3dcccccd,
31951 0x3e4ccccd, 0x3e99999a, 0x3ecccccd, 0x08000036, 0x001020f2, 0x00000005, 0x00004002, 0x3dcccccd,
31952 0x3e4ccccd, 0x3e99999a, 0x3ecccccd, 0x08000036, 0x001020f2, 0x00000006, 0x00004002, 0x3dcccccd,
31953 0x3e4ccccd, 0x3e99999a, 0x3ecccccd, 0x08000036, 0x001020f2, 0x00000007, 0x00004002, 0x3dcccccd,
31954 0x3e4ccccd, 0x3e99999a, 0x3ecccccd, 0x0100003e,
31957 D3D11_BLEND_DESC blend_desc
=
31959 .IndependentBlendEnable
= TRUE
,
31962 {TRUE
, D3D11_BLEND_SRC_ALPHA
, D3D11_BLEND_DEST_ALPHA
, D3D11_BLEND_OP_ADD
,
31963 D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
},
31964 {TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ZERO
, D3D11_BLEND_OP_ADD
,
31965 D3D11_BLEND_ZERO
, D3D11_BLEND_ONE
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
},
31966 {TRUE
, D3D11_BLEND_SRC_COLOR
, D3D11_BLEND_DEST_COLOR
, D3D11_BLEND_OP_ADD
,
31967 D3D11_BLEND_SRC_ALPHA
, D3D11_BLEND_DEST_ALPHA
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
},
31968 {TRUE
, D3D11_BLEND_ONE
, D3D11_BLEND_ONE
, D3D11_BLEND_OP_MIN
,
31969 D3D11_BLEND_ONE
, D3D11_BLEND_ONE
, D3D11_BLEND_OP_MIN
, D3D11_COLOR_WRITE_ENABLE_ALL
},
31970 {TRUE
, D3D11_BLEND_BLEND_FACTOR
, D3D11_BLEND_BLEND_FACTOR
, D3D11_BLEND_OP_ADD
,
31971 D3D11_BLEND_ZERO
, D3D11_BLEND_ONE
, D3D11_BLEND_OP_ADD
, D3D11_COLOR_WRITE_ENABLE_ALL
},
31972 {TRUE
, D3D11_BLEND_INV_SRC_ALPHA
, D3D11_BLEND_INV_BLEND_FACTOR
, D3D11_BLEND_OP_SUBTRACT
,
31973 D3D11_BLEND_ONE
, D3D11_BLEND_ONE
, D3D11_BLEND_OP_REV_SUBTRACT
, D3D11_COLOR_WRITE_ENABLE_ALL
},
31974 {FALSE
, 0, 0, 0, 0, 0, 0, D3D11_COLOR_WRITE_ENABLE_ALL
},
31975 {TRUE
, D3D11_BLEND_DEST_COLOR
, D3D11_BLEND_SRC_COLOR
, D3D11_BLEND_OP_ADD
,
31976 D3D11_BLEND_INV_SRC_ALPHA
, D3D11_BLEND_INV_DEST_ALPHA
, D3D11_BLEND_OP_SUBTRACT
,
31977 D3D11_COLOR_WRITE_ENABLE_ALL
},
31981 static const DWORD expected_colors
[] =
31982 {0x66426e1c, 0xb34c3319, 0xa6214a05, 0x66333319, 0xb34c4829, 0x4d19000a, 0x664c3319, 0x081f3305};
31984 static const float clear_color
[] = {0.1f
, 0.5f
, 0.2f
, 0.7f
};
31985 static const float blend_factor
[] = {0.8f
, 0.4f
, 0.6f
, 0.2f
};
31987 if (!init_test_context(&test_context
, NULL
))
31990 device
= test_context
.device
;
31991 context
= test_context
.immediate_context
;
31993 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
31994 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
31995 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
31997 hr
= ID3D11Device_CreateBlendState(device
, &blend_desc
, &blend_state
);
31998 ok(hr
== S_OK
, "Failed to create blend state, hr %#x.\n", hr
);
31999 ID3D11DeviceContext_OMSetBlendState(context
, blend_state
, blend_factor
, D3D11_DEFAULT_SAMPLE_MASK
);
32000 ID3D11BlendState_Release(blend_state
);
32002 for (i
= 0; i
< 8; ++i
)
32004 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
32005 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rts
[i
]);
32006 ok(hr
== S_OK
, "Failed to create texture %u, hr %#x.\n", i
, hr
);
32008 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)rts
[i
], NULL
, &rtvs
[i
]);
32009 ok(hr
== S_OK
, "Failed to create rendertarget view %u, hr %#x.\n", i
, hr
);
32012 ID3D11DeviceContext_OMSetRenderTargets(context
, 8, rtvs
, NULL
);
32014 for (i
= 0; i
< 8; ++i
)
32015 ID3D11DeviceContext_ClearRenderTargetView(context
, rtvs
[i
], clear_color
);
32016 draw_quad(&test_context
);
32018 for (i
= 0; i
< 8; ++i
)
32020 get_texture_readback(rts
[i
], 0, &rb
);
32021 color
= get_readback_color(&rb
, 320, 240, 0);
32022 ok(compare_color(color
, expected_colors
[i
], 1), "%u: Got unexpected color 0x%08x.\n", i
, color
);
32023 release_resource_readback(&rb
);
32026 blend_desc
.IndependentBlendEnable
= FALSE
;
32027 hr
= ID3D11Device_CreateBlendState(device
, &blend_desc
, &blend_state
);
32028 ok(hr
== S_OK
, "Failed to create blend state, hr %#x.\n", hr
);
32029 ID3D11DeviceContext_OMSetBlendState(context
, blend_state
, blend_factor
, D3D11_DEFAULT_SAMPLE_MASK
);
32030 ID3D11BlendState_Release(blend_state
);
32032 for (i
= 0; i
< 8; ++i
)
32033 ID3D11DeviceContext_ClearRenderTargetView(context
, rtvs
[i
], clear_color
);
32034 draw_quad(&test_context
);
32036 for (i
= 0; i
< 8; ++i
)
32038 get_texture_readback(rts
[i
], 0, &rb
);
32039 color
= get_readback_color(&rb
, 320, 240, 0);
32040 ok(compare_color(color
, expected_colors
[0], 1), "%u: Got unexpected color 0x%08x.\n", i
, color
);
32041 release_resource_readback(&rb
);
32043 ID3D11Texture2D_Release(rts
[i
]);
32044 ID3D11RenderTargetView_Release(rtvs
[i
]);
32047 ID3D11PixelShader_Release(ps
);
32048 release_test_context(&test_context
);
32051 static void test_dual_source_blend(void)
32053 struct d3d11_test_context test_context
;
32054 ID3D11BlendState
*blend_state
;
32055 ID3D11DeviceContext
*context
;
32056 ID3D11PixelShader
*ps
;
32057 ID3D11Device
*device
;
32061 static const DWORD ps_code
[] =
32064 void main(float4 position
: SV_Position
,
32065 out float4 t0
: SV_Target0
, out float4 t1
: SV_Target1
)
32067 t0
= float4(0.5, 0.5, 0.0, 1.0);
32068 t1
= float4(0.0, 0.5, 0.5, 0.0);
32071 0x43425844, 0x87120d01, 0xa0014738, 0x3a32d86c, 0x9d757441, 0x00000001, 0x00000118, 0x00000003,
32072 0x0000002c, 0x00000060, 0x000000ac, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
32073 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69,
32074 0x4e47534f, 0x00000044, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003,
32075 0x00000000, 0x0000000f, 0x00000038, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
32076 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000064, 0x00000040, 0x00000019, 0x03000065,
32077 0x001020f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000001, 0x08000036, 0x001020f2, 0x00000000,
32078 0x00004002, 0x3f000000, 0x3f000000, 0x00000000, 0x3f000000, 0x08000036, 0x001020f2, 0x00000001,
32079 0x00004002, 0x00000000, 0x3f000000, 0x3f000000, 0x00000000, 0x0100003e
32082 static const D3D11_BLEND_DESC blend_desc
=
32084 .RenderTarget
[0].BlendEnable
= TRUE
,
32085 .RenderTarget
[0].SrcBlend
= D3D11_BLEND_SRC1_COLOR
,
32086 .RenderTarget
[0].DestBlend
= D3D11_BLEND_SRC1_COLOR
,
32087 .RenderTarget
[0].BlendOp
= D3D11_BLEND_OP_ADD
,
32088 .RenderTarget
[0].SrcBlendAlpha
= D3D11_BLEND_ONE
,
32089 .RenderTarget
[0].DestBlendAlpha
= D3D11_BLEND_ZERO
,
32090 .RenderTarget
[0].BlendOpAlpha
= D3D11_BLEND_OP_ADD
,
32091 .RenderTarget
[0].RenderTargetWriteMask
= D3D11_COLOR_WRITE_ENABLE_ALL
,
32094 static const float clear_color
[] = {0.7f
, 0.0f
, 1.0f
, 1.0f
};
32096 if (!init_test_context(&test_context
, NULL
))
32099 device
= test_context
.device
;
32100 context
= test_context
.immediate_context
;
32102 hr
= ID3D11Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), NULL
, &ps
);
32103 ok(hr
== S_OK
, "Failed to create pixel shader, hr %#x.\n", hr
);
32104 ID3D11DeviceContext_PSSetShader(context
, ps
, NULL
, 0);
32106 hr
= ID3D11Device_CreateBlendState(device
, &blend_desc
, &blend_state
);
32107 ok(hr
== S_OK
, "Failed to create blend state, hr %#x.\n", hr
);
32108 ID3D11DeviceContext_OMSetBlendState(context
, blend_state
, NULL
, D3D11_DEFAULT_SAMPLE_MASK
);
32109 ID3D11BlendState_Release(blend_state
);
32111 ID3D11DeviceContext_ClearRenderTargetView(context
, test_context
.backbuffer_rtv
, clear_color
);
32112 draw_quad(&test_context
);
32114 color
= get_texture_color(test_context
.backbuffer
, 320, 240);
32115 ok(compare_color(color
, 0x80804000, 1), "Got unexpected color 0x%08x.\n", color
);
32117 ID3D11PixelShader_Release(ps
);
32118 release_test_context(&test_context
);
32121 static void test_deferred_context_state(void)
32123 ID3D11Buffer
*green_buffer
, *blue_buffer
, *ret_buffer
;
32124 ID3D11DeviceContext
*immediate
, *deferred
;
32125 struct d3d11_test_context test_context
;
32126 ID3D11CommandList
*list1
, *list2
;
32127 ID3D11Device
*device
;
32130 static const float green
[] = {0.0f
, 1.0f
, 0.0f
, 1.0f
};
32131 static const float blue
[] = {0.0f
, 0.0f
, 1.0f
, 1.0f
};
32133 if (!init_test_context(&test_context
, NULL
))
32136 device
= test_context
.device
;
32137 immediate
= test_context
.immediate_context
;
32139 green_buffer
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(green
), &green
);
32140 blue_buffer
= create_buffer(device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(blue
), &blue
);
32141 ID3D11DeviceContext_PSSetConstantBuffers(immediate
, 0, 1, &green_buffer
);
32143 hr
= ID3D11Device_CreateDeferredContext(device
, 0, &deferred
);
32144 todo_wine
ok(hr
== S_OK
, "Failed to create deferred context, hr %#x.\n", hr
);
32147 ID3D11Buffer_Release(blue_buffer
);
32148 ID3D11Buffer_Release(green_buffer
);
32149 release_test_context(&test_context
);
32153 ID3D11DeviceContext_PSGetConstantBuffers(deferred
, 0, 1, &ret_buffer
);
32154 ok(!ret_buffer
, "Got unexpected buffer %p.\n", ret_buffer
);
32156 ID3D11DeviceContext_PSSetConstantBuffers(deferred
, 0, 1, &blue_buffer
);
32158 ID3D11DeviceContext_PSGetConstantBuffers(deferred
, 0, 1, &ret_buffer
);
32159 ok(ret_buffer
== blue_buffer
, "Got unexpected buffer %p.\n", ret_buffer
);
32160 ID3D11Buffer_Release(ret_buffer
);
32162 hr
= ID3D11DeviceContext_FinishCommandList(deferred
, TRUE
, &list1
);
32163 ok(hr
== S_OK
, "Failed to create command list, hr %#x.\n", hr
);
32165 ID3D11DeviceContext_PSGetConstantBuffers(deferred
, 0, 1, &ret_buffer
);
32166 ok(ret_buffer
== blue_buffer
, "Got unexpected buffer %p.\n", ret_buffer
);
32167 ID3D11Buffer_Release(ret_buffer
);
32169 hr
= ID3D11DeviceContext_FinishCommandList(deferred
, FALSE
, &list2
);
32170 ok(hr
== S_OK
, "Failed to create command list, hr %#x.\n", hr
);
32172 ID3D11DeviceContext_PSGetConstantBuffers(deferred
, 0, 1, &ret_buffer
);
32173 ok(!ret_buffer
, "Got unexpected buffer %p.\n", ret_buffer
);
32175 ID3D11DeviceContext_PSSetConstantBuffers(immediate
, 0, 1, &green_buffer
);
32176 ID3D11DeviceContext_ExecuteCommandList(immediate
, list1
, TRUE
);
32177 ID3D11DeviceContext_PSGetConstantBuffers(immediate
, 0, 1, &ret_buffer
);
32178 ok(ret_buffer
== green_buffer
, "Got unexpected buffer %p.\n", ret_buffer
);
32179 ID3D11Buffer_Release(ret_buffer
);
32181 ID3D11DeviceContext_PSSetConstantBuffers(immediate
, 0, 1, &green_buffer
);
32182 ID3D11DeviceContext_ExecuteCommandList(immediate
, list1
, FALSE
);
32183 ID3D11DeviceContext_PSGetConstantBuffers(immediate
, 0, 1, &ret_buffer
);
32184 ok(!ret_buffer
, "Got unexpected buffer %p.\n", ret_buffer
);
32186 ID3D11CommandList_Release(list2
);
32187 ID3D11CommandList_Release(list1
);
32188 ID3D11DeviceContext_Release(deferred
);
32189 ID3D11Buffer_Release(blue_buffer
);
32190 ID3D11Buffer_Release(green_buffer
);
32191 release_test_context(&test_context
);
32194 static void test_deferred_context_swap_state(void)
32196 ID3D11DeviceContext1
*immediate
, *deferred
;
32197 ID3DDeviceContextState
*state
, *prev_state
;
32198 ID3D11Buffer
*green_buffer
, *ret_buffer
;
32199 struct d3d11_test_context test_context
;
32200 D3D_FEATURE_LEVEL feature_level
;
32201 ID3D11Device1
*device
;
32204 static const float green
[] = {0.0f
, 1.0f
, 0.0f
, 1.0f
};
32206 if (!init_test_context(&test_context
, NULL
))
32209 if (FAILED(ID3D11Device_QueryInterface(test_context
.device
, &IID_ID3D11Device1
, (void **)&device
)))
32211 skip("ID3D11Device1 is not available.\n");
32212 release_test_context(&test_context
);
32216 ID3D11Device1_GetImmediateContext1(device
, &immediate
);
32218 green_buffer
= create_buffer(test_context
.device
, D3D11_BIND_CONSTANT_BUFFER
, sizeof(green
), &green
);
32219 ID3D11DeviceContext1_PSSetConstantBuffers(immediate
, 0, 1, &green_buffer
);
32221 hr
= ID3D11Device1_CreateDeferredContext1(device
, 0, &deferred
);
32222 todo_wine
ok(hr
== S_OK
, "Failed to create deferred context, hr %#x.\n", hr
);
32226 feature_level
= ID3D11Device1_GetFeatureLevel(device
);
32227 hr
= ID3D11Device1_CreateDeviceContextState(device
, 0, &feature_level
, 1, D3D11_SDK_VERSION
,
32228 &IID_ID3D11Device1
, NULL
, &state
);
32229 ok(hr
== S_OK
, "Failed to create device context state, hr %#x.\n", hr
);
32231 prev_state
= (void *)0xdeadbeef;
32232 ID3D11DeviceContext1_SwapDeviceContextState(deferred
, NULL
, &prev_state
);
32233 ok(!prev_state
, "Got state %p.\n", prev_state
);
32235 prev_state
= (void *)0xdeadbeef;
32236 ID3D11DeviceContext1_SwapDeviceContextState(deferred
, state
, &prev_state
);
32237 ok(!prev_state
, "Got state %p.\n", prev_state
);
32239 ID3D11DeviceContext1_PSGetConstantBuffers(deferred
, 0, 1, &ret_buffer
);
32240 ok(!ret_buffer
, "Got unexpected buffer %p.\n", ret_buffer
);
32242 ID3DDeviceContextState_Release(state
);
32243 ID3D11DeviceContext1_Release(deferred
);
32246 ID3D11Buffer_Release(green_buffer
);
32247 ID3D11DeviceContext1_Release(immediate
);
32248 ID3D11Device1_Release(device
);
32249 release_test_context(&test_context
);
32252 static void test_deferred_context_rendering(void)
32254 ID3D11DeviceContext
*immediate
, *deferred
;
32255 struct d3d11_test_context test_context
;
32256 D3D11_TEXTURE2D_DESC texture_desc
;
32257 ID3D11CommandList
*list1
, *list2
;
32258 ID3D11RenderTargetView
*rtv
;
32259 ID3D11Texture2D
*texture
;
32260 ID3D11Device
*device
;
32264 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
32265 static const float green
[] = {0.0f
, 1.0f
, 0.0f
, 1.0f
};
32266 static const float blue
[] = {0.0f
, 0.0f
, 1.0f
, 1.0f
};
32268 if (!init_test_context(&test_context
, NULL
))
32271 device
= test_context
.device
;
32272 immediate
= test_context
.immediate_context
;
32274 ID3D11DeviceContext_ClearRenderTargetView(immediate
, test_context
.backbuffer_rtv
, white
);
32276 hr
= ID3D11Device_CreateDeferredContext(device
, 0, &deferred
);
32277 todo_wine
ok(hr
== S_OK
, "Failed to create deferred context, hr %#x.\n", hr
);
32280 release_test_context(&test_context
);
32284 ID3D11DeviceContext_ClearRenderTargetView(deferred
, test_context
.backbuffer_rtv
, green
);
32286 hr
= ID3D11DeviceContext_FinishCommandList(deferred
, TRUE
, &list1
);
32287 ok(hr
== S_OK
, "Failed to create command list, hr %#x.\n", hr
);
32289 hr
= ID3D11DeviceContext_FinishCommandList(deferred
, TRUE
, &list2
);
32290 ok(hr
== S_OK
, "Failed to create command list, hr %#x.\n", hr
);
32292 color
= get_texture_color(test_context
.backbuffer
, 320, 240);
32293 ok(color
== 0xffffffff, "Got unexpected color %#08x.\n", color
);
32295 ID3D11DeviceContext_ExecuteCommandList(immediate
, list1
, TRUE
);
32296 color
= get_texture_color(test_context
.backbuffer
, 320, 240);
32297 ok(color
== 0xff00ff00, "Got unexpected color %#08x.\n", color
);
32299 ID3D11DeviceContext_ClearRenderTargetView(immediate
, test_context
.backbuffer_rtv
, white
);
32300 ID3D11DeviceContext_ExecuteCommandList(immediate
, list1
, TRUE
);
32301 color
= get_texture_color(test_context
.backbuffer
, 320, 240);
32302 ok(color
== 0xff00ff00, "Got unexpected color %#08x.\n", color
);
32304 ID3D11DeviceContext_ClearRenderTargetView(immediate
, test_context
.backbuffer_rtv
, white
);
32305 ID3D11DeviceContext_ExecuteCommandList(immediate
, list2
, TRUE
);
32306 color
= get_texture_color(test_context
.backbuffer
, 320, 240);
32307 ok(color
== 0xffffffff, "Got unexpected color %#08x.\n", color
);
32309 ID3D11CommandList_Release(list2
);
32311 ID3D11DeviceContext_ExecuteCommandList(deferred
, list1
, TRUE
);
32312 hr
= ID3D11DeviceContext_FinishCommandList(deferred
, TRUE
, &list2
);
32313 ok(hr
== S_OK
, "Failed to create command list, hr %#x.\n", hr
);
32315 ID3D11DeviceContext_ClearRenderTargetView(immediate
, test_context
.backbuffer_rtv
, white
);
32316 ID3D11DeviceContext_ExecuteCommandList(immediate
, list2
, TRUE
);
32317 color
= get_texture_color(test_context
.backbuffer
, 320, 240);
32318 ok(color
== 0xff00ff00, "Got unexpected color %#08x.\n", color
);
32320 ID3D11CommandList_Release(list2
);
32321 ID3D11CommandList_Release(list1
);
32322 ID3D11DeviceContext_Release(deferred
);
32324 ID3D11Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
32325 hr
= ID3D11Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
32326 ok(hr
== S_OK
, "Failed to create texture, hr %#x.\n", hr
);
32327 hr
= ID3D11Device_CreateRenderTargetView(device
, (ID3D11Resource
*)texture
, NULL
, &rtv
);
32328 ok(hr
== S_OK
, "Failed to create view, hr %#x.\n", hr
);
32330 ID3D11DeviceContext_ClearRenderTargetView(immediate
, test_context
.backbuffer_rtv
, white
);
32331 ID3D11DeviceContext_ClearRenderTargetView(immediate
, rtv
, green
);
32333 hr
= ID3D11Device_CreateDeferredContext(device
, 0, &deferred
);
32334 ok(hr
== S_OK
, "Failed to create deferred context, hr %#x.\n", hr
);
32336 ID3D11DeviceContext_CopyResource(deferred
, (ID3D11Resource
*)test_context
.backbuffer
, (ID3D11Resource
*)texture
);
32338 hr
= ID3D11DeviceContext_FinishCommandList(deferred
, TRUE
, &list1
);
32339 ok(hr
== S_OK
, "Failed to create command list, hr %#x.\n", hr
);
32341 ID3D11DeviceContext_ClearRenderTargetView(immediate
, rtv
, blue
);
32342 ID3D11DeviceContext_ExecuteCommandList(immediate
, list1
, TRUE
);
32343 color
= get_texture_color(test_context
.backbuffer
, 320, 240);
32344 ok(color
== 0xffff0000, "Got unexpected color %#08x.\n", color
);
32346 ID3D11CommandList_Release(list1
);
32347 ID3D11DeviceContext_Release(deferred
);
32349 ID3D11RenderTargetView_Release(rtv
);
32350 ID3D11Texture2D_Release(texture
);
32351 release_test_context(&test_context
);
32356 unsigned int argc
, i
;
32359 use_mt
= !getenv("WINETEST_NO_MT_D3D");
32361 argc
= winetest_get_mainargs(&argv
);
32362 for (i
= 2; i
< argc
; ++i
)
32364 if (!strcmp(argv
[i
], "--validate"))
32365 enable_debug_layer
= TRUE
;
32366 else if (!strcmp(argv
[i
], "--warp"))
32367 use_warp_adapter
= TRUE
;
32368 else if (!strcmp(argv
[i
], "--adapter") && i
+ 1 < argc
)
32369 use_adapter_idx
= atoi(argv
[++i
]);
32370 else if (!strcmp(argv
[i
], "--single"))
32374 print_adapter_info();
32376 queue_test(test_create_device
);
32377 queue_for_each_feature_level(test_device_interfaces
);
32378 queue_test(test_immediate_context
);
32379 queue_test(test_create_deferred_context
);
32380 queue_test(test_create_texture1d
);
32381 queue_test(test_texture1d_interfaces
);
32382 queue_test(test_create_texture2d
);
32383 queue_test(test_texture2d_interfaces
);
32384 queue_test(test_create_texture3d
);
32385 queue_test(test_texture3d_interfaces
);
32386 queue_test(test_create_buffer
);
32387 queue_test(test_create_depthstencil_view
);
32388 queue_test(test_depthstencil_view_interfaces
);
32389 queue_test(test_create_rendertarget_view
);
32390 queue_test(test_create_shader_resource_view
);
32391 queue_for_each_feature_level(test_create_shader
);
32392 queue_test(test_create_sampler_state
);
32393 queue_test(test_create_blend_state
);
32394 queue_test(test_create_depthstencil_state
);
32395 queue_test(test_create_rasterizer_state
);
32396 queue_test(test_create_query
);
32397 queue_test(test_occlusion_query
);
32398 queue_test(test_pipeline_statistics_query
);
32399 queue_test(test_timestamp_query
);
32400 queue_test(test_so_statistics_query
);
32401 queue_test(test_device_removed_reason
);
32402 queue_test(test_private_data
);
32403 queue_for_each_feature_level(test_state_refcounting
);
32404 queue_test(test_device_context_state
);
32405 queue_test(test_blend
);
32406 queue_test(test_texture1d
);
32407 queue_test(test_texture
);
32408 queue_test(test_cube_maps
);
32409 queue_test(test_depth_stencil_sampling
);
32410 queue_test(test_sample_c_lz
);
32411 queue_test(test_multiple_render_targets
);
32412 queue_test(test_render_target_views
);
32413 queue_test(test_layered_rendering
);
32414 queue_test(test_scissor
);
32415 queue_test(test_clear_state
);
32416 queue_test(test_il_append_aligned
);
32417 queue_test(test_instanced_draw
);
32418 queue_test(test_vertex_id
);
32419 queue_test(test_fragment_coords
);
32420 queue_test(test_initial_texture_data
);
32421 queue_test(test_update_subresource
);
32422 queue_test(test_copy_subresource_region
);
32423 queue_test(test_copy_subresource_region_1d
);
32424 queue_test(test_copy_subresource_region_3d
);
32425 queue_test(test_resource_map
);
32426 queue_for_each_feature_level(test_resource_access
);
32427 queue_test(test_check_multisample_quality_levels
);
32428 queue_for_each_feature_level(test_swapchain_formats
);
32429 queue_test(test_swapchain_views
);
32430 queue_test(test_swapchain_flip
);
32431 queue_test(test_clear_render_target_view_1d
);
32432 queue_test(test_clear_render_target_view_2d
);
32433 queue_test(test_clear_render_target_view_3d
);
32434 queue_test(test_clear_depth_stencil_view
);
32435 queue_test(test_clear_buffer_unordered_access_view
);
32436 queue_test(test_initial_depth_stencil_state
);
32437 queue_test(test_draw_depth_only
);
32438 queue_test(test_draw_uav_only
);
32439 queue_test(test_cb_relative_addressing
);
32440 queue_test(test_vs_input_relative_addressing
);
32441 queue_test(test_getdc
);
32442 queue_test(test_shader_stage_input_output_matching
);
32443 queue_test(test_shader_interstage_interface
);
32444 queue_test(test_sm4_if_instruction
);
32445 queue_test(test_sm4_breakc_instruction
);
32446 queue_test(test_sm4_continuec_instruction
);
32447 queue_test(test_sm4_discard_instruction
);
32448 queue_test(test_sm5_swapc_instruction
);
32449 queue_test(test_create_input_layout
);
32450 queue_test(test_input_layout_alignment
);
32451 queue_test(test_input_assembler
);
32452 queue_test(test_null_sampler
);
32453 queue_test(test_check_feature_support
);
32454 queue_test(test_create_unordered_access_view
);
32455 queue_test(test_immediate_constant_buffer
);
32456 queue_test(test_fp_specials
);
32457 queue_test(test_uint_shader_instructions
);
32458 queue_test(test_index_buffer_offset
);
32459 queue_test(test_face_culling
);
32460 queue_test(test_line_antialiasing_blending
);
32461 queue_for_each_feature_level(test_format_support
);
32462 queue_for_each_9_x_feature_level(test_fl9_draw
);
32463 queue_test(test_ddy
);
32464 queue_test(test_shader_input_registers_limits
);
32465 queue_test(test_unbind_shader_resource_view
);
32466 queue_test(test_stencil_separate
);
32467 queue_test(test_uav_load
);
32468 queue_test(test_cs_uav_store
);
32469 queue_test(test_uav_store_immediate_constant
);
32470 queue_test(test_ps_cs_uav_binding
);
32471 queue_test(test_atomic_instructions
);
32472 queue_test(test_sm4_ret_instruction
);
32473 queue_test(test_primitive_restart
);
32474 queue_test(test_resinfo_instruction
);
32475 queue_test(test_sm5_bufinfo_instruction
);
32476 queue_test(test_sampleinfo_instruction
);
32477 queue_test(test_render_target_device_mismatch
);
32478 queue_test(test_buffer_srv
);
32479 queue_for_each_feature_level_in_range(D3D_FEATURE_LEVEL_10_0
, D3D_FEATURE_LEVEL_11_0
,
32480 test_unaligned_raw_buffer_access
);
32481 queue_test(test_uav_counters
);
32482 queue_test(test_dispatch_indirect
);
32483 queue_test(test_compute_shader_registers
);
32484 queue_test(test_tgsm
);
32485 queue_test(test_geometry_shader
);
32486 queue_test(test_quad_tessellation
);
32487 queue_test(test_stream_output
);
32488 queue_test(test_fl10_stream_output_desc
);
32489 queue_test(test_stream_output_resume
);
32490 queue_test(test_stream_output_components
);
32491 queue_test(test_stream_output_vs
);
32492 queue_test(test_gather
);
32493 queue_test(test_gather_c
);
32494 queue_test(test_depth_bias
);
32495 queue_test(test_fractional_viewports
);
32496 queue_for_each_feature_level_in_range(D3D_FEATURE_LEVEL_10_0
, D3D_FEATURE_LEVEL_11_0
, test_negative_viewports
);
32497 queue_test(test_early_depth_stencil
);
32498 queue_test(test_conservative_depth_output
);
32499 queue_test(test_format_compatibility
);
32500 queue_for_each_feature_level_in_range(D3D_FEATURE_LEVEL_10_0
, D3D_FEATURE_LEVEL_11_0
,
32501 test_compressed_format_compatibility
);
32502 queue_test(test_clip_distance
);
32503 queue_test(test_combined_clip_and_cull_distances
);
32504 queue_test(test_generate_mips
);
32505 queue_test(test_alpha_to_coverage
);
32506 queue_test(test_unbound_multisample_texture
);
32507 queue_test(test_multiple_viewports
);
32508 queue_test(test_multisample_resolve
);
32509 queue_test(test_sample_shading
);
32510 queue_test(test_sample_mask
);
32511 queue_test(test_depth_clip
);
32512 queue_test(test_staging_buffers
);
32513 queue_test(test_render_a8
);
32514 queue_test(test_standard_pattern
);
32515 queue_test(test_desktop_window
);
32516 queue_test(test_sample_attached_rtv
);
32517 queue_test(test_color_mask
);
32518 queue_test(test_independent_blend
);
32519 queue_test(test_dual_source_blend
);
32520 queue_test(test_deferred_context_state
);
32521 queue_test(test_deferred_context_swap_state
);
32522 queue_test(test_deferred_context_rendering
);
32524 run_queued_tests();