2 * Copyright 2008 Henri Verbeet for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/test.h"
43 unsigned int x
, y
, z
, w
;
46 static void set_box(D3D10_BOX
*box
, UINT left
, UINT top
, UINT front
, UINT right
, UINT bottom
, UINT back
)
56 static ULONG
get_refcount(IUnknown
*iface
)
58 IUnknown_AddRef(iface
);
59 return IUnknown_Release(iface
);
62 static BOOL
compare_float(float f
, float g
, unsigned int ulps
)
72 if (abs(x
- y
) > ulps
)
78 static BOOL
compare_vec4(const struct vec4
*v1
, const struct vec4
*v2
, unsigned int ulps
)
80 return compare_float(v1
->x
, v2
->x
, ulps
)
81 && compare_float(v1
->y
, v2
->y
, ulps
)
82 && compare_float(v1
->z
, v2
->z
, ulps
)
83 && compare_float(v1
->w
, v2
->w
, ulps
);
86 static BOOL
compare_uvec4(const struct uvec4
* v1
, const struct uvec4
*v2
)
88 return v1
->x
== v2
->x
&& v1
->y
== v2
->y
&& v1
->z
== v2
->z
&& v1
->w
== v2
->w
;
91 static BOOL
compare_color(DWORD c1
, DWORD c2
, BYTE max_diff
)
93 if (abs((int)(c1
& 0xff) - (int)(c2
& 0xff)) > max_diff
)
96 if (abs((int)(c1
& 0xff) - (int)(c2
& 0xff)) > max_diff
)
99 if (abs((int)(c1
& 0xff) - (int)(c2
& 0xff)) > max_diff
)
102 if (abs((int)(c1
& 0xff) - (int)(c2
& 0xff)) > max_diff
)
110 D3D10_SRV_DIMENSION dimension
;
111 unsigned int miplevel_idx
;
112 unsigned int miplevel_count
;
113 unsigned int layer_idx
;
114 unsigned int layer_count
;
117 static void get_srv_desc(D3D10_SHADER_RESOURCE_VIEW_DESC
*d3d10_desc
, const struct srv_desc
*desc
)
119 d3d10_desc
->Format
= desc
->format
;
120 d3d10_desc
->ViewDimension
= desc
->dimension
;
121 if (desc
->dimension
== D3D10_SRV_DIMENSION_TEXTURE1D
)
123 U(*d3d10_desc
).Texture1D
.MostDetailedMip
= desc
->miplevel_idx
;
124 U(*d3d10_desc
).Texture1D
.MipLevels
= desc
->miplevel_count
;
126 else if (desc
->dimension
== D3D10_SRV_DIMENSION_TEXTURE1DARRAY
)
128 U(*d3d10_desc
).Texture1DArray
.MostDetailedMip
= desc
->miplevel_idx
;
129 U(*d3d10_desc
).Texture1DArray
.MipLevels
= desc
->miplevel_count
;
130 U(*d3d10_desc
).Texture1DArray
.FirstArraySlice
= desc
->layer_idx
;
131 U(*d3d10_desc
).Texture1DArray
.ArraySize
= desc
->layer_count
;
133 else if (desc
->dimension
== D3D10_SRV_DIMENSION_TEXTURE2D
)
135 U(*d3d10_desc
).Texture2D
.MostDetailedMip
= desc
->miplevel_idx
;
136 U(*d3d10_desc
).Texture2D
.MipLevels
= desc
->miplevel_count
;
138 else if (desc
->dimension
== D3D10_SRV_DIMENSION_TEXTURE2DARRAY
)
140 U(*d3d10_desc
).Texture2DArray
.MostDetailedMip
= desc
->miplevel_idx
;
141 U(*d3d10_desc
).Texture2DArray
.MipLevels
= desc
->miplevel_count
;
142 U(*d3d10_desc
).Texture2DArray
.FirstArraySlice
= desc
->layer_idx
;
143 U(*d3d10_desc
).Texture2DArray
.ArraySize
= desc
->layer_count
;
145 else if (desc
->dimension
== D3D10_SRV_DIMENSION_TEXTURE2DMSARRAY
)
147 U(*d3d10_desc
).Texture2DMSArray
.FirstArraySlice
= desc
->layer_idx
;
148 U(*d3d10_desc
).Texture2DMSArray
.ArraySize
= desc
->layer_count
;
150 else if (desc
->dimension
== D3D10_SRV_DIMENSION_TEXTURE3D
)
152 U(*d3d10_desc
).Texture3D
.MostDetailedMip
= desc
->miplevel_idx
;
153 U(*d3d10_desc
).Texture3D
.MipLevels
= desc
->miplevel_count
;
155 else if (desc
->dimension
== D3D10_SRV_DIMENSION_TEXTURECUBE
)
157 U(*d3d10_desc
).TextureCube
.MostDetailedMip
= desc
->miplevel_idx
;
158 U(*d3d10_desc
).TextureCube
.MipLevels
= desc
->miplevel_count
;
160 else if (desc
->dimension
!= D3D10_SRV_DIMENSION_UNKNOWN
161 && desc
->dimension
!= D3D10_SRV_DIMENSION_TEXTURE2DMS
)
163 trace("Unhandled view dimension %#x.\n", desc
->dimension
);
167 #define check_srv_desc(a, b) check_srv_desc_(__LINE__, a, b)
168 static void check_srv_desc_(unsigned int line
, const D3D10_SHADER_RESOURCE_VIEW_DESC
*desc
,
169 const struct srv_desc
*expected_desc
)
171 ok_(__FILE__
, line
)(desc
->Format
== expected_desc
->format
,
172 "Got format %#x, expected %#x.\n", desc
->Format
, expected_desc
->format
);
173 ok_(__FILE__
, line
)(desc
->ViewDimension
== expected_desc
->dimension
,
174 "Got view dimension %#x, expected %#x.\n", desc
->ViewDimension
, expected_desc
->dimension
);
176 if (desc
->ViewDimension
!= expected_desc
->dimension
)
179 if (desc
->ViewDimension
== D3D10_SRV_DIMENSION_TEXTURE2D
)
181 ok_(__FILE__
, line
)(U(*desc
).Texture2D
.MostDetailedMip
== expected_desc
->miplevel_idx
,
182 "Got MostDetailedMip %u, expected %u.\n",
183 U(*desc
).Texture2D
.MostDetailedMip
, expected_desc
->miplevel_idx
);
184 ok_(__FILE__
, line
)(U(*desc
).Texture2D
.MipLevels
== expected_desc
->miplevel_count
,
185 "Got MipLevels %u, expected %u.\n",
186 U(*desc
).Texture2D
.MipLevels
, expected_desc
->miplevel_count
);
188 else if (desc
->ViewDimension
== D3D10_SRV_DIMENSION_TEXTURE2DARRAY
)
190 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.MostDetailedMip
== expected_desc
->miplevel_idx
,
191 "Got MostDetailedMip %u, expected %u.\n",
192 U(*desc
).Texture2DArray
.MostDetailedMip
, expected_desc
->miplevel_idx
);
193 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.MipLevels
== expected_desc
->miplevel_count
,
194 "Got MipLevels %u, expected %u.\n",
195 U(*desc
).Texture2DArray
.MipLevels
, expected_desc
->miplevel_count
);
196 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.FirstArraySlice
== expected_desc
->layer_idx
,
197 "Got FirstArraySlice %u, expected %u.\n",
198 U(*desc
).Texture2DArray
.FirstArraySlice
, expected_desc
->layer_idx
);
199 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.ArraySize
== expected_desc
->layer_count
,
200 "Got ArraySize %u, expected %u.\n",
201 U(*desc
).Texture2DArray
.ArraySize
, expected_desc
->layer_count
);
203 else if (desc
->ViewDimension
== D3D10_SRV_DIMENSION_TEXTURE2DMSARRAY
)
205 ok_(__FILE__
, line
)(U(*desc
).Texture2DMSArray
.FirstArraySlice
== expected_desc
->layer_idx
,
206 "Got FirstArraySlice %u, expected %u.\n",
207 U(*desc
).Texture2DMSArray
.FirstArraySlice
, expected_desc
->layer_idx
);
208 ok_(__FILE__
, line
)(U(*desc
).Texture2DMSArray
.ArraySize
== expected_desc
->layer_count
,
209 "Got ArraySize %u, expected %u.\n",
210 U(*desc
).Texture2DMSArray
.ArraySize
, expected_desc
->layer_count
);
212 else if (desc
->ViewDimension
== D3D10_SRV_DIMENSION_TEXTURE3D
)
214 ok_(__FILE__
, line
)(U(*desc
).Texture3D
.MostDetailedMip
== expected_desc
->miplevel_idx
,
215 "Got MostDetailedMip %u, expected %u.\n",
216 U(*desc
).Texture3D
.MostDetailedMip
, expected_desc
->miplevel_idx
);
217 ok_(__FILE__
, line
)(U(*desc
).Texture3D
.MipLevels
== expected_desc
->miplevel_count
,
218 "Got MipLevels %u, expected %u.\n",
219 U(*desc
).Texture3D
.MipLevels
, expected_desc
->miplevel_count
);
221 else if (desc
->ViewDimension
== D3D10_SRV_DIMENSION_TEXTURECUBE
)
223 ok_(__FILE__
, line
)(U(*desc
).TextureCube
.MostDetailedMip
== expected_desc
->miplevel_idx
,
224 "Got MostDetailedMip %u, expected %u.\n",
225 U(*desc
).TextureCube
.MostDetailedMip
, expected_desc
->miplevel_idx
);
226 ok_(__FILE__
, line
)(U(*desc
).TextureCube
.MipLevels
== expected_desc
->miplevel_count
,
227 "Got MipLevels %u, expected %u.\n",
228 U(*desc
).TextureCube
.MipLevels
, expected_desc
->miplevel_count
);
230 else if (desc
->ViewDimension
!= D3D10_SRV_DIMENSION_TEXTURE2DMS
)
232 trace("Unhandled view dimension %#x.\n", desc
->ViewDimension
);
239 D3D10_RTV_DIMENSION dimension
;
240 unsigned int miplevel_idx
;
241 unsigned int layer_idx
;
242 unsigned int layer_count
;
245 static void get_rtv_desc(D3D10_RENDER_TARGET_VIEW_DESC
*d3d10_desc
, const struct rtv_desc
*desc
)
247 d3d10_desc
->Format
= desc
->format
;
248 d3d10_desc
->ViewDimension
= desc
->dimension
;
249 if (desc
->dimension
== D3D10_RTV_DIMENSION_TEXTURE1D
)
251 U(*d3d10_desc
).Texture1D
.MipSlice
= desc
->miplevel_idx
;
253 else if (desc
->dimension
== D3D10_RTV_DIMENSION_TEXTURE1DARRAY
)
255 U(*d3d10_desc
).Texture1DArray
.MipSlice
= desc
->miplevel_idx
;
256 U(*d3d10_desc
).Texture1DArray
.FirstArraySlice
= desc
->layer_idx
;
257 U(*d3d10_desc
).Texture1DArray
.ArraySize
= desc
->layer_count
;
259 else if (desc
->dimension
== D3D10_RTV_DIMENSION_TEXTURE2D
)
261 U(*d3d10_desc
).Texture2D
.MipSlice
= desc
->miplevel_idx
;
263 else if (desc
->dimension
== D3D10_RTV_DIMENSION_TEXTURE2DARRAY
)
265 U(*d3d10_desc
).Texture2DArray
.MipSlice
= desc
->miplevel_idx
;
266 U(*d3d10_desc
).Texture2DArray
.FirstArraySlice
= desc
->layer_idx
;
267 U(*d3d10_desc
).Texture2DArray
.ArraySize
= desc
->layer_count
;
269 else if (desc
->dimension
== D3D10_RTV_DIMENSION_TEXTURE2DMSARRAY
)
271 U(*d3d10_desc
).Texture2DMSArray
.FirstArraySlice
= desc
->layer_idx
;
272 U(*d3d10_desc
).Texture2DMSArray
.ArraySize
= desc
->layer_count
;
274 else if (desc
->dimension
== D3D10_RTV_DIMENSION_TEXTURE3D
)
276 U(*d3d10_desc
).Texture3D
.MipSlice
= desc
->miplevel_idx
;
277 U(*d3d10_desc
).Texture3D
.FirstWSlice
= desc
->layer_idx
;
278 U(*d3d10_desc
).Texture3D
.WSize
= desc
->layer_count
;
280 else if (desc
->dimension
!= D3D10_RTV_DIMENSION_UNKNOWN
281 && desc
->dimension
!= D3D10_RTV_DIMENSION_TEXTURE2DMS
)
283 trace("Unhandled view dimension %#x.\n", desc
->dimension
);
287 #define check_rtv_desc(a, b) check_rtv_desc_(__LINE__, a, b)
288 static void check_rtv_desc_(unsigned int line
, const D3D10_RENDER_TARGET_VIEW_DESC
*desc
,
289 const struct rtv_desc
*expected_desc
)
291 ok_(__FILE__
, line
)(desc
->Format
== expected_desc
->format
,
292 "Got format %#x, expected %#x.\n", desc
->Format
, expected_desc
->format
);
293 ok_(__FILE__
, line
)(desc
->ViewDimension
== expected_desc
->dimension
,
294 "Got view dimension %#x, expected %#x.\n", desc
->ViewDimension
, expected_desc
->dimension
);
296 if (desc
->ViewDimension
!= expected_desc
->dimension
)
299 if (desc
->ViewDimension
== D3D10_RTV_DIMENSION_TEXTURE2D
)
301 ok_(__FILE__
, line
)(U(*desc
).Texture2D
.MipSlice
== expected_desc
->miplevel_idx
,
302 "Got MipSlice %u, expected %u.\n",
303 U(*desc
).Texture2D
.MipSlice
, expected_desc
->miplevel_idx
);
305 else if (desc
->ViewDimension
== D3D10_RTV_DIMENSION_TEXTURE2DARRAY
)
307 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.MipSlice
== expected_desc
->miplevel_idx
,
308 "Got MipSlice %u, expected %u.\n",
309 U(*desc
).Texture2DArray
.MipSlice
, expected_desc
->miplevel_idx
);
310 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.FirstArraySlice
== expected_desc
->layer_idx
,
311 "Got FirstArraySlice %u, expected %u.\n",
312 U(*desc
).Texture2DArray
.FirstArraySlice
, expected_desc
->layer_idx
);
313 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.ArraySize
== expected_desc
->layer_count
,
314 "Got ArraySize %u, expected %u.\n",
315 U(*desc
).Texture2DArray
.ArraySize
, expected_desc
->layer_count
);
317 else if (desc
->ViewDimension
== D3D10_RTV_DIMENSION_TEXTURE2DMSARRAY
)
319 ok_(__FILE__
, line
)(U(*desc
).Texture2DMSArray
.FirstArraySlice
== expected_desc
->layer_idx
,
320 "Got FirstArraySlice %u, expected %u.\n",
321 U(*desc
).Texture2DMSArray
.FirstArraySlice
, expected_desc
->layer_idx
);
322 ok_(__FILE__
, line
)(U(*desc
).Texture2DMSArray
.ArraySize
== expected_desc
->layer_count
,
323 "Got ArraySize %u, expected %u.\n",
324 U(*desc
).Texture2DMSArray
.ArraySize
, expected_desc
->layer_count
);
326 else if (desc
->ViewDimension
== D3D10_RTV_DIMENSION_TEXTURE3D
)
328 ok_(__FILE__
, line
)(U(*desc
).Texture3D
.MipSlice
== expected_desc
->miplevel_idx
,
329 "Got MipSlice %u, expected %u.\n",
330 U(*desc
).Texture3D
.MipSlice
, expected_desc
->miplevel_idx
);
331 ok_(__FILE__
, line
)(U(*desc
).Texture3D
.FirstWSlice
== expected_desc
->layer_idx
,
332 "Got FirstWSlice %u, expected %u.\n",
333 U(*desc
).Texture3D
.FirstWSlice
, expected_desc
->layer_idx
);
334 ok_(__FILE__
, line
)(U(*desc
).Texture3D
.WSize
== expected_desc
->layer_count
,
335 "Got WSize %u, expected %u.\n",
336 U(*desc
).Texture3D
.WSize
, expected_desc
->layer_count
);
338 else if (desc
->ViewDimension
!= D3D10_RTV_DIMENSION_TEXTURE2DMS
)
340 trace("Unhandled view dimension %#x.\n", desc
->ViewDimension
);
347 D3D10_DSV_DIMENSION dimension
;
348 unsigned int miplevel_idx
;
349 unsigned int layer_idx
;
350 unsigned int layer_count
;
353 static void get_dsv_desc(D3D10_DEPTH_STENCIL_VIEW_DESC
*d3d10_desc
, const struct dsv_desc
*desc
)
355 d3d10_desc
->Format
= desc
->format
;
356 d3d10_desc
->ViewDimension
= desc
->dimension
;
357 if (desc
->dimension
== D3D10_DSV_DIMENSION_TEXTURE1D
)
359 U(*d3d10_desc
).Texture1D
.MipSlice
= desc
->miplevel_idx
;
361 else if (desc
->dimension
== D3D10_DSV_DIMENSION_TEXTURE1DARRAY
)
363 U(*d3d10_desc
).Texture1DArray
.MipSlice
= desc
->miplevel_idx
;
364 U(*d3d10_desc
).Texture1DArray
.FirstArraySlice
= desc
->layer_idx
;
365 U(*d3d10_desc
).Texture1DArray
.ArraySize
= desc
->layer_count
;
367 else if (desc
->dimension
== D3D10_DSV_DIMENSION_TEXTURE2D
)
369 U(*d3d10_desc
).Texture2D
.MipSlice
= desc
->miplevel_idx
;
371 else if (desc
->dimension
== D3D10_DSV_DIMENSION_TEXTURE2DARRAY
)
373 U(*d3d10_desc
).Texture2DArray
.MipSlice
= desc
->miplevel_idx
;
374 U(*d3d10_desc
).Texture2DArray
.FirstArraySlice
= desc
->layer_idx
;
375 U(*d3d10_desc
).Texture2DArray
.ArraySize
= desc
->layer_count
;
377 else if (desc
->dimension
== D3D10_DSV_DIMENSION_TEXTURE2DMSARRAY
)
379 U(*d3d10_desc
).Texture2DMSArray
.FirstArraySlice
= desc
->layer_idx
;
380 U(*d3d10_desc
).Texture2DMSArray
.ArraySize
= desc
->layer_count
;
382 else if (desc
->dimension
!= D3D10_DSV_DIMENSION_UNKNOWN
383 && desc
->dimension
!= D3D10_DSV_DIMENSION_TEXTURE2DMS
)
385 trace("Unhandled view dimension %#x.\n", desc
->dimension
);
389 #define check_dsv_desc(a, b) check_dsv_desc_(__LINE__, a, b)
390 static void check_dsv_desc_(unsigned int line
, const D3D10_DEPTH_STENCIL_VIEW_DESC
*desc
,
391 const struct dsv_desc
*expected_desc
)
393 ok_(__FILE__
, line
)(desc
->Format
== expected_desc
->format
,
394 "Got format %#x, expected %#x.\n", desc
->Format
, expected_desc
->format
);
395 ok_(__FILE__
, line
)(desc
->ViewDimension
== expected_desc
->dimension
,
396 "Got view dimension %#x, expected %#x.\n", desc
->ViewDimension
, expected_desc
->dimension
);
398 if (desc
->ViewDimension
!= expected_desc
->dimension
)
401 if (desc
->ViewDimension
== D3D10_DSV_DIMENSION_TEXTURE2D
)
403 ok_(__FILE__
, line
)(U(*desc
).Texture2D
.MipSlice
== expected_desc
->miplevel_idx
,
404 "Got MipSlice %u, expected %u.\n",
405 U(*desc
).Texture2D
.MipSlice
, expected_desc
->miplevel_idx
);
407 else if (desc
->ViewDimension
== D3D10_DSV_DIMENSION_TEXTURE2DARRAY
)
409 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.MipSlice
== expected_desc
->miplevel_idx
,
410 "Got MipSlice %u, expected %u.\n",
411 U(*desc
).Texture2DArray
.MipSlice
, expected_desc
->miplevel_idx
);
412 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.FirstArraySlice
== expected_desc
->layer_idx
,
413 "Got FirstArraySlice %u, expected %u.\n",
414 U(*desc
).Texture2DArray
.FirstArraySlice
, expected_desc
->layer_idx
);
415 ok_(__FILE__
, line
)(U(*desc
).Texture2DArray
.ArraySize
== expected_desc
->layer_count
,
416 "Got ArraySize %u, expected %u.\n",
417 U(*desc
).Texture2DArray
.ArraySize
, expected_desc
->layer_count
);
419 else if (desc
->ViewDimension
== D3D10_DSV_DIMENSION_TEXTURE2DMSARRAY
)
421 ok_(__FILE__
, line
)(U(*desc
).Texture2DMSArray
.FirstArraySlice
== expected_desc
->layer_idx
,
422 "Got FirstArraySlice %u, expected %u.\n",
423 U(*desc
).Texture2DMSArray
.FirstArraySlice
, expected_desc
->layer_idx
);
424 ok_(__FILE__
, line
)(U(*desc
).Texture2DMSArray
.ArraySize
== expected_desc
->layer_count
,
425 "Got ArraySize %u, expected %u.\n",
426 U(*desc
).Texture2DMSArray
.ArraySize
, expected_desc
->layer_count
);
428 else if (desc
->ViewDimension
!= D3D10_DSV_DIMENSION_TEXTURE2DMS
)
430 trace("Unhandled view dimension %#x.\n", desc
->ViewDimension
);
434 #define create_buffer(a, b, c, d) create_buffer_(__LINE__, a, b, c, d)
435 static ID3D10Buffer
*create_buffer_(unsigned int line
, ID3D10Device
*device
,
436 unsigned int bind_flags
, unsigned int size
, const void *data
)
438 D3D10_SUBRESOURCE_DATA resource_data
;
439 D3D10_BUFFER_DESC buffer_desc
;
440 ID3D10Buffer
*buffer
;
443 buffer_desc
.ByteWidth
= size
;
444 buffer_desc
.Usage
= D3D10_USAGE_DEFAULT
;
445 buffer_desc
.BindFlags
= bind_flags
;
446 buffer_desc
.CPUAccessFlags
= 0;
447 buffer_desc
.MiscFlags
= 0;
449 resource_data
.pSysMem
= data
;
450 resource_data
.SysMemPitch
= 0;
451 resource_data
.SysMemSlicePitch
= 0;
453 hr
= ID3D10Device_CreateBuffer(device
, &buffer_desc
, data
? &resource_data
: NULL
, &buffer
);
454 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to create buffer, hr %#x.\n", hr
);
458 struct texture_readback
460 ID3D10Texture2D
*texture
;
461 D3D10_MAPPED_TEXTURE2D mapped_texture
;
462 unsigned int width
, height
, sub_resource_idx
;
465 static void get_texture_readback(ID3D10Texture2D
*texture
, unsigned int sub_resource_idx
,
466 struct texture_readback
*rb
)
468 D3D10_TEXTURE2D_DESC texture_desc
;
469 unsigned int miplevel
;
470 ID3D10Device
*device
;
473 memset(rb
, 0, sizeof(*rb
));
475 ID3D10Texture2D_GetDevice(texture
, &device
);
477 ID3D10Texture2D_GetDesc(texture
, &texture_desc
);
478 texture_desc
.Usage
= D3D10_USAGE_STAGING
;
479 texture_desc
.BindFlags
= 0;
480 texture_desc
.CPUAccessFlags
= D3D10_CPU_ACCESS_READ
;
481 texture_desc
.MiscFlags
= 0;
482 if (FAILED(hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rb
->texture
)))
484 trace("Failed to create texture, hr %#x.\n", hr
);
485 ID3D10Device_Release(device
);
489 miplevel
= sub_resource_idx
% texture_desc
.MipLevels
;
490 rb
->width
= max(1, texture_desc
.Width
>> miplevel
);
491 rb
->height
= max(1, texture_desc
.Height
>> miplevel
);
492 rb
->sub_resource_idx
= sub_resource_idx
;
494 ID3D10Device_CopyResource(device
, (ID3D10Resource
*)rb
->texture
, (ID3D10Resource
*)texture
);
495 if (FAILED(hr
= ID3D10Texture2D_Map(rb
->texture
, sub_resource_idx
,
496 D3D10_MAP_READ
, 0, &rb
->mapped_texture
)))
498 trace("Failed to map sub-resource %u, hr %#x.\n", sub_resource_idx
, hr
);
499 ID3D10Texture2D_Release(rb
->texture
);
503 ID3D10Device_Release(device
);
506 static DWORD
get_readback_color(struct texture_readback
*rb
, unsigned int x
, unsigned int y
)
508 return ((DWORD
*)rb
->mapped_texture
.pData
)[rb
->mapped_texture
.RowPitch
* y
/ sizeof(DWORD
) + x
];
511 static float get_readback_float(struct texture_readback
*rb
, unsigned int x
, unsigned int y
)
513 return ((float *)rb
->mapped_texture
.pData
)[rb
->mapped_texture
.RowPitch
* y
/ sizeof(float) + x
];
516 static const struct vec4
*get_readback_vec4(struct texture_readback
*rb
, unsigned int x
, unsigned int y
)
518 return &((const struct vec4
*)rb
->mapped_texture
.pData
)[rb
->mapped_texture
.RowPitch
* y
/ sizeof(struct vec4
) + x
];
521 static const struct uvec4
*get_readback_uvec4(struct texture_readback
*rb
, unsigned int x
, unsigned int y
)
523 return &((const struct uvec4
*)rb
->mapped_texture
.pData
)[rb
->mapped_texture
.RowPitch
* y
/ sizeof(struct uvec4
) + x
];
526 static void release_texture_readback(struct texture_readback
*rb
)
528 ID3D10Texture2D_Unmap(rb
->texture
, rb
->sub_resource_idx
);
529 ID3D10Texture2D_Release(rb
->texture
);
532 static DWORD
get_texture_color(ID3D10Texture2D
*texture
, unsigned int x
, unsigned int y
)
534 struct texture_readback rb
;
537 get_texture_readback(texture
, 0, &rb
);
538 color
= get_readback_color(&rb
, x
, y
);
539 release_texture_readback(&rb
);
544 #define check_texture_sub_resource_color(t, s, c, d) check_texture_sub_resource_color_(__LINE__, t, s, c, d)
545 static void check_texture_sub_resource_color_(unsigned int line
, ID3D10Texture2D
*texture
,
546 unsigned int sub_resource_idx
, DWORD expected_color
, BYTE max_diff
)
548 struct texture_readback rb
;
549 unsigned int x
= 0, y
= 0;
550 BOOL all_match
= TRUE
;
553 get_texture_readback(texture
, sub_resource_idx
, &rb
);
554 for (y
= 0; y
< rb
.height
; ++y
)
556 for (x
= 0; x
< rb
.width
; ++x
)
558 color
= get_readback_color(&rb
, x
, y
);
559 if (!compare_color(color
, expected_color
, max_diff
))
568 release_texture_readback(&rb
);
569 ok_(__FILE__
, line
)(all_match
,
570 "Got unexpected color 0x%08x at (%u, %u), sub-resource %u.\n",
571 color
, x
, y
, sub_resource_idx
);
574 #define check_texture_color(t, c, d) check_texture_color_(__LINE__, t, c, d)
575 static void check_texture_color_(unsigned int line
, ID3D10Texture2D
*texture
,
576 DWORD expected_color
, BYTE max_diff
)
578 unsigned int sub_resource_idx
, sub_resource_count
;
579 D3D10_TEXTURE2D_DESC texture_desc
;
581 ID3D10Texture2D_GetDesc(texture
, &texture_desc
);
582 sub_resource_count
= texture_desc
.ArraySize
* texture_desc
.MipLevels
;
583 for (sub_resource_idx
= 0; sub_resource_idx
< sub_resource_count
; ++sub_resource_idx
)
584 check_texture_sub_resource_color_(line
, texture
, sub_resource_idx
, expected_color
, max_diff
);
587 #define check_texture_sub_resource_float(r, s, f, d) check_texture_sub_resource_float_(__LINE__, r, s, f, d)
588 static void check_texture_sub_resource_float_(unsigned int line
, ID3D10Texture2D
*texture
,
589 unsigned int sub_resource_idx
, float expected_value
, BYTE max_diff
)
591 struct texture_readback rb
;
592 unsigned int x
= 0, y
= 0;
593 BOOL all_match
= TRUE
;
596 get_texture_readback(texture
, sub_resource_idx
, &rb
);
597 for (y
= 0; y
< rb
.height
; ++y
)
599 for (x
= 0; x
< rb
.width
; ++x
)
601 value
= get_readback_float(&rb
, x
, y
);
602 if (!compare_float(value
, expected_value
, max_diff
))
611 release_texture_readback(&rb
);
612 ok_(__FILE__
, line
)(all_match
,
613 "Got unexpected value %.8e at (%u, %u), sub-resource %u.\n",
614 value
, x
, y
, sub_resource_idx
);
617 #define check_texture_float(r, f, d) check_texture_float_(__LINE__, r, f, d)
618 static void check_texture_float_(unsigned int line
, ID3D10Texture2D
*texture
,
619 float expected_value
, BYTE max_diff
)
621 unsigned int sub_resource_idx
, sub_resource_count
;
622 D3D10_TEXTURE2D_DESC texture_desc
;
624 ID3D10Texture2D_GetDesc(texture
, &texture_desc
);
625 sub_resource_count
= texture_desc
.ArraySize
* texture_desc
.MipLevels
;
626 for (sub_resource_idx
= 0; sub_resource_idx
< sub_resource_count
; ++sub_resource_idx
)
627 check_texture_sub_resource_float_(line
, texture
, sub_resource_idx
, expected_value
, max_diff
);
630 #define check_texture_sub_resource_vec4(a, b, c, d) check_texture_sub_resource_vec4_(__LINE__, a, b, c, d)
631 static void check_texture_sub_resource_vec4_(unsigned int line
, ID3D10Texture2D
*texture
,
632 unsigned int sub_resource_idx
, const struct vec4
*expected_value
, BYTE max_diff
)
634 struct texture_readback rb
;
635 unsigned int x
= 0, y
= 0;
636 struct vec4 value
= {0};
637 BOOL all_match
= TRUE
;
639 get_texture_readback(texture
, sub_resource_idx
, &rb
);
640 for (y
= 0; y
< rb
.height
; ++y
)
642 for (x
= 0; x
< rb
.width
; ++x
)
644 value
= *get_readback_vec4(&rb
, x
, y
);
645 if (!compare_vec4(&value
, expected_value
, max_diff
))
654 release_texture_readback(&rb
);
655 ok_(__FILE__
, line
)(all_match
,
656 "Got unexpected value {%.8e, %.8e, %.8e, %.8e} at (%u, %u), sub-resource %u.\n",
657 value
.x
, value
.y
, value
.z
, value
.w
, x
, y
, sub_resource_idx
);
660 #define check_texture_vec4(a, b, c) check_texture_vec4_(__LINE__, a, b, c)
661 static void check_texture_vec4_(unsigned int line
, ID3D10Texture2D
*texture
,
662 const struct vec4
*expected_value
, BYTE max_diff
)
664 unsigned int sub_resource_idx
, sub_resource_count
;
665 D3D10_TEXTURE2D_DESC texture_desc
;
667 ID3D10Texture2D_GetDesc(texture
, &texture_desc
);
668 sub_resource_count
= texture_desc
.ArraySize
* texture_desc
.MipLevels
;
669 for (sub_resource_idx
= 0; sub_resource_idx
< sub_resource_count
; ++sub_resource_idx
)
670 check_texture_sub_resource_vec4_(line
, texture
, sub_resource_idx
, expected_value
, max_diff
);
673 static ID3D10Device
*create_device(void)
675 ID3D10Device
*device
;
677 if (SUCCEEDED(D3D10CreateDevice(NULL
, D3D10_DRIVER_TYPE_HARDWARE
, NULL
, 0, D3D10_SDK_VERSION
, &device
)))
679 if (SUCCEEDED(D3D10CreateDevice(NULL
, D3D10_DRIVER_TYPE_WARP
, NULL
, 0, D3D10_SDK_VERSION
, &device
)))
681 if (SUCCEEDED(D3D10CreateDevice(NULL
, D3D10_DRIVER_TYPE_REFERENCE
, NULL
, 0, D3D10_SDK_VERSION
, &device
)))
687 static BOOL
is_warp_device(ID3D10Device
*device
)
689 DXGI_ADAPTER_DESC adapter_desc
;
690 IDXGIDevice
*dxgi_device
;
691 IDXGIAdapter
*adapter
;
694 hr
= ID3D10Device_QueryInterface(device
, &IID_IDXGIDevice
, (void **)&dxgi_device
);
695 ok(SUCCEEDED(hr
), "Failed to query IDXGIDevice interface, hr %#x.\n", hr
);
696 hr
= IDXGIDevice_GetAdapter(dxgi_device
, &adapter
);
697 ok(SUCCEEDED(hr
), "Failed to get adapter, hr %#x.\n", hr
);
698 IDXGIDevice_Release(dxgi_device
);
699 hr
= IDXGIAdapter_GetDesc(adapter
, &adapter_desc
);
700 ok(SUCCEEDED(hr
), "Failed to get adapter desc, hr %#x.\n", hr
);
701 IDXGIAdapter_Release(adapter
);
703 return !adapter_desc
.SubSysId
&& !adapter_desc
.Revision
704 && ((!adapter_desc
.VendorId
&& !adapter_desc
.DeviceId
)
705 || (adapter_desc
.VendorId
== 0x1414 && adapter_desc
.DeviceId
== 0x008c));
708 static BOOL
is_d3d11_interface_available(ID3D10Device
*device
)
710 ID3D11Device
*d3d11_device
;
713 if (SUCCEEDED(hr
= ID3D10Device_QueryInterface(device
, &IID_ID3D11Device
, (void **)&d3d11_device
)))
714 ID3D11Device_Release(d3d11_device
);
716 return SUCCEEDED(hr
);
719 #define SWAPCHAIN_FLAG_SHADER_INPUT 0x1
721 struct swapchain_desc
725 DXGI_SWAP_EFFECT swap_effect
;
729 static IDXGISwapChain
*create_swapchain(ID3D10Device
*device
, HWND window
, const struct swapchain_desc
*swapchain_desc
)
731 IDXGISwapChain
*swapchain
;
732 DXGI_SWAP_CHAIN_DESC dxgi_desc
;
733 IDXGIDevice
*dxgi_device
;
734 IDXGIAdapter
*adapter
;
735 IDXGIFactory
*factory
;
738 hr
= ID3D10Device_QueryInterface(device
, &IID_IDXGIDevice
, (void **)&dxgi_device
);
739 ok(SUCCEEDED(hr
), "Failed to get DXGI device, hr %#x.\n", hr
);
740 hr
= IDXGIDevice_GetAdapter(dxgi_device
, &adapter
);
741 ok(SUCCEEDED(hr
), "Failed to get adapter, hr %#x.\n", hr
);
742 IDXGIDevice_Release(dxgi_device
);
743 hr
= IDXGIAdapter_GetParent(adapter
, &IID_IDXGIFactory
, (void **)&factory
);
744 ok(SUCCEEDED(hr
), "Failed to get factory, hr %#x.\n", hr
);
745 IDXGIAdapter_Release(adapter
);
747 dxgi_desc
.BufferDesc
.Width
= 640;
748 dxgi_desc
.BufferDesc
.Height
= 480;
749 dxgi_desc
.BufferDesc
.RefreshRate
.Numerator
= 60;
750 dxgi_desc
.BufferDesc
.RefreshRate
.Denominator
= 1;
751 dxgi_desc
.BufferDesc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
752 dxgi_desc
.BufferDesc
.ScanlineOrdering
= DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED
;
753 dxgi_desc
.BufferDesc
.Scaling
= DXGI_MODE_SCALING_UNSPECIFIED
;
754 dxgi_desc
.SampleDesc
.Count
= 1;
755 dxgi_desc
.SampleDesc
.Quality
= 0;
756 dxgi_desc
.BufferUsage
= DXGI_USAGE_RENDER_TARGET_OUTPUT
;
757 dxgi_desc
.BufferCount
= 1;
758 dxgi_desc
.OutputWindow
= window
;
759 dxgi_desc
.Windowed
= TRUE
;
760 dxgi_desc
.SwapEffect
= DXGI_SWAP_EFFECT_DISCARD
;
765 dxgi_desc
.Windowed
= swapchain_desc
->windowed
;
766 dxgi_desc
.SwapEffect
= swapchain_desc
->swap_effect
;
767 dxgi_desc
.BufferCount
= swapchain_desc
->buffer_count
;
769 if (swapchain_desc
->flags
& SWAPCHAIN_FLAG_SHADER_INPUT
)
770 dxgi_desc
.BufferUsage
|= DXGI_USAGE_SHADER_INPUT
;
773 hr
= IDXGIFactory_CreateSwapChain(factory
, (IUnknown
*)device
, &dxgi_desc
, &swapchain
);
774 ok(SUCCEEDED(hr
), "Failed to create swapchain, hr %#x.\n", hr
);
775 IDXGIFactory_Release(factory
);
780 struct d3d10core_test_context
782 ID3D10Device
*device
;
784 IDXGISwapChain
*swapchain
;
785 ID3D10Texture2D
*backbuffer
;
786 ID3D10RenderTargetView
*backbuffer_rtv
;
788 ID3D10InputLayout
*input_layout
;
789 ID3D10VertexShader
*vs
;
792 ID3D10PixelShader
*ps
;
796 #define init_test_context(c) init_test_context_(__LINE__, c)
797 static BOOL
init_test_context_(unsigned int line
, struct d3d10core_test_context
*context
)
802 memset(context
, 0, sizeof(*context
));
804 if (!(context
->device
= create_device()))
806 skip_(__FILE__
, line
)("Failed to create device.\n");
809 context
->window
= CreateWindowA("static", "d3d10core_test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
810 0, 0, 640, 480, NULL
, NULL
, NULL
, NULL
);
811 context
->swapchain
= create_swapchain(context
->device
, context
->window
, NULL
);
812 hr
= IDXGISwapChain_GetBuffer(context
->swapchain
, 0, &IID_ID3D10Texture2D
, (void **)&context
->backbuffer
);
813 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to get backbuffer, hr %#x.\n", hr
);
815 hr
= ID3D10Device_CreateRenderTargetView(context
->device
, (ID3D10Resource
*)context
->backbuffer
,
816 NULL
, &context
->backbuffer_rtv
);
817 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
819 ID3D10Device_OMSetRenderTargets(context
->device
, 1, &context
->backbuffer_rtv
, NULL
);
827 ID3D10Device_RSSetViewports(context
->device
, 1, &vp
);
832 #define release_test_context(c) release_test_context_(__LINE__, c)
833 static void release_test_context_(unsigned int line
, struct d3d10core_test_context
*context
)
837 if (context
->input_layout
)
838 ID3D10InputLayout_Release(context
->input_layout
);
840 ID3D10VertexShader_Release(context
->vs
);
842 ID3D10Buffer_Release(context
->vb
);
844 ID3D10PixelShader_Release(context
->ps
);
846 ID3D10Buffer_Release(context
->ps_cb
);
848 ID3D10RenderTargetView_Release(context
->backbuffer_rtv
);
849 ID3D10Texture2D_Release(context
->backbuffer
);
850 IDXGISwapChain_Release(context
->swapchain
);
851 DestroyWindow(context
->window
);
853 ref
= ID3D10Device_Release(context
->device
);
854 ok_(__FILE__
, line
)(!ref
, "Device has %u references left.\n", ref
);
857 #define draw_quad(c) draw_quad_(__LINE__, c)
858 static void draw_quad_(unsigned int line
, struct d3d10core_test_context
*context
)
860 static const D3D10_INPUT_ELEMENT_DESC default_layout_desc
[] =
862 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D10_INPUT_PER_VERTEX_DATA
, 0},
864 static const DWORD default_vs_code
[] =
867 float4
main(float4 position
: POSITION
) : SV_POSITION
872 0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003,
873 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
874 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
875 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
876 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
877 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
878 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
882 struct vec2 position
;
892 ID3D10Device
*device
= context
->device
;
893 unsigned int stride
, offset
;
896 if (!context
->input_layout
)
898 hr
= ID3D10Device_CreateInputLayout(device
, default_layout_desc
,
899 sizeof(default_layout_desc
) / sizeof(*default_layout_desc
),
900 default_vs_code
, sizeof(default_vs_code
), &context
->input_layout
);
901 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
903 context
->vb
= create_buffer(device
, D3D10_BIND_VERTEX_BUFFER
, sizeof(quad
), quad
);
905 hr
= ID3D10Device_CreateVertexShader(device
, default_vs_code
, sizeof(default_vs_code
), &context
->vs
);
906 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
909 ID3D10Device_IASetInputLayout(context
->device
, context
->input_layout
);
910 ID3D10Device_IASetPrimitiveTopology(context
->device
, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
911 stride
= sizeof(*quad
);
913 ID3D10Device_IASetVertexBuffers(context
->device
, 0, 1, &context
->vb
, &stride
, &offset
);
914 ID3D10Device_VSSetShader(context
->device
, context
->vs
);
916 ID3D10Device_Draw(context
->device
, 4, 0);
919 #define draw_color_quad(c, color) draw_color_quad_(__LINE__, c, color)
920 static void draw_color_quad_(unsigned int line
, struct d3d10core_test_context
*context
, const struct vec4
*color
)
922 static const DWORD ps_color_code
[] =
927 float4
main() : SV_TARGET
932 0x43425844, 0x80f1c810, 0xdacbbc8b, 0xe07b133e, 0x3059cbfa, 0x00000001, 0x000000b8, 0x00000003,
933 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
934 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
935 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000040, 0x00000040, 0x00000010,
936 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x06000036,
937 0x001020f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x0100003e,
940 ID3D10Device
*device
= context
->device
;
945 hr
= ID3D10Device_CreatePixelShader(device
, ps_color_code
, sizeof(ps_color_code
), &context
->ps
);
946 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
950 context
->ps_cb
= create_buffer(device
, D3D10_BIND_CONSTANT_BUFFER
, sizeof(*color
), NULL
);
952 ID3D10Device_PSSetShader(device
, context
->ps
);
953 ID3D10Device_PSSetConstantBuffers(device
, 0, 1, &context
->ps_cb
);
955 ID3D10Device_UpdateSubresource(device
, (ID3D10Resource
*)context
->ps_cb
, 0, NULL
, color
, 0, 0);
957 draw_quad_(line
, context
);
960 static void test_feature_level(void)
962 D3D_FEATURE_LEVEL feature_level
;
963 ID3D11Device
*device11
;
964 ID3D10Device
*device10
;
967 if (!(device10
= create_device()))
969 skip("Failed to create device, skipping tests.\n");
973 hr
= ID3D10Device_QueryInterface(device10
, &IID_ID3D11Device
, (void **)&device11
);
974 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
975 "Failed to query ID3D11Device interface, hr %#x.\n", hr
);
978 win_skip("D3D11 is not available.\n");
979 ID3D10Device_Release(device10
);
983 /* Device was created by D3D10CreateDevice. */
984 feature_level
= ID3D11Device_GetFeatureLevel(device11
);
985 ok(feature_level
== D3D_FEATURE_LEVEL_10_0
, "Got unexpected feature level %#x.\n", feature_level
);
987 ID3D11Device_Release(device11
);
988 ID3D10Device_Release(device10
);
991 static void test_device_interfaces(void)
993 IDXGIAdapter
*dxgi_adapter
;
994 IDXGIDevice
*dxgi_device
;
995 ID3D10Device
*device
;
1000 if (!(device
= create_device()))
1002 skip("Failed to create device.\n");
1006 hr
= ID3D10Device_QueryInterface(device
, &IID_IUnknown
, (void **)&iface
);
1007 ok(SUCCEEDED(hr
), "Device should implement IUnknown interface, hr %#x.\n", hr
);
1008 IUnknown_Release(iface
);
1010 hr
= ID3D10Device_QueryInterface(device
, &IID_IDXGIObject
, (void **)&iface
);
1011 ok(SUCCEEDED(hr
), "Device should implement IDXGIObject interface, hr %#x.\n", hr
);
1012 IUnknown_Release(iface
);
1014 hr
= ID3D10Device_QueryInterface(device
, &IID_IDXGIDevice
, (void **)&dxgi_device
);
1015 ok(SUCCEEDED(hr
), "Device should implement IDXGIDevice.\n");
1016 hr
= IDXGIDevice_GetParent(dxgi_device
, &IID_IDXGIAdapter
, (void **)&dxgi_adapter
);
1017 ok(SUCCEEDED(hr
), "Device parent should implement IDXGIAdapter.\n");
1018 hr
= IDXGIAdapter_GetParent(dxgi_adapter
, &IID_IDXGIFactory
, (void **)&iface
);
1019 ok(SUCCEEDED(hr
), "Adapter parent should implement IDXGIFactory.\n");
1020 IUnknown_Release(iface
);
1021 IUnknown_Release(dxgi_adapter
);
1022 hr
= IDXGIDevice_GetParent(dxgi_device
, &IID_IDXGIAdapter1
, (void **)&dxgi_adapter
);
1023 ok(SUCCEEDED(hr
), "Device parent should implement IDXGIAdapter1.\n");
1024 hr
= IDXGIAdapter_GetParent(dxgi_adapter
, &IID_IDXGIFactory1
, (void **)&iface
);
1025 ok(hr
== E_NOINTERFACE
, "Adapter parent should not implement IDXGIFactory1.\n");
1026 IUnknown_Release(dxgi_adapter
);
1027 IUnknown_Release(dxgi_device
);
1029 hr
= ID3D10Device_QueryInterface(device
, &IID_IDXGIDevice1
, (void **)&iface
);
1030 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
1031 "Device should implement IDXGIDevice1.\n");
1032 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
1034 hr
= ID3D10Device_QueryInterface(device
, &IID_ID3D10Multithread
, (void **)&iface
);
1035 ok(SUCCEEDED(hr
), "Device should implement ID3D10Multithread interface, hr %#x.\n", hr
);
1036 IUnknown_Release(iface
);
1038 hr
= ID3D10Device_QueryInterface(device
, &IID_ID3D10Device1
, (void **)&iface
);
1039 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
1040 "Device should implement ID3D10Device1 interface, hr %#x.\n", hr
);
1041 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
1043 hr
= ID3D10Device_QueryInterface(device
, &IID_ID3D11Device
, (void **)&iface
);
1044 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
1045 "Device should implement ID3D11Device interface, hr %#x.\n", hr
);
1046 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
1048 refcount
= ID3D10Device_Release(device
);
1049 ok(!refcount
, "Device has %u references left.\n", refcount
);
1052 static void test_create_texture2d(void)
1054 ULONG refcount
, expected_refcount
;
1055 D3D10_SUBRESOURCE_DATA data
= {0};
1056 ID3D10Device
*device
, *tmp
;
1057 D3D10_TEXTURE2D_DESC desc
;
1058 ID3D10Texture2D
*texture
;
1059 UINT quality_level_count
;
1060 IDXGISurface
*surface
;
1068 D3D10_BIND_FLAG bind_flags
;
1075 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 1, D3D10_BIND_VERTEX_BUFFER
, 0, FALSE
, TRUE
},
1076 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 1, D3D10_BIND_INDEX_BUFFER
, 0, FALSE
, TRUE
},
1077 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 1, D3D10_BIND_CONSTANT_BUFFER
, 0, FALSE
, TRUE
},
1078 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 0, D3D10_BIND_SHADER_RESOURCE
, 0, FALSE
, FALSE
},
1079 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 1, D3D10_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
1080 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 2, D3D10_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
1081 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 3, D3D10_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
1082 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 3, D3D10_BIND_SHADER_RESOURCE
, D3D10_RESOURCE_MISC_TEXTURECUBE
,
1084 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 1, D3D10_BIND_SHADER_RESOURCE
, D3D10_RESOURCE_MISC_TEXTURECUBE
,
1086 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 5, D3D10_BIND_SHADER_RESOURCE
, D3D10_RESOURCE_MISC_TEXTURECUBE
,
1088 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 6, D3D10_BIND_SHADER_RESOURCE
, D3D10_RESOURCE_MISC_TEXTURECUBE
,
1090 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 7, D3D10_BIND_SHADER_RESOURCE
, D3D10_RESOURCE_MISC_TEXTURECUBE
,
1092 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 10, D3D10_BIND_SHADER_RESOURCE
, D3D10_RESOURCE_MISC_TEXTURECUBE
,
1094 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 12, D3D10_BIND_SHADER_RESOURCE
, D3D10_RESOURCE_MISC_TEXTURECUBE
,
1096 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 0, D3D10_BIND_RENDER_TARGET
, 0, FALSE
, FALSE
},
1097 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 1, D3D10_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
1098 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 2, D3D10_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
1099 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 9, D3D10_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
1100 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, 1, D3D10_BIND_DEPTH_STENCIL
, 0, FALSE
, FALSE
},
1101 {DXGI_FORMAT_R32G32B32_TYPELESS
, 1, D3D10_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
1102 {DXGI_FORMAT_R16G16B16A16_TYPELESS
, 1, D3D10_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
1103 {DXGI_FORMAT_R16G16B16A16_TYPELESS
, 1, D3D10_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
1104 {DXGI_FORMAT_R32G32_TYPELESS
, 1, D3D10_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
1105 {DXGI_FORMAT_R32G8X24_TYPELESS
, 1, D3D10_BIND_DEPTH_STENCIL
, 0, TRUE
, TRUE
},
1106 {DXGI_FORMAT_R10G10B10A2_TYPELESS
, 1, D3D10_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
1107 {DXGI_FORMAT_R10G10B10A2_TYPELESS
, 1, D3D10_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
1108 {DXGI_FORMAT_R16G16_TYPELESS
, 1, D3D10_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
1109 {DXGI_FORMAT_R16G16_UNORM
, 1, D3D10_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
1110 {DXGI_FORMAT_R16G16_SNORM
, 1, D3D10_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
1111 {DXGI_FORMAT_R32_TYPELESS
, 0, D3D10_BIND_SHADER_RESOURCE
, 0, FALSE
, FALSE
},
1112 {DXGI_FORMAT_R32_TYPELESS
, 1, D3D10_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
1113 {DXGI_FORMAT_R32_TYPELESS
, 9, D3D10_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
1114 {DXGI_FORMAT_R32_TYPELESS
, 9, D3D10_BIND_SHADER_RESOURCE
, D3D10_RESOURCE_MISC_TEXTURECUBE
,
1116 {DXGI_FORMAT_R32_TYPELESS
, 1, D3D11_BIND_DEPTH_STENCIL
, 0, TRUE
, FALSE
},
1117 {DXGI_FORMAT_R24G8_TYPELESS
, 1, D3D10_BIND_VERTEX_BUFFER
, 0, FALSE
, TRUE
},
1118 {DXGI_FORMAT_R24G8_TYPELESS
, 1, D3D10_BIND_INDEX_BUFFER
, 0, FALSE
, TRUE
},
1119 {DXGI_FORMAT_R24G8_TYPELESS
, 1, D3D10_BIND_CONSTANT_BUFFER
, 0, FALSE
, TRUE
},
1120 {DXGI_FORMAT_R24G8_TYPELESS
, 1, D3D10_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
1121 {DXGI_FORMAT_R24G8_TYPELESS
, 1, D3D10_BIND_DEPTH_STENCIL
, 0, TRUE
, FALSE
},
1122 {DXGI_FORMAT_R8G8_TYPELESS
, 1, D3D10_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
1123 {DXGI_FORMAT_R8G8_TYPELESS
, 1, D3D10_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
1124 {DXGI_FORMAT_R8G8_UNORM
, 1, D3D10_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
1125 {DXGI_FORMAT_R8G8_SNORM
, 1, D3D10_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
1126 {DXGI_FORMAT_R16_TYPELESS
, 1, D3D10_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
1127 {DXGI_FORMAT_R16_TYPELESS
, 1, D3D10_BIND_DEPTH_STENCIL
, 0, TRUE
, FALSE
},
1128 {DXGI_FORMAT_R8_TYPELESS
, 1, D3D10_BIND_SHADER_RESOURCE
, 0, TRUE
, FALSE
},
1129 {DXGI_FORMAT_R8G8B8A8_UNORM
, 1, D3D10_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
1130 {DXGI_FORMAT_R8G8B8A8_UNORM
, 1, D3D10_BIND_DEPTH_STENCIL
, 0, FALSE
, FALSE
},
1131 {DXGI_FORMAT_R8G8B8A8_SNORM
, 1, D3D10_BIND_RENDER_TARGET
, 0, TRUE
, FALSE
},
1132 {DXGI_FORMAT_D24_UNORM_S8_UINT
, 1, D3D10_BIND_RENDER_TARGET
, 0, FALSE
, FALSE
},
1133 {DXGI_FORMAT_D32_FLOAT
, 1, D3D10_BIND_RENDER_TARGET
, 0, FALSE
, FALSE
},
1136 if (!(device
= create_device()))
1138 skip("Failed to create device, skipping tests.\n");
1146 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
1147 desc
.SampleDesc
.Count
= 1;
1148 desc
.SampleDesc
.Quality
= 0;
1149 desc
.Usage
= D3D10_USAGE_DEFAULT
;
1150 desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
1151 desc
.CPUAccessFlags
= 0;
1154 hr
= ID3D10Device_CreateTexture2D(device
, &desc
, &data
, &texture
);
1155 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
1157 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
1158 hr
= ID3D10Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
1159 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x\n", hr
);
1160 refcount
= get_refcount((IUnknown
*)device
);
1161 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
1163 expected_refcount
= refcount
+ 1;
1164 ID3D10Texture2D_GetDevice(texture
, &tmp
);
1165 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
1166 refcount
= get_refcount((IUnknown
*)device
);
1167 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
1168 ID3D10Device_Release(tmp
);
1170 hr
= ID3D10Texture2D_QueryInterface(texture
, &IID_IDXGISurface
, (void **)&surface
);
1171 ok(SUCCEEDED(hr
), "Texture should implement IDXGISurface\n");
1172 if (SUCCEEDED(hr
)) IDXGISurface_Release(surface
);
1173 ID3D10Texture2D_Release(texture
);
1176 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
1177 hr
= ID3D10Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
1178 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x\n", hr
);
1179 refcount
= get_refcount((IUnknown
*)device
);
1180 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
1182 expected_refcount
= refcount
+ 1;
1183 ID3D10Texture2D_GetDevice(texture
, &tmp
);
1184 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
1185 refcount
= get_refcount((IUnknown
*)device
);
1186 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
1187 ID3D10Device_Release(tmp
);
1189 ID3D10Texture2D_GetDesc(texture
, &desc
);
1190 ok(desc
.Width
== 512, "Got unexpected Width %u.\n", desc
.Width
);
1191 ok(desc
.Height
== 512, "Got unexpected Height %u.\n", desc
.Height
);
1192 ok(desc
.MipLevels
== 10, "Got unexpected MipLevels %u.\n", desc
.MipLevels
);
1193 ok(desc
.ArraySize
== 1, "Got unexpected ArraySize %u.\n", desc
.ArraySize
);
1194 ok(desc
.Format
== DXGI_FORMAT_R8G8B8A8_UNORM
, "Got unexpected Format %#x.\n", desc
.Format
);
1195 ok(desc
.SampleDesc
.Count
== 1, "Got unexpected SampleDesc.Count %u.\n", desc
.SampleDesc
.Count
);
1196 ok(desc
.SampleDesc
.Quality
== 0, "Got unexpected SampleDesc.Quality %u.\n", desc
.SampleDesc
.Quality
);
1197 ok(desc
.Usage
== D3D10_USAGE_DEFAULT
, "Got unexpected Usage %u.\n", desc
.Usage
);
1198 ok(desc
.BindFlags
== D3D10_BIND_RENDER_TARGET
, "Got unexpected BindFlags %u.\n", desc
.BindFlags
);
1199 ok(desc
.CPUAccessFlags
== 0, "Got unexpected CPUAccessFlags %u.\n", desc
.CPUAccessFlags
);
1200 ok(desc
.MiscFlags
== 0, "Got unexpected MiscFlags %u.\n", desc
.MiscFlags
);
1202 hr
= ID3D10Texture2D_QueryInterface(texture
, &IID_IDXGISurface
, (void **)&surface
);
1203 ok(FAILED(hr
), "Texture should not implement IDXGISurface\n");
1204 if (SUCCEEDED(hr
)) IDXGISurface_Release(surface
);
1205 ID3D10Texture2D_Release(texture
);
1209 hr
= ID3D10Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
1210 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x\n", hr
);
1212 hr
= ID3D10Texture2D_QueryInterface(texture
, &IID_IDXGISurface
, (void **)&surface
);
1213 ok(FAILED(hr
), "Texture should not implement IDXGISurface\n");
1214 if (SUCCEEDED(hr
)) IDXGISurface_Release(surface
);
1215 ID3D10Texture2D_Release(texture
);
1217 ID3D10Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 2, &quality_level_count
);
1219 desc
.SampleDesc
.Count
= 2;
1220 hr
= ID3D10Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
1221 if (quality_level_count
)
1223 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
1224 ID3D10Texture2D_Release(texture
);
1225 desc
.SampleDesc
.Quality
= quality_level_count
;
1226 hr
= ID3D10Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
1228 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
1230 /* We assume 15 samples multisampling is never supported in practice. */
1231 desc
.SampleDesc
.Count
= 15;
1232 desc
.SampleDesc
.Quality
= 0;
1233 hr
= ID3D10Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
1234 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
1236 desc
.SampleDesc
.Count
= 1;
1237 for (i
= 0; i
< sizeof(tests
) / sizeof(*tests
); ++i
)
1239 desc
.ArraySize
= tests
[i
].array_size
;
1240 desc
.Format
= tests
[i
].format
;
1241 desc
.BindFlags
= tests
[i
].bind_flags
;
1242 desc
.MiscFlags
= tests
[i
].misc_flags
;
1243 hr
= ID3D10Device_CreateTexture2D(device
, &desc
, NULL
, (ID3D10Texture2D
**)&texture
);
1245 todo_wine_if(tests
[i
].todo
)
1246 ok(hr
== (tests
[i
].succeeds
? S_OK
: E_INVALIDARG
), "Test %u: Got unexpected hr %#x.\n", i
, hr
);
1249 ID3D10Texture2D_Release(texture
);
1252 refcount
= ID3D10Device_Release(device
);
1253 ok(!refcount
, "Device has %u references left.\n", refcount
);
1256 static void test_texture2d_interfaces(void)
1258 ID3D11Texture2D
*d3d11_texture
;
1259 D3D10_TEXTURE2D_DESC desc
;
1260 ID3D10Texture2D
*texture
;
1261 IDXGISurface
*surface
;
1262 ID3D10Device
*device
;
1267 static const struct test
1271 UINT expected_bind_flags
;
1272 UINT expected_misc_flags
;
1274 desc_conversion_tests
[] =
1277 D3D10_BIND_RENDER_TARGET
, 0,
1278 D3D11_BIND_RENDER_TARGET
, 0
1281 0, D3D10_RESOURCE_MISC_SHARED
,
1282 0, D3D11_RESOURCE_MISC_SHARED
1286 if (!(device
= create_device()))
1288 skip("Failed to create device, skipping tests.\n");
1296 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
1297 desc
.SampleDesc
.Count
= 1;
1298 desc
.SampleDesc
.Quality
= 0;
1299 desc
.Usage
= D3D10_USAGE_DEFAULT
;
1300 desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
1301 desc
.CPUAccessFlags
= 0;
1304 hr
= ID3D10Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
1305 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
1307 hr
= ID3D10Texture2D_QueryInterface(texture
, &IID_IDXGISurface
, (void **)&surface
);
1308 ok(hr
== E_NOINTERFACE
, "Texture should not implement IDXGISurface.\n");
1310 hr
= ID3D10Texture2D_QueryInterface(texture
, &IID_ID3D11Texture2D
, (void **)&d3d11_texture
);
1311 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
1312 "Texture should implement ID3D11Texture2D.\n");
1313 if (SUCCEEDED(hr
)) ID3D11Texture2D_Release(d3d11_texture
);
1314 ID3D10Texture2D_Release(texture
);
1318 win_skip("D3D11 is not available, skipping tests.\n");
1319 ID3D10Device_Release(device
);
1323 for (i
= 0; i
< sizeof(desc_conversion_tests
) / sizeof(*desc_conversion_tests
); ++i
)
1325 const struct test
*current
= &desc_conversion_tests
[i
];
1326 D3D11_TEXTURE2D_DESC d3d11_desc
;
1327 ID3D11Device
*d3d11_device
;
1333 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
1334 desc
.SampleDesc
.Count
= 1;
1335 desc
.SampleDesc
.Quality
= 0;
1336 desc
.Usage
= D3D10_USAGE_DEFAULT
;
1337 desc
.BindFlags
= current
->bind_flags
;
1338 desc
.CPUAccessFlags
= 0;
1339 desc
.MiscFlags
= current
->misc_flags
;
1341 hr
= ID3D10Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
1342 /* Shared resources are not supported by REF and WARP devices. */
1343 ok(SUCCEEDED(hr
) || broken(hr
== E_OUTOFMEMORY
),
1344 "Test %u: Failed to create a 2d texture, hr %#x.\n", i
, hr
);
1347 win_skip("Failed to create ID3D10Texture2D, skipping test %u.\n", i
);
1351 hr
= ID3D10Texture2D_QueryInterface(texture
, &IID_IDXGISurface
, (void **)&surface
);
1352 ok(SUCCEEDED(hr
), "Test %u: Texture should implement IDXGISurface.\n", i
);
1353 IDXGISurface_Release(surface
);
1355 hr
= ID3D10Texture2D_QueryInterface(texture
, &IID_ID3D11Texture2D
, (void **)&d3d11_texture
);
1356 ok(SUCCEEDED(hr
), "Test %u: Texture should implement ID3D11Texture2D.\n", i
);
1357 ID3D10Texture2D_Release(texture
);
1359 ID3D11Texture2D_GetDesc(d3d11_texture
, &d3d11_desc
);
1361 ok(d3d11_desc
.Width
== desc
.Width
,
1362 "Test %u: Got unexpected Width %u.\n", i
, d3d11_desc
.Width
);
1363 ok(d3d11_desc
.Height
== desc
.Height
,
1364 "Test %u: Got unexpected Height %u.\n", i
, d3d11_desc
.Height
);
1365 ok(d3d11_desc
.MipLevels
== desc
.MipLevels
,
1366 "Test %u: Got unexpected MipLevels %u.\n", i
, d3d11_desc
.MipLevels
);
1367 ok(d3d11_desc
.ArraySize
== desc
.ArraySize
,
1368 "Test %u: Got unexpected ArraySize %u.\n", i
, d3d11_desc
.ArraySize
);
1369 ok(d3d11_desc
.Format
== desc
.Format
,
1370 "Test %u: Got unexpected Format %u.\n", i
, d3d11_desc
.Format
);
1371 ok(d3d11_desc
.SampleDesc
.Count
== desc
.SampleDesc
.Count
,
1372 "Test %u: Got unexpected SampleDesc.Count %u.\n", i
, d3d11_desc
.SampleDesc
.Count
);
1373 ok(d3d11_desc
.SampleDesc
.Quality
== desc
.SampleDesc
.Quality
,
1374 "Test %u: Got unexpected SampleDesc.Quality %u.\n", i
, d3d11_desc
.SampleDesc
.Quality
);
1375 ok(d3d11_desc
.Usage
== (D3D11_USAGE
)desc
.Usage
,
1376 "Test %u: Got unexpected Usage %u.\n", i
, d3d11_desc
.Usage
);
1377 ok(d3d11_desc
.BindFlags
== current
->expected_bind_flags
,
1378 "Test %u: Got unexpected BindFlags %#x.\n", i
, d3d11_desc
.BindFlags
);
1379 ok(d3d11_desc
.CPUAccessFlags
== desc
.CPUAccessFlags
,
1380 "Test %u: Got unexpected CPUAccessFlags %#x.\n", i
, d3d11_desc
.CPUAccessFlags
);
1381 ok(d3d11_desc
.MiscFlags
== current
->expected_misc_flags
,
1382 "Test %u: Got unexpected MiscFlags %#x.\n", i
, d3d11_desc
.MiscFlags
);
1384 d3d11_device
= NULL
;
1385 ID3D11Texture2D_GetDevice(d3d11_texture
, &d3d11_device
);
1386 ok(!!d3d11_device
, "Test %u: Got NULL, expected device pointer.\n", i
);
1387 ID3D11Device_Release(d3d11_device
);
1389 ID3D11Texture2D_Release(d3d11_texture
);
1392 refcount
= ID3D10Device_Release(device
);
1393 ok(!refcount
, "Device has %u references left.\n", refcount
);
1396 static void test_create_texture3d(void)
1398 ULONG refcount
, expected_refcount
;
1399 D3D10_SUBRESOURCE_DATA data
= {0};
1400 ID3D10Device
*device
, *tmp
;
1401 D3D10_TEXTURE3D_DESC desc
;
1402 ID3D10Texture3D
*texture
;
1403 IDXGISurface
*surface
;
1410 D3D10_BIND_FLAG bind_flags
;
1416 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, D3D10_BIND_VERTEX_BUFFER
, FALSE
, TRUE
},
1417 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, D3D10_BIND_INDEX_BUFFER
, FALSE
, TRUE
},
1418 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, D3D10_BIND_CONSTANT_BUFFER
, FALSE
, TRUE
},
1419 {DXGI_FORMAT_R32G32B32A32_TYPELESS
, D3D10_BIND_SHADER_RESOURCE
, TRUE
, FALSE
},
1420 {DXGI_FORMAT_R16G16B16A16_TYPELESS
, D3D10_BIND_SHADER_RESOURCE
, TRUE
, FALSE
},
1421 {DXGI_FORMAT_R10G10B10A2_TYPELESS
, D3D10_BIND_SHADER_RESOURCE
, TRUE
, FALSE
},
1422 {DXGI_FORMAT_R8G8B8A8_UNORM
, D3D10_BIND_DEPTH_STENCIL
, FALSE
, FALSE
},
1423 {DXGI_FORMAT_D24_UNORM_S8_UINT
, D3D10_BIND_RENDER_TARGET
, FALSE
, FALSE
},
1424 {DXGI_FORMAT_D32_FLOAT
, D3D10_BIND_RENDER_TARGET
, FALSE
, FALSE
},
1427 if (!(device
= create_device()))
1429 skip("Failed to create device, skipping tests.\n");
1437 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
1438 desc
.Usage
= D3D10_USAGE_DEFAULT
;
1439 desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
1440 desc
.CPUAccessFlags
= 0;
1443 hr
= ID3D10Device_CreateTexture3D(device
, &desc
, &data
, &texture
);
1444 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
1446 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
1447 hr
= ID3D10Device_CreateTexture3D(device
, &desc
, NULL
, &texture
);
1448 ok(SUCCEEDED(hr
), "Failed to create a 3d texture, hr %#x.\n", hr
);
1449 refcount
= get_refcount((IUnknown
*)device
);
1450 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
1452 expected_refcount
= refcount
+ 1;
1453 ID3D10Texture3D_GetDevice(texture
, &tmp
);
1454 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
1455 refcount
= get_refcount((IUnknown
*)device
);
1456 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
1457 ID3D10Device_Release(tmp
);
1459 hr
= ID3D10Texture3D_QueryInterface(texture
, &IID_IDXGISurface
, (void **)&surface
);
1460 ok(FAILED(hr
), "Texture should not implement IDXGISurface.\n");
1461 if (SUCCEEDED(hr
)) IDXGISurface_Release(surface
);
1462 ID3D10Texture3D_Release(texture
);
1465 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
1466 hr
= ID3D10Device_CreateTexture3D(device
, &desc
, NULL
, &texture
);
1467 ok(SUCCEEDED(hr
), "Failed to create a 3d texture, hr %#x.\n", hr
);
1468 refcount
= get_refcount((IUnknown
*)device
);
1469 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
1471 expected_refcount
= refcount
+ 1;
1472 ID3D10Texture3D_GetDevice(texture
, &tmp
);
1473 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
1474 refcount
= get_refcount((IUnknown
*)device
);
1475 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
1476 ID3D10Device_Release(tmp
);
1478 ID3D10Texture3D_GetDesc(texture
, &desc
);
1479 ok(desc
.Width
== 64, "Got unexpected Width %u.\n", desc
.Width
);
1480 ok(desc
.Height
== 64, "Got unexpected Height %u.\n", desc
.Height
);
1481 ok(desc
.Depth
== 64, "Got unexpected Depth %u.\n", desc
.Depth
);
1482 ok(desc
.MipLevels
== 7, "Got unexpected MipLevels %u.\n", desc
.MipLevels
);
1483 ok(desc
.Format
== DXGI_FORMAT_R8G8B8A8_UNORM
, "Got unexpected Format %#x.\n", desc
.Format
);
1484 ok(desc
.Usage
== D3D10_USAGE_DEFAULT
, "Got unexpected Usage %u.\n", desc
.Usage
);
1485 ok(desc
.BindFlags
== D3D10_BIND_RENDER_TARGET
, "Got unexpected BindFlags %u.\n", desc
.BindFlags
);
1486 ok(desc
.CPUAccessFlags
== 0, "Got unexpected CPUAccessFlags %u.\n", desc
.CPUAccessFlags
);
1487 ok(desc
.MiscFlags
== 0, "Got unexpected MiscFlags %u.\n", desc
.MiscFlags
);
1489 hr
= ID3D10Texture3D_QueryInterface(texture
, &IID_IDXGISurface
, (void **)&surface
);
1490 ok(FAILED(hr
), "Texture should not implement IDXGISurface.\n");
1491 if (SUCCEEDED(hr
)) IDXGISurface_Release(surface
);
1492 ID3D10Texture3D_Release(texture
);
1495 for (i
= 0; i
< sizeof(tests
) / sizeof(*tests
); ++i
)
1497 desc
.Format
= tests
[i
].format
;
1498 desc
.BindFlags
= tests
[i
].bind_flags
;
1499 hr
= ID3D10Device_CreateTexture3D(device
, &desc
, NULL
, (ID3D10Texture3D
**)&texture
);
1501 todo_wine_if(tests
[i
].todo
)
1502 ok(hr
== (tests
[i
].succeeds
? S_OK
: E_INVALIDARG
), "Test %u: Got unexpected hr %#x.\n", i
, hr
);
1505 ID3D10Texture3D_Release(texture
);
1508 refcount
= ID3D10Device_Release(device
);
1509 ok(!refcount
, "Device has %u references left.\n", refcount
);
1512 static void test_buffer_interfaces(void)
1514 ID3D11Buffer
*d3d11_buffer
;
1515 D3D10_BUFFER_DESC desc
;
1516 ID3D10Buffer
*buffer
;
1517 ID3D10Device
*device
;
1522 static const struct test
1526 UINT expected_bind_flags
;
1527 UINT expected_misc_flags
;
1529 desc_conversion_tests
[] =
1532 D3D10_BIND_VERTEX_BUFFER
, 0,
1533 D3D11_BIND_VERTEX_BUFFER
, 0
1536 D3D10_BIND_INDEX_BUFFER
, 0,
1537 D3D11_BIND_INDEX_BUFFER
, 0
1540 D3D10_BIND_CONSTANT_BUFFER
, 0,
1541 D3D11_BIND_CONSTANT_BUFFER
, 0
1544 D3D10_BIND_SHADER_RESOURCE
, 0,
1545 D3D11_BIND_SHADER_RESOURCE
, 0
1548 D3D10_BIND_STREAM_OUTPUT
, 0,
1549 D3D11_BIND_STREAM_OUTPUT
, 0
1552 D3D10_BIND_RENDER_TARGET
, 0,
1553 D3D11_BIND_RENDER_TARGET
, 0
1556 0, D3D10_RESOURCE_MISC_SHARED
,
1557 0, D3D11_RESOURCE_MISC_SHARED
1561 if (!(device
= create_device()))
1563 skip("Failed to create device.\n");
1567 buffer
= create_buffer(device
, D3D10_BIND_VERTEX_BUFFER
, 1024, NULL
);
1568 hr
= ID3D10Buffer_QueryInterface(buffer
, &IID_ID3D11Buffer
, (void **)&d3d11_buffer
);
1569 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
1570 "Buffer should implement ID3D11Buffer.\n");
1571 if (SUCCEEDED(hr
)) ID3D11Buffer_Release(d3d11_buffer
);
1572 ID3D10Buffer_Release(buffer
);
1576 win_skip("D3D11 is not available.\n");
1577 ID3D10Device_Release(device
);
1581 for (i
= 0; i
< sizeof(desc_conversion_tests
) / sizeof(*desc_conversion_tests
); ++i
)
1583 const struct test
*current
= &desc_conversion_tests
[i
];
1584 D3D11_BUFFER_DESC d3d11_desc
;
1585 ID3D11Device
*d3d11_device
;
1587 desc
.ByteWidth
= 1024;
1588 desc
.Usage
= D3D10_USAGE_DEFAULT
;
1589 desc
.BindFlags
= current
->bind_flags
;
1590 desc
.CPUAccessFlags
= 0;
1591 desc
.MiscFlags
= current
->misc_flags
;
1593 hr
= ID3D10Device_CreateBuffer(device
, &desc
, NULL
, &buffer
);
1594 /* Shared resources are not supported by REF and WARP devices. */
1595 ok(SUCCEEDED(hr
) || broken(hr
== E_OUTOFMEMORY
), "Test %u: Failed to create a buffer, hr %#x.\n", i
, hr
);
1598 win_skip("Failed to create a buffer, skipping test %u.\n", i
);
1602 hr
= ID3D10Buffer_QueryInterface(buffer
, &IID_ID3D11Buffer
, (void **)&d3d11_buffer
);
1603 ok(SUCCEEDED(hr
), "Test %u: Buffer should implement ID3D11Buffer.\n", i
);
1604 ID3D10Buffer_Release(buffer
);
1606 ID3D11Buffer_GetDesc(d3d11_buffer
, &d3d11_desc
);
1608 ok(d3d11_desc
.ByteWidth
== desc
.ByteWidth
,
1609 "Test %u: Got unexpected ByteWidth %u.\n", i
, d3d11_desc
.ByteWidth
);
1610 ok(d3d11_desc
.Usage
== (D3D11_USAGE
)desc
.Usage
,
1611 "Test %u: Got unexpected Usage %u.\n", i
, d3d11_desc
.Usage
);
1612 ok(d3d11_desc
.BindFlags
== current
->expected_bind_flags
,
1613 "Test %u: Got unexpected BindFlags %#x.\n", i
, d3d11_desc
.BindFlags
);
1614 ok(d3d11_desc
.CPUAccessFlags
== desc
.CPUAccessFlags
,
1615 "Test %u: Got unexpected CPUAccessFlags %#x.\n", i
, d3d11_desc
.CPUAccessFlags
);
1616 ok(d3d11_desc
.MiscFlags
== current
->expected_misc_flags
,
1617 "Test %u: Got unexpected MiscFlags %#x.\n", i
, d3d11_desc
.MiscFlags
);
1618 ok(d3d11_desc
.StructureByteStride
== 0,
1619 "Test %u: Got unexpected StructureByteStride %u.\n", i
, d3d11_desc
.StructureByteStride
);
1621 d3d11_device
= NULL
;
1622 ID3D11Buffer_GetDevice(d3d11_buffer
, &d3d11_device
);
1623 ok(!!d3d11_device
, "Test %u: Got NULL, expected device pointer.\n", i
);
1624 ID3D11Device_Release(d3d11_device
);
1626 ID3D11Buffer_Release(d3d11_buffer
);
1629 refcount
= ID3D10Device_Release(device
);
1630 ok(!refcount
, "Device has %u references left.\n", refcount
);
1633 static void test_create_depthstencil_view(void)
1635 D3D10_DEPTH_STENCIL_VIEW_DESC dsv_desc
;
1636 D3D10_TEXTURE2D_DESC texture_desc
;
1637 ULONG refcount
, expected_refcount
;
1638 ID3D10DepthStencilView
*dsview
;
1639 ID3D10Device
*device
, *tmp
;
1640 ID3D10Texture2D
*texture
;
1645 #define FMT_UNKNOWN DXGI_FORMAT_UNKNOWN
1646 #define D24S8 DXGI_FORMAT_D24_UNORM_S8_UINT
1647 #define R24G8_TL DXGI_FORMAT_R24G8_TYPELESS
1648 #define DIM_UNKNOWN D3D10_DSV_DIMENSION_UNKNOWN
1649 #define TEX_1D D3D10_DSV_DIMENSION_TEXTURE1D
1650 #define TEX_1D_ARRAY D3D10_DSV_DIMENSION_TEXTURE1DARRAY
1651 #define TEX_2D D3D10_DSV_DIMENSION_TEXTURE2D
1652 #define TEX_2D_ARRAY D3D10_DSV_DIMENSION_TEXTURE2DARRAY
1653 #define TEX_2DMS D3D10_DSV_DIMENSION_TEXTURE2DMS
1654 #define TEX_2DMS_ARR D3D10_DSV_DIMENSION_TEXTURE2DMSARRAY
1659 unsigned int miplevel_count
;
1660 unsigned int array_size
;
1663 struct dsv_desc dsv_desc
;
1664 struct dsv_desc expected_dsv_desc
;
1668 {{ 1, 1, D24S8
}, {0}, {D24S8
, TEX_2D
, 0}},
1669 {{10, 1, D24S8
}, {0}, {D24S8
, TEX_2D
, 0}},
1670 {{10, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2D
, 0}, {D24S8
, TEX_2D
, 0}},
1671 {{10, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2D
, 1}, {D24S8
, TEX_2D
, 1}},
1672 {{10, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2D
, 9}, {D24S8
, TEX_2D
, 9}},
1673 {{ 1, 1, R24G8_TL
}, {D24S8
, TEX_2D
, 0}, {D24S8
, TEX_2D
, 0}},
1674 {{10, 1, R24G8_TL
}, {D24S8
, TEX_2D
, 0}, {D24S8
, TEX_2D
, 0}},
1675 {{ 1, 4, D24S8
}, {0}, {D24S8
, TEX_2D_ARRAY
, 0, 0, 4}},
1676 {{10, 4, D24S8
}, {0}, {D24S8
, TEX_2D_ARRAY
, 0, 0, 4}},
1677 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 0, ~0u}, {D24S8
, TEX_2D_ARRAY
, 0, 0, 4}},
1678 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 1, 0, ~0u}, {D24S8
, TEX_2D_ARRAY
, 1, 0, 4}},
1679 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 3, 0, ~0u}, {D24S8
, TEX_2D_ARRAY
, 3, 0, 4}},
1680 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 5, 0, ~0u}, {D24S8
, TEX_2D_ARRAY
, 5, 0, 4}},
1681 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 9, 0, ~0u}, {D24S8
, TEX_2D_ARRAY
, 9, 0, 4}},
1682 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 1, ~0u}, {D24S8
, TEX_2D_ARRAY
, 0, 1, 3}},
1683 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 2, ~0u}, {D24S8
, TEX_2D_ARRAY
, 0, 2, 2}},
1684 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 3, ~0u}, {D24S8
, TEX_2D_ARRAY
, 0, 3, 1}},
1685 {{ 1, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS
}, {D24S8
, TEX_2DMS
}},
1686 {{ 1, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS
}, {D24S8
, TEX_2DMS
}},
1687 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS
}, {D24S8
, TEX_2DMS
}},
1688 {{ 1, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 1}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 1}},
1689 {{ 1, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, ~0u}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 1}},
1690 {{10, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 1}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 1}},
1691 {{10, 1, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, ~0u}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 1}},
1692 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 1}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 1}},
1693 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 4}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 4}},
1694 {{10, 4, D24S8
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, ~0u}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 4}},
1700 unsigned int miplevel_count
;
1701 unsigned int array_size
;
1704 struct dsv_desc dsv_desc
;
1706 invalid_desc_tests
[] =
1708 {{1, 1, D24S8
}, {D24S8
, DIM_UNKNOWN
}},
1709 {{6, 4, D24S8
}, {D24S8
, DIM_UNKNOWN
}},
1710 {{1, 1, D24S8
}, {D24S8
, TEX_1D
, 0}},
1711 {{1, 1, D24S8
}, {D24S8
, TEX_1D_ARRAY
, 0, 0, 1}},
1712 {{1, 1, D24S8
}, {R24G8_TL
, TEX_2D
, 0}},
1713 {{1, 1, R24G8_TL
}, {FMT_UNKNOWN
, TEX_2D
, 0}},
1714 {{1, 1, D24S8
}, {D24S8
, TEX_2D
, 1}},
1715 {{1, 1, D24S8
}, {D24S8
, TEX_2D_ARRAY
, 0, 0, 0}},
1716 {{1, 1, D24S8
}, {D24S8
, TEX_2D_ARRAY
, 1, 0, 1}},
1717 {{1, 1, D24S8
}, {D24S8
, TEX_2D_ARRAY
, 0, 0, 2}},
1718 {{1, 1, D24S8
}, {D24S8
, TEX_2D_ARRAY
, 0, 1, 1}},
1719 {{1, 1, D24S8
}, {D24S8
, TEX_2DMS_ARR
, 0, 0, 2}},
1720 {{1, 1, D24S8
}, {D24S8
, TEX_2DMS_ARR
, 0, 1, 1}},
1733 if (!(device
= create_device()))
1735 skip("Failed to create device.\n");
1739 texture_desc
.Width
= 512;
1740 texture_desc
.Height
= 512;
1741 texture_desc
.MipLevels
= 1;
1742 texture_desc
.ArraySize
= 1;
1743 texture_desc
.Format
= DXGI_FORMAT_D24_UNORM_S8_UINT
;
1744 texture_desc
.SampleDesc
.Count
= 1;
1745 texture_desc
.SampleDesc
.Quality
= 0;
1746 texture_desc
.Usage
= D3D10_USAGE_DEFAULT
;
1747 texture_desc
.BindFlags
= D3D10_BIND_DEPTH_STENCIL
;
1748 texture_desc
.CPUAccessFlags
= 0;
1749 texture_desc
.MiscFlags
= 0;
1751 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
1752 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
1754 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
1755 hr
= ID3D10Device_CreateDepthStencilView(device
, (ID3D10Resource
*)texture
, NULL
, &dsview
);
1756 ok(SUCCEEDED(hr
), "Failed to create a depthstencil view, hr %#x.\n", hr
);
1757 refcount
= get_refcount((IUnknown
*)device
);
1758 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
1760 expected_refcount
= refcount
+ 1;
1761 ID3D10DepthStencilView_GetDevice(dsview
, &tmp
);
1762 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
1763 refcount
= get_refcount((IUnknown
*)device
);
1764 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
1765 ID3D10Device_Release(tmp
);
1767 memset(&dsv_desc
, 0, sizeof(dsv_desc
));
1768 ID3D10DepthStencilView_GetDesc(dsview
, &dsv_desc
);
1769 ok(dsv_desc
.Format
== texture_desc
.Format
, "Got unexpected format %#x.\n", dsv_desc
.Format
);
1770 ok(dsv_desc
.ViewDimension
== D3D10_DSV_DIMENSION_TEXTURE2D
,
1771 "Got unexpected view dimension %#x.\n", dsv_desc
.ViewDimension
);
1772 ok(!U(dsv_desc
).Texture2D
.MipSlice
, "Got unexpected mip slice %u.\n", U(dsv_desc
).Texture2D
.MipSlice
);
1774 ID3D10DepthStencilView_Release(dsview
);
1775 ID3D10Texture2D_Release(texture
);
1777 for (i
= 0; i
< sizeof(tests
) / sizeof(*tests
); ++i
)
1779 D3D10_DEPTH_STENCIL_VIEW_DESC
*current_desc
;
1781 texture_desc
.MipLevels
= tests
[i
].texture
.miplevel_count
;
1782 texture_desc
.ArraySize
= tests
[i
].texture
.array_size
;
1783 texture_desc
.Format
= tests
[i
].texture
.format
;
1785 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
1786 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
1788 if (tests
[i
].dsv_desc
.dimension
== D3D10_DSV_DIMENSION_UNKNOWN
)
1790 current_desc
= NULL
;
1794 current_desc
= &dsv_desc
;
1795 get_dsv_desc(current_desc
, &tests
[i
].dsv_desc
);
1798 hr
= ID3D10Device_CreateDepthStencilView(device
, (ID3D10Resource
*)texture
, current_desc
, &dsview
);
1799 ok(SUCCEEDED(hr
), "Test %u: Failed to create depth stencil view, hr %#x.\n", i
, hr
);
1801 hr
= ID3D10DepthStencilView_QueryInterface(dsview
, &IID_ID3D11DepthStencilView
, (void **)&iface
);
1802 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
1803 "Test %u: Depth stencil view should implement ID3D11DepthStencilView.\n", i
);
1804 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
1806 memset(&dsv_desc
, 0, sizeof(dsv_desc
));
1807 ID3D10DepthStencilView_GetDesc(dsview
, &dsv_desc
);
1808 check_dsv_desc(&dsv_desc
, &tests
[i
].expected_dsv_desc
);
1810 ID3D10DepthStencilView_Release(dsview
);
1811 ID3D10Texture2D_Release(texture
);
1814 for (i
= 0; i
< sizeof(invalid_desc_tests
) / sizeof(*invalid_desc_tests
); ++i
)
1816 texture_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
1817 texture_desc
.ArraySize
= invalid_desc_tests
[i
].texture
.array_size
;
1818 texture_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
1820 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
1821 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
1823 get_dsv_desc(&dsv_desc
, &invalid_desc_tests
[i
].dsv_desc
);
1824 hr
= ID3D10Device_CreateDepthStencilView(device
, (ID3D10Resource
*)texture
, &dsv_desc
, &dsview
);
1825 ok(hr
== E_INVALIDARG
, "Test %u: Got unexpected hr %#x.\n", i
, hr
);
1827 ID3D10Texture2D_Release(texture
);
1830 refcount
= ID3D10Device_Release(device
);
1831 ok(!refcount
, "Device has %u references left.\n", refcount
);
1834 static void test_depthstencil_view_interfaces(void)
1836 D3D11_DEPTH_STENCIL_VIEW_DESC d3d11_dsv_desc
;
1837 D3D10_DEPTH_STENCIL_VIEW_DESC dsv_desc
;
1838 ID3D11DepthStencilView
*d3d11_dsview
;
1839 D3D10_TEXTURE2D_DESC texture_desc
;
1840 ID3D10DepthStencilView
*dsview
;
1841 ID3D10Texture2D
*texture
;
1842 ID3D10Device
*device
;
1846 if (!(device
= create_device()))
1848 skip("Failed to create device.\n");
1852 texture_desc
.Width
= 512;
1853 texture_desc
.Height
= 512;
1854 texture_desc
.MipLevels
= 1;
1855 texture_desc
.ArraySize
= 1;
1856 texture_desc
.Format
= DXGI_FORMAT_D24_UNORM_S8_UINT
;
1857 texture_desc
.SampleDesc
.Count
= 1;
1858 texture_desc
.SampleDesc
.Quality
= 0;
1859 texture_desc
.Usage
= D3D10_USAGE_DEFAULT
;
1860 texture_desc
.BindFlags
= D3D10_BIND_DEPTH_STENCIL
;
1861 texture_desc
.CPUAccessFlags
= 0;
1862 texture_desc
.MiscFlags
= 0;
1864 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
1865 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
1867 dsv_desc
.Format
= texture_desc
.Format
;
1868 dsv_desc
.ViewDimension
= D3D10_DSV_DIMENSION_TEXTURE2D
;
1869 U(dsv_desc
).Texture2D
.MipSlice
= 0;
1871 hr
= ID3D10Device_CreateDepthStencilView(device
, (ID3D10Resource
*)texture
, &dsv_desc
, &dsview
);
1872 ok(SUCCEEDED(hr
), "Failed to create a depthstencil view, hr %#x.\n", hr
);
1874 hr
= ID3D10DepthStencilView_QueryInterface(dsview
, &IID_ID3D11DepthStencilView
, (void **)&d3d11_dsview
);
1875 ID3D10DepthStencilView_Release(dsview
);
1876 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
1877 "Depth stencil view should implement ID3D11DepthStencilView.\n");
1881 ID3D11DepthStencilView_GetDesc(d3d11_dsview
, &d3d11_dsv_desc
);
1882 ok(d3d11_dsv_desc
.Format
== dsv_desc
.Format
, "Got unexpected format %#x.\n", d3d11_dsv_desc
.Format
);
1883 ok(d3d11_dsv_desc
.ViewDimension
== (D3D11_DSV_DIMENSION
)dsv_desc
.ViewDimension
,
1884 "Got unexpected view dimension %u.\n", d3d11_dsv_desc
.ViewDimension
);
1885 ok(!d3d11_dsv_desc
.Flags
, "Got unexpected flags %#x.\n", d3d11_dsv_desc
.Flags
);
1886 ok(U(d3d11_dsv_desc
).Texture2D
.MipSlice
== U(dsv_desc
).Texture2D
.MipSlice
,
1887 "Got unexpected mip slice %u.\n", U(d3d11_dsv_desc
).Texture2D
.MipSlice
);
1889 ID3D11DepthStencilView_Release(d3d11_dsview
);
1893 win_skip("D3D11 is not available.\n");
1896 ID3D10Texture2D_Release(texture
);
1898 refcount
= ID3D10Device_Release(device
);
1899 ok(!refcount
, "Device has %u references left.\n", refcount
);
1902 static void test_create_rendertarget_view(void)
1904 D3D10_RENDER_TARGET_VIEW_DESC rtv_desc
;
1905 D3D10_TEXTURE3D_DESC texture3d_desc
;
1906 D3D10_TEXTURE2D_DESC texture2d_desc
;
1907 D3D10_SUBRESOURCE_DATA data
= {0};
1908 ULONG refcount
, expected_refcount
;
1909 D3D10_BUFFER_DESC buffer_desc
;
1910 ID3D10RenderTargetView
*rtview
;
1911 ID3D10Device
*device
, *tmp
;
1912 ID3D10Texture3D
*texture3d
;
1913 ID3D10Texture2D
*texture2d
;
1914 ID3D10Resource
*texture
;
1915 ID3D10Buffer
*buffer
;
1920 #define FMT_UNKNOWN DXGI_FORMAT_UNKNOWN
1921 #define RGBA8_UNORM DXGI_FORMAT_R8G8B8A8_UNORM
1922 #define RGBA8_TL DXGI_FORMAT_R8G8B8A8_TYPELESS
1923 #define DIM_UNKNOWN D3D10_RTV_DIMENSION_UNKNOWN
1924 #define TEX_1D D3D10_RTV_DIMENSION_TEXTURE1D
1925 #define TEX_1D_ARRAY D3D10_RTV_DIMENSION_TEXTURE1DARRAY
1926 #define TEX_2D D3D10_RTV_DIMENSION_TEXTURE2D
1927 #define TEX_2D_ARRAY D3D10_RTV_DIMENSION_TEXTURE2DARRAY
1928 #define TEX_2DMS D3D10_RTV_DIMENSION_TEXTURE2DMS
1929 #define TEX_2DMS_ARR D3D10_RTV_DIMENSION_TEXTURE2DMSARRAY
1930 #define TEX_3D D3D10_RTV_DIMENSION_TEXTURE3D
1935 unsigned int miplevel_count
;
1936 unsigned int depth_or_array_size
;
1939 struct rtv_desc rtv_desc
;
1940 struct rtv_desc expected_rtv_desc
;
1944 {{ 1, 1, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D
, 0}},
1945 {{10, 1, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D
, 0}},
1946 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D
, 0}, {RGBA8_UNORM
, TEX_2D
, 0}},
1947 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D
, 1}, {RGBA8_UNORM
, TEX_2D
, 1}},
1948 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D
, 9}, {RGBA8_UNORM
, TEX_2D
, 9}},
1949 {{ 1, 1, RGBA8_TL
}, {RGBA8_UNORM
, TEX_2D
, 0}, {RGBA8_UNORM
, TEX_2D
, 0}},
1950 {{10, 1, RGBA8_TL
}, {RGBA8_UNORM
, TEX_2D
, 0}, {RGBA8_UNORM
, TEX_2D
, 0}},
1951 {{ 1, 4, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 4}},
1952 {{10, 4, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 4}},
1953 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 4}},
1954 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 1, 0, 4}},
1955 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 3, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 3, 0, 4}},
1956 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 5, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 5, 0, 4}},
1957 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 9, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 9, 0, 4}},
1958 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 1, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 3}},
1959 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 2, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 2, 2}},
1960 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 3, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 3, 1}},
1961 {{ 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS
}, {RGBA8_UNORM
, TEX_2DMS
}},
1962 {{ 1, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS
}, {RGBA8_UNORM
, TEX_2DMS
}},
1963 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS
}, {RGBA8_UNORM
, TEX_2DMS
}},
1964 {{ 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 1}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 1}},
1965 {{ 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 1}},
1966 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 1}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 1}},
1967 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 1}},
1968 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 1}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 1}},
1969 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, 4}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 4}},
1970 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 4}},
1971 {{ 1, 6, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 6}},
1972 {{ 2, 6, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 6}},
1973 {{ 2, 6, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 6}},
1974 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 2}},
1975 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 2}},
1976 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 1, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 1, 3}},
1977 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 2, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 2, 2}},
1978 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 3, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 3, 1}},
1979 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 1, 1}, {RGBA8_UNORM
, TEX_3D
, 0, 1, 1}},
1980 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 1, 1}, {RGBA8_UNORM
, TEX_3D
, 1, 1, 1}},
1981 {{ 2, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 1, ~0u}, {RGBA8_UNORM
, TEX_3D
, 1, 1, 1}},
1982 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 8}},
1983 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 4}},
1984 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 2, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 2, 0, 2}},
1985 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 3, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 3, 0, 1}},
1986 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 4, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 4, 0, 1}},
1987 {{ 6, 8, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 5, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 5, 0, 1}},
1993 D3D10_RTV_DIMENSION dimension
;
1994 unsigned int miplevel_count
;
1995 unsigned int depth_or_array_size
;
1998 struct rtv_desc rtv_desc
;
2000 invalid_desc_tests
[] =
2002 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, DIM_UNKNOWN
}},
2003 {{TEX_2D
, 6, 4, RGBA8_UNORM
}, {RGBA8_UNORM
, DIM_UNKNOWN
}},
2004 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0}},
2005 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 0, 1}},
2006 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 1}},
2007 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, ~0u}},
2008 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_2D
, 0}},
2009 {{TEX_2D
, 1, 1, RGBA8_TL
}, {FMT_UNKNOWN
, TEX_2D
, 0}},
2010 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 1}},
2011 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 0}},
2012 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 1, 0, 1}},
2013 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 2}},
2014 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 1}},
2015 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 0, 2}},
2016 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 1}},
2017 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0}},
2018 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 0, 1}},
2019 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0}},
2020 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 1}},
2021 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0}},
2022 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 0, 1}},
2023 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0}},
2024 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 1}},
2025 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 0}},
2026 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 1}},
2027 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_3D
, 0, 0, 1}},
2028 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_TL
, TEX_3D
, 0, 0, 1}},
2029 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0, 9}},
2030 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 3, 0, 2}},
2031 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 2, 0, 4}},
2032 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 0, 8}},
2033 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 8, ~0u}},
2034 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 4, ~0u}},
2035 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 2, 2, ~0u}},
2036 {{TEX_3D
, 4, 8, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 3, 1, ~0u}},
2050 if (!(device
= create_device()))
2052 skip("Failed to create device.\n");
2056 buffer_desc
.ByteWidth
= 1024;
2057 buffer_desc
.Usage
= D3D10_USAGE_DEFAULT
;
2058 buffer_desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
2059 buffer_desc
.CPUAccessFlags
= 0;
2060 buffer_desc
.MiscFlags
= 0;
2062 hr
= ID3D10Device_CreateBuffer(device
, &buffer_desc
, &data
, &buffer
);
2063 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
2065 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
2066 hr
= ID3D10Device_CreateBuffer(device
, &buffer_desc
, NULL
, &buffer
);
2067 ok(SUCCEEDED(hr
), "Failed to create a buffer, hr %#x.\n", hr
);
2068 refcount
= get_refcount((IUnknown
*)device
);
2069 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2071 expected_refcount
= refcount
+ 1;
2072 ID3D10Buffer_GetDevice(buffer
, &tmp
);
2073 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2074 refcount
= get_refcount((IUnknown
*)device
);
2075 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2076 ID3D10Device_Release(tmp
);
2078 rtv_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
2079 rtv_desc
.ViewDimension
= D3D10_RTV_DIMENSION_BUFFER
;
2080 U(rtv_desc
).Buffer
.ElementOffset
= 0;
2081 U(rtv_desc
).Buffer
.ElementWidth
= 64;
2083 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
2084 hr
= ID3D10Device_CreateRenderTargetView(device
, (ID3D10Resource
*)buffer
, &rtv_desc
, &rtview
);
2085 ok(SUCCEEDED(hr
), "Failed to create a rendertarget view, hr %#x.\n", hr
);
2086 refcount
= get_refcount((IUnknown
*)device
);
2087 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2089 expected_refcount
= refcount
+ 1;
2090 ID3D10RenderTargetView_GetDevice(rtview
, &tmp
);
2091 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2092 refcount
= get_refcount((IUnknown
*)device
);
2093 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2094 ID3D10Device_Release(tmp
);
2096 hr
= ID3D10RenderTargetView_QueryInterface(rtview
, &IID_ID3D11RenderTargetView
, (void **)&iface
);
2097 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
2098 "Render target view should implement ID3D11RenderTargetView.\n");
2099 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
2101 ID3D10RenderTargetView_Release(rtview
);
2102 ID3D10Buffer_Release(buffer
);
2104 texture2d_desc
.Width
= 512;
2105 texture2d_desc
.Height
= 512;
2106 texture2d_desc
.SampleDesc
.Count
= 1;
2107 texture2d_desc
.SampleDesc
.Quality
= 0;
2108 texture2d_desc
.Usage
= D3D10_USAGE_DEFAULT
;
2109 texture2d_desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
2110 texture2d_desc
.CPUAccessFlags
= 0;
2111 texture2d_desc
.MiscFlags
= 0;
2113 texture3d_desc
.Width
= 64;
2114 texture3d_desc
.Height
= 64;
2115 texture3d_desc
.Usage
= D3D10_USAGE_DEFAULT
;
2116 texture3d_desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
2117 texture3d_desc
.CPUAccessFlags
= 0;
2118 texture3d_desc
.MiscFlags
= 0;
2120 for (i
= 0; i
< sizeof(tests
) / sizeof(*tests
); ++i
)
2122 D3D10_RENDER_TARGET_VIEW_DESC
*current_desc
;
2124 if (tests
[i
].expected_rtv_desc
.dimension
!= D3D10_RTV_DIMENSION_TEXTURE3D
)
2126 texture2d_desc
.MipLevels
= tests
[i
].texture
.miplevel_count
;
2127 texture2d_desc
.ArraySize
= tests
[i
].texture
.depth_or_array_size
;
2128 texture2d_desc
.Format
= tests
[i
].texture
.format
;
2130 hr
= ID3D10Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, &texture2d
);
2131 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
2132 texture
= (ID3D10Resource
*)texture2d
;
2136 texture3d_desc
.MipLevels
= tests
[i
].texture
.miplevel_count
;
2137 texture3d_desc
.Depth
= tests
[i
].texture
.depth_or_array_size
;
2138 texture3d_desc
.Format
= tests
[i
].texture
.format
;
2140 hr
= ID3D10Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &texture3d
);
2141 ok(SUCCEEDED(hr
), "Test %u: Failed to create 3d texture, hr %#x.\n", i
, hr
);
2142 texture
= (ID3D10Resource
*)texture3d
;
2145 if (tests
[i
].rtv_desc
.dimension
== D3D10_RTV_DIMENSION_UNKNOWN
)
2147 current_desc
= NULL
;
2151 current_desc
= &rtv_desc
;
2152 get_rtv_desc(current_desc
, &tests
[i
].rtv_desc
);
2155 hr
= ID3D10Device_CreateRenderTargetView(device
, texture
, current_desc
, &rtview
);
2156 ok(SUCCEEDED(hr
), "Test %u: Failed to create render target view, hr %#x.\n", i
, hr
);
2158 hr
= ID3D10RenderTargetView_QueryInterface(rtview
, &IID_ID3D11RenderTargetView
, (void **)&iface
);
2159 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
2160 "Test %u: Render target view should implement ID3D11RenderTargetView.\n", i
);
2161 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
2163 memset(&rtv_desc
, 0, sizeof(rtv_desc
));
2164 ID3D10RenderTargetView_GetDesc(rtview
, &rtv_desc
);
2165 check_rtv_desc(&rtv_desc
, &tests
[i
].expected_rtv_desc
);
2167 ID3D10RenderTargetView_Release(rtview
);
2168 ID3D10Resource_Release(texture
);
2171 for (i
= 0; i
< sizeof(invalid_desc_tests
) / sizeof(*invalid_desc_tests
); ++i
)
2173 assert(invalid_desc_tests
[i
].texture
.dimension
== D3D10_RTV_DIMENSION_TEXTURE2D
2174 || invalid_desc_tests
[i
].texture
.dimension
== D3D10_RTV_DIMENSION_TEXTURE3D
);
2176 if (invalid_desc_tests
[i
].texture
.dimension
!= D3D10_RTV_DIMENSION_TEXTURE3D
)
2178 texture2d_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
2179 texture2d_desc
.ArraySize
= invalid_desc_tests
[i
].texture
.depth_or_array_size
;
2180 texture2d_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
2182 hr
= ID3D10Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, &texture2d
);
2183 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
2184 texture
= (ID3D10Resource
*)texture2d
;
2188 texture3d_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
2189 texture3d_desc
.Depth
= invalid_desc_tests
[i
].texture
.depth_or_array_size
;
2190 texture3d_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
2192 hr
= ID3D10Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &texture3d
);
2193 ok(SUCCEEDED(hr
), "Test %u: Failed to create 3d texture, hr %#x.\n", i
, hr
);
2194 texture
= (ID3D10Resource
*)texture3d
;
2197 get_rtv_desc(&rtv_desc
, &invalid_desc_tests
[i
].rtv_desc
);
2198 hr
= ID3D10Device_CreateRenderTargetView(device
, texture
, &rtv_desc
, &rtview
);
2199 ok(hr
== E_INVALIDARG
, "Test %u: Got unexpected hr %#x.\n", i
, hr
);
2201 ID3D10Resource_Release(texture
);
2204 refcount
= ID3D10Device_Release(device
);
2205 ok(!refcount
, "Device has %u references left.\n", refcount
);
2208 static void test_render_target_views(void)
2212 UINT miplevel_count
;
2218 D3D10_RTV_DIMENSION dimension
;
2219 unsigned int miplevel_idx
;
2220 unsigned int layer_idx
;
2221 unsigned int layer_count
;
2224 static const struct vec4 red
= {1.0f
, 0.0f
, 0.0f
, 1.0f
};
2227 struct texture texture
;
2228 struct rtv_desc rtv
;
2229 DWORD expected_colors
[4];
2233 {{2, 1}, {DXGI_FORMAT_UNKNOWN
, D3D10_RTV_DIMENSION_TEXTURE2D
, 0},
2234 {0xff0000ff, 0x00000000}},
2235 {{2, 1}, {DXGI_FORMAT_UNKNOWN
, D3D10_RTV_DIMENSION_TEXTURE2D
, 1},
2236 {0x00000000, 0xff0000ff}},
2237 {{2, 1}, {DXGI_FORMAT_UNKNOWN
, D3D10_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 0, 1},
2238 {0xff0000ff, 0x00000000}},
2239 {{2, 1}, {DXGI_FORMAT_UNKNOWN
, D3D10_RTV_DIMENSION_TEXTURE2DARRAY
, 1, 0, 1},
2240 {0x00000000, 0xff0000ff}},
2241 {{1, 4}, {DXGI_FORMAT_UNKNOWN
, D3D10_RTV_DIMENSION_TEXTURE2D
, 0},
2242 {0xff0000ff, 0x00000000, 0x00000000, 0x00000000}},
2243 {{1, 4}, {DXGI_FORMAT_UNKNOWN
, D3D10_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 0, 1},
2244 {0xff0000ff, 0x00000000, 0x00000000, 0x00000000}},
2245 {{1, 4}, {DXGI_FORMAT_UNKNOWN
, D3D10_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 1, 1},
2246 {0x00000000, 0xff0000ff, 0x00000000, 0x00000000}},
2247 {{1, 4}, {DXGI_FORMAT_UNKNOWN
, D3D10_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 2, 1},
2248 {0x00000000, 0x00000000, 0xff0000ff, 0x00000000}},
2249 {{1, 4}, {DXGI_FORMAT_UNKNOWN
, D3D10_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 3, 1},
2250 {0x00000000, 0x00000000, 0x00000000, 0xff0000ff}},
2251 {{1, 4}, {DXGI_FORMAT_UNKNOWN
, D3D10_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 0, 4},
2252 {0xff0000ff, 0x00000000, 0x00000000, 0x00000000}},
2253 {{2, 2}, {DXGI_FORMAT_UNKNOWN
, D3D10_RTV_DIMENSION_TEXTURE2D
, 0},
2254 {0xff0000ff, 0x00000000, 0x00000000, 0x00000000}},
2255 {{2, 2}, {DXGI_FORMAT_UNKNOWN
, D3D10_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 0, 1},
2256 {0xff0000ff, 0x00000000, 0x00000000, 0x00000000}},
2257 {{2, 2}, {DXGI_FORMAT_UNKNOWN
, D3D10_RTV_DIMENSION_TEXTURE2DARRAY
, 0, 1, 1},
2258 {0x00000000, 0x00000000, 0xff0000ff, 0x00000000}},
2259 {{2, 2}, {DXGI_FORMAT_UNKNOWN
, D3D10_RTV_DIMENSION_TEXTURE2DARRAY
, 1, 0, 1},
2260 {0x00000000, 0xff0000ff, 0x00000000, 0x00000000}},
2261 {{2, 2}, {DXGI_FORMAT_UNKNOWN
, D3D10_RTV_DIMENSION_TEXTURE2DARRAY
, 1, 1, 1},
2262 {0x00000000, 0x00000000, 0x00000000, 0xff0000ff}},
2265 struct d3d10core_test_context test_context
;
2266 D3D10_RENDER_TARGET_VIEW_DESC rtv_desc
;
2267 D3D10_TEXTURE2D_DESC texture_desc
;
2268 ID3D10RenderTargetView
*rtv
;
2269 ID3D10Texture2D
*texture
;
2270 ID3D10Device
*device
;
2274 if (!init_test_context(&test_context
))
2277 device
= test_context
.device
;
2279 texture_desc
.Width
= 32;
2280 texture_desc
.Height
= 32;
2281 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
2282 texture_desc
.SampleDesc
.Count
= 1;
2283 texture_desc
.SampleDesc
.Quality
= 0;
2284 texture_desc
.Usage
= D3D10_USAGE_DEFAULT
;
2285 texture_desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
2286 texture_desc
.CPUAccessFlags
= 0;
2287 texture_desc
.MiscFlags
= 0;
2289 for (i
= 0; i
< sizeof(tests
) / sizeof(*tests
); ++i
)
2291 const struct test
*test
= &tests
[i
];
2292 unsigned int sub_resource_count
;
2294 texture_desc
.MipLevels
= test
->texture
.miplevel_count
;
2295 texture_desc
.ArraySize
= test
->texture
.array_size
;
2297 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
2298 ok(SUCCEEDED(hr
), "Test %u: Failed to create texture, hr %#x.\n", i
, hr
);
2300 get_rtv_desc(&rtv_desc
, &test
->rtv
);
2301 hr
= ID3D10Device_CreateRenderTargetView(device
, (ID3D10Resource
*)texture
, &rtv_desc
, &rtv
);
2302 ok(SUCCEEDED(hr
), "Test %u: Failed to create render target view, hr %#x.\n", i
, hr
);
2304 ID3D10Device_OMSetRenderTargets(device
, 1, &rtv
, NULL
);
2305 draw_color_quad(&test_context
, &red
);
2307 sub_resource_count
= texture_desc
.MipLevels
* texture_desc
.ArraySize
;
2308 assert(sub_resource_count
<= sizeof(test
->expected_colors
) / sizeof(*test
->expected_colors
));
2309 for (j
= 0; j
< sub_resource_count
; ++j
)
2310 check_texture_sub_resource_color(texture
, j
, test
->expected_colors
[j
], 1);
2312 ID3D10RenderTargetView_Release(rtv
);
2313 ID3D10Texture2D_Release(texture
);
2316 release_test_context(&test_context
);
2319 static void test_create_shader_resource_view(void)
2321 D3D10_SHADER_RESOURCE_VIEW_DESC srv_desc
;
2322 D3D10_TEXTURE3D_DESC texture3d_desc
;
2323 D3D10_TEXTURE2D_DESC texture2d_desc
;
2324 ULONG refcount
, expected_refcount
;
2325 ID3D10ShaderResourceView
*srview
;
2326 ID3D10Device
*device
, *tmp
;
2327 ID3D10Texture3D
*texture3d
;
2328 ID3D10Texture2D
*texture2d
;
2329 ID3D10Resource
*texture
;
2330 ID3D10Buffer
*buffer
;
2335 #define FMT_UNKNOWN DXGI_FORMAT_UNKNOWN
2336 #define RGBA8_UNORM DXGI_FORMAT_R8G8B8A8_UNORM
2337 #define RGBA8_TL DXGI_FORMAT_R8G8B8A8_TYPELESS
2338 #define DIM_UNKNOWN D3D10_SRV_DIMENSION_UNKNOWN
2339 #define TEX_1D D3D10_SRV_DIMENSION_TEXTURE1D
2340 #define TEX_1D_ARRAY D3D10_SRV_DIMENSION_TEXTURE1DARRAY
2341 #define TEX_2D D3D10_SRV_DIMENSION_TEXTURE2D
2342 #define TEX_2D_ARRAY D3D10_SRV_DIMENSION_TEXTURE2DARRAY
2343 #define TEX_2DMS D3D10_SRV_DIMENSION_TEXTURE2DMS
2344 #define TEX_2DMS_ARR D3D10_SRV_DIMENSION_TEXTURE2DMSARRAY
2345 #define TEX_3D D3D10_SRV_DIMENSION_TEXTURE3D
2346 #define TEX_CUBE D3D10_SRV_DIMENSION_TEXTURECUBE
2351 unsigned int miplevel_count
;
2352 unsigned int depth_or_array_size
;
2355 struct srv_desc srv_desc
;
2356 struct srv_desc expected_srv_desc
;
2360 {{10, 1, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D
, 0, 10}},
2361 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D
, 0, ~0u}, {RGBA8_UNORM
, TEX_2D
, 0, 10}},
2362 {{10, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0, ~0u}, {RGBA8_UNORM
, TEX_2D
, 0, 10}},
2363 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D
, 0, 10}, {RGBA8_UNORM
, TEX_2D
, 0, 10}},
2364 {{ 1, 1, RGBA8_TL
}, {RGBA8_UNORM
, TEX_2D
, 0, ~0u}, {RGBA8_UNORM
, TEX_2D
, 0, 1}},
2365 {{10, 1, RGBA8_TL
}, {RGBA8_UNORM
, TEX_2D
, 0, ~0u}, {RGBA8_UNORM
, TEX_2D
, 0, 10}},
2366 {{10, 4, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 10, 0, 4}},
2367 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, ~0u, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 10, 0, 4}},
2368 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 1, ~0u, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 1, 9, 0, 4}},
2369 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 3, ~0u, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 3, 7, 0, 4}},
2370 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 5, ~0u, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 5, 5, 0, 4}},
2371 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 9, ~0u, 0, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 9, 1, 0, 4}},
2372 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, ~0u, 1, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 10, 1, 3}},
2373 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, ~0u, 2, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 10, 2, 2}},
2374 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, ~0u, 3, ~0u}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 10, 3, 1}},
2375 {{ 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS
}, {RGBA8_UNORM
, TEX_2DMS
}},
2376 {{ 1, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS
}, {RGBA8_UNORM
, TEX_2DMS
}},
2377 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS
}, {RGBA8_UNORM
, TEX_2DMS
}},
2378 {{ 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 1, 0, 1}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 1}},
2379 {{ 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 1}},
2380 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 1, 0, 1}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 1}},
2381 {{10, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 1}},
2382 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 1, 0, 1}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 1}},
2383 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 1, 0, 4}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 4}},
2384 {{10, 4, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_2DMS_ARR
, 0, 1, 0, ~0u}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 4}},
2385 {{ 1, 12, RGBA8_UNORM
}, {0}, {RGBA8_UNORM
, TEX_3D
, 0, 1}},
2386 {{ 1, 12, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 1}, {RGBA8_UNORM
, TEX_3D
, 0, 1}},
2387 {{ 1, 12, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 1}},
2388 {{ 4, 12, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, ~0u}, {RGBA8_UNORM
, TEX_3D
, 0, 4}},
2389 {{ 2, 6, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_CUBE
, 0, ~0u}, {RGBA8_UNORM
, TEX_CUBE
, 0, 2}},
2390 {{ 2, 6, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_CUBE
, 0, 1}, {RGBA8_UNORM
, TEX_CUBE
, 0, 1}},
2391 {{ 2, 6, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_CUBE
, 1, 1}, {RGBA8_UNORM
, TEX_CUBE
, 1, 1}},
2397 D3D10_SRV_DIMENSION dimension
;
2398 unsigned int miplevel_count
;
2399 unsigned int depth_or_array_size
;
2402 struct srv_desc srv_desc
;
2404 invalid_desc_tests
[] =
2406 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, DIM_UNKNOWN
}},
2407 {{TEX_2D
, 6, 4, RGBA8_UNORM
}, {RGBA8_UNORM
, DIM_UNKNOWN
}},
2408 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0, 1}},
2409 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 1, 0, 1}},
2410 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 1}},
2411 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_2D
, 0, ~0u}},
2412 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_2D
, 0, 1}},
2413 {{TEX_2D
, 1, 1, RGBA8_TL
}, {FMT_UNKNOWN
, TEX_2D
, 0, ~0u}},
2414 {{TEX_2D
, 1, 1, RGBA8_TL
}, {FMT_UNKNOWN
, TEX_2D
, 0, 1}},
2415 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0, 0}},
2416 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0, 2}},
2417 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 1, 1}},
2418 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 0, 0}},
2419 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 0, 0, 1}},
2420 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 0, 0}},
2421 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 2, 0, 1}},
2422 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 1, 1, 0, 1}},
2423 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 0, 2}},
2424 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 1, 1}},
2425 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 0, 2}},
2426 {{TEX_2D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2DMS_ARR
, 0, 1, 1, 1}},
2427 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_CUBE
, 0, 0}},
2428 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_CUBE
, 0, 2}},
2429 {{TEX_2D
, 1, 6, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_CUBE
, 1, 1}},
2430 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0, 1}},
2431 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 1, 0, 1}},
2432 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0, 1}},
2433 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_CUBE
, 0, 1}},
2434 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 0, 1}},
2435 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D
, 0, 1}},
2436 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_1D_ARRAY
, 0, 1, 0, 1}},
2437 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D
, 0, 1}},
2438 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_CUBE
, 0, 1}},
2439 {{TEX_3D
, 1, 9, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_2D_ARRAY
, 0, 1, 0, 1}},
2440 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 0}},
2441 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_TL
, TEX_3D
, 0, 1}},
2442 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 0, 2}},
2443 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {FMT_UNKNOWN
, TEX_3D
, 1, 1}},
2444 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 0, 2}},
2445 {{TEX_3D
, 1, 1, RGBA8_UNORM
}, {RGBA8_UNORM
, TEX_3D
, 1, 1}},
2459 if (!(device
= create_device()))
2461 skip("Failed to create device.\n");
2465 buffer
= create_buffer(device
, D3D10_BIND_SHADER_RESOURCE
, 1024, NULL
);
2467 hr
= ID3D10Device_CreateShaderResourceView(device
, (ID3D10Resource
*)buffer
, NULL
, &srview
);
2468 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
2470 srv_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
2471 srv_desc
.ViewDimension
= D3D10_SRV_DIMENSION_BUFFER
;
2472 U(srv_desc
).Buffer
.ElementOffset
= 0;
2473 U(srv_desc
).Buffer
.ElementWidth
= 64;
2475 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
2476 hr
= ID3D10Device_CreateShaderResourceView(device
, (ID3D10Resource
*)buffer
, &srv_desc
, &srview
);
2477 ok(SUCCEEDED(hr
), "Failed to create a shader resource view, hr %#x.\n", hr
);
2478 refcount
= get_refcount((IUnknown
*)device
);
2479 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2481 expected_refcount
= refcount
+ 1;
2482 ID3D10ShaderResourceView_GetDevice(srview
, &tmp
);
2483 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2484 refcount
= get_refcount((IUnknown
*)device
);
2485 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2486 ID3D10Device_Release(tmp
);
2488 hr
= ID3D10ShaderResourceView_QueryInterface(srview
, &IID_ID3D10ShaderResourceView1
, (void **)&iface
);
2489 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
2490 "Shader resource view should implement ID3D10ShaderResourceView1.\n");
2491 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
2492 hr
= ID3D10ShaderResourceView_QueryInterface(srview
, &IID_ID3D11ShaderResourceView
, (void **)&iface
);
2493 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
2494 "Shader resource view should implement ID3D11ShaderResourceView.\n");
2495 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
2497 ID3D10ShaderResourceView_Release(srview
);
2498 ID3D10Buffer_Release(buffer
);
2500 texture2d_desc
.Width
= 512;
2501 texture2d_desc
.Height
= 512;
2502 texture2d_desc
.SampleDesc
.Count
= 1;
2503 texture2d_desc
.SampleDesc
.Quality
= 0;
2504 texture2d_desc
.Usage
= D3D10_USAGE_DEFAULT
;
2505 texture2d_desc
.BindFlags
= D3D10_BIND_SHADER_RESOURCE
;
2506 texture2d_desc
.CPUAccessFlags
= 0;
2508 texture3d_desc
.Width
= 64;
2509 texture3d_desc
.Height
= 64;
2510 texture3d_desc
.Usage
= D3D10_USAGE_DEFAULT
;
2511 texture3d_desc
.BindFlags
= D3D10_BIND_SHADER_RESOURCE
;
2512 texture3d_desc
.CPUAccessFlags
= 0;
2513 texture3d_desc
.MiscFlags
= 0;
2515 for (i
= 0; i
< sizeof(tests
) / sizeof(*tests
); ++i
)
2517 D3D10_SHADER_RESOURCE_VIEW_DESC
*current_desc
;
2519 if (tests
[i
].expected_srv_desc
.dimension
!= D3D10_SRV_DIMENSION_TEXTURE3D
)
2521 texture2d_desc
.MipLevels
= tests
[i
].texture
.miplevel_count
;
2522 texture2d_desc
.ArraySize
= tests
[i
].texture
.depth_or_array_size
;
2523 texture2d_desc
.Format
= tests
[i
].texture
.format
;
2524 texture2d_desc
.MiscFlags
= 0;
2526 if (tests
[i
].srv_desc
.dimension
== D3D10_SRV_DIMENSION_TEXTURECUBE
)
2527 texture2d_desc
.MiscFlags
|= D3D10_RESOURCE_MISC_TEXTURECUBE
;
2529 hr
= ID3D10Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, &texture2d
);
2530 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
2531 texture
= (ID3D10Resource
*)texture2d
;
2535 texture3d_desc
.MipLevels
= tests
[i
].texture
.miplevel_count
;
2536 texture3d_desc
.Depth
= tests
[i
].texture
.depth_or_array_size
;
2537 texture3d_desc
.Format
= tests
[i
].texture
.format
;
2539 hr
= ID3D10Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &texture3d
);
2540 ok(SUCCEEDED(hr
), "Test %u: Failed to create 3d texture, hr %#x.\n", i
, hr
);
2541 texture
= (ID3D10Resource
*)texture3d
;
2544 if (tests
[i
].srv_desc
.dimension
== D3D10_SRV_DIMENSION_UNKNOWN
)
2546 current_desc
= NULL
;
2550 current_desc
= &srv_desc
;
2551 get_srv_desc(current_desc
, &tests
[i
].srv_desc
);
2554 hr
= ID3D10Device_CreateShaderResourceView(device
, texture
, current_desc
, &srview
);
2555 ok(SUCCEEDED(hr
), "Test %u: Failed to create a shader resource view, hr %#x.\n", i
, hr
);
2557 hr
= ID3D10ShaderResourceView_QueryInterface(srview
, &IID_ID3D10ShaderResourceView1
, (void **)&iface
);
2558 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
2559 "Test %u: Shader resource view should implement ID3D10ShaderResourceView1.\n", i
);
2560 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
2561 hr
= ID3D10ShaderResourceView_QueryInterface(srview
, &IID_ID3D11ShaderResourceView
, (void **)&iface
);
2562 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
2563 "Test %u: Shader resource view should implement ID3D11ShaderResourceView.\n", i
);
2564 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
2566 memset(&srv_desc
, 0, sizeof(srv_desc
));
2567 ID3D10ShaderResourceView_GetDesc(srview
, &srv_desc
);
2568 check_srv_desc(&srv_desc
, &tests
[i
].expected_srv_desc
);
2570 ID3D10ShaderResourceView_Release(srview
);
2571 ID3D10Resource_Release(texture
);
2574 for (i
= 0; i
< sizeof(invalid_desc_tests
) / sizeof(*invalid_desc_tests
); ++i
)
2576 assert(invalid_desc_tests
[i
].texture
.dimension
== D3D10_SRV_DIMENSION_TEXTURE2D
2577 || invalid_desc_tests
[i
].texture
.dimension
== D3D10_SRV_DIMENSION_TEXTURE3D
);
2579 if (invalid_desc_tests
[i
].texture
.dimension
== D3D10_SRV_DIMENSION_TEXTURE2D
)
2581 texture2d_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
2582 texture2d_desc
.ArraySize
= invalid_desc_tests
[i
].texture
.depth_or_array_size
;
2583 texture2d_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
2584 texture2d_desc
.MiscFlags
= 0;
2586 if (invalid_desc_tests
[i
].srv_desc
.dimension
== D3D10_SRV_DIMENSION_TEXTURECUBE
)
2587 texture2d_desc
.MiscFlags
|= D3D10_RESOURCE_MISC_TEXTURECUBE
;
2589 hr
= ID3D10Device_CreateTexture2D(device
, &texture2d_desc
, NULL
, &texture2d
);
2590 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
2591 texture
= (ID3D10Resource
*)texture2d
;
2595 texture3d_desc
.MipLevels
= invalid_desc_tests
[i
].texture
.miplevel_count
;
2596 texture3d_desc
.Depth
= invalid_desc_tests
[i
].texture
.depth_or_array_size
;
2597 texture3d_desc
.Format
= invalid_desc_tests
[i
].texture
.format
;
2599 hr
= ID3D10Device_CreateTexture3D(device
, &texture3d_desc
, NULL
, &texture3d
);
2600 ok(SUCCEEDED(hr
), "Test %u: Failed to create 3d texture, hr %#x.\n", i
, hr
);
2601 texture
= (ID3D10Resource
*)texture3d
;
2604 get_srv_desc(&srv_desc
, &invalid_desc_tests
[i
].srv_desc
);
2605 hr
= ID3D10Device_CreateShaderResourceView(device
, texture
, &srv_desc
, &srview
);
2606 ok(hr
== E_INVALIDARG
, "Test %u: Got unexpected hr %#x.\n", i
, hr
);
2608 ID3D10Resource_Release(texture
);
2611 refcount
= ID3D10Device_Release(device
);
2612 ok(!refcount
, "Device has %u references left.\n", refcount
);
2615 static void test_create_shader(void)
2623 float4 position
: POSITION
;
2624 float3 normal
: NORMAL
;
2629 float4 position
: POSITION
;
2630 float4 diffuse
: COLOR
;
2633 output
main(const input v
)
2637 o
.position
= mul(v
.position
, mat
);
2638 o
.diffuse
= dot((float3
)light
, v
.normal
);
2643 static const DWORD vs_4_0
[] =
2645 0x43425844, 0x3ae813ca, 0x0f034b91, 0x790f3226, 0x6b4a718a, 0x00000001, 0x000001c0,
2646 0x00000003, 0x0000002c, 0x0000007c, 0x000000cc, 0x4e475349, 0x00000048, 0x00000002,
2647 0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f,
2648 0x00000041, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000707, 0x49534f50,
2649 0x4e4f4954, 0x524f4e00, 0x004c414d, 0x4e47534f, 0x00000048, 0x00000002, 0x00000008,
2650 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x00000041,
2651 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x49534f50, 0x4e4f4954,
2652 0x4c4f4300, 0xab00524f, 0x52444853, 0x000000ec, 0x00010040, 0x0000003b, 0x04000059,
2653 0x00208e46, 0x00000000, 0x00000005, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f,
2654 0x00101072, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x001020f2,
2655 0x00000001, 0x08000011, 0x00102012, 0x00000000, 0x00101e46, 0x00000000, 0x00208e46,
2656 0x00000000, 0x00000001, 0x08000011, 0x00102022, 0x00000000, 0x00101e46, 0x00000000,
2657 0x00208e46, 0x00000000, 0x00000002, 0x08000011, 0x00102042, 0x00000000, 0x00101e46,
2658 0x00000000, 0x00208e46, 0x00000000, 0x00000003, 0x08000011, 0x00102082, 0x00000000,
2659 0x00101e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x08000010, 0x001020f2,
2660 0x00000001, 0x00208246, 0x00000000, 0x00000000, 0x00101246, 0x00000001, 0x0100003e,
2663 static const DWORD vs_2_0
[] =
2665 0xfffe0200, 0x002bfffe, 0x42415443, 0x0000001c, 0x00000077, 0xfffe0200, 0x00000002,
2666 0x0000001c, 0x00000100, 0x00000070, 0x00000044, 0x00040002, 0x00000001, 0x0000004c,
2667 0x00000000, 0x0000005c, 0x00000002, 0x00000004, 0x00000060, 0x00000000, 0x6867696c,
2668 0xabab0074, 0x00030001, 0x00040001, 0x00000001, 0x00000000, 0x0074616d, 0x00030003,
2669 0x00040004, 0x00000001, 0x00000000, 0x325f7376, 0x4d00305f, 0x6f726369, 0x74666f73,
2670 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e392072,
2671 0x392e3932, 0x332e3235, 0x00313131, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f,
2672 0x80000003, 0x900f0001, 0x03000009, 0xc0010000, 0x90e40000, 0xa0e40000, 0x03000009,
2673 0xc0020000, 0x90e40000, 0xa0e40001, 0x03000009, 0xc0040000, 0x90e40000, 0xa0e40002,
2674 0x03000009, 0xc0080000, 0x90e40000, 0xa0e40003, 0x03000008, 0xd00f0000, 0xa0e40004,
2675 0x90e40001, 0x0000ffff,
2678 static const DWORD vs_3_0
[] =
2680 0xfffe0300, 0x002bfffe, 0x42415443, 0x0000001c, 0x00000077, 0xfffe0300, 0x00000002,
2681 0x0000001c, 0x00000100, 0x00000070, 0x00000044, 0x00040002, 0x00000001, 0x0000004c,
2682 0x00000000, 0x0000005c, 0x00000002, 0x00000004, 0x00000060, 0x00000000, 0x6867696c,
2683 0xabab0074, 0x00030001, 0x00040001, 0x00000001, 0x00000000, 0x0074616d, 0x00030003,
2684 0x00040004, 0x00000001, 0x00000000, 0x335f7376, 0x4d00305f, 0x6f726369, 0x74666f73,
2685 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e392072,
2686 0x392e3932, 0x332e3235, 0x00313131, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f,
2687 0x80000003, 0x900f0001, 0x0200001f, 0x80000000, 0xe00f0000, 0x0200001f, 0x8000000a,
2688 0xe00f0001, 0x03000009, 0xe0010000, 0x90e40000, 0xa0e40000, 0x03000009, 0xe0020000,
2689 0x90e40000, 0xa0e40001, 0x03000009, 0xe0040000, 0x90e40000, 0xa0e40002, 0x03000009,
2690 0xe0080000, 0x90e40000, 0xa0e40003, 0x03000008, 0xe00f0001, 0xa0e40004, 0x90e40001,
2695 float4
main(const float4 color
: COLOR
) : SV_TARGET
2704 static const DWORD ps_4_0
[] =
2706 0x43425844, 0x4da9446f, 0xfbe1f259, 0x3fdb3009, 0x517521fa, 0x00000001, 0x000001ac,
2707 0x00000005, 0x00000034, 0x0000008c, 0x000000bc, 0x000000f0, 0x00000130, 0x46454452,
2708 0x00000050, 0x00000000, 0x00000000, 0x00000000, 0x0000001c, 0xffff0400, 0x00000100,
2709 0x0000001c, 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168,
2710 0x6f432072, 0x6c69706d, 0x39207265, 0x2e39322e, 0x2e323539, 0x31313133, 0xababab00,
2711 0x4e475349, 0x00000028, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
2712 0x00000003, 0x00000000, 0x00000f0f, 0x4f4c4f43, 0xabab0052, 0x4e47534f, 0x0000002c,
2713 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
2714 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040,
2715 0x0000000e, 0x03001062, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000,
2716 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x54415453,
2717 0x00000074, 0x00000002, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000,
2718 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2719 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
2720 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2721 0x00000000, 0x00000000,
2727 float4 pos
: SV_POSITION
;
2731 void main(point float4 vin
[1] : POSITION
, inout TriangleStream
<gs_out
> vout
)
2733 float offset
= 0.1 * vin
[0].w
;
2736 v
.pos
= float4(vin
[0].x
- offset
, vin
[0].y
- offset
, vin
[0].z
, vin
[0].w
);
2738 v
.pos
= float4(vin
[0].x
- offset
, vin
[0].y
+ offset
, vin
[0].z
, vin
[0].w
);
2740 v
.pos
= float4(vin
[0].x
+ offset
, vin
[0].y
- offset
, vin
[0].z
, vin
[0].w
);
2742 v
.pos
= float4(vin
[0].x
+ offset
, vin
[0].y
+ offset
, vin
[0].z
, vin
[0].w
);
2746 static const DWORD gs_4_0
[] =
2748 0x43425844, 0x000ee786, 0xc624c269, 0x885a5cbe, 0x444b3b1f, 0x00000001, 0x0000023c, 0x00000003,
2749 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
2750 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
2751 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
2752 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x000001a0, 0x00020040,
2753 0x00000068, 0x0400005f, 0x002010f2, 0x00000001, 0x00000000, 0x02000068, 0x00000001, 0x0100085d,
2754 0x0100285c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x0200005e, 0x00000004, 0x0f000032,
2755 0x00100032, 0x00000000, 0x80201ff6, 0x00000041, 0x00000000, 0x00000000, 0x00004002, 0x3dcccccd,
2756 0x3dcccccd, 0x00000000, 0x00000000, 0x00201046, 0x00000000, 0x00000000, 0x05000036, 0x00102032,
2757 0x00000000, 0x00100046, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000,
2758 0x00000000, 0x01000013, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0e000032,
2759 0x00100052, 0x00000000, 0x00201ff6, 0x00000000, 0x00000000, 0x00004002, 0x3dcccccd, 0x00000000,
2760 0x3dcccccd, 0x00000000, 0x00201106, 0x00000000, 0x00000000, 0x05000036, 0x00102022, 0x00000000,
2761 0x0010002a, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000, 0x00000000,
2762 0x01000013, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x05000036, 0x00102022,
2763 0x00000000, 0x0010001a, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000,
2764 0x00000000, 0x01000013, 0x05000036, 0x00102032, 0x00000000, 0x00100086, 0x00000000, 0x06000036,
2765 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000, 0x00000000, 0x01000013, 0x0100003e,
2768 ULONG refcount
, expected_refcount
;
2769 ID3D10Device
*device
, *tmp
;
2770 ID3D10GeometryShader
*gs
;
2771 ID3D10VertexShader
*vs
;
2772 ID3D10PixelShader
*ps
;
2776 if (!(device
= create_device()))
2778 skip("Failed to create device, skipping tests.\n");
2783 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
2784 hr
= ID3D10Device_CreateVertexShader(device
, vs_4_0
, sizeof(vs_4_0
), &vs
);
2785 ok(SUCCEEDED(hr
), "Failed to create SM4 vertex shader, hr %#x\n", hr
);
2787 refcount
= get_refcount((IUnknown
*)device
);
2788 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2790 expected_refcount
= refcount
+ 1;
2791 ID3D10VertexShader_GetDevice(vs
, &tmp
);
2792 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2793 refcount
= get_refcount((IUnknown
*)device
);
2794 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2795 ID3D10Device_Release(tmp
);
2797 hr
= ID3D10VertexShader_QueryInterface(vs
, &IID_ID3D11VertexShader
, (void **)&iface
);
2798 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
2799 "Vertex shader should implement ID3D11VertexShader.\n");
2800 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
2802 refcount
= ID3D10VertexShader_Release(vs
);
2803 ok(!refcount
, "Vertex shader has %u references left.\n", refcount
);
2805 hr
= ID3D10Device_CreateVertexShader(device
, vs_2_0
, sizeof(vs_2_0
), &vs
);
2806 ok(hr
== E_INVALIDARG
, "Created a SM2 vertex shader, hr %#x\n", hr
);
2808 hr
= ID3D10Device_CreateVertexShader(device
, vs_3_0
, sizeof(vs_3_0
), &vs
);
2809 ok(hr
== E_INVALIDARG
, "Created a SM3 vertex shader, hr %#x\n", hr
);
2811 hr
= ID3D10Device_CreateVertexShader(device
, ps_4_0
, sizeof(ps_4_0
), &vs
);
2812 ok(hr
== E_INVALIDARG
, "Created a SM4 vertex shader from a pixel shader source, hr %#x\n", hr
);
2815 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
2816 hr
= ID3D10Device_CreatePixelShader(device
, ps_4_0
, sizeof(ps_4_0
), &ps
);
2817 ok(SUCCEEDED(hr
), "Failed to create SM4 vertex shader, hr %#x\n", hr
);
2819 refcount
= get_refcount((IUnknown
*)device
);
2820 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2822 expected_refcount
= refcount
+ 1;
2823 ID3D10PixelShader_GetDevice(ps
, &tmp
);
2824 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2825 refcount
= get_refcount((IUnknown
*)device
);
2826 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2827 ID3D10Device_Release(tmp
);
2829 hr
= ID3D10PixelShader_QueryInterface(ps
, &IID_ID3D11PixelShader
, (void **)&iface
);
2830 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
2831 "Pixel shader should implement ID3D11PixelShader.\n");
2832 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
2834 refcount
= ID3D10PixelShader_Release(ps
);
2835 ok(!refcount
, "Pixel shader has %u references left.\n", refcount
);
2837 /* geometry shader */
2838 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
2839 hr
= ID3D10Device_CreateGeometryShader(device
, gs_4_0
, sizeof(gs_4_0
), &gs
);
2840 ok(SUCCEEDED(hr
), "Failed to create SM4 geometry shader, hr %#x.\n", hr
);
2842 refcount
= get_refcount((IUnknown
*)device
);
2843 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2845 expected_refcount
= refcount
+ 1;
2846 ID3D10GeometryShader_GetDevice(gs
, &tmp
);
2847 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2848 refcount
= get_refcount((IUnknown
*)device
);
2849 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2850 ID3D10Device_Release(tmp
);
2852 hr
= ID3D10GeometryShader_QueryInterface(gs
, &IID_ID3D11GeometryShader
, (void **)&iface
);
2853 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
2854 "Geometry shader should implement ID3D11GeometryShader.\n");
2855 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
2857 refcount
= ID3D10GeometryShader_Release(gs
);
2858 ok(!refcount
, "Geometry shader has %u references left.\n", refcount
);
2860 refcount
= ID3D10Device_Release(device
);
2861 ok(!refcount
, "Device has %u references left.\n", refcount
);
2864 static void test_create_sampler_state(void)
2866 static const struct test
2868 D3D10_FILTER filter
;
2869 D3D11_FILTER expected_filter
;
2871 desc_conversion_tests
[] =
2873 {D3D10_FILTER_MIN_MAG_MIP_POINT
, D3D11_FILTER_MIN_MAG_MIP_POINT
},
2874 {D3D10_FILTER_MIN_MAG_POINT_MIP_LINEAR
, D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR
},
2875 {D3D10_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT
, D3D11_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT
},
2876 {D3D10_FILTER_MIN_POINT_MAG_MIP_LINEAR
, D3D11_FILTER_MIN_POINT_MAG_MIP_LINEAR
},
2877 {D3D10_FILTER_MIN_LINEAR_MAG_MIP_POINT
, D3D11_FILTER_MIN_LINEAR_MAG_MIP_POINT
},
2878 {D3D10_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR
, D3D11_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR
},
2879 {D3D10_FILTER_MIN_MAG_LINEAR_MIP_POINT
, D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT
},
2880 {D3D10_FILTER_MIN_MAG_MIP_LINEAR
, D3D11_FILTER_MIN_MAG_MIP_LINEAR
},
2881 {D3D10_FILTER_ANISOTROPIC
, D3D11_FILTER_ANISOTROPIC
},
2882 {D3D10_FILTER_COMPARISON_MIN_MAG_MIP_POINT
, D3D11_FILTER_COMPARISON_MIN_MAG_MIP_POINT
},
2883 {D3D10_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR
, D3D11_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR
},
2885 D3D10_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT
,
2886 D3D11_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT
2888 {D3D10_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR
, D3D11_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR
},
2889 {D3D10_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT
, D3D11_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT
},
2891 D3D10_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR
,
2892 D3D11_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR
2894 {D3D10_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT
, D3D11_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT
},
2895 {D3D10_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR
, D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR
},
2896 {D3D10_FILTER_COMPARISON_ANISOTROPIC
, D3D11_FILTER_COMPARISON_ANISOTROPIC
},
2899 ID3D10SamplerState
*sampler_state1
, *sampler_state2
;
2900 ID3D11SamplerState
*d3d11_sampler_state
;
2901 ULONG refcount
, expected_refcount
;
2902 ID3D10Device
*device
, *tmp
;
2903 ID3D11Device
*d3d11_device
;
2904 D3D10_SAMPLER_DESC desc
;
2908 if (!(device
= create_device()))
2910 skip("Failed to create device, skipping tests.\n");
2914 hr
= ID3D10Device_CreateSamplerState(device
, NULL
, &sampler_state1
);
2915 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
2917 desc
.Filter
= D3D10_FILTER_MIN_MAG_MIP_LINEAR
;
2918 desc
.AddressU
= D3D10_TEXTURE_ADDRESS_WRAP
;
2919 desc
.AddressV
= D3D10_TEXTURE_ADDRESS_WRAP
;
2920 desc
.AddressW
= D3D10_TEXTURE_ADDRESS_WRAP
;
2921 desc
.MipLODBias
= 0.0f
;
2922 desc
.MaxAnisotropy
= 16;
2923 desc
.ComparisonFunc
= D3D10_COMPARISON_ALWAYS
;
2924 desc
.BorderColor
[0] = 0.0f
;
2925 desc
.BorderColor
[1] = 1.0f
;
2926 desc
.BorderColor
[2] = 0.0f
;
2927 desc
.BorderColor
[3] = 1.0f
;
2929 desc
.MaxLOD
= 16.0f
;
2931 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
2932 hr
= ID3D10Device_CreateSamplerState(device
, &desc
, &sampler_state1
);
2933 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
2934 hr
= ID3D10Device_CreateSamplerState(device
, &desc
, &sampler_state2
);
2935 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
2936 ok(sampler_state1
== sampler_state2
, "Got different sampler state objects.\n");
2937 refcount
= get_refcount((IUnknown
*)device
);
2938 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
2940 expected_refcount
= refcount
+ 1;
2941 ID3D10SamplerState_GetDevice(sampler_state1
, &tmp
);
2942 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
2943 refcount
= get_refcount((IUnknown
*)device
);
2944 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
2945 ID3D10Device_Release(tmp
);
2947 ID3D10SamplerState_GetDesc(sampler_state1
, &desc
);
2948 ok(desc
.Filter
== D3D10_FILTER_MIN_MAG_MIP_LINEAR
, "Got unexpected filter %#x.\n", desc
.Filter
);
2949 ok(desc
.AddressU
== D3D10_TEXTURE_ADDRESS_WRAP
, "Got unexpected address u %u.\n", desc
.AddressU
);
2950 ok(desc
.AddressV
== D3D10_TEXTURE_ADDRESS_WRAP
, "Got unexpected address v %u.\n", desc
.AddressV
);
2951 ok(desc
.AddressW
== D3D10_TEXTURE_ADDRESS_WRAP
, "Got unexpected address w %u.\n", desc
.AddressW
);
2952 ok(!desc
.MipLODBias
, "Got unexpected mip LOD bias %f.\n", desc
.MipLODBias
);
2953 ok(!desc
.MaxAnisotropy
|| broken(desc
.MaxAnisotropy
== 16) /* Not set to 0 on all Windows versions. */,
2954 "Got unexpected max anisotropy %u.\n", desc
.MaxAnisotropy
);
2955 ok(desc
.ComparisonFunc
== D3D10_COMPARISON_NEVER
, "Got unexpected comparison func %u.\n", desc
.ComparisonFunc
);
2956 ok(!desc
.BorderColor
[0] && !desc
.BorderColor
[1] && !desc
.BorderColor
[2] && !desc
.BorderColor
[3],
2957 "Got unexpected border color {%.8e, %.8e, %.8e, %.8e}.\n",
2958 desc
.BorderColor
[0], desc
.BorderColor
[1], desc
.BorderColor
[2], desc
.BorderColor
[3]);
2959 ok(!desc
.MinLOD
, "Got unexpected min LOD %f.\n", desc
.MinLOD
);
2960 ok(desc
.MaxLOD
== 16.0f
, "Got unexpected max LOD %f.\n", desc
.MaxLOD
);
2962 refcount
= ID3D10SamplerState_Release(sampler_state2
);
2963 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
2964 refcount
= ID3D10SamplerState_Release(sampler_state1
);
2965 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
2967 hr
= ID3D10Device_QueryInterface(device
, &IID_ID3D11Device
, (void **)&d3d11_device
);
2968 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
2969 "Device should implement ID3D11Device.\n");
2972 win_skip("D3D11 is not available.\n");
2976 for (i
= 0; i
< sizeof(desc_conversion_tests
) / sizeof(*desc_conversion_tests
); ++i
)
2978 const struct test
*current
= &desc_conversion_tests
[i
];
2979 D3D11_SAMPLER_DESC d3d11_desc
, expected_desc
;
2981 desc
.Filter
= current
->filter
;
2982 desc
.AddressU
= D3D10_TEXTURE_ADDRESS_WRAP
;
2983 desc
.AddressV
= D3D10_TEXTURE_ADDRESS_WRAP
;
2984 desc
.AddressW
= D3D10_TEXTURE_ADDRESS_BORDER
;
2985 desc
.MipLODBias
= 0.0f
;
2986 desc
.MaxAnisotropy
= 16;
2987 desc
.ComparisonFunc
= D3D10_COMPARISON_ALWAYS
;
2988 desc
.BorderColor
[0] = 0.0f
;
2989 desc
.BorderColor
[1] = 1.0f
;
2990 desc
.BorderColor
[2] = 0.0f
;
2991 desc
.BorderColor
[3] = 1.0f
;
2993 desc
.MaxLOD
= 16.0f
;
2995 hr
= ID3D10Device_CreateSamplerState(device
, &desc
, &sampler_state1
);
2996 ok(SUCCEEDED(hr
), "Test %u: Failed to create sampler state, hr %#x.\n", i
, hr
);
2998 hr
= ID3D10SamplerState_QueryInterface(sampler_state1
, &IID_ID3D11SamplerState
,
2999 (void **)&d3d11_sampler_state
);
3000 ok(SUCCEEDED(hr
), "Test %u: Sampler state should implement ID3D11SamplerState.\n", i
);
3002 memcpy(&expected_desc
, &desc
, sizeof(expected_desc
));
3003 expected_desc
.Filter
= current
->expected_filter
;
3004 if (!D3D11_DECODE_IS_ANISOTROPIC_FILTER(current
->filter
))
3005 expected_desc
.MaxAnisotropy
= 0;
3006 if (!D3D11_DECODE_IS_COMPARISON_FILTER(current
->filter
))
3007 expected_desc
.ComparisonFunc
= D3D11_COMPARISON_NEVER
;
3009 ID3D11SamplerState_GetDesc(d3d11_sampler_state
, &d3d11_desc
);
3010 ok(d3d11_desc
.Filter
== expected_desc
.Filter
,
3011 "Test %u: Got unexpected filter %#x.\n", i
, d3d11_desc
.Filter
);
3012 ok(d3d11_desc
.AddressU
== expected_desc
.AddressU
,
3013 "Test %u: Got unexpected address u %u.\n", i
, d3d11_desc
.AddressU
);
3014 ok(d3d11_desc
.AddressV
== expected_desc
.AddressV
,
3015 "Test %u: Got unexpected address v %u.\n", i
, d3d11_desc
.AddressV
);
3016 ok(d3d11_desc
.AddressW
== expected_desc
.AddressW
,
3017 "Test %u: Got unexpected address w %u.\n", i
, d3d11_desc
.AddressW
);
3018 ok(d3d11_desc
.MipLODBias
== expected_desc
.MipLODBias
,
3019 "Test %u: Got unexpected mip LOD bias %f.\n", i
, d3d11_desc
.MipLODBias
);
3020 ok(d3d11_desc
.MaxAnisotropy
== expected_desc
.MaxAnisotropy
,
3021 "Test %u: Got unexpected max anisotropy %u.\n", i
, d3d11_desc
.MaxAnisotropy
);
3022 ok(d3d11_desc
.ComparisonFunc
== expected_desc
.ComparisonFunc
,
3023 "Test %u: Got unexpected comparison func %u.\n", i
, d3d11_desc
.ComparisonFunc
);
3024 ok(d3d11_desc
.BorderColor
[0] == expected_desc
.BorderColor
[0]
3025 && d3d11_desc
.BorderColor
[1] == expected_desc
.BorderColor
[1]
3026 && d3d11_desc
.BorderColor
[2] == expected_desc
.BorderColor
[2]
3027 && d3d11_desc
.BorderColor
[3] == expected_desc
.BorderColor
[3],
3028 "Test %u: Got unexpected border color {%.8e, %.8e, %.8e, %.8e}.\n", i
,
3029 d3d11_desc
.BorderColor
[0], d3d11_desc
.BorderColor
[1],
3030 d3d11_desc
.BorderColor
[2], d3d11_desc
.BorderColor
[3]);
3031 ok(d3d11_desc
.MinLOD
== expected_desc
.MinLOD
,
3032 "Test %u: Got unexpected min LOD %f.\n", i
, d3d11_desc
.MinLOD
);
3033 ok(d3d11_desc
.MaxLOD
== expected_desc
.MaxLOD
,
3034 "Test %u: Got unexpected max LOD %f.\n", i
, d3d11_desc
.MaxLOD
);
3036 refcount
= ID3D11SamplerState_Release(d3d11_sampler_state
);
3037 ok(refcount
== 1, "Test %u: Got unexpected refcount %u.\n", i
, refcount
);
3039 hr
= ID3D11Device_CreateSamplerState(d3d11_device
, &d3d11_desc
, &d3d11_sampler_state
);
3040 ok(SUCCEEDED(hr
), "Test %u: Failed to create sampler state, hr %#x.\n", i
, hr
);
3041 hr
= ID3D11SamplerState_QueryInterface(d3d11_sampler_state
, &IID_ID3D10SamplerState
,
3042 (void **)&sampler_state2
);
3043 ok(SUCCEEDED(hr
), "Test %u: Sampler state should implement ID3D10SamplerState.\n", i
);
3044 ok(sampler_state1
== sampler_state2
, "Test %u: Got different sampler state objects.\n", i
);
3046 refcount
= ID3D11SamplerState_Release(d3d11_sampler_state
);
3047 ok(refcount
== 2, "Test %u: Got unexpected refcount %u.\n", i
, refcount
);
3048 refcount
= ID3D10SamplerState_Release(sampler_state2
);
3049 ok(refcount
== 1, "Test %u: Got unexpected refcount %u.\n", i
, refcount
);
3050 refcount
= ID3D10SamplerState_Release(sampler_state1
);
3051 ok(!refcount
, "Test %u: Got unexpected refcount %u.\n", i
, refcount
);
3054 ID3D11Device_Release(d3d11_device
);
3057 refcount
= ID3D10Device_Release(device
);
3058 ok(!refcount
, "Device has %u references left.\n", refcount
);
3061 static void test_create_blend_state(void)
3063 ID3D10BlendState
*blend_state1
, *blend_state2
;
3064 ID3D11BlendState
*d3d11_blend_state
;
3065 ULONG refcount
, expected_refcount
;
3066 D3D11_BLEND_DESC d3d11_blend_desc
;
3067 D3D10_BLEND_DESC blend_desc
;
3068 ID3D11Device
*d3d11_device
;
3069 ID3D10Device
*device
, *tmp
;
3074 if (!(device
= create_device()))
3076 skip("Failed to create device.\n");
3080 hr
= ID3D10Device_CreateBlendState(device
, NULL
, &blend_state1
);
3081 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
3083 blend_desc
.AlphaToCoverageEnable
= FALSE
;
3084 blend_desc
.SrcBlend
= D3D10_BLEND_ONE
;
3085 blend_desc
.DestBlend
= D3D10_BLEND_ZERO
;
3086 blend_desc
.BlendOp
= D3D10_BLEND_OP_ADD
;
3087 blend_desc
.SrcBlendAlpha
= D3D10_BLEND_ONE
;
3088 blend_desc
.DestBlendAlpha
= D3D10_BLEND_ZERO
;
3089 blend_desc
.BlendOpAlpha
= D3D10_BLEND_OP_ADD
;
3090 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
3092 blend_desc
.BlendEnable
[i
] = FALSE
;
3093 blend_desc
.RenderTargetWriteMask
[i
] = D3D10_COLOR_WRITE_ENABLE_ALL
;
3096 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
3097 hr
= ID3D10Device_CreateBlendState(device
, &blend_desc
, &blend_state1
);
3098 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
3099 hr
= ID3D10Device_CreateBlendState(device
, &blend_desc
, &blend_state2
);
3100 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
3101 ok(blend_state1
== blend_state2
, "Got different blend state objects.\n");
3102 refcount
= get_refcount((IUnknown
*)device
);
3103 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
3105 expected_refcount
= refcount
+ 1;
3106 ID3D10BlendState_GetDevice(blend_state1
, &tmp
);
3107 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
3108 refcount
= get_refcount((IUnknown
*)device
);
3109 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
3110 ID3D10Device_Release(tmp
);
3112 hr
= ID3D10BlendState_QueryInterface(blend_state1
, &IID_ID3D10BlendState1
, (void **)&iface
);
3113 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
3114 "Blend state should implement ID3D10BlendState1.\n");
3115 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
3117 hr
= ID3D10Device_QueryInterface(device
, &IID_ID3D11Device
, (void **)&d3d11_device
);
3118 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
3119 "Device should implement ID3D11Device.\n");
3122 win_skip("D3D11 is not available.\n");
3126 hr
= ID3D10BlendState_QueryInterface(blend_state1
, &IID_ID3D11BlendState
, (void **)&d3d11_blend_state
);
3127 ok(SUCCEEDED(hr
), "Blend state should implement ID3D11BlendState.\n");
3129 ID3D11BlendState_GetDesc(d3d11_blend_state
, &d3d11_blend_desc
);
3130 ok(d3d11_blend_desc
.AlphaToCoverageEnable
== blend_desc
.AlphaToCoverageEnable
,
3131 "Got unexpected alpha to coverage enable %#x.\n", d3d11_blend_desc
.AlphaToCoverageEnable
);
3132 ok(d3d11_blend_desc
.IndependentBlendEnable
== FALSE
,
3133 "Got unexpected independent blend enable %#x.\n", d3d11_blend_desc
.IndependentBlendEnable
);
3134 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
3136 ok(d3d11_blend_desc
.RenderTarget
[i
].BlendEnable
== blend_desc
.BlendEnable
[i
],
3137 "Got unexpected blend enable %#x for render target %u.\n",
3138 d3d11_blend_desc
.RenderTarget
[i
].BlendEnable
, i
);
3139 ok(d3d11_blend_desc
.RenderTarget
[i
].SrcBlend
== (D3D11_BLEND
)blend_desc
.SrcBlend
,
3140 "Got unexpected src blend %u for render target %u.\n",
3141 d3d11_blend_desc
.RenderTarget
[i
].SrcBlend
, i
);
3142 ok(d3d11_blend_desc
.RenderTarget
[i
].DestBlend
== (D3D11_BLEND
)blend_desc
.DestBlend
,
3143 "Got unexpected dest blend %u for render target %u.\n",
3144 d3d11_blend_desc
.RenderTarget
[i
].DestBlend
, i
);
3145 ok(d3d11_blend_desc
.RenderTarget
[i
].BlendOp
== (D3D11_BLEND_OP
)blend_desc
.BlendOp
,
3146 "Got unexpected blend op %u for render target %u.\n",
3147 d3d11_blend_desc
.RenderTarget
[i
].BlendOp
, i
);
3148 ok(d3d11_blend_desc
.RenderTarget
[i
].SrcBlendAlpha
== (D3D11_BLEND
)blend_desc
.SrcBlendAlpha
,
3149 "Got unexpected src blend alpha %u for render target %u.\n",
3150 d3d11_blend_desc
.RenderTarget
[i
].SrcBlendAlpha
, i
);
3151 ok(d3d11_blend_desc
.RenderTarget
[i
].DestBlendAlpha
== (D3D11_BLEND
)blend_desc
.DestBlendAlpha
,
3152 "Got unexpected dest blend alpha %u for render target %u.\n",
3153 d3d11_blend_desc
.RenderTarget
[i
].DestBlendAlpha
, i
);
3154 ok(d3d11_blend_desc
.RenderTarget
[i
].BlendOpAlpha
== (D3D11_BLEND_OP
)blend_desc
.BlendOpAlpha
,
3155 "Got unexpected blend op alpha %u for render target %u.\n",
3156 d3d11_blend_desc
.RenderTarget
[i
].BlendOpAlpha
, i
);
3157 ok(d3d11_blend_desc
.RenderTarget
[i
].RenderTargetWriteMask
== blend_desc
.RenderTargetWriteMask
[i
],
3158 "Got unexpected render target write mask %#x for render target %u.\n",
3159 d3d11_blend_desc
.RenderTarget
[i
].RenderTargetWriteMask
, i
);
3162 refcount
= ID3D11BlendState_Release(d3d11_blend_state
);
3163 ok(refcount
== 2, "Got unexpected refcount %u.\n", refcount
);
3164 refcount
= ID3D10BlendState_Release(blend_state2
);
3165 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
3167 hr
= ID3D11Device_CreateBlendState(d3d11_device
, &d3d11_blend_desc
, &d3d11_blend_state
);
3168 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
3170 hr
= ID3D11BlendState_QueryInterface(d3d11_blend_state
, &IID_ID3D10BlendState
, (void **)&blend_state2
);
3171 ok(SUCCEEDED(hr
), "Blend state should implement ID3D10BlendState.\n");
3172 ok(blend_state1
== blend_state2
, "Got different blend state objects.\n");
3174 refcount
= ID3D11BlendState_Release(d3d11_blend_state
);
3175 ok(refcount
== 2, "Got unexpected refcount %u.\n", refcount
);
3176 refcount
= ID3D10BlendState_Release(blend_state2
);
3177 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
3178 refcount
= ID3D10BlendState_Release(blend_state1
);
3179 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
3181 blend_desc
.BlendEnable
[0] = TRUE
;
3182 blend_desc
.RenderTargetWriteMask
[1] = D3D10_COLOR_WRITE_ENABLE_RED
;
3183 blend_desc
.RenderTargetWriteMask
[2] = D3D10_COLOR_WRITE_ENABLE_GREEN
;
3184 blend_desc
.RenderTargetWriteMask
[3] = D3D10_COLOR_WRITE_ENABLE_BLUE
;
3186 hr
= ID3D10Device_CreateBlendState(device
, &blend_desc
, &blend_state1
);
3187 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
3189 hr
= ID3D10BlendState_QueryInterface(blend_state1
, &IID_ID3D11BlendState
, (void **)&d3d11_blend_state
);
3190 ok(SUCCEEDED(hr
), "Blend state should implement ID3D11BlendState.\n");
3192 ID3D11BlendState_GetDesc(d3d11_blend_state
, &d3d11_blend_desc
);
3193 ok(d3d11_blend_desc
.AlphaToCoverageEnable
== blend_desc
.AlphaToCoverageEnable
,
3194 "Got unexpected alpha to coverage enable %#x.\n", d3d11_blend_desc
.AlphaToCoverageEnable
);
3195 ok(d3d11_blend_desc
.IndependentBlendEnable
== TRUE
,
3196 "Got unexpected independent blend enable %#x.\n", d3d11_blend_desc
.IndependentBlendEnable
);
3197 for (i
= 0; i
< D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
3199 ok(d3d11_blend_desc
.RenderTarget
[i
].BlendEnable
== blend_desc
.BlendEnable
[i
],
3200 "Got unexpected blend enable %#x for render target %u.\n",
3201 d3d11_blend_desc
.RenderTarget
[i
].BlendEnable
, i
);
3202 ok(d3d11_blend_desc
.RenderTarget
[i
].SrcBlend
== (D3D11_BLEND
)blend_desc
.SrcBlend
,
3203 "Got unexpected src blend %u for render target %u.\n",
3204 d3d11_blend_desc
.RenderTarget
[i
].SrcBlend
, i
);
3205 ok(d3d11_blend_desc
.RenderTarget
[i
].DestBlend
== (D3D11_BLEND
)blend_desc
.DestBlend
,
3206 "Got unexpected dest blend %u for render target %u.\n",
3207 d3d11_blend_desc
.RenderTarget
[i
].DestBlend
, i
);
3208 ok(d3d11_blend_desc
.RenderTarget
[i
].BlendOp
== (D3D11_BLEND_OP
)blend_desc
.BlendOp
,
3209 "Got unexpected blend op %u for render target %u.\n",
3210 d3d11_blend_desc
.RenderTarget
[i
].BlendOp
, i
);
3211 ok(d3d11_blend_desc
.RenderTarget
[i
].SrcBlendAlpha
== (D3D11_BLEND
)blend_desc
.SrcBlendAlpha
,
3212 "Got unexpected src blend alpha %u for render target %u.\n",
3213 d3d11_blend_desc
.RenderTarget
[i
].SrcBlendAlpha
, i
);
3214 ok(d3d11_blend_desc
.RenderTarget
[i
].DestBlendAlpha
== (D3D11_BLEND
)blend_desc
.DestBlendAlpha
,
3215 "Got unexpected dest blend alpha %u for render target %u.\n",
3216 d3d11_blend_desc
.RenderTarget
[i
].DestBlendAlpha
, i
);
3217 ok(d3d11_blend_desc
.RenderTarget
[i
].BlendOpAlpha
== (D3D11_BLEND_OP
)blend_desc
.BlendOpAlpha
,
3218 "Got unexpected blend op alpha %u for render target %u.\n",
3219 d3d11_blend_desc
.RenderTarget
[i
].BlendOpAlpha
, i
);
3220 ok(d3d11_blend_desc
.RenderTarget
[i
].RenderTargetWriteMask
== blend_desc
.RenderTargetWriteMask
[i
],
3221 "Got unexpected render target write mask %#x for render target %u.\n",
3222 d3d11_blend_desc
.RenderTarget
[i
].RenderTargetWriteMask
, i
);
3225 refcount
= ID3D11BlendState_Release(d3d11_blend_state
);
3226 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
3228 hr
= ID3D11Device_CreateBlendState(d3d11_device
, &d3d11_blend_desc
, &d3d11_blend_state
);
3229 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
3231 hr
= ID3D11BlendState_QueryInterface(d3d11_blend_state
, &IID_ID3D10BlendState
, (void **)&blend_state2
);
3232 ok(SUCCEEDED(hr
), "Blend state should implement ID3D10BlendState.\n");
3233 ok(blend_state1
== blend_state2
, "Got different blend state objects.\n");
3235 refcount
= ID3D11BlendState_Release(d3d11_blend_state
);
3236 ok(refcount
== 2, "Got unexpected refcount %u.\n", refcount
);
3238 ID3D11Device_Release(d3d11_device
);
3241 refcount
= ID3D10BlendState_Release(blend_state2
);
3242 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
3243 refcount
= ID3D10BlendState_Release(blend_state1
);
3244 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
3246 refcount
= ID3D10Device_Release(device
);
3247 ok(!refcount
, "Device has %u references left.\n", refcount
);
3250 static void test_create_depthstencil_state(void)
3252 ID3D10DepthStencilState
*ds_state1
, *ds_state2
;
3253 ULONG refcount
, expected_refcount
;
3254 D3D10_DEPTH_STENCIL_DESC ds_desc
;
3255 ID3D10Device
*device
, *tmp
;
3258 if (!(device
= create_device()))
3260 skip("Failed to create device, skipping tests.\n");
3264 hr
= ID3D10Device_CreateDepthStencilState(device
, NULL
, &ds_state1
);
3265 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
3267 ds_desc
.DepthEnable
= TRUE
;
3268 ds_desc
.DepthWriteMask
= D3D10_DEPTH_WRITE_MASK_ALL
;
3269 ds_desc
.DepthFunc
= D3D10_COMPARISON_LESS
;
3270 ds_desc
.StencilEnable
= FALSE
;
3271 ds_desc
.StencilReadMask
= D3D10_DEFAULT_STENCIL_READ_MASK
;
3272 ds_desc
.StencilWriteMask
= D3D10_DEFAULT_STENCIL_WRITE_MASK
;
3273 ds_desc
.FrontFace
.StencilFailOp
= D3D10_STENCIL_OP_KEEP
;
3274 ds_desc
.FrontFace
.StencilDepthFailOp
= D3D10_STENCIL_OP_KEEP
;
3275 ds_desc
.FrontFace
.StencilPassOp
= D3D10_STENCIL_OP_KEEP
;
3276 ds_desc
.FrontFace
.StencilFunc
= D3D10_COMPARISON_ALWAYS
;
3277 ds_desc
.BackFace
.StencilFailOp
= D3D10_STENCIL_OP_KEEP
;
3278 ds_desc
.BackFace
.StencilDepthFailOp
= D3D10_STENCIL_OP_KEEP
;
3279 ds_desc
.BackFace
.StencilPassOp
= D3D10_STENCIL_OP_KEEP
;
3280 ds_desc
.BackFace
.StencilFunc
= D3D10_COMPARISON_ALWAYS
;
3282 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
3283 hr
= ID3D10Device_CreateDepthStencilState(device
, &ds_desc
, &ds_state1
);
3284 ok(SUCCEEDED(hr
), "Failed to create depthstencil state, hr %#x.\n", hr
);
3285 hr
= ID3D10Device_CreateDepthStencilState(device
, &ds_desc
, &ds_state2
);
3286 ok(SUCCEEDED(hr
), "Failed to create depthstencil state, hr %#x.\n", hr
);
3287 ok(ds_state1
== ds_state2
, "Got different depthstencil state objects.\n");
3288 refcount
= get_refcount((IUnknown
*)device
);
3289 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
3291 expected_refcount
= refcount
+ 1;
3292 ID3D10DepthStencilState_GetDevice(ds_state1
, &tmp
);
3293 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
3294 refcount
= get_refcount((IUnknown
*)device
);
3295 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
3296 ID3D10Device_Release(tmp
);
3298 refcount
= ID3D10DepthStencilState_Release(ds_state2
);
3299 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
3300 refcount
= ID3D10DepthStencilState_Release(ds_state1
);
3301 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
3303 ds_desc
.DepthEnable
= FALSE
;
3304 ds_desc
.DepthWriteMask
= D3D10_DEPTH_WRITE_MASK_ZERO
;
3305 ds_desc
.DepthFunc
= D3D10_COMPARISON_NEVER
;
3306 ds_desc
.StencilEnable
= FALSE
;
3307 ds_desc
.StencilReadMask
= 0;
3308 ds_desc
.StencilWriteMask
= 0;
3309 ds_desc
.FrontFace
.StencilFailOp
= D3D10_STENCIL_OP_ZERO
;
3310 ds_desc
.FrontFace
.StencilDepthFailOp
= D3D10_STENCIL_OP_ZERO
;
3311 ds_desc
.FrontFace
.StencilPassOp
= D3D10_STENCIL_OP_ZERO
;
3312 ds_desc
.FrontFace
.StencilFunc
= D3D10_COMPARISON_NEVER
;
3313 ds_desc
.BackFace
= ds_desc
.FrontFace
;
3315 hr
= ID3D10Device_CreateDepthStencilState(device
, &ds_desc
, &ds_state1
);
3316 ok(SUCCEEDED(hr
), "Failed to create depthstencil state, hr %#x.\n", hr
);
3318 memset(&ds_desc
, 0, sizeof(ds_desc
));
3319 ID3D10DepthStencilState_GetDesc(ds_state1
, &ds_desc
);
3320 ok(!ds_desc
.DepthEnable
, "Got unexpected depth enable %#x.\n", ds_desc
.DepthEnable
);
3321 ok(ds_desc
.DepthWriteMask
== D3D10_DEPTH_WRITE_MASK_ALL
3322 || broken(ds_desc
.DepthWriteMask
== D3D10_DEPTH_WRITE_MASK_ZERO
),
3323 "Got unexpected depth write mask %#x.\n", ds_desc
.DepthWriteMask
);
3324 ok(ds_desc
.DepthFunc
== D3D10_COMPARISON_LESS
|| broken(ds_desc
.DepthFunc
== D3D10_COMPARISON_NEVER
),
3325 "Got unexpected depth func %#x.\n", ds_desc
.DepthFunc
);
3326 ok(!ds_desc
.StencilEnable
, "Got unexpected stencil enable %#x.\n", ds_desc
.StencilEnable
);
3327 ok(ds_desc
.StencilReadMask
== D3D10_DEFAULT_STENCIL_READ_MASK
,
3328 "Got unexpected stencil read mask %#x.\n", ds_desc
.StencilReadMask
);
3329 ok(ds_desc
.StencilWriteMask
== D3D10_DEFAULT_STENCIL_WRITE_MASK
,
3330 "Got unexpected stencil write mask %#x.\n", ds_desc
.StencilWriteMask
);
3331 ok(ds_desc
.FrontFace
.StencilDepthFailOp
== D3D10_STENCIL_OP_KEEP
,
3332 "Got unexpected front face stencil depth fail op %#x.\n", ds_desc
.FrontFace
.StencilDepthFailOp
);
3333 ok(ds_desc
.FrontFace
.StencilPassOp
== D3D10_STENCIL_OP_KEEP
,
3334 "Got unexpected front face stencil pass op %#x.\n", ds_desc
.FrontFace
.StencilPassOp
);
3335 ok(ds_desc
.FrontFace
.StencilFailOp
== D3D10_STENCIL_OP_KEEP
,
3336 "Got unexpected front face stencil fail op %#x.\n", ds_desc
.FrontFace
.StencilFailOp
);
3337 ok(ds_desc
.FrontFace
.StencilFunc
== D3D10_COMPARISON_ALWAYS
,
3338 "Got unexpected front face stencil func %#x.\n", ds_desc
.FrontFace
.StencilFunc
);
3339 ok(ds_desc
.BackFace
.StencilDepthFailOp
== D3D10_STENCIL_OP_KEEP
,
3340 "Got unexpected back face stencil depth fail op %#x.\n", ds_desc
.BackFace
.StencilDepthFailOp
);
3341 ok(ds_desc
.BackFace
.StencilPassOp
== D3D10_STENCIL_OP_KEEP
,
3342 "Got unexpected back face stencil pass op %#x.\n", ds_desc
.BackFace
.StencilPassOp
);
3343 ok(ds_desc
.BackFace
.StencilFailOp
== D3D10_STENCIL_OP_KEEP
,
3344 "Got unexpected back face stencil fail op %#x.\n", ds_desc
.BackFace
.StencilFailOp
);
3345 ok(ds_desc
.BackFace
.StencilFunc
== D3D10_COMPARISON_ALWAYS
,
3346 "Got unexpected back face stencil func %#x.\n", ds_desc
.BackFace
.StencilFunc
);
3348 ID3D10DepthStencilState_Release(ds_state1
);
3350 refcount
= ID3D10Device_Release(device
);
3351 ok(!refcount
, "Device has %u references left.\n", refcount
);
3354 static void test_create_rasterizer_state(void)
3356 ID3D10RasterizerState
*rast_state1
, *rast_state2
;
3357 ULONG refcount
, expected_refcount
;
3358 D3D10_RASTERIZER_DESC rast_desc
;
3359 ID3D10Device
*device
, *tmp
;
3362 if (!(device
= create_device()))
3364 skip("Failed to create device, skipping tests.\n");
3368 hr
= ID3D10Device_CreateRasterizerState(device
, NULL
, &rast_state1
);
3369 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
3371 rast_desc
.FillMode
= D3D10_FILL_SOLID
;
3372 rast_desc
.CullMode
= D3D10_CULL_BACK
;
3373 rast_desc
.FrontCounterClockwise
= FALSE
;
3374 rast_desc
.DepthBias
= 0;
3375 rast_desc
.DepthBiasClamp
= 0.0f
;
3376 rast_desc
.SlopeScaledDepthBias
= 0.0f
;
3377 rast_desc
.DepthClipEnable
= TRUE
;
3378 rast_desc
.ScissorEnable
= FALSE
;
3379 rast_desc
.MultisampleEnable
= FALSE
;
3380 rast_desc
.AntialiasedLineEnable
= FALSE
;
3382 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
3383 hr
= ID3D10Device_CreateRasterizerState(device
, &rast_desc
, &rast_state1
);
3384 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
3385 hr
= ID3D10Device_CreateRasterizerState(device
, &rast_desc
, &rast_state2
);
3386 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
3387 ok(rast_state1
== rast_state2
, "Got different rasterizer state objects.\n");
3388 refcount
= get_refcount((IUnknown
*)device
);
3389 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
3391 expected_refcount
= refcount
+ 1;
3392 ID3D10RasterizerState_GetDevice(rast_state1
, &tmp
);
3393 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
3394 refcount
= get_refcount((IUnknown
*)device
);
3395 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
3396 ID3D10Device_Release(tmp
);
3398 refcount
= ID3D10RasterizerState_Release(rast_state2
);
3399 ok(refcount
== 1, "Got unexpected refcount %u.\n", refcount
);
3400 refcount
= ID3D10RasterizerState_Release(rast_state1
);
3401 ok(!refcount
, "Got unexpected refcount %u.\n", refcount
);
3403 refcount
= ID3D10Device_Release(device
);
3404 ok(!refcount
, "Device has %u references left.\n", refcount
);
3407 static void test_create_query(void)
3417 {D3D10_QUERY_EVENT
, FALSE
, FALSE
},
3418 {D3D10_QUERY_OCCLUSION
, FALSE
, FALSE
},
3419 {D3D10_QUERY_TIMESTAMP
, FALSE
, FALSE
},
3420 {D3D10_QUERY_TIMESTAMP_DISJOINT
, FALSE
, FALSE
},
3421 {D3D10_QUERY_PIPELINE_STATISTICS
, FALSE
, TRUE
},
3422 {D3D10_QUERY_OCCLUSION_PREDICATE
, TRUE
, FALSE
},
3423 {D3D10_QUERY_SO_STATISTICS
, FALSE
, TRUE
},
3424 {D3D10_QUERY_SO_OVERFLOW_PREDICATE
, TRUE
, TRUE
},
3427 ULONG refcount
, expected_refcount
;
3428 D3D10_QUERY_DESC query_desc
;
3429 ID3D10Predicate
*predicate
;
3430 ID3D10Device
*device
, *tmp
;
3431 HRESULT hr
, expected_hr
;
3436 if (!(device
= create_device()))
3438 skip("Failed to create device.\n");
3442 hr
= ID3D10Device_CreateQuery(device
, NULL
, &query
);
3443 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
3444 hr
= ID3D10Device_CreatePredicate(device
, NULL
, &predicate
);
3445 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
3447 for (i
= 0; i
< sizeof(tests
) / sizeof(*tests
); ++i
)
3449 query_desc
.Query
= tests
[i
].query
;
3450 query_desc
.MiscFlags
= 0;
3452 hr
= ID3D10Device_CreateQuery(device
, &query_desc
, NULL
);
3453 todo_wine_if(tests
[i
].todo
)
3454 ok(hr
== S_FALSE
, "Got unexpected hr %#x for query type %u.\n", hr
, query_desc
.Query
);
3456 query_desc
.Query
= tests
[i
].query
;
3457 hr
= ID3D10Device_CreateQuery(device
, &query_desc
, &query
);
3458 todo_wine_if(tests
[i
].todo
)
3459 ok(hr
== S_OK
, "Got unexpected hr %#x for query type %u.\n", hr
, query_desc
.Query
);
3463 expected_hr
= tests
[i
].is_predicate
? S_OK
: E_NOINTERFACE
;
3464 hr
= ID3D10Query_QueryInterface(query
, &IID_ID3D10Predicate
, (void **)&predicate
);
3465 ID3D10Query_Release(query
);
3466 ok(hr
== expected_hr
, "Got unexpected hr %#x for query type %u.\n", hr
, query_desc
.Query
);
3468 ID3D10Predicate_Release(predicate
);
3470 expected_hr
= tests
[i
].is_predicate
? S_FALSE
: E_INVALIDARG
;
3471 hr
= ID3D10Device_CreatePredicate(device
, &query_desc
, NULL
);
3472 ok(hr
== expected_hr
, "Got unexpected hr %#x for query type %u.\n", hr
, query_desc
.Query
);
3474 expected_hr
= tests
[i
].is_predicate
? S_OK
: E_INVALIDARG
;
3475 hr
= ID3D10Device_CreatePredicate(device
, &query_desc
, &predicate
);
3476 ok(hr
== expected_hr
, "Got unexpected hr %#x for query type %u.\n", hr
, query_desc
.Query
);
3478 ID3D10Predicate_Release(predicate
);
3481 query_desc
.Query
= D3D10_QUERY_OCCLUSION_PREDICATE
;
3482 expected_refcount
= get_refcount((IUnknown
*)device
) + 1;
3483 hr
= ID3D10Device_CreatePredicate(device
, &query_desc
, &predicate
);
3484 ok(SUCCEEDED(hr
), "Failed to create predicate, hr %#x.\n", hr
);
3485 refcount
= get_refcount((IUnknown
*)device
);
3486 ok(refcount
>= expected_refcount
, "Got unexpected refcount %u, expected >= %u.\n", refcount
, expected_refcount
);
3488 expected_refcount
= refcount
+ 1;
3489 ID3D10Predicate_GetDevice(predicate
, &tmp
);
3490 ok(tmp
== device
, "Got unexpected device %p, expected %p.\n", tmp
, device
);
3491 refcount
= get_refcount((IUnknown
*)device
);
3492 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
3493 ID3D10Device_Release(tmp
);
3494 hr
= ID3D10Predicate_QueryInterface(predicate
, &IID_ID3D11Predicate
, (void **)&iface
);
3495 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
3496 "Predicate should implement ID3D11Predicate.\n");
3497 if (SUCCEEDED(hr
)) IUnknown_Release(iface
);
3498 ID3D10Predicate_Release(predicate
);
3500 refcount
= ID3D10Device_Release(device
);
3501 ok(!refcount
, "Device has %u references left.\n", refcount
);
3504 static void test_timestamp_query(void)
3506 static const struct vec4 red
= {1.0f
, 0.0f
, 0.0f
, 1.0f
};
3508 D3D10_QUERY_DATA_TIMESTAMP_DISJOINT disjoint
, prev_disjoint
;
3509 ID3D10Query
*timestamp_query
, *timestamp_disjoint_query
;
3510 struct d3d10core_test_context test_context
;
3511 D3D10_QUERY_DESC query_desc
;
3512 unsigned int data_size
, i
;
3513 ID3D10Device
*device
;
3517 if (!init_test_context(&test_context
))
3520 device
= test_context
.device
;
3522 query_desc
.Query
= D3D10_QUERY_TIMESTAMP
;
3523 query_desc
.MiscFlags
= 0;
3524 hr
= ID3D10Device_CreateQuery(device
, &query_desc
, ×tamp_query
);
3525 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
3526 data_size
= ID3D10Query_GetDataSize(timestamp_query
);
3527 ok(data_size
== sizeof(UINT64
), "Got unexpected data size %u.\n", data_size
);
3529 query_desc
.Query
= D3D10_QUERY_TIMESTAMP_DISJOINT
;
3530 query_desc
.MiscFlags
= 0;
3531 hr
= ID3D10Device_CreateQuery(device
, &query_desc
, ×tamp_disjoint_query
);
3532 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
3533 data_size
= ID3D10Query_GetDataSize(timestamp_disjoint_query
);
3534 ok(data_size
== sizeof(disjoint
), "Got unexpected data size %u.\n", data_size
);
3536 /* Test a TIMESTAMP_DISJOINT query. */
3537 ID3D10Query_Begin(timestamp_disjoint_query
);
3538 ID3D10Query_End(timestamp_disjoint_query
);
3539 for (i
= 0; i
< 500; ++i
)
3541 if ((hr
= ID3D10Query_GetData(timestamp_disjoint_query
, NULL
, 0, 0)) != S_FALSE
)
3545 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
3547 disjoint
.Frequency
= 0xdeadbeef;
3548 disjoint
.Disjoint
= 0xff;
3549 hr
= ID3D10Query_GetData(timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
), 0);
3550 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
3551 ok(disjoint
.Frequency
!= 0xdeadbeef, "Frequency data was not modified.\n");
3552 ok(disjoint
.Disjoint
== TRUE
|| disjoint
.Disjoint
== FALSE
, "Got unexpected disjoint %#x.\n", disjoint
.Disjoint
);
3554 prev_disjoint
= disjoint
;
3556 disjoint
.Frequency
= 0xdeadbeef;
3557 disjoint
.Disjoint
= 0xff;
3558 hr
= ID3D10Query_GetData(timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
) - 1, 0);
3559 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
3560 hr
= ID3D10Query_GetData(timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
) + 1, 0);
3561 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
3562 hr
= ID3D10Query_GetData(timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
) / 2, 0);
3563 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
3564 hr
= ID3D10Query_GetData(timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
) * 2, 0);
3565 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
3566 ok(disjoint
.Frequency
== 0xdeadbeef, "Frequency data was modified.\n");
3567 ok(disjoint
.Disjoint
== 0xff, "Disjoint data was modified.\n");
3569 hr
= ID3D10Query_GetData(timestamp_disjoint_query
, NULL
, 0, 0);
3570 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
3571 hr
= ID3D10Query_GetData(timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
), D3D10_ASYNC_GETDATA_DONOTFLUSH
);
3572 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
3573 ok(!memcmp(&disjoint
, &prev_disjoint
, sizeof(disjoint
)), "Disjoint data mismatch.\n");
3575 hr
= ID3D10Query_GetData(timestamp_query
, NULL
, 0, 0);
3576 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
3577 hr
= ID3D10Query_GetData(timestamp_query
, ×tamp
, sizeof(timestamp
), 0);
3578 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
3580 /* Test a TIMESTAMP query inside a TIMESTAMP_DISJOINT query. */
3581 ID3D10Query_Begin(timestamp_disjoint_query
);
3583 hr
= ID3D10Query_GetData(timestamp_query
, ×tamp
, sizeof(timestamp
), 0);
3584 todo_wine
ok(hr
== DXGI_ERROR_INVALID_CALL
, "Got unexpected hr %#x.\n", hr
);
3586 draw_color_quad(&test_context
, &red
);
3588 ID3D10Query_End(timestamp_query
);
3589 for (i
= 0; i
< 500; ++i
)
3591 if ((hr
= ID3D10Query_GetData(timestamp_query
, NULL
, 0, 0)) != S_FALSE
)
3595 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
3597 timestamp
= 0xdeadbeef;
3598 hr
= ID3D10Query_GetData(timestamp_query
, ×tamp
, sizeof(timestamp
) / 2, 0);
3599 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
3600 ok(timestamp
== 0xdeadbeef, "Timestamp was modified.\n");
3602 hr
= ID3D10Query_GetData(timestamp_query
, ×tamp
, sizeof(timestamp
), 0);
3603 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
3604 ok(timestamp
!= 0xdeadbeef, "Timestamp was not modified.\n");
3606 timestamp
= 0xdeadbeef;
3607 hr
= ID3D10Query_GetData(timestamp_query
, ×tamp
, sizeof(timestamp
) - 1, 0);
3608 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
3609 hr
= ID3D10Query_GetData(timestamp_query
, ×tamp
, sizeof(timestamp
) + 1, 0);
3610 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
3611 hr
= ID3D10Query_GetData(timestamp_query
, ×tamp
, sizeof(timestamp
) / 2, 0);
3612 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
3613 hr
= ID3D10Query_GetData(timestamp_query
, ×tamp
, sizeof(timestamp
) * 2, 0);
3614 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
3615 ok(timestamp
== 0xdeadbeef, "Timestamp was modified.\n");
3617 ID3D10Query_End(timestamp_disjoint_query
);
3618 for (i
= 0; i
< 500; ++i
)
3620 if ((hr
= ID3D10Query_GetData(timestamp_disjoint_query
, NULL
, 0, 0)) != S_FALSE
)
3624 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
3626 disjoint
.Frequency
= 0xdeadbeef;
3627 disjoint
.Disjoint
= 0xff;
3628 hr
= ID3D10Query_GetData(timestamp_disjoint_query
, &disjoint
, sizeof(disjoint
), 0);
3629 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
3630 ok(disjoint
.Frequency
!= 0xdeadbeef, "Frequency data was not modified.\n");
3631 ok(disjoint
.Disjoint
== TRUE
|| disjoint
.Disjoint
== FALSE
, "Got unexpected disjoint %#x.\n", disjoint
.Disjoint
);
3633 /* It's not strictly necessary for the TIMESTAMP query to be inside a TIMESTAMP_DISJOINT query. */
3634 ID3D10Query_Release(timestamp_query
);
3635 query_desc
.Query
= D3D10_QUERY_TIMESTAMP
;
3636 query_desc
.MiscFlags
= 0;
3637 hr
= ID3D10Device_CreateQuery(device
, &query_desc
, ×tamp_query
);
3638 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
3640 draw_color_quad(&test_context
, &red
);
3642 ID3D10Query_End(timestamp_query
);
3643 for (i
= 0; i
< 500; ++i
)
3645 if ((hr
= ID3D10Query_GetData(timestamp_query
, NULL
, 0, 0)) != S_FALSE
)
3649 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
3650 hr
= ID3D10Query_GetData(timestamp_query
, ×tamp
, sizeof(timestamp
), 0);
3651 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
3653 ID3D10Query_Release(timestamp_query
);
3654 ID3D10Query_Release(timestamp_disjoint_query
);
3655 release_test_context(&test_context
);
3658 static void test_device_removed_reason(void)
3660 ID3D10Device
*device
;
3664 if (!(device
= create_device()))
3666 skip("Failed to create device, skipping tests.\n");
3670 hr
= ID3D10Device_GetDeviceRemovedReason(device
);
3671 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
3672 hr
= ID3D10Device_GetDeviceRemovedReason(device
);
3673 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
3675 refcount
= ID3D10Device_Release(device
);
3676 ok(!refcount
, "Device has %u references left.\n", refcount
);
3679 static void test_scissor(void)
3681 struct d3d10core_test_context test_context
;
3682 D3D10_RASTERIZER_DESC rs_desc
;
3683 ID3D10RasterizerState
*rs
;
3684 D3D10_RECT scissor_rect
;
3685 ID3D10PixelShader
*ps
;
3686 ID3D10Device
*device
;
3690 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 1.0f
};
3691 static const DWORD ps_code
[] =
3694 float4
main(float4 position
: SV_POSITION
) : SV_Target
3696 return float4(0.0, 1.0, 0.0, 1.0);
3699 0x43425844, 0x30240e72, 0x012f250c, 0x8673c6ea, 0x392e4cec, 0x00000001, 0x000000d4, 0x00000003,
3700 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
3701 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
3702 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
3703 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000038, 0x00000040,
3704 0x0000000e, 0x03000065, 0x001020f2, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002,
3705 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e,
3708 if (!init_test_context(&test_context
))
3711 device
= test_context
.device
;
3713 hr
= ID3D10Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), &ps
);
3714 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
3716 rs_desc
.FillMode
= D3D10_FILL_SOLID
;
3717 rs_desc
.CullMode
= D3D10_CULL_BACK
;
3718 rs_desc
.FrontCounterClockwise
= FALSE
;
3719 rs_desc
.DepthBias
= 0;
3720 rs_desc
.DepthBiasClamp
= 0.0f
;
3721 rs_desc
.SlopeScaledDepthBias
= 0.0f
;
3722 rs_desc
.DepthClipEnable
= TRUE
;
3723 rs_desc
.ScissorEnable
= TRUE
;
3724 rs_desc
.MultisampleEnable
= FALSE
;
3725 rs_desc
.AntialiasedLineEnable
= FALSE
;
3726 hr
= ID3D10Device_CreateRasterizerState(device
, &rs_desc
, &rs
);
3727 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
3729 ID3D10Device_PSSetShader(device
, ps
);
3731 scissor_rect
.left
= 160;
3732 scissor_rect
.top
= 120;
3733 scissor_rect
.right
= 480;
3734 scissor_rect
.bottom
= 360;
3735 ID3D10Device_RSSetScissorRects(device
, 1, &scissor_rect
);
3737 ID3D10Device_ClearRenderTargetView(device
, test_context
.backbuffer_rtv
, red
);
3738 check_texture_color(test_context
.backbuffer
, 0xff0000ff, 1);
3740 draw_quad(&test_context
);
3741 color
= get_texture_color(test_context
.backbuffer
, 320, 60);
3742 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
3743 color
= get_texture_color(test_context
.backbuffer
, 80, 240);
3744 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
3745 color
= get_texture_color(test_context
.backbuffer
, 320, 240);
3746 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
3747 color
= get_texture_color(test_context
.backbuffer
, 560, 240);
3748 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
3749 color
= get_texture_color(test_context
.backbuffer
, 320, 420);
3750 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
3752 ID3D10Device_ClearRenderTargetView(device
, test_context
.backbuffer_rtv
, red
);
3753 ID3D10Device_RSSetState(device
, rs
);
3754 draw_quad(&test_context
);
3755 color
= get_texture_color(test_context
.backbuffer
, 320, 60);
3756 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
3757 color
= get_texture_color(test_context
.backbuffer
, 80, 240);
3758 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
3759 color
= get_texture_color(test_context
.backbuffer
, 320, 240);
3760 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
3761 color
= get_texture_color(test_context
.backbuffer
, 560, 240);
3762 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
3763 color
= get_texture_color(test_context
.backbuffer
, 320, 420);
3764 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
3766 ID3D10RasterizerState_Release(rs
);
3767 ID3D10PixelShader_Release(ps
);
3768 release_test_context(&test_context
);
3771 static void test_clear_state(void)
3773 static const D3D10_INPUT_ELEMENT_DESC layout_desc
[] =
3775 {"POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, 0, D3D10_INPUT_PER_VERTEX_DATA
, 0},
3778 float4
main(float4 pos
: POSITION
) : POSITION
3783 static const DWORD simple_vs
[] =
3785 0x43425844, 0x66689e7c, 0x643f0971, 0xb7f67ff4, 0xabc48688, 0x00000001, 0x000000d4, 0x00000003,
3786 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
3787 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
3788 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
3789 0x00000000, 0x0000000f, 0x49534f50, 0x4e4f4954, 0xababab00, 0x52444853, 0x00000038, 0x00010040,
3790 0x0000000e, 0x0300005f, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
3791 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
3797 float4 pos
: SV_POSITION
;
3801 void main(point float4 vin
[1] : POSITION
, inout TriangleStream
<gs_out
> vout
)
3803 float offset
= 0.1 * vin
[0].w
;
3806 v
.pos
= float4(vin
[0].x
- offset
, vin
[0].y
- offset
, vin
[0].z
, vin
[0].w
);
3808 v
.pos
= float4(vin
[0].x
- offset
, vin
[0].y
+ offset
, vin
[0].z
, vin
[0].w
);
3810 v
.pos
= float4(vin
[0].x
+ offset
, vin
[0].y
- offset
, vin
[0].z
, vin
[0].w
);
3812 v
.pos
= float4(vin
[0].x
+ offset
, vin
[0].y
+ offset
, vin
[0].z
, vin
[0].w
);
3816 static const DWORD simple_gs
[] =
3818 0x43425844, 0x000ee786, 0xc624c269, 0x885a5cbe, 0x444b3b1f, 0x00000001, 0x0000023c, 0x00000003,
3819 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
3820 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
3821 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
3822 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x000001a0, 0x00020040,
3823 0x00000068, 0x0400005f, 0x002010f2, 0x00000001, 0x00000000, 0x02000068, 0x00000001, 0x0100085d,
3824 0x0100285c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x0200005e, 0x00000004, 0x0f000032,
3825 0x00100032, 0x00000000, 0x80201ff6, 0x00000041, 0x00000000, 0x00000000, 0x00004002, 0x3dcccccd,
3826 0x3dcccccd, 0x00000000, 0x00000000, 0x00201046, 0x00000000, 0x00000000, 0x05000036, 0x00102032,
3827 0x00000000, 0x00100046, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000,
3828 0x00000000, 0x01000013, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0e000032,
3829 0x00100052, 0x00000000, 0x00201ff6, 0x00000000, 0x00000000, 0x00004002, 0x3dcccccd, 0x00000000,
3830 0x3dcccccd, 0x00000000, 0x00201106, 0x00000000, 0x00000000, 0x05000036, 0x00102022, 0x00000000,
3831 0x0010002a, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000, 0x00000000,
3832 0x01000013, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x05000036, 0x00102022,
3833 0x00000000, 0x0010001a, 0x00000000, 0x06000036, 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000,
3834 0x00000000, 0x01000013, 0x05000036, 0x00102032, 0x00000000, 0x00100086, 0x00000000, 0x06000036,
3835 0x001020c2, 0x00000000, 0x00201ea6, 0x00000000, 0x00000000, 0x01000013, 0x0100003e,
3839 float4
main(float4 color
: COLOR
) : SV_TARGET
3844 static const DWORD simple_ps
[] =
3846 0x43425844, 0x08c2b568, 0x17d33120, 0xb7d82948, 0x13a570fb, 0x00000001, 0x000000d0, 0x00000003,
3847 0x0000002c, 0x0000005c, 0x00000090, 0x4e475349, 0x00000028, 0x00000001, 0x00000008, 0x00000020,
3848 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x4f4c4f43, 0xabab0052, 0x4e47534f,
3849 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
3850 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
3851 0x03001062, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x05000036, 0x001020f2,
3852 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
3855 D3D10_VIEWPORT tmp_viewport
[D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
];
3856 ID3D10ShaderResourceView
*tmp_srv
[D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
];
3857 ID3D10ShaderResourceView
*srv
[D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
];
3858 ID3D10RenderTargetView
*tmp_rtv
[D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
];
3859 RECT tmp_rect
[D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
];
3860 ID3D10SamplerState
*tmp_sampler
[D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
];
3861 ID3D10RenderTargetView
*rtv
[D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
];
3862 ID3D10Texture2D
*rt_texture
[D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
];
3863 ID3D10Buffer
*cb
[D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
];
3864 ID3D10Buffer
*tmp_buffer
[D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
];
3865 ID3D10SamplerState
*sampler
[D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
];
3866 ID3D10Buffer
*buffer
[D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
];
3867 UINT offset
[D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
];
3868 UINT stride
[D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
];
3869 ID3D10Buffer
*so_buffer
[D3D10_SO_BUFFER_SLOT_COUNT
];
3870 ID3D10InputLayout
*tmp_input_layout
, *input_layout
;
3871 ID3D10DepthStencilState
*tmp_ds_state
, *ds_state
;
3872 ID3D10BlendState
*tmp_blend_state
, *blend_state
;
3873 ID3D10RasterizerState
*tmp_rs_state
, *rs_state
;
3874 ID3D10Predicate
*tmp_predicate
, *predicate
;
3875 D3D10_SHADER_RESOURCE_VIEW_DESC srv_desc
;
3876 ID3D10DepthStencilView
*tmp_dsv
, *dsv
;
3877 D3D10_PRIMITIVE_TOPOLOGY topology
;
3878 D3D10_TEXTURE2D_DESC texture_desc
;
3879 ID3D10GeometryShader
*tmp_gs
, *gs
;
3880 D3D10_DEPTH_STENCIL_DESC ds_desc
;
3881 ID3D10VertexShader
*tmp_vs
, *vs
;
3882 D3D10_SAMPLER_DESC sampler_desc
;
3883 D3D10_QUERY_DESC predicate_desc
;
3884 ID3D10PixelShader
*tmp_ps
, *ps
;
3885 D3D10_RASTERIZER_DESC rs_desc
;
3886 D3D10_BLEND_DESC blend_desc
;
3887 ID3D10Texture2D
*ds_texture
;
3888 float tmp_blend_factor
[4];
3889 float blend_factor
[4];
3890 ID3D10Device
*device
;
3891 BOOL predicate_value
;
3899 if (!(device
= create_device()))
3901 skip("Failed to create device, skipping tests.\n");
3905 /* Verify the initial state after device creation. */
3907 ID3D10Device_VSGetConstantBuffers(device
, 0, D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, tmp_buffer
);
3908 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
3910 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
3912 ID3D10Device_VSGetShaderResources(device
, 0, D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
3913 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
3915 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
3917 ID3D10Device_VSGetSamplers(device
, 0, D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
3918 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
3920 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
3922 ID3D10Device_VSGetShader(device
, &tmp_vs
);
3923 ok(!tmp_vs
, "Got unexpected vertex shader %p.\n", tmp_vs
);
3925 ID3D10Device_GSGetConstantBuffers(device
, 0, D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, tmp_buffer
);
3926 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
3928 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
3930 ID3D10Device_GSGetShaderResources(device
, 0, D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
3931 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
3933 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
3935 ID3D10Device_GSGetSamplers(device
, 0, D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
3936 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
3938 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
3940 ID3D10Device_GSGetShader(device
, &tmp_gs
);
3941 ok(!tmp_gs
, "Got unexpected geometry shader %p.\n", tmp_gs
);
3943 ID3D10Device_PSGetConstantBuffers(device
, 0, D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, tmp_buffer
);
3944 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
3946 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
3948 ID3D10Device_PSGetShaderResources(device
, 0, D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
3949 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
3951 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
3953 ID3D10Device_PSGetSamplers(device
, 0, D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
3954 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
3956 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
3958 ID3D10Device_PSGetShader(device
, &tmp_ps
);
3959 ok(!tmp_ps
, "Got unexpected pixel shader %p.\n", tmp_ps
);
3961 ID3D10Device_IAGetVertexBuffers(device
, 0, D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
, tmp_buffer
, stride
, offset
);
3962 for (i
= 0; i
< D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
3964 ok(!tmp_buffer
[i
], "Got unexpected vertex buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
3965 ok(!stride
[i
], "Got unexpected stride %u in slot %u.\n", stride
[i
], i
);
3966 ok(!offset
[i
], "Got unexpected offset %u in slot %u.\n", offset
[i
], i
);
3968 ID3D10Device_IAGetIndexBuffer(device
, tmp_buffer
, &format
, offset
);
3969 ok(!tmp_buffer
[0], "Got unexpected index buffer %p.\n", tmp_buffer
[0]);
3970 ok(format
== DXGI_FORMAT_UNKNOWN
, "Got unexpected index buffer format %#x.\n", format
);
3971 ok(!offset
[0], "Got unexpected index buffer offset %u.\n", offset
[0]);
3972 ID3D10Device_IAGetInputLayout(device
, &tmp_input_layout
);
3973 ok(!tmp_input_layout
, "Got unexpected input layout %p.\n", tmp_input_layout
);
3974 ID3D10Device_IAGetPrimitiveTopology(device
, &topology
);
3975 ok(topology
== D3D10_PRIMITIVE_TOPOLOGY_UNDEFINED
, "Got unexpected primitive topology %#x.\n", topology
);
3977 ID3D10Device_OMGetBlendState(device
, &tmp_blend_state
, blend_factor
, &sample_mask
);
3978 ok(!tmp_blend_state
, "Got unexpected blend state %p.\n", tmp_blend_state
);
3979 ok(blend_factor
[0] == 1.0f
&& blend_factor
[1] == 1.0f
3980 && blend_factor
[2] == 1.0f
&& blend_factor
[3] == 1.0f
,
3981 "Got unexpected blend factor {%.8e, %.8e, %.8e, %.8e}.\n",
3982 blend_factor
[0], blend_factor
[1], blend_factor
[2], blend_factor
[3]);
3983 ok(sample_mask
== D3D10_DEFAULT_SAMPLE_MASK
, "Got unexpected sample mask %#x.\n", sample_mask
);
3984 ID3D10Device_OMGetDepthStencilState(device
, &tmp_ds_state
, &stencil_ref
);
3985 ok(!tmp_ds_state
, "Got unexpected depth stencil state %p.\n", tmp_ds_state
);
3986 ok(!stencil_ref
, "Got unexpected stencil ref %u.\n", stencil_ref
);
3987 ID3D10Device_OMGetRenderTargets(device
, D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
, tmp_rtv
, &tmp_dsv
);
3988 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
3990 ok(!tmp_rtv
[i
], "Got unexpected render target view %p in slot %u.\n", tmp_rtv
[i
], i
);
3992 ok(!tmp_dsv
, "Got unexpected depth stencil view %p.\n", tmp_dsv
);
3994 ID3D10Device_RSGetScissorRects(device
, &count
, NULL
);
3995 todo_wine
ok(!count
, "Got unexpected scissor rect count %u.\n", count
);
3996 memset(tmp_rect
, 0x55, sizeof(tmp_rect
));
3997 count
= D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
;
3998 ID3D10Device_RSGetScissorRects(device
, &count
, tmp_rect
);
3999 for (i
= 0; i
< D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
; ++i
)
4001 ok(!tmp_rect
[i
].left
&& !tmp_rect
[i
].top
&& !tmp_rect
[i
].right
&& !tmp_rect
[i
].bottom
,
4002 "Got unexpected scissor rect %s in slot %u.\n", wine_dbgstr_rect(&tmp_rect
[i
]), i
);
4004 ID3D10Device_RSGetViewports(device
, &count
, NULL
);
4005 todo_wine
ok(!count
, "Got unexpected viewport count %u.\n", count
);
4006 memset(tmp_viewport
, 0x55, sizeof(tmp_viewport
));
4007 count
= D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
;
4008 ID3D10Device_RSGetViewports(device
, &count
, tmp_viewport
);
4009 for (i
= 0; i
< D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
; ++i
)
4011 ok(!tmp_viewport
[i
].TopLeftX
&& !tmp_viewport
[i
].TopLeftY
&& !tmp_viewport
[i
].Width
4012 && !tmp_viewport
[i
].Height
&& !tmp_viewport
[i
].MinDepth
&& !tmp_viewport
[i
].MaxDepth
,
4013 "Got unexpected viewport {%d, %d, %u, %u, %.8e, %.8e} in slot %u.\n",
4014 tmp_viewport
[i
].TopLeftX
, tmp_viewport
[i
].TopLeftY
, tmp_viewport
[i
].Width
,
4015 tmp_viewport
[i
].Height
, tmp_viewport
[i
].MinDepth
, tmp_viewport
[i
].MaxDepth
, i
);
4017 ID3D10Device_RSGetState(device
, &tmp_rs_state
);
4018 ok(!tmp_rs_state
, "Got unexpected rasterizer state %p.\n", tmp_rs_state
);
4020 ID3D10Device_SOGetTargets(device
, D3D10_SO_BUFFER_SLOT_COUNT
, tmp_buffer
, offset
);
4021 for (i
= 0; i
< D3D10_SO_BUFFER_SLOT_COUNT
; ++i
)
4023 ok(!tmp_buffer
[i
], "Got unexpected stream output %p in slot %u.\n", tmp_buffer
[i
], i
);
4024 ok(!offset
[i
], "Got unexpected stream output offset %u in slot %u.\n", offset
[i
], i
);
4027 ID3D10Device_GetPredication(device
, &tmp_predicate
, &predicate_value
);
4028 ok(!tmp_predicate
, "Got unexpected predicate %p.\n", tmp_predicate
);
4029 ok(!predicate_value
, "Got unexpected predicate value %#x.\n", predicate_value
);
4031 /* Create resources. */
4033 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4034 cb
[i
] = create_buffer(device
, D3D10_BIND_CONSTANT_BUFFER
, 1024, NULL
);
4036 for (i
= 0; i
< D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4038 buffer
[i
] = create_buffer(device
,
4039 D3D10_BIND_VERTEX_BUFFER
| D3D10_BIND_INDEX_BUFFER
| D3D10_BIND_SHADER_RESOURCE
,
4042 stride
[i
] = (i
+ 1) * 4;
4043 offset
[i
] = (i
+ 1) * 16;
4046 for (i
= 0; i
< D3D10_SO_BUFFER_SLOT_COUNT
; ++i
)
4047 so_buffer
[i
] = create_buffer(device
, D3D10_BIND_STREAM_OUTPUT
, 1024, NULL
);
4049 srv_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
4050 srv_desc
.ViewDimension
= D3D10_SRV_DIMENSION_BUFFER
;
4051 U(srv_desc
).Buffer
.ElementOffset
= 0;
4052 U(srv_desc
).Buffer
.ElementWidth
= 64;
4054 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4056 hr
= ID3D10Device_CreateShaderResourceView(device
,
4057 (ID3D10Resource
*)buffer
[i
% D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
], &srv_desc
, &srv
[i
]);
4058 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
4061 sampler_desc
.Filter
= D3D10_FILTER_MIN_MAG_MIP_LINEAR
;
4062 sampler_desc
.AddressU
= D3D10_TEXTURE_ADDRESS_CLAMP
;
4063 sampler_desc
.AddressV
= D3D10_TEXTURE_ADDRESS_CLAMP
;
4064 sampler_desc
.AddressW
= D3D10_TEXTURE_ADDRESS_CLAMP
;
4065 sampler_desc
.MipLODBias
= 0.0f
;
4066 sampler_desc
.MaxAnisotropy
= 16;
4067 sampler_desc
.ComparisonFunc
= D3D10_COMPARISON_NEVER
;
4068 sampler_desc
.BorderColor
[0] = 0.0f
;
4069 sampler_desc
.BorderColor
[1] = 0.0f
;
4070 sampler_desc
.BorderColor
[2] = 0.0f
;
4071 sampler_desc
.BorderColor
[3] = 0.0f
;
4072 sampler_desc
.MinLOD
= 0.0f
;
4073 sampler_desc
.MaxLOD
= 16.0f
;
4075 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4077 sampler_desc
.MinLOD
= (float)i
;
4079 hr
= ID3D10Device_CreateSamplerState(device
, &sampler_desc
, &sampler
[i
]);
4080 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
4083 hr
= ID3D10Device_CreateVertexShader(device
, simple_vs
, sizeof(simple_vs
), &vs
);
4084 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
4086 hr
= ID3D10Device_CreateGeometryShader(device
, simple_gs
, sizeof(simple_gs
), &gs
);
4087 ok(SUCCEEDED(hr
), "Failed to create geometry shader, hr %#x.\n", hr
);
4089 hr
= ID3D10Device_CreatePixelShader(device
, simple_ps
, sizeof(simple_ps
), &ps
);
4090 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
4092 hr
= ID3D10Device_CreateInputLayout(device
, layout_desc
, sizeof(layout_desc
) / sizeof(*layout_desc
),
4093 simple_vs
, sizeof(simple_vs
), &input_layout
);
4094 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
4096 blend_desc
.AlphaToCoverageEnable
= FALSE
;
4097 blend_desc
.BlendEnable
[0] = FALSE
;
4098 blend_desc
.BlendEnable
[1] = FALSE
;
4099 blend_desc
.BlendEnable
[2] = FALSE
;
4100 blend_desc
.BlendEnable
[3] = FALSE
;
4101 blend_desc
.BlendEnable
[4] = FALSE
;
4102 blend_desc
.BlendEnable
[5] = FALSE
;
4103 blend_desc
.BlendEnable
[6] = FALSE
;
4104 blend_desc
.BlendEnable
[7] = FALSE
;
4105 blend_desc
.SrcBlend
= D3D10_BLEND_ONE
;
4106 blend_desc
.DestBlend
= D3D10_BLEND_ZERO
;
4107 blend_desc
.BlendOp
= D3D10_BLEND_OP_ADD
;
4108 blend_desc
.SrcBlendAlpha
= D3D10_BLEND_ONE
;
4109 blend_desc
.DestBlendAlpha
= D3D10_BLEND_ZERO
;
4110 blend_desc
.BlendOpAlpha
= D3D10_BLEND_OP_ADD
;
4111 blend_desc
.RenderTargetWriteMask
[0] = D3D10_COLOR_WRITE_ENABLE_ALL
;
4112 blend_desc
.RenderTargetWriteMask
[1] = D3D10_COLOR_WRITE_ENABLE_ALL
;
4113 blend_desc
.RenderTargetWriteMask
[2] = D3D10_COLOR_WRITE_ENABLE_ALL
;
4114 blend_desc
.RenderTargetWriteMask
[3] = D3D10_COLOR_WRITE_ENABLE_ALL
;
4115 blend_desc
.RenderTargetWriteMask
[4] = D3D10_COLOR_WRITE_ENABLE_ALL
;
4116 blend_desc
.RenderTargetWriteMask
[5] = D3D10_COLOR_WRITE_ENABLE_ALL
;
4117 blend_desc
.RenderTargetWriteMask
[6] = D3D10_COLOR_WRITE_ENABLE_ALL
;
4118 blend_desc
.RenderTargetWriteMask
[7] = D3D10_COLOR_WRITE_ENABLE_ALL
;
4120 hr
= ID3D10Device_CreateBlendState(device
, &blend_desc
, &blend_state
);
4121 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
4123 ds_desc
.DepthEnable
= TRUE
;
4124 ds_desc
.DepthWriteMask
= D3D10_DEPTH_WRITE_MASK_ALL
;
4125 ds_desc
.DepthFunc
= D3D10_COMPARISON_LESS
;
4126 ds_desc
.StencilEnable
= FALSE
;
4127 ds_desc
.StencilReadMask
= D3D10_DEFAULT_STENCIL_READ_MASK
;
4128 ds_desc
.StencilWriteMask
= D3D10_DEFAULT_STENCIL_WRITE_MASK
;
4129 ds_desc
.FrontFace
.StencilFailOp
= D3D10_STENCIL_OP_KEEP
;
4130 ds_desc
.FrontFace
.StencilDepthFailOp
= D3D10_STENCIL_OP_KEEP
;
4131 ds_desc
.FrontFace
.StencilPassOp
= D3D10_STENCIL_OP_KEEP
;
4132 ds_desc
.FrontFace
.StencilFunc
= D3D10_COMPARISON_ALWAYS
;
4133 ds_desc
.BackFace
.StencilFailOp
= D3D10_STENCIL_OP_KEEP
;
4134 ds_desc
.BackFace
.StencilDepthFailOp
= D3D10_STENCIL_OP_KEEP
;
4135 ds_desc
.BackFace
.StencilPassOp
= D3D10_STENCIL_OP_KEEP
;
4136 ds_desc
.BackFace
.StencilFunc
= D3D10_COMPARISON_ALWAYS
;
4138 hr
= ID3D10Device_CreateDepthStencilState(device
, &ds_desc
, &ds_state
);
4139 ok(SUCCEEDED(hr
), "Failed to create depthstencil state, hr %#x.\n", hr
);
4141 texture_desc
.Width
= 512;
4142 texture_desc
.Height
= 512;
4143 texture_desc
.MipLevels
= 1;
4144 texture_desc
.ArraySize
= 1;
4145 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
4146 texture_desc
.SampleDesc
.Count
= 1;
4147 texture_desc
.SampleDesc
.Quality
= 0;
4148 texture_desc
.Usage
= D3D10_USAGE_DEFAULT
;
4149 texture_desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
4150 texture_desc
.CPUAccessFlags
= 0;
4151 texture_desc
.MiscFlags
= 0;
4153 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
4155 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rt_texture
[i
]);
4156 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
4159 texture_desc
.Format
= DXGI_FORMAT_D24_UNORM_S8_UINT
;
4160 texture_desc
.BindFlags
= D3D10_BIND_DEPTH_STENCIL
;
4162 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &ds_texture
);
4163 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
4165 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
4167 hr
= ID3D10Device_CreateRenderTargetView(device
, (ID3D10Resource
*)rt_texture
[i
], NULL
, &rtv
[i
]);
4168 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
4171 hr
= ID3D10Device_CreateDepthStencilView(device
, (ID3D10Resource
*)ds_texture
, NULL
, &dsv
);
4172 ok(SUCCEEDED(hr
), "Failed to create depthstencil view, hr %#x.\n", hr
);
4174 for (i
= 0; i
< D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
; ++i
)
4176 SetRect(&tmp_rect
[i
], i
, i
* 2, i
+ 1, (i
+ 1) * 2);
4178 tmp_viewport
[i
].TopLeftX
= i
* 3;
4179 tmp_viewport
[i
].TopLeftY
= i
* 4;
4180 tmp_viewport
[i
].Width
= 3;
4181 tmp_viewport
[i
].Height
= 4;
4182 tmp_viewport
[i
].MinDepth
= i
* 0.01f
;
4183 tmp_viewport
[i
].MaxDepth
= (i
+ 1) * 0.01f
;
4186 rs_desc
.FillMode
= D3D10_FILL_SOLID
;
4187 rs_desc
.CullMode
= D3D10_CULL_BACK
;
4188 rs_desc
.FrontCounterClockwise
= FALSE
;
4189 rs_desc
.DepthBias
= 0;
4190 rs_desc
.DepthBiasClamp
= 0.0f
;
4191 rs_desc
.SlopeScaledDepthBias
= 0.0f
;
4192 rs_desc
.DepthClipEnable
= TRUE
;
4193 rs_desc
.ScissorEnable
= FALSE
;
4194 rs_desc
.MultisampleEnable
= FALSE
;
4195 rs_desc
.AntialiasedLineEnable
= FALSE
;
4197 hr
= ID3D10Device_CreateRasterizerState(device
, &rs_desc
, &rs_state
);
4198 ok(SUCCEEDED(hr
), "Failed to create rasterizer state, hr %#x.\n", hr
);
4200 predicate_desc
.Query
= D3D10_QUERY_OCCLUSION_PREDICATE
;
4201 predicate_desc
.MiscFlags
= 0;
4203 hr
= ID3D10Device_CreatePredicate(device
, &predicate_desc
, &predicate
);
4204 ok(SUCCEEDED(hr
), "Failed to create predicate, hr %#x.\n", hr
);
4206 /* Verify the behavior of set state methods. */
4208 blend_factor
[0] = 0.1f
;
4209 blend_factor
[1] = 0.2f
;
4210 blend_factor
[2] = 0.3f
;
4211 blend_factor
[3] = 0.4f
;
4212 ID3D10Device_OMSetBlendState(device
, blend_state
, blend_factor
, D3D10_DEFAULT_SAMPLE_MASK
);
4213 ID3D10Device_OMGetBlendState(device
, &tmp_blend_state
, tmp_blend_factor
, &sample_mask
);
4214 ok(tmp_blend_factor
[0] == 0.1f
&& tmp_blend_factor
[1] == 0.2f
4215 && tmp_blend_factor
[2] == 0.3f
&& tmp_blend_factor
[3] == 0.4f
,
4216 "Got unexpected blend factor {%.8e, %.8e, %.8e, %.8e}.\n",
4217 tmp_blend_factor
[0], tmp_blend_factor
[1], tmp_blend_factor
[2], tmp_blend_factor
[3]);
4218 ID3D10BlendState_Release(tmp_blend_state
);
4220 ID3D10Device_OMSetBlendState(device
, blend_state
, NULL
, D3D10_DEFAULT_SAMPLE_MASK
);
4221 ID3D10Device_OMGetBlendState(device
, &tmp_blend_state
, tmp_blend_factor
, &sample_mask
);
4222 ok(tmp_blend_factor
[0] == 1.0f
&& tmp_blend_factor
[1] == 1.0f
4223 && tmp_blend_factor
[2] == 1.0f
&& tmp_blend_factor
[3] == 1.0f
,
4224 "Got unexpected blend factor {%.8e, %.8e, %.8e, %.8e}.\n",
4225 tmp_blend_factor
[0], tmp_blend_factor
[1], tmp_blend_factor
[2], tmp_blend_factor
[3]);
4226 ID3D10BlendState_Release(tmp_blend_state
);
4230 ID3D10Device_VSSetConstantBuffers(device
, 0, D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, cb
);
4231 ID3D10Device_VSSetShaderResources(device
, 0, D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, srv
);
4232 ID3D10Device_VSSetSamplers(device
, 0, D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
, sampler
);
4233 ID3D10Device_VSSetShader(device
, vs
);
4235 ID3D10Device_GSSetConstantBuffers(device
, 0, D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, cb
);
4236 ID3D10Device_GSSetShaderResources(device
, 0, D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, srv
);
4237 ID3D10Device_GSSetSamplers(device
, 0, D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
, sampler
);
4238 ID3D10Device_GSSetShader(device
, gs
);
4240 ID3D10Device_PSSetConstantBuffers(device
, 0, D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, cb
);
4241 ID3D10Device_PSSetShaderResources(device
, 0, D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, srv
);
4242 ID3D10Device_PSSetSamplers(device
, 0, D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
, sampler
);
4243 ID3D10Device_PSSetShader(device
, ps
);
4245 ID3D10Device_IASetVertexBuffers(device
, 0, D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
, buffer
, stride
, offset
);
4246 ID3D10Device_IASetIndexBuffer(device
, buffer
[0], DXGI_FORMAT_R32_UINT
, offset
[0]);
4247 ID3D10Device_IASetInputLayout(device
, input_layout
);
4248 ID3D10Device_IASetPrimitiveTopology(device
, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
4250 blend_factor
[0] = 0.1f
;
4251 blend_factor
[1] = 0.2f
;
4252 blend_factor
[2] = 0.3f
;
4253 blend_factor
[3] = 0.4f
;
4254 ID3D10Device_OMSetBlendState(device
, blend_state
, blend_factor
, 0xff00ff00);
4255 ID3D10Device_OMSetDepthStencilState(device
, ds_state
, 3);
4256 ID3D10Device_OMSetRenderTargets(device
, D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
, rtv
, dsv
);
4258 ID3D10Device_RSSetScissorRects(device
, D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
, tmp_rect
);
4259 ID3D10Device_RSSetViewports(device
, D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
, tmp_viewport
);
4260 ID3D10Device_RSSetState(device
, rs_state
);
4262 ID3D10Device_SOSetTargets(device
, D3D10_SO_BUFFER_SLOT_COUNT
, so_buffer
, offset
);
4264 ID3D10Device_SetPredication(device
, predicate
, TRUE
);
4266 /* Verify the set state. */
4268 ID3D10Device_VSGetConstantBuffers(device
, 0, D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, tmp_buffer
);
4269 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4271 ok(tmp_buffer
[i
] == cb
[i
], "Got unexpected constant buffer %p in slot %u, expected %p.\n",
4272 tmp_buffer
[i
], i
, cb
[i
]);
4273 ID3D10Buffer_Release(tmp_buffer
[i
]);
4275 ID3D10Device_VSGetShaderResources(device
, 0, D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
4276 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4278 ok(tmp_srv
[i
] == srv
[i
], "Got unexpected shader resource view %p in slot %u, expected %p.\n",
4279 tmp_srv
[i
], i
, srv
[i
]);
4280 ID3D10ShaderResourceView_Release(tmp_srv
[i
]);
4282 ID3D10Device_VSGetSamplers(device
, 0, D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
4283 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4285 ok(tmp_sampler
[i
] == sampler
[i
], "Got unexpected sampler %p in slot %u, expected %p.\n",
4286 tmp_sampler
[i
], i
, sampler
[i
]);
4287 ID3D10SamplerState_Release(tmp_sampler
[i
]);
4289 ID3D10Device_VSGetShader(device
, &tmp_vs
);
4290 ok(tmp_vs
== vs
, "Got unexpected vertex shader %p, expected %p.\n", tmp_vs
, vs
);
4291 ID3D10VertexShader_Release(tmp_vs
);
4293 ID3D10Device_GSGetConstantBuffers(device
, 0, D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, tmp_buffer
);
4294 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4296 ok(tmp_buffer
[i
] == cb
[i
], "Got unexpected constant buffer %p in slot %u, expected %p.\n",
4297 tmp_buffer
[i
], i
, cb
[i
]);
4298 ID3D10Buffer_Release(tmp_buffer
[i
]);
4300 ID3D10Device_GSGetShaderResources(device
, 0, D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
4301 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4303 ok(tmp_srv
[i
] == srv
[i
], "Got unexpected shader resource view %p in slot %u, expected %p.\n",
4304 tmp_srv
[i
], i
, srv
[i
]);
4305 ID3D10ShaderResourceView_Release(tmp_srv
[i
]);
4307 ID3D10Device_GSGetSamplers(device
, 0, D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
4308 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4310 ok(tmp_sampler
[i
] == sampler
[i
], "Got unexpected sampler %p in slot %u, expected %p.\n",
4311 tmp_sampler
[i
], i
, sampler
[i
]);
4312 ID3D10SamplerState_Release(tmp_sampler
[i
]);
4314 ID3D10Device_GSGetShader(device
, &tmp_gs
);
4315 ok(tmp_gs
== gs
, "Got unexpected geometry shader %p, expected %p.\n", tmp_gs
, gs
);
4316 ID3D10GeometryShader_Release(tmp_gs
);
4318 ID3D10Device_PSGetConstantBuffers(device
, 0, D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, tmp_buffer
);
4319 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4321 ok(tmp_buffer
[i
] == cb
[i
], "Got unexpected constant buffer %p in slot %u, expected %p.\n",
4322 tmp_buffer
[i
], i
, cb
[i
]);
4323 ID3D10Buffer_Release(tmp_buffer
[i
]);
4325 ID3D10Device_PSGetShaderResources(device
, 0, D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
4326 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4328 ok(tmp_srv
[i
] == srv
[i
], "Got unexpected shader resource view %p in slot %u, expected %p.\n",
4329 tmp_srv
[i
], i
, srv
[i
]);
4330 ID3D10ShaderResourceView_Release(tmp_srv
[i
]);
4332 ID3D10Device_PSGetSamplers(device
, 0, D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
4333 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4335 ok(tmp_sampler
[i
] == sampler
[i
], "Got unexpected sampler %p in slot %u, expected %p.\n",
4336 tmp_sampler
[i
], i
, sampler
[i
]);
4337 ID3D10SamplerState_Release(tmp_sampler
[i
]);
4339 ID3D10Device_PSGetShader(device
, &tmp_ps
);
4340 ok(tmp_ps
== ps
, "Got unexpected pixel shader %p, expected %p.\n", tmp_ps
, ps
);
4341 ID3D10PixelShader_Release(tmp_ps
);
4343 ID3D10Device_IAGetVertexBuffers(device
, 0, D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
, tmp_buffer
, stride
, offset
);
4344 for (i
= 0; i
< D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4346 ok(tmp_buffer
[i
] == buffer
[i
], "Got unexpected vertex buffer %p in slot %u, expected %p.\n",
4347 tmp_buffer
[i
], i
, buffer
[i
]);
4348 ok(stride
[i
] == (i
+ 1) * 4, "Got unexpected stride %u in slot %u.\n", stride
[i
], i
);
4349 ok(offset
[i
] == (i
+ 1) * 16, "Got unexpected offset %u in slot %u.\n", offset
[i
], i
);
4350 ID3D10Buffer_Release(tmp_buffer
[i
]);
4352 ID3D10Device_IAGetIndexBuffer(device
, tmp_buffer
, &format
, offset
);
4353 ok(tmp_buffer
[0] == buffer
[0], "Got unexpected index buffer %p, expected %p.\n", tmp_buffer
[0], buffer
[0]);
4354 ID3D10Buffer_Release(tmp_buffer
[0]);
4355 ok(format
== DXGI_FORMAT_R32_UINT
, "Got unexpected index buffer format %#x.\n", format
);
4356 ok(offset
[0] == 16, "Got unexpected index buffer offset %u.\n", offset
[0]);
4357 ID3D10Device_IAGetInputLayout(device
, &tmp_input_layout
);
4358 ok(tmp_input_layout
== input_layout
, "Got unexpected input layout %p, expected %p.\n",
4359 tmp_input_layout
, input_layout
);
4360 ID3D10InputLayout_Release(tmp_input_layout
);
4361 ID3D10Device_IAGetPrimitiveTopology(device
, &topology
);
4362 ok(topology
== D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
, "Got unexpected primitive topology %#x.\n", topology
);
4364 ID3D10Device_OMGetBlendState(device
, &tmp_blend_state
, blend_factor
, &sample_mask
);
4365 ok(tmp_blend_state
== blend_state
, "Got unexpected blend state %p, expected %p.\n", tmp_blend_state
, blend_state
);
4366 ID3D10BlendState_Release(tmp_blend_state
);
4367 ok(blend_factor
[0] == 0.1f
&& blend_factor
[1] == 0.2f
4368 && blend_factor
[2] == 0.3f
&& blend_factor
[3] == 0.4f
,
4369 "Got unexpected blend factor {%.8e, %.8e, %.8e, %.8e}.\n",
4370 blend_factor
[0], blend_factor
[1], blend_factor
[2], blend_factor
[3]);
4371 ok(sample_mask
== 0xff00ff00, "Got unexpected sample mask %#x.\n", sample_mask
);
4372 ID3D10Device_OMGetDepthStencilState(device
, &tmp_ds_state
, &stencil_ref
);
4373 ok(tmp_ds_state
== ds_state
, "Got unexpected depth stencil state %p, expected %p.\n", tmp_ds_state
, ds_state
);
4374 ID3D10DepthStencilState_Release(tmp_ds_state
);
4375 ok(stencil_ref
== 3, "Got unexpected stencil ref %u.\n", stencil_ref
);
4376 ID3D10Device_OMGetRenderTargets(device
, D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
, tmp_rtv
, &tmp_dsv
);
4377 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
4379 ok(tmp_rtv
[i
] == rtv
[i
], "Got unexpected render target view %p in slot %u, expected %p.\n",
4380 tmp_rtv
[i
], i
, rtv
[i
]);
4381 ID3D10RenderTargetView_Release(tmp_rtv
[i
]);
4383 ok(tmp_dsv
== dsv
, "Got unexpected depth stencil view %p, expected %p.\n", tmp_dsv
, dsv
);
4384 ID3D10DepthStencilView_Release(tmp_dsv
);
4386 ID3D10Device_RSGetScissorRects(device
, &count
, NULL
);
4387 todo_wine
ok(count
== D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
,
4388 "Got unexpected scissor rect count %u.\n", count
);
4389 memset(tmp_rect
, 0x55, sizeof(tmp_rect
));
4390 ID3D10Device_RSGetScissorRects(device
, &count
, tmp_rect
);
4391 for (i
= 0; i
< count
; ++i
)
4393 ok(tmp_rect
[i
].left
== i
4394 && tmp_rect
[i
].top
== i
* 2
4395 && tmp_rect
[i
].right
== i
+ 1
4396 && tmp_rect
[i
].bottom
== (i
+ 1) * 2,
4397 "Got unexpected scissor rect %s in slot %u.\n", wine_dbgstr_rect(&tmp_rect
[i
]), i
);
4399 ID3D10Device_RSGetViewports(device
, &count
, NULL
);
4400 todo_wine
ok(count
== D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
,
4401 "Got unexpected viewport count %u.\n", count
);
4402 memset(tmp_viewport
, 0x55, sizeof(tmp_viewport
));
4403 ID3D10Device_RSGetViewports(device
, &count
, tmp_viewport
);
4404 for (i
= 0; i
< count
; ++i
)
4406 ok(tmp_viewport
[i
].TopLeftX
== i
* 3
4407 && tmp_viewport
[i
].TopLeftY
== i
* 4
4408 && tmp_viewport
[i
].Width
== 3
4409 && tmp_viewport
[i
].Height
== 4
4410 && compare_float(tmp_viewport
[i
].MinDepth
, i
* 0.01f
, 16)
4411 && compare_float(tmp_viewport
[i
].MaxDepth
, (i
+ 1) * 0.01f
, 16),
4412 "Got unexpected viewport {%d, %d, %u, %u, %.8e, %.8e} in slot %u.\n",
4413 tmp_viewport
[i
].TopLeftX
, tmp_viewport
[i
].TopLeftY
, tmp_viewport
[i
].Width
,
4414 tmp_viewport
[i
].Height
, tmp_viewport
[i
].MinDepth
, tmp_viewport
[i
].MaxDepth
, i
);
4416 ID3D10Device_RSGetState(device
, &tmp_rs_state
);
4417 ok(tmp_rs_state
== rs_state
, "Got unexpected rasterizer state %p, expected %p.\n", tmp_rs_state
, rs_state
);
4418 ID3D10RasterizerState_Release(tmp_rs_state
);
4420 ID3D10Device_SOGetTargets(device
, D3D10_SO_BUFFER_SLOT_COUNT
, tmp_buffer
, offset
);
4421 for (i
= 0; i
< D3D10_SO_BUFFER_SLOT_COUNT
; ++i
)
4423 ok(tmp_buffer
[i
] == so_buffer
[i
], "Got unexpected stream output %p in slot %u, expected %p.\n",
4424 tmp_buffer
[i
], i
, so_buffer
[i
]);
4425 ID3D10Buffer_Release(tmp_buffer
[i
]);
4426 todo_wine
ok(offset
[i
] == ~0u, "Got unexpected stream output offset %u in slot %u.\n", offset
[i
], i
);
4429 ID3D10Device_GetPredication(device
, &tmp_predicate
, &predicate_value
);
4430 ok(tmp_predicate
== predicate
, "Got unexpected predicate %p, expected %p.\n", tmp_predicate
, predicate
);
4431 ID3D10Predicate_Release(tmp_predicate
);
4432 ok(predicate_value
, "Got unexpected predicate value %#x.\n", predicate_value
);
4434 /* Verify ClearState(). */
4436 ID3D10Device_ClearState(device
);
4438 ID3D10Device_VSGetConstantBuffers(device
, 0, D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, tmp_buffer
);
4439 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4441 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
4443 ID3D10Device_VSGetShaderResources(device
, 0, D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
4444 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4446 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
4448 ID3D10Device_VSGetSamplers(device
, 0, D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
4449 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4451 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
4453 ID3D10Device_VSGetShader(device
, &tmp_vs
);
4454 ok(!tmp_vs
, "Got unexpected vertex shader %p.\n", tmp_vs
);
4456 ID3D10Device_GSGetConstantBuffers(device
, 0, D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, tmp_buffer
);
4457 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4459 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
4461 ID3D10Device_GSGetShaderResources(device
, 0, D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
4462 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4464 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
4466 ID3D10Device_GSGetSamplers(device
, 0, D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
4467 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4469 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
4471 ID3D10Device_GSGetShader(device
, &tmp_gs
);
4472 ok(!tmp_gs
, "Got unexpected geometry shader %p.\n", tmp_gs
);
4474 ID3D10Device_PSGetConstantBuffers(device
, 0, D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
, tmp_buffer
);
4475 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4477 ok(!tmp_buffer
[i
], "Got unexpected constant buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
4479 ID3D10Device_PSGetShaderResources(device
, 0, D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
, tmp_srv
);
4480 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4482 ok(!tmp_srv
[i
], "Got unexpected shader resource view %p in slot %u.\n", tmp_srv
[i
], i
);
4484 ID3D10Device_PSGetSamplers(device
, 0, D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
, tmp_sampler
);
4485 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4487 ok(!tmp_sampler
[i
], "Got unexpected sampler %p in slot %u.\n", tmp_sampler
[i
], i
);
4489 ID3D10Device_PSGetShader(device
, &tmp_ps
);
4490 ok(!tmp_ps
, "Got unexpected pixel shader %p.\n", tmp_ps
);
4492 ID3D10Device_IAGetVertexBuffers(device
, 0, D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
, tmp_buffer
, stride
, offset
);
4493 for (i
= 0; i
< D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4495 ok(!tmp_buffer
[i
], "Got unexpected vertex buffer %p in slot %u.\n", tmp_buffer
[i
], i
);
4496 todo_wine
ok(!stride
[i
], "Got unexpected stride %u in slot %u.\n", stride
[i
], i
);
4497 todo_wine
ok(!offset
[i
], "Got unexpected offset %u in slot %u.\n", offset
[i
], i
);
4499 ID3D10Device_IAGetIndexBuffer(device
, tmp_buffer
, &format
, offset
);
4500 ok(!tmp_buffer
[0], "Got unexpected index buffer %p.\n", tmp_buffer
[0]);
4501 ok(format
== DXGI_FORMAT_UNKNOWN
, "Got unexpected index buffer format %#x.\n", format
);
4502 ok(!offset
[0], "Got unexpected index buffer offset %u.\n", offset
[0]);
4503 ID3D10Device_IAGetInputLayout(device
, &tmp_input_layout
);
4504 ok(!tmp_input_layout
, "Got unexpected input layout %p.\n", tmp_input_layout
);
4505 ID3D10Device_IAGetPrimitiveTopology(device
, &topology
);
4506 ok(topology
== D3D10_PRIMITIVE_TOPOLOGY_UNDEFINED
, "Got unexpected primitive topology %#x.\n", topology
);
4508 ID3D10Device_OMGetBlendState(device
, &tmp_blend_state
, blend_factor
, &sample_mask
);
4509 ok(!tmp_blend_state
, "Got unexpected blend state %p.\n", tmp_blend_state
);
4510 ok(blend_factor
[0] == 1.0f
&& blend_factor
[1] == 1.0f
4511 && blend_factor
[2] == 1.0f
&& blend_factor
[3] == 1.0f
,
4512 "Got unexpected blend factor {%.8e, %.8e, %.8e, %.8e}.\n",
4513 blend_factor
[0], blend_factor
[1], blend_factor
[2], blend_factor
[3]);
4514 ok(sample_mask
== D3D10_DEFAULT_SAMPLE_MASK
, "Got unexpected sample mask %#x.\n", sample_mask
);
4515 ID3D10Device_OMGetDepthStencilState(device
, &tmp_ds_state
, &stencil_ref
);
4516 ok(!tmp_ds_state
, "Got unexpected depth stencil state %p.\n", tmp_ds_state
);
4517 ok(!stencil_ref
, "Got unexpected stencil ref %u.\n", stencil_ref
);
4518 ID3D10Device_OMGetRenderTargets(device
, D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
, tmp_rtv
, &tmp_dsv
);
4519 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
4521 ok(!tmp_rtv
[i
], "Got unexpected render target view %p in slot %u.\n", tmp_rtv
[i
], i
);
4523 ok(!tmp_dsv
, "Got unexpected depth stencil view %p.\n", tmp_dsv
);
4525 ID3D10Device_RSGetScissorRects(device
, &count
, NULL
);
4526 todo_wine
ok(!count
, "Got unexpected scissor rect count %u.\n", count
);
4527 memset(tmp_rect
, 0x55, sizeof(tmp_rect
));
4528 count
= D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
;
4529 ID3D10Device_RSGetScissorRects(device
, &count
, tmp_rect
);
4530 for (i
= 0; i
< D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
; ++i
)
4533 todo_wine
ok(!tmp_rect
[i
].left
&& !tmp_rect
[i
].top
&& !tmp_rect
[i
].right
&& !tmp_rect
[i
].bottom
,
4534 "Got unexpected scissor rect %s in slot %u.\n",
4535 wine_dbgstr_rect(&tmp_rect
[i
]), i
);
4537 ok(!tmp_rect
[i
].left
&& !tmp_rect
[i
].top
&& !tmp_rect
[i
].right
&& !tmp_rect
[i
].bottom
,
4538 "Got unexpected scissor rect %s in slot %u.\n",
4539 wine_dbgstr_rect(&tmp_rect
[i
]), i
);
4541 ID3D10Device_RSGetViewports(device
, &count
, NULL
);
4542 todo_wine
ok(!count
, "Got unexpected viewport count %u.\n", count
);
4543 memset(tmp_viewport
, 0x55, sizeof(tmp_viewport
));
4544 count
= D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
;
4545 ID3D10Device_RSGetViewports(device
, &count
, tmp_viewport
);
4546 for (i
= 0; i
< D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
; ++i
)
4549 todo_wine
ok(!tmp_viewport
[i
].TopLeftX
&& !tmp_viewport
[i
].TopLeftY
&& !tmp_viewport
[i
].Width
4550 && !tmp_viewport
[i
].Height
&& !tmp_viewport
[i
].MinDepth
&& !tmp_viewport
[i
].MaxDepth
,
4551 "Got unexpected viewport {%d, %d, %u, %u, %.8e, %.8e} in slot %u.\n",
4552 tmp_viewport
[i
].TopLeftX
, tmp_viewport
[i
].TopLeftY
, tmp_viewport
[i
].Width
,
4553 tmp_viewport
[i
].Height
, tmp_viewport
[i
].MinDepth
, tmp_viewport
[i
].MaxDepth
, i
);
4555 ok(!tmp_viewport
[i
].TopLeftX
&& !tmp_viewport
[i
].TopLeftY
&& !tmp_viewport
[i
].Width
4556 && !tmp_viewport
[i
].Height
&& !tmp_viewport
[i
].MinDepth
&& !tmp_viewport
[i
].MaxDepth
,
4557 "Got unexpected viewport {%d, %d, %u, %u, %.8e, %.8e} in slot %u.\n",
4558 tmp_viewport
[i
].TopLeftX
, tmp_viewport
[i
].TopLeftY
, tmp_viewport
[i
].Width
,
4559 tmp_viewport
[i
].Height
, tmp_viewport
[i
].MinDepth
, tmp_viewport
[i
].MaxDepth
, i
);
4561 ID3D10Device_RSGetState(device
, &tmp_rs_state
);
4562 ok(!tmp_rs_state
, "Got unexpected rasterizer state %p.\n", tmp_rs_state
);
4564 ID3D10Device_SOGetTargets(device
, D3D10_SO_BUFFER_SLOT_COUNT
, tmp_buffer
, offset
);
4565 for (i
= 0; i
< D3D10_SO_BUFFER_SLOT_COUNT
; ++i
)
4567 ok(!tmp_buffer
[i
], "Got unexpected stream output %p in slot %u.\n", tmp_buffer
[i
], i
);
4568 ok(!offset
[i
], "Got unexpected stream output offset %u in slot %u.\n", offset
[i
], i
);
4571 ID3D10Device_GetPredication(device
, &tmp_predicate
, &predicate_value
);
4572 ok(!tmp_predicate
, "Got unexpected predicate %p.\n", tmp_predicate
);
4573 ok(!predicate_value
, "Got unexpected predicate value %#x.\n", predicate_value
);
4577 ID3D10Predicate_Release(predicate
);
4578 ID3D10RasterizerState_Release(rs_state
);
4579 ID3D10DepthStencilView_Release(dsv
);
4580 ID3D10Texture2D_Release(ds_texture
);
4582 for (i
= 0; i
< D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT
; ++i
)
4584 ID3D10RenderTargetView_Release(rtv
[i
]);
4585 ID3D10Texture2D_Release(rt_texture
[i
]);
4588 ID3D10DepthStencilState_Release(ds_state
);
4589 ID3D10BlendState_Release(blend_state
);
4590 ID3D10InputLayout_Release(input_layout
);
4591 ID3D10VertexShader_Release(vs
);
4592 ID3D10GeometryShader_Release(gs
);
4593 ID3D10PixelShader_Release(ps
);
4595 for (i
= 0; i
< D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT
; ++i
)
4597 ID3D10SamplerState_Release(sampler
[i
]);
4600 for (i
= 0; i
< D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4602 ID3D10ShaderResourceView_Release(srv
[i
]);
4605 for (i
= 0; i
< D3D10_SO_BUFFER_SLOT_COUNT
; ++i
)
4607 ID3D10Buffer_Release(so_buffer
[i
]);
4610 for (i
= 0; i
< D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
; ++i
)
4612 ID3D10Buffer_Release(buffer
[i
]);
4615 for (i
= 0; i
< D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
; ++i
)
4617 ID3D10Buffer_Release(cb
[i
]);
4620 refcount
= ID3D10Device_Release(device
);
4621 ok(!refcount
, "Device has %u references left.\n", refcount
);
4624 static void test_blend(void)
4626 struct d3d10core_test_context test_context
;
4627 ID3D10BlendState
*src_blend
, *dst_blend
;
4628 ID3D10RenderTargetView
*offscreen_rtv
;
4629 D3D10_TEXTURE2D_DESC texture_desc
;
4630 ID3D10InputLayout
*input_layout
;
4631 D3D10_BLEND_DESC blend_desc
;
4632 unsigned int stride
, offset
;
4633 ID3D10Texture2D
*offscreen
;
4634 ID3D10VertexShader
*vs
;
4635 ID3D10PixelShader
*ps
;
4636 ID3D10Device
*device
;
4642 static const DWORD vs_code
[] =
4647 float4 position
: SV_POSITION
;
4648 float4 color
: COLOR
;
4651 struct vs_out
main(float4 position
: POSITION
, float4 color
: COLOR
)
4655 o
.position
= position
;
4661 0x43425844, 0x5c73b061, 0x5c71125f, 0x3f8b345f, 0xce04b9ab, 0x00000001, 0x00000140, 0x00000003,
4662 0x0000002c, 0x0000007c, 0x000000d0, 0x4e475349, 0x00000048, 0x00000002, 0x00000008, 0x00000038,
4663 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
4664 0x00000003, 0x00000001, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x4e47534f,
4665 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003, 0x00000000,
4666 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x505f5653,
4667 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000068, 0x00010040, 0x0000001a,
4668 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067, 0x001020f2,
4669 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2, 0x00000000,
4670 0x00101e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001, 0x0100003e,
4672 static const DWORD ps_code
[] =
4677 float4 position
: SV_POSITION
;
4678 float4 color
: COLOR
;
4681 float4
main(struct vs_out i
) : SV_TARGET
4686 0x43425844, 0xe2087fa6, 0xa35fbd95, 0x8e585b3f, 0x67890f54, 0x00000001, 0x000000f4, 0x00000003,
4687 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
4688 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
4689 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
4690 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
4691 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040,
4692 0x0000000e, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
4693 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
4697 struct vec3 position
;
4703 {{-1.0f
, -1.0f
, 0.1f
}, 0x4000ff00},
4704 {{-1.0f
, 0.0f
, 0.1f
}, 0x4000ff00},
4705 {{ 1.0f
, -1.0f
, 0.1f
}, 0x4000ff00},
4706 {{ 1.0f
, 0.0f
, 0.1f
}, 0x4000ff00},
4708 {{-1.0f
, 0.0f
, 0.1f
}, 0xc0ff0000},
4709 {{-1.0f
, 1.0f
, 0.1f
}, 0xc0ff0000},
4710 {{ 1.0f
, 0.0f
, 0.1f
}, 0xc0ff0000},
4711 {{ 1.0f
, 1.0f
, 0.1f
}, 0xc0ff0000},
4713 static const D3D10_INPUT_ELEMENT_DESC layout_desc
[] =
4715 {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT
, 0, 0, D3D10_INPUT_PER_VERTEX_DATA
, 0},
4716 {"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, 12, D3D10_INPUT_PER_VERTEX_DATA
, 0},
4718 static const float blend_factor
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
4719 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
4721 if (!init_test_context(&test_context
))
4724 device
= test_context
.device
;
4726 hr
= ID3D10Device_CreateInputLayout(device
, layout_desc
, sizeof(layout_desc
) / sizeof(*layout_desc
),
4727 vs_code
, sizeof(vs_code
), &input_layout
);
4728 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
4730 vb
= create_buffer(device
, D3D10_BIND_VERTEX_BUFFER
, sizeof(quads
), quads
);
4731 hr
= ID3D10Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), &vs
);
4732 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
4733 hr
= ID3D10Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), &ps
);
4734 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
4736 memset(&blend_desc
, 0, sizeof(blend_desc
));
4737 blend_desc
.BlendEnable
[0] = TRUE
;
4738 blend_desc
.SrcBlend
= D3D10_BLEND_SRC_ALPHA
;
4739 blend_desc
.DestBlend
= D3D10_BLEND_INV_SRC_ALPHA
;
4740 blend_desc
.BlendOp
= D3D10_BLEND_OP_ADD
;
4741 blend_desc
.SrcBlendAlpha
= D3D10_BLEND_SRC_ALPHA
;
4742 blend_desc
.DestBlendAlpha
= D3D10_BLEND_INV_SRC_ALPHA
;
4743 blend_desc
.BlendOpAlpha
= D3D10_BLEND_OP_ADD
;
4744 blend_desc
.RenderTargetWriteMask
[0] = D3D10_COLOR_WRITE_ENABLE_ALL
;
4746 hr
= ID3D10Device_CreateBlendState(device
, &blend_desc
, &src_blend
);
4747 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
4749 blend_desc
.SrcBlend
= D3D10_BLEND_DEST_ALPHA
;
4750 blend_desc
.DestBlend
= D3D10_BLEND_INV_DEST_ALPHA
;
4751 blend_desc
.SrcBlendAlpha
= D3D10_BLEND_DEST_ALPHA
;
4752 blend_desc
.DestBlendAlpha
= D3D10_BLEND_INV_DEST_ALPHA
;
4754 hr
= ID3D10Device_CreateBlendState(device
, &blend_desc
, &dst_blend
);
4755 ok(SUCCEEDED(hr
), "Failed to create blend state, hr %#x.\n", hr
);
4757 ID3D10Device_IASetInputLayout(device
, input_layout
);
4758 ID3D10Device_IASetPrimitiveTopology(device
, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
4759 stride
= sizeof(*quads
);
4761 ID3D10Device_IASetVertexBuffers(device
, 0, 1, &vb
, &stride
, &offset
);
4762 ID3D10Device_VSSetShader(device
, vs
);
4763 ID3D10Device_PSSetShader(device
, ps
);
4765 ID3D10Device_ClearRenderTargetView(device
, test_context
.backbuffer_rtv
, red
);
4767 ID3D10Device_OMSetBlendState(device
, src_blend
, blend_factor
, D3D10_DEFAULT_SAMPLE_MASK
);
4768 ID3D10Device_Draw(device
, 4, 0);
4769 ID3D10Device_OMSetBlendState(device
, dst_blend
, blend_factor
, D3D10_DEFAULT_SAMPLE_MASK
);
4770 ID3D10Device_Draw(device
, 4, 4);
4772 color
= get_texture_color(test_context
.backbuffer
, 320, 360);
4773 ok(compare_color(color
, 0x700040bf, 1), "Got unexpected color 0x%08x.\n", color
);
4774 color
= get_texture_color(test_context
.backbuffer
, 320, 120);
4775 ok(compare_color(color
, 0xa080007f, 1), "Got unexpected color 0x%08x.\n", color
);
4777 texture_desc
.Width
= 128;
4778 texture_desc
.Height
= 128;
4779 texture_desc
.MipLevels
= 1;
4780 texture_desc
.ArraySize
= 1;
4781 texture_desc
.Format
= DXGI_FORMAT_B8G8R8X8_UNORM
;
4782 texture_desc
.SampleDesc
.Count
= 1;
4783 texture_desc
.SampleDesc
.Quality
= 0;
4784 texture_desc
.Usage
= D3D10_USAGE_DEFAULT
;
4785 texture_desc
.BindFlags
= D3D10_BIND_SHADER_RESOURCE
| D3D10_BIND_RENDER_TARGET
;
4786 texture_desc
.CPUAccessFlags
= 0;
4787 texture_desc
.MiscFlags
= 0;
4789 /* DXGI_FORMAT_B8G8R8X8_UNORM is not supported on all implementations. */
4790 if (FAILED(ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &offscreen
)))
4792 skip("DXGI_FORMAT_B8G8R8X8_UNORM not supported, skipping tests.\n");
4796 hr
= ID3D10Device_CreateRenderTargetView(device
, (ID3D10Resource
*)offscreen
, NULL
, &offscreen_rtv
);
4797 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
4799 ID3D10Device_OMSetRenderTargets(device
, 1, &offscreen_rtv
, NULL
);
4807 ID3D10Device_RSSetViewports(device
, 1, &vp
);
4809 ID3D10Device_ClearRenderTargetView(device
, offscreen_rtv
, red
);
4811 ID3D10Device_OMSetBlendState(device
, src_blend
, blend_factor
, D3D10_DEFAULT_SAMPLE_MASK
);
4812 ID3D10Device_Draw(device
, 4, 0);
4813 ID3D10Device_OMSetBlendState(device
, dst_blend
, blend_factor
, D3D10_DEFAULT_SAMPLE_MASK
);
4814 ID3D10Device_Draw(device
, 4, 4);
4816 color
= get_texture_color(offscreen
, 64, 96) & 0x00ffffff;
4817 ok(compare_color(color
, 0x00bf4000, 1), "Got unexpected color 0x%08x.\n", color
);
4818 color
= get_texture_color(offscreen
, 64, 32) & 0x00ffffff;
4819 ok(compare_color(color
, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color
);
4821 ID3D10RenderTargetView_Release(offscreen_rtv
);
4822 ID3D10Texture2D_Release(offscreen
);
4824 ID3D10BlendState_Release(dst_blend
);
4825 ID3D10BlendState_Release(src_blend
);
4826 ID3D10PixelShader_Release(ps
);
4827 ID3D10VertexShader_Release(vs
);
4828 ID3D10Buffer_Release(vb
);
4829 ID3D10InputLayout_Release(input_layout
);
4830 release_test_context(&test_context
);
4833 static void test_texture(void)
4844 UINT miplevel_count
;
4847 D3D10_SUBRESOURCE_DATA data
[3];
4850 struct d3d10core_test_context test_context
;
4851 D3D10_SHADER_RESOURCE_VIEW_DESC srv_desc
;
4852 const struct texture
*current_texture
;
4853 D3D10_TEXTURE2D_DESC texture_desc
;
4854 D3D10_SAMPLER_DESC sampler_desc
;
4855 const struct shader
*current_ps
;
4856 ID3D10ShaderResourceView
*srv
;
4857 ID3D10SamplerState
*sampler
;
4858 struct texture_readback rb
;
4859 ID3D10Texture2D
*texture
;
4860 struct vec4 ps_constant
;
4861 ID3D10PixelShader
*ps
;
4862 ID3D10Device
*device
;
4863 unsigned int i
, x
, y
;
4868 static const DWORD ps_ld_code
[] =
4875 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
4878 t
.GetDimensions(miplevel
, p
.x
, p
.y
, p
.z
);
4880 p
*= float3(position
.x
/ 640.0f
, position
.y
/ 480.0f
, 1.0f
);
4881 return t
.Load(int3(p
));
4884 0x43425844, 0xbdda6bdf, 0xc6ffcdf1, 0xa58596b3, 0x822383f0, 0x00000001, 0x000001ac, 0x00000003,
4885 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
4886 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
4887 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
4888 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000110, 0x00000040,
4889 0x00000044, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04001858, 0x00107000, 0x00000000,
4890 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
4891 0x02000068, 0x00000001, 0x0600001c, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000,
4892 0x0700003d, 0x001000f2, 0x00000000, 0x0010000a, 0x00000000, 0x00107e46, 0x00000000, 0x07000038,
4893 0x00100032, 0x00000000, 0x00100046, 0x00000000, 0x00101046, 0x00000000, 0x06000036, 0x001000c2,
4894 0x00000000, 0x00208006, 0x00000000, 0x00000000, 0x0a000038, 0x001000f2, 0x00000000, 0x00100e46,
4895 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x3f800000, 0x3f800000, 0x0500001b, 0x001000f2,
4896 0x00000000, 0x00100e46, 0x00000000, 0x0700002d, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
4897 0x00107e46, 0x00000000, 0x0100003e,
4899 static const DWORD ps_ld_sint8_code
[] =
4904 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
4909 p
= float3(position
.x
/ 640.0f
, position
.y
/ 480.0f
, 0.0f
);
4910 t
.GetDimensions(0, s
.x
, s
.y
, s
.z
);
4913 c
= t
.Load(int3(p
));
4914 return (max(c
/ (float4
)127, (float4
)-1) + (float4
)1) / 2.0f
;
4917 0x43425844, 0xb3d0b0fc, 0x0e486f4a, 0xf67eec12, 0xfb9dd52f, 0x00000001, 0x00000240, 0x00000003,
4918 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
4919 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
4920 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
4921 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000001a4, 0x00000040,
4922 0x00000069, 0x04001858, 0x00107000, 0x00000000, 0x00003333, 0x04002064, 0x00101032, 0x00000000,
4923 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x0700003d, 0x001000f2,
4924 0x00000000, 0x00004001, 0x00000000, 0x00107e46, 0x00000000, 0x0a000038, 0x00100032, 0x00000001,
4925 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x08000036,
4926 0x001000c2, 0x00000001, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07000038,
4927 0x001000f2, 0x00000000, 0x00100f46, 0x00000000, 0x00100e46, 0x00000001, 0x0500001b, 0x001000f2,
4928 0x00000000, 0x00100e46, 0x00000000, 0x0700002d, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
4929 0x00107e46, 0x00000000, 0x0500002b, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x0a000038,
4930 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3c010204, 0x3c010204, 0x3c010204,
4931 0x3c010204, 0x0a000034, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0xbf800000,
4932 0xbf800000, 0xbf800000, 0xbf800000, 0x0a000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
4933 0x00004002, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000, 0x0a000038, 0x001020f2, 0x00000000,
4934 0x00100e46, 0x00000000, 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, 0x0100003e,
4936 static const DWORD ps_ld_uint8_code
[] =
4941 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
4945 p
= float3(position
.x
/ 640.0f
, position
.y
/ 480.0f
, 0.0f
);
4946 t
.GetDimensions(0, s
.x
, s
.y
, s
.z
);
4949 return t
.Load(int3(p
)) / (float4
)255;
4952 0x43425844, 0xd09917eb, 0x4508a07e, 0xb0b7250a, 0x228c1f0e, 0x00000001, 0x000001c8, 0x00000003,
4953 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
4954 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
4955 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
4956 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x0000012c, 0x00000040,
4957 0x0000004b, 0x04001858, 0x00107000, 0x00000000, 0x00004444, 0x04002064, 0x00101032, 0x00000000,
4958 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x0700003d, 0x001000f2,
4959 0x00000000, 0x00004001, 0x00000000, 0x00107e46, 0x00000000, 0x0a000038, 0x00100032, 0x00000001,
4960 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x08000036,
4961 0x001000c2, 0x00000001, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07000038,
4962 0x001000f2, 0x00000000, 0x00100f46, 0x00000000, 0x00100e46, 0x00000001, 0x0500001b, 0x001000f2,
4963 0x00000000, 0x00100e46, 0x00000000, 0x0700002d, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
4964 0x00107e46, 0x00000000, 0x05000056, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x0a000038,
4965 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3b808081, 0x3b808081, 0x3b808081,
4966 0x3b808081, 0x0100003e,
4968 static const DWORD ps_sample_code
[] =
4974 float4
main(float4 position
: SV_POSITION
) : SV_Target
4978 p
.x
= position
.x
/ 640.0f
;
4979 p
.y
= position
.y
/ 480.0f
;
4980 return t
.Sample(s
, p
);
4983 0x43425844, 0x1ce9b612, 0xc8176faa, 0xd37844af, 0xdb515605, 0x00000001, 0x00000134, 0x00000003,
4984 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
4985 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
4986 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
4987 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
4988 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
4989 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
4990 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
4991 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
4992 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
4994 static const DWORD ps_sample_b_code
[] =
5002 float4
main(float4 position
: SV_POSITION
) : SV_Target
5006 p
.x
= position
.x
/ 640.0f
;
5007 p
.y
= position
.y
/ 480.0f
;
5008 return t
.SampleBias(s
, p
, bias
);
5011 0x43425844, 0xc39b0686, 0x8244a7fc, 0x14c0b97a, 0x2900b3b7, 0x00000001, 0x00000150, 0x00000003,
5012 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
5013 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
5014 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
5015 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000b4, 0x00000040,
5016 0x0000002d, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000, 0x00000000,
5017 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001,
5018 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0a000038, 0x00100032, 0x00000000,
5019 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x0c00004a,
5020 0x001020f2, 0x00000000, 0x00100046, 0x00000000, 0x00107e46, 0x00000000, 0x00106000, 0x00000000,
5021 0x0020800a, 0x00000000, 0x00000000, 0x0100003e,
5023 static const DWORD ps_sample_l_code
[] =
5031 float4
main(float4 position
: SV_POSITION
) : SV_Target
5035 p
.x
= position
.x
/ 640.0f
;
5036 p
.y
= position
.y
/ 480.0f
;
5037 return t
.SampleLevel(s
, p
, level
);
5040 0x43425844, 0x61e05d85, 0x2a7300fb, 0x0a83706b, 0x889d1683, 0x00000001, 0x00000150, 0x00000003,
5041 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
5042 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
5043 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
5044 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000b4, 0x00000040,
5045 0x0000002d, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000, 0x00000000,
5046 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001,
5047 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0a000038, 0x00100032, 0x00000000,
5048 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x0c000048,
5049 0x001020f2, 0x00000000, 0x00100046, 0x00000000, 0x00107e46, 0x00000000, 0x00106000, 0x00000000,
5050 0x0020800a, 0x00000000, 0x00000000, 0x0100003e,
5052 static const DWORD ps_sample_2d_array_code
[] =
5060 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
5063 float3 p
= float3(position
.x
/ 640.0f
, position
.y
/ 480.0f
, 1.0f
);
5064 t
.GetDimensions(d
.x
, d
.y
, d
.z
);
5066 return t
.Sample(s
, p
* d
);
5069 0x43425844, 0xa9457e44, 0xc0b3ef8e, 0x3d751ae8, 0x23fa4807, 0x00000001, 0x00000194, 0x00000003,
5070 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
5071 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
5072 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
5073 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000f8, 0x00000040,
5074 0x0000003e, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000, 0x00000000,
5075 0x04004058, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001,
5076 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0700003d, 0x001000f2, 0x00000000,
5077 0x00004001, 0x00000000, 0x00107e46, 0x00000000, 0x0a000038, 0x001000c2, 0x00000000, 0x00101406,
5078 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x3acccccd, 0x3b088889, 0x07000038, 0x00100032,
5079 0x00000000, 0x00100046, 0x00000000, 0x00100ae6, 0x00000000, 0x06000036, 0x00100042, 0x00000000,
5080 0x0020800a, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100246, 0x00000000,
5081 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
5083 static const struct shader ps_ld
= {ps_ld_code
, sizeof(ps_ld_code
)};
5084 static const struct shader ps_ld_sint8
= {ps_ld_sint8_code
, sizeof(ps_ld_sint8_code
)};
5085 static const struct shader ps_ld_uint8
= {ps_ld_uint8_code
, sizeof(ps_ld_uint8_code
)};
5086 static const struct shader ps_sample
= {ps_sample_code
, sizeof(ps_sample_code
)};
5087 static const struct shader ps_sample_b
= {ps_sample_b_code
, sizeof(ps_sample_b_code
)};
5088 static const struct shader ps_sample_l
= {ps_sample_l_code
, sizeof(ps_sample_l_code
)};
5089 static const struct shader ps_sample_2d_array
= {ps_sample_2d_array_code
, sizeof(ps_sample_2d_array_code
)};
5090 static const DWORD red_data
[] =
5092 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff, 0x00000000, 0x00000000,
5093 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff, 0x00000000, 0x00000000,
5094 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff, 0x00000000, 0x00000000,
5095 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff, 0x00000000, 0x00000000,
5097 static const DWORD green_data
[] =
5099 0xff00ff00, 0xff00ff00, 0xff00ff00, 0xff00ff00,
5100 0xff00ff00, 0xff00ff00, 0xff00ff00, 0xff00ff00,
5101 0xff00ff00, 0xff00ff00, 0xff00ff00, 0xff00ff00,
5102 0xff00ff00, 0xff00ff00, 0xff00ff00, 0xff00ff00,
5104 static const DWORD blue_data
[] =
5106 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000, 0x00000000,
5107 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000, 0x00000000,
5108 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000, 0x00000000,
5109 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000, 0x00000000,
5111 static const DWORD rgba_level_0
[] =
5113 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
5114 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
5115 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
5116 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
5118 static const DWORD rgba_level_1
[] =
5120 0xffffffff, 0xff0000ff,
5121 0xff000000, 0xff00ff00,
5123 static const DWORD rgba_level_2
[] =
5127 static const DWORD srgb_data
[] =
5129 0x00000000, 0xffffffff, 0xff000000, 0x7f7f7f7f,
5130 0xff010203, 0xff102030, 0xff0a0b0c, 0xff8090a0,
5131 0xffb1c4de, 0xfff0f1f2, 0xfffafdfe, 0xff5a560f,
5132 0xffd5ff00, 0xffc8f99f, 0xffaa00aa, 0xffdd55bb,
5134 static const BYTE a8_data
[] =
5136 0x00, 0x10, 0x20, 0x30,
5137 0x40, 0x50, 0x60, 0x70,
5138 0x80, 0x90, 0xa0, 0xb0,
5139 0xc0, 0xd0, 0xe0, 0xf0,
5141 static const BYTE bc1_data
[] =
5143 0x00, 0xf8, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
5144 0xe0, 0x07, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00,
5145 0x1f, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
5146 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
5148 static const BYTE bc2_data
[] =
5150 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf8, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
5151 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x07, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00,
5152 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
5153 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
5155 static const BYTE bc3_data
[] =
5157 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
5158 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00,
5159 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
5160 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
5162 static const BYTE bc4_data
[] =
5164 0x10, 0x7f, 0x77, 0x39, 0x05, 0x00, 0x00, 0x00,
5165 0x10, 0x7f, 0x49, 0x92, 0x24, 0x49, 0x92, 0x24,
5166 0x10, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
5167 0x10, 0x7f, 0xb6, 0x6d, 0xdb, 0xb6, 0x6d, 0xdb,
5169 static const BYTE bc5_data
[] =
5171 0x10, 0x7f, 0x77, 0x39, 0x05, 0x00, 0x00, 0x00, 0x10, 0x7f, 0x77, 0x39, 0x05, 0x00, 0x00, 0x00,
5172 0x10, 0x7f, 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0x10, 0x7f, 0x49, 0x92, 0x24, 0x49, 0x92, 0x24,
5173 0x10, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x10, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
5174 0x10, 0x7f, 0xb6, 0x6d, 0xdb, 0xb6, 0x6d, 0xdb, 0x10, 0x7f, 0xb6, 0x6d, 0xdb, 0xb6, 0x6d, 0xdb,
5176 static const struct texture rgba_texture
=
5178 4, 4, 3, 1, DXGI_FORMAT_R8G8B8A8_UNORM
,
5180 {rgba_level_0
, 4 * sizeof(*rgba_level_0
), 0},
5181 {rgba_level_1
, 2 * sizeof(*rgba_level_1
), 0},
5182 {rgba_level_2
, sizeof(*rgba_level_2
), 0},
5185 static const struct texture srgb_texture
= {4, 4, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
5186 {{srgb_data
, 4 * sizeof(*srgb_data
)}}};
5187 static const struct texture srgb_typeless
= {4, 4, 1, 1, DXGI_FORMAT_R8G8B8A8_TYPELESS
,
5188 {{srgb_data
, 4 * sizeof(*srgb_data
)}}};
5189 static const struct texture a8_texture
= {4, 4, 1, 1, DXGI_FORMAT_A8_UNORM
,
5190 {{a8_data
, 4 * sizeof(*a8_data
)}}};
5191 static const struct texture bc1_texture
= {8, 8, 1, 1, DXGI_FORMAT_BC1_UNORM
, {{bc1_data
, 2 * 8}}};
5192 static const struct texture bc2_texture
= {8, 8, 1, 1, DXGI_FORMAT_BC2_UNORM
, {{bc2_data
, 2 * 16}}};
5193 static const struct texture bc3_texture
= {8, 8, 1, 1, DXGI_FORMAT_BC3_UNORM
, {{bc3_data
, 2 * 16}}};
5194 static const struct texture bc4_texture
= {8, 8, 1, 1, DXGI_FORMAT_BC4_UNORM
, {{bc4_data
, 2 * 8}}};
5195 static const struct texture bc5_texture
= {8, 8, 1, 1, DXGI_FORMAT_BC5_UNORM
, {{bc5_data
, 2 * 16}}};
5196 static const struct texture bc1_texture_srgb
= {8, 8, 1, 1, DXGI_FORMAT_BC1_UNORM_SRGB
, {{bc1_data
, 2 * 8}}};
5197 static const struct texture bc2_texture_srgb
= {8, 8, 1, 1, DXGI_FORMAT_BC2_UNORM_SRGB
, {{bc2_data
, 2 * 16}}};
5198 static const struct texture bc3_texture_srgb
= {8, 8, 1, 1, DXGI_FORMAT_BC3_UNORM_SRGB
, {{bc3_data
, 2 * 16}}};
5199 static const struct texture bc1_typeless
= {8, 8, 1, 1, DXGI_FORMAT_BC1_TYPELESS
, {{bc1_data
, 2 * 8}}};
5200 static const struct texture bc2_typeless
= {8, 8, 1, 1, DXGI_FORMAT_BC2_TYPELESS
, {{bc2_data
, 2 * 16}}};
5201 static const struct texture bc3_typeless
= {8, 8, 1, 1, DXGI_FORMAT_BC3_TYPELESS
, {{bc3_data
, 2 * 16}}};
5202 static const struct texture sint8_texture
= {4, 4, 1, 1, DXGI_FORMAT_R8G8B8A8_SINT
,
5203 {{rgba_level_0
, 4 * sizeof(*rgba_level_0
)}}};
5204 static const struct texture uint8_texture
= {4, 4, 1, 1, DXGI_FORMAT_R8G8B8A8_UINT
,
5205 {{rgba_level_0
, 4 * sizeof(*rgba_level_0
)}}};
5206 static const struct texture array_2d_texture
=
5208 4, 4, 1, 3, DXGI_FORMAT_R8G8B8A8_UNORM
,
5210 {red_data
, 6 * sizeof(*red_data
)},
5211 {green_data
, 4 * sizeof(*green_data
)},
5212 {blue_data
, 5 * sizeof(*blue_data
)},
5215 static const DWORD red_colors
[] =
5217 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff,
5218 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff,
5219 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff,
5220 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff,
5222 static const DWORD blue_colors
[] =
5224 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
5225 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
5226 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
5227 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
5229 static const DWORD level_1_colors
[] =
5231 0xffffffff, 0xffffffff, 0xff0000ff, 0xff0000ff,
5232 0xffffffff, 0xffffffff, 0xff0000ff, 0xff0000ff,
5233 0xff000000, 0xff000000, 0xff00ff00, 0xff00ff00,
5234 0xff000000, 0xff000000, 0xff00ff00, 0xff00ff00,
5236 static const DWORD lerp_1_2_colors
[] =
5238 0xffff7f7f, 0xffff7f7f, 0xff7f007f, 0xff7f007f,
5239 0xffff7f7f, 0xffff7f7f, 0xff7f007f, 0xff7f007f,
5240 0xff7f0000, 0xff7f0000, 0xff7f7f00, 0xff7f7f00,
5241 0xff7f0000, 0xff7f0000, 0xff7f7f00, 0xff7f7f00,
5243 static const DWORD level_2_colors
[] =
5245 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
5246 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
5247 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
5248 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
5250 static const DWORD srgb_colors
[] =
5252 0x00000001, 0xffffffff, 0xff000000, 0x7f363636,
5253 0xff000000, 0xff010408, 0xff010101, 0xff37475a,
5254 0xff708cba, 0xffdee0e2, 0xfff3fbfd, 0xff1a1801,
5255 0xffa9ff00, 0xff93f159, 0xff670067, 0xffb8177f,
5257 static const DWORD a8_colors
[] =
5259 0x00000000, 0x10000000, 0x20000000, 0x30000000,
5260 0x40000000, 0x50000000, 0x60000000, 0x70000000,
5261 0x80000000, 0x90000000, 0xa0000000, 0xb0000000,
5262 0xc0000000, 0xd0000000, 0xe0000000, 0xf0000000,
5264 static const DWORD bc_colors
[] =
5266 0xff0000ff, 0xff0000ff, 0xff00ff00, 0xff00ff00,
5267 0xff0000ff, 0xff0000ff, 0xff00ff00, 0xff00ff00,
5268 0xffff0000, 0xffff0000, 0xffffffff, 0xffffffff,
5269 0xffff0000, 0xffff0000, 0xffffffff, 0xffffffff,
5271 static const DWORD bc4_colors
[] =
5273 0xff000026, 0xff000010, 0xff00007f, 0xff00007f,
5274 0xff000010, 0xff000010, 0xff00007f, 0xff00007f,
5275 0xff0000ff, 0xff0000ff, 0xff000000, 0xff000000,
5276 0xff0000ff, 0xff0000ff, 0xff000000, 0xff000000,
5278 static const DWORD bc5_colors
[] =
5280 0xff002626, 0xff001010, 0xff007f7f, 0xff007f7f,
5281 0xff001010, 0xff001010, 0xff007f7f, 0xff007f7f,
5282 0xff00ffff, 0xff00ffff, 0xff000000, 0xff000000,
5283 0xff00ffff, 0xff00ffff, 0xff000000, 0xff000000,
5285 static const DWORD sint8_colors
[] =
5287 0x7e80807e, 0x7e807e7e, 0x7e807e80, 0x7e7e7e80,
5288 0x7e7e8080, 0x7e7e7f7f, 0x7e808080, 0x7effffff,
5289 0x7e7e7e7e, 0x7e7e7e7e, 0x7e7e7e7e, 0x7e808080,
5290 0x7e7e7e7e, 0x7e7f7f7f, 0x7e7f7f7f, 0x7e7f7f7f,
5292 static const DWORD zero_colors
[4 * 4] = {0};
5293 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
5295 static const struct texture_test
5297 const struct shader
*ps
;
5298 const struct texture
*texture
;
5299 D3D10_FILTER filter
;
5304 const DWORD
*expected_colors
;
5308 #define POINT D3D10_FILTER_MIN_MAG_MIP_POINT
5309 #define POINT_LINEAR D3D10_FILTER_MIN_MAG_POINT_MIP_LINEAR
5310 #define MIP_MAX D3D10_FLOAT32_MAX
5311 {&ps_ld
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, rgba_level_0
},
5312 {&ps_ld
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, level_1_colors
},
5313 {&ps_ld
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 2.0f
, level_2_colors
},
5314 {&ps_ld
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 3.0f
, zero_colors
},
5315 {&ps_ld
, &srgb_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, srgb_colors
},
5316 {&ps_ld
, &bc1_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
5317 {&ps_ld
, &bc1_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, zero_colors
},
5318 {&ps_ld
, &bc2_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
5319 {&ps_ld
, &bc2_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, zero_colors
},
5320 {&ps_ld
, &bc3_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
5321 {&ps_ld
, &bc3_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, zero_colors
},
5322 {&ps_ld
, &bc4_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc4_colors
},
5323 {&ps_ld
, &bc5_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc5_colors
},
5324 {&ps_ld
, &bc1_texture_srgb
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
5325 {&ps_ld
, &bc2_texture_srgb
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
5326 {&ps_ld
, &bc3_texture_srgb
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
5327 {&ps_ld
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, zero_colors
},
5328 {&ps_ld
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, zero_colors
},
5329 {&ps_ld_sint8
, &sint8_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, sint8_colors
},
5330 {&ps_ld_uint8
, &uint8_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, rgba_level_0
},
5331 {&ps_sample
, &bc1_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
5332 {&ps_sample
, &bc2_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
5333 {&ps_sample
, &bc3_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc_colors
},
5334 {&ps_sample
, &bc4_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc4_colors
},
5335 {&ps_sample
, &bc5_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, bc5_colors
},
5336 {&ps_sample
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, rgba_level_0
},
5337 {&ps_sample
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, rgba_level_0
},
5338 {&ps_sample
, &rgba_texture
, POINT
, 2.0f
, 0.0f
, MIP_MAX
, 0.0f
, rgba_level_0
},
5339 {&ps_sample
, &rgba_texture
, POINT
, 8.0f
, 0.0f
, MIP_MAX
, 0.0f
, level_1_colors
},
5340 {&ps_sample
, &srgb_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, srgb_colors
},
5341 {&ps_sample
, &a8_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, a8_colors
},
5342 {&ps_sample
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, zero_colors
},
5343 {&ps_sample
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, zero_colors
},
5344 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, rgba_level_0
},
5345 {&ps_sample_b
, &rgba_texture
, POINT
, 8.0f
, 0.0f
, MIP_MAX
, 0.0f
, level_1_colors
},
5346 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 8.0f
, level_1_colors
},
5347 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 8.4f
, level_1_colors
},
5348 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 8.5f
, level_2_colors
},
5349 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 9.0f
, level_2_colors
},
5350 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 2.0f
, 1.0f
, rgba_level_0
},
5351 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 2.0f
, 9.0f
, level_2_colors
},
5352 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 1.0f
, 9.0f
, level_1_colors
},
5353 {&ps_sample_b
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, 0.0f
, 9.0f
, rgba_level_0
},
5354 {&ps_sample_b
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, zero_colors
},
5355 {&ps_sample_b
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, zero_colors
},
5356 {&ps_sample_b
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, zero_colors
},
5357 {&ps_sample_b
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 1.0f
, zero_colors
},
5358 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, -1.0f
, rgba_level_0
},
5359 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, rgba_level_0
},
5360 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.4f
, rgba_level_0
},
5361 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.5f
, level_1_colors
},
5362 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 1.0f
, level_1_colors
},
5363 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 1.4f
, level_1_colors
},
5364 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 1.5f
, level_2_colors
},
5365 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 2.0f
, level_2_colors
},
5366 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 3.0f
, level_2_colors
},
5367 {&ps_sample_l
, &rgba_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 4.0f
, level_2_colors
},
5368 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 0.0f
, 0.0f
, MIP_MAX
, 1.5f
, lerp_1_2_colors
},
5369 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 0.0f
, MIP_MAX
, -2.0f
, rgba_level_0
},
5370 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 0.0f
, MIP_MAX
, -1.0f
, level_1_colors
},
5371 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 0.0f
, MIP_MAX
, 0.0f
, level_2_colors
},
5372 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 0.0f
, MIP_MAX
, 1.0f
, level_2_colors
},
5373 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 0.0f
, MIP_MAX
, 1.5f
, level_2_colors
},
5374 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 2.0f
, 2.0f
, -9.0f
, level_2_colors
},
5375 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 2.0f
, 2.0f
, -1.0f
, level_2_colors
},
5376 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 2.0f
, 2.0f
, 0.0f
, level_2_colors
},
5377 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 2.0f
, 2.0f
, 1.0f
, level_2_colors
},
5378 {&ps_sample_l
, &rgba_texture
, POINT_LINEAR
, 2.0f
, 2.0f
, 2.0f
, 9.0f
, level_2_colors
},
5379 {&ps_sample_l
, &rgba_texture
, POINT
, 2.0f
, 2.0f
, 2.0f
, -9.0f
, level_2_colors
},
5380 {&ps_sample_l
, &rgba_texture
, POINT
, 2.0f
, 2.0f
, 2.0f
, -1.0f
, level_2_colors
},
5381 {&ps_sample_l
, &rgba_texture
, POINT
, 2.0f
, 2.0f
, 2.0f
, 0.0f
, level_2_colors
},
5382 {&ps_sample_l
, &rgba_texture
, POINT
, 2.0f
, 2.0f
, 2.0f
, 1.0f
, level_2_colors
},
5383 {&ps_sample_l
, &rgba_texture
, POINT
, 2.0f
, 2.0f
, 2.0f
, 9.0f
, level_2_colors
},
5384 {&ps_sample_l
, NULL
, POINT
, 2.0f
, 2.0f
, 0.0f
, 0.0f
, zero_colors
},
5385 {&ps_sample_l
, NULL
, POINT
, 2.0f
, 2.0f
, 0.0f
, 1.0f
, zero_colors
},
5386 {&ps_sample_l
, NULL
, POINT
, 2.0f
, 2.0f
, MIP_MAX
, 0.0f
, zero_colors
},
5387 {&ps_sample_l
, NULL
, POINT
, 2.0f
, 2.0f
, MIP_MAX
, 1.0f
, zero_colors
},
5388 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, -9.0f
, red_colors
},
5389 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, -1.0f
, red_colors
},
5390 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, red_colors
},
5391 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.4f
, red_colors
},
5392 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.5f
, red_colors
},
5393 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 1.0f
, green_data
},
5394 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 1.4f
, green_data
},
5395 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 2.0f
, blue_colors
},
5396 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 2.1f
, blue_colors
},
5397 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 3.0f
, blue_colors
},
5398 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 3.1f
, blue_colors
},
5399 {&ps_sample_2d_array
, &array_2d_texture
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 9.0f
, blue_colors
},
5400 {&ps_sample_2d_array
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, zero_colors
},
5401 {&ps_sample_2d_array
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 2.0f
, zero_colors
},
5402 {&ps_sample_2d_array
, NULL
, POINT
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, zero_colors
},
5403 {&ps_sample_2d_array
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 0.0f
, zero_colors
},
5404 {&ps_sample_2d_array
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 1.0f
, zero_colors
},
5405 {&ps_sample_2d_array
, NULL
, POINT
, 0.0f
, 0.0f
, MIP_MAX
, 2.0f
, zero_colors
},
5410 static const struct srv_test
5412 const struct shader
*ps
;
5413 const struct texture
*texture
;
5414 struct srv_desc srv_desc
;
5416 const DWORD
*expected_colors
;
5420 #define TEX_2D D3D10_SRV_DIMENSION_TEXTURE2D
5421 #define TEX_2D_ARRAY D3D10_SRV_DIMENSION_TEXTURE2DARRAY
5422 #define BC1_UNORM DXGI_FORMAT_BC1_UNORM
5423 #define BC1_UNORM_SRGB DXGI_FORMAT_BC1_UNORM_SRGB
5424 #define BC2_UNORM DXGI_FORMAT_BC2_UNORM
5425 #define BC2_UNORM_SRGB DXGI_FORMAT_BC2_UNORM_SRGB
5426 #define BC3_UNORM DXGI_FORMAT_BC3_UNORM
5427 #define BC3_UNORM_SRGB DXGI_FORMAT_BC3_UNORM_SRGB
5428 #define R8G8B8A8_UNORM_SRGB DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
5429 #define R8G8B8A8_UNORM DXGI_FORMAT_R8G8B8A8_UNORM
5430 #define FMT_UNKNOWN DXGI_FORMAT_UNKNOWN
5431 {&ps_sample
, &bc1_typeless
, {BC1_UNORM
, TEX_2D
, 0, 1}, 0.0f
, bc_colors
},
5432 {&ps_sample
, &bc1_typeless
, {BC1_UNORM_SRGB
, TEX_2D
, 0, 1}, 0.0f
, bc_colors
},
5433 {&ps_sample
, &bc2_typeless
, {BC2_UNORM
, TEX_2D
, 0, 1}, 0.0f
, bc_colors
},
5434 {&ps_sample
, &bc2_typeless
, {BC2_UNORM_SRGB
, TEX_2D
, 0, 1}, 0.0f
, bc_colors
},
5435 {&ps_sample
, &bc3_typeless
, {BC3_UNORM
, TEX_2D
, 0, 1}, 0.0f
, bc_colors
},
5436 {&ps_sample
, &bc3_typeless
, {BC3_UNORM_SRGB
, TEX_2D
, 0, 1}, 0.0f
, bc_colors
},
5437 {&ps_sample
, &srgb_typeless
, {R8G8B8A8_UNORM_SRGB
, TEX_2D
, 0, 1}, 0.0f
, srgb_colors
},
5438 {&ps_sample
, &srgb_typeless
, {R8G8B8A8_UNORM
, TEX_2D
, 0, 1}, 0.0f
, srgb_data
},
5439 {&ps_sample
, &array_2d_texture
, {FMT_UNKNOWN
, TEX_2D
, 0, 1}, 0.0f
, red_colors
},
5440 {&ps_sample_2d_array
, &array_2d_texture
, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 1, 0, 1}, 0.0f
, red_colors
},
5441 {&ps_sample_2d_array
, &array_2d_texture
, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 1, 1, 1}, 0.0f
, green_data
},
5442 {&ps_sample_2d_array
, &array_2d_texture
, {FMT_UNKNOWN
, TEX_2D_ARRAY
, 0, 1, 2, 1}, 0.0f
, blue_colors
},
5446 #undef BC1_UNORM_SRGB
5448 #undef BC2_UNORM_SRGB
5450 #undef BC3_UNORM_SRGB
5451 #undef R8G8B8A8_UNORM_SRGB
5452 #undef R8G8B8A8_UNORM
5456 if (!init_test_context(&test_context
))
5459 device
= test_context
.device
;
5461 cb
= create_buffer(device
, D3D10_BIND_CONSTANT_BUFFER
, sizeof(ps_constant
), NULL
);
5463 ID3D10Device_PSSetConstantBuffers(device
, 0, 1, &cb
);
5465 texture_desc
.SampleDesc
.Count
= 1;
5466 texture_desc
.SampleDesc
.Quality
= 0;
5467 texture_desc
.Usage
= D3D10_USAGE_DEFAULT
;
5468 texture_desc
.BindFlags
= D3D10_BIND_SHADER_RESOURCE
;
5469 texture_desc
.CPUAccessFlags
= 0;
5470 texture_desc
.MiscFlags
= 0;
5472 sampler_desc
.Filter
= D3D10_FILTER_MIN_MAG_MIP_POINT
;
5473 sampler_desc
.AddressU
= D3D10_TEXTURE_ADDRESS_CLAMP
;
5474 sampler_desc
.AddressV
= D3D10_TEXTURE_ADDRESS_CLAMP
;
5475 sampler_desc
.AddressW
= D3D10_TEXTURE_ADDRESS_CLAMP
;
5476 sampler_desc
.MipLODBias
= 0.0f
;
5477 sampler_desc
.MaxAnisotropy
= 0;
5478 sampler_desc
.ComparisonFunc
= D3D10_COMPARISON_NEVER
;
5479 sampler_desc
.BorderColor
[0] = 0.0f
;
5480 sampler_desc
.BorderColor
[1] = 0.0f
;
5481 sampler_desc
.BorderColor
[2] = 0.0f
;
5482 sampler_desc
.BorderColor
[3] = 0.0f
;
5483 sampler_desc
.MinLOD
= 0.0f
;
5484 sampler_desc
.MaxLOD
= D3D10_FLOAT32_MAX
;
5491 current_texture
= NULL
;
5492 for (i
= 0; i
< sizeof(texture_tests
) / sizeof(*texture_tests
); ++i
)
5494 const struct texture_test
*test
= &texture_tests
[i
];
5496 if (current_ps
!= test
->ps
)
5499 ID3D10PixelShader_Release(ps
);
5501 current_ps
= test
->ps
;
5503 hr
= ID3D10Device_CreatePixelShader(device
, current_ps
->code
, current_ps
->size
, &ps
);
5504 ok(SUCCEEDED(hr
), "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
5506 ID3D10Device_PSSetShader(device
, ps
);
5509 if (current_texture
!= test
->texture
)
5512 ID3D10Texture2D_Release(texture
);
5514 ID3D10ShaderResourceView_Release(srv
);
5516 current_texture
= test
->texture
;
5518 if (current_texture
)
5520 texture_desc
.Width
= current_texture
->width
;
5521 texture_desc
.Height
= current_texture
->height
;
5522 texture_desc
.MipLevels
= current_texture
->miplevel_count
;
5523 texture_desc
.ArraySize
= current_texture
->array_size
;
5524 texture_desc
.Format
= current_texture
->format
;
5526 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, current_texture
->data
, &texture
);
5527 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
5529 hr
= ID3D10Device_CreateShaderResourceView(device
, (ID3D10Resource
*)texture
, NULL
, &srv
);
5530 ok(SUCCEEDED(hr
), "Test %u: Failed to create shader resource view, hr %#x.\n", i
, hr
);
5538 ID3D10Device_PSSetShaderResources(device
, 0, 1, &srv
);
5541 if (!sampler
|| (sampler_desc
.Filter
!= test
->filter
5542 || sampler_desc
.MipLODBias
!= test
->lod_bias
5543 || sampler_desc
.MinLOD
!= test
->min_lod
5544 || sampler_desc
.MaxLOD
!= test
->max_lod
))
5547 ID3D10SamplerState_Release(sampler
);
5549 sampler_desc
.Filter
= test
->filter
;
5550 sampler_desc
.MipLODBias
= test
->lod_bias
;
5551 sampler_desc
.MinLOD
= test
->min_lod
;
5552 sampler_desc
.MaxLOD
= test
->max_lod
;
5554 hr
= ID3D10Device_CreateSamplerState(device
, &sampler_desc
, &sampler
);
5555 ok(SUCCEEDED(hr
), "Test %u: Failed to create sampler state, hr %#x.\n", i
, hr
);
5557 ID3D10Device_PSSetSamplers(device
, 0, 1, &sampler
);
5560 ps_constant
.x
= test
->ps_constant
;
5561 ID3D10Device_UpdateSubresource(device
, (ID3D10Resource
*)cb
, 0, NULL
, &ps_constant
, 0, 0);
5563 ID3D10Device_ClearRenderTargetView(device
, test_context
.backbuffer_rtv
, red
);
5565 draw_quad(&test_context
);
5567 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
5568 for (y
= 0; y
< 4; ++y
)
5570 for (x
= 0; x
< 4; ++x
)
5572 color
= get_readback_color(&rb
, 80 + x
* 160, 60 + y
* 120);
5573 ok(compare_color(color
, test
->expected_colors
[y
* 4 + x
], 1),
5574 "Test %u: Got unexpected color 0x%08x at (%u, %u).\n", i
, color
, x
, y
);
5577 release_texture_readback(&rb
);
5580 ID3D10ShaderResourceView_Release(srv
);
5581 ID3D10SamplerState_Release(sampler
);
5583 ID3D10Texture2D_Release(texture
);
5584 ID3D10PixelShader_Release(ps
);
5586 if (is_warp_device(device
) && !is_d3d11_interface_available(device
))
5588 win_skip("SRV tests are broken on WARP.\n");
5589 ID3D10Buffer_Release(cb
);
5590 release_test_context(&test_context
);
5594 sampler_desc
.Filter
= D3D10_FILTER_MIN_MAG_MIP_POINT
;
5595 sampler_desc
.MipLODBias
= 0.0f
;
5596 sampler_desc
.MinLOD
= 0.0f
;
5597 sampler_desc
.MaxLOD
= D3D10_FLOAT32_MAX
;
5599 hr
= ID3D10Device_CreateSamplerState(device
, &sampler_desc
, &sampler
);
5600 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
5602 ID3D10Device_PSSetSamplers(device
, 0, 1, &sampler
);
5608 current_texture
= NULL
;
5609 for (i
= 0; i
< sizeof(srv_tests
) / sizeof(*srv_tests
); ++i
)
5611 const struct srv_test
*test
= &srv_tests
[i
];
5613 if (current_ps
!= test
->ps
)
5616 ID3D10PixelShader_Release(ps
);
5618 current_ps
= test
->ps
;
5620 hr
= ID3D10Device_CreatePixelShader(device
, current_ps
->code
, current_ps
->size
, &ps
);
5621 ok(SUCCEEDED(hr
), "Test %u: Failed to create pixel shader, hr %#x.\n", i
, hr
);
5623 ID3D10Device_PSSetShader(device
, ps
);
5626 if (current_texture
!= test
->texture
)
5629 ID3D10Texture2D_Release(texture
);
5631 current_texture
= test
->texture
;
5633 texture_desc
.Width
= current_texture
->width
;
5634 texture_desc
.Height
= current_texture
->height
;
5635 texture_desc
.MipLevels
= current_texture
->miplevel_count
;
5636 texture_desc
.ArraySize
= current_texture
->array_size
;
5637 texture_desc
.Format
= current_texture
->format
;
5639 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, current_texture
->data
, &texture
);
5640 ok(SUCCEEDED(hr
), "Test %u: Failed to create 2d texture, hr %#x.\n", i
, hr
);
5644 ID3D10ShaderResourceView_Release(srv
);
5646 get_srv_desc(&srv_desc
, &test
->srv_desc
);
5647 hr
= ID3D10Device_CreateShaderResourceView(device
, (ID3D10Resource
*)texture
, &srv_desc
, &srv
);
5648 ok(SUCCEEDED(hr
), "Test %u: Failed to create shader resource view, hr %#x.\n", i
, hr
);
5650 ID3D10Device_PSSetShaderResources(device
, 0, 1, &srv
);
5652 ps_constant
.x
= test
->ps_constant
;
5653 ID3D10Device_UpdateSubresource(device
, (ID3D10Resource
*)cb
, 0, NULL
, &ps_constant
, 0, 0);
5655 ID3D10Device_ClearRenderTargetView(device
, test_context
.backbuffer_rtv
, red
);
5657 draw_quad(&test_context
);
5659 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
5660 for (y
= 0; y
< 4; ++y
)
5662 for (x
= 0; x
< 4; ++x
)
5664 color
= get_readback_color(&rb
, 80 + x
* 160, 60 + y
* 120);
5665 ok(compare_color(color
, test
->expected_colors
[y
* 4 + x
], 1),
5666 "Test %u: Got unexpected color 0x%08x at (%u, %u).\n", i
, color
, x
, y
);
5669 release_texture_readback(&rb
);
5671 ID3D10PixelShader_Release(ps
);
5672 ID3D10Texture2D_Release(texture
);
5673 ID3D10ShaderResourceView_Release(srv
);
5674 ID3D10SamplerState_Release(sampler
);
5676 ID3D10Buffer_Release(cb
);
5677 release_test_context(&test_context
);
5680 static void test_multiple_render_targets(void)
5682 D3D10_TEXTURE2D_DESC texture_desc
;
5683 ID3D10InputLayout
*input_layout
;
5684 unsigned int stride
, offset
, i
;
5685 ID3D10RenderTargetView
*rtv
[4];
5686 ID3D10Texture2D
*rt
[4];
5687 ID3D10VertexShader
*vs
;
5688 ID3D10PixelShader
*ps
;
5689 ID3D10Device
*device
;
5695 static const D3D10_INPUT_ELEMENT_DESC layout_desc
[] =
5697 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D10_INPUT_PER_VERTEX_DATA
, 0},
5699 static const DWORD vs_code
[] =
5702 float4
main(float4 position
: POSITION
) : SV_POSITION
5707 0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003,
5708 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
5709 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
5710 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
5711 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
5712 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
5713 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
5715 static const DWORD ps_code
[] =
5720 float4 t1
: SV_TARGET0
;
5721 float4 t2
: SV_Target1
;
5722 float4 t3
: SV_TARGET2
;
5723 float4 t4
: SV_Target3
;
5726 output
main(float4 position
: SV_POSITION
)
5729 o
.t1
= (float4
)1.0f
;
5730 o
.t2
= (float4
)0.5f
;
5731 o
.t3
= (float4
)0.2f
;
5732 o
.t4
= float4(0.0f
, 0.2f
, 0.5f
, 1.0f
);
5736 0x43425844, 0x8701ad18, 0xe3d5291d, 0x7b4288a6, 0x01917515, 0x00000001, 0x000001a8, 0x00000003,
5737 0x0000002c, 0x00000060, 0x000000e4, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
5738 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
5739 0x4e47534f, 0x0000007c, 0x00000004, 0x00000008, 0x00000068, 0x00000000, 0x00000000, 0x00000003,
5740 0x00000000, 0x0000000f, 0x00000072, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
5741 0x00000068, 0x00000002, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x00000072, 0x00000003,
5742 0x00000000, 0x00000003, 0x00000003, 0x0000000f, 0x545f5653, 0x45475241, 0x56530054, 0x7261545f,
5743 0x00746567, 0x52444853, 0x000000bc, 0x00000040, 0x0000002f, 0x03000065, 0x001020f2, 0x00000000,
5744 0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x03000065, 0x001020f2,
5745 0x00000003, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x3f800000, 0x3f800000,
5746 0x3f800000, 0x08000036, 0x001020f2, 0x00000001, 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000,
5747 0x3f000000, 0x08000036, 0x001020f2, 0x00000002, 0x00004002, 0x3e4ccccd, 0x3e4ccccd, 0x3e4ccccd,
5748 0x3e4ccccd, 0x08000036, 0x001020f2, 0x00000003, 0x00004002, 0x00000000, 0x3e4ccccd, 0x3f000000,
5749 0x3f800000, 0x0100003e,
5753 struct vec2 position
;
5762 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 1.0f
};
5764 if (!(device
= create_device()))
5766 skip("Failed to create device.\n");
5770 hr
= ID3D10Device_CreateInputLayout(device
, layout_desc
, sizeof(layout_desc
) / sizeof(*layout_desc
),
5771 vs_code
, sizeof(vs_code
), &input_layout
);
5772 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
5774 vb
= create_buffer(device
, D3D10_BIND_VERTEX_BUFFER
, sizeof(quad
), quad
);
5776 texture_desc
.Width
= 640;
5777 texture_desc
.Height
= 480;
5778 texture_desc
.MipLevels
= 1;
5779 texture_desc
.ArraySize
= 1;
5780 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
5781 texture_desc
.SampleDesc
.Count
= 1;
5782 texture_desc
.SampleDesc
.Quality
= 0;
5783 texture_desc
.Usage
= D3D10_USAGE_DEFAULT
;
5784 texture_desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
5785 texture_desc
.CPUAccessFlags
= 0;
5786 texture_desc
.MiscFlags
= 0;
5788 for (i
= 0; i
< sizeof(rt
) / sizeof(*rt
); ++i
)
5790 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &rt
[i
]);
5791 ok(SUCCEEDED(hr
), "Failed to create texture %u, hr %#x.\n", i
, hr
);
5793 hr
= ID3D10Device_CreateRenderTargetView(device
, (ID3D10Resource
*)rt
[i
], NULL
, &rtv
[i
]);
5794 ok(SUCCEEDED(hr
), "Failed to create rendertarget view %u, hr %#x.\n", i
, hr
);
5797 hr
= ID3D10Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), &vs
);
5798 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
5799 hr
= ID3D10Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), &ps
);
5800 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
5802 ID3D10Device_OMSetRenderTargets(device
, 4, rtv
, NULL
);
5803 ID3D10Device_IASetInputLayout(device
, input_layout
);
5804 ID3D10Device_IASetPrimitiveTopology(device
, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
5805 stride
= sizeof(*quad
);
5807 ID3D10Device_IASetVertexBuffers(device
, 0, 1, &vb
, &stride
, &offset
);
5808 ID3D10Device_VSSetShader(device
, vs
);
5809 ID3D10Device_PSSetShader(device
, ps
);
5817 ID3D10Device_RSSetViewports(device
, 1, &vp
);
5819 for (i
= 0; i
< sizeof(rtv
) / sizeof(*rtv
); ++i
)
5820 ID3D10Device_ClearRenderTargetView(device
, rtv
[i
], red
);
5822 ID3D10Device_Draw(device
, 4, 0);
5824 check_texture_color(rt
[0], 0xffffffff, 2);
5825 check_texture_color(rt
[1], 0x7f7f7f7f, 2);
5826 check_texture_color(rt
[2], 0x33333333, 2);
5827 check_texture_color(rt
[3], 0xff7f3300, 2);
5829 ID3D10Buffer_Release(vb
);
5830 ID3D10PixelShader_Release(ps
);
5831 ID3D10VertexShader_Release(vs
);
5832 ID3D10InputLayout_Release(input_layout
);
5833 for (i
= 0; i
< sizeof(rtv
) / sizeof(*rtv
); ++i
)
5834 ID3D10RenderTargetView_Release(rtv
[i
]);
5835 for (i
= 0; i
< sizeof(rt
) / sizeof(*rt
); ++i
)
5836 ID3D10Texture2D_Release(rt
[i
]);
5837 refcount
= ID3D10Device_Release(device
);
5838 ok(!refcount
, "Device has %u references left.\n", refcount
);
5841 static void test_private_data(void)
5843 D3D10_TEXTURE2D_DESC texture_desc
;
5844 ULONG refcount
, expected_refcount
;
5845 ID3D11Texture2D
*d3d11_texture
;
5846 ID3D11Device
*d3d11_device
;
5847 ID3D10Device
*test_object
;
5848 ID3D10Texture2D
*texture
;
5849 IDXGIDevice
*dxgi_device
;
5850 IDXGISurface
*surface
;
5851 ID3D10Device
*device
;
5856 static const GUID test_guid
=
5857 {0xfdb37466, 0x428f, 0x4edf, {0xa3, 0x7f, 0x9b, 0x1d, 0xf4, 0x88, 0xc5, 0xfc}};
5858 static const GUID test_guid2
=
5859 {0x2e5afac2, 0x87b5, 0x4c10, {0x9b, 0x4b, 0x89, 0xd7, 0xd1, 0x12, 0xe7, 0x2b}};
5860 static const DWORD data
[] = {1, 2, 3, 4};
5862 if (!(device
= create_device()))
5864 skip("Failed to create device, skipping tests.\n");
5868 test_object
= create_device();
5870 texture_desc
.Width
= 512;
5871 texture_desc
.Height
= 512;
5872 texture_desc
.MipLevels
= 1;
5873 texture_desc
.ArraySize
= 1;
5874 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
5875 texture_desc
.SampleDesc
.Count
= 1;
5876 texture_desc
.SampleDesc
.Quality
= 0;
5877 texture_desc
.Usage
= D3D10_USAGE_DEFAULT
;
5878 texture_desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
5879 texture_desc
.CPUAccessFlags
= 0;
5880 texture_desc
.MiscFlags
= 0;
5882 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
5883 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
5884 hr
= ID3D10Texture2D_QueryInterface(texture
, &IID_IDXGISurface
, (void **)&surface
);
5885 ok(SUCCEEDED(hr
), "Failed to get IDXGISurface, hr %#x.\n", hr
);
5887 /* SetPrivateData() with a pointer of NULL has the purpose of
5888 * FreePrivateData() in previous D3D versions. A successful clear returns
5889 * S_OK. A redundant clear S_FALSE. Setting a NULL interface is not
5890 * considered a clear but as setting an interface pointer that happens to
5892 hr
= ID3D10Device_SetPrivateData(device
, &test_guid
, 0, NULL
);
5893 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
5894 hr
= ID3D10Device_SetPrivateDataInterface(device
, &test_guid
, NULL
);
5895 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5896 hr
= ID3D10Device_SetPrivateData(device
, &test_guid
, ~0u, NULL
);
5897 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5898 hr
= ID3D10Device_SetPrivateData(device
, &test_guid
, ~0u, NULL
);
5899 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
5901 hr
= ID3D10Device_SetPrivateDataInterface(device
, &test_guid
, NULL
);
5902 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5903 size
= sizeof(ptr
) * 2;
5904 ptr
= (IUnknown
*)0xdeadbeef;
5905 hr
= ID3D10Device_GetPrivateData(device
, &test_guid
, &size
, &ptr
);
5906 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5907 ok(!ptr
, "Got unexpected pointer %p.\n", ptr
);
5908 ok(size
== sizeof(IUnknown
*), "Got unexpected size %u.\n", size
);
5910 hr
= ID3D10Device_QueryInterface(device
, &IID_IDXGIDevice
, (void **)&dxgi_device
);
5911 ok(SUCCEEDED(hr
), "Failed to get DXGI device, hr %#x.\n", hr
);
5912 size
= sizeof(ptr
) * 2;
5913 ptr
= (IUnknown
*)0xdeadbeef;
5914 hr
= IDXGIDevice_GetPrivateData(dxgi_device
, &test_guid
, &size
, &ptr
);
5915 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5916 ok(!ptr
, "Got unexpected pointer %p.\n", ptr
);
5917 ok(size
== sizeof(IUnknown
*), "Got unexpected size %u.\n", size
);
5918 IDXGIDevice_Release(dxgi_device
);
5920 refcount
= get_refcount((IUnknown
*)test_object
);
5921 hr
= ID3D10Device_SetPrivateDataInterface(device
, &test_guid
,
5922 (IUnknown
*)test_object
);
5923 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5924 expected_refcount
= refcount
+ 1;
5925 refcount
= get_refcount((IUnknown
*)test_object
);
5926 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
5927 hr
= ID3D10Device_SetPrivateDataInterface(device
, &test_guid
,
5928 (IUnknown
*)test_object
);
5929 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5930 refcount
= get_refcount((IUnknown
*)test_object
);
5931 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
5933 hr
= ID3D10Device_SetPrivateDataInterface(device
, &test_guid
, NULL
);
5934 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5935 --expected_refcount
;
5936 refcount
= get_refcount((IUnknown
*)test_object
);
5937 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
5939 hr
= ID3D10Device_SetPrivateDataInterface(device
, &test_guid
,
5940 (IUnknown
*)test_object
);
5941 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5942 size
= sizeof(data
);
5943 hr
= ID3D10Device_SetPrivateData(device
, &test_guid
, size
, data
);
5944 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5945 refcount
= get_refcount((IUnknown
*)test_object
);
5946 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
5947 hr
= ID3D10Device_SetPrivateData(device
, &test_guid
, 42, NULL
);
5948 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5949 hr
= ID3D10Device_SetPrivateData(device
, &test_guid
, 42, NULL
);
5950 ok(hr
== S_FALSE
, "Got unexpected hr %#x.\n", hr
);
5952 hr
= ID3D10Device_SetPrivateDataInterface(device
, &test_guid
,
5953 (IUnknown
*)test_object
);
5954 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5955 ++expected_refcount
;
5956 size
= 2 * sizeof(ptr
);
5958 hr
= ID3D10Device_GetPrivateData(device
, &test_guid
, &size
, &ptr
);
5959 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5960 ok(size
== sizeof(test_object
), "Got unexpected size %u.\n", size
);
5961 ++expected_refcount
;
5962 refcount
= get_refcount((IUnknown
*)test_object
);
5963 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
5964 IUnknown_Release(ptr
);
5965 --expected_refcount
;
5967 hr
= ID3D10Device_QueryInterface(device
, &IID_ID3D11Device
, (void **)&d3d11_device
);
5968 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
5969 "Device should implement ID3D11Device.\n");
5974 hr
= ID3D11Device_GetPrivateData(d3d11_device
, &test_guid
, &size
, &ptr
);
5975 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5976 ok(ptr
== (IUnknown
*)test_object
, "Got unexpected ptr %p, expected %p.\n", ptr
, test_object
);
5977 IUnknown_Release(ptr
);
5978 ID3D11Device_Release(d3d11_device
);
5979 refcount
= get_refcount((IUnknown
*)test_object
);
5980 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n",
5981 refcount
, expected_refcount
);
5984 ptr
= (IUnknown
*)0xdeadbeef;
5986 hr
= ID3D10Device_GetPrivateData(device
, &test_guid
, &size
, NULL
);
5987 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5988 ok(size
== sizeof(device
), "Got unexpected size %u.\n", size
);
5989 size
= 2 * sizeof(ptr
);
5990 hr
= ID3D10Device_GetPrivateData(device
, &test_guid
, &size
, NULL
);
5991 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
5992 ok(size
== sizeof(device
), "Got unexpected size %u.\n", size
);
5993 refcount
= get_refcount((IUnknown
*)test_object
);
5994 ok(refcount
== expected_refcount
, "Got unexpected refcount %u, expected %u.\n", refcount
, expected_refcount
);
5997 hr
= ID3D10Device_GetPrivateData(device
, &test_guid
, &size
, &ptr
);
5998 ok(hr
== DXGI_ERROR_MORE_DATA
, "Got unexpected hr %#x.\n", hr
);
5999 ok(size
== sizeof(device
), "Got unexpected size %u.\n", size
);
6000 ok(ptr
== (IUnknown
*)0xdeadbeef, "Got unexpected pointer %p.\n", ptr
);
6001 hr
= ID3D10Device_GetPrivateData(device
, &test_guid2
, NULL
, NULL
);
6002 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
6004 hr
= ID3D10Device_GetPrivateData(device
, &test_guid2
, &size
, &ptr
);
6005 ok(hr
== DXGI_ERROR_NOT_FOUND
, "Got unexpected hr %#x.\n", hr
);
6006 ok(size
== 0, "Got unexpected size %u.\n", size
);
6007 ok(ptr
== (IUnknown
*)0xdeadbeef, "Got unexpected pointer %p.\n", ptr
);
6008 hr
= ID3D10Device_GetPrivateData(device
, &test_guid
, NULL
, &ptr
);
6009 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
6010 ok(ptr
== (IUnknown
*)0xdeadbeef, "Got unexpected pointer %p.\n", ptr
);
6012 hr
= ID3D10Texture2D_SetPrivateDataInterface(texture
, &test_guid
, (IUnknown
*)test_object
);
6013 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6016 hr
= IDXGISurface_GetPrivateData(surface
, &test_guid
, &size
, &ptr
);
6017 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6018 ok(ptr
== (IUnknown
*)test_object
, "Got unexpected ptr %p, expected %p.\n", ptr
, test_object
);
6019 IUnknown_Release(ptr
);
6021 hr
= ID3D10Texture2D_QueryInterface(texture
, &IID_ID3D11Texture2D
, (void **)&d3d11_texture
);
6022 ok(SUCCEEDED(hr
) || broken(hr
== E_NOINTERFACE
) /* Not available on all Windows versions. */,
6023 "Texture should implement ID3D11Texture2D.\n");
6028 hr
= ID3D11Texture2D_GetPrivateData(d3d11_texture
, &test_guid
, &size
, &ptr
);
6029 ok(hr
== S_OK
, "Got unexpected hr %#x.\n", hr
);
6030 ok(ptr
== (IUnknown
*)test_object
, "Got unexpected ptr %p, expected %p.\n", ptr
, test_object
);
6031 IUnknown_Release(ptr
);
6032 ID3D11Texture2D_Release(d3d11_texture
);
6035 IDXGISurface_Release(surface
);
6036 ID3D10Texture2D_Release(texture
);
6037 refcount
= ID3D10Device_Release(device
);
6038 ok(!refcount
, "Device has %u references left.\n", refcount
);
6039 refcount
= ID3D10Device_Release(test_object
);
6040 ok(!refcount
, "Test object has %u references left.\n", refcount
);
6043 static void test_il_append_aligned(void)
6045 struct d3d10core_test_context test_context
;
6046 ID3D10InputLayout
*input_layout
;
6047 unsigned int stride
, offset
;
6048 ID3D10VertexShader
*vs
;
6049 ID3D10PixelShader
*ps
;
6050 ID3D10Device
*device
;
6051 ID3D10Buffer
*vb
[3];
6055 static const D3D10_INPUT_ELEMENT_DESC layout_desc
[] =
6057 {"COLOR", 2, DXGI_FORMAT_R32G32_FLOAT
, 1, D3D10_APPEND_ALIGNED_ELEMENT
,
6058 D3D10_INPUT_PER_INSTANCE_DATA
, 2},
6059 {"COLOR", 3, DXGI_FORMAT_R32G32_FLOAT
, 2, D3D10_APPEND_ALIGNED_ELEMENT
,
6060 D3D10_INPUT_PER_INSTANCE_DATA
, 1},
6061 {"POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
, 0, D3D10_APPEND_ALIGNED_ELEMENT
,
6062 D3D10_INPUT_PER_VERTEX_DATA
, 0},
6063 {"COLOR", 0, DXGI_FORMAT_R32G32_FLOAT
, 2, D3D10_APPEND_ALIGNED_ELEMENT
,
6064 D3D10_INPUT_PER_INSTANCE_DATA
, 1},
6065 {"COLOR", 1, DXGI_FORMAT_R32G32_FLOAT
, 1, D3D10_APPEND_ALIGNED_ELEMENT
,
6066 D3D10_INPUT_PER_INSTANCE_DATA
, 2},
6068 static const DWORD vs_code
[] =
6073 float4 position
: POSITION
;
6074 float2 color_xy
: COLOR0
;
6075 float2 color_zw
: COLOR1
;
6076 unsigned int instance_id
: SV_INSTANCEID
;
6081 float4 position
: SV_POSITION
;
6082 float2 color_xy
: COLOR0
;
6083 float2 color_zw
: COLOR1
;
6086 struct vs_out
main(struct vs_in i
)
6090 o
.position
= i
.position
;
6091 o
.position
.x
+= i
.instance_id
* 0.5;
6092 o
.color_xy
= i
.color_xy
;
6093 o
.color_zw
= i
.color_zw
;
6098 0x43425844, 0x52e3bf46, 0x6300403d, 0x624cffe4, 0xa4fc0013, 0x00000001, 0x00000214, 0x00000003,
6099 0x0000002c, 0x000000bc, 0x00000128, 0x4e475349, 0x00000088, 0x00000004, 0x00000008, 0x00000068,
6100 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000071, 0x00000000, 0x00000000,
6101 0x00000003, 0x00000001, 0x00000303, 0x00000071, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
6102 0x00000303, 0x00000077, 0x00000000, 0x00000008, 0x00000001, 0x00000003, 0x00000101, 0x49534f50,
6103 0x4e4f4954, 0x4c4f4300, 0x5300524f, 0x4e495f56, 0x4e415453, 0x44494543, 0xababab00, 0x4e47534f,
6104 0x00000064, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000,
6105 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000c03, 0x0000005c,
6106 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000030c, 0x505f5653, 0x5449534f, 0x004e4f49,
6107 0x4f4c4f43, 0xabab0052, 0x52444853, 0x000000e4, 0x00010040, 0x00000039, 0x0300005f, 0x001010f2,
6108 0x00000000, 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x00101032, 0x00000002, 0x04000060,
6109 0x00101012, 0x00000003, 0x00000008, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065,
6110 0x00102032, 0x00000001, 0x03000065, 0x001020c2, 0x00000001, 0x02000068, 0x00000001, 0x05000056,
6111 0x00100012, 0x00000000, 0x0010100a, 0x00000003, 0x09000032, 0x00102012, 0x00000000, 0x0010000a,
6112 0x00000000, 0x00004001, 0x3f000000, 0x0010100a, 0x00000000, 0x05000036, 0x001020e2, 0x00000000,
6113 0x00101e56, 0x00000000, 0x05000036, 0x00102032, 0x00000001, 0x00101046, 0x00000001, 0x05000036,
6114 0x001020c2, 0x00000001, 0x00101406, 0x00000002, 0x0100003e,
6116 static const DWORD ps_code
[] =
6121 float4 position
: SV_POSITION
;
6122 float2 color_xy
: COLOR0
;
6123 float2 color_zw
: COLOR1
;
6126 float4
main(struct vs_out i
) : SV_TARGET
6128 return float4(i
.color_xy
.xy
, i
.color_zw
.xy
);
6131 0x43425844, 0x64e48a09, 0xaa484d46, 0xe40a6e78, 0x9885edf3, 0x00000001, 0x00000118, 0x00000003,
6132 0x0000002c, 0x00000098, 0x000000cc, 0x4e475349, 0x00000064, 0x00000003, 0x00000008, 0x00000050,
6133 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000,
6134 0x00000003, 0x00000001, 0x00000303, 0x0000005c, 0x00000001, 0x00000000, 0x00000003, 0x00000001,
6135 0x00000c0c, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x4e47534f, 0x0000002c,
6136 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f,
6137 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000044, 0x00000040, 0x00000011, 0x03001062,
6138 0x00101032, 0x00000001, 0x03001062, 0x001010c2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
6139 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
6143 struct vec4 position
;
6147 {{-1.0f
, -1.0f
, 0.0f
, 1.0f
}},
6148 {{-1.0f
, 1.0f
, 0.0f
, 1.0f
}},
6149 {{-0.5f
, -1.0f
, 0.0f
, 1.0f
}},
6150 {{-0.5f
, 1.0f
, 0.0f
, 1.0f
}},
6159 {{0.5f
, 0.5f
}, {0.0f
, 1.0f
}},
6160 {{0.5f
, 0.5f
}, {1.0f
, 1.0f
}},
6169 {{0.5f
, 0.5f
}, {1.0f
, 0.0f
}},
6170 {{0.5f
, 0.5f
}, {0.0f
, 1.0f
}},
6171 {{0.5f
, 0.5f
}, {0.0f
, 0.0f
}},
6172 {{0.5f
, 0.5f
}, {1.0f
, 0.0f
}},
6174 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
6176 if (!init_test_context(&test_context
))
6179 device
= test_context
.device
;
6181 hr
= ID3D10Device_CreateInputLayout(device
, layout_desc
, sizeof(layout_desc
) / sizeof(*layout_desc
),
6182 vs_code
, sizeof(vs_code
), &input_layout
);
6183 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
6185 vb
[0] = create_buffer(device
, D3D10_BIND_VERTEX_BUFFER
, sizeof(stream0
), stream0
);
6186 vb
[1] = create_buffer(device
, D3D10_BIND_VERTEX_BUFFER
, sizeof(stream1
), stream1
);
6187 vb
[2] = create_buffer(device
, D3D10_BIND_VERTEX_BUFFER
, sizeof(stream2
), stream2
);
6189 hr
= ID3D10Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), &vs
);
6190 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
6191 hr
= ID3D10Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), &ps
);
6192 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
6194 ID3D10Device_IASetInputLayout(device
, input_layout
);
6195 ID3D10Device_IASetPrimitiveTopology(device
, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
6197 stride
= sizeof(*stream0
);
6198 ID3D10Device_IASetVertexBuffers(device
, 0, 1, &vb
[0], &stride
, &offset
);
6199 stride
= sizeof(*stream1
);
6200 ID3D10Device_IASetVertexBuffers(device
, 1, 1, &vb
[1], &stride
, &offset
);
6201 stride
= sizeof(*stream2
);
6202 ID3D10Device_IASetVertexBuffers(device
, 2, 1, &vb
[2], &stride
, &offset
);
6203 ID3D10Device_VSSetShader(device
, vs
);
6204 ID3D10Device_PSSetShader(device
, ps
);
6206 ID3D10Device_ClearRenderTargetView(device
, test_context
.backbuffer_rtv
, red
);
6208 ID3D10Device_DrawInstanced(device
, 4, 4, 0, 0);
6210 color
= get_texture_color(test_context
.backbuffer
, 80, 240);
6211 ok(compare_color(color
, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
6212 color
= get_texture_color(test_context
.backbuffer
, 240, 240);
6213 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
6214 color
= get_texture_color(test_context
.backbuffer
, 400, 240);
6215 ok(compare_color(color
, 0xffff0000, 1), "Got unexpected color 0x%08x.\n", color
);
6216 color
= get_texture_color(test_context
.backbuffer
, 560, 240);
6217 ok(compare_color(color
, 0xffff00ff, 1), "Got unexpected color 0x%08x.\n", color
);
6219 ID3D10PixelShader_Release(ps
);
6220 ID3D10VertexShader_Release(vs
);
6221 ID3D10Buffer_Release(vb
[2]);
6222 ID3D10Buffer_Release(vb
[1]);
6223 ID3D10Buffer_Release(vb
[0]);
6224 ID3D10InputLayout_Release(input_layout
);
6225 release_test_context(&test_context
);
6228 static void test_fragment_coords(void)
6230 struct d3d10core_test_context test_context
;
6231 ID3D10PixelShader
*ps
, *ps_frac
;
6232 ID3D10Device
*device
;
6233 ID3D10Buffer
*ps_cb
;
6237 static const DWORD ps_code
[] =
6242 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
6244 float4 ret
= float4(0.0, 0.0, 0.0, 1.0);
6246 if (position
.x
> cutoff
.x
)
6248 if (position
.y
> cutoff
.y
)
6254 0x43425844, 0x49fc9e51, 0x8068867d, 0xf20cfa39, 0xb8099e6b, 0x00000001, 0x00000144, 0x00000003,
6255 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
6256 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
6257 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
6258 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000a8, 0x00000040,
6259 0x0000002a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04002064, 0x00101032, 0x00000000,
6260 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x08000031, 0x00100032,
6261 0x00000000, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000000, 0x0a000001, 0x00102062,
6262 0x00000000, 0x00100106, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x3f800000, 0x00000000,
6263 0x08000036, 0x00102092, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x3f800000,
6266 static const DWORD ps_frac_code
[] =
6269 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
6271 return float4(frac(position
.xy
), 0.0, 1.0);
6274 0x43425844, 0x86d9d78a, 0x190b72c2, 0x50841fd6, 0xdc24022e, 0x00000001, 0x000000f8, 0x00000003,
6275 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
6276 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
6277 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
6278 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x0000005c, 0x00000040,
6279 0x00000017, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
6280 0x0500001a, 0x00102032, 0x00000000, 0x00101046, 0x00000000, 0x08000036, 0x001020c2, 0x00000000,
6281 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e,
6283 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
6284 struct vec4 cutoff
= {320.0f
, 240.0f
, 0.0f
, 0.0f
};
6286 if (!init_test_context(&test_context
))
6289 device
= test_context
.device
;
6291 ps_cb
= create_buffer(device
, D3D10_BIND_CONSTANT_BUFFER
, sizeof(cutoff
), &cutoff
);
6293 hr
= ID3D10Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), &ps
);
6294 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
6295 hr
= ID3D10Device_CreatePixelShader(device
, ps_frac_code
, sizeof(ps_frac_code
), &ps_frac
);
6296 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
6298 ID3D10Device_PSSetConstantBuffers(device
, 0, 1, &ps_cb
);
6299 ID3D10Device_PSSetShader(device
, ps
);
6301 ID3D10Device_ClearRenderTargetView(device
, test_context
.backbuffer_rtv
, red
);
6303 draw_quad(&test_context
);
6305 color
= get_texture_color(test_context
.backbuffer
, 319, 239);
6306 ok(compare_color(color
, 0xff000000, 1), "Got unexpected color 0x%08x.\n", color
);
6307 color
= get_texture_color(test_context
.backbuffer
, 320, 239);
6308 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
6309 color
= get_texture_color(test_context
.backbuffer
, 319, 240);
6310 ok(compare_color(color
, 0xffff0000, 1), "Got unexpected color 0x%08x.\n", color
);
6311 color
= get_texture_color(test_context
.backbuffer
, 320, 240);
6312 ok(compare_color(color
, 0xffffff00, 1), "Got unexpected color 0x%08x.\n", color
);
6314 ID3D10Buffer_Release(ps_cb
);
6317 ps_cb
= create_buffer(device
, D3D10_BIND_CONSTANT_BUFFER
, sizeof(cutoff
), &cutoff
);
6318 ID3D10Device_PSSetConstantBuffers(device
, 0, 1, &ps_cb
);
6320 draw_quad(&test_context
);
6322 color
= get_texture_color(test_context
.backbuffer
, 14, 14);
6323 ok(compare_color(color
, 0xff000000, 1), "Got unexpected color 0x%08x.\n", color
);
6324 color
= get_texture_color(test_context
.backbuffer
, 18, 14);
6325 ok(compare_color(color
, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
6326 color
= get_texture_color(test_context
.backbuffer
, 14, 18);
6327 ok(compare_color(color
, 0xffff0000, 1), "Got unexpected color 0x%08x.\n", color
);
6328 color
= get_texture_color(test_context
.backbuffer
, 18, 18);
6329 ok(compare_color(color
, 0xffffff00, 1), "Got unexpected color 0x%08x.\n", color
);
6331 ID3D10Device_PSSetShader(device
, ps_frac
);
6332 ID3D10Device_ClearRenderTargetView(device
, test_context
.backbuffer_rtv
, red
);
6334 draw_quad(&test_context
);
6336 color
= get_texture_color(test_context
.backbuffer
, 14, 14);
6337 ok(compare_color(color
, 0xff008080, 1), "Got unexpected color 0x%08x.\n", color
);
6339 ID3D10Buffer_Release(ps_cb
);
6340 ID3D10PixelShader_Release(ps_frac
);
6341 ID3D10PixelShader_Release(ps
);
6342 release_test_context(&test_context
);
6345 static void test_update_subresource(void)
6347 struct d3d10core_test_context test_context
;
6348 D3D10_TEXTURE2D_DESC texture_desc
;
6349 ID3D10SamplerState
*sampler_state
;
6350 ID3D10ShaderResourceView
*ps_srv
;
6351 D3D10_SAMPLER_DESC sampler_desc
;
6352 struct texture_readback rb
;
6353 ID3D10Texture2D
*texture
;
6354 ID3D10PixelShader
*ps
;
6355 ID3D10Device
*device
;
6361 static const DWORD ps_code
[] =
6367 float4
main(float4 position
: SV_POSITION
) : SV_Target
6371 p
.x
= position
.x
/ 640.0f
;
6372 p
.y
= position
.y
/ 480.0f
;
6373 return t
.Sample(s
, p
);
6376 0x43425844, 0x1ce9b612, 0xc8176faa, 0xd37844af, 0xdb515605, 0x00000001, 0x00000134, 0x00000003,
6377 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
6378 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
6379 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
6380 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
6381 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
6382 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
6383 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
6384 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
6385 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
6387 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
6388 static const DWORD bitmap_data
[] =
6390 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
6391 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
6392 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
6393 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
6395 static const DWORD expected_colors
[] =
6397 0xffffffff, 0xff000000, 0xffffffff, 0xff000000,
6398 0xff00ff00, 0xff0000ff, 0xff00ffff, 0x00000000,
6399 0xffffff00, 0xffff0000, 0xffff00ff, 0x00000000,
6400 0xff000000, 0xff7f7f7f, 0xffffffff, 0x00000000,
6403 if (!init_test_context(&test_context
))
6406 device
= test_context
.device
;
6408 texture_desc
.Width
= 4;
6409 texture_desc
.Height
= 4;
6410 texture_desc
.MipLevels
= 1;
6411 texture_desc
.ArraySize
= 1;
6412 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
6413 texture_desc
.SampleDesc
.Count
= 1;
6414 texture_desc
.SampleDesc
.Quality
= 0;
6415 texture_desc
.Usage
= D3D10_USAGE_DEFAULT
;
6416 texture_desc
.BindFlags
= D3D10_BIND_SHADER_RESOURCE
;
6417 texture_desc
.CPUAccessFlags
= 0;
6418 texture_desc
.MiscFlags
= 0;
6420 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
6421 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x\n", hr
);
6423 hr
= ID3D10Device_CreateShaderResourceView(device
, (ID3D10Resource
*)texture
, NULL
, &ps_srv
);
6424 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x\n", hr
);
6426 sampler_desc
.Filter
= D3D10_FILTER_MIN_MAG_MIP_POINT
;
6427 sampler_desc
.AddressU
= D3D10_TEXTURE_ADDRESS_CLAMP
;
6428 sampler_desc
.AddressV
= D3D10_TEXTURE_ADDRESS_CLAMP
;
6429 sampler_desc
.AddressW
= D3D10_TEXTURE_ADDRESS_CLAMP
;
6430 sampler_desc
.MipLODBias
= 0.0f
;
6431 sampler_desc
.MaxAnisotropy
= 0;
6432 sampler_desc
.ComparisonFunc
= D3D10_COMPARISON_NEVER
;
6433 sampler_desc
.BorderColor
[0] = 0.0f
;
6434 sampler_desc
.BorderColor
[1] = 0.0f
;
6435 sampler_desc
.BorderColor
[2] = 0.0f
;
6436 sampler_desc
.BorderColor
[3] = 0.0f
;
6437 sampler_desc
.MinLOD
= 0.0f
;
6438 sampler_desc
.MaxLOD
= 0.0f
;
6440 hr
= ID3D10Device_CreateSamplerState(device
, &sampler_desc
, &sampler_state
);
6441 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
6443 hr
= ID3D10Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), &ps
);
6444 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
6446 ID3D10Device_PSSetShaderResources(device
, 0, 1, &ps_srv
);
6447 ID3D10Device_PSSetSamplers(device
, 0, 1, &sampler_state
);
6448 ID3D10Device_PSSetShader(device
, ps
);
6450 ID3D10Device_ClearRenderTargetView(device
, test_context
.backbuffer_rtv
, red
);
6451 check_texture_color(test_context
.backbuffer
, 0x7f0000ff, 1);
6453 draw_quad(&test_context
);
6454 check_texture_color(test_context
.backbuffer
, 0x00000000, 0);
6456 set_box(&box
, 1, 1, 0, 3, 3, 1);
6457 ID3D10Device_UpdateSubresource(device
, (ID3D10Resource
*)texture
, 0, &box
,
6458 bitmap_data
, 4 * sizeof(*bitmap_data
), 0);
6459 set_box(&box
, 0, 3, 0, 3, 4, 1);
6460 ID3D10Device_UpdateSubresource(device
, (ID3D10Resource
*)texture
, 0, &box
,
6461 &bitmap_data
[6], 4 * sizeof(*bitmap_data
), 0);
6462 set_box(&box
, 0, 0, 0, 4, 1, 1);
6463 ID3D10Device_UpdateSubresource(device
, (ID3D10Resource
*)texture
, 0, &box
,
6464 &bitmap_data
[10], 4 * sizeof(*bitmap_data
), 0);
6465 set_box(&box
, 0, 1, 0, 1, 3, 1);
6466 ID3D10Device_UpdateSubresource(device
, (ID3D10Resource
*)texture
, 0, &box
,
6467 &bitmap_data
[2], sizeof(*bitmap_data
), 0);
6468 set_box(&box
, 4, 4, 0, 3, 1, 1);
6469 ID3D10Device_UpdateSubresource(device
, (ID3D10Resource
*)texture
, 0, &box
,
6470 bitmap_data
, sizeof(*bitmap_data
), 0);
6471 set_box(&box
, 0, 0, 0, 4, 4, 0);
6472 ID3D10Device_UpdateSubresource(device
, (ID3D10Resource
*)texture
, 0, &box
,
6473 bitmap_data
, 4 * sizeof(*bitmap_data
), 0);
6474 draw_quad(&test_context
);
6475 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
6476 for (i
= 0; i
< 4; ++i
)
6478 for (j
= 0; j
< 4; ++j
)
6480 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120);
6481 ok(compare_color(color
, expected_colors
[j
+ i
* 4], 1),
6482 "Got unexpected color 0x%08x at (%u, %u), expected 0x%08x.\n",
6483 color
, j
, i
, expected_colors
[j
+ i
* 4]);
6486 release_texture_readback(&rb
);
6488 ID3D10Device_UpdateSubresource(device
, (ID3D10Resource
*)texture
, 0, NULL
,
6489 bitmap_data
, 4 * sizeof(*bitmap_data
), 0);
6490 draw_quad(&test_context
);
6491 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
6492 for (i
= 0; i
< 4; ++i
)
6494 for (j
= 0; j
< 4; ++j
)
6496 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120);
6497 ok(compare_color(color
, bitmap_data
[j
+ i
* 4], 1),
6498 "Got unexpected color 0x%08x at (%u, %u), expected 0x%08x.\n",
6499 color
, j
, i
, bitmap_data
[j
+ i
* 4]);
6502 release_texture_readback(&rb
);
6504 ID3D10PixelShader_Release(ps
);
6505 ID3D10SamplerState_Release(sampler_state
);
6506 ID3D10ShaderResourceView_Release(ps_srv
);
6507 ID3D10Texture2D_Release(texture
);
6508 release_test_context(&test_context
);
6511 static void test_copy_subresource_region(void)
6513 struct d3d10core_test_context test_context
;
6514 ID3D10Texture2D
*dst_texture
, *src_texture
;
6515 ID3D10Buffer
*dst_buffer
, *src_buffer
;
6516 D3D10_SUBRESOURCE_DATA resource_data
;
6517 D3D10_TEXTURE2D_DESC texture_desc
;
6518 ID3D10SamplerState
*sampler_state
;
6519 ID3D10ShaderResourceView
*ps_srv
;
6520 D3D10_SAMPLER_DESC sampler_desc
;
6521 struct vec4 float_colors
[16];
6522 struct texture_readback rb
;
6523 ID3D10PixelShader
*ps
;
6524 ID3D10Device
*device
;
6530 static const DWORD ps_code
[] =
6536 float4
main(float4 position
: SV_POSITION
) : SV_Target
6540 p
.x
= position
.x
/ 640.0f
;
6541 p
.y
= position
.y
/ 480.0f
;
6542 return t
.Sample(s
, p
);
6545 0x43425844, 0x1ce9b612, 0xc8176faa, 0xd37844af, 0xdb515605, 0x00000001, 0x00000134, 0x00000003,
6546 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
6547 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
6548 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
6549 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
6550 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
6551 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
6552 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
6553 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
6554 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
6556 static const DWORD ps_buffer_code
[] =
6561 float4
main(float4 position
: SV_POSITION
) : SV_TARGET
6563 float2 p
= (float2
)4;
6564 p
*= float2(position
.x
/ 640.0f
, position
.y
/ 480.0f
);
6565 return buffer
[(int)p
.y
* 4 + (int)p
.x
];
6568 0x43425844, 0x57e7139f, 0x4f0c9e52, 0x598b77e3, 0x5a239132, 0x00000001, 0x0000016c, 0x00000003,
6569 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
6570 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
6571 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
6572 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000d0, 0x00000040,
6573 0x00000034, 0x04000859, 0x00208e46, 0x00000000, 0x00000010, 0x04002064, 0x00101032, 0x00000000,
6574 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0a000038, 0x00100032,
6575 0x00000000, 0x00101516, 0x00000000, 0x00004002, 0x3c088889, 0x3bcccccd, 0x00000000, 0x00000000,
6576 0x0500001b, 0x00100032, 0x00000000, 0x00100046, 0x00000000, 0x07000029, 0x00100012, 0x00000000,
6577 0x0010000a, 0x00000000, 0x00004001, 0x00000002, 0x0700001e, 0x00100012, 0x00000000, 0x0010000a,
6578 0x00000000, 0x0010001a, 0x00000000, 0x07000036, 0x001020f2, 0x00000000, 0x04208e46, 0x00000000,
6579 0x0010000a, 0x00000000, 0x0100003e,
6581 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
6582 static const DWORD bitmap_data
[] =
6584 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
6585 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
6586 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
6587 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
6589 static const DWORD expected_colors
[] =
6591 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
6592 0xffffff00, 0xff0000ff, 0xff00ffff, 0x00000000,
6593 0xff7f7f7f, 0xffff0000, 0xffff00ff, 0xff7f7f7f,
6594 0xffffffff, 0xffffffff, 0xff000000, 0x00000000,
6597 if (!init_test_context(&test_context
))
6600 device
= test_context
.device
;
6602 texture_desc
.Width
= 4;
6603 texture_desc
.Height
= 4;
6604 texture_desc
.MipLevels
= 1;
6605 texture_desc
.ArraySize
= 1;
6606 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
6607 texture_desc
.SampleDesc
.Count
= 1;
6608 texture_desc
.SampleDesc
.Quality
= 0;
6609 texture_desc
.Usage
= D3D10_USAGE_DEFAULT
;
6610 texture_desc
.BindFlags
= D3D10_BIND_SHADER_RESOURCE
;
6611 texture_desc
.CPUAccessFlags
= 0;
6612 texture_desc
.MiscFlags
= 0;
6614 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &dst_texture
);
6615 ok(SUCCEEDED(hr
), "Failed to create 2d texture, hr %#x.\n", hr
);
6617 texture_desc
.Usage
= D3D10_USAGE_IMMUTABLE
;
6619 resource_data
.pSysMem
= bitmap_data
;
6620 resource_data
.SysMemPitch
= 4 * sizeof(*bitmap_data
);
6621 resource_data
.SysMemSlicePitch
= 0;
6623 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, &resource_data
, &src_texture
);
6624 ok(SUCCEEDED(hr
), "Failed to create 2d texture, hr %#x.\n", hr
);
6626 hr
= ID3D10Device_CreateShaderResourceView(device
, (ID3D10Resource
*)dst_texture
, NULL
, &ps_srv
);
6627 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
6629 sampler_desc
.Filter
= D3D10_FILTER_MIN_MAG_MIP_POINT
;
6630 sampler_desc
.AddressU
= D3D10_TEXTURE_ADDRESS_CLAMP
;
6631 sampler_desc
.AddressV
= D3D10_TEXTURE_ADDRESS_CLAMP
;
6632 sampler_desc
.AddressW
= D3D10_TEXTURE_ADDRESS_CLAMP
;
6633 sampler_desc
.MipLODBias
= 0.0f
;
6634 sampler_desc
.MaxAnisotropy
= 0;
6635 sampler_desc
.ComparisonFunc
= D3D10_COMPARISON_NEVER
;
6636 sampler_desc
.BorderColor
[0] = 0.0f
;
6637 sampler_desc
.BorderColor
[1] = 0.0f
;
6638 sampler_desc
.BorderColor
[2] = 0.0f
;
6639 sampler_desc
.BorderColor
[3] = 0.0f
;
6640 sampler_desc
.MinLOD
= 0.0f
;
6641 sampler_desc
.MaxLOD
= 0.0f
;
6643 hr
= ID3D10Device_CreateSamplerState(device
, &sampler_desc
, &sampler_state
);
6644 ok(SUCCEEDED(hr
), "Failed to create sampler state, hr %#x.\n", hr
);
6646 hr
= ID3D10Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), &ps
);
6647 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
6649 ID3D10Device_PSSetShaderResources(device
, 0, 1, &ps_srv
);
6650 ID3D10Device_PSSetSamplers(device
, 0, 1, &sampler_state
);
6651 ID3D10Device_PSSetShader(device
, ps
);
6653 ID3D10Device_ClearRenderTargetView(device
, test_context
.backbuffer_rtv
, red
);
6655 set_box(&box
, 0, 0, 0, 2, 2, 1);
6656 ID3D10Device_CopySubresourceRegion(device
, (ID3D10Resource
*)dst_texture
, 0,
6657 1, 1, 0, (ID3D10Resource
*)src_texture
, 0, &box
);
6658 set_box(&box
, 1, 2, 0, 4, 3, 1);
6659 ID3D10Device_CopySubresourceRegion(device
, (ID3D10Resource
*)dst_texture
, 0,
6660 0, 3, 0, (ID3D10Resource
*)src_texture
, 0, &box
);
6661 set_box(&box
, 0, 3, 0, 4, 4, 1);
6662 ID3D10Device_CopySubresourceRegion(device
, (ID3D10Resource
*)dst_texture
, 0,
6663 0, 0, 0, (ID3D10Resource
*)src_texture
, 0, &box
);
6664 set_box(&box
, 3, 0, 0, 4, 2, 1);
6665 ID3D10Device_CopySubresourceRegion(device
, (ID3D10Resource
*)dst_texture
, 0,
6666 0, 1, 0, (ID3D10Resource
*)src_texture
, 0, &box
);
6667 set_box(&box
, 3, 1, 0, 4, 2, 1);
6668 ID3D10Device_CopySubresourceRegion(device
, (ID3D10Resource
*)dst_texture
, 0,
6669 3, 2, 0, (ID3D10Resource
*)src_texture
, 0, &box
);
6670 set_box(&box
, 0, 0, 0, 4, 4, 0);
6671 ID3D10Device_CopySubresourceRegion(device
, (ID3D10Resource
*)dst_texture
, 0,
6672 0, 0, 0, (ID3D10Resource
*)src_texture
, 0, &box
);
6673 draw_quad(&test_context
);
6674 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
6675 for (i
= 0; i
< 4; ++i
)
6677 for (j
= 0; j
< 4; ++j
)
6679 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120);
6680 ok(compare_color(color
, expected_colors
[j
+ i
* 4], 1),
6681 "Got unexpected color 0x%08x at (%u, %u), expected 0x%08x.\n",
6682 color
, j
, i
, expected_colors
[j
+ i
* 4]);
6685 release_texture_readback(&rb
);
6687 ID3D10Device_CopySubresourceRegion(device
, (ID3D10Resource
*)dst_texture
, 0,
6688 0, 0, 0, (ID3D10Resource
*)src_texture
, 0, NULL
);
6689 draw_quad(&test_context
);
6690 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
6691 for (i
= 0; i
< 4; ++i
)
6693 for (j
= 0; j
< 4; ++j
)
6695 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120);
6696 ok(compare_color(color
, bitmap_data
[j
+ i
* 4], 1),
6697 "Got unexpected color 0x%08x at (%u, %u), expected 0x%08x.\n",
6698 color
, j
, i
, bitmap_data
[j
+ i
* 4]);
6701 release_texture_readback(&rb
);
6703 ID3D10PixelShader_Release(ps
);
6704 hr
= ID3D10Device_CreatePixelShader(device
, ps_buffer_code
, sizeof(ps_buffer_code
), &ps
);
6705 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
6707 ID3D10ShaderResourceView_Release(ps_srv
);
6710 ID3D10SamplerState_Release(sampler_state
);
6711 sampler_state
= NULL
;
6713 ID3D10Texture2D_Release(dst_texture
);
6714 ID3D10Texture2D_Release(src_texture
);
6716 ID3D10Device_PSSetShaderResources(device
, 0, 1, &ps_srv
);
6717 ID3D10Device_PSSetSamplers(device
, 0, 1, &sampler_state
);
6718 ID3D10Device_PSSetShader(device
, ps
);
6720 dst_buffer
= create_buffer(device
, D3D10_BIND_CONSTANT_BUFFER
, sizeof(float_colors
), NULL
);
6722 ID3D10Device_PSSetConstantBuffers(device
, 0, 1, &dst_buffer
);
6724 src_buffer
= create_buffer(device
, 0, 256 * sizeof(*float_colors
), NULL
);
6726 for (i
= 0; i
< 4; ++i
)
6728 for (j
= 0; j
< 4; ++j
)
6730 float_colors
[j
+ i
* 4].x
= ((bitmap_data
[j
+ i
* 4] >> 0) & 0xff) / 255.0f
;
6731 float_colors
[j
+ i
* 4].y
= ((bitmap_data
[j
+ i
* 4] >> 8) & 0xff) / 255.0f
;
6732 float_colors
[j
+ i
* 4].z
= ((bitmap_data
[j
+ i
* 4] >> 16) & 0xff) / 255.0f
;
6733 float_colors
[j
+ i
* 4].w
= ((bitmap_data
[j
+ i
* 4] >> 24) & 0xff) / 255.0f
;
6736 set_box(&box
, 0, 0, 0, sizeof(float_colors
), 1, 1);
6737 ID3D10Device_UpdateSubresource(device
, (ID3D10Resource
*)src_buffer
, 0, &box
, float_colors
, 0, 0);
6739 set_box(&box
, 0, 0, 0, sizeof(float_colors
), 0, 1);
6740 ID3D10Device_CopySubresourceRegion(device
, (ID3D10Resource
*)dst_buffer
, 0,
6741 0, 0, 0, (ID3D10Resource
*)src_buffer
, 0, &box
);
6742 draw_quad(&test_context
);
6743 check_texture_color(test_context
.backbuffer
, 0x00000000, 0);
6745 set_box(&box
, 0, 0, 0, sizeof(float_colors
), 1, 0);
6746 ID3D10Device_CopySubresourceRegion(device
, (ID3D10Resource
*)dst_buffer
, 0,
6747 0, 0, 0, (ID3D10Resource
*)src_buffer
, 0, &box
);
6748 draw_quad(&test_context
);
6749 check_texture_color(test_context
.backbuffer
, 0x00000000, 0);
6751 set_box(&box
, 0, 0, 0, sizeof(float_colors
), 0, 0);
6752 ID3D10Device_CopySubresourceRegion(device
, (ID3D10Resource
*)dst_buffer
, 0,
6753 0, 0, 0, (ID3D10Resource
*)src_buffer
, 0, &box
);
6754 draw_quad(&test_context
);
6755 check_texture_color(test_context
.backbuffer
, 0x00000000, 0);
6757 set_box(&box
, 0, 0, 0, sizeof(float_colors
), 1, 1);
6758 ID3D10Device_CopySubresourceRegion(device
, (ID3D10Resource
*)dst_buffer
, 0,
6759 0, 0, 0, (ID3D10Resource
*)src_buffer
, 0, &box
);
6760 draw_quad(&test_context
);
6761 get_texture_readback(test_context
.backbuffer
, 0, &rb
);
6762 for (i
= 0; i
< 4; ++i
)
6764 for (j
= 0; j
< 4; ++j
)
6766 color
= get_readback_color(&rb
, 80 + j
* 160, 60 + i
* 120);
6767 ok(compare_color(color
, bitmap_data
[j
+ i
* 4], 1),
6768 "Got unexpected color 0x%08x at (%u, %u), expected 0x%08x.\n",
6769 color
, j
, i
, bitmap_data
[j
+ i
* 4]);
6772 release_texture_readback(&rb
);
6774 ID3D10Buffer_Release(dst_buffer
);
6775 ID3D10Buffer_Release(src_buffer
);
6776 ID3D10PixelShader_Release(ps
);
6777 release_test_context(&test_context
);
6780 static void test_texture_data_init(void)
6782 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
6783 struct d3d10core_test_context test_context
;
6784 D3D10_TEXTURE2D_DESC desc
;
6785 ID3D10Texture2D
*texture
;
6786 ID3D10Device
*device
;
6790 if (!init_test_context(&test_context
))
6793 device
= test_context
.device
;
6799 desc
.SampleDesc
.Count
= 1;
6800 desc
.SampleDesc
.Quality
= 0;
6801 desc
.Usage
= D3D10_USAGE_DEFAULT
;
6803 desc
.CPUAccessFlags
= 0;
6806 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
6807 hr
= ID3D10Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
6808 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
6809 check_texture_color(texture
, 0x00000000, 0);
6810 ID3D10Texture2D_Release(texture
);
6812 desc
.Format
= DXGI_FORMAT_D24_UNORM_S8_UINT
;
6813 hr
= ID3D10Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
6814 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
6815 check_texture_color(texture
, 0x00000000, 0);
6816 ID3D10Texture2D_Release(texture
);
6818 desc
.Format
= DXGI_FORMAT_D32_FLOAT
;
6819 hr
= ID3D10Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
6820 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
6821 check_texture_float(texture
, 0.0f
, 0);
6822 ID3D10Texture2D_Release(texture
);
6826 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
6827 hr
= ID3D10Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
6828 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
6829 check_texture_float(texture
, 0.0f
, 0);
6830 ID3D10Texture2D_Release(texture
);
6832 desc
.Format
= DXGI_FORMAT_D24_UNORM_S8_UINT
;
6833 hr
= ID3D10Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
6834 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
6835 check_texture_color(texture
, 0x00000000, 0);
6836 ID3D10Texture2D_Release(texture
);
6838 desc
.Format
= DXGI_FORMAT_D32_FLOAT
;
6839 hr
= ID3D10Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
6840 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
6841 check_texture_float(texture
, 0.0f
, 0);
6842 ID3D10Texture2D_Release(texture
);
6844 hr
= ID3D10Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 2, &count
);
6845 ok(SUCCEEDED(hr
), "Failed to get quality levels, hr %#x.\n", hr
);
6848 skip("Multisampling not supported for DXGI_FORMAT_R8G8B8A8_UNORM, skipping tests.\n");
6849 release_test_context(&test_context
);
6853 ID3D10Device_ClearRenderTargetView(device
, test_context
.backbuffer_rtv
, white
);
6856 desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
6857 desc
.SampleDesc
.Count
= 2;
6858 desc
.SampleDesc
.Quality
= 0;
6859 desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
6860 hr
= ID3D10Device_CreateTexture2D(device
, &desc
, NULL
, &texture
);
6861 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
6863 ID3D10Device_ResolveSubresource(device
, (ID3D10Resource
*)test_context
.backbuffer
, 0,
6864 (ID3D10Resource
*)texture
, 0, DXGI_FORMAT_R8G8B8A8_UNORM
);
6866 todo_wine
check_texture_color(test_context
.backbuffer
, 0x00000000, 0);
6868 ID3D10Texture2D_Release(texture
);
6870 release_test_context(&test_context
);
6873 static void test_check_multisample_quality_levels(void)
6875 ID3D10Device
*device
;
6876 UINT quality_levels
;
6880 if (!(device
= create_device()))
6882 skip("Failed to create device.\n");
6886 ID3D10Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 2, &quality_levels
);
6887 if (!quality_levels
)
6889 skip("Multisampling not supported for DXGI_FORMAT_R8G8B8A8_UNORM, skipping test.\n");
6893 quality_levels
= 0xdeadbeef;
6894 hr
= ID3D10Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_UNKNOWN
, 2, &quality_levels
);
6895 todo_wine
ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
6896 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
6897 quality_levels
= 0xdeadbeef;
6898 hr
= ID3D10Device_CheckMultisampleQualityLevels(device
, 65536, 2, &quality_levels
);
6899 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
6900 todo_wine
ok(quality_levels
== 0xdeadbeef, "Got unexpected quality_levels %u.\n", quality_levels
);
6902 quality_levels
= 0xdeadbeef;
6903 hr
= ID3D10Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, NULL
);
6904 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
6905 hr
= ID3D10Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 0, &quality_levels
);
6906 ok(hr
== E_FAIL
, "Got unexpected hr %#x.\n", hr
);
6907 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
6909 quality_levels
= 0xdeadbeef;
6910 hr
= ID3D10Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 1, NULL
);
6911 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
6912 hr
= ID3D10Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 1, &quality_levels
);
6913 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
6914 ok(quality_levels
== 1, "Got unexpected quality_levels %u.\n", quality_levels
);
6916 quality_levels
= 0xdeadbeef;
6917 hr
= ID3D10Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 2, NULL
);
6918 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
6919 hr
= ID3D10Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 2, &quality_levels
);
6920 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
6921 ok(quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
6923 /* We assume 15 samples multisampling is never supported in practice. */
6924 quality_levels
= 0xdeadbeef;
6925 hr
= ID3D10Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 15, &quality_levels
);
6926 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
6927 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
6928 hr
= ID3D10Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 32, &quality_levels
);
6929 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
6930 quality_levels
= 0xdeadbeef;
6931 hr
= ID3D10Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 33, &quality_levels
);
6932 ok(hr
== E_FAIL
, "Got unexpected hr %#x.\n", hr
);
6933 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
6934 quality_levels
= 0xdeadbeef;
6935 hr
= ID3D10Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_R8G8B8A8_UNORM
, 64, &quality_levels
);
6936 ok(hr
== E_FAIL
, "Got unexpected hr %#x.\n", hr
);
6937 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
6939 hr
= ID3D10Device_CheckMultisampleQualityLevels(device
, DXGI_FORMAT_BC3_UNORM
, 2, &quality_levels
);
6940 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
6941 ok(!quality_levels
, "Got unexpected quality_levels %u.\n", quality_levels
);
6944 refcount
= ID3D10Device_Release(device
);
6945 ok(!refcount
, "Device has %u references left.\n", refcount
);
6948 static void test_cb_relative_addressing(void)
6950 struct d3d10core_test_context test_context
;
6951 ID3D10Buffer
*vb
, *colors_cb
, *index_cb
;
6952 ID3D10InputLayout
*input_layout
;
6953 unsigned int i
, index
[4] = {0};
6954 unsigned int stride
, offset
;
6955 ID3D10VertexShader
*vs
;
6956 ID3D10PixelShader
*ps
;
6957 ID3D10Device
*device
;
6961 static const D3D10_INPUT_ELEMENT_DESC layout_desc
[] =
6963 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D10_INPUT_PER_VERTEX_DATA
, 0},
6965 static const DWORD vs_code
[] =
6977 float4 position
: POSITION
;
6982 float4 position
: SV_POSITION
;
6983 float4 color
: COLOR
;
6986 vs_out
main(const vs_in v
)
6990 o
.position
= v
.position
;
6991 o
.color
= colors
[color_index
];
6996 0x43425844, 0xcecf6d7c, 0xe418097c, 0x47902dd0, 0x9500abc2, 0x00000001, 0x00000160, 0x00000003,
6997 0x0000002c, 0x00000060, 0x000000b4, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
6998 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
6999 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
7000 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
7001 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x000000a4, 0x00010040,
7002 0x00000029, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04000859, 0x00208e46, 0x00000001,
7003 0x00000008, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
7004 0x03000065, 0x001020f2, 0x00000001, 0x02000068, 0x00000001, 0x05000036, 0x001020f2, 0x00000000,
7005 0x00101e46, 0x00000000, 0x06000036, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000,
7006 0x07000036, 0x001020f2, 0x00000001, 0x04208e46, 0x00000001, 0x0010000a, 0x00000000, 0x0100003e,
7008 static const DWORD ps_code
[] =
7013 float4 position
: SV_POSITION
;
7014 float4 color
: COLOR
;
7017 float4
main(const ps_in v
) : SV_TARGET
7022 0x43425844, 0xe2087fa6, 0xa35fbd95, 0x8e585b3f, 0x67890f54, 0x00000001, 0x000000f4, 0x00000003,
7023 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
7024 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
7025 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
7026 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
7027 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040,
7028 0x0000000e, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
7029 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
7033 struct vec2 position
;
7048 {{0.0f
, 0.0f
, 0.0f
, 1.0f
}},
7049 {{0.0f
, 0.0f
, 1.0f
, 0.0f
}},
7050 {{0.0f
, 0.0f
, 1.0f
, 1.0f
}},
7051 {{0.0f
, 1.0f
, 0.0f
, 0.0f
}},
7052 {{0.0f
, 1.0f
, 0.0f
, 1.0f
}},
7053 {{0.0f
, 1.0f
, 1.0f
, 0.0f
}},
7054 {{0.0f
, 1.0f
, 1.0f
, 1.0f
}},
7055 {{1.0f
, 0.0f
, 0.0f
, 0.0f
}},
7056 {{1.0f
, 0.0f
, 0.0f
, 1.0f
}},
7057 {{1.0f
, 0.0f
, 1.0f
, 0.0f
}},
7078 static const float white
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
7080 if (!init_test_context(&test_context
))
7083 device
= test_context
.device
;
7085 hr
= ID3D10Device_CreateInputLayout(device
, layout_desc
, sizeof(layout_desc
) / sizeof(*layout_desc
),
7086 vs_code
, sizeof(vs_code
), &input_layout
);
7087 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
7089 vb
= create_buffer(device
, D3D10_BIND_VERTEX_BUFFER
, sizeof(quad
), quad
);
7090 colors_cb
= create_buffer(device
, D3D10_BIND_CONSTANT_BUFFER
, sizeof(colors
), &colors
);
7091 index_cb
= create_buffer(device
, D3D10_BIND_CONSTANT_BUFFER
, sizeof(index
), NULL
);
7093 hr
= ID3D10Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), &vs
);
7094 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
7095 hr
= ID3D10Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), &ps
);
7096 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
7098 ID3D10Device_IASetInputLayout(device
, input_layout
);
7099 ID3D10Device_IASetPrimitiveTopology(device
, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
7100 stride
= sizeof(*quad
);
7102 ID3D10Device_IASetVertexBuffers(device
, 0, 1, &vb
, &stride
, &offset
);
7103 ID3D10Device_VSSetShader(device
, vs
);
7104 ID3D10Device_VSSetConstantBuffers(device
, 0, 1, &index_cb
);
7105 ID3D10Device_VSSetConstantBuffers(device
, 1, 1, &colors_cb
);
7106 ID3D10Device_PSSetShader(device
, ps
);
7108 for (i
= 0; i
< sizeof(test_data
) / sizeof(*test_data
); ++i
)
7110 ID3D10Device_ClearRenderTargetView(device
, test_context
.backbuffer_rtv
, white
);
7112 index
[0] = test_data
[i
].index
;
7113 ID3D10Device_UpdateSubresource(device
, (ID3D10Resource
*)index_cb
, 0, NULL
, index
, 0, 0);
7115 ID3D10Device_Draw(device
, 4, 0);
7117 color
= get_texture_color(test_context
.backbuffer
, 319, 239);
7118 ok(compare_color(color
, test_data
[i
].expected
, 1),
7119 "Got unexpected color 0x%08x for index %d.\n", color
, test_data
[i
].index
);
7122 ID3D10Buffer_Release(index_cb
);
7123 ID3D10Buffer_Release(colors_cb
);
7125 ID3D10PixelShader_Release(ps
);
7126 ID3D10VertexShader_Release(vs
);
7127 ID3D10Buffer_Release(vb
);
7128 ID3D10InputLayout_Release(input_layout
);
7129 release_test_context(&test_context
);
7132 static void test_swapchain_flip(void)
7134 IDXGISwapChain
*swapchain
;
7135 ID3D10Texture2D
*backbuffer_0
, *backbuffer_1
, *backbuffer_2
, *offscreen
;
7136 ID3D10RenderTargetView
*backbuffer_0_rtv
, *offscreen_rtv
;
7137 ID3D10ShaderResourceView
*backbuffer_0_srv
, *backbuffer_1_srv
;
7138 D3D10_TEXTURE2D_DESC texture_desc
;
7139 ID3D10VertexShader
*vs
;
7140 ID3D10PixelShader
*ps
;
7141 ID3D10InputLayout
*input_layout
;
7143 unsigned int stride
, offset
;
7144 ID3D10Device
*device
;
7151 static const D3D10_INPUT_ELEMENT_DESC layout_desc
[] =
7153 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D10_INPUT_PER_VERTEX_DATA
, 0},
7155 static const DWORD vs_code
[] =
7158 float4
main(float4 position
: POSITION
) : SV_POSITION
7163 0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003,
7164 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
7165 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
7166 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
7167 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
7168 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
7169 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
7172 static const DWORD ps_code
[] =
7178 float4
main(float4 position
: SV_POSITION
) : SV_Target
7184 if (position
.x
< 320)
7185 return t0
.Sample(s
, p
);
7186 return t1
.Sample(s
, p
);
7189 0x43425844, 0x1733542c, 0xf74c6b6a, 0x0fb11eac, 0x76f6a999, 0x00000001, 0x000002cc, 0x00000005,
7190 0x00000034, 0x000000f4, 0x00000128, 0x0000015c, 0x00000250, 0x46454452, 0x000000b8, 0x00000000,
7191 0x00000000, 0x00000003, 0x0000001c, 0xffff0400, 0x00000100, 0x00000084, 0x0000007c, 0x00000003,
7192 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x0000007e, 0x00000002,
7193 0x00000005, 0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000c, 0x00000081, 0x00000002,
7194 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000c, 0x30740073, 0x00317400,
7195 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d,
7196 0x39207265, 0x2e39322e, 0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x0000002c, 0x00000001,
7197 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000010f, 0x505f5653,
7198 0x5449534f, 0x004e4f49, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000,
7199 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853,
7200 0x000000ec, 0x00000040, 0x0000003b, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000,
7201 0x00000000, 0x00005555, 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x04002064, 0x00101012,
7202 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x07000031,
7203 0x00100012, 0x00000000, 0x0010100a, 0x00000000, 0x00004001, 0x43a00000, 0x0304001f, 0x0010000a,
7204 0x00000000, 0x0c000045, 0x001020f2, 0x00000000, 0x00004002, 0x3f000000, 0x3f000000, 0x00000000,
7205 0x00000000, 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e, 0x01000015, 0x0c000045,
7206 0x001020f2, 0x00000000, 0x00004002, 0x3f000000, 0x3f000000, 0x00000000, 0x00000000, 0x00107e46,
7207 0x00000001, 0x00106000, 0x00000000, 0x0100003e, 0x54415453, 0x00000074, 0x00000007, 0x00000001,
7208 0x00000000, 0x00000002, 0x00000001, 0x00000000, 0x00000000, 0x00000002, 0x00000001, 0x00000000,
7209 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000,
7210 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
7211 0x00000000, 0x00000000, 0x00000000
7215 struct vec2 position
;
7224 static const float red
[] = {1.0f
, 0.0f
, 0.0f
, 0.5f
};
7225 static const float green
[] = {0.0f
, 1.0f
, 0.0f
, 0.5f
};
7226 static const float blue
[] = {0.0f
, 0.0f
, 1.0f
, 0.5f
};
7227 struct swapchain_desc desc
;
7229 if (!(device
= create_device()))
7231 skip("Failed to create device, skipping tests.\n");
7234 window
= CreateWindowA("static", "d3d10core_test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
7235 0, 0, 640, 480, NULL
, NULL
, NULL
, NULL
);
7236 desc
.buffer_count
= 3;
7237 desc
.swap_effect
= DXGI_SWAP_EFFECT_SEQUENTIAL
;
7238 desc
.windowed
= TRUE
;
7239 desc
.flags
= SWAPCHAIN_FLAG_SHADER_INPUT
;
7240 swapchain
= create_swapchain(device
, window
, &desc
);
7242 hr
= IDXGISwapChain_GetBuffer(swapchain
, 0, &IID_ID3D10Texture2D
, (void **)&backbuffer_0
);
7243 ok(SUCCEEDED(hr
), "Failed to get buffer, hr %#x.\n", hr
);
7244 hr
= IDXGISwapChain_GetBuffer(swapchain
, 1, &IID_ID3D10Texture2D
, (void **)&backbuffer_1
);
7245 ok(SUCCEEDED(hr
), "Failed to get buffer, hr %#x.\n", hr
);
7246 hr
= IDXGISwapChain_GetBuffer(swapchain
, 2, &IID_ID3D10Texture2D
, (void **)&backbuffer_2
);
7247 ok(SUCCEEDED(hr
), "Failed to get buffer, hr %#x.\n", hr
);
7249 hr
= ID3D10Device_CreateRenderTargetView(device
, (ID3D10Resource
*)backbuffer_0
, NULL
, &backbuffer_0_rtv
);
7250 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
7251 hr
= ID3D10Device_CreateShaderResourceView(device
, (ID3D10Resource
*)backbuffer_0
, NULL
, &backbuffer_0_srv
);
7252 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
7253 hr
= ID3D10Device_CreateShaderResourceView(device
, (ID3D10Resource
*)backbuffer_1
, NULL
, &backbuffer_1_srv
);
7254 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
7256 ID3D10Texture2D_GetDesc(backbuffer_0
, &texture_desc
);
7257 todo_wine
ok((texture_desc
.BindFlags
& (D3D10_BIND_RENDER_TARGET
| D3D10_BIND_SHADER_RESOURCE
))
7258 == (D3D10_BIND_RENDER_TARGET
| D3D10_BIND_SHADER_RESOURCE
),
7259 "Got unexpected bind flags %x.\n", texture_desc
.BindFlags
);
7260 ok(texture_desc
.Usage
== D3D10_USAGE_DEFAULT
, "Got unexpected usage %u.\n", texture_desc
.Usage
);
7262 ID3D10Texture2D_GetDesc(backbuffer_1
, &texture_desc
);
7263 todo_wine
ok((texture_desc
.BindFlags
& (D3D10_BIND_RENDER_TARGET
| D3D10_BIND_SHADER_RESOURCE
))
7264 == (D3D10_BIND_RENDER_TARGET
| D3D10_BIND_SHADER_RESOURCE
),
7265 "Got unexpected bind flags %x.\n", texture_desc
.BindFlags
);
7266 ok(texture_desc
.Usage
== D3D10_USAGE_DEFAULT
, "Got unexpected usage %u.\n", texture_desc
.Usage
);
7268 hr
= ID3D10Device_CreateRenderTargetView(device
, (ID3D10Resource
*)backbuffer_1
, NULL
, &offscreen_rtv
);
7269 todo_wine
ok(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
7271 ID3D10RenderTargetView_Release(offscreen_rtv
);
7273 ID3D10Device_PSSetShaderResources(device
, 0, 1, &backbuffer_0_srv
);
7274 ID3D10Device_PSSetShaderResources(device
, 1, 1, &backbuffer_1_srv
);
7276 texture_desc
.Width
= 640;
7277 texture_desc
.Height
= 480;
7278 texture_desc
.MipLevels
= 1;
7279 texture_desc
.ArraySize
= 1;
7280 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
7281 texture_desc
.SampleDesc
.Count
= 1;
7282 texture_desc
.SampleDesc
.Quality
= 0;
7283 texture_desc
.Usage
= D3D10_USAGE_DEFAULT
;
7284 texture_desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
7285 texture_desc
.CPUAccessFlags
= 0;
7286 texture_desc
.MiscFlags
= 0;
7287 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &offscreen
);
7288 ok(SUCCEEDED(hr
), "Failed to create a 2d texture, hr %#x.\n", hr
);
7289 hr
= ID3D10Device_CreateRenderTargetView(device
, (ID3D10Resource
*)offscreen
, NULL
, &offscreen_rtv
);
7290 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
7291 ID3D10Device_OMSetRenderTargets(device
, 1, &offscreen_rtv
, NULL
);
7298 ID3D10Device_RSSetViewports(device
, 1, &vp
);
7300 vb
= create_buffer(device
, D3D10_BIND_VERTEX_BUFFER
, sizeof(quad
), quad
);
7302 hr
= ID3D10Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), &vs
);
7303 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
7304 hr
= ID3D10Device_CreateInputLayout(device
, layout_desc
, sizeof(layout_desc
) / sizeof(*layout_desc
),
7305 vs_code
, sizeof(vs_code
), &input_layout
);
7306 ok(SUCCEEDED(hr
), "Failed to create input layout, hr %#x.\n", hr
);
7307 ID3D10Device_IASetInputLayout(device
, input_layout
);
7308 ID3D10Device_IASetPrimitiveTopology(device
, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
7309 ID3D10Device_VSSetShader(device
, vs
);
7310 stride
= sizeof(*quad
);
7312 ID3D10Device_IASetVertexBuffers(device
, 0, 1, &vb
, &stride
, &offset
);
7314 hr
= ID3D10Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), &ps
);
7315 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
7316 ID3D10Device_PSSetShader(device
, ps
);
7318 ID3D10Device_ClearRenderTargetView(device
, backbuffer_0_rtv
, red
);
7320 ID3D10Device_Draw(device
, 4, 0);
7321 color
= get_texture_color(offscreen
, 120, 240);
7322 todo_wine
ok(compare_color(color
, 0x7f0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
7324 /* DXGI moves buffers in the same direction as earlier versions. Buffer 2 becomes buffer 1,
7325 * buffer 1 becomes the new buffer 0, and buffer 0 becomes buffer n - 1. However, only buffer
7326 * 0 can be rendered to.
7328 * What is this good for? I don't know. Ad-hoc tests suggest that Present always waits for
7329 * the next vsync interval, even if there are still untouched buffers. Buffer 0 is the buffer
7330 * that is shown on the screen, just like in <= d3d9. Present also doesn't discard buffers if
7331 * rendering finishes before the vsync interval is over. I haven't found any productive use
7332 * for more than one buffer. */
7333 IDXGISwapChain_Present(swapchain
, 0, 0);
7335 ID3D10Device_ClearRenderTargetView(device
, backbuffer_0_rtv
, green
);
7337 ID3D10Device_Draw(device
, 4, 0);
7338 color
= get_texture_color(offscreen
, 120, 240); /* green, buf 0 */
7339 todo_wine
ok(compare_color(color
, 0x7f00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
7340 /* Buffer 1 is still untouched. */
7342 color
= get_texture_color(backbuffer_0
, 320, 240); /* green */
7343 ok(compare_color(color
, 0x7f00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
7344 color
= get_texture_color(backbuffer_2
, 320, 240); /* red */
7345 ok(compare_color(color
, 0x7f0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
7347 IDXGISwapChain_Present(swapchain
, 0, 0);
7349 ID3D10Device_ClearRenderTargetView(device
, backbuffer_0_rtv
, blue
);
7351 ID3D10Device_Draw(device
, 4, 0);
7352 color
= get_texture_color(offscreen
, 120, 240); /* blue, buf 0 */
7353 todo_wine
ok(compare_color(color
, 0x7fff0000, 1), "Got unexpected color 0x%08x.\n", color
);
7354 color
= get_texture_color(offscreen
, 360, 240); /* red, buf 1 */
7355 ok(compare_color(color
, 0x7f0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
7357 color
= get_texture_color(backbuffer_0
, 320, 240); /* blue */
7358 ok(compare_color(color
, 0x7fff0000, 1), "Got unexpected color 0x%08x.\n", color
);
7359 color
= get_texture_color(backbuffer_1
, 320, 240); /* red */
7360 ok(compare_color(color
, 0x7f0000ff, 1), "Got unexpected color 0x%08x.\n", color
);
7361 color
= get_texture_color(backbuffer_2
, 320, 240); /* green */
7362 ok(compare_color(color
, 0x7f00ff00, 1), "Got unexpected color 0x%08x.\n", color
);
7364 ID3D10VertexShader_Release(vs
);
7365 ID3D10PixelShader_Release(ps
);
7366 ID3D10Buffer_Release(vb
);
7367 ID3D10InputLayout_Release(input_layout
);
7368 ID3D10ShaderResourceView_Release(backbuffer_0_srv
);
7369 ID3D10ShaderResourceView_Release(backbuffer_1_srv
);
7370 ID3D10RenderTargetView_Release(backbuffer_0_rtv
);
7371 ID3D10RenderTargetView_Release(offscreen_rtv
);
7372 ID3D10Texture2D_Release(offscreen
);
7373 ID3D10Texture2D_Release(backbuffer_0
);
7374 ID3D10Texture2D_Release(backbuffer_1
);
7375 ID3D10Texture2D_Release(backbuffer_2
);
7376 IDXGISwapChain_Release(swapchain
);
7378 refcount
= ID3D10Device_Release(device
);
7379 ok(!refcount
, "Device has %u references left.\n", refcount
);
7380 DestroyWindow(window
);
7383 static void test_clear_render_target_view(void)
7385 static const DWORD expected_color
= 0xbf4c7f19, expected_srgb_color
= 0xbf95bc59;
7386 static const float color
[] = {0.1f
, 0.5f
, 0.3f
, 0.75f
};
7387 static const float green
[] = {0.0f
, 1.0f
, 0.0f
, 0.5f
};
7389 struct d3d10core_test_context test_context
;
7390 ID3D10Texture2D
*texture
, *srgb_texture
;
7391 ID3D10RenderTargetView
*rtv
, *srgb_rtv
;
7392 D3D10_RENDER_TARGET_VIEW_DESC rtv_desc
;
7393 D3D10_TEXTURE2D_DESC texture_desc
;
7394 ID3D10Device
*device
;
7397 if (!init_test_context(&test_context
))
7400 device
= test_context
.device
;
7402 texture_desc
.Width
= 640;
7403 texture_desc
.Height
= 480;
7404 texture_desc
.MipLevels
= 1;
7405 texture_desc
.ArraySize
= 1;
7406 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
7407 texture_desc
.SampleDesc
.Count
= 1;
7408 texture_desc
.SampleDesc
.Quality
= 0;
7409 texture_desc
.Usage
= D3D10_USAGE_DEFAULT
;
7410 texture_desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
7411 texture_desc
.CPUAccessFlags
= 0;
7412 texture_desc
.MiscFlags
= 0;
7413 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
7414 ok(SUCCEEDED(hr
), "Failed to create depth texture, hr %#x.\n", hr
);
7416 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
;
7417 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &srgb_texture
);
7418 ok(SUCCEEDED(hr
), "Failed to create depth texture, hr %#x.\n", hr
);
7420 hr
= ID3D10Device_CreateRenderTargetView(device
, (ID3D10Resource
*)texture
, NULL
, &rtv
);
7421 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
7423 hr
= ID3D10Device_CreateRenderTargetView(device
, (ID3D10Resource
*)srgb_texture
, NULL
, &srgb_rtv
);
7424 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
7426 ID3D10Device_ClearRenderTargetView(device
, test_context
.backbuffer_rtv
, color
);
7427 check_texture_color(test_context
.backbuffer
, expected_color
, 1);
7429 ID3D10Device_ClearRenderTargetView(device
, rtv
, color
);
7430 check_texture_color(texture
, expected_color
, 1);
7432 if (is_d3d11_interface_available(device
))
7434 ID3D10Device_ClearRenderTargetView(device
, NULL
, green
);
7435 check_texture_color(texture
, expected_color
, 1);
7438 win_skip("D3D11 is not available, skipping test.\n");
7440 ID3D10Device_ClearRenderTargetView(device
, srgb_rtv
, color
);
7441 check_texture_color(srgb_texture
, expected_srgb_color
, 1);
7443 ID3D10RenderTargetView_Release(srgb_rtv
);
7444 ID3D10RenderTargetView_Release(rtv
);
7445 ID3D10Texture2D_Release(srgb_texture
);
7446 ID3D10Texture2D_Release(texture
);
7448 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_TYPELESS
;
7449 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
7450 ok(SUCCEEDED(hr
), "Failed to create depth texture, hr %#x.\n", hr
);
7452 rtv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
;
7453 rtv_desc
.ViewDimension
= D3D10_RTV_DIMENSION_TEXTURE2D
;
7454 U(rtv_desc
).Texture2D
.MipSlice
= 0;
7455 hr
= ID3D10Device_CreateRenderTargetView(device
, (ID3D10Resource
*)texture
, &rtv_desc
, &srgb_rtv
);
7456 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
7458 rtv_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
7459 rtv_desc
.ViewDimension
= D3D10_RTV_DIMENSION_TEXTURE2D
;
7460 U(rtv_desc
).Texture2D
.MipSlice
= 0;
7461 hr
= ID3D10Device_CreateRenderTargetView(device
, (ID3D10Resource
*)texture
, &rtv_desc
, &rtv
);
7462 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
7464 ID3D10Device_ClearRenderTargetView(device
, rtv
, color
);
7465 check_texture_color(texture
, expected_color
, 1);
7467 if (!is_warp_device(device
))
7469 ID3D10Device_ClearRenderTargetView(device
, srgb_rtv
, color
);
7470 todo_wine
check_texture_color(texture
, expected_srgb_color
, 1);
7474 win_skip("sRGB clears are broken on WARP.\n");
7477 ID3D10RenderTargetView_Release(srgb_rtv
);
7478 ID3D10RenderTargetView_Release(rtv
);
7479 ID3D10Texture2D_Release(texture
);
7480 release_test_context(&test_context
);
7483 static void test_clear_depth_stencil_view(void)
7485 D3D10_TEXTURE2D_DESC texture_desc
;
7486 ID3D10Texture2D
*depth_texture
;
7487 ID3D10DepthStencilView
*dsv
;
7488 ID3D10Device
*device
;
7492 if (!(device
= create_device()))
7494 skip("Failed to create device.\n");
7498 texture_desc
.Width
= 640;
7499 texture_desc
.Height
= 480;
7500 texture_desc
.MipLevels
= 1;
7501 texture_desc
.ArraySize
= 1;
7502 texture_desc
.Format
= DXGI_FORMAT_D32_FLOAT
;
7503 texture_desc
.SampleDesc
.Count
= 1;
7504 texture_desc
.SampleDesc
.Quality
= 0;
7505 texture_desc
.Usage
= D3D10_USAGE_DEFAULT
;
7506 texture_desc
.BindFlags
= D3D10_BIND_DEPTH_STENCIL
;
7507 texture_desc
.CPUAccessFlags
= 0;
7508 texture_desc
.MiscFlags
= 0;
7509 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &depth_texture
);
7510 ok(SUCCEEDED(hr
), "Failed to create depth texture, hr %#x.\n", hr
);
7512 hr
= ID3D10Device_CreateDepthStencilView(device
, (ID3D10Resource
*)depth_texture
, NULL
, &dsv
);
7513 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
7515 ID3D10Device_ClearDepthStencilView(device
, dsv
, D3D10_CLEAR_DEPTH
, 1.0f
, 0);
7516 check_texture_float(depth_texture
, 1.0f
, 0);
7518 ID3D10Device_ClearDepthStencilView(device
, dsv
, D3D10_CLEAR_DEPTH
, 0.25f
, 0);
7519 check_texture_float(depth_texture
, 0.25f
, 0);
7521 ID3D10Texture2D_Release(depth_texture
);
7522 ID3D10DepthStencilView_Release(dsv
);
7524 texture_desc
.Format
= DXGI_FORMAT_D24_UNORM_S8_UINT
;
7525 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &depth_texture
);
7526 ok(SUCCEEDED(hr
), "Failed to create depth texture, hr %#x.\n", hr
);
7528 hr
= ID3D10Device_CreateDepthStencilView(device
, (ID3D10Resource
*)depth_texture
, NULL
, &dsv
);
7529 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
7531 ID3D10Device_ClearDepthStencilView(device
, dsv
, D3D10_CLEAR_DEPTH
| D3D10_CLEAR_STENCIL
, 1.0f
, 0);
7532 todo_wine
check_texture_color(depth_texture
, 0x00ffffff, 0);
7534 ID3D10Device_ClearDepthStencilView(device
, dsv
, D3D10_CLEAR_DEPTH
| D3D10_CLEAR_STENCIL
, 0.0f
, 0xff);
7535 todo_wine
check_texture_color(depth_texture
, 0xff000000, 0);
7537 ID3D10Device_ClearDepthStencilView(device
, dsv
, D3D10_CLEAR_DEPTH
| D3D10_CLEAR_STENCIL
, 1.0f
, 0xff);
7538 check_texture_color(depth_texture
, 0xffffffff, 0);
7540 ID3D10Device_ClearDepthStencilView(device
, dsv
, D3D10_CLEAR_DEPTH
| D3D10_CLEAR_STENCIL
, 0.0f
, 0);
7541 check_texture_color(depth_texture
, 0x00000000, 0);
7543 if (is_d3d11_interface_available(device
))
7545 ID3D10Device_ClearDepthStencilView(device
, NULL
, D3D10_CLEAR_DEPTH
| D3D10_CLEAR_STENCIL
, 1.0f
, 0xff);
7546 check_texture_color(depth_texture
, 0x00000000, 0);
7549 win_skip("D3D11 is not available, skipping test.\n");
7551 ID3D10Device_ClearDepthStencilView(device
, dsv
, D3D10_CLEAR_DEPTH
, 1.0f
, 0xff);
7552 todo_wine
check_texture_color(depth_texture
, 0x00ffffff, 0);
7554 ID3D10Device_ClearDepthStencilView(device
, dsv
, D3D10_CLEAR_STENCIL
, 0.0f
, 0xff);
7555 check_texture_color(depth_texture
, 0xffffffff, 0);
7557 ID3D10Texture2D_Release(depth_texture
);
7558 ID3D10DepthStencilView_Release(dsv
);
7560 refcount
= ID3D10Device_Release(device
);
7561 ok(!refcount
, "Device has %u references left.\n", refcount
);
7564 static void test_draw_depth_only(void)
7566 ID3D10DepthStencilState
*depth_stencil_state
;
7567 D3D10_DEPTH_STENCIL_DESC depth_stencil_desc
;
7568 struct d3d10core_test_context test_context
;
7569 ID3D10PixelShader
*ps_color
, *ps_depth
;
7570 D3D10_TEXTURE2D_DESC texture_desc
;
7571 ID3D10DepthStencilView
*dsv
;
7572 struct texture_readback rb
;
7573 ID3D10Texture2D
*texture
;
7574 ID3D10Device
*device
;
7581 static const DWORD ps_color_code
[] =
7584 float4
main(float4 position
: SV_POSITION
) : SV_Target
7586 return float4(0.0, 1.0, 0.0, 1.0);
7589 0x43425844, 0x30240e72, 0x012f250c, 0x8673c6ea, 0x392e4cec, 0x00000001, 0x000000d4, 0x00000003,
7590 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
7591 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
7592 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
7593 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000038, 0x00000040,
7594 0x0000000e, 0x03000065, 0x001020f2, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002,
7595 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e,
7597 static const DWORD ps_depth_code
[] =
7602 float main() : SV_Depth
7607 0x43425844, 0x91af6cd0, 0x7e884502, 0xcede4f54, 0x6f2c9326, 0x00000001, 0x000000b0, 0x00000003,
7608 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
7609 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff,
7610 0x00000e01, 0x445f5653, 0x68747065, 0xababab00, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
7611 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x02000065, 0x0000c001, 0x05000036, 0x0000c001,
7612 0x0020800a, 0x00000000, 0x00000000, 0x0100003e,
7615 if (!init_test_context(&test_context
))
7618 device
= test_context
.device
;
7620 cb
= create_buffer(device
, D3D10_BIND_CONSTANT_BUFFER
, sizeof(depth
), NULL
);
7622 texture_desc
.Width
= 640;
7623 texture_desc
.Height
= 480;
7624 texture_desc
.MipLevels
= 1;
7625 texture_desc
.ArraySize
= 1;
7626 texture_desc
.Format
= DXGI_FORMAT_D32_FLOAT
;
7627 texture_desc
.SampleDesc
.Count
= 1;
7628 texture_desc
.SampleDesc
.Quality
= 0;
7629 texture_desc
.Usage
= D3D10_USAGE_DEFAULT
;
7630 texture_desc
.BindFlags
= D3D10_BIND_DEPTH_STENCIL
;
7631 texture_desc
.CPUAccessFlags
= 0;
7632 texture_desc
.MiscFlags
= 0;
7634 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
7635 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
7637 hr
= ID3D10Device_CreateDepthStencilView(device
, (ID3D10Resource
*)texture
, NULL
, &dsv
);
7638 ok(SUCCEEDED(hr
), "Failed to create depth stencil view, hr %#x.\n", hr
);
7640 depth_stencil_desc
.DepthEnable
= TRUE
;
7641 depth_stencil_desc
.DepthWriteMask
= D3D10_DEPTH_WRITE_MASK_ALL
;
7642 depth_stencil_desc
.DepthFunc
= D3D10_COMPARISON_LESS
;
7643 depth_stencil_desc
.StencilEnable
= FALSE
;
7645 hr
= ID3D10Device_CreateDepthStencilState(device
, &depth_stencil_desc
, &depth_stencil_state
);
7646 ok(SUCCEEDED(hr
), "Failed to create depth stencil state, hr %#x.\n", hr
);
7648 hr
= ID3D10Device_CreatePixelShader(device
, ps_color_code
, sizeof(ps_color_code
), &ps_color
);
7649 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
7650 hr
= ID3D10Device_CreatePixelShader(device
, ps_depth_code
, sizeof(ps_depth_code
), &ps_depth
);
7651 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
7653 ID3D10Device_PSSetConstantBuffers(device
, 0, 1, &cb
);
7654 ID3D10Device_PSSetShader(device
, ps_color
);
7655 ID3D10Device_OMSetRenderTargets(device
, 0, NULL
, dsv
);
7656 ID3D10Device_OMSetDepthStencilState(device
, depth_stencil_state
, 0);
7658 ID3D10Device_ClearDepthStencilView(device
, dsv
, D3D10_CLEAR_DEPTH
, 1.0f
, 0);
7659 check_texture_float(texture
, 1.0f
, 1);
7660 draw_quad(&test_context
);
7661 check_texture_float(texture
, 0.0f
, 1);
7663 ID3D10Device_PSSetShader(device
, ps_depth
);
7666 ID3D10Device_UpdateSubresource(device
, (ID3D10Resource
*)cb
, 0, NULL
, &depth
, 0, 0);
7667 draw_quad(&test_context
);
7668 check_texture_float(texture
, 0.0f
, 1);
7669 ID3D10Device_ClearDepthStencilView(device
, dsv
, D3D10_CLEAR_DEPTH
, 1.0f
, 0);
7670 check_texture_float(texture
, 1.0f
, 1);
7671 draw_quad(&test_context
);
7672 check_texture_float(texture
, 0.7f
, 1);
7674 ID3D10Device_UpdateSubresource(device
, (ID3D10Resource
*)cb
, 0, NULL
, &depth
, 0, 0);
7675 draw_quad(&test_context
);
7676 check_texture_float(texture
, 0.7f
, 1);
7678 ID3D10Device_UpdateSubresource(device
, (ID3D10Resource
*)cb
, 0, NULL
, &depth
, 0, 0);
7679 draw_quad(&test_context
);
7680 check_texture_float(texture
, 0.5f
, 1);
7682 ID3D10Device_ClearDepthStencilView(device
, dsv
, D3D10_CLEAR_DEPTH
, 1.0f
, 0);
7684 for (i
= 0; i
< 4; ++i
)
7686 for (j
= 0; j
< 4; ++j
)
7688 depth
.x
= 1.0f
/ 16.0f
* (j
+ 4 * i
);
7689 ID3D10Device_UpdateSubresource(device
, (ID3D10Resource
*)cb
, 0, NULL
, &depth
, 0, 0);
7691 vp
.TopLeftX
= 160 * j
;
7692 vp
.TopLeftY
= 120 * i
;
7697 ID3D10Device_RSSetViewports(device
, 1, &vp
);
7699 draw_quad(&test_context
);
7702 get_texture_readback(texture
, 0, &rb
);
7703 for (i
= 0; i
< 4; ++i
)
7705 for (j
= 0; j
< 4; ++j
)
7707 float obtained_depth
, expected_depth
;
7709 obtained_depth
= get_readback_float(&rb
, 80 + j
* 160, 60 + i
* 120);
7710 expected_depth
= 1.0f
/ 16.0f
* (j
+ 4 * i
);
7711 ok(compare_float(obtained_depth
, expected_depth
, 1),
7712 "Got unexpected depth %.8e at (%u, %u), expected %.8e.\n",
7713 obtained_depth
, j
, i
, expected_depth
);
7716 release_texture_readback(&rb
);
7718 ID3D10Buffer_Release(cb
);
7719 ID3D10PixelShader_Release(ps_color
);
7720 ID3D10PixelShader_Release(ps_depth
);
7721 ID3D10DepthStencilView_Release(dsv
);
7722 ID3D10DepthStencilState_Release(depth_stencil_state
);
7723 ID3D10Texture2D_Release(texture
);
7724 release_test_context(&test_context
);
7727 static void test_shader_stage_input_output_matching(void)
7729 struct d3d10core_test_context test_context
;
7730 D3D10_TEXTURE2D_DESC texture_desc
;
7731 ID3D10Texture2D
*render_target
;
7732 ID3D10RenderTargetView
*rtv
[2];
7733 ID3D10VertexShader
*vs
;
7734 ID3D10PixelShader
*ps
;
7735 ID3D10Device
*device
;
7738 static const DWORD vs_code
[] =
7743 float4 position
: SV_PoSiTion
;
7744 float4 color0
: COLOR0
;
7745 float4 color1
: COLOR1
;
7748 void main(uint id
: SV_VertexID
, out output o
)
7750 float2 coords
= float2((id
<< 1) & 2, id
& 2);
7751 o
.position
= float4(coords
* float2(2, -2) + float2(-1, 1), 0, 1);
7752 o
.color0
= float4(1.0f
, 0.0f
, 0.0f
, 1.0f
);
7753 o
.color1
= float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
7756 0x43425844, 0x93c216a1, 0xbaa7e8d4, 0xd5368c6a, 0x4e889e07, 0x00000001, 0x00000224, 0x00000003,
7757 0x0000002c, 0x00000060, 0x000000cc, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
7758 0x00000000, 0x00000006, 0x00000001, 0x00000000, 0x00000101, 0x565f5653, 0x65747265, 0x00444978,
7759 0x4e47534f, 0x00000064, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003,
7760 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
7761 0x0000005c, 0x00000001, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x505f5653, 0x5469536f,
7762 0x006e6f69, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000150, 0x00010040, 0x00000054, 0x04000060,
7763 0x00101012, 0x00000000, 0x00000006, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065,
7764 0x001020f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068, 0x00000001, 0x07000029,
7765 0x00100012, 0x00000000, 0x0010100a, 0x00000000, 0x00004001, 0x00000001, 0x07000001, 0x00100012,
7766 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000002, 0x07000001, 0x00100042, 0x00000000,
7767 0x0010100a, 0x00000000, 0x00004001, 0x00000002, 0x05000056, 0x00100032, 0x00000000, 0x00100086,
7768 0x00000000, 0x0f000032, 0x00102032, 0x00000000, 0x00100046, 0x00000000, 0x00004002, 0x40000000,
7769 0xc0000000, 0x00000000, 0x00000000, 0x00004002, 0xbf800000, 0x3f800000, 0x00000000, 0x00000000,
7770 0x08000036, 0x001020c2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x3f800000,
7771 0x08000036, 0x001020f2, 0x00000001, 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000,
7772 0x08000036, 0x001020f2, 0x00000002, 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x3f800000,
7775 static const DWORD ps_code
[] =
7780 float4 position
: SV_PoSiTiOn
;
7781 float4 color1
: COLOR1
;
7782 float4 color0
: COLOR0
;
7787 float4 target0
: SV_Target0
;
7788 float4 target1
: SV_Target1
;
7791 void main(const in input i
, out output o
)
7793 o
.target0
= i
.color0
;
7794 o
.target1
= i
.color1
;
7797 0x43425844, 0x620ef963, 0xed8f19fe, 0x7b3a0a53, 0x126ce021, 0x00000001, 0x00000150, 0x00000003,
7798 0x0000002c, 0x00000098, 0x000000e4, 0x4e475349, 0x00000064, 0x00000003, 0x00000008, 0x00000050,
7799 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000001, 0x00000000,
7800 0x00000003, 0x00000001, 0x00000f0f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000002,
7801 0x00000f0f, 0x505f5653, 0x5469536f, 0x006e4f69, 0x4f4c4f43, 0xabab0052, 0x4e47534f, 0x00000044,
7802 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f,
7803 0x00000038, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x545f5653, 0x65677261,
7804 0xabab0074, 0x52444853, 0x00000064, 0x00000040, 0x00000019, 0x03001062, 0x001010f2, 0x00000001,
7805 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x001020f2,
7806 0x00000001, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000002, 0x05000036, 0x001020f2,
7807 0x00000001, 0x00101e46, 0x00000001, 0x0100003e,
7810 if (!init_test_context(&test_context
))
7813 device
= test_context
.device
;
7815 hr
= ID3D10Device_CreateVertexShader(device
, vs_code
, sizeof(vs_code
), &vs
);
7816 ok(SUCCEEDED(hr
), "Failed to create vertex shader, hr %#x.\n", hr
);
7817 hr
= ID3D10Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), &ps
);
7818 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
7820 ID3D10Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
7821 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &render_target
);
7822 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
7824 rtv
[0] = test_context
.backbuffer_rtv
;
7825 hr
= ID3D10Device_CreateRenderTargetView(device
, (ID3D10Resource
*)render_target
, NULL
, &rtv
[1]);
7826 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
7828 ID3D10Device_VSSetShader(device
, vs
);
7829 ID3D10Device_PSSetShader(device
, ps
);
7830 ID3D10Device_IASetPrimitiveTopology(device
, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST
);
7831 ID3D10Device_OMSetRenderTargets(device
, 2, rtv
, NULL
);
7832 ID3D10Device_Draw(device
, 3, 0);
7834 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
7835 check_texture_color(render_target
, 0xff0000ff, 0);
7837 ID3D10RenderTargetView_Release(rtv
[1]);
7838 ID3D10Texture2D_Release(render_target
);
7839 ID3D10PixelShader_Release(ps
);
7840 ID3D10VertexShader_Release(vs
);
7841 release_test_context(&test_context
);
7844 static void test_sm4_if_instruction(void)
7846 struct d3d10core_test_context test_context
;
7847 ID3D10PixelShader
*ps_if_nz
, *ps_if_z
;
7848 ID3D10Device
*device
;
7849 unsigned int bits
[4];
7850 DWORD expected_color
;
7855 static const DWORD ps_if_nz_code
[] =
7860 float4
main() : SV_TARGET
7863 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
7865 return float4(1.0f
, 0.0f
, 0.0f
, 1.0f
);
7868 0x43425844, 0x2a94f6f1, 0xdbe88943, 0x3426a708, 0x09cec990, 0x00000001, 0x00000100, 0x00000003,
7869 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
7870 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
7871 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000088, 0x00000040, 0x00000022,
7872 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x0404001f,
7873 0x0020800a, 0x00000000, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000,
7874 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000012, 0x08000036, 0x001020f2, 0x00000000,
7875 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000015, 0x0100003e,
7877 static const DWORD ps_if_z_code
[] =
7882 float4
main() : SV_TARGET
7885 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
7887 return float4(1.0f
, 0.0f
, 0.0f
, 1.0f
);
7890 0x43425844, 0x2e3030ca, 0x94c8610c, 0xdf0c1b1f, 0x80f2ca2c, 0x00000001, 0x00000100, 0x00000003,
7891 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
7892 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
7893 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000088, 0x00000040, 0x00000022,
7894 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x0400001f,
7895 0x0020800a, 0x00000000, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000,
7896 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000012, 0x08000036, 0x001020f2, 0x00000000,
7897 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000015, 0x0100003e,
7899 static unsigned int bit_patterns
[] =
7901 0x00000000, 0x00000001, 0x10010001, 0x10000000, 0x80000000, 0xffff0000, 0x0000ffff, 0xffffffff,
7904 if (!init_test_context(&test_context
))
7907 device
= test_context
.device
;
7909 hr
= ID3D10Device_CreatePixelShader(device
, ps_if_nz_code
, sizeof(ps_if_nz_code
), &ps_if_nz
);
7910 ok(SUCCEEDED(hr
), "Failed to create if_nz pixel shader, hr %#x.\n", hr
);
7911 hr
= ID3D10Device_CreatePixelShader(device
, ps_if_z_code
, sizeof(ps_if_z_code
), &ps_if_z
);
7912 ok(SUCCEEDED(hr
), "Failed to create if_z pixel shader, hr %#x.\n", hr
);
7914 cb
= create_buffer(device
, D3D10_BIND_CONSTANT_BUFFER
, sizeof(bits
), NULL
);
7915 ID3D10Device_PSSetConstantBuffers(device
, 0, 1, &cb
);
7917 for (i
= 0; i
< sizeof(bit_patterns
) / sizeof(*bit_patterns
); ++i
)
7919 *bits
= bit_patterns
[i
];
7920 ID3D10Device_UpdateSubresource(device
, (ID3D10Resource
*)cb
, 0, NULL
, bits
, 0, 0);
7922 ID3D10Device_PSSetShader(device
, ps_if_nz
);
7923 expected_color
= *bits
? 0xff00ff00 : 0xff0000ff;
7924 draw_quad(&test_context
);
7925 check_texture_color(test_context
.backbuffer
, expected_color
, 0);
7927 ID3D10Device_PSSetShader(device
, ps_if_z
);
7928 expected_color
= *bits
? 0xff0000ff : 0xff00ff00;
7929 draw_quad(&test_context
);
7930 check_texture_color(test_context
.backbuffer
, expected_color
, 0);
7933 ID3D10Buffer_Release(cb
);
7934 ID3D10PixelShader_Release(ps_if_z
);
7935 ID3D10PixelShader_Release(ps_if_nz
);
7936 release_test_context(&test_context
);
7939 static void test_sm4_breakc_instruction(void)
7941 struct d3d10core_test_context test_context
;
7942 ID3D10PixelShader
*ps
;
7943 ID3D10Device
*device
;
7946 static const DWORD ps_breakc_nz_code
[] =
7949 float4
main() : SV_TARGET
7953 for (uint i
= 0; i
< 255; ++i
)
7957 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
7959 return float4(1.0f
, 0.0f
, 0.0f
, 1.0f
);
7962 0x43425844, 0x065ac80a, 0x24369e7e, 0x218d5dc1, 0x3532868c, 0x00000001, 0x00000188, 0x00000003,
7963 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
7964 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
7965 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000110, 0x00000040, 0x00000044,
7966 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x08000036, 0x00100032, 0x00000000,
7967 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01000030, 0x07000050, 0x00100042,
7968 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0x000000ff, 0x03040003, 0x0010002a, 0x00000000,
7969 0x0a00001e, 0x00100032, 0x00000000, 0x00100046, 0x00000000, 0x00004002, 0x00000001, 0x00000001,
7970 0x00000000, 0x00000000, 0x01000016, 0x07000020, 0x00100012, 0x00000000, 0x0010000a, 0x00000000,
7971 0x00004001, 0x000000ff, 0x0304001f, 0x0010000a, 0x00000000, 0x08000036, 0x001020f2, 0x00000000,
7972 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000012, 0x08000036,
7973 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e,
7974 0x01000015, 0x0100003e,
7976 static const DWORD ps_breakc_z_code
[] =
7979 float4
main() : SV_TARGET
7983 for (int i
= 0, j
= 254; i
< 255 && j
>= 0; ++i
, --j
)
7987 return float4(0.0f
, 1.0f
, 0.0f
, 1.0f
);
7989 return float4(1.0f
, 0.0f
, 0.0f
, 1.0f
);
7992 0x43425844, 0x687406ef, 0x7bdeb7d1, 0xb3282292, 0x934a9101, 0x00000001, 0x000001c0, 0x00000003,
7993 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
7994 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
7995 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000148, 0x00000040, 0x00000052,
7996 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x08000036, 0x00100072, 0x00000000,
7997 0x00004002, 0x00000000, 0x00000000, 0x000000fe, 0x00000000, 0x01000030, 0x07000022, 0x00100082,
7998 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0x000000ff, 0x07000021, 0x00100012, 0x00000001,
7999 0x0010002a, 0x00000000, 0x00004001, 0x00000000, 0x07000001, 0x00100082, 0x00000000, 0x0010003a,
8000 0x00000000, 0x0010000a, 0x00000001, 0x03000003, 0x0010003a, 0x00000000, 0x0a00001e, 0x00100072,
8001 0x00000000, 0x00100246, 0x00000000, 0x00004002, 0x00000001, 0x00000001, 0xffffffff, 0x00000000,
8002 0x01000016, 0x07000020, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x000000ff,
8003 0x0304001f, 0x0010000a, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000,
8004 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000012, 0x08000036, 0x001020f2, 0x00000000,
8005 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000015, 0x0100003e,
8008 if (!init_test_context(&test_context
))
8011 device
= test_context
.device
;
8013 hr
= ID3D10Device_CreatePixelShader(device
, ps_breakc_nz_code
, sizeof(ps_breakc_nz_code
), &ps
);
8014 ok(SUCCEEDED(hr
), "Failed to create breakc_nz pixel shader, hr %#x.\n", hr
);
8015 ID3D10Device_PSSetShader(device
, ps
);
8016 draw_quad(&test_context
);
8017 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
8018 ID3D10PixelShader_Release(ps
);
8020 hr
= ID3D10Device_CreatePixelShader(device
, ps_breakc_z_code
, sizeof(ps_breakc_z_code
), &ps
);
8021 ok(SUCCEEDED(hr
), "Failed to create breakc_z pixel shader, hr %#x.\n", hr
);
8022 ID3D10Device_PSSetShader(device
, ps
);
8023 draw_quad(&test_context
);
8024 check_texture_color(test_context
.backbuffer
, 0xff00ff00, 0);
8025 ID3D10PixelShader_Release(ps
);
8027 release_test_context(&test_context
);
8030 static void test_create_input_layout(void)
8032 D3D10_INPUT_ELEMENT_DESC layout_desc
[] =
8034 {"POSITION", 0, DXGI_FORMAT_UNKNOWN
, 0, 0, D3D10_INPUT_PER_VERTEX_DATA
, 0},
8036 ID3D10InputLayout
*input_layout
;
8037 ID3D10Device
*device
;
8042 static const DWORD vs_code
[] =
8045 float4
main(float4 position
: POSITION
) : SV_POSITION
8050 0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003,
8051 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
8052 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
8053 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
8054 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
8055 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
8056 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
8058 static const DXGI_FORMAT vertex_formats
[] =
8060 DXGI_FORMAT_R32G32_FLOAT
,
8061 DXGI_FORMAT_R32G32_UINT
,
8062 DXGI_FORMAT_R32G32_SINT
,
8063 DXGI_FORMAT_R16G16_FLOAT
,
8064 DXGI_FORMAT_R16G16_UINT
,
8065 DXGI_FORMAT_R16G16_SINT
,
8066 DXGI_FORMAT_R32_FLOAT
,
8067 DXGI_FORMAT_R32_UINT
,
8068 DXGI_FORMAT_R32_SINT
,
8069 DXGI_FORMAT_R16_UINT
,
8070 DXGI_FORMAT_R16_SINT
,
8071 DXGI_FORMAT_R8_UINT
,
8072 DXGI_FORMAT_R8_SINT
,
8075 if (!(device
= create_device()))
8077 skip("Failed to create device.\n");
8081 for (i
= 0; i
< sizeof(vertex_formats
) / sizeof(*vertex_formats
); ++i
)
8083 layout_desc
->Format
= vertex_formats
[i
];
8084 hr
= ID3D10Device_CreateInputLayout(device
, layout_desc
,
8085 sizeof(layout_desc
) / sizeof(*layout_desc
), vs_code
, sizeof(vs_code
),
8087 ok(SUCCEEDED(hr
), "Failed to create input layout for format %#x, hr %#x.\n",
8088 vertex_formats
[i
], hr
);
8089 ID3D10InputLayout_Release(input_layout
);
8092 refcount
= ID3D10Device_Release(device
);
8093 ok(!refcount
, "Device has %u references left.\n", refcount
);
8096 static void test_input_assembler(void)
8113 D3D10_INPUT_ELEMENT_DESC input_layout_desc
[] =
8115 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT
, 0, 0, D3D10_INPUT_PER_VERTEX_DATA
, 0},
8116 {"ATTRIBUTE", 0, DXGI_FORMAT_UNKNOWN
, 1, 0, D3D10_INPUT_PER_VERTEX_DATA
, 0},
8118 ID3D10VertexShader
*vs_float
, *vs_uint
, *vs_sint
;
8119 ID3D10InputLayout
*input_layout
[LAYOUT_COUNT
];
8120 struct d3d10core_test_context test_context
;
8121 ID3D10Buffer
*vb_position
, *vb_attribute
;
8122 unsigned int i
, x
, y
, max_data_size
;
8123 D3D10_TEXTURE2D_DESC texture_desc
;
8124 ID3D10Texture2D
*render_target
;
8125 ID3D10RenderTargetView
*rtv
;
8126 struct texture_readback rb
;
8127 ID3D10PixelShader
*ps
;
8128 ID3D10Device
*device
;
8129 UINT stride
, offset
;
8132 static const DXGI_FORMAT layout_formats
[LAYOUT_COUNT
] =
8134 DXGI_FORMAT_R32G32B32A32_FLOAT
,
8135 DXGI_FORMAT_R16G16B16A16_UINT
,
8136 DXGI_FORMAT_R16G16B16A16_SINT
,
8137 DXGI_FORMAT_R16G16B16A16_UNORM
,
8138 DXGI_FORMAT_R16G16B16A16_SNORM
,
8139 DXGI_FORMAT_R8G8B8A8_UINT
,
8140 DXGI_FORMAT_R8G8B8A8_SINT
,
8141 DXGI_FORMAT_R8G8B8A8_UNORM
,
8142 DXGI_FORMAT_R8G8B8A8_SNORM
,
8146 struct vec2 position
;
8155 static const DWORD ps_code
[] =
8158 float4
main(float4 position
: POSITION
, float4 color
: COLOR
) : SV_Target
8163 0x43425844, 0xa9150342, 0x70e18d2e, 0xf7769835, 0x4c3a7f02, 0x00000001, 0x000000f0, 0x00000003,
8164 0x0000002c, 0x0000007c, 0x000000b0, 0x4e475349, 0x00000048, 0x00000002, 0x00000008, 0x00000038,
8165 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x00000041, 0x00000000, 0x00000000,
8166 0x00000003, 0x00000001, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x4e47534f,
8167 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
8168 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
8169 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036, 0x001020f2,
8170 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
8172 static const DWORD vs_float_code
[] =
8177 float4 position
: SV_Position
;
8178 float4 color
: COLOR
;
8181 void main(float4 position
: POSITION
, float4 color
: ATTRIBUTE
, out output o
)
8183 o
.position
= position
;
8187 0x43425844, 0xf6051ffd, 0xd9e49503, 0x171ad197, 0x3764fe47, 0x00000001, 0x00000144, 0x00000003,
8188 0x0000002c, 0x00000080, 0x000000d4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
8189 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
8190 0x00000003, 0x00000001, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x54544100, 0x55424952, 0xab004554,
8191 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
8192 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
8193 0x505f5653, 0x7469736f, 0x006e6f69, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000068, 0x00010040,
8194 0x0000001a, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067,
8195 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2,
8196 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001,
8199 static const DWORD vs_uint_code
[] =
8204 float4 position
: SV_Position
;
8205 float4 color
: COLOR
;
8208 void main(float4 position
: POSITION
, uint4 color
: ATTRIBUTE
, out output o
)
8210 o
.position
= position
;
8214 0x43425844, 0x0bae0bc0, 0xf6473aa5, 0x4ecf4a25, 0x414fac23, 0x00000001, 0x00000144, 0x00000003,
8215 0x0000002c, 0x00000080, 0x000000d4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
8216 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
8217 0x00000001, 0x00000001, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x54544100, 0x55424952, 0xab004554,
8218 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
8219 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
8220 0x505f5653, 0x7469736f, 0x006e6f69, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000068, 0x00010040,
8221 0x0000001a, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067,
8222 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2,
8223 0x00000000, 0x00101e46, 0x00000000, 0x05000056, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001,
8226 static const DWORD vs_sint_code
[] =
8231 float4 position
: SV_Position
;
8232 float4 color
: COLOR
;
8235 void main(float4 position
: POSITION
, int4 color
: ATTRIBUTE
, out output o
)
8237 o
.position
= position
;
8241 0x43425844, 0xaf60aad9, 0xba91f3a4, 0x2015d384, 0xf746fdf5, 0x00000001, 0x00000144, 0x00000003,
8242 0x0000002c, 0x00000080, 0x000000d4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
8243 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
8244 0x00000002, 0x00000001, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x54544100, 0x55424952, 0xab004554,
8245 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003,
8246 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
8247 0x505f5653, 0x7469736f, 0x006e6f69, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000068, 0x00010040,
8248 0x0000001a, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067,
8249 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2,
8250 0x00000000, 0x00101e46, 0x00000000, 0x0500002b, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001,
8253 static const float float32_data
[] =
8255 1.0f
, 2.0f
, 3.0f
, 4.0f
, 1.0f
, 2.0f
, 3.0f
, 4.0f
, 1.0f
, 2.0f
, 3.0f
, 4.0f
, 1.0f
, 2.0f
, 3.0f
, 4.0f
,
8257 static const unsigned short uint16_data
[] =
8259 6, 8, 55, 777, 6, 8, 55, 777, 6, 8, 55, 777, 6, 8, 55, 777,
8261 static const short sint16_data
[] =
8263 -1, 33, 8, -77, -1, 33, 8, -77, -1, 33, 8, -77, -1, 33, 8, -77,
8265 static const unsigned short unorm16_data
[] =
8267 0, 16383, 32767, 65535, 0, 16383, 32767, 65535, 0, 16383, 32767, 65535, 0, 16383, 32767, 65535,
8269 static const short snorm16_data
[] =
8271 -32768, 0, 32767, 0, -32768, 0, 32767, 0, -32768, 0, 32767, 0, -32768, 0, 32767, 0,
8273 static const unsigned char uint8_data
[] =
8275 0, 64, 128, 255, 0, 64, 128, 255, 0, 64, 128, 255, 0, 64, 128, 255,
8277 static const signed char sint8_data
[] =
8279 -128, 0, 127, 64, -128, 0, 127, 64, -128, 0, 127, 64, -128, 0, 127, 64,
8283 enum layout_id layout_id
;
8284 unsigned int stride
;
8285 unsigned int data_size
;
8287 struct vec4 expected_color
;
8292 {LAYOUT_FLOAT32
, 4 * sizeof(*float32_data
), sizeof(float32_data
), float32_data
,
8293 {1.0f
, 2.0f
, 3.0f
, 4.0f
}},
8294 {LAYOUT_UINT16
, 4 * sizeof(*uint16_data
), sizeof(uint16_data
), uint16_data
,
8295 {6.0f
, 8.0f
, 55.0f
, 777.0f
}, TRUE
},
8296 {LAYOUT_SINT16
, 4 * sizeof(*sint16_data
), sizeof(sint16_data
), sint16_data
,
8297 {-1.0f
, 33.0f
, 8.0f
, -77.0f
}, TRUE
},
8298 {LAYOUT_UNORM16
, 4 * sizeof(*unorm16_data
), sizeof(unorm16_data
), unorm16_data
,
8299 {0.0f
, 16383.0f
/ 65535.0f
, 32767.0f
/ 65535.0f
, 1.0f
}},
8300 {LAYOUT_SNORM16
, 4 * sizeof(*snorm16_data
), sizeof(snorm16_data
), snorm16_data
,
8301 {-1.0f
, 0.0f
, 1.0f
, 0.0f
}},
8302 {LAYOUT_UINT8
, 4 * sizeof(*uint8_data
), sizeof(uint8_data
), uint8_data
,
8303 {0.0f
, 64.0f
, 128.0f
, 255.0f
}},
8304 {LAYOUT_SINT8
, 4 * sizeof(*sint8_data
), sizeof(sint8_data
), sint8_data
,
8305 {-128.0f
, 0.0f
, 127.0f
, 64.0f
}},
8306 {LAYOUT_UNORM8
, 4 * sizeof(*uint8_data
), sizeof(uint8_data
), uint8_data
,
8307 {0.0f
, 64.0f
/ 255.0f
, 128.0f
/ 255.0f
, 1.0f
}},
8308 {LAYOUT_SNORM8
, 4 * sizeof(*sint8_data
), sizeof(sint8_data
), sint8_data
,
8309 {-1.0f
, 0.0f
, 1.0f
, 64.0f
/ 127.0f
}},
8312 if (!init_test_context(&test_context
))
8315 device
= test_context
.device
;
8317 hr
= ID3D10Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), &ps
);
8318 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
8320 hr
= ID3D10Device_CreateVertexShader(device
, vs_float_code
, sizeof(vs_float_code
), &vs_float
);
8321 ok(SUCCEEDED(hr
), "Failed to create float vertex shader, hr %#x.\n", hr
);
8322 hr
= ID3D10Device_CreateVertexShader(device
, vs_uint_code
, sizeof(vs_uint_code
), &vs_uint
);
8323 ok(SUCCEEDED(hr
), "Failed to create uint vertex shader, hr %#x.\n", hr
);
8324 hr
= ID3D10Device_CreateVertexShader(device
, vs_sint_code
, sizeof(vs_sint_code
), &vs_sint
);
8325 ok(SUCCEEDED(hr
), "Failed to create sint vertex shader, hr %#x.\n", hr
);
8327 for (i
= 0; i
< LAYOUT_COUNT
; ++i
)
8329 input_layout_desc
[1].Format
= layout_formats
[i
];
8330 hr
= ID3D10Device_CreateInputLayout(device
, input_layout_desc
,
8331 sizeof(input_layout_desc
) / sizeof(*input_layout_desc
),
8332 vs_float_code
, sizeof(vs_float_code
), &input_layout
[i
]);
8333 ok(SUCCEEDED(hr
), "Failed to create input layout for format %#x, hr %#x.\n", layout_formats
[i
], hr
);
8337 for (i
= 0; i
< sizeof(tests
) / sizeof(*tests
); ++i
)
8339 if (tests
[i
].data_size
> max_data_size
)
8340 max_data_size
= tests
[i
].data_size
;
8343 vb_position
= create_buffer(device
, D3D10_BIND_VERTEX_BUFFER
, sizeof(quad
), quad
);
8344 vb_attribute
= create_buffer(device
, D3D10_BIND_VERTEX_BUFFER
, max_data_size
, NULL
);
8346 texture_desc
.Width
= 640;
8347 texture_desc
.Height
= 480;
8348 texture_desc
.MipLevels
= 1;
8349 texture_desc
.ArraySize
= 1;
8350 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
8351 texture_desc
.SampleDesc
.Count
= 1;
8352 texture_desc
.SampleDesc
.Quality
= 0;
8353 texture_desc
.Usage
= D3D10_USAGE_DEFAULT
;
8354 texture_desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
;
8355 texture_desc
.CPUAccessFlags
= 0;
8356 texture_desc
.MiscFlags
= 0;
8358 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &render_target
);
8359 ok(SUCCEEDED(hr
), "Failed to create 2d texture, hr %#x.\n", hr
);
8361 hr
= ID3D10Device_CreateRenderTargetView(device
, (ID3D10Resource
*)render_target
, NULL
, &rtv
);
8362 ok(SUCCEEDED(hr
), "Failed to create rendertarget view, hr %#x.\n", hr
);
8364 ID3D10Device_IASetPrimitiveTopology(device
, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
);
8366 stride
= sizeof(*quad
);
8367 ID3D10Device_IASetVertexBuffers(device
, 0, 1, &vb_position
, &stride
, &offset
);
8368 ID3D10Device_PSSetShader(device
, ps
);
8369 ID3D10Device_OMSetRenderTargets(device
, 1, &rtv
, NULL
);
8371 for (i
= 0; i
< sizeof(tests
) / sizeof(*tests
); ++i
)
8373 D3D10_BOX box
= {0, 0, 0, 1, 1, 1};
8374 const struct vec4
*color
;
8376 assert(tests
[i
].layout_id
< LAYOUT_COUNT
);
8377 ID3D10Device_IASetInputLayout(device
, input_layout
[tests
[i
].layout_id
]);
8379 box
.right
= tests
[i
].data_size
;
8380 ID3D10Device_UpdateSubresource(device
, (ID3D10Resource
*)vb_attribute
, 0,
8381 &box
, tests
[i
].data
, 0, 0);
8383 stride
= tests
[i
].stride
;
8384 ID3D10Device_IASetVertexBuffers(device
, 1, 1, &vb_attribute
, &stride
, &offset
);
8386 switch (layout_formats
[tests
[i
].layout_id
])
8388 case DXGI_FORMAT_R16G16B16A16_UINT
:
8389 case DXGI_FORMAT_R8G8B8A8_UINT
:
8390 ID3D10Device_VSSetShader(device
, vs_uint
);
8392 case DXGI_FORMAT_R16G16B16A16_SINT
:
8393 case DXGI_FORMAT_R8G8B8A8_SINT
:
8394 ID3D10Device_VSSetShader(device
, vs_sint
);
8398 trace("Unhandled format %#x.\n", layout_formats
[tests
[i
].layout_id
]);
8400 case DXGI_FORMAT_R32G32B32A32_FLOAT
:
8401 case DXGI_FORMAT_R16G16B16A16_UNORM
:
8402 case DXGI_FORMAT_R16G16B16A16_SNORM
:
8403 case DXGI_FORMAT_R8G8B8A8_UNORM
:
8404 case DXGI_FORMAT_R8G8B8A8_SNORM
:
8405 ID3D10Device_VSSetShader(device
, vs_float
);
8409 ID3D10Device_Draw(device
, 4, 0);
8411 get_texture_readback(render_target
, 0, &rb
);
8412 for (y
= 0; y
< rb
.height
; ++y
)
8414 for (x
= 0; x
< rb
.width
; ++x
)
8416 color
= get_readback_vec4(&rb
, x
, y
);
8417 ok(compare_vec4(color
, &tests
[i
].expected_color
, 2),
8418 "Test %u: Got unexpected color {%.8e, %.8e, %.8e, %.8e} at (%u, %u).\n",
8419 i
, color
->x
, color
->y
, color
->z
, color
->w
, x
, y
);
8422 release_texture_readback(&rb
);
8425 ID3D10Texture2D_Release(render_target
);
8426 ID3D10RenderTargetView_Release(rtv
);
8427 ID3D10Buffer_Release(vb_attribute
);
8428 ID3D10Buffer_Release(vb_position
);
8429 for (i
= 0; i
< LAYOUT_COUNT
; ++i
)
8430 ID3D10InputLayout_Release(input_layout
[i
]);
8431 ID3D10PixelShader_Release(ps
);
8432 ID3D10VertexShader_Release(vs_float
);
8433 ID3D10VertexShader_Release(vs_uint
);
8434 ID3D10VertexShader_Release(vs_sint
);
8435 release_test_context(&test_context
);
8438 static void test_null_sampler(void)
8440 struct d3d10core_test_context test_context
;
8441 D3D10_TEXTURE2D_DESC texture_desc
;
8442 ID3D10ShaderResourceView
*srv
;
8443 ID3D10RenderTargetView
*rtv
;
8444 ID3D10SamplerState
*sampler
;
8445 ID3D10Texture2D
*texture
;
8446 ID3D10PixelShader
*ps
;
8447 ID3D10Device
*device
;
8450 static const DWORD ps_code
[] =
8456 float4
main(float4 position
: SV_POSITION
) : SV_Target
8458 return t
.Sample(s
, float2(position
.x
/ 640.0f
, position
.y
/ 480.0f
));
8461 0x43425844, 0x1ce9b612, 0xc8176faa, 0xd37844af, 0xdb515605, 0x00000001, 0x00000134, 0x00000003,
8462 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
8463 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
8464 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
8465 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000098, 0x00000040,
8466 0x00000026, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
8467 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
8468 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd,
8469 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
8470 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
8472 static const float blue
[] = {0.0f
, 0.0f
, 1.0f
, 1.0f
};
8474 if (!init_test_context(&test_context
))
8477 device
= test_context
.device
;
8479 hr
= ID3D10Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), &ps
);
8480 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
8482 texture_desc
.Width
= 64;
8483 texture_desc
.Height
= 64;
8484 texture_desc
.MipLevels
= 1;
8485 texture_desc
.ArraySize
= 1;
8486 texture_desc
.Format
= DXGI_FORMAT_R8G8B8A8_UNORM
;
8487 texture_desc
.SampleDesc
.Count
= 1;
8488 texture_desc
.SampleDesc
.Quality
= 0;
8489 texture_desc
.Usage
= D3D10_USAGE_DEFAULT
;
8490 texture_desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
| D3D10_BIND_SHADER_RESOURCE
;
8491 texture_desc
.CPUAccessFlags
= 0;
8492 texture_desc
.MiscFlags
= 0;
8494 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
8495 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
8497 hr
= ID3D10Device_CreateRenderTargetView(device
, (ID3D10Resource
*)texture
, NULL
, &rtv
);
8498 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
8500 hr
= ID3D10Device_CreateShaderResourceView(device
, (ID3D10Resource
*)texture
, NULL
, &srv
);
8501 ok(SUCCEEDED(hr
), "Failed to create shader resource view, hr %#x.\n", hr
);
8503 ID3D10Device_ClearRenderTargetView(device
, rtv
, blue
);
8505 ID3D10Device_PSSetShader(device
, ps
);
8506 ID3D10Device_PSSetShaderResources(device
, 0, 1, &srv
);
8508 ID3D10Device_PSSetSamplers(device
, 0, 1, &sampler
);
8509 draw_quad(&test_context
);
8510 check_texture_color(test_context
.backbuffer
, 0xffff0000, 0);
8512 ID3D10ShaderResourceView_Release(srv
);
8513 ID3D10RenderTargetView_Release(rtv
);
8514 ID3D10Texture2D_Release(texture
);
8515 ID3D10PixelShader_Release(ps
);
8516 release_test_context(&test_context
);
8519 static void test_immediate_constant_buffer(void)
8521 struct d3d10core_test_context test_context
;
8522 D3D10_TEXTURE2D_DESC texture_desc
;
8523 ID3D10RenderTargetView
*rtv
;
8524 unsigned int index
[4] = {0};
8525 ID3D10Texture2D
*texture
;
8526 ID3D10PixelShader
*ps
;
8527 ID3D10Device
*device
;
8532 static const DWORD ps_code
[] =
8537 static const int int_array
[6] =
8539 310, 111, 212, -513, -318, 0,
8542 static const uint uint_array
[6] =
8544 2, 7, 0x7f800000, 0xff800000, 0x7fc00000, 0
8547 static const float float_array
[6] =
8549 76, 83.5f
, 0.5f
, 0.75f
, -0.5f
, 0.0f
,
8552 float4
main() : SV_Target
8554 return float4(int_array
[index
], uint_array
[index
], float_array
[index
], 1.0f
);
8557 0x43425844, 0xbad068da, 0xd631ea3c, 0x41648374, 0x3ccd0120, 0x00000001, 0x00000184, 0x00000003,
8558 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
8559 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
8560 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x0000010c, 0x00000040, 0x00000043,
8561 0x00001835, 0x0000001a, 0x00000136, 0x00000002, 0x42980000, 0x00000000, 0x0000006f, 0x00000007,
8562 0x42a70000, 0x00000000, 0x000000d4, 0x7f800000, 0x3f000000, 0x00000000, 0xfffffdff, 0xff800000,
8563 0x3f400000, 0x00000000, 0xfffffec2, 0x7fc00000, 0xbf000000, 0x00000000, 0x00000000, 0x00000000,
8564 0x00000000, 0x00000000, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2,
8565 0x00000000, 0x02000068, 0x00000001, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x3f800000,
8566 0x06000036, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x06000056, 0x00102022,
8567 0x00000000, 0x0090901a, 0x0010000a, 0x00000000, 0x0600002b, 0x00102012, 0x00000000, 0x0090900a,
8568 0x0010000a, 0x00000000, 0x06000036, 0x00102042, 0x00000000, 0x0090902a, 0x0010000a, 0x00000000,
8571 static struct vec4 expected_result
[] =
8573 { 310.0f
, 2.0f
, 76.00f
, 1.0f
},
8574 { 111.0f
, 7.0f
, 83.50f
, 1.0f
},
8575 { 212.0f
, 2139095040.0f
, 0.50f
, 1.0f
},
8576 {-513.0f
, 4286578688.0f
, 0.75f
, 1.0f
},
8577 {-318.0f
, 2143289344.0f
, -0.50f
, 1.0f
},
8578 { 0.0f
, 0.0f
, 0.0f
, 1.0f
},
8581 if (!init_test_context(&test_context
))
8584 device
= test_context
.device
;
8586 hr
= ID3D10Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), &ps
);
8587 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
8588 ID3D10Device_PSSetShader(device
, ps
);
8590 cb
= create_buffer(device
, D3D10_BIND_CONSTANT_BUFFER
, sizeof(index
), NULL
);
8591 ID3D10Device_PSSetConstantBuffers(device
, 0, 1, &cb
);
8593 ID3D10Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
8594 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
8595 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
8596 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
8598 hr
= ID3D10Device_CreateRenderTargetView(device
, (ID3D10Resource
*)texture
, NULL
, &rtv
);
8599 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
8600 ID3D10Device_OMSetRenderTargets(device
, 1, &rtv
, NULL
);
8602 for (i
= 0; i
< sizeof(expected_result
) / sizeof(*expected_result
); ++i
)
8605 ID3D10Device_UpdateSubresource(device
, (ID3D10Resource
*)cb
, 0, NULL
, index
, 0, 0);
8607 draw_quad(&test_context
);
8608 check_texture_vec4(texture
, &expected_result
[i
], 0);
8611 ID3D10Buffer_Release(cb
);
8612 ID3D10PixelShader_Release(ps
);
8613 ID3D10Texture2D_Release(texture
);
8614 ID3D10RenderTargetView_Release(rtv
);
8615 release_test_context(&test_context
);
8618 static void test_fp_specials(void)
8620 struct d3d10core_test_context test_context
;
8621 D3D10_TEXTURE2D_DESC texture_desc
;
8622 ID3D10RenderTargetView
*rtv
;
8623 struct texture_readback rb
;
8624 ID3D10Texture2D
*texture
;
8625 ID3D10PixelShader
*ps
;
8626 ID3D10Device
*device
;
8630 static const DWORD ps_code
[] =
8633 float4
main() : SV_Target
8635 return float4(0.0f
/ 0.0f
, 1.0f
/ 0.0f
, -1.0f
/ 0.0f
, 1.0f
);
8638 0x43425844, 0x86d7f319, 0x14cde598, 0xe7ce83a8, 0x0e06f3f0, 0x00000001, 0x000000b0, 0x00000003,
8639 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
8640 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
8641 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
8642 0x03000065, 0x001020f2, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0xffc00000,
8643 0x7f800000, 0xff800000, 0x3f800000, 0x0100003e,
8645 const struct uvec4 expected_result
= {0xffc00000, 0x7f800000, 0xff800000, 0x3f800000};
8647 if (!init_test_context(&test_context
))
8650 device
= test_context
.device
;
8652 hr
= ID3D10Device_CreatePixelShader(device
, ps_code
, sizeof(ps_code
), &ps
);
8653 ok(SUCCEEDED(hr
), "Failed to create pixel shader, hr %#x.\n", hr
);
8654 ID3D10Device_PSSetShader(device
, ps
);
8656 ID3D10Texture2D_GetDesc(test_context
.backbuffer
, &texture_desc
);
8657 texture_desc
.Format
= DXGI_FORMAT_R32G32B32A32_FLOAT
;
8658 hr
= ID3D10Device_CreateTexture2D(device
, &texture_desc
, NULL
, &texture
);
8659 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
8661 hr
= ID3D10Device_CreateRenderTargetView(device
, (ID3D10Resource
*)texture
, NULL
, &rtv
);
8662 ok(SUCCEEDED(hr
), "Failed to create render target view, hr %#x.\n", hr
);
8664 ID3D10Device_OMSetRenderTargets(device
, 1, &rtv
, NULL
);
8666 draw_quad(&test_context
);
8667 get_texture_readback(texture
, 0, &rb
);
8668 for (y
= 0; y
< texture_desc
.Height
; ++y
)
8670 for (x
= 0; x
< texture_desc
.Width
; ++x
)
8672 const struct uvec4
*value
= get_readback_uvec4(&rb
, x
, y
);
8673 ok(compare_uvec4(value
, &expected_result
),
8674 "Got unexpected value {0x%08x, 0x%08x, 0x%08x, 0x%08x} at (%u, %u).\n",
8675 value
->x
, value
->y
, value
->z
, value
->w
, x
, y
);
8678 release_texture_readback(&rb
);
8680 ID3D10PixelShader_Release(ps
);
8681 ID3D10Texture2D_Release(texture
);
8682 ID3D10RenderTargetView_Release(rtv
);
8683 release_test_context(&test_context
);
8688 test_feature_level();
8689 test_device_interfaces();
8690 test_create_texture2d();
8691 test_texture2d_interfaces();
8692 test_create_texture3d();
8693 test_buffer_interfaces();
8694 test_create_depthstencil_view();
8695 test_depthstencil_view_interfaces();
8696 test_create_rendertarget_view();
8697 test_render_target_views();
8698 test_create_shader_resource_view();
8699 test_create_shader();
8700 test_create_sampler_state();
8701 test_create_blend_state();
8702 test_create_depthstencil_state();
8703 test_create_rasterizer_state();
8704 test_create_query();
8705 test_timestamp_query();
8706 test_device_removed_reason();
8711 test_multiple_render_targets();
8712 test_private_data();
8713 test_il_append_aligned();
8714 test_fragment_coords();
8715 test_update_subresource();
8716 test_copy_subresource_region();
8717 test_texture_data_init();
8718 test_check_multisample_quality_levels();
8719 test_cb_relative_addressing();
8720 test_swapchain_flip();
8721 test_clear_render_target_view();
8722 test_clear_depth_stencil_view();
8723 test_draw_depth_only();
8724 test_shader_stage_input_output_matching();
8725 test_sm4_if_instruction();
8726 test_sm4_breakc_instruction();
8727 test_create_input_layout();
8728 test_input_assembler();
8729 test_null_sampler();
8730 test_immediate_constant_buffer();