2 * Copyright (C) 2005 Henri Verbeet
3 * Copyright (C) 2007 Stefan Dösinger(for CodeWeavers)
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 /* See comment in dlls/d3d9/tests/visual.c for general guidelines */
25 #include "wine/test.h"
27 static HMODULE d3d8_handle
= 0;
29 static HWND
create_window(void)
33 wc
.lpfnWndProc
= &DefWindowProc
;
34 wc
.lpszClassName
= "d3d8_test_wc";
37 ret
= CreateWindow("d3d8_test_wc", "d3d8_test",
38 WS_MAXIMIZE
| WS_VISIBLE
| WS_CAPTION
, 0, 0, 640, 480, 0, 0, 0, 0);
42 static DWORD
getPixelColor(IDirect3DDevice8
*device
, UINT x
, UINT y
)
45 IDirect3DSurface8
*surf
;
46 IDirect3DTexture8
*tex
;
48 D3DLOCKED_RECT lockedRect
;
49 RECT rectToLock
= {x
, y
, x
+1, y
+1};
51 hr
= IDirect3DDevice8_CreateTexture(device
, 640, 480, 1 /* Levels */, 0 /* usage */, D3DFMT_A8R8G8B8
, D3DPOOL_SYSTEMMEM
, &tex
);
52 if(FAILED(hr
) || !tex
) /* This is not a test */
54 trace("Can't create an offscreen plain surface to read the render target data, hr=%#08x\n", hr
);
57 hr
= IDirect3DTexture8_GetSurfaceLevel(tex
, 0, &surf
);
58 if(FAILED(hr
) || !tex
) /* This is not a test */
60 trace("Can't get surface from texture, hr=%#08x\n", hr
);
65 hr
= IDirect3DDevice8_GetFrontBuffer(device
, surf
);
68 trace("Can't read the front buffer data, hr=%#08x\n", hr
);
73 hr
= IDirect3DSurface8_LockRect(surf
, &lockedRect
, &rectToLock
, D3DLOCK_READONLY
);
76 trace("Can't lock the offscreen surface, hr=%#08x\n", hr
);
80 /* Remove the X channel for now. DirectX and OpenGL have different ideas how to treat it apparently, and it isn't
81 * really important for these tests
83 ret
= ((DWORD
*) lockedRect
.pBits
)[0] & 0x00ffffff;
84 hr
= IDirect3DSurface8_UnlockRect(surf
);
87 trace("Can't unlock the offscreen surface, hr=%#08x\n", hr
);
91 if(surf
) IDirect3DSurface8_Release(surf
);
92 if(tex
) IDirect3DTexture8_Release(tex
);
96 static IDirect3DDevice8
*init_d3d8(void)
98 IDirect3D8
* (__stdcall
* d3d8_create
)(UINT SDKVersion
) = 0;
99 IDirect3D8
*d3d8_ptr
= 0;
100 IDirect3DDevice8
*device_ptr
= 0;
101 D3DPRESENT_PARAMETERS present_parameters
;
104 d3d8_create
= (void *)GetProcAddress(d3d8_handle
, "Direct3DCreate8");
105 ok(d3d8_create
!= NULL
, "Failed to get address of Direct3DCreate8\n");
106 if (!d3d8_create
) return NULL
;
108 d3d8_ptr
= d3d8_create(D3D_SDK_VERSION
);
109 ok(d3d8_ptr
!= NULL
, "Failed to create IDirect3D8 object\n");
110 if (!d3d8_ptr
) return NULL
;
112 ZeroMemory(&present_parameters
, sizeof(present_parameters
));
113 present_parameters
.Windowed
= FALSE
;
114 present_parameters
.hDeviceWindow
= create_window();
115 present_parameters
.SwapEffect
= D3DSWAPEFFECT_DISCARD
;
116 present_parameters
.BackBufferWidth
= 640;
117 present_parameters
.BackBufferHeight
= 480;
118 present_parameters
.BackBufferFormat
= D3DFMT_X8R8G8B8
;
119 present_parameters
.EnableAutoDepthStencil
= TRUE
;
120 present_parameters
.AutoDepthStencilFormat
= D3DFMT_D16
;
122 hr
= IDirect3D8_CreateDevice(d3d8_ptr
, D3DADAPTER_DEFAULT
, D3DDEVTYPE_HAL
, present_parameters
.hDeviceWindow
, D3DCREATE_SOFTWARE_VERTEXPROCESSING
, &present_parameters
, &device_ptr
);
123 ok(hr
== D3D_OK
|| hr
== D3DERR_INVALIDCALL
, "IDirect3D_CreateDevice returned: %#08x\n", hr
);
141 static void lighting_test(IDirect3DDevice8
*device
)
144 DWORD fvf
= D3DFVF_XYZ
| D3DFVF_DIFFUSE
;
145 DWORD nfvf
= D3DFVF_XYZ
| D3DFVF_DIFFUSE
| D3DFVF_NORMAL
;
148 float mat
[16] = { 1.0f
, 0.0f
, 0.0f
, 0.0f
,
149 0.0f
, 1.0f
, 0.0f
, 0.0f
,
150 0.0f
, 0.0f
, 1.0f
, 0.0f
,
151 0.0f
, 0.0f
, 0.0f
, 1.0f
};
153 struct vertex unlitquad
[] =
155 {-1.0f
, -1.0f
, 0.1f
, 0xffff0000},
156 {-1.0f
, 0.0f
, 0.1f
, 0xffff0000},
157 { 0.0f
, 0.0f
, 0.1f
, 0xffff0000},
158 { 0.0f
, -1.0f
, 0.1f
, 0xffff0000},
160 struct vertex litquad
[] =
162 {-1.0f
, 0.0f
, 0.1f
, 0xff00ff00},
163 {-1.0f
, 1.0f
, 0.1f
, 0xff00ff00},
164 { 0.0f
, 1.0f
, 0.1f
, 0xff00ff00},
165 { 0.0f
, 0.0f
, 0.1f
, 0xff00ff00},
167 struct nvertex unlitnquad
[] =
169 { 0.0f
, -1.0f
, 0.1f
, 1.0f
, 1.0f
, 1.0f
, 0xff0000ff},
170 { 0.0f
, 0.0f
, 0.1f
, 1.0f
, 1.0f
, 1.0f
, 0xff0000ff},
171 { 1.0f
, 0.0f
, 0.1f
, 1.0f
, 1.0f
, 1.0f
, 0xff0000ff},
172 { 1.0f
, -1.0f
, 0.1f
, 1.0f
, 1.0f
, 1.0f
, 0xff0000ff},
174 struct nvertex litnquad
[] =
176 { 0.0f
, 0.0f
, 0.1f
, 1.0f
, 1.0f
, 1.0f
, 0xffffff00},
177 { 0.0f
, 1.0f
, 0.1f
, 1.0f
, 1.0f
, 1.0f
, 0xffffff00},
178 { 1.0f
, 1.0f
, 0.1f
, 1.0f
, 1.0f
, 1.0f
, 0xffffff00},
179 { 1.0f
, 0.0f
, 0.1f
, 1.0f
, 1.0f
, 1.0f
, 0xffffff00},
181 WORD Indices
[] = {0, 1, 2, 2, 3, 0};
183 hr
= IDirect3DDevice8_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0xffffffff, 0.0, 0);
184 ok(hr
== D3D_OK
, "IDirect3DDevice8_Clear failed with %#08x\n", hr
);
186 /* Setup some states that may cause issues */
187 hr
= IDirect3DDevice8_SetTransform(device
, D3DTS_WORLDMATRIX(0), (D3DMATRIX
*) mat
);
188 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetTransform returned %#08x\n", hr
);
189 hr
= IDirect3DDevice8_SetTransform(device
, D3DTS_VIEW
, (D3DMATRIX
*)mat
);
190 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetTransform returned %#08x\n", hr
);
191 hr
= IDirect3DDevice8_SetTransform(device
, D3DTS_PROJECTION
, (D3DMATRIX
*) mat
);
192 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetTransform returned %#08x\n", hr
);
193 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_CLIPPING
, FALSE
);
194 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState returned %#08x\n", hr
);
195 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_ZENABLE
, FALSE
);
196 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState returned %#08x\n", hr
);
197 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_FOGENABLE
, FALSE
);
198 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState returned %#08x\n", hr
);
199 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_STENCILENABLE
, FALSE
);
200 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState returned %#08x\n", hr
);
201 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_ALPHATESTENABLE
, FALSE
);
202 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState returned %#08x\n", hr
);
203 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_ALPHABLENDENABLE
, FALSE
);
204 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState returned %#08x\n", hr
);
205 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_CULLMODE
, D3DCULL_NONE
);
206 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState failed with %#08x\n", hr
);
207 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_COLORWRITEENABLE
, D3DCOLORWRITEENABLE_RED
| D3DCOLORWRITEENABLE_GREEN
| D3DCOLORWRITEENABLE_BLUE
);
208 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState failed with %#08x\n", hr
);
210 hr
= IDirect3DDevice8_SetVertexShader(device
, fvf
);
211 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetVertexShader returned %#08x\n", hr
);
213 hr
= IDirect3DDevice8_BeginScene(device
);
214 ok(hr
== D3D_OK
, "IDirect3DDevice8_BeginScene failed with %#08x\n", hr
);
217 /* No lights are defined... That means, lit vertices should be entirely black */
218 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_LIGHTING
, FALSE
);
219 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState returned %#08x\n", hr
);
220 hr
= IDirect3DDevice8_DrawIndexedPrimitiveUP(device
, D3DPT_TRIANGLELIST
, 0 /* MinIndex */, 4 /* NumVerts */,
221 2 /*PrimCount */, Indices
, D3DFMT_INDEX16
, unlitquad
, sizeof(unlitquad
[0]));
222 ok(hr
== D3D_OK
, "IDirect3DDevice8_DrawIndexedPrimitiveUP failed with %#08x\n", hr
);
224 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_LIGHTING
, TRUE
);
225 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState returned %#08x\n", hr
);
226 hr
= IDirect3DDevice8_DrawIndexedPrimitiveUP(device
, D3DPT_TRIANGLELIST
, 0 /* MinIndex */, 4 /* NumVerts */,
227 2 /*PrimCount */, Indices
, D3DFMT_INDEX16
, litquad
, sizeof(litquad
[0]));
228 ok(hr
== D3D_OK
, "IDirect3DDevice8_DrawIndexedPrimitiveUP failed with %#08x\n", hr
);
230 hr
= IDirect3DDevice8_SetVertexShader(device
, nfvf
);
231 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetVertexShader failed with %#08x\n", hr
);
233 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_LIGHTING
, FALSE
);
234 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState returned %#08x\n", hr
);
235 hr
= IDirect3DDevice8_DrawIndexedPrimitiveUP(device
, D3DPT_TRIANGLELIST
, 0 /* MinIndex */, 4 /* NumVerts */,
236 2 /*PrimCount */, Indices
, D3DFMT_INDEX16
, unlitnquad
, sizeof(unlitnquad
[0]));
237 ok(hr
== D3D_OK
, "IDirect3DDevice8_DrawIndexedPrimitiveUP failed with %#08x\n", hr
);
239 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_LIGHTING
, TRUE
);
240 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState returned %#08x\n", hr
);
241 hr
= IDirect3DDevice8_DrawIndexedPrimitiveUP(device
, D3DPT_TRIANGLELIST
, 0 /* MinIndex */, 4 /* NumVerts */,
242 2 /*PrimCount */, Indices
, D3DFMT_INDEX16
, litnquad
, sizeof(litnquad
[0]));
243 ok(hr
== D3D_OK
, "IDirect3DDevice8_DrawIndexedPrimitiveUP failed with %#08x\n", hr
);
245 IDirect3DDevice8_EndScene(device
);
246 ok(hr
== D3D_OK
, "IDirect3DDevice8_EndScene failed with %#08x\n", hr
);
249 IDirect3DDevice8_Present(device
, NULL
, NULL
, NULL
, NULL
);
251 color
= getPixelColor(device
, 160, 360); /* lower left quad - unlit without normals */
252 ok(color
== 0x00ff0000, "Unlit quad without normals has color %08x\n", color
);
253 color
= getPixelColor(device
, 160, 120); /* upper left quad - lit without normals */
254 ok(color
== 0x00000000, "Lit quad without normals has color %08x\n", color
);
255 color
= getPixelColor(device
, 480, 360); /* lower left quad - unlit width normals */
256 ok(color
== 0x000000ff, "Unlit quad width normals has color %08x\n", color
);
257 color
= getPixelColor(device
, 480, 120); /* upper left quad - lit width normals */
258 ok(color
== 0x00000000, "Lit quad width normals has color %08x\n", color
);
260 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_LIGHTING
, FALSE
);
261 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState returned %#08x\n", hr
);
264 static void clear_test(IDirect3DDevice8
*device
)
266 /* Tests the correctness of clearing parameters */
272 hr
= IDirect3DDevice8_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0xffffffff, 0.0, 0);
273 ok(hr
== D3D_OK
, "IDirect3DDevice8_Clear failed with %#08x\n", hr
);
275 /* Positive x, negative y */
281 /* Positive x, positive y */
286 /* Clear 2 rectangles with one call. Shows that a positive value is returned, but the negative rectangle
287 * is ignored, the positive is still cleared afterwards
289 hr
= IDirect3DDevice8_Clear(device
, 2, rect
, D3DCLEAR_TARGET
, 0xffff0000, 0.0, 0);
290 ok(hr
== D3D_OK
, "IDirect3DDevice8_Clear failed with %#08x\n", hr
);
292 /* negative x, negative y */
293 rect_negneg
.x1
= 640;
294 rect_negneg
.x1
= 240;
295 rect_negneg
.x2
= 320;
297 hr
= IDirect3DDevice8_Clear(device
, 1, &rect_negneg
, D3DCLEAR_TARGET
, 0xff00ff00, 0.0, 0);
298 ok(hr
== D3D_OK
, "IDirect3DDevice8_Clear failed with %#08x\n", hr
);
300 IDirect3DDevice8_Present(device
, NULL
, NULL
, NULL
, NULL
);
302 color
= getPixelColor(device
, 160, 360); /* lower left quad */
303 ok(color
== 0x00ffffff, "Clear rectangle 3(pos, neg) has color %08x\n", color
);
304 color
= getPixelColor(device
, 160, 120); /* upper left quad */
305 ok(color
== 0x00ff0000, "Clear rectangle 1(pos, pos) has color %08x\n", color
);
306 color
= getPixelColor(device
, 480, 360); /* lower right quad */
307 ok(color
== 0x00ffffff, "Clear rectangle 4(NULL) has color %08x\n", color
);
308 color
= getPixelColor(device
, 480, 120); /* upper right quad */
309 ok(color
== 0x00ffffff, "Clear rectangle 4(neg, neg) has color %08x\n", color
);
324 static void fog_test(IDirect3DDevice8
*device
)
328 float start
= 0.0, end
= 1.0;
330 /* Gets full z based fog with linear fog, no fog with specular color */
331 struct sVertex unstransformed_1
[] = {
332 {-1, -1, 0.1f
, 0xFFFF0000, 0xFF000000 },
333 {-1, 0, 0.1f
, 0xFFFF0000, 0xFF000000 },
334 { 0, 0, 0.1f
, 0xFFFF0000, 0xFF000000 },
335 { 0, -1, 0.1f
, 0xFFFF0000, 0xFF000000 },
337 /* Ok, I am too lazy to deal with transform matrices */
338 struct sVertex unstransformed_2
[] = {
339 {-1, 0, 1.0f
, 0xFFFF0000, 0xFF000000 },
340 {-1, 1, 1.0f
, 0xFFFF0000, 0xFF000000 },
341 { 0, 1, 1.0f
, 0xFFFF0000, 0xFF000000 },
342 { 0, 0, 1.0f
, 0xFFFF0000, 0xFF000000 },
344 /* Untransformed ones. Give them a different diffuse color to make the test look
345 * nicer. It also makes making sure that they are drawn correctly easier.
347 struct sVertexT transformed_1
[] = {
348 {320, 0, 1.0f
, 1.0f
, 0xFFFFFF00, 0xFF000000 },
349 {640, 0, 1.0f
, 1.0f
, 0xFFFFFF00, 0xFF000000 },
350 {640, 240, 1.0f
, 1.0f
, 0xFFFFFF00, 0xFF000000 },
351 {320, 240, 1.0f
, 1.0f
, 0xFFFFFF00, 0xFF000000 },
353 struct sVertexT transformed_2
[] = {
354 {320, 240, 1.0f
, 1.0f
, 0xFFFFFF00, 0xFF000000 },
355 {640, 240, 1.0f
, 1.0f
, 0xFFFFFF00, 0xFF000000 },
356 {640, 480, 1.0f
, 1.0f
, 0xFFFFFF00, 0xFF000000 },
357 {320, 480, 1.0f
, 1.0f
, 0xFFFFFF00, 0xFF000000 },
359 WORD Indices
[] = {0, 1, 2, 2, 3, 0};
361 hr
= IDirect3DDevice8_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0xffff00ff, 0.0, 0);
362 ok(hr
== D3D_OK
, "IDirect3DDevice8_Clear returned %#08x\n", hr
);
364 /* Setup initial states: No lighting, fog on, fog color */
365 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_LIGHTING
, FALSE
);
366 ok(hr
== D3D_OK
, "Turning off lighting returned %#08x\n", hr
);
367 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_FOGENABLE
, TRUE
);
368 ok(hr
== D3D_OK
, "Turning on fog calculations returned %#08x\n", hr
);
369 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_FOGCOLOR
, 0xFF00FF00 /* A nice green */);
370 ok(hr
== D3D_OK
, "Turning on fog calculations returned %#08x\n", hr
);
372 /* First test: Both table fog and vertex fog off */
373 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_FOGTABLEMODE
, D3DFOG_NONE
);
374 ok(hr
== D3D_OK
, "Turning off table fog returned %#08x\n", hr
);
375 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_FOGVERTEXMODE
, D3DFOG_NONE
);
376 ok(hr
== D3D_OK
, "Turning off table fog returned %#08x\n", hr
);
378 /* Start = 0, end = 1. Should be default, but set them */
379 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_FOGSTART
, *((DWORD
*) &start
));
380 ok(hr
== D3D_OK
, "Setting fog start returned %#08x\n", hr
);
381 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_FOGEND
, *((DWORD
*) &end
));
382 ok(hr
== D3D_OK
, "Setting fog start returned %#08x\n", hr
);
384 if(IDirect3DDevice8_BeginScene(device
) == D3D_OK
)
386 hr
= IDirect3DDevice8_SetVertexShader(device
, D3DFVF_XYZ
| D3DFVF_DIFFUSE
| D3DFVF_SPECULAR
);
387 ok( hr
== D3D_OK
, "SetVertexShader returned %#08x\n", hr
);
388 /* Untransformed, vertex fog = NONE, table fog = NONE: Read the fog weighting from the specular color */
389 hr
= IDirect3DDevice8_DrawIndexedPrimitiveUP(device
, D3DPT_TRIANGLELIST
, 0 /* MinIndex */, 4 /* NumVerts */,
390 2 /*PrimCount */, Indices
, D3DFMT_INDEX16
, unstransformed_1
,
391 sizeof(unstransformed_1
[0]));
392 ok(hr
== D3D_OK
, "DrawIndexedPrimitiveUP returned %#08x\n", hr
);
394 /* That makes it use the Z value */
395 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_FOGVERTEXMODE
, D3DFOG_LINEAR
);
396 ok(hr
== D3D_OK
, "Turning off table fog returned %#08x\n", hr
);
397 /* Untransformed, vertex fog != none (or table fog != none):
398 * Use the Z value as input into the equation
400 hr
= IDirect3DDevice8_DrawIndexedPrimitiveUP(device
, D3DPT_TRIANGLELIST
, 0 /* MinIndex */, 4 /* NumVerts */,
401 2 /*PrimCount */, Indices
, D3DFMT_INDEX16
, unstransformed_2
,
402 sizeof(unstransformed_1
[0]));
403 ok(hr
== D3D_OK
, "DrawIndexedPrimitiveUP returned %#08x\n", hr
);
405 /* transformed verts */
406 hr
= IDirect3DDevice8_SetVertexShader(device
, D3DFVF_XYZRHW
| D3DFVF_DIFFUSE
| D3DFVF_SPECULAR
);
407 ok( hr
== D3D_OK
, "SetVertexShader returned %#08x\n", hr
);
408 /* Transformed, vertex fog != NONE, pixel fog == NONE: Use specular color alpha component */
409 hr
= IDirect3DDevice8_DrawIndexedPrimitiveUP(device
, D3DPT_TRIANGLELIST
, 0 /* MinIndex */, 4 /* NumVerts */,
410 2 /*PrimCount */, Indices
, D3DFMT_INDEX16
, transformed_1
,
411 sizeof(transformed_1
[0]));
412 ok(hr
== D3D_OK
, "DrawIndexedPrimitiveUP returned %#08x\n", hr
);
414 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_FOGTABLEMODE
, D3DFOG_LINEAR
);
415 ok( hr
== D3D_OK
, "Setting fog table mode to D3DFOG_LINEAR returned %#08x\n", hr
);
416 /* Transformed, table fog != none, vertex anything: Use Z value as input to the fog
419 hr
= IDirect3DDevice8_DrawIndexedPrimitiveUP(device
, D3DPT_TRIANGLELIST
, 0 /* MinIndex */, 4 /* NumVerts */,
420 2 /*PrimCount */, Indices
, D3DFMT_INDEX16
, transformed_2
,
421 sizeof(transformed_2
[0]));
423 hr
= IDirect3DDevice8_EndScene(device
);
424 ok(hr
== D3D_OK
, "EndScene returned %#08x\n", hr
);
428 ok(FALSE
, "BeginScene failed\n");
431 IDirect3DDevice8_Present(device
, NULL
, NULL
, NULL
, NULL
);
432 color
= getPixelColor(device
, 160, 360);
433 ok(color
== 0x00FF0000, "Untransformed vertex with no table or vertex fog has color %08x\n", color
);
434 color
= getPixelColor(device
, 160, 120);
435 ok(color
== 0x0000FF00, "Untransformed vertex with linear vertex fog has color %08x\n", color
);
436 color
= getPixelColor(device
, 480, 120);
437 ok(color
== 0x00FFFF00, "Transformed vertex with linear vertex fog has color %08x\n", color
);
438 color
= getPixelColor(device
, 480, 360);
439 ok(color
== 0x0000FF00, "Transformed vertex with linear table fog has color %08x\n", color
);
441 /* Turn off the fog master switch to avoid confusing other tests */
442 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_FOGENABLE
, FALSE
);
443 ok(hr
== D3D_OK
, "Turning off fog calculations returned %#08x\n", hr
);
446 static void present_test(IDirect3DDevice8
*device
)
448 struct vertex quad
[] =
450 {-1.0f
, -1.0f
, 0.9f
, 0xffff0000},
451 {-1.0f
, 1.0f
, 0.9f
, 0xffff0000},
452 { 1.0f
, -1.0f
, 0.1f
, 0xffff0000},
453 { 1.0f
, 1.0f
, 0.1f
, 0xffff0000},
458 /* Does the Present clear the depth stencil? Clear the depth buffer with some value != 0,
459 * then call Present. Then clear the color buffer to make sure it has some defined content
460 * after the Present with D3DSWAPEFFECT_DISCARD. After that draw a plane that is somewhere cut
461 * by the depth value.
463 hr
= IDirect3DDevice8_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
| D3DCLEAR_ZBUFFER
, 0xffffffff, 0.75, 0);
464 ok(hr
== D3D_OK
, "IDirect3DDevice8_Clear returned %s\n", DXGetErrorString8(hr
));
465 hr
= IDirect3DDevice8_Present(device
, NULL
, NULL
, NULL
, NULL
);
466 hr
= IDirect3DDevice8_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0xffffffff, 0.4, 0);
468 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_ZENABLE
, D3DZB_TRUE
);
469 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr
));
470 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_ZFUNC
, D3DCMP_GREATER
);
471 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr
));
472 hr
= IDirect3DDevice8_SetVertexShader(device
, D3DFVF_XYZ
| D3DFVF_DIFFUSE
);
473 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetFVF returned %s\n", DXGetErrorString8(hr
));
475 hr
= IDirect3DDevice8_BeginScene(device
);
476 ok(hr
== D3D_OK
, "IDirect3DDevice8_BeginScene failed with %s\n", DXGetErrorString8(hr
));
479 /* No lights are defined... That means, lit vertices should be entirely black */
480 hr
= IDirect3DDevice8_DrawPrimitiveUP(device
, D3DPT_TRIANGLESTRIP
, 2 /*PrimCount */, quad
, sizeof(quad
[0]));
481 ok(hr
== D3D_OK
, "IDirect3DDevice8_DrawIndexedPrimitiveUP failed with %s\n", DXGetErrorString8(hr
));
483 hr
= IDirect3DDevice8_EndScene(device
);
484 ok(hr
== D3D_OK
, "IDirect3DDevice8_EndScene failed with %s\n", DXGetErrorString8(hr
));
487 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_ZENABLE
, D3DZB_FALSE
);
488 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr
));
490 hr
= IDirect3DDevice8_Present(device
, NULL
, NULL
, NULL
, NULL
);
491 ok(SUCCEEDED(hr
), "Present failed (%#08x)\n", hr
);
492 color
= getPixelColor(device
, 512, 240);
493 ok(color
== 0x00ffffff, "Present failed: Got color 0x%08x, expected 0x00ffffff.\n", color
);
494 color
= getPixelColor(device
, 64, 240);
495 ok(color
== 0x00ff0000, "Present failed: Got color 0x%08x, expected 0x00ff0000.\n", color
);
498 static void test_rcp_rsq(IDirect3DDevice8
*device
)
503 unsigned char c1
, c2
, c3
;
504 float constant
[4] = {1.0, 1.0, 1.0, 2.0};
506 static const float quad
[][3] = {
507 {-1.0f
, -1.0f
, 0.0f
},
509 { 1.0f
, -1.0f
, 0.0f
},
513 const DWORD rcp_test
[] = {
514 0xfffe0101, /* vs.1.1 */
516 0x0009fffe, 0x30303030, 0x30303030, /* Shaders have to have a minimal size. */
517 0x30303030, 0x30303030, 0x30303030, /* Add a filler comment. Usually D3DX8's*/
518 0x30303030, 0x30303030, 0x30303030, /* version comment makes the shader big */
519 0x00303030, /* enough to make windows happy */
521 0x00000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */
522 0x00000006, 0xd00f0000, 0xa0e40000, /* rcp oD0, c0 */
526 const DWORD rsq_test
[] = {
527 0xfffe0101, /* vs.1.1 */
529 0x0009fffe, 0x30303030, 0x30303030, /* Shaders have to have a minimal size. */
530 0x30303030, 0x30303030, 0x30303030, /* Add a filler comment. Usually D3DX8's*/
531 0x30303030, 0x30303030, 0x30303030, /* version comment makes the shader big */
532 0x00303030, /* enough to make windows happy */
534 0x00000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */
535 0x00000007, 0xd00f0000, 0xa0e40000, /* rsq oD0, c0 */
542 D3DVSD_REG(D3DVSDE_POSITION
, D3DVSDT_FLOAT3
), /* D3DVSDE_POSITION, Register v0 */
546 hr
= IDirect3DDevice8_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
| D3DCLEAR_ZBUFFER
, 0xff800080, 0.0, 0);
547 ok(hr
== D3D_OK
, "IDirect3DDevice8_Clear failed with %#08x\n", hr
);
549 hr
= IDirect3DDevice8_CreateVertexShader(device
, decl
, rcp_test
, &shader
, 0);
550 ok(hr
== D3D_OK
, "IDirect3DDevice8_CreateVertexShader returned with %#08x\n", hr
);
552 IDirect3DDevice8_SetVertexShader(device
, shader
);
553 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetVertexShader returned %#08x\n", hr
);
554 IDirect3DDevice8_SetVertexShaderConstant(device
, 0, constant
, 1);
556 hr
= IDirect3DDevice8_BeginScene(device
);
557 ok(hr
== D3D_OK
, "IDirect3DDevice8_BeginScene returned %#08x\n", hr
);
560 hr
= IDirect3DDevice8_DrawPrimitiveUP(device
, D3DPT_TRIANGLESTRIP
, 2, &quad
[0], 3 * sizeof(float));
561 ok(SUCCEEDED(hr
), "DrawPrimitiveUP failed (%#08x)\n", hr
);
562 hr
= IDirect3DDevice8_EndScene(device
);
563 ok(hr
== D3D_OK
, "IDirect3DDevice8_EndScene returned %#08x\n", hr
);
566 hr
= IDirect3DDevice8_Present(device
, NULL
, NULL
, NULL
, NULL
);
567 ok(SUCCEEDED(hr
), "Present failed (%#08x)\n", hr
);
568 color
= getPixelColor(device
, 320, 240);
569 c1
= (color
& 0x00ff0000 )>> 16;
570 c2
= (color
& 0x0000ff00 )>> 8;
571 c3
= (color
& 0x000000ff )>> 0;
572 ok(c1
== c2
&& c2
== c3
, "Color components differ: c1 = %02x, c2 = %02x, c3 = %02x\n",
574 ok(c1
>= 0x7c && c1
<= 0x84, "Color component value is %02x\n", c1
);
576 IDirect3DDevice8_SetVertexShader(device
, 0);
577 IDirect3DDevice8_DeleteVertexShader(device
, shader
);
579 hr
= IDirect3DDevice8_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
| D3DCLEAR_ZBUFFER
, 0xff800080, 0.0, 0);
580 ok(hr
== D3D_OK
, "IDirect3DDevice8_Clear failed with %#08x\n", hr
);
582 hr
= IDirect3DDevice8_CreateVertexShader(device
, decl
, rsq_test
, &shader
, 0);
583 ok(hr
== D3D_OK
, "IDirect3DDevice8_CreateVertexShader returned with %#08x\n", hr
);
585 IDirect3DDevice8_SetVertexShader(device
, shader
);
586 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetVertexShader returned %#08x\n", hr
);
587 IDirect3DDevice8_SetVertexShaderConstant(device
, 0, constant
, 1);
589 hr
= IDirect3DDevice8_BeginScene(device
);
590 ok(hr
== D3D_OK
, "IDirect3DDevice8_BeginScene returned %#08x\n", hr
);
593 hr
= IDirect3DDevice8_DrawPrimitiveUP(device
, D3DPT_TRIANGLESTRIP
, 2, &quad
[0], 3 * sizeof(float));
594 ok(SUCCEEDED(hr
), "DrawPrimitiveUP failed (%#08x)\n", hr
);
595 hr
= IDirect3DDevice8_EndScene(device
);
596 ok(hr
== D3D_OK
, "IDirect3DDevice8_EndScene returned %#08x\n", hr
);
599 hr
= IDirect3DDevice8_Present(device
, NULL
, NULL
, NULL
, NULL
);
600 ok(SUCCEEDED(hr
), "Present failed (%#08x)\n", hr
);
601 color
= getPixelColor(device
, 320, 240);
602 c1
= (color
& 0x00ff0000 )>> 16;
603 c2
= (color
& 0x0000ff00 )>> 8;
604 c3
= (color
& 0x000000ff )>> 0;
605 ok(c1
== c2
&& c2
== c3
, "Color components differ: c1 = %02x, c2 = %02x, c3 = %02x\n",
607 ok(c1
>= 0xb0 && c1
<= 0xb8, "Color component value is %02x\n", c1
);
609 IDirect3DDevice8_SetVertexShader(device
, 0);
610 IDirect3DDevice8_DeleteVertexShader(device
, shader
);
613 static void offscreen_test(IDirect3DDevice8
*device
)
616 IDirect3DTexture8
*offscreenTexture
= NULL
;
617 IDirect3DSurface8
*backbuffer
= NULL
, *offscreen
= NULL
, *depthstencil
= NULL
;
620 static const float quad
[][5] = {
621 {-0.5f
, -0.5f
, 0.1f
, 0.0f
, 0.0f
},
622 {-0.5f
, 0.5f
, 0.1f
, 0.0f
, 1.0f
},
623 { 0.5f
, -0.5f
, 0.1f
, 1.0f
, 0.0f
},
624 { 0.5f
, 0.5f
, 0.1f
, 1.0f
, 1.0f
},
627 hr
= IDirect3DDevice8_GetDepthStencilSurface(device
, &depthstencil
);
628 ok(hr
== D3D_OK
, "IDirect3DDevice8_GetDepthStencilSurface failed, hr = %#08x\n", hr
);
630 hr
= IDirect3DDevice8_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0xffff0000, 0.0, 0);
631 ok(hr
== D3D_OK
, "Clear failed, hr = %#08x\n", hr
);
633 hr
= IDirect3DDevice8_CreateTexture(device
, 128, 128, 1, D3DUSAGE_RENDERTARGET
, D3DFMT_X8R8G8B8
, D3DPOOL_DEFAULT
, &offscreenTexture
);
634 ok(hr
== D3D_OK
|| D3DERR_INVALIDCALL
, "Creating the offscreen render target failed, hr = %#08x\n", hr
);
635 if(!offscreenTexture
) {
636 trace("Failed to create an X8R8G8B8 offscreen texture, trying R5G6B5\n");
637 hr
= IDirect3DDevice8_CreateTexture(device
, 128, 128, 1, D3DUSAGE_RENDERTARGET
, D3DFMT_R5G6B5
, D3DPOOL_DEFAULT
, &offscreenTexture
);
638 ok(hr
== D3D_OK
|| D3DERR_INVALIDCALL
, "Creating the offscreen render target failed, hr = %#08x\n", hr
);
639 if(!offscreenTexture
) {
640 skip("Cannot create an offscreen render target\n");
645 hr
= IDirect3DDevice8_GetBackBuffer(device
, 0, D3DBACKBUFFER_TYPE_MONO
, &backbuffer
);
646 ok(hr
== D3D_OK
, "Can't get back buffer, hr = %#08x\n", hr
);
651 hr
= IDirect3DTexture8_GetSurfaceLevel(offscreenTexture
, 0, &offscreen
);
652 ok(hr
== D3D_OK
, "Can't get offscreen surface, hr = %#08x\n", hr
);
657 hr
= IDirect3DDevice8_SetVertexShader(device
, D3DFVF_XYZ
| D3DFVF_TEX1
);
658 ok(hr
== D3D_OK
, "SetVertexShader failed, hr = %#08x\n", hr
);
660 hr
= IDirect3DDevice8_SetTextureStageState(device
, 0, D3DTSS_COLOROP
, D3DTOP_SELECTARG1
);
661 ok(hr
== D3D_OK
, "SetTextureStageState failed, hr = %#08x\n", hr
);
662 hr
= IDirect3DDevice8_SetTextureStageState(device
, 0, D3DTSS_COLORARG1
, D3DTA_TEXTURE
);
663 ok(hr
== D3D_OK
, "SetTextureStageState failed, hr = %#08x\n", hr
);
664 hr
= IDirect3DDevice8_SetTextureStageState(device
, 0, D3DTSS_MINFILTER
, D3DTEXF_NONE
);
665 ok(SUCCEEDED(hr
), "SetTextureStageState D3DSAMP_MINFILTER failed (%#08x)\n", hr
);
666 hr
= IDirect3DDevice8_SetTextureStageState(device
, 0, D3DTSS_MAGFILTER
, D3DTEXF_NONE
);
667 ok(SUCCEEDED(hr
), "SetTextureStageState D3DSAMP_MAGFILTER failed (%#08x)\n", hr
);
668 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_LIGHTING
, FALSE
);
669 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr
));
671 if(IDirect3DDevice8_BeginScene(device
) == D3D_OK
) {
672 hr
= IDirect3DDevice8_SetRenderTarget(device
, offscreen
, depthstencil
);
673 ok(hr
== D3D_OK
, "SetRenderTarget failed, hr = %#08x\n", hr
);
674 hr
= IDirect3DDevice8_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0xffff00ff, 0.0, 0);
675 ok(hr
== D3D_OK
, "Clear failed, hr = %#08x\n", hr
);
677 /* Draw without textures - Should result in a white quad */
678 hr
= IDirect3DDevice8_DrawPrimitiveUP(device
, D3DPT_TRIANGLESTRIP
, 2, quad
, sizeof(quad
[0]));
679 ok(hr
== D3D_OK
, "DrawPrimitiveUP failed, hr = %#08x\n", hr
);
681 hr
= IDirect3DDevice8_SetRenderTarget(device
, backbuffer
, depthstencil
);
682 ok(hr
== D3D_OK
, "SetRenderTarget failed, hr = %#08x\n", hr
);
683 hr
= IDirect3DDevice8_SetTexture(device
, 0, (IDirect3DBaseTexture8
*) offscreenTexture
);
684 ok(hr
== D3D_OK
, "SetTexture failed, %s\n", DXGetErrorString8(hr
));
686 /* This time with the texture */
687 hr
= IDirect3DDevice8_DrawPrimitiveUP(device
, D3DPT_TRIANGLESTRIP
, 2, quad
, sizeof(quad
[0]));
688 ok(hr
== D3D_OK
, "DrawPrimitiveUP failed, hr = %#08x\n", hr
);
690 IDirect3DDevice8_EndScene(device
);
693 IDirect3DDevice8_Present(device
, NULL
, NULL
, NULL
, NULL
);
695 /* Center quad - should be white */
696 color
= getPixelColor(device
, 320, 240);
697 ok(color
== 0x00ffffff, "Offscreen failed: Got color 0x%08x, expected 0x00ffffff.\n", color
);
698 /* Some quad in the cleared part of the texture */
699 color
= getPixelColor(device
, 170, 240);
700 ok(color
== 0x00ff00ff, "Offscreen failed: Got color 0x%08x, expected 0x00ff00ff.\n", color
);
701 /* Part of the originally cleared back buffer */
702 color
= getPixelColor(device
, 10, 10);
703 ok(color
== 0x00ff0000, "Offscreen failed: Got color 0x%08x, expected 0x00ff0000.\n", color
);
705 /* Lower left corner of the screen, where back buffer offscreen rendering draws the offscreen texture.
706 * It should be red, but the offscreen texture may leave some junk there. Not tested yet. Depending on
707 * the offscreen rendering mode this test would succeed or fail
709 color
= getPixelColor(device
, 10, 470);
710 ok(color
== 0x00ff0000, "Offscreen failed: Got color 0x%08x, expected 0x00ff0000.\n", color
);
714 hr
= IDirect3DDevice8_SetTexture(device
, 0, NULL
);
718 hr
= IDirect3DDevice8_SetRenderTarget(device
, backbuffer
, depthstencil
);
719 IDirect3DSurface8_Release(backbuffer
);
721 if(offscreenTexture
) {
722 IDirect3DTexture8_Release(offscreenTexture
);
725 IDirect3DSurface8_Release(offscreen
);
728 IDirect3DSurface8_Release(depthstencil
);
732 static void alpha_test(IDirect3DDevice8
*device
)
735 IDirect3DTexture8
*offscreenTexture
;
736 IDirect3DSurface8
*backbuffer
= NULL
, *offscreen
= NULL
, *depthstencil
= NULL
;
737 DWORD color
, red
, green
, blue
;
739 struct vertex quad1
[] =
741 {-1.0f
, -1.0f
, 0.1f
, 0x4000ff00},
742 {-1.0f
, 0.0f
, 0.1f
, 0x4000ff00},
743 { 1.0f
, -1.0f
, 0.1f
, 0x4000ff00},
744 { 1.0f
, 0.0f
, 0.1f
, 0x4000ff00},
746 struct vertex quad2
[] =
748 {-1.0f
, 0.0f
, 0.1f
, 0xc00000ff},
749 {-1.0f
, 1.0f
, 0.1f
, 0xc00000ff},
750 { 1.0f
, 0.0f
, 0.1f
, 0xc00000ff},
751 { 1.0f
, 1.0f
, 0.1f
, 0xc00000ff},
753 static const float composite_quad
[][5] = {
754 { 0.0f
, -1.0f
, 0.1f
, 0.0f
, 1.0f
},
755 { 0.0f
, 1.0f
, 0.1f
, 0.0f
, 0.0f
},
756 { 1.0f
, -1.0f
, 0.1f
, 1.0f
, 1.0f
},
757 { 1.0f
, 1.0f
, 0.1f
, 1.0f
, 0.0f
},
760 /* Clear the render target with alpha = 0.5 */
761 hr
= IDirect3DDevice8_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0x80ff0000, 0.0, 0);
762 ok(hr
== D3D_OK
, "Clear failed, hr = %08x\n", hr
);
764 hr
= IDirect3DDevice8_CreateTexture(device
, 128, 128, 1, D3DUSAGE_RENDERTARGET
, D3DFMT_A8R8G8B8
, D3DPOOL_DEFAULT
, &offscreenTexture
);
765 ok(hr
== D3D_OK
|| D3DERR_INVALIDCALL
, "Creating the offscreen render target failed, hr = %#08x\n", hr
);
767 hr
= IDirect3DDevice8_GetDepthStencilSurface(device
, &depthstencil
);
768 ok(hr
== D3D_OK
, "IDirect3DDevice8_GetDepthStencilSurface failed, hr = %#08x\n", hr
);
770 hr
= IDirect3DDevice8_GetBackBuffer(device
, 0, D3DBACKBUFFER_TYPE_MONO
, &backbuffer
);
771 ok(hr
== D3D_OK
, "Can't get back buffer, hr = %#08x\n", hr
);
775 hr
= IDirect3DTexture8_GetSurfaceLevel(offscreenTexture
, 0, &offscreen
);
776 ok(hr
== D3D_OK
, "Can't get offscreen surface, hr = %#08x\n", hr
);
781 hr
= IDirect3DDevice8_SetVertexShader(device
, D3DFVF_XYZ
| D3DFVF_DIFFUSE
);
782 ok(hr
== D3D_OK
, "SetVertexShader failed, hr = %#08x\n", hr
);
784 hr
= IDirect3DDevice8_SetTextureStageState(device
, 0, D3DTSS_COLOROP
, D3DTOP_SELECTARG1
);
785 ok(hr
== D3D_OK
, "SetTextureStageState failed, hr = %#08x\n", hr
);
786 hr
= IDirect3DDevice8_SetTextureStageState(device
, 0, D3DTSS_COLORARG1
, D3DTA_TEXTURE
);
787 ok(hr
== D3D_OK
, "SetTextureStageState failed, hr = %#08x\n", hr
);
788 hr
= IDirect3DDevice8_SetTextureStageState(device
, 0, D3DTSS_MINFILTER
, D3DTEXF_NONE
);
789 ok(SUCCEEDED(hr
), "SetTextureStageState D3DSAMP_MINFILTER failed (%#08x)\n", hr
);
790 hr
= IDirect3DDevice8_SetTextureStageState(device
, 0, D3DTSS_MAGFILTER
, D3DTEXF_NONE
);
791 ok(SUCCEEDED(hr
), "SetTextureStageState D3DSAMP_MAGFILTER failed (%#08x)\n", hr
);
792 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_LIGHTING
, FALSE
);
793 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr
));
795 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_ALPHABLENDENABLE
, TRUE
);
796 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState failed, hr = %08x\n", hr
);
797 if(IDirect3DDevice8_BeginScene(device
) == D3D_OK
) {
799 /* Draw two quads, one with src alpha blending, one with dest alpha blending. The
800 * SRCALPHA / INVSRCALPHA blend doesn't give any surprises. Colors are blended based on
803 * The DESTALPHA / INVDESTALPHA do not "work" on the regular buffer because there is no alpha.
804 * They give essentially ZERO and ONE blend factors
806 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_SRCBLEND
, D3DBLEND_SRCALPHA
);
807 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState failed, hr = %08x\n", hr
);
808 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_DESTBLEND
, D3DBLEND_INVSRCALPHA
);
809 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState failed, hr = %08x\n", hr
);
810 hr
= IDirect3DDevice8_DrawPrimitiveUP(device
, D3DPT_TRIANGLESTRIP
, 2, quad1
, sizeof(quad1
[0]));
811 ok(hr
== D3D_OK
, "DrawPrimitiveUP failed, hr = %#08x\n", hr
);
813 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_SRCBLEND
, D3DBLEND_DESTALPHA
);
814 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState failed, hr = %08x\n", hr
);
815 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_DESTBLEND
, D3DBLEND_INVDESTALPHA
);
816 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState failed, hr = %08x\n", hr
);
817 hr
= IDirect3DDevice8_DrawPrimitiveUP(device
, D3DPT_TRIANGLESTRIP
, 2, quad2
, sizeof(quad2
[0]));
818 ok(hr
== D3D_OK
, "DrawPrimitiveUP failed, hr = %#08x\n", hr
);
820 /* Switch to the offscreen buffer, and redo the testing. SRCALPHA and DESTALPHA. The offscreen buffer
821 * has a alpha channel on its own. Clear the offscreen buffer with alpha = 0.5 again, then draw the
822 * quads again. The SRCALPHA/INVSRCALPHA doesn't give any surprises, but the DESTALPHA/INVDESTALPHA
823 * blending works as supposed now - blend factor is 0.5 in both cases, not 0.75 as from the input
826 hr
= IDirect3DDevice8_SetRenderTarget(device
, offscreen
, 0);
827 ok(hr
== D3D_OK
, "Can't get back buffer, hr = %08x\n", hr
);
828 hr
= IDirect3DDevice8_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0x80ff0000, 0.0, 0);
829 ok(hr
== D3D_OK
, "Clear failed, hr = %08x\n", hr
);
831 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_SRCBLEND
, D3DBLEND_SRCALPHA
);
832 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState failed, hr = %08x\n", hr
);
833 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_DESTBLEND
, D3DBLEND_INVSRCALPHA
);
834 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState failed, hr = %08x\n", hr
);
835 hr
= IDirect3DDevice8_DrawPrimitiveUP(device
, D3DPT_TRIANGLESTRIP
, 2, quad1
, sizeof(quad1
[0]));
836 ok(hr
== D3D_OK
, "DrawPrimitiveUP failed, hr = %#08x\n", hr
);
838 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_SRCBLEND
, D3DBLEND_DESTALPHA
);
839 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState failed, hr = %08x\n", hr
);
840 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_DESTBLEND
, D3DBLEND_INVDESTALPHA
);
841 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState failed, hr = %08x\n", hr
);
842 hr
= IDirect3DDevice8_DrawPrimitiveUP(device
, D3DPT_TRIANGLESTRIP
, 2, quad2
, sizeof(quad2
[0]));
843 ok(hr
== D3D_OK
, "DrawPrimitiveUP failed, hr = %#08x\n", hr
);
845 hr
= IDirect3DDevice8_SetRenderTarget(device
, backbuffer
, depthstencil
);
846 ok(hr
== D3D_OK
, "Can't get back buffer, hr = %08x\n", hr
);
848 /* Render the offscreen texture onto the frame buffer to be able to compare it regularly.
849 * Disable alpha blending for the final composition
851 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_ALPHABLENDENABLE
, FALSE
);
852 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState failed, hr = %08x\n", hr
);
853 hr
= IDirect3DDevice8_SetVertexShader(device
, D3DFVF_XYZ
| D3DFVF_TEX1
);
854 ok(hr
== D3D_OK
, "SetVertexShader failed, hr = %#08x\n", hr
);
856 hr
= IDirect3DDevice8_SetTexture(device
, 0, (IDirect3DBaseTexture8
*) offscreenTexture
);
857 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetTexture failed, hr = %08x\n", hr
);
858 hr
= IDirect3DDevice8_DrawPrimitiveUP(device
, D3DPT_TRIANGLESTRIP
, 2, composite_quad
, sizeof(float) * 5);
859 ok(hr
== D3D_OK
, "DrawPrimitiveUP failed, hr = %#08x\n", hr
);
860 hr
= IDirect3DDevice8_SetTexture(device
, 0, NULL
);
861 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetTexture failed, hr = %08x\n", hr
);
863 hr
= IDirect3DDevice8_EndScene(device
);
864 ok(hr
== D3D_OK
, "IDirect3DDevice7_EndScene failed, hr = %08x\n", hr
);
867 IDirect3DDevice8_Present(device
, NULL
, NULL
, NULL
, NULL
);
869 color
= getPixelColor(device
, 160, 360);
870 red
= (color
& 0x00ff0000) >> 16;
871 green
= (color
& 0x0000ff00) >> 8;
872 blue
= (color
& 0x000000ff);
873 ok(red
>= 0xbe && red
<= 0xc0 && green
>= 0x39 && green
<= 0x41 && blue
== 0x00,
874 "SRCALPHA on frame buffer returned color %08x, expected 0x00bf4000\n", color
);
876 color
= getPixelColor(device
, 160, 120);
877 red
= (color
& 0x00ff0000) >> 16;
878 green
= (color
& 0x0000ff00) >> 8;
879 blue
= (color
& 0x000000ff);
880 ok(red
== 0x00 && green
== 0x00 && blue
>= 0xfe && blue
<= 0xff ,
881 "DSTALPHA on frame buffer returned color %08x, expected 0x00ff0000\n", color
);
883 color
= getPixelColor(device
, 480, 360);
884 red
= (color
& 0x00ff0000) >> 16;
885 green
= (color
& 0x0000ff00) >> 8;
886 blue
= (color
& 0x000000ff);
887 ok(red
>= 0xbe && red
<= 0xc0 && green
>= 0x39 && green
<= 0x41 && blue
== 0x00,
888 "SRCALPHA on texture returned color %08x, expected bar\n", color
);
890 color
= getPixelColor(device
, 480, 120);
891 red
= (color
& 0x00ff0000) >> 16;
892 green
= (color
& 0x0000ff00) >> 8;
893 blue
= (color
& 0x000000ff);
894 ok(red
>= 0x7e && red
<= 0x81 && green
== 0x00 && blue
>= 0x7e && blue
<= 0x81,
895 "DSTALPHA on texture returned color %08x, expected foo\n", color
);
900 IDirect3DSurface8_Release(backbuffer
);
902 if(offscreenTexture
) {
903 IDirect3DTexture8_Release(offscreenTexture
);
906 IDirect3DSurface8_Release(offscreen
);
909 IDirect3DSurface8_Release(depthstencil
);
913 static void p8_texture_test(IDirect3DDevice8
*device
)
915 IDirect3D8
*d3d
= NULL
;
917 IDirect3DTexture8
*texture
= NULL
, *texture2
= NULL
;
920 DWORD color
, red
, green
, blue
;
921 PALETTEENTRY table
[256];
925 -1.0, 0, 0.1, 0.0, 0.0,
926 -1.0, 1.0, 0.1, 0.0, 1.0,
927 1.0, 0, 0.1, 1.0, 0.0,
928 1.0, 1.0, 0.1, 1.0, 1.0,
931 -1.0, -1.0, 0.1, 0.0, 0.0,
932 -1.0, 0, 0.1, 0.0, 1.0,
933 1.0, -1.0, 0.1, 1.0, 0.0,
934 1.0, 0, 0.1, 1.0, 1.0,
937 IDirect3DDevice8_GetDirect3D(device
, &d3d
);
939 if(IDirect3D8_CheckDeviceFormat(d3d
, 0, D3DDEVTYPE_HAL
, D3DFMT_X8R8G8B8
, 0,
940 D3DRTYPE_TEXTURE
, D3DFMT_P8
) != D3D_OK
) {
941 skip("D3DFMT_P8 textures not supported\n");
945 hr
= IDirect3DDevice8_CreateTexture(device
, 1, 1, 1, 0, D3DFMT_P8
,
946 D3DPOOL_MANAGED
, &texture2
);
947 ok(hr
== D3D_OK
, "IDirect3DDevice8_CreateTexture failed, hr = %08x\n", hr
);
949 skip("Failed to create D3DFMT_P8 texture\n");
953 memset(&lr
, 0, sizeof(lr
));
954 hr
= IDirect3DTexture8_LockRect(texture2
, 0, &lr
, NULL
, 0);
955 ok(hr
== D3D_OK
, "IDirect3DTexture8_LockRect failed, hr = %08x\n", hr
);
959 hr
= IDirect3DTexture8_UnlockRect(texture2
, 0);
960 ok(hr
== D3D_OK
, "IDirect3DTexture8_UnlockRect failed, hr = %08x\n", hr
);
962 hr
= IDirect3DDevice8_CreateTexture(device
, 1, 1, 1, 0, D3DFMT_P8
,
963 D3DPOOL_MANAGED
, &texture
);
964 ok(hr
== D3D_OK
, "IDirect3DDevice8_CreateTexture failed, hr = %08x\n", hr
);
966 skip("Failed to create D3DFMT_P8 texture\n");
970 memset(&lr
, 0, sizeof(lr
));
971 hr
= IDirect3DTexture8_LockRect(texture
, 0, &lr
, NULL
, 0);
972 ok(hr
== D3D_OK
, "IDirect3DTexture8_LockRect failed, hr = %08x\n", hr
);
976 hr
= IDirect3DTexture8_UnlockRect(texture
, 0);
977 ok(hr
== D3D_OK
, "IDirect3DTexture8_UnlockRect failed, hr = %08x\n", hr
);
979 hr
= IDirect3DDevice8_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0xff000000, 0.0, 0);
980 ok(hr
== D3D_OK
, "IDirect3DDevice8_Clear failed, hr = %08x\n", hr
);
982 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_ALPHABLENDENABLE
, TRUE
);
983 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState failed, hr = %08x\n", hr
);
985 /* The first part of the test should work both with and without D3DPTEXTURECAPS_ALPHAPALETTE;
986 alpha of every entry is set to 1.0, which MS says is required when there's no
987 D3DPTEXTURECAPS_ALPHAPALETTE capability */
988 for (i
= 0; i
< 256; i
++) {
989 table
[i
].peRed
= table
[i
].peGreen
= table
[i
].peBlue
= 0;
990 table
[i
].peFlags
= 0xff;
992 table
[1].peRed
= 0xff;
993 hr
= IDirect3DDevice8_SetPaletteEntries(device
, 0, table
);
994 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetPaletteEntries failed, hr = %08x\n", hr
);
997 table
[1].peBlue
= 0xff;
998 hr
= IDirect3DDevice8_SetPaletteEntries(device
, 1, table
);
999 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetPaletteEntries failed, hr = %08x\n", hr
);
1001 hr
= IDirect3DDevice8_BeginScene(device
);
1002 ok(hr
== D3D_OK
, "IDirect3DDevice8_BeginScene failed, hr = %08x\n", hr
);
1004 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_SRCBLEND
, D3DBLEND_SRCALPHA
);
1005 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState failed, hr = %08x\n", hr
);
1006 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_DESTBLEND
, D3DBLEND_INVSRCALPHA
);
1007 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState failed, hr = %08x\n", hr
);
1009 hr
= IDirect3DDevice8_SetVertexShader(device
, D3DFVF_XYZ
| D3DFVF_TEX1
);
1010 ok(hr
== D3D_OK
, "SetVertexShader failed, hr = %#08x\n", hr
);
1012 hr
= IDirect3DDevice8_SetCurrentTexturePalette(device
, 0);
1013 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetCurrentTexturePalette failed, hr = %08x\n", hr
);
1015 hr
= IDirect3DDevice8_SetTexture(device
, 0, (IDirect3DBaseTexture8
*) texture2
);
1016 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetTexture failed, hr = %08x\n", hr
);
1017 hr
= IDirect3DDevice8_DrawPrimitiveUP(device
, D3DPT_TRIANGLESTRIP
, 2, quad
, 5 * sizeof(float));
1018 ok(hr
== D3D_OK
, "IDirect3DDevice8_DrawPrimitiveUP failed, hr = %08x\n", hr
);
1020 hr
= IDirect3DDevice8_SetTexture(device
, 0, (IDirect3DBaseTexture8
*) texture
);
1021 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetTexture failed, hr = %08x\n", hr
);
1022 hr
= IDirect3DDevice8_DrawPrimitiveUP(device
, D3DPT_TRIANGLESTRIP
, 2, quad
, 5 * sizeof(float));
1023 ok(hr
== D3D_OK
, "IDirect3DDevice8_DrawPrimitiveUP failed, hr = %08x\n", hr
);
1025 hr
= IDirect3DDevice8_SetCurrentTexturePalette(device
, 1);
1026 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetCurrentTexturePalette failed, hr = %08x\n", hr
);
1027 hr
= IDirect3DDevice8_DrawPrimitiveUP(device
, D3DPT_TRIANGLESTRIP
, 2, quad2
, 5 * sizeof(float));
1028 ok(hr
== D3D_OK
, "IDirect3DDevice8_DrawPrimitiveUP failed, hr = %08x\n", hr
);
1030 hr
= IDirect3DDevice8_EndScene(device
);
1031 ok(hr
== D3D_OK
, "IDirect3DDevice8_EndScene failed, hr = %08x\n", hr
);
1034 hr
= IDirect3DDevice8_Present(device
, NULL
, NULL
, NULL
, NULL
);
1035 ok(hr
== D3D_OK
, "IDirect3DDevice8_Present failed, hr = %08x\n", hr
);
1037 color
= getPixelColor(device
, 32, 32);
1038 red
= (color
& 0x00ff0000) >> 16;
1039 green
= (color
& 0x0000ff00) >> 8;
1040 blue
= (color
& 0x000000ff) >> 0;
1041 ok(red
== 0xff && blue
== 0 && green
== 0,
1042 "got color %08x, expected 0x00ff0000\n", color
);
1044 color
= getPixelColor(device
, 32, 320);
1045 red
= (color
& 0x00ff0000) >> 16;
1046 green
= (color
& 0x0000ff00) >> 8;
1047 blue
= (color
& 0x000000ff) >> 0;
1048 ok(red
== 0 && blue
== 0xff && green
== 0,
1049 "got color %08x, expected 0x000000ff\n", color
);
1051 hr
= IDirect3DDevice8_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0xff000000, 0.0, 0);
1052 ok(hr
== D3D_OK
, "IDirect3DDevice8_Clear failed, hr = %08x\n", hr
);
1054 hr
= IDirect3DDevice8_BeginScene(device
);
1055 ok(hr
== D3D_OK
, "IDirect3DDevice8_BeginScene failed, hr = %08x\n", hr
);
1057 hr
= IDirect3DDevice8_SetTexture(device
, 0, (IDirect3DBaseTexture8
*) texture2
);
1058 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetTexture failed, hr = %08x\n", hr
);
1060 hr
= IDirect3DDevice8_DrawPrimitiveUP(device
, D3DPT_TRIANGLESTRIP
, 2, quad
, 5 * sizeof(float));
1061 ok(hr
== D3D_OK
, "IDirect3DDevice8_DrawPrimitiveUP failed, hr = %08x\n", hr
);
1063 hr
= IDirect3DDevice8_EndScene(device
);
1064 ok(hr
== D3D_OK
, "IDirect3DDevice8_EndScene failed, hr = %08x\n", hr
);
1067 hr
= IDirect3DDevice8_Present(device
, NULL
, NULL
, NULL
, NULL
);
1068 ok(hr
== D3D_OK
, "IDirect3DDevice8_Present failed, hr = %08x\n", hr
);
1070 color
= getPixelColor(device
, 32, 32);
1071 red
= (color
& 0x00ff0000) >> 16;
1072 green
= (color
& 0x0000ff00) >> 8;
1073 blue
= (color
& 0x000000ff) >> 0;
1074 ok(red
== 0 && blue
== 0xff && green
== 0,
1075 "got color %08x, expected 0x000000ff\n", color
);
1077 /* Test palettes with alpha */
1078 IDirect3DDevice8_GetDeviceCaps(device
, &caps
);
1079 if (!(caps
.TextureCaps
& D3DPTEXTURECAPS_ALPHAPALETTE
)) {
1080 skip("no D3DPTEXTURECAPS_ALPHAPALETTE capability, tests with alpha in palette will be skipped\n");
1082 hr
= IDirect3DDevice8_Clear(device
, 0, NULL
, D3DCLEAR_TARGET
, 0xff000000, 0.0, 0);
1083 ok(hr
== D3D_OK
, "IDirect3DDevice8_Clear failed, hr = %08x\n", hr
);
1085 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_ALPHABLENDENABLE
, TRUE
);
1086 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState failed, hr = %08x\n", hr
);
1088 for (i
= 0; i
< 256; i
++) {
1089 table
[i
].peRed
= table
[i
].peGreen
= table
[i
].peBlue
= 0;
1090 table
[i
].peFlags
= 0xff;
1092 table
[1].peRed
= 0xff;
1093 table
[1].peFlags
= 0x80;
1094 hr
= IDirect3DDevice8_SetPaletteEntries(device
, 0, table
);
1095 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetPaletteEntries failed, hr = %08x\n", hr
);
1098 table
[1].peBlue
= 0xff;
1099 table
[1].peFlags
= 0x80;
1100 hr
= IDirect3DDevice8_SetPaletteEntries(device
, 1, table
);
1101 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetPaletteEntries failed, hr = %08x\n", hr
);
1103 hr
= IDirect3DDevice8_BeginScene(device
);
1104 ok(hr
== D3D_OK
, "IDirect3DDevice8_BeginScene failed, hr = %08x\n", hr
);
1106 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_SRCBLEND
, D3DBLEND_SRCALPHA
);
1107 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState failed, hr = %08x\n", hr
);
1108 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_DESTBLEND
, D3DBLEND_INVSRCALPHA
);
1109 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState failed, hr = %08x\n", hr
);
1111 hr
= IDirect3DDevice8_SetVertexShader(device
, D3DFVF_XYZ
| D3DFVF_TEX1
);
1112 ok(hr
== D3D_OK
, "SetVertexShader failed, hr = %#08x\n", hr
);
1114 hr
= IDirect3DDevice8_SetCurrentTexturePalette(device
, 0);
1115 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetCurrentTexturePalette failed, hr = %08x\n", hr
);
1117 hr
= IDirect3DDevice8_DrawPrimitiveUP(device
, D3DPT_TRIANGLESTRIP
, 2, quad
, 5 * sizeof(float));
1118 ok(hr
== D3D_OK
, "IDirect3DDevice8_DrawPrimitiveUP failed, hr = %08x\n", hr
);
1120 hr
= IDirect3DDevice8_SetCurrentTexturePalette(device
, 1);
1121 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetCurrentTexturePalette failed, hr = %08x\n", hr
);
1123 hr
= IDirect3DDevice8_DrawPrimitiveUP(device
, D3DPT_TRIANGLESTRIP
, 2, quad2
, 5 * sizeof(float));
1124 ok(hr
== D3D_OK
, "IDirect3DDevice8_DrawPrimitiveUP failed, hr = %08x\n", hr
);
1126 hr
= IDirect3DDevice8_EndScene(device
);
1127 ok(hr
== D3D_OK
, "IDirect3DDevice8_EndScene failed, hr = %08x\n", hr
);
1130 hr
= IDirect3DDevice8_Present(device
, NULL
, NULL
, NULL
, NULL
);
1131 ok(hr
== D3D_OK
, "IDirect3DDevice8_Present failed, hr = %08x\n", hr
);
1133 color
= getPixelColor(device
, 32, 32);
1134 red
= (color
& 0x00ff0000) >> 16;
1135 green
= (color
& 0x0000ff00) >> 8;
1136 blue
= (color
& 0x000000ff) >> 0;
1137 ok(red
>= 0x7e && red
<= 0x81 && blue
== 0 && green
== 0,
1138 "got color %08x, expected 0x00800000 or near\n", color
);
1140 color
= getPixelColor(device
, 32, 320);
1141 red
= (color
& 0x00ff0000) >> 16;
1142 green
= (color
& 0x0000ff00) >> 8;
1143 blue
= (color
& 0x000000ff) >> 0;
1144 ok(red
== 0 && blue
>= 0x7e && blue
<= 0x81 && green
== 0,
1145 "got color %08x, expected 0x00000080 or near\n", color
);
1148 hr
= IDirect3DDevice8_SetTexture(device
, 0, NULL
);
1149 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetTexture failed, hr = %08x\n", hr
);
1150 hr
= IDirect3DDevice8_SetRenderState(device
, D3DRS_ALPHABLENDENABLE
, FALSE
);
1151 ok(hr
== D3D_OK
, "IDirect3DDevice8_SetRenderState failed, hr = %08x\n", hr
);
1154 if(texture
) IDirect3DTexture8_Release(texture
);
1155 if(texture2
) IDirect3DTexture8_Release(texture2
);
1156 IDirect3D8_Release(d3d
);
1161 IDirect3DDevice8
*device_ptr
;
1166 d3d8_handle
= LoadLibraryA("d3d8.dll");
1169 skip("Could not load d3d8.dll\n");
1173 device_ptr
= init_d3d8();
1176 skip("Could not initialize direct3d\n");
1180 IDirect3DDevice8_GetDeviceCaps(device_ptr
, &caps
);
1182 /* Check for the reliability of the returned data */
1183 hr
= IDirect3DDevice8_Clear(device_ptr
, 0, NULL
, D3DCLEAR_TARGET
, 0xffff0000, 0.0, 0);
1186 trace("Clear failed, can't assure correctness of the test results, skipping\n");
1189 IDirect3DDevice8_Present(device_ptr
, NULL
, NULL
, NULL
, NULL
);
1191 color
= getPixelColor(device_ptr
, 1, 1);
1192 if(color
!=0x00ff0000)
1194 trace("Sanity check returned an incorrect color(%08x), can't assure the correctness of the tests, skipping\n", color
);
1198 hr
= IDirect3DDevice8_Clear(device_ptr
, 0, NULL
, D3DCLEAR_TARGET
, 0xff00ddee, 0.0, 0);
1201 trace("Clear failed, can't assure correctness of the test results, skipping\n");
1204 IDirect3DDevice8_Present(device_ptr
, NULL
, NULL
, NULL
, NULL
);
1206 color
= getPixelColor(device_ptr
, 639, 479);
1207 if(color
!= 0x0000ddee)
1209 trace("Sanity check returned an incorrect color(%08x), can't assure the correctness of the tests, skipping\n", color
);
1213 /* Now run the real test */
1214 lighting_test(device_ptr
);
1215 clear_test(device_ptr
);
1216 fog_test(device_ptr
);
1217 present_test(device_ptr
);
1218 offscreen_test(device_ptr
);
1219 alpha_test(device_ptr
);
1221 if (caps
.VertexShaderVersion
>= D3DVS_VERSION(1, 1))
1223 test_rcp_rsq(device_ptr
);
1227 skip("No vs.1.1 support\n");
1230 p8_texture_test(device_ptr
);
1234 D3DDEVICE_CREATION_PARAMETERS creation_parameters
;
1235 IDirect3DDevice8_GetCreationParameters(device_ptr
, &creation_parameters
);
1236 IDirect3DDevice8_Release(device_ptr
);
1237 DestroyWindow(creation_parameters
.hFocusWindow
);