Add AppDefaults app selection to control panel
[wine/gsoc-2012-control.git] / dlls / d3d9 / tests / texture.c
blob8e8f27b78247389c70f3192da4ec151418592f05
1 /*
2 * Copyright (C) 2006 Henri Verbeet
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
18 #define COBJMACROS
19 #include <d3d9.h>
20 #include "wine/test.h"
22 static HWND create_window(void)
24 WNDCLASS wc = {0};
25 wc.lpfnWndProc = DefWindowProc;
26 wc.lpszClassName = "d3d9_test_wc";
27 RegisterClass(&wc);
29 return CreateWindow("d3d9_test_wc", "d3d9_test",
30 0, 0, 0, 0, 0, 0, 0, 0, 0);
33 static IDirect3DDevice9 *init_d3d9(HMODULE d3d9_handle)
35 IDirect3D9 * (__stdcall * d3d9_create)(UINT SDKVersion) = 0;
36 IDirect3D9 *d3d9_ptr = 0;
37 IDirect3DDevice9 *device_ptr = 0;
38 D3DPRESENT_PARAMETERS present_parameters;
39 HRESULT hr;
41 d3d9_create = (void *)GetProcAddress(d3d9_handle, "Direct3DCreate9");
42 ok(d3d9_create != NULL, "Failed to get address of Direct3DCreate9\n");
43 if (!d3d9_create) return NULL;
45 d3d9_ptr = d3d9_create(D3D_SDK_VERSION);
46 if (!d3d9_ptr)
48 skip("could not create D3D9\n");
49 return NULL;
52 ZeroMemory(&present_parameters, sizeof(present_parameters));
53 present_parameters.Windowed = TRUE;
54 present_parameters.hDeviceWindow = create_window();
55 present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
57 hr = IDirect3D9_CreateDevice(d3d9_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
58 NULL, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device_ptr);
60 if(FAILED(hr))
62 skip("could not create device, IDirect3D9_CreateDevice returned %#x\n", hr);
63 return NULL;
66 return device_ptr;
69 static void test_texture_stage_state(IDirect3DDevice9 *device_ptr, DWORD stage, D3DTEXTURESTAGESTATETYPE type, DWORD expected)
71 DWORD value;
73 HRESULT hr = IDirect3DDevice9_GetTextureStageState(device_ptr, stage, type, &value);
74 ok(SUCCEEDED(hr) && value == expected, "GetTextureStageState (stage %#x, type %#x) returned: hr %#x, value %#x. "
75 "Expected hr %#x, value %#x\n", stage, type, hr, value, D3D_OK, expected);
78 /* Test the default texture stage state values */
79 static void test_texture_stage_states(IDirect3DDevice9 *device_ptr, int num_stages)
81 int i;
82 for (i = 0; i < num_stages; ++i)
84 test_texture_stage_state(device_ptr, i, D3DTSS_COLOROP, i ? D3DTOP_DISABLE : D3DTOP_MODULATE);
85 test_texture_stage_state(device_ptr, i, D3DTSS_COLORARG1, D3DTA_TEXTURE);
86 test_texture_stage_state(device_ptr, i, D3DTSS_COLORARG2, D3DTA_CURRENT);
87 test_texture_stage_state(device_ptr, i, D3DTSS_ALPHAOP, i ? D3DTOP_DISABLE : D3DTOP_SELECTARG1);
88 test_texture_stage_state(device_ptr, i, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
89 test_texture_stage_state(device_ptr, i, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
90 test_texture_stage_state(device_ptr, i, D3DTSS_BUMPENVMAT00, 0);
91 test_texture_stage_state(device_ptr, i, D3DTSS_BUMPENVMAT01, 0);
92 test_texture_stage_state(device_ptr, i, D3DTSS_BUMPENVMAT10, 0);
93 test_texture_stage_state(device_ptr, i, D3DTSS_BUMPENVMAT11, 0);
94 test_texture_stage_state(device_ptr, i, D3DTSS_TEXCOORDINDEX, i);
95 test_texture_stage_state(device_ptr, i, D3DTSS_BUMPENVLSCALE, 0);
96 test_texture_stage_state(device_ptr, i, D3DTSS_BUMPENVLOFFSET, 0);
97 test_texture_stage_state(device_ptr, i, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
98 test_texture_stage_state(device_ptr, i, D3DTSS_COLORARG0, D3DTA_CURRENT);
99 test_texture_stage_state(device_ptr, i, D3DTSS_ALPHAARG0, D3DTA_CURRENT);
100 test_texture_stage_state(device_ptr, i, D3DTSS_RESULTARG, D3DTA_CURRENT);
101 test_texture_stage_state(device_ptr, i, D3DTSS_CONSTANT, 0);
105 static void test_cube_texture_from_pool(IDirect3DDevice9 *device_ptr, DWORD caps, D3DPOOL pool, BOOL need_cap)
107 IDirect3DCubeTexture9 *texture_ptr = NULL;
108 HRESULT hr;
110 hr = IDirect3DDevice9_CreateCubeTexture(device_ptr, 512, 1, 0, D3DFMT_X8R8G8B8, pool, &texture_ptr, NULL);
112 if((caps & D3DPTEXTURECAPS_CUBEMAP) || !need_cap)
113 ok(SUCCEEDED(hr), "hr=0x%.8x\n", hr);
114 else
115 ok(hr == D3DERR_INVALIDCALL, "hr=0x%.8x\n", hr);
117 if(texture_ptr) IDirect3DCubeTexture9_Release(texture_ptr);
120 static void test_cube_texture_mipmap_gen(IDirect3DDevice9 *device_ptr)
122 IDirect3DCubeTexture9 *texture_ptr = NULL;
123 IDirect3D9 *d3d9;
124 HRESULT hr;
126 hr = IDirect3DDevice9_GetDirect3D(device_ptr, &d3d9);
127 ok(hr == D3D_OK, "IDirect3DDevice9_GetDirect3D returned 0x%08x\n", hr);
129 hr = IDirect3D9_CheckDeviceFormat(d3d9, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
130 D3DUSAGE_AUTOGENMIPMAP,
131 D3DRTYPE_CUBETEXTURE, D3DFMT_X8R8G8B8);
132 if(FAILED(hr))
134 skip("No cube mipmap generation support\n");
135 return;
138 /* testing shows that autogenmipmap and rendertarget are mutually exclusive options */
139 hr = IDirect3DDevice9_CreateCubeTexture(device_ptr, 64, 0, (D3DUSAGE_RENDERTARGET |
140 D3DUSAGE_AUTOGENMIPMAP), D3DFMT_X8R8G8B8,
141 D3DPOOL_DEFAULT, &texture_ptr, 0);
142 ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture returned 0x%08x, expected 0x%08x\n",
143 hr, D3D_OK);
144 if (texture_ptr) IDirect3DCubeTexture9_Release(texture_ptr);
145 texture_ptr = NULL;
147 hr = IDirect3DDevice9_CreateCubeTexture(device_ptr, 64, 0,
148 D3DUSAGE_AUTOGENMIPMAP, D3DFMT_X8R8G8B8,
149 D3DPOOL_MANAGED, &texture_ptr, 0);
150 ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed (0x%08x)\n", hr);
151 if (texture_ptr) IDirect3DCubeTexture9_Release(texture_ptr);
152 texture_ptr = NULL;
155 static void test_cube_texture_levels(IDirect3DDevice9 *device_ptr)
157 IDirect3DCubeTexture9 *texture_ptr;
158 DWORD levels;
159 D3DSURFACE_DESC desc;
160 HRESULT hr;
161 IDirect3DSurface9 *surface;
163 hr = IDirect3DDevice9_CreateCubeTexture(device_ptr, 64, 0, 0, D3DFMT_X8R8G8B8,
164 D3DPOOL_DEFAULT, &texture_ptr, NULL);
165 if (FAILED(hr))
167 skip("Couldn't create cube texture\n");
168 return;
171 levels = IDirect3DCubeTexture9_GetLevelCount(texture_ptr);
172 ok(levels == 7, "Got %u levels, expected 7\n", levels);
174 hr = IDirect3DCubeTexture9_GetLevelDesc(texture_ptr, levels - 1, &desc);
175 ok(hr == D3D_OK, "IDirect3DCubeTexture9_GetLevelDesc returned %#x\n", hr);
176 hr = IDirect3DCubeTexture9_GetLevelDesc(texture_ptr, levels, &desc);
177 ok(hr == D3DERR_INVALIDCALL, "IDirect3DCubeTexture9_GetLevelDesc returned %#x\n", hr);
178 hr = IDirect3DCubeTexture9_GetLevelDesc(texture_ptr, levels + 1, &desc);
179 ok(hr == D3DERR_INVALIDCALL, "IDirect3DCubeTexture9_GetLevelDesc returned %#x\n", hr);
181 hr = IDirect3DCubeTexture9_GetCubeMapSurface(texture_ptr, D3DCUBEMAP_FACE_POSITIVE_X,
182 0, &surface);
183 ok(hr == D3D_OK, "IDirect3DCubeTexture9_GetCubeMapSurface returned %#x\n", hr);
184 if (SUCCEEDED(hr)) IDirect3DSurface9_Release(surface);
185 hr = IDirect3DCubeTexture9_GetCubeMapSurface(texture_ptr, D3DCUBEMAP_FACE_NEGATIVE_Z + 1,
186 0, &surface);
187 ok(hr == D3DERR_INVALIDCALL, "IDirect3DCubeTexture9_GetCubeMapSurface returned %#x\n", hr);
188 if (SUCCEEDED(hr)) IDirect3DSurface9_Release(surface);
189 hr = IDirect3DCubeTexture9_GetCubeMapSurface(texture_ptr, D3DCUBEMAP_FACE_POSITIVE_X - 1,
190 0, &surface);
191 ok(hr == D3DERR_INVALIDCALL, "IDirect3DCubeTexture9_GetCubeMapSurface returned %#x\n", hr);
192 if (SUCCEEDED(hr)) IDirect3DSurface9_Release(surface);
194 IDirect3DCubeTexture9_Release(texture_ptr);
197 static void test_cube_textures(IDirect3DDevice9 *device_ptr, DWORD caps)
199 test_cube_texture_from_pool(device_ptr, caps, D3DPOOL_DEFAULT, TRUE);
200 test_cube_texture_from_pool(device_ptr, caps, D3DPOOL_MANAGED, TRUE);
201 test_cube_texture_from_pool(device_ptr, caps, D3DPOOL_SYSTEMMEM, TRUE);
202 test_cube_texture_from_pool(device_ptr, caps, D3DPOOL_SCRATCH, FALSE);
203 test_cube_texture_mipmap_gen(device_ptr);
204 test_cube_texture_levels(device_ptr);
207 static void test_mipmap_gen(IDirect3DDevice9 *device)
209 HRESULT hr;
210 IDirect3D9 *d3d9;
211 IDirect3DTexture9 *texture = NULL;
212 IDirect3DSurface9 *surface;
213 DWORD levels;
214 D3DSURFACE_DESC desc;
215 int i;
216 D3DLOCKED_RECT lr;
218 hr = IDirect3DDevice9_GetDirect3D(device, &d3d9);
219 ok(hr == D3D_OK, "IDirect3DDevice9_GetDirect3D returned %#x\n", hr);
221 hr = IDirect3D9_CheckDeviceFormat(d3d9, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
222 D3DUSAGE_AUTOGENMIPMAP,
223 D3DRTYPE_TEXTURE, D3DFMT_X8R8G8B8);
224 if(FAILED(hr))
226 skip("No mipmap generation support\n");
227 return;
230 /* testing shows that autogenmipmap and rendertarget are mutually exclusive options */
231 hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 0, (D3DUSAGE_RENDERTARGET |
232 D3DUSAGE_AUTOGENMIPMAP), D3DFMT_X8R8G8B8,
233 D3DPOOL_DEFAULT, &texture, 0);
234 ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture returned 0x%08x, expected 0x%08x\n",
235 hr, D3D_OK);
236 if (texture) IDirect3DTexture9_Release(texture);
237 texture = NULL;
239 hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 0, D3DUSAGE_AUTOGENMIPMAP,
240 D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &texture, 0);
241 ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed(%08x)\n", hr);
243 if (SUCCEEDED(hr))
245 D3DTEXTUREFILTERTYPE fltt;
246 fltt = IDirect3DTexture9_GetAutoGenFilterType(texture);
247 ok(D3DTEXF_LINEAR == fltt /* || broken(D3DTEXF_POINT == fltt)*/,
248 "GetAutoGenFilterType returned default %d\n", fltt);
249 hr = IDirect3DTexture9_SetAutoGenFilterType(texture, D3DTEXF_NONE);
250 todo_wine ok(hr == D3DERR_INVALIDCALL, "SetAutoGenFilterType D3DTEXF_NONE returned %08x\n", hr);
251 hr = IDirect3DTexture9_SetAutoGenFilterType(texture, D3DTEXF_ANISOTROPIC);
252 ok(hr == D3D_OK, "SetAutoGenFilterType D3DTEXF_ANISOTROPIC returned %08x\n", hr);
253 fltt = IDirect3DTexture9_GetAutoGenFilterType(texture);
254 ok(D3DTEXF_ANISOTROPIC == fltt, "GetAutoGenFilterType returned %d\n", fltt);
255 hr = IDirect3DTexture9_SetAutoGenFilterType(texture, D3DTEXF_LINEAR);
256 ok(hr == D3D_OK, "SetAutoGenFilterType D3DTEXF_LINEAR returned %08x\n", hr);
258 levels = IDirect3DTexture9_GetLevelCount(texture);
259 ok(levels == 1, "Got %d levels, expected 1\n", levels);
261 for(i = 0; i < 6 /* 64 = 2 ^ 6 */; i++)
263 surface = NULL;
264 hr = IDirect3DTexture9_GetSurfaceLevel(texture, i, &surface);
265 ok(hr == (i == 0 ? D3D_OK : D3DERR_INVALIDCALL),
266 "GetSurfaceLevel on level %d returned %#x\n", i, hr);
267 if(surface) IDirect3DSurface9_Release(surface);
269 hr = IDirect3DTexture9_GetLevelDesc(texture, i, &desc);
270 ok(hr == (i == 0 ? D3D_OK : D3DERR_INVALIDCALL),
271 "GetLevelDesc on level %d returned %#x\n", i, hr);
273 hr = IDirect3DTexture9_LockRect(texture, i, &lr, NULL, 0);
274 ok(hr == (i == 0 ? D3D_OK : D3DERR_INVALIDCALL),
275 "LockRect on level %d returned %#x\n", i, hr);
276 if(SUCCEEDED(hr))
278 hr = IDirect3DTexture9_UnlockRect(texture, i);
279 ok(hr == D3D_OK, "Unlock returned %08x\n", hr);
282 IDirect3DTexture9_Release(texture);
284 hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 2 /* levels */, D3DUSAGE_AUTOGENMIPMAP,
285 D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &texture, 0);
286 ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_CreateTexture(levels = 2) returned %08x\n", hr);
287 hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 6 /* levels */, D3DUSAGE_AUTOGENMIPMAP,
288 D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &texture, 0);
289 ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_CreateTexture(levels = 6) returned %08x\n", hr);
291 hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 1 /* levels */, D3DUSAGE_AUTOGENMIPMAP,
292 D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &texture, 0);
293 ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture(levels = 1) returned %08x\n", hr);
294 levels = IDirect3DTexture9_GetLevelCount(texture);
295 ok(levels == 1, "Got %d levels, expected 1\n", levels);
296 IDirect3DTexture9_Release(texture);
299 static void test_filter(IDirect3DDevice9 *device) {
300 HRESULT hr;
301 IDirect3DTexture9 *texture;
302 IDirect3D9 *d3d9;
303 DWORD passes = 0;
304 unsigned int i;
305 struct filter_tests {
306 DWORD magfilter, minfilter, mipfilter;
307 BOOL has_texture;
308 HRESULT result;
309 } tests[] = {
310 { D3DTEXF_NONE, D3DTEXF_NONE, D3DTEXF_NONE, FALSE, D3DERR_UNSUPPORTEDTEXTUREFILTER },
311 { D3DTEXF_POINT, D3DTEXF_NONE, D3DTEXF_NONE, FALSE, D3DERR_UNSUPPORTEDTEXTUREFILTER },
312 { D3DTEXF_NONE, D3DTEXF_POINT, D3DTEXF_NONE, FALSE, D3DERR_UNSUPPORTEDTEXTUREFILTER },
313 { D3DTEXF_POINT, D3DTEXF_POINT, D3DTEXF_NONE, FALSE, D3D_OK },
314 { D3DTEXF_POINT, D3DTEXF_POINT, D3DTEXF_POINT, FALSE, D3D_OK },
316 { D3DTEXF_NONE, D3DTEXF_NONE, D3DTEXF_NONE, TRUE, D3DERR_UNSUPPORTEDTEXTUREFILTER },
317 { D3DTEXF_POINT, D3DTEXF_NONE, D3DTEXF_NONE, TRUE, D3DERR_UNSUPPORTEDTEXTUREFILTER },
318 { D3DTEXF_POINT, D3DTEXF_POINT, D3DTEXF_NONE, TRUE, D3D_OK },
319 { D3DTEXF_POINT, D3DTEXF_POINT, D3DTEXF_POINT, TRUE, D3D_OK },
321 { D3DTEXF_NONE, D3DTEXF_NONE, D3DTEXF_NONE, TRUE, D3DERR_UNSUPPORTEDTEXTUREFILTER },
322 { D3DTEXF_LINEAR, D3DTEXF_NONE, D3DTEXF_NONE, TRUE, D3DERR_UNSUPPORTEDTEXTUREFILTER },
323 { D3DTEXF_LINEAR, D3DTEXF_POINT, D3DTEXF_NONE, TRUE, E_FAIL },
324 { D3DTEXF_POINT, D3DTEXF_LINEAR, D3DTEXF_NONE, TRUE, E_FAIL },
325 { D3DTEXF_POINT, D3DTEXF_POINT, D3DTEXF_LINEAR, TRUE, E_FAIL },
329 hr = IDirect3DDevice9_GetDirect3D(device, &d3d9);
330 ok(hr == D3D_OK, "IDirect3DDevice9_GetDirect3D(levels = 1) returned %08x\n", hr);
331 hr = IDirect3D9_CheckDeviceFormat(d3d9, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0,
332 D3DRTYPE_TEXTURE, D3DFMT_A32B32G32R32F);
333 if(FAILED(hr)) {
334 skip("D3DFMT_A32B32G32R32F not supported\n");
335 goto out;
337 hr = IDirect3D9_CheckDeviceFormat(d3d9, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_QUERY_FILTER,
338 D3DRTYPE_TEXTURE, D3DFMT_A32B32G32R32F);
339 if(SUCCEEDED(hr)) {
340 skip("D3DFMT_A32B32G32R32F supports filtering\n");
341 goto out;
344 hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 0, 0, D3DFMT_A32B32G32R32F,
345 D3DPOOL_MANAGED, &texture, 0);
346 ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture returned %08x\n", hr);
348 /* Needed for ValidateDevice */
349 hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
350 ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF returned %08x\n", hr);
352 for(i = 0; i < (sizeof(tests) / sizeof(tests[0])); i++) {
353 if(tests[i].has_texture) {
354 hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *) texture);
355 ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture returned %08x\n", hr);
356 } else {
357 hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
358 ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture returned %08x\n", hr);
361 hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, tests[i].magfilter);
362 ok(hr == D3D_OK, "IDirect3DDevice9_SetSamplerState returned %08x\n", hr);
363 hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MINFILTER, tests[i].minfilter);
364 ok(hr == D3D_OK, "IDirect3DDevice9_SetSamplerState returned %08x\n", hr);
365 hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, tests[i].mipfilter);
366 ok(hr == D3D_OK, "IDirect3DDevice9_SetSamplerState returned %08x\n", hr);
368 passes = 0xdeadbeef;
369 hr = IDirect3DDevice9_ValidateDevice(device, &passes);
370 ok(hr == tests[i].result, "ValidateDevice failed: Texture %s, min %u, mag %u, mip %u. Got %08x, expected %08x\n",
371 tests[i].has_texture ? "TRUE" : "FALSE", tests[i].magfilter, tests[i].minfilter,
372 tests[i].mipfilter, hr, tests[i].result);
373 if(SUCCEEDED(hr)) {
374 ok(passes != 0, "ValidateDevice succeeded, passes is %u\n", passes);
375 } else {
376 ok(passes == 0xdeadbeef, "ValidateDevice failed, passes is %u\n", passes);
380 hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
381 ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTexture returned %#x.\n", hr);
382 IDirect3DTexture9_Release(texture);
384 out:
385 IDirect3D9_Release(d3d9);
388 static void test_gettexture(IDirect3DDevice9 *device) {
389 HRESULT hr;
390 IDirect3DBaseTexture9 *texture = (IDirect3DBaseTexture9 *) 0xdeadbeef;
392 hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
393 ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture failed, hr = 0x%08x\n", hr);
394 hr = IDirect3DDevice9_GetTexture(device, 0, &texture);
395 ok(hr == D3D_OK, "IDirect3DDevice9_GetTexture failed, hr = 0x%08x\n", hr);
396 ok(texture == NULL, "Texture returned is %p, expected NULL\n", texture);
399 static void test_lod(IDirect3DDevice9 *device)
401 HRESULT hr;
402 DWORD ret;
403 IDirect3DTexture9 *texture;
405 hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 3, 0, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT,
406 &texture, NULL);
407 ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed with %08x\n", hr);
409 /* SetLOD is only supported on D3DPOOL_MANAGED textures, but it doesn't return a HRESULT,
410 * so it can't return a normal error. Instead, the call is simply ignored
412 ret = IDirect3DTexture9_SetLOD(texture, 0);
413 ok(ret == 0, "IDirect3DTexture9_SetLOD returned %u, expected 0\n", ret);
414 ret = IDirect3DTexture9_SetLOD(texture, 1);
415 ok(ret == 0, "IDirect3DTexture9_SetLOD returned %u, expected 0\n", ret);
416 ret = IDirect3DTexture9_SetLOD(texture, 2);
417 ok(ret == 0, "IDirect3DTexture9_SetLOD returned %u, expected 0\n", ret);
418 ret = IDirect3DTexture9_GetLOD(texture);
419 ok(ret == 0, "IDirect3DTexture9_GetLOD returned %u, expected 0\n", ret);
421 IDirect3DTexture9_Release(texture);
424 START_TEST(texture)
426 D3DCAPS9 caps;
427 HMODULE d3d9_handle;
428 IDirect3DDevice9 *device_ptr;
429 ULONG refcount;
431 d3d9_handle = LoadLibraryA("d3d9.dll");
432 if (!d3d9_handle)
434 skip("Could not load d3d9.dll\n");
435 return;
438 device_ptr = init_d3d9(d3d9_handle);
439 if (!device_ptr) return;
441 IDirect3DDevice9_GetDeviceCaps(device_ptr, &caps);
443 test_texture_stage_states(device_ptr, caps.MaxTextureBlendStages);
444 test_cube_textures(device_ptr, caps.TextureCaps);
445 test_mipmap_gen(device_ptr);
446 test_filter(device_ptr);
447 test_gettexture(device_ptr);
448 test_lod(device_ptr);
450 refcount = IDirect3DDevice9_Release(device_ptr);
451 ok(!refcount, "Device has %u references left\n", refcount);