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 /* 2x2 16-bit dds, no mipmaps */
29 static const unsigned char dds_16bit
[] = {
30 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x02,0x00,0x00,0x00,
31 0x02,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
32 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
33 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
34 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
35 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x7c,0x00,0x00,
36 0xe0,0x03,0x00,0x00,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,
37 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
38 0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f
41 /* 2x2 24-bit dds, 2 mipmaps */
42 static const unsigned char dds_24bit
[] = {
43 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x0a,0x00,0x02,0x00,0x00,0x00,
44 0x02,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
45 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
46 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
47 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
48 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0xff,0x00,
49 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00,
50 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
51 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
54 /* 4x4 cube map dds */
55 static const unsigned char dds_cube_map
[] = {
56 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x04,0x00,0x00,0x00,
57 0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
58 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
59 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
60 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
61 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
62 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00,0x00,
63 0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
64 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
65 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
66 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
67 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
68 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
69 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50
72 /* 4x4x2 volume map dds, 2 mipmaps */
73 static const unsigned char dds_volume_map
[] = {
74 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x8a,0x00,0x04,0x00,0x00,0x00,
75 0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
76 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
77 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
78 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
79 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
80 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00,
81 0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
82 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
83 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
84 0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x2f,0x7e,0xcf,0x79,0x01,0x54,0x5c,0x5c,
85 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x84,0xef,0x7b,0xaa,0xab,0xab,0xab
88 static void test_D3DXCheckTextureRequirements(IDirect3DDevice9
*device
)
90 UINT width
, height
, mipmaps
;
91 D3DFORMAT format
, expected
;
95 D3DDEVICE_CREATION_PARAMETERS params
;
98 IDirect3DDevice9_GetDeviceCaps(device
, &caps
);
101 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
102 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
104 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, D3DX_DEFAULT
, NULL
, D3DPOOL_DEFAULT
);
105 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
107 hr
= D3DXCheckTextureRequirements(NULL
, NULL
, NULL
, NULL
, D3DX_DEFAULT
, NULL
, D3DPOOL_DEFAULT
);
108 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
111 width
= height
= D3DX_DEFAULT
;
112 hr
= D3DXCheckTextureRequirements(device
, &width
, &height
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
113 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
114 ok(width
== 256, "Returned width %d, expected %d\n", width
, 256);
115 ok(height
== 256, "Returned height %d, expected %d\n", height
, 256);
117 width
= D3DX_DEFAULT
;
118 hr
= D3DXCheckTextureRequirements(device
, &width
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
119 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
120 ok(width
== 256, "Returned width %d, expected %d\n", width
, 256);
122 if (caps
.TextureCaps
& D3DPTEXTURECAPS_POW2
)
123 skip("Hardware only supports pow2 textures\n");
127 hr
= D3DXCheckTextureRequirements(device
, &width
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
128 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
129 ok(width
== 62, "Returned width %d, expected %d\n", width
, 62);
131 width
= D3DX_DEFAULT
; height
= 63;
132 hr
= D3DXCheckTextureRequirements(device
, &width
, &height
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
133 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
134 ok(width
== height
, "Returned width %d, expected %d\n", width
, height
);
135 ok(height
== 63, "Returned height %d, expected %d\n", height
, 63);
138 width
= D3DX_DEFAULT
; height
= 0;
139 hr
= D3DXCheckTextureRequirements(device
, &width
, &height
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
140 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
141 ok(width
== 1, "Returned width %d, expected %d\n", width
, 1);
142 ok(height
== 1, "Returned height %d, expected %d\n", height
, 1);
144 width
= 0; height
= 0;
145 hr
= D3DXCheckTextureRequirements(device
, &width
, &height
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
146 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
147 ok(width
== 1, "Returned width %d, expected %d\n", width
, 1);
148 ok(height
== 1, "Returned height %d, expected %d\n", height
, 1);
151 hr
= D3DXCheckTextureRequirements(device
, &width
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
152 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
153 ok(width
== 1, "Returned width %d, expected %d\n", width
, 1);
156 hr
= D3DXCheckTextureRequirements(device
, &width
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
157 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
158 ok(width
== caps
.MaxTextureWidth
, "Returned width %d, expected %d\n", width
, caps
.MaxTextureWidth
);
160 width
= caps
.MaxTextureWidth
-1;
161 hr
= D3DXCheckTextureRequirements(device
, &width
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
162 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
163 if (caps
.TextureCaps
& D3DPTEXTURECAPS_POW2
)
164 ok(width
== caps
.MaxTextureWidth
, "Returned width %d, expected %d\n", width
, caps
.MaxTextureWidth
);
166 ok(width
== caps
.MaxTextureWidth
-1, "Returned width %d, expected %d\n", width
, caps
.MaxTextureWidth
-1);
169 width
= 64; height
= 63;
171 hr
= D3DXCheckTextureRequirements(device
, &width
, &height
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
172 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
173 ok(mipmaps
== 7, "Returned mipmaps %d, expected %d\n", mipmaps
, 7);
175 if (!(caps
.TextureCaps
& D3DPTEXTURECAPS_POW2
))
177 width
= 284; height
= 137;
179 hr
= D3DXCheckTextureRequirements(device
, &width
, &height
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
180 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
181 ok(mipmaps
== 9, "Returned mipmaps %d, expected %d\n", mipmaps
, 9);
185 hr
= D3DXCheckTextureRequirements(device
, &width
, &height
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
186 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
187 ok(mipmaps
== 6, "Returned mipmaps %d, expected %d\n", mipmaps
, 6);
190 skip("Skipping some tests, npot2 textures unsupported\n");
193 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
194 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
195 ok(mipmaps
== 9, "Returned mipmaps %d, expected %d\n", mipmaps
, 9);
198 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
199 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
200 ok(mipmaps
== 9, "Returned mipmaps %d, expected %d\n", mipmaps
, 9);
203 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, D3DUSAGE_WRITEONLY
, NULL
, D3DPOOL_DEFAULT
);
204 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
205 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, D3DUSAGE_DONOTCLIP
, NULL
, D3DPOOL_DEFAULT
);
206 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
207 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, D3DUSAGE_POINTS
, NULL
, D3DPOOL_DEFAULT
);
208 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
209 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, D3DUSAGE_RTPATCHES
, NULL
, D3DPOOL_DEFAULT
);
210 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
211 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, D3DUSAGE_NPATCHES
, NULL
, D3DPOOL_DEFAULT
);
212 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckTextureRequirements succeeded, but should've failed.\n");
215 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
216 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
218 format
= D3DFMT_UNKNOWN
;
219 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, 0, &format
, D3DPOOL_DEFAULT
);
220 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
221 ok(format
== D3DFMT_A8R8G8B8
, "Returned format %u, expected %u\n", format
, D3DFMT_A8R8G8B8
);
223 format
= D3DX_DEFAULT
;
224 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, 0, &format
, D3DPOOL_DEFAULT
);
225 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
226 ok(format
== D3DFMT_A8R8G8B8
, "Returned format %u, expected %u\n", format
, D3DFMT_A8R8G8B8
);
228 format
= D3DFMT_R8G8B8
;
229 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, 0, &format
, D3DPOOL_DEFAULT
);
230 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
231 ok(format
== D3DFMT_X8R8G8B8
, "Returned format %u, expected %u\n", format
, D3DFMT_X8R8G8B8
);
233 IDirect3DDevice9_GetDirect3D(device
, &d3d
);
234 IDirect3DDevice9_GetCreationParameters(device
, ¶ms
);
235 IDirect3DDevice9_GetDisplayMode(device
, 0, &mode
);
237 if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d
, params
.AdapterOrdinal
, params
.DeviceType
,
238 mode
.Format
, 0, D3DRTYPE_TEXTURE
, D3DFMT_R3G3B2
)))
239 expected
= D3DFMT_R3G3B2
;
242 if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d
, params
.AdapterOrdinal
, params
.DeviceType
,
243 mode
.Format
, 0, D3DRTYPE_TEXTURE
, D3DFMT_X4R4G4B4
)))
244 expected
= D3DFMT_X4R4G4B4
;
246 expected
= D3DFMT_X1R5G5B5
;
249 format
= D3DFMT_R3G3B2
;
250 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, 0, &format
, D3DPOOL_DEFAULT
);
251 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
252 ok(format
== expected
, "Returned format %u, expected %u\n", format
, expected
);
254 if(SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d
, params
.AdapterOrdinal
, params
.DeviceType
,
255 mode
.Format
, 0, D3DRTYPE_TEXTURE
, D3DFMT_A8R3G3B2
)))
256 expected
= D3DFMT_A8R3G3B2
;
258 expected
= D3DFMT_A8R8G8B8
;
260 format
= D3DFMT_A8R3G3B2
;
261 hr
= D3DXCheckTextureRequirements(device
, NULL
, NULL
, NULL
, 0, &format
, D3DPOOL_DEFAULT
);
262 ok(hr
== D3D_OK
, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
263 ok(format
== expected
, "Returned format %u, expected %u\n", format
, expected
);
265 IDirect3D9_Release(d3d
);
268 static void test_D3DXCheckCubeTextureRequirements(IDirect3DDevice9
*device
)
270 UINT size
, mipmaps
, expected
;
275 IDirect3DDevice9_GetDeviceCaps(device
, &caps
);
277 if (!(caps
.TextureCaps
& D3DPTEXTURECAPS_CUBEMAP
))
279 skip("No cube textures support\n");
284 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
285 ok(hr
== D3D_OK
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
287 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, NULL
, D3DX_DEFAULT
, NULL
, D3DPOOL_DEFAULT
);
288 ok(hr
== D3D_OK
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
290 hr
= D3DXCheckCubeTextureRequirements(NULL
, NULL
, NULL
, D3DX_DEFAULT
, NULL
, D3DPOOL_DEFAULT
);
291 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
295 hr
= D3DXCheckCubeTextureRequirements(device
, &size
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
296 ok(hr
== D3D_OK
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
297 ok(size
== 256, "Returned size %d, expected %d\n", size
, 256);
302 hr
= D3DXCheckCubeTextureRequirements(device
, &size
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
303 ok(hr
== D3D_OK
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
304 ok(mipmaps
== 7, "Returned mipmaps %d, expected %d\n", mipmaps
, 7);
308 expected
= caps
.TextureCaps
& D3DPTEXTURECAPS_CUBEMAP_POW2
? 10 : 9;
309 hr
= D3DXCheckCubeTextureRequirements(device
, &size
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
310 ok(hr
== D3D_OK
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
311 ok(mipmaps
== expected
, "Returned mipmaps %d, expected %d\n", mipmaps
, expected
);
315 expected
= caps
.TextureCaps
& D3DPTEXTURECAPS_CUBEMAP_POW2
? 7 : 6;
316 hr
= D3DXCheckCubeTextureRequirements(device
, &size
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
317 ok(hr
== D3D_OK
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
318 ok(mipmaps
== expected
, "Returned mipmaps %d, expected %d\n", mipmaps
, expected
);
321 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
322 ok(hr
== D3D_OK
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
323 ok(mipmaps
== 9, "Returned mipmaps %d, expected %d\n", mipmaps
, 9);
326 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, NULL
, D3DUSAGE_WRITEONLY
, NULL
, D3DPOOL_DEFAULT
);
327 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
328 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, NULL
, D3DUSAGE_DONOTCLIP
, NULL
, D3DPOOL_DEFAULT
);
329 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
330 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, NULL
, D3DUSAGE_POINTS
, NULL
, D3DPOOL_DEFAULT
);
331 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
332 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, NULL
, D3DUSAGE_RTPATCHES
, NULL
, D3DPOOL_DEFAULT
);
333 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
334 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, NULL
, D3DUSAGE_NPATCHES
, NULL
, D3DPOOL_DEFAULT
);
335 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckCubeTextureRequirements succeeded, but should've failed.\n");
338 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
339 ok(hr
== D3D_OK
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
341 format
= D3DFMT_UNKNOWN
;
342 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, NULL
, 0, &format
, D3DPOOL_DEFAULT
);
343 ok(hr
== D3D_OK
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
344 ok(format
== D3DFMT_A8R8G8B8
, "Returned format %u, expected %u\n", format
, D3DFMT_A8R8G8B8
);
346 format
= D3DX_DEFAULT
;
347 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, NULL
, 0, &format
, D3DPOOL_DEFAULT
);
348 ok(hr
== D3D_OK
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
349 ok(format
== D3DFMT_A8R8G8B8
, "Returned format %u, expected %u\n", format
, D3DFMT_A8R8G8B8
);
351 format
= D3DFMT_R8G8B8
;
352 hr
= D3DXCheckCubeTextureRequirements(device
, NULL
, NULL
, 0, &format
, D3DPOOL_DEFAULT
);
353 ok(hr
== D3D_OK
, "D3DXCheckCubeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
354 ok(format
== D3DFMT_X8R8G8B8
, "Returned format %u, expected %u\n", format
, D3DFMT_X8R8G8B8
);
357 static void test_D3DXCheckVolumeTextureRequirements(IDirect3DDevice9
*device
)
359 UINT width
, height
, depth
, mipmaps
, expected
;
364 IDirect3DDevice9_GetDeviceCaps(device
, &caps
);
366 if (!(caps
.TextureCaps
& D3DPTEXTURECAPS_VOLUMEMAP
))
368 skip("No volume textures support\n");
373 hr
= D3DXCheckVolumeTextureRequirements(device
, NULL
, NULL
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
374 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
376 hr
= D3DXCheckVolumeTextureRequirements(device
, NULL
, NULL
, NULL
, NULL
, D3DX_DEFAULT
, NULL
, D3DPOOL_DEFAULT
);
377 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
379 hr
= D3DXCheckVolumeTextureRequirements(NULL
, NULL
, NULL
, NULL
, NULL
, D3DX_DEFAULT
, NULL
, D3DPOOL_DEFAULT
);
380 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
382 /* width, height, depth */
383 width
= height
= depth
= D3DX_DEFAULT
;
384 hr
= D3DXCheckVolumeTextureRequirements(device
, &width
, &height
, &depth
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
385 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
386 ok(width
== 256, "Returned width %d, expected %d\n", width
, 256);
387 ok(height
== 256, "Returned height %d, expected %d\n", height
, 256);
388 ok(depth
== 1, "Returned depth %d, expected %d\n", depth
, 1);
390 width
= D3DX_DEFAULT
;
391 hr
= D3DXCheckVolumeTextureRequirements(device
, &width
, NULL
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
392 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
393 ok(width
== 256, "Returned width %d, expected %d\n", width
, 256);
395 width
= D3DX_DEFAULT
; height
= 0; depth
= 0;
396 hr
= D3DXCheckVolumeTextureRequirements(device
, &width
, &height
, &depth
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
397 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
398 ok(width
== 1, "Returned width %d, expected %d\n", width
, 1);
399 ok(height
== 1, "Returned height %d, expected %d\n", height
, 1);
400 ok(depth
== 1, "Returned height %d, expected %d\n", depth
, 1);
402 width
= 0; height
= 0; depth
= 0;
403 hr
= D3DXCheckVolumeTextureRequirements(device
, &width
, &height
, &depth
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
404 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
405 ok(width
== 1, "Returned width %d, expected %d\n", width
, 1);
406 ok(height
== 1, "Returned height %d, expected %d\n", height
, 1);
407 ok(depth
== 1, "Returned height %d, expected %d\n", depth
, 1);
410 hr
= D3DXCheckVolumeTextureRequirements(device
, &width
, NULL
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
411 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
412 ok(width
== 1, "Returned width %d, expected %d\n", width
, 1);
415 hr
= D3DXCheckVolumeTextureRequirements(device
, &width
, NULL
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
416 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
417 ok(width
== caps
.MaxVolumeExtent
, "Returned width %d, expected %d\n", width
, caps
.MaxVolumeExtent
);
420 hr
= D3DXCheckVolumeTextureRequirements(device
, NULL
, NULL
, NULL
, NULL
, 0, NULL
, D3DPOOL_DEFAULT
);
421 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
423 format
= D3DFMT_UNKNOWN
;
424 hr
= D3DXCheckVolumeTextureRequirements(device
, NULL
, NULL
, NULL
, NULL
, 0, &format
, D3DPOOL_DEFAULT
);
425 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
426 ok(format
== D3DFMT_A8R8G8B8
, "Returned format %u, expected %u\n", format
, D3DFMT_A8R8G8B8
);
428 format
= D3DX_DEFAULT
;
429 hr
= D3DXCheckVolumeTextureRequirements(device
, NULL
, NULL
, NULL
, NULL
, 0, &format
, D3DPOOL_DEFAULT
);
430 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
431 ok(format
== D3DFMT_A8R8G8B8
, "Returned format %u, expected %u\n", format
, D3DFMT_A8R8G8B8
);
433 format
= D3DFMT_R8G8B8
;
434 hr
= D3DXCheckVolumeTextureRequirements(device
, NULL
, NULL
, NULL
, NULL
, 0, &format
, D3DPOOL_DEFAULT
);
435 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
436 ok(format
== D3DFMT_X8R8G8B8
, "Returned format %u, expected %u\n", format
, D3DFMT_X8R8G8B8
);
439 if (!(caps
.TextureCaps
& D3DPTEXTURECAPS_MIPVOLUMEMAP
))
441 skip("No volume textures mipmapping support\n");
445 width
= height
= depth
= 64;
447 hr
= D3DXCheckVolumeTextureRequirements(device
, &width
, &height
, &depth
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
448 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
449 ok(mipmaps
== 7, "Returned mipmaps %d, expected %d\n", mipmaps
, 7);
455 expected
= caps
.TextureCaps
& D3DPTEXTURECAPS_VOLUMEMAP_POW2
? 10 : 9;
456 hr
= D3DXCheckVolumeTextureRequirements(device
, &width
, &height
, &depth
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
457 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
458 ok(mipmaps
== expected
, "Returned mipmaps %d, expected %d\n", mipmaps
, expected
);
461 hr
= D3DXCheckVolumeTextureRequirements(device
, NULL
, NULL
, NULL
, &mipmaps
, 0, NULL
, D3DPOOL_DEFAULT
);
462 ok(hr
== D3D_OK
, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr
, D3D_OK
);
463 ok(mipmaps
== 9, "Returned mipmaps %d, expected %d\n", mipmaps
, 9);
466 static void test_D3DXCreateTexture(IDirect3DDevice9
*device
)
468 IDirect3DTexture9
*texture
;
469 D3DSURFACE_DESC desc
;
474 IDirect3DDevice9_GetDeviceCaps(device
, &caps
);
476 hr
= D3DXCreateTexture(NULL
, 0, 0, 0, 0, D3DX_DEFAULT
, 0, D3DPOOL_DEFAULT
);
477 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateTexture returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
479 /* width and height tests */
481 hr
= D3DXCreateTexture(device
, D3DX_DEFAULT
, D3DX_DEFAULT
, D3DX_DEFAULT
, 0, 0, D3DPOOL_DEFAULT
, &texture
);
482 ok(hr
== D3D_OK
, "D3DXCreateTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
486 hr
= IDirect3DTexture9_GetLevelDesc(texture
, 0, &desc
);
487 ok(hr
== D3D_OK
, "GetLevelDesc returned %#x, expected %#x\n", hr
, D3D_OK
);
488 ok(desc
.Format
== D3DFMT_A8R8G8B8
, "Returned format %u, expected %u\n", desc
.Format
, D3DFMT_A8R8G8B8
);
490 ok(desc
.Width
== 256, "Returned width %d, expected %d\n", desc
.Width
, 256);
491 ok(desc
.Height
== 256, "Returned height %d, expected %d\n", desc
.Height
, 256);
493 IDirect3DTexture9_Release(texture
);
497 hr
= D3DXCreateTexture(device
, 0, 0, 0, 0, 0, D3DPOOL_DEFAULT
, &texture
);
498 ok(hr
== D3D_OK
, "D3DXCreateTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
502 hr
= IDirect3DTexture9_GetLevelDesc(texture
, 0, &desc
);
503 ok(hr
== D3D_OK
, "GetLevelDesc returned %#x, expected %#x\n", hr
, D3D_OK
);
504 ok(desc
.Format
== D3DFMT_A8R8G8B8
, "Returned format %u, expected %u\n", desc
.Format
, D3DFMT_A8R8G8B8
);
506 ok(desc
.Width
== 1, "Returned width %d, expected %d\n", desc
.Width
, 1);
507 ok(desc
.Height
== 1, "Returned height %d, expected %d\n", desc
.Height
, 1);
509 IDirect3DTexture9_Release(texture
);
513 if (caps
.TextureCaps
& D3DPTEXTURECAPS_POW2
)
514 skip("Hardware only supports pow2 textures\n");
517 hr
= D3DXCreateTexture(device
, D3DX_DEFAULT
, 63, 0, 0, 0, D3DPOOL_DEFAULT
, &texture
);
519 /* may not work with conditional NPOT */
520 ((hr
!= D3D_OK
) && (caps
.TextureCaps
& D3DPTEXTURECAPS_NONPOW2CONDITIONAL
)),
521 "D3DXCreateTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
525 hr
= IDirect3DTexture9_GetLevelDesc(texture
, 0, &desc
);
526 ok(hr
== D3D_OK
, "GetLevelDesc returned %#x, expected %#x\n", hr
, D3D_OK
);
527 ok(desc
.Format
== D3DFMT_A8R8G8B8
, "Returned format %u, expected %u\n", desc
.Format
, D3DFMT_A8R8G8B8
);
529 /* Conditional NPOT may create a texture with different dimensions, so allow those
530 situations instead of returning a fail */
532 ok(desc
.Width
== 63 ||
533 (caps
.TextureCaps
& D3DPTEXTURECAPS_NONPOW2CONDITIONAL
),
534 "Returned width %d, expected %d\n", desc
.Width
, 63);
536 ok(desc
.Height
== 63 ||
537 (caps
.TextureCaps
& D3DPTEXTURECAPS_NONPOW2CONDITIONAL
),
538 "Returned height %d, expected %d\n", desc
.Height
, 63);
540 IDirect3DTexture9_Release(texture
);
546 hr
= D3DXCreateTexture(device
, 64, 63, 9, 0, 0, D3DPOOL_DEFAULT
, &texture
);
547 ok(hr
== D3D_OK
, "D3DXCreateTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
551 mipmaps
= IDirect3DTexture9_GetLevelCount(texture
);
552 ok(mipmaps
== 7, "Returned mipmaps %d, expected %d\n", mipmaps
, 7);
554 IDirect3DTexture9_Release(texture
);
558 hr
= D3DXCreateTexture(device
, 284, 137, 9, 0, 0, D3DPOOL_DEFAULT
, &texture
);
559 ok(hr
== D3D_OK
, "D3DXCreateTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
563 mipmaps
= IDirect3DTexture9_GetLevelCount(texture
);
564 ok(mipmaps
== 9, "Returned mipmaps %d, expected %d\n", mipmaps
, 9);
566 IDirect3DTexture9_Release(texture
);
570 hr
= D3DXCreateTexture(device
, 0, 0, 20, 0, 0, D3DPOOL_DEFAULT
, &texture
);
571 ok(hr
== D3D_OK
, "D3DXCreateTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
575 mipmaps
= IDirect3DTexture9_GetLevelCount(texture
);
576 ok(mipmaps
== 1, "Returned mipmaps %d, expected %d\n", mipmaps
, 1);
578 IDirect3DTexture9_Release(texture
);
582 hr
= D3DXCreateTexture(device
, 64, 64, 1, 0, 0, D3DPOOL_DEFAULT
, &texture
);
583 ok(hr
== D3D_OK
, "D3DXCreateTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
587 mipmaps
= IDirect3DTexture9_GetLevelCount(texture
);
588 ok(mipmaps
== 1, "Returned mipmaps %d, expected %d\n", mipmaps
, 1);
590 IDirect3DTexture9_Release(texture
);
595 hr
= D3DXCreateTexture(device
, 0, 0, 0, D3DUSAGE_WRITEONLY
, 0, D3DPOOL_DEFAULT
, &texture
);
596 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateTexture succeeded, but should have failed.\n");
597 hr
= D3DXCreateTexture(device
, 0, 0, 0, D3DUSAGE_DONOTCLIP
, 0, D3DPOOL_DEFAULT
, &texture
);
598 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateTexture succeeded, but should have failed.\n");
599 hr
= D3DXCreateTexture(device
, 0, 0, 0, D3DUSAGE_POINTS
, 0, D3DPOOL_DEFAULT
, &texture
);
600 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateTexture succeeded, but should have failed.\n");
601 hr
= D3DXCreateTexture(device
, 0, 0, 0, D3DUSAGE_RTPATCHES
, 0, D3DPOOL_DEFAULT
, &texture
);
602 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateTexture succeeded, but should have failed.\n");
603 hr
= D3DXCreateTexture(device
, 0, 0, 0, D3DUSAGE_NPATCHES
, 0, D3DPOOL_DEFAULT
, &texture
);
604 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateTexture succeeded, but should have failed.\n");
608 hr
= D3DXCreateTexture(device
, 0, 0, 0, 0, D3DFMT_UNKNOWN
, D3DPOOL_DEFAULT
, &texture
);
609 ok(hr
== D3D_OK
, "D3DXCreateTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
613 hr
= IDirect3DTexture9_GetLevelDesc(texture
, 0, &desc
);
614 ok(hr
== D3D_OK
, "GetLevelDesc returned %#x, expected %#x\n", hr
, D3D_OK
);
615 ok(desc
.Format
== D3DFMT_A8R8G8B8
, "Returned format %u, expected %u\n", desc
.Format
, D3DFMT_A8R8G8B8
);
617 IDirect3DTexture9_Release(texture
);
621 hr
= D3DXCreateTexture(device
, 0, 0, 0, 0, 0, D3DPOOL_DEFAULT
, &texture
);
622 ok(hr
== D3D_OK
, "D3DXCreateTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
626 hr
= IDirect3DTexture9_GetLevelDesc(texture
, 0, &desc
);
627 ok(hr
== D3D_OK
, "GetLevelDesc returned %#x, expected %#x\n", hr
, D3D_OK
);
628 ok(desc
.Format
== D3DFMT_A8R8G8B8
, "Returned format %u, expected %u\n", desc
.Format
, D3DFMT_A8R8G8B8
);
630 IDirect3DTexture9_Release(texture
);
633 /* D3DXCreateTextureFromResource */
635 hr
= D3DXCreateTextureFromResourceA(device
, NULL
, MAKEINTRESOURCEA(IDB_BITMAP_1x1
), &texture
);
636 ok(hr
== D3D_OK
, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr
, D3D_OK
);
637 if (SUCCEEDED(hr
)) IDirect3DTexture9_Release(texture
);
639 hr
= D3DXCreateTextureFromResourceA(device
, NULL
, MAKEINTRESOURCEA(IDD_BITMAPDATA_1x1
), &texture
);
640 ok(hr
== D3D_OK
, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr
, D3D_OK
);
641 if (SUCCEEDED(hr
)) IDirect3DTexture9_Release(texture
);
643 hr
= D3DXCreateTextureFromResourceA(device
, NULL
, MAKEINTRESOURCEA(IDS_STRING
), &texture
);
644 ok(hr
== D3DXERR_INVALIDDATA
, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr
, D3DXERR_INVALIDDATA
);
646 hr
= D3DXCreateTextureFromResourceA(NULL
, NULL
, MAKEINTRESOURCEA(IDD_BITMAPDATA_1x1
), &texture
);
647 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
649 hr
= D3DXCreateTextureFromResourceA(device
, NULL
, NULL
, &texture
);
650 ok(hr
== D3DXERR_INVALIDDATA
, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr
, D3DXERR_INVALIDDATA
);
652 hr
= D3DXCreateTextureFromResourceA(device
, NULL
, MAKEINTRESOURCEA(IDD_BITMAPDATA_1x1
), NULL
);
653 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateTextureFromResource returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
656 /* D3DXCreateTextureFromResourceEx */
657 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
);
658 ok(hr
== D3D_OK
, "D3DXCreateTextureFromResourceEx returned %#x, expected %#x\n", hr
, D3D_OK
);
659 if (SUCCEEDED(hr
)) IDirect3DTexture9_Release(texture
);
661 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
);
662 ok(hr
== D3DXERR_INVALIDDATA
, "D3DXCreateTextureFromResourceEx returned %#x, expected %#x\n", hr
, D3DXERR_INVALIDDATA
);
664 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
);
665 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateTextureFromResourceEx returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
667 hr
= D3DXCreateTextureFromResourceExA(device
, NULL
, NULL
, D3DX_DEFAULT
, D3DX_DEFAULT
, D3DX_DEFAULT
, 0, D3DFMT_UNKNOWN
, D3DPOOL_MANAGED
, D3DX_DEFAULT
, D3DX_DEFAULT
, 0, NULL
, NULL
, &texture
);
668 ok(hr
== D3DXERR_INVALIDDATA
, "D3DXCreateTextureFromResourceEx returned %#x, expected %#x\n", hr
, D3DXERR_INVALIDDATA
);
670 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
);
671 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateTextureFromResourceEx returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
674 static void test_D3DXFilterTexture(IDirect3DDevice9
*device
)
676 IDirect3DTexture9
*tex
;
677 IDirect3DCubeTexture9
*cubetex
;
680 hr
= IDirect3DDevice9_CreateTexture(device
, 256, 256, 5, 0, D3DFMT_A8R8G8B8
, D3DPOOL_MANAGED
, &tex
, NULL
);
684 hr
= D3DXFilterTexture((IDirect3DBaseTexture9
*) tex
, NULL
, 0, D3DX_FILTER_NONE
);
685 ok(hr
== D3D_OK
, "D3DXFilterTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
687 hr
= D3DXFilterTexture((IDirect3DBaseTexture9
*) tex
, NULL
, 0, D3DX_FILTER_BOX
+ 1); /* Invalid filter */
688 ok(hr
== D3DERR_INVALIDCALL
, "D3DXFilterTexture returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
690 hr
= D3DXFilterTexture((IDirect3DBaseTexture9
*) tex
, NULL
, 5, D3DX_FILTER_NONE
); /* Invalid miplevel */
691 ok(hr
== D3DERR_INVALIDCALL
, "D3DXFilterTexture returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
694 skip("Failed to create texture\n");
696 IDirect3DTexture9_Release(tex
);
698 hr
= D3DXFilterTexture(NULL
, NULL
, 0, D3DX_FILTER_NONE
);
699 ok(hr
== D3DERR_INVALIDCALL
, "D3DXFilterTexture returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
701 /* Test different pools */
702 hr
= IDirect3DDevice9_CreateTexture(device
, 256, 256, 0, 0, D3DFMT_A8R8G8B8
, D3DPOOL_SYSTEMMEM
, &tex
, NULL
);
706 hr
= D3DXFilterTexture((IDirect3DBaseTexture9
*) tex
, NULL
, 0, D3DX_FILTER_NONE
);
707 ok(hr
== D3D_OK
, "D3DXFilterTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
708 IDirect3DTexture9_Release(tex
);
711 skip("Failed to create texture\n");
713 hr
= IDirect3DDevice9_CreateTexture(device
, 256, 256, 0, 0, D3DFMT_A8R8G8B8
, D3DPOOL_SCRATCH
, &tex
, NULL
);
717 hr
= D3DXFilterTexture((IDirect3DBaseTexture9
*) tex
, NULL
, 0, D3DX_FILTER_NONE
);
718 ok(hr
== D3D_OK
, "D3DXFilterTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
719 IDirect3DTexture9_Release(tex
);
722 skip("Failed to create texture\n");
724 /* Cube texture test */
725 hr
= IDirect3DDevice9_CreateCubeTexture(device
, 256, 5, 0, D3DFMT_A8R8G8B8
, D3DPOOL_MANAGED
, &cubetex
, NULL
);
729 hr
= D3DXFilterTexture((IDirect3DBaseTexture9
*) cubetex
, NULL
, 0, D3DX_FILTER_NONE
);
730 ok(hr
== D3D_OK
, "D3DXFilterTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
732 hr
= D3DXFilterTexture((IDirect3DBaseTexture9
*) cubetex
, NULL
, 0, D3DX_FILTER_BOX
+ 1); /* Invalid filter */
733 ok(hr
== D3DERR_INVALIDCALL
, "D3DXFilterTexture returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
735 hr
= D3DXFilterTexture((IDirect3DBaseTexture9
*) cubetex
, NULL
, 5, D3DX_FILTER_NONE
); /* Invalid miplevel */
736 ok(hr
== D3DERR_INVALIDCALL
, "D3DXFilterTexture returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
739 skip("Failed to create texture\n");
741 IDirect3DCubeTexture9_Release(cubetex
);
744 static BOOL
color_match(const DWORD
*value
, const DWORD
*expected
)
748 for (i
= 0; i
< 4; i
++)
750 DWORD diff
= value
[i
] > expected
[i
] ? value
[i
] - expected
[i
] : expected
[i
] - value
[i
];
751 if (diff
> 1) return FALSE
;
756 static void WINAPI
fillfunc(D3DXVECTOR4
*value
, const D3DXVECTOR2
*texcoord
,
757 const D3DXVECTOR2
*texelsize
, void *data
)
759 value
->x
= texcoord
->x
;
760 value
->y
= texcoord
->y
;
761 value
->z
= texelsize
->x
;
765 static void test_D3DXFillTexture(IDirect3DDevice9
*device
)
767 IDirect3DTexture9
*tex
;
769 D3DLOCKED_RECT lock_rect
;
772 DWORD value
, expected
, size
, pitch
;
775 hr
= IDirect3DDevice9_CreateTexture(device
, size
, size
, 0, 0, D3DFMT_A8R8G8B8
,
776 D3DPOOL_MANAGED
, &tex
, NULL
);
780 hr
= D3DXFillTexture(tex
, fillfunc
, NULL
);
781 ok(hr
== D3D_OK
, "D3DXFillTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
783 for (m
= 0; m
< 3; m
++)
785 hr
= IDirect3DTexture9_LockRect(tex
, m
, &lock_rect
, NULL
, D3DLOCK_READONLY
);
786 ok(hr
== D3D_OK
, "Couldn't lock the texture, error %#x\n", hr
);
789 pitch
= lock_rect
.Pitch
/ sizeof(DWORD
);
790 for (y
= 0; y
< size
; y
++)
792 for (x
= 0; x
< size
; x
++)
794 value
= ((DWORD
*)lock_rect
.pBits
)[y
* pitch
+ x
];
795 v
[0] = (value
>> 24) & 0xff;
796 v
[1] = (value
>> 16) & 0xff;
797 v
[2] = (value
>> 8) & 0xff;
801 e
[1] = (x
+ 0.5f
) / size
* 255.0f
+ 0.5f
;
802 e
[2] = (y
+ 0.5f
) / size
* 255.0f
+ 0.5f
;
803 e
[3] = 255.0f
/ size
+ 0.5f
;
804 expected
= e
[0] << 24 | e
[1] << 16 | e
[2] << 8 | e
[3];
806 ok(color_match(v
, e
),
807 "Texel at (%u, %u) doesn't match: %#x, expected %#x\n",
808 x
, y
, value
, expected
);
811 IDirect3DTexture9_UnlockRect(tex
, m
);
817 skip("Failed to create texture\n");
819 IDirect3DTexture9_Release(tex
);
821 hr
= IDirect3DDevice9_CreateTexture(device
, 4, 4, 1, 0, D3DFMT_A1R5G5B5
,
822 D3DPOOL_MANAGED
, &tex
, NULL
);
826 hr
= D3DXFillTexture(tex
, fillfunc
, NULL
);
827 ok(hr
== D3D_OK
, "D3DXFillTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
829 hr
= IDirect3DTexture9_LockRect(tex
, 0, &lock_rect
, NULL
, D3DLOCK_READONLY
);
830 ok(hr
== D3D_OK
, "Couldn't lock the texture, error %#x\n", hr
);
833 pitch
= lock_rect
.Pitch
/ sizeof(WORD
);
834 for (y
= 0; y
< 4; y
++)
836 for (x
= 0; x
< 4; x
++)
838 value
= ((WORD
*)lock_rect
.pBits
)[y
* pitch
+ x
];
840 v
[1] = value
>> 10 & 0x1f;
841 v
[2] = value
>> 5 & 0x1f;
845 e
[1] = (x
+ 0.5f
) / 4.0f
* 31.0f
+ 0.5f
;
846 e
[2] = (y
+ 0.5f
) / 4.0f
* 31.0f
+ 0.5f
;
848 expected
= e
[0] << 15 | e
[1] << 10 | e
[2] << 5 | e
[3];
850 ok(color_match(v
, e
),
851 "Texel at (%u, %u) doesn't match: %#x, expected %#x\n",
852 x
, y
, value
, expected
);
855 IDirect3DTexture9_UnlockRect(tex
, 0);
859 skip("Failed to create texture\n");
861 IDirect3DTexture9_Release(tex
);
864 static void WINAPI
fillfunc_cube(D3DXVECTOR4
*value
, const D3DXVECTOR3
*texcoord
,
865 const D3DXVECTOR3
*texelsize
, void *data
)
867 value
->x
= (texcoord
->x
+ 1.0f
) / 2.0f
;
868 value
->y
= (texcoord
->y
+ 1.0f
) / 2.0f
;
869 value
->z
= (texcoord
->z
+ 1.0f
) / 2.0f
;
870 value
->w
= texelsize
->x
;
883 static float get_cube_coord(enum cube_coord coord
, unsigned int x
, unsigned int y
, unsigned int size
)
890 return size
- x
- 0.5f
;
894 return size
- y
- 0.5f
;
900 trace("Unexpected coordinate value\n");
905 static void test_D3DXFillCubeTexture(IDirect3DDevice9
*device
)
907 IDirect3DCubeTexture9
*tex
;
909 D3DLOCKED_RECT lock_rect
;
912 DWORD value
, expected
, size
, pitch
;
913 enum cube_coord coordmap
[6][3] =
915 {ONE
, YCOORDINV
, XCOORDINV
},
916 {ZERO
, YCOORDINV
, XCOORD
},
917 {XCOORD
, ONE
, YCOORD
},
918 {XCOORD
, ZERO
, YCOORDINV
},
919 {XCOORD
, YCOORDINV
, ONE
},
920 {XCOORDINV
, YCOORDINV
, ZERO
}
924 hr
= IDirect3DDevice9_CreateCubeTexture(device
, size
, 0, 0, D3DFMT_A8R8G8B8
,
925 D3DPOOL_MANAGED
, &tex
, NULL
);
929 hr
= D3DXFillCubeTexture(tex
, fillfunc_cube
, NULL
);
930 ok(hr
== D3D_OK
, "D3DXFillCubeTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
932 for (m
= 0; m
< 3; m
++)
934 for (f
= 0; f
< 6; f
++)
936 hr
= IDirect3DCubeTexture9_LockRect(tex
, f
, m
, &lock_rect
, NULL
, D3DLOCK_READONLY
);
937 ok(hr
== D3D_OK
, "Couldn't lock the texture, error %#x\n", hr
);
940 pitch
= lock_rect
.Pitch
/ sizeof(DWORD
);
941 for (y
= 0; y
< size
; y
++)
943 for (x
= 0; x
< size
; x
++)
945 value
= ((DWORD
*)lock_rect
.pBits
)[y
* pitch
+ x
];
946 v
[0] = (value
>> 24) & 0xff;
947 v
[1] = (value
>> 16) & 0xff;
948 v
[2] = (value
>> 8) & 0xff;
951 e
[0] = (f
== 0) || (f
== 1) ?
952 0 : (BYTE
)(255.0f
/ size
* 2.0f
+ 0.5f
);
953 e
[1] = get_cube_coord(coordmap
[f
][0], x
, y
, size
) / size
* 255.0f
+ 0.5f
;
954 e
[2] = get_cube_coord(coordmap
[f
][1], x
, y
, size
) / size
* 255.0f
+ 0.5f
;
955 e
[3] = get_cube_coord(coordmap
[f
][2], x
, y
, size
) / size
* 255.0f
+ 0.5f
;
956 expected
= e
[0] << 24 | e
[1] << 16 | e
[2] << 8 | e
[3];
958 ok(color_match(v
, e
),
959 "Texel at face %u (%u, %u) doesn't match: %#x, expected %#x\n",
960 f
, x
, y
, value
, expected
);
963 IDirect3DCubeTexture9_UnlockRect(tex
, f
, m
);
970 skip("Failed to create texture\n");
972 IDirect3DCubeTexture9_Release(tex
);
974 hr
= IDirect3DDevice9_CreateCubeTexture(device
, 4, 1, 0, D3DFMT_A1R5G5B5
,
975 D3DPOOL_MANAGED
, &tex
, NULL
);
979 hr
= D3DXFillCubeTexture(tex
, fillfunc_cube
, NULL
);
980 ok(hr
== D3D_OK
, "D3DXFillTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
981 for (f
= 0; f
< 6; f
++)
983 hr
= IDirect3DCubeTexture9_LockRect(tex
, f
, 0, &lock_rect
, NULL
, D3DLOCK_READONLY
);
984 ok(hr
== D3D_OK
, "Couldn't lock the texture, error %#x\n", hr
);
987 pitch
= lock_rect
.Pitch
/ sizeof(WORD
);
988 for (y
= 0; y
< 4; y
++)
990 for (x
= 0; x
< 4; x
++)
992 value
= ((WORD
*)lock_rect
.pBits
)[y
* pitch
+ x
];
994 v
[1] = value
>> 10 & 0x1f;
995 v
[2] = value
>> 5 & 0x1f;
998 e
[0] = (f
== 0) || (f
== 1) ?
999 0 : (BYTE
)(1.0f
/ size
* 2.0f
+ 0.5f
);
1000 e
[1] = get_cube_coord(coordmap
[f
][0], x
, y
, 4) / 4 * 31.0f
+ 0.5f
;
1001 e
[2] = get_cube_coord(coordmap
[f
][1], x
, y
, 4) / 4 * 31.0f
+ 0.5f
;
1002 e
[3] = get_cube_coord(coordmap
[f
][2], x
, y
, 4) / 4 * 31.0f
+ 0.5f
;
1003 expected
= e
[0] << 15 | e
[1] << 10 | e
[2] << 5 | e
[3];
1005 ok(color_match(v
, e
),
1006 "Texel at face %u (%u, %u) doesn't match: %#x, expected %#x\n",
1007 f
, x
, y
, value
, expected
);
1010 IDirect3DCubeTexture9_UnlockRect(tex
, f
, 0);
1015 skip("Failed to create texture\n");
1017 IDirect3DCubeTexture9_Release(tex
);
1020 static void WINAPI
fillfunc_volume(D3DXVECTOR4
*value
, const D3DXVECTOR3
*texcoord
,
1021 const D3DXVECTOR3
*texelsize
, void *data
)
1023 value
->x
= texcoord
->x
;
1024 value
->y
= texcoord
->y
;
1025 value
->z
= texcoord
->z
;
1026 value
->w
= texelsize
->x
;
1029 static void test_D3DXFillVolumeTexture(IDirect3DDevice9
*device
)
1031 IDirect3DVolumeTexture9
*tex
;
1033 D3DLOCKED_BOX lock_box
;
1036 DWORD value
, expected
, size
, row_pitch
, slice_pitch
;
1039 hr
= IDirect3DDevice9_CreateVolumeTexture(device
, size
, size
, size
, 0, 0, D3DFMT_A8R8G8B8
,
1040 D3DPOOL_MANAGED
, &tex
, NULL
);
1044 hr
= D3DXFillVolumeTexture(tex
, fillfunc_volume
, NULL
);
1045 ok(hr
== D3D_OK
, "D3DXFillVolumeTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
1047 for (m
= 0; m
< 3; m
++)
1049 hr
= IDirect3DVolumeTexture9_LockBox(tex
, m
, &lock_box
, NULL
, D3DLOCK_READONLY
);
1050 ok(hr
== D3D_OK
, "Couldn't lock the texture, error %#x\n", hr
);
1053 row_pitch
= lock_box
.RowPitch
/ sizeof(DWORD
);
1054 slice_pitch
= lock_box
.SlicePitch
/ sizeof(DWORD
);
1055 for (z
= 0; z
< size
; z
++)
1057 for (y
= 0; y
< size
; y
++)
1059 for (x
= 0; x
< size
; x
++)
1061 value
= ((DWORD
*)lock_box
.pBits
)[z
* slice_pitch
+ y
* row_pitch
+ x
];
1062 v
[0] = (value
>> 24) & 0xff;
1063 v
[1] = (value
>> 16) & 0xff;
1064 v
[2] = (value
>> 8) & 0xff;
1065 v
[3] = value
& 0xff;
1067 e
[0] = 255.0f
/ size
+ 0.5f
;
1068 e
[1] = (x
+ 0.5f
) / size
* 255.0f
+ 0.5f
;
1069 e
[2] = (y
+ 0.5f
) / size
* 255.0f
+ 0.5f
;
1070 e
[3] = (z
+ 0.5f
) / size
* 255.0f
+ 0.5f
;
1071 expected
= e
[0] << 24 | e
[1] << 16 | e
[2] << 8 | e
[3];
1073 ok(color_match(v
, e
),
1074 "Texel at (%u, %u, %u) doesn't match: %#x, expected %#x\n",
1075 x
, y
, z
, value
, expected
);
1079 IDirect3DVolumeTexture9_UnlockBox(tex
, m
);
1085 skip("Failed to create texture\n");
1087 IDirect3DVolumeTexture9_Release(tex
);
1089 hr
= IDirect3DDevice9_CreateVolumeTexture(device
, 4, 4, 4, 1, 0, D3DFMT_A1R5G5B5
,
1090 D3DPOOL_MANAGED
, &tex
, NULL
);
1094 hr
= D3DXFillVolumeTexture(tex
, fillfunc_volume
, NULL
);
1095 ok(hr
== D3D_OK
, "D3DXFillTexture returned %#x, expected %#x\n", hr
, D3D_OK
);
1096 hr
= IDirect3DVolumeTexture9_LockBox(tex
, 0, &lock_box
, NULL
, D3DLOCK_READONLY
);
1097 ok(hr
== D3D_OK
, "Couldn't lock the texture, error %#x\n", hr
);
1100 row_pitch
= lock_box
.RowPitch
/ sizeof(WORD
);
1101 slice_pitch
= lock_box
.SlicePitch
/ sizeof(WORD
);
1102 for (z
= 0; z
< 4; z
++)
1104 for (y
= 0; y
< 4; y
++)
1106 for (x
= 0; x
< 4; x
++)
1108 value
= ((WORD
*)lock_box
.pBits
)[z
* slice_pitch
+ y
* row_pitch
+ x
];
1110 v
[1] = value
>> 10 & 0x1f;
1111 v
[2] = value
>> 5 & 0x1f;
1112 v
[3] = value
& 0x1f;
1115 e
[1] = (x
+ 0.5f
) / 4 * 31.0f
+ 0.5f
;
1116 e
[2] = (y
+ 0.5f
) / 4 * 31.0f
+ 0.5f
;
1117 e
[3] = (z
+ 0.5f
) / 4 * 31.0f
+ 0.5f
;
1118 expected
= e
[0] << 15 | e
[1] << 10 | e
[2] << 5 | e
[3];
1120 ok(color_match(v
, e
),
1121 "Texel at (%u, %u, %u) doesn't match: %#x, expected %#x\n",
1122 x
, y
, z
, value
, expected
);
1126 IDirect3DVolumeTexture9_UnlockBox(tex
, 0);
1130 skip("Failed to create texture\n");
1132 IDirect3DVolumeTexture9_Release(tex
);
1135 static void test_D3DXCreateTextureFromFileInMemory(IDirect3DDevice9
*device
)
1138 IDirect3DTexture9
*texture
;
1140 hr
= D3DXCreateTextureFromFileInMemory(device
, dds_16bit
, sizeof(dds_16bit
), &texture
);
1141 ok(hr
== D3D_OK
, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x\n", hr
, D3D_OK
);
1142 if (SUCCEEDED(hr
)) IDirect3DTexture9_Release(texture
);
1144 hr
= D3DXCreateTextureFromFileInMemory(device
, dds_24bit
, sizeof(dds_24bit
), &texture
);
1145 ok(hr
== D3D_OK
, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x\n", hr
, D3D_OK
);
1146 if (SUCCEEDED(hr
)) IDirect3DTexture9_Release(texture
);
1148 hr
= D3DXCreateTextureFromFileInMemory(device
, dds_24bit
, sizeof(dds_24bit
) - 1, &texture
);
1149 ok(hr
== D3DXERR_INVALIDDATA
, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x\n", hr
, D3DXERR_INVALIDDATA
);
1152 static void test_D3DXCreateCubeTextureFromFileInMemory(IDirect3DDevice9
*device
)
1157 IDirect3DCubeTexture9
*cube_texture
;
1158 D3DSURFACE_DESC surface_desc
;
1160 hr
= D3DXCreateCubeTextureFromFileInMemory(NULL
, dds_cube_map
, sizeof(dds_cube_map
), &cube_texture
);
1161 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateCubeTextureFromFileInMemory returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
1163 hr
= D3DXCreateCubeTextureFromFileInMemory(device
, NULL
, sizeof(dds_cube_map
), &cube_texture
);
1164 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateCubeTextureFromFileInMemory returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
1166 hr
= D3DXCreateCubeTextureFromFileInMemory(device
, dds_cube_map
, 0, &cube_texture
);
1167 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateCubeTextureFromFileInMemory returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
1169 hr
= D3DXCreateCubeTextureFromFileInMemory(device
, dds_cube_map
, sizeof(dds_cube_map
), NULL
);
1170 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateCubeTextureFromFileInMemory returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
1172 hr
= D3DXCreateCubeTextureFromFileInMemory(device
, dds_cube_map
, sizeof(dds_cube_map
), &cube_texture
);
1175 levelcount
= IDirect3DCubeTexture9_GetLevelCount(cube_texture
);
1176 todo_wine
ok(levelcount
== 3, "GetLevelCount returned %u, expected 3\n", levelcount
);
1178 hr
= IDirect3DCubeTexture9_GetLevelDesc(cube_texture
, 0, &surface_desc
);
1179 ok(hr
== D3D_OK
, "GetLevelDesc returned %#x, expected %#x\n", hr
, D3D_OK
);
1180 ok(surface_desc
.Width
== 4, "Got width %u, expected 4\n", surface_desc
.Width
);
1181 ok(surface_desc
.Height
== 4, "Got height %u, expected 4\n", surface_desc
.Height
);
1183 hr
= IDirect3DCubeTexture9_GetLevelDesc(cube_texture
, 3, &surface_desc
);
1184 todo_wine
ok(hr
== D3DERR_INVALIDCALL
, "GetLevelDesc returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
1186 ref
= IDirect3DCubeTexture9_Release(cube_texture
);
1187 ok(ref
== 0, "Invalid reference count. Got %u, expected 0\n", ref
);
1188 } else skip("Couldn't create cube texture\n");
1191 static void test_D3DXCreateVolumeTextureFromFileInMemory(IDirect3DDevice9
*device
)
1196 IDirect3DVolumeTexture9
*volume_texture
;
1197 D3DVOLUME_DESC volume_desc
;
1200 hr
= D3DXCreateVolumeTextureFromFileInMemory(NULL
, dds_volume_map
, sizeof(dds_volume_map
), &volume_texture
);
1201 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
1203 hr
= D3DXCreateVolumeTextureFromFileInMemory(device
, NULL
, sizeof(dds_volume_map
), &volume_texture
);
1204 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
1206 hr
= D3DXCreateVolumeTextureFromFileInMemory(device
, dds_volume_map
, 0, &volume_texture
);
1207 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
1209 hr
= D3DXCreateVolumeTextureFromFileInMemory(device
, dds_volume_map
, sizeof(dds_volume_map
), NULL
);
1210 ok(hr
== D3DERR_INVALIDCALL
, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr
, D3DERR_INVALIDCALL
);
1212 hr
= D3DXCreateVolumeTextureFromFileInMemory(device
, dds_volume_map
, sizeof(dds_volume_map
), &volume_texture
);
1215 levelcount
= IDirect3DVolumeTexture9_GetLevelCount(volume_texture
);
1216 ok(levelcount
== 3, "GetLevelCount returned %u, expected 3\n", levelcount
);
1218 hr
= IDirect3DVolumeTexture9_GetLevelDesc(volume_texture
, 0, &volume_desc
);
1219 ok(hr
== D3D_OK
, "GetLevelDesc returend %#x, expected %#x\n", hr
, D3D_OK
);
1220 ok(volume_desc
.Width
== 4, "Got width %u, expected 4\n", volume_desc
.Width
);
1221 ok(volume_desc
.Height
== 4, "Got height %u, expected 4\n", volume_desc
.Height
);
1222 ok(volume_desc
.Depth
== 2, "Got depth %u, expected 2\n", volume_desc
.Depth
);
1224 hr
= IDirect3DVolumeTexture9_GetLevelDesc(volume_texture
, 1, &volume_desc
);
1225 ok(hr
== D3D_OK
, "GetLevelDesc returned %#x, expected %#x\n", hr
, D3D_OK
);
1226 ok(volume_desc
.Width
== 2, "Got width %u, expected 2\n", volume_desc
.Width
);
1227 ok(volume_desc
.Height
== 2, "Got height %u, expected 2\n", volume_desc
.Height
);
1228 ok(volume_desc
.Depth
== 1, "Got depth %u, expected 1\n", volume_desc
.Depth
);
1230 ref
= IDirect3DVolumeTexture9_Release(volume_texture
);
1231 ok(ref
== 0, "Invalid reference count. Got %u, expected 0\n", ref
);
1240 IDirect3DDevice9
*device
;
1241 D3DPRESENT_PARAMETERS d3dpp
;
1244 wnd
= CreateWindow("static", "d3dx9_test", 0, 0, 0, 0, 0, NULL
, NULL
, NULL
, NULL
);
1246 skip("Couldn't create application window\n");
1249 d3d
= Direct3DCreate9(D3D_SDK_VERSION
);
1251 skip("Couldn't create IDirect3D9 object\n");
1256 ZeroMemory(&d3dpp
, sizeof(d3dpp
));
1257 d3dpp
.Windowed
= TRUE
;
1258 d3dpp
.SwapEffect
= D3DSWAPEFFECT_DISCARD
;
1259 hr
= IDirect3D9_CreateDevice(d3d
, D3DADAPTER_DEFAULT
, D3DDEVTYPE_HAL
, wnd
, D3DCREATE_MIXED_VERTEXPROCESSING
, &d3dpp
, &device
);
1261 skip("Failed to create IDirect3DDevice9 object %#x\n", hr
);
1262 IDirect3D9_Release(d3d
);
1267 test_D3DXCheckTextureRequirements(device
);
1268 test_D3DXCheckCubeTextureRequirements(device
);
1269 test_D3DXCheckVolumeTextureRequirements(device
);
1270 test_D3DXCreateTexture(device
);
1271 test_D3DXFilterTexture(device
);
1272 test_D3DXFillTexture(device
);
1273 test_D3DXFillCubeTexture(device
);
1274 test_D3DXFillVolumeTexture(device
);
1275 test_D3DXCreateTextureFromFileInMemory(device
);
1276 test_D3DXCreateCubeTextureFromFileInMemory(device
);
1277 test_D3DXCreateVolumeTextureFromFileInMemory(device
);
1279 IDirect3DDevice9_Release(device
);
1280 IDirect3D9_Release(d3d
);