2 * Tests for the D3DX9 texture functions
4 * Copyright 2009 Tony Wasserka
5 * Copyright 2010 Owen Rudge for CodeWeavers
6 * Copyright 2010 Matteo Bruni for CodeWeavers
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/test.h"
26 #include "resources.h"
28 static void test_D3DXCheckTextureRequirements(IDirect3DDevice9
*device
)
30 UINT width
, height
, mipmaps
;
31 D3DFORMAT format
, expected
;
35 D3DDEVICE_CREATION_PARAMETERS params
;
38 IDirect3DDevice9_GetDeviceCaps(device
, &caps
);
41 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
42 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
44 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, D3DX_DEFAULT
, NULL
, D3DPOOL_DEFAULT
);
45 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
47 hr
= D3DXCheckTextureRequirements(NULL
, NULL
, NULL
, NULL
, D3DX_DEFAULT
, NULL
, D3DPOOL_DEFAULT
);
48 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
51 width
= height
= D3DX_DEFAULT
;
52 hr
= D3DXCheckTextureRequirements(device
, &width
, &height
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
53 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
54 ok(width
== 256, "Returned width %d, expected %d\n", width
, 256);
55 ok(height
== 256, "Returned height %d, expected %d\n", height
, 256);
58 hr
= D3DXCheckTextureRequirements(device
, &width
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
59 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
60 ok(width
== 256, "Returned width %d, expected %d\n", width
, 256);
62 if (caps
.TextureCaps
& D3DPTEXTURECAPS_POW2
)
63 skip("Hardware only supports pow2 textures\n");
67 hr
= D3DXCheckTextureRequirements(device
, &width
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
68 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
69 ok(width
== 62, "Returned width %d, expected %d\n", width
, 62);
71 width
= D3DX_DEFAULT
; height
= 63;
72 hr
= D3DXCheckTextureRequirements(device
, &width
, &height
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
73 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
74 ok(width
== height
, "Returned width %d, expected %d\n", width
, height
);
75 ok(height
== 63, "Returned height %d, expected %d\n", height
, 63);
78 width
= D3DX_DEFAULT
; height
= 0;
79 hr
= D3DXCheckTextureRequirements(device
, &width
, &height
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
80 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
81 ok(width
== 1, "Returned width %d, expected %d\n", width
, 1);
82 ok(height
== 1, "Returned height %d, expected %d\n", height
, 1);
84 width
= 0; height
= 0;
85 hr
= D3DXCheckTextureRequirements(device
, &width
, &height
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
86 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
87 ok(width
== 1, "Returned width %d, expected %d\n", width
, 1);
88 ok(height
== 1, "Returned height %d, expected %d\n", height
, 1);
91 hr
= D3DXCheckTextureRequirements(device
, &width
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
92 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
93 ok(width
== 1, "Returned width %d, expected %d\n", width
, 1);
96 hr
= D3DXCheckTextureRequirements(device
, &width
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
97 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
98 ok(width
== caps
.MaxTextureWidth
, "Returned width %d, expected %d\n", width
, caps
.MaxTextureWidth
);
100 width
= caps
.MaxTextureWidth
-1;
101 hr
= D3DXCheckTextureRequirements(device
, &width
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
102 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
103 ok(width
== caps
.MaxTextureWidth
-1, "Returned width %d, expected %d\n", width
, caps
.MaxTextureWidth
-1);
106 width
= 64; height
= 63;
108 hr
= D3DXCheckTextureRequirements(device
, &width
, &height
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
109 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
110 ok(mipmaps
== 7, "Returned mipmaps %d, expected %d\n", mipmaps
, 7);
112 width
= 284; height
= 137;
114 hr
= D3DXCheckTextureRequirements(device
, &width
, &height
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
115 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
116 ok(mipmaps
== 9, "Returned mipmaps %d, expected %d\n", mipmaps
, 9);
120 hr
= D3DXCheckTextureRequirements(device
, &width
, &height
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
121 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
122 ok(mipmaps
== 6, "Returned mipmaps %d, expected %d\n", mipmaps
, 6);
125 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
126 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
127 ok(mipmaps
== 9, "Returned mipmaps %d, expected %d\n", mipmaps
, 9);
130 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
131 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
132 ok(mipmaps
== 9, "Returned mipmaps %d, expected %d\n", mipmaps
, 9);
135 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, D3DUSAGE_WRITEONLY
, NULL
, D3DPOOL_DEFAULT
);
136 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
137 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, D3DUSAGE_DONOTCLIP
, NULL
, D3DPOOL_DEFAULT
);
138 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
139 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, D3DUSAGE_POINTS
, NULL
, D3DPOOL_DEFAULT
);
140 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
141 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, D3DUSAGE_RTPATCHES
, NULL
, D3DPOOL_DEFAULT
);
142 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
143 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, D3DUSAGE_NPATCHES
, NULL
, D3DPOOL_DEFAULT
);
144 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
147 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
148 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
150 format
= D3DFMT_UNKNOWN
;
151 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, 0, &format
, D3DPOOL_DEFAULT
);
152 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
153 ok(format
== D3DFMT_A8R8G8B8
, "Returned format %u, expected %u\n", format
, D3DFMT_A8R8G8B8
);
155 format
= D3DX_DEFAULT
;
156 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, 0, &format
, D3DPOOL_DEFAULT
);
157 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
158 ok(format
== D3DFMT_A8R8G8B8
, "Returned format %u, expected %u\n", format
, D3DFMT_A8R8G8B8
);
160 format
= D3DFMT_R8G8B8
;
161 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, 0, &format
, D3DPOOL_DEFAULT
);
162 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
163 ok(format
== D3DFMT_X8R8G8B8
, "Returned format %u, expected %u\n", format
, D3DFMT_X8R8G8B8
);
165 IDirect3DDevice9_GetDirect3D(device
, &d3d
);
166 IDirect3DDevice9_GetCreationParameters(device
, ¶ms
);
167 IDirect3DDevice9_GetDisplayMode(device
, 0, &mode
);
169 if(SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d
, params
.AdapterOrdinal
, params
.DeviceType
,
170 mode
.Format
, 0, D3DRTYPE_TEXTURE
, D3DFMT_R3G3B2
)))
171 expected
= D3DFMT_R3G3B2
;
173 expected
= D3DFMT_X4R4G4B4
;
175 format
= D3DFMT_R3G3B2
;
176 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, 0, &format
, D3DPOOL_DEFAULT
);
177 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
178 ok(format
== expected
, "Returned format %u, expected %u\n", format
, expected
);
180 if(SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d
, params
.AdapterOrdinal
, params
.DeviceType
,
181 mode
.Format
, 0, D3DRTYPE_TEXTURE
, D3DFMT_A8R3G3B2
)))
182 expected
= D3DFMT_A8R3G3B2
;
184 expected
= D3DFMT_A8R8G8B8
;
186 format
= D3DFMT_A8R3G3B2
;
187 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, 0, &format
, D3DPOOL_DEFAULT
);
188 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
189 ok(format
== expected
, "Returned format %u, expected %u\n", format
, expected
);
191 IDirect3D9_Release(d3d
);
194 static void test_D3DXCheckCubeTextureRequirements(IDirect3DDevice9
*device
)
201 IDirect3DDevice9_GetDeviceCaps(device
, &caps
);
203 if (!(caps
.TextureCaps
& D3DPTEXTURECAPS_CUBEMAP
))
205 skip("No cube textures support\n");
210 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
211 ok(hr
== D3D_OK
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
213 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, NULL
, D3DX_DEFAULT
, NULL
, D3DPOOL_DEFAULT
);
214 ok(hr
== D3D_OK
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
216 hr
= D3DXCheckCubeTextureRequirements(NULL
, NULL
, NULL
, D3DX_DEFAULT
, NULL
, D3DPOOL_DEFAULT
);
217 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
221 hr
= D3DXCheckCubeTextureRequirements(device
, &size
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
222 ok(hr
== D3D_OK
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
223 ok(size
== 256, "Returned size %d, expected %d\n", size
, 256);
228 hr
= D3DXCheckCubeTextureRequirements(device
, &size
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
229 ok(hr
== D3D_OK
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
230 ok(mipmaps
== 7, "Returned mipmaps %d, expected %d\n", mipmaps
, 7);
234 hr
= D3DXCheckCubeTextureRequirements(device
, &size
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
235 ok(hr
== D3D_OK
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
236 ok(mipmaps
== 10, "Returned mipmaps %d, expected %d\n", mipmaps
, 10);
240 hr
= D3DXCheckCubeTextureRequirements(device
, &size
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
241 ok(hr
== D3D_OK
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
242 ok(mipmaps
== 7, "Returned mipmaps %d, expected %d\n", mipmaps
, 7);
245 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
246 ok(hr
== D3D_OK
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
247 ok(mipmaps
== 9, "Returned mipmaps %d, expected %d\n", mipmaps
, 9);
250 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, NULL
, D3DUSAGE_WRITEONLY
, NULL
, D3DPOOL_DEFAULT
);
251 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
252 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, NULL
, D3DUSAGE_DONOTCLIP
, NULL
, D3DPOOL_DEFAULT
);
253 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
254 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, NULL
, D3DUSAGE_POINTS
, NULL
, D3DPOOL_DEFAULT
);
255 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
256 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, NULL
, D3DUSAGE_RTPATCHES
, NULL
, D3DPOOL_DEFAULT
);
257 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
258 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, NULL
, D3DUSAGE_NPATCHES
, NULL
, D3DPOOL_DEFAULT
);
259 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
262 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
263 ok(hr
== D3D_OK
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
265 format
= D3DFMT_UNKNOWN
;
266 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, NULL
, 0, &format
, D3DPOOL_DEFAULT
);
267 ok(hr
== D3D_OK
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
268 ok(format
== D3DFMT_A8R8G8B8
, "Returned format %u, expected %u\n", format
, D3DFMT_A8R8G8B8
);
270 format
= D3DX_DEFAULT
;
271 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, NULL
, 0, &format
, D3DPOOL_DEFAULT
);
272 ok(hr
== D3D_OK
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
273 ok(format
== D3DFMT_A8R8G8B8
, "Returned format %u, expected %u\n", format
, D3DFMT_A8R8G8B8
);
275 format
= D3DFMT_R8G8B8
;
276 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, NULL
, 0, &format
, D3DPOOL_DEFAULT
);
277 ok(hr
== D3D_OK
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
278 ok(format
== D3DFMT_X8R8G8B8
, "Returned format %u, expected %u\n", format
, D3DFMT_X8R8G8B8
);
281 static void test_D3DXCheckVolumeTextureRequirements(IDirect3DDevice9
*device
)
283 UINT width
, height
, depth
, mipmaps
;
288 IDirect3DDevice9_GetDeviceCaps(device
, &caps
);
290 if (!(caps
.TextureCaps
& D3DPTEXTURECAPS_VOLUMEMAP
))
292 skip("No volume textures support\n");
297 hr
= D3DXCheckVolumeTextureRequirements(device
, NULL
, NULL
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
298 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
300 hr
= D3DXCheckVolumeTextureRequirements(device
, NULL
, NULL
, NULL
, NULL
, D3DX_DEFAULT
, NULL
, D3DPOOL_DEFAULT
);
301 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
303 hr
= D3DXCheckVolumeTextureRequirements(NULL
, NULL
, NULL
, NULL
, NULL
, D3DX_DEFAULT
, NULL
, D3DPOOL_DEFAULT
);
304 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
306 /* width, height, depth */
307 width
= height
= depth
= D3DX_DEFAULT
;
308 hr
= D3DXCheckVolumeTextureRequirements(device
, &width
, &height
, &depth
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
309 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
310 ok(width
== 256, "Returned width %d, expected %d\n", width
, 256);
311 ok(height
== 256, "Returned height %d, expected %d\n", height
, 256);
312 ok(depth
== 1, "Returned depth %d, expected %d\n", depth
, 1);
314 width
= D3DX_DEFAULT
;
315 hr
= D3DXCheckVolumeTextureRequirements(device
, &width
, NULL
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
316 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
317 ok(width
== 256, "Returned width %d, expected %d\n", width
, 256);
319 width
= D3DX_DEFAULT
; height
= 0; depth
= 0;
320 hr
= D3DXCheckVolumeTextureRequirements(device
, &width
, &height
, &depth
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
321 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
322 ok(width
== 1, "Returned width %d, expected %d\n", width
, 1);
323 ok(height
== 1, "Returned height %d, expected %d\n", height
, 1);
324 ok(depth
== 1, "Returned height %d, expected %d\n", depth
, 1);
326 width
= 0; height
= 0; depth
= 0;
327 hr
= D3DXCheckVolumeTextureRequirements(device
, &width
, &height
, &depth
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
328 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
329 ok(width
== 1, "Returned width %d, expected %d\n", width
, 1);
330 ok(height
== 1, "Returned height %d, expected %d\n", height
, 1);
331 ok(depth
== 1, "Returned height %d, expected %d\n", depth
, 1);
334 hr
= D3DXCheckVolumeTextureRequirements(device
, &width
, NULL
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
335 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
336 ok(width
== 1, "Returned width %d, expected %d\n", width
, 1);
339 hr
= D3DXCheckVolumeTextureRequirements(device
, &width
, NULL
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
340 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
341 ok(width
== caps
.MaxVolumeExtent
, "Returned width %d, expected %d\n", width
, caps
.MaxVolumeExtent
);
344 hr
= D3DXCheckVolumeTextureRequirements(device
, NULL
, NULL
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
345 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
347 format
= D3DFMT_UNKNOWN
;
348 hr
= D3DXCheckVolumeTextureRequirements(device
, NULL
, NULL
, NULL
, NULL
, 0, &format
, D3DPOOL_DEFAULT
);
349 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
350 ok(format
== D3DFMT_A8R8G8B8
, "Returned format %u, expected %u\n", format
, D3DFMT_A8R8G8B8
);
352 format
= D3DX_DEFAULT
;
353 hr
= D3DXCheckVolumeTextureRequirements(device
, NULL
, NULL
, NULL
, NULL
, 0, &format
, D3DPOOL_DEFAULT
);
354 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
355 ok(format
== D3DFMT_A8R8G8B8
, "Returned format %u, expected %u\n", format
, D3DFMT_A8R8G8B8
);
357 format
= D3DFMT_R8G8B8
;
358 hr
= D3DXCheckVolumeTextureRequirements(device
, NULL
, NULL
, NULL
, NULL
, 0, &format
, D3DPOOL_DEFAULT
);
359 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
360 ok(format
== D3DFMT_X8R8G8B8
, "Returned format %u, expected %u\n", format
, D3DFMT_X8R8G8B8
);
363 if (!(caps
.TextureCaps
& D3DPTEXTURECAPS_MIPVOLUMEMAP
))
365 skip("No volume textures mipmapping support\n");
369 width
= height
= depth
= 64;
371 hr
= D3DXCheckVolumeTextureRequirements(device
, &width
, &height
, &depth
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
372 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
373 ok(mipmaps
== 7, "Returned mipmaps %d, expected %d\n", mipmaps
, 7);
379 hr
= D3DXCheckVolumeTextureRequirements(device
, &width
, &height
, &depth
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
380 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
381 ok(mipmaps
== 10, "Returned mipmaps %d, expected %d\n", mipmaps
, 10);
384 hr
= D3DXCheckVolumeTextureRequirements(device
, NULL
, NULL
, NULL
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
385 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
386 ok(mipmaps
== 9, "Returned mipmaps %d, expected %d\n", mipmaps
, 9);
389 static void test_D3DXCreateTexture(IDirect3DDevice9
*device
)
391 IDirect3DTexture9
*texture
;
392 D3DSURFACE_DESC desc
;
397 IDirect3DDevice9_GetDeviceCaps(device
, &caps
);
399 hr
= D3DXCreateTexture(NULL
, 0, 0, 0, 0, D3DX_DEFAULT
, 0, D3DPOOL_DEFAULT
);
400 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateTexture returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
402 /* width and height tests */
404 hr
= D3DXCreateTexture(device
, D3DX_DEFAULT
, D3DX_DEFAULT
, D3DX_DEFAULT
, 0, 0, D3DPOOL_DEFAULT
, &texture
);
405 ok(hr
== D3D_OK
, "D3DXCreateTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
409 hr
= IDirect3DTexture9_GetLevelDesc(texture
, 0, &desc
);
411 ok(desc
.Width
== 256, "Returned width %d, expected %d\n", desc
.Width
, 256);
412 ok(desc
.Height
== 256, "Returned height %d, expected %d\n", desc
.Height
, 256);
414 IDirect3DTexture9_Release(texture
);
418 hr
= D3DXCreateTexture(device
, 0, 0, 0, 0, 0, D3DPOOL_DEFAULT
, &texture
);
419 ok(hr
== D3D_OK
, "D3DXCreateTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
423 hr
= IDirect3DTexture9_GetLevelDesc(texture
, 0, &desc
);
425 ok(desc
.Width
== 1, "Returned width %d, expected %d\n", desc
.Width
, 1);
426 ok(desc
.Height
== 1, "Returned height %d, expected %d\n", desc
.Height
, 1);
428 IDirect3DTexture9_Release(texture
);
432 if (caps
.TextureCaps
& D3DPTEXTURECAPS_POW2
)
433 skip("Hardware only supports pow2 textures\n");
436 hr
= D3DXCreateTexture(device
, D3DX_DEFAULT
, 63, 0, 0, 0, D3DPOOL_DEFAULT
, &texture
);
438 /* may not work with conditional NPOT */
439 ((hr
!= D3D_OK
) && (caps
.TextureCaps
& D3DPTEXTURECAPS_NONPOW2CONDITIONAL
)),
440 "D3DXCreateTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
444 hr
= IDirect3DTexture9_GetLevelDesc(texture
, 0, &desc
);
446 /* Conditional NPOT may create a texture with different dimensions, so allow those
447 situations instead of returning a fail */
449 ok(desc
.Width
== 63 ||
450 (caps
.TextureCaps
& D3DPTEXTURECAPS_NONPOW2CONDITIONAL
),
451 "Returned width %d, expected %d\n", desc
.Width
, 63);
453 ok(desc
.Height
== 63 ||
454 (caps
.TextureCaps
& D3DPTEXTURECAPS_NONPOW2CONDITIONAL
),
455 "Returned height %d, expected %d\n", desc
.Height
, 63);
457 IDirect3DTexture9_Release(texture
);
463 hr
= D3DXCreateTexture(device
, 64, 63, 9, 0, 0, D3DPOOL_DEFAULT
, &texture
);
464 ok(hr
== D3D_OK
, "D3DXCreateTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
468 mipmaps
= IDirect3DTexture9_GetLevelCount(texture
);
469 ok(mipmaps
== 7, "Returned mipmaps %d, expected %d\n", mipmaps
, 7);
471 IDirect3DTexture9_Release(texture
);
475 hr
= D3DXCreateTexture(device
, 284, 137, 9, 0, 0, D3DPOOL_DEFAULT
, &texture
);
476 ok(hr
== D3D_OK
, "D3DXCreateTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
480 mipmaps
= IDirect3DTexture9_GetLevelCount(texture
);
481 ok(mipmaps
== 9, "Returned mipmaps %d, expected %d\n", mipmaps
, 9);
483 IDirect3DTexture9_Release(texture
);
487 hr
= D3DXCreateTexture(device
, 0, 0, 20, 0, 0, D3DPOOL_DEFAULT
, &texture
);
488 ok(hr
== D3D_OK
, "D3DXCreateTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
492 mipmaps
= IDirect3DTexture9_GetLevelCount(texture
);
493 ok(mipmaps
== 1, "Returned mipmaps %d, expected %d\n", mipmaps
, 1);
495 IDirect3DTexture9_Release(texture
);
499 hr
= D3DXCreateTexture(device
, 64, 64, 1, 0, 0, D3DPOOL_DEFAULT
, &texture
);
500 ok(hr
== D3D_OK
, "D3DXCreateTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
504 mipmaps
= IDirect3DTexture9_GetLevelCount(texture
);
505 ok(mipmaps
== 1, "Returned mipmaps %d, expected %d\n", mipmaps
, 1);
507 IDirect3DTexture9_Release(texture
);
512 hr
= D3DXCreateTexture(device
, 0, 0, 0, D3DUSAGE_WRITEONLY
, 0, D3DPOOL_DEFAULT
, &texture
);
513 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateTexture succeeded, but should have failed.\n");
514 hr
= D3DXCreateTexture(device
, 0, 0, 0, D3DUSAGE_DONOTCLIP
, 0, D3DPOOL_DEFAULT
, &texture
);
515 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateTexture succeeded, but should have failed.\n");
516 hr
= D3DXCreateTexture(device
, 0, 0, 0, D3DUSAGE_POINTS
, 0, D3DPOOL_DEFAULT
, &texture
);
517 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateTexture succeeded, but should have failed.\n");
518 hr
= D3DXCreateTexture(device
, 0, 0, 0, D3DUSAGE_RTPATCHES
, 0, D3DPOOL_DEFAULT
, &texture
);
519 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateTexture succeeded, but should have failed.\n");
520 hr
= D3DXCreateTexture(device
, 0, 0, 0, D3DUSAGE_NPATCHES
, 0, D3DPOOL_DEFAULT
, &texture
);
521 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateTexture succeeded, but should have failed.\n");
525 hr
= D3DXCreateTexture(device
, 0, 0, 0, 0, D3DFMT_UNKNOWN
, D3DPOOL_DEFAULT
, &texture
);
526 ok(hr
== D3D_OK
, "D3DXCreateTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
530 hr
= IDirect3DTexture9_GetLevelDesc(texture
, 0, &desc
);
531 ok(desc
.Format
== D3DFMT_A8R8G8B8
, "Returned format %u, expected %u\n", desc
.Format
, D3DFMT_A8R8G8B8
);
533 IDirect3DTexture9_Release(texture
);
537 hr
= D3DXCreateTexture(device
, 0, 0, 0, 0, 0, D3DPOOL_DEFAULT
, &texture
);
538 ok(hr
== D3D_OK
, "D3DXCreateTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
542 hr
= IDirect3DTexture9_GetLevelDesc(texture
, 0, &desc
);
543 ok(desc
.Format
== D3DFMT_A8R8G8B8
, "Returned format %u, expected %u\n", desc
.Format
, D3DFMT_A8R8G8B8
);
545 IDirect3DTexture9_Release(texture
);
548 /* D3DXCreateTextureFromResource */
550 hr
= D3DXCreateTextureFromResourceA(device
, NULL
, MAKEINTRESOURCEA(IDB_BITMAP_1x1
), &texture
);
551 ok(hr
== D3D_OK
, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr
, D3D_OK
);
552 if (SUCCEEDED(hr
)) IDirect3DTexture9_Release(texture
);
554 hr
= D3DXCreateTextureFromResourceA(device
, NULL
, MAKEINTRESOURCEA(IDD_BITMAPDATA_1x1
), &texture
);
555 ok(hr
== D3D_OK
, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr
, D3D_OK
);
556 if (SUCCEEDED(hr
)) IDirect3DTexture9_Release(texture
);
558 hr
= D3DXCreateTextureFromResourceA(device
, NULL
, MAKEINTRESOURCEA(IDS_STRING
), &texture
);
559 ok(hr
== D3DXERR_INVALIDDATA
, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr
, D3DXERR_INVALIDDATA
);
561 hr
= D3DXCreateTextureFromResourceA(NULL
, NULL
, MAKEINTRESOURCEA(IDD_BITMAPDATA_1x1
), &texture
);
562 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
564 hr
= D3DXCreateTextureFromResourceA(device
, NULL
, NULL
, &texture
);
565 ok(hr
== D3DXERR_INVALIDDATA
, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr
, D3DXERR_INVALIDDATA
);
567 hr
= D3DXCreateTextureFromResourceA(device
, NULL
, MAKEINTRESOURCEA(IDD_BITMAPDATA_1x1
), NULL
);
568 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
571 /* D3DXCreateTextureFromResourceEx */
572 hr
= D3DXCreateTextureFromResourceExA(device
, NULL
, MAKEINTRESOURCEA(IDD_BITMAPDATA_1x1
), D3DX_DEFAULT
, D3DX_DEFAULT
, D3DX_DEFAULT
, 0, D3DFMT_UNKNOWN
, D3DPOOL_MANAGED
, D3DX_DEFAULT
, D3DX_DEFAULT
, 0, NULL
, NULL
, &texture
);
573 ok(hr
== D3D_OK
, "D3DXCreateTextureFromResourceEx returned %#x, expected %#x\n", hr
, D3D_OK
);
574 if (SUCCEEDED(hr
)) IDirect3DTexture9_Release(texture
);
576 hr
= D3DXCreateTextureFromResourceExA(device
, NULL
, MAKEINTRESOURCEA(IDS_STRING
), D3DX_DEFAULT
, D3DX_DEFAULT
, D3DX_DEFAULT
, 0, D3DFMT_UNKNOWN
, D3DPOOL_MANAGED
, D3DX_DEFAULT
, D3DX_DEFAULT
, 0, NULL
, NULL
, &texture
);
577 ok(hr
== D3DXERR_INVALIDDATA
, "D3DXCreateTextureFromResourceEx returned %#x, expected %#x\n", hr
, D3DXERR_INVALIDDATA
);
579 hr
= D3DXCreateTextureFromResourceExA(NULL
, NULL
, MAKEINTRESOURCEA(IDD_BITMAPDATA_1x1
), D3DX_DEFAULT
, D3DX_DEFAULT
, D3DX_DEFAULT
, 0, D3DFMT_UNKNOWN
, D3DPOOL_MANAGED
, D3DX_DEFAULT
, D3DX_DEFAULT
, 0, NULL
, NULL
, &texture
);
580 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateTextureFromResourceEx returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
582 hr
= D3DXCreateTextureFromResourceExA(device
, NULL
, NULL
, D3DX_DEFAULT
, D3DX_DEFAULT
, D3DX_DEFAULT
, 0, D3DFMT_UNKNOWN
, D3DPOOL_MANAGED
, D3DX_DEFAULT
, D3DX_DEFAULT
, 0, NULL
, NULL
, &texture
);
583 ok(hr
== D3DXERR_INVALIDDATA
, "D3DXCreateTextureFromResourceEx returned %#x, expected %#x\n", hr
, D3DXERR_INVALIDDATA
);
585 hr
= D3DXCreateTextureFromResourceExA(device
, NULL
, MAKEINTRESOURCEA(IDD_BITMAPDATA_1x1
), D3DX_DEFAULT
, D3DX_DEFAULT
, D3DX_DEFAULT
, 0, D3DFMT_UNKNOWN
, D3DPOOL_MANAGED
, D3DX_DEFAULT
, D3DX_DEFAULT
, 0, NULL
, NULL
, NULL
);
586 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateTextureFromResourceEx returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
589 static void test_D3DXFilterTexture(IDirect3DDevice9
*device
)
591 IDirect3DTexture9
*tex
;
592 IDirect3DCubeTexture9
*cubetex
;
595 hr
= IDirect3DDevice9_CreateTexture(device
, 256, 256, 5, 0, D3DFMT_A8R8G8B8
, D3DPOOL_MANAGED
, &tex
, NULL
);
599 hr
= D3DXFilterTexture((IDirect3DBaseTexture9
*) tex
, NULL
, 0, D3DX_FILTER_NONE
);
600 ok(hr
== D3D_OK
, "D3DXFilterTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
602 hr
= D3DXFilterTexture((IDirect3DBaseTexture9
*) tex
, NULL
, 0, D3DX_FILTER_BOX
+ 1); /* Invalid filter */
603 ok(hr
== D3DERR_INVALIDCALL
, "D3DXFilterTexture returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
605 hr
= D3DXFilterTexture((IDirect3DBaseTexture9
*) tex
, NULL
, 5, D3DX_FILTER_NONE
); /* Invalid miplevel */
606 ok(hr
== D3DERR_INVALIDCALL
, "D3DXFilterTexture returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
609 skip("Failed to create texture\n");
611 IDirect3DTexture9_Release(tex
);
613 hr
= D3DXFilterTexture(NULL
, NULL
, 0, D3DX_FILTER_NONE
);
614 ok(hr
== D3DERR_INVALIDCALL
, "D3DXFilterTexture returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
616 /* Test different pools */
617 hr
= IDirect3DDevice9_CreateTexture(device
, 256, 256, 0, 0, D3DFMT_A8R8G8B8
, D3DPOOL_SYSTEMMEM
, &tex
, NULL
);
621 hr
= D3DXFilterTexture((IDirect3DBaseTexture9
*) tex
, NULL
, 0, D3DX_FILTER_NONE
);
622 ok(hr
== D3D_OK
, "D3DXFilterTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
623 IDirect3DTexture9_Release(tex
);
626 skip("Failed to create texture\n");
628 hr
= IDirect3DDevice9_CreateTexture(device
, 256, 256, 0, 0, D3DFMT_A8R8G8B8
, D3DPOOL_SCRATCH
, &tex
, NULL
);
632 hr
= D3DXFilterTexture((IDirect3DBaseTexture9
*) tex
, NULL
, 0, D3DX_FILTER_NONE
);
633 ok(hr
== D3D_OK
, "D3DXFilterTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
634 IDirect3DTexture9_Release(tex
);
637 skip("Failed to create texture\n");
639 /* Cube texture test */
640 hr
= IDirect3DDevice9_CreateCubeTexture(device
, 256, 5, 0, D3DFMT_A8R8G8B8
, D3DPOOL_MANAGED
, &cubetex
, NULL
);
644 hr
= D3DXFilterTexture((IDirect3DBaseTexture9
*) cubetex
, NULL
, 0, D3DX_FILTER_NONE
);
645 ok(hr
== D3D_OK
, "D3DXFilterTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
647 hr
= D3DXFilterTexture((IDirect3DBaseTexture9
*) cubetex
, NULL
, 0, D3DX_FILTER_BOX
+ 1); /* Invalid filter */
648 ok(hr
== D3DERR_INVALIDCALL
, "D3DXFilterTexture returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
650 hr
= D3DXFilterTexture((IDirect3DBaseTexture9
*) cubetex
, NULL
, 5, D3DX_FILTER_NONE
); /* Invalid miplevel */
651 ok(hr
== D3DERR_INVALIDCALL
, "D3DXFilterTexture returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
654 skip("Failed to create texture\n");
656 IDirect3DCubeTexture9_Release(cubetex
);
663 IDirect3DDevice9
*device
;
664 D3DPRESENT_PARAMETERS d3dpp
;
667 wnd
= CreateWindow("static", "d3dx9_test", 0, 0, 0, 0, 0, NULL
, NULL
, NULL
, NULL
);
669 skip("Couldn't create application window\n");
672 d3d
= Direct3DCreate9(D3D_SDK_VERSION
);
674 skip("Couldn't create IDirect3D9 object\n");
679 ZeroMemory(&d3dpp
, sizeof(d3dpp
));
680 d3dpp
.Windowed
= TRUE
;
681 d3dpp
.SwapEffect
= D3DSWAPEFFECT_DISCARD
;
682 hr
= IDirect3D9_CreateDevice(d3d
, D3DADAPTER_DEFAULT
, D3DDEVTYPE_HAL
, wnd
, D3DCREATE_MIXED_VERTEXPROCESSING
, &d3dpp
, &device
);
684 skip("Failed to create IDirect3DDevice9 object %#x\n", hr
);
685 IDirect3D9_Release(d3d
);
690 test_D3DXCheckTextureRequirements(device
);
691 test_D3DXCheckCubeTextureRequirements(device
);
692 test_D3DXCheckVolumeTextureRequirements(device
);
693 test_D3DXCreateTexture(device
);
694 test_D3DXFilterTexture(device
);
696 IDirect3DDevice9_Release(device
);
697 IDirect3D9_Release(d3d
);