d3d8: Fix failing tests on windows, when no 3d hardware acceleration is available.
[wine] / dlls / d3d8 / tests / d3d8_main.c
1 /*
2  * Copyright (C) 2006 Louis Lenders
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include "wine/test.h"
20
21 static HRESULT (WINAPI *ValidateVertexShader)(DWORD*,DWORD*,DWORD*,int,DWORD*);
22 static HRESULT (WINAPI *ValidatePixelShader)(DWORD*,DWORD*,int,DWORD*);
23
24 static void test_ValidateVertexShader(void)
25 {
26     HRESULT ret;
27     static DWORD simple_vs[] = {0xFFFE0101,             /* vs_1_1               */
28         0x00000009, 0xC0010000, 0x90E40000, 0xA0E40000, /* dp4 oPos.x, v0, c0   */
29         0x00000009, 0xC0020000, 0x90E40000, 0xA0E40001, /* dp4 oPos.y, v0, c1   */
30         0x00000009, 0xC0040000, 0x90E40000, 0xA0E40002, /* dp4 oPos.z, v0, c2   */
31         0x00000009, 0xC0080000, 0x90E40000, 0xA0E40003, /* dp4 oPos.w, v0, c3   */
32         0x0000FFFF};
33
34     ret=ValidateVertexShader(0,0,0,0,0);
35     ok(ret==E_FAIL,"ValidateVertexShader returned %x but expected E_FAIL\n",ret);
36
37     ret=ValidateVertexShader(0,0,0,1,0);
38     ok(ret==E_FAIL,"ValidateVertexShader returned %x but expected E_FAIL\n",ret);
39
40     ret=ValidateVertexShader(simple_vs,0,0,0,0);
41     ok(ret==S_OK,"ValidateVertexShader returned %x but expected S_OK\n",ret);
42
43     ret=ValidateVertexShader(simple_vs,0,0,1,0);
44     ok(ret==S_OK,"ValidateVertexShader returned %x but expected S_OK\n",ret);
45     /* seems to do some version checking */
46     *simple_vs=0xFFFE0100;             /* vs_1_0               */
47     ret=ValidateVertexShader(simple_vs,0,0,0,0);
48     ok(ret==S_OK,"ValidateVertexShader returned %x but expected S_OK\n",ret);
49
50     *simple_vs=0xFFFE0102;            /* bogus version         */
51     ret=ValidateVertexShader(simple_vs,0,0,1,0);
52     ok(ret==E_FAIL,"ValidateVertexShader returned %x but expected E_FAIL\n",ret);
53     /* I've seen that applications pass 2nd and 3rd parameter always as 0;simple test with non-zero parameters */
54     *simple_vs=0xFFFE0101;             /* vs_1_1               */
55     ret=ValidateVertexShader(simple_vs,simple_vs,0,1,0);
56     ok(ret==E_FAIL,"ValidateVertexShader returned %x but expected E_FAIL\n",ret);
57
58     ret=ValidateVertexShader(simple_vs,0,simple_vs,1,0);
59     ok(ret==E_FAIL,"ValidateVertexShader returned %x but expected E_FAIL\n",ret);
60     /* I've seen 4th parameter is always passed as either 0 or 1, but passing other values doesn't seem to hurt*/
61     ret=ValidateVertexShader(simple_vs,0,0,12345,0);
62     ok(ret==S_OK,"ValidateVertexShader returned %x but expected S_OK\n",ret);
63     /* What is 5th parameter ???? Following works ok */
64     ret=ValidateVertexShader(simple_vs,0,0,1,simple_vs);
65     ok(ret==S_OK,"ValidateVertexShader returned %x but expected S_OK\n",ret);
66 }
67
68 static void test_ValidatePixelShader(void)
69
70     HRESULT ret;
71     static DWORD simple_ps[] = {0xFFFF0101,                                     /* ps_1_1                       */
72         0x00000051, 0xA00F0001, 0x3F800000, 0x00000000, 0x00000000, 0x00000000, /* def c1 = 1.0, 0.0, 0.0, 0.0  */
73         0x00000042, 0xB00F0000,                                                 /* tex t0                       */
74         0x00000008, 0x800F0000, 0xA0E40001, 0xA0E40000,                         /* dp3 r0, c1, c0               */
75         0x00000005, 0x800F0000, 0x90E40000, 0x80E40000,                         /* mul r0, v0, r0               */
76         0x00000005, 0x800F0000, 0xB0E40000, 0x80E40000,                         /* mul r0, t0, r0               */
77         0x0000FFFF};                                                            /* END                          */
78
79     ret=ValidatePixelShader(0,0,0,0);
80     ok(ret==E_FAIL,"ValidatePixelShader returned %x but expected E_FAIL\n",ret);
81
82     ret=ValidatePixelShader(0,0,1,0);
83     ok(ret==E_FAIL,"ValidatePixelShader returned %x but expected E_FAIL\n",ret);
84
85     ret=ValidatePixelShader(simple_ps,0,0,0);
86     ok(ret==S_OK,"ValidatePixelShader returned %x but expected S_OK\n",ret);
87
88     ret=ValidatePixelShader(simple_ps,0,1,0);
89     ok(ret==S_OK,"ValidatePixelShader returned %x but expected S_OK\n",ret);
90     /* seems to do some version checking */
91     *simple_ps=0xFFFF0105;             /* bogus version  */
92     ret=ValidatePixelShader(simple_ps,0,1,0);
93     ok(ret==E_FAIL,"ValidatePixelShader returned %x but expected E_FAIL\n",ret);
94     /* I've seen that applications pass 2nd parameter always as 0;simple test with non-zero parameter */
95     *simple_ps=0xFFFF0101;             /* ps_1_1         */
96     ret=ValidatePixelShader(simple_ps,simple_ps,1,0);
97     ok(ret==E_FAIL,"ValidatePixelShader returned %x but expected E_FAIL\n",ret);
98     /* I've seen 3rd parameter is always passed as either 0 or 1, but passing other values doesn't seem to hurt*/
99     ret=ValidatePixelShader(simple_ps,0,12345,0);
100     ok(ret==S_OK,"ValidatePixelShader returned %x but expected S_OK\n",ret);
101     /* What is 4th parameter ???? Following works ok */
102     ret=ValidatePixelShader(simple_ps,0,1,simple_ps);
103     ok(ret==S_OK,"ValidatePixelShader returned %x but expected S_OK\n",ret);
104 }
105
106 START_TEST(d3d8_main)
107 {
108     HMODULE d3d8_handle = LoadLibraryA( "d3d8.dll" );
109     if (!d3d8_handle)
110         return;
111     ValidateVertexShader = (void*)GetProcAddress (d3d8_handle, "ValidateVertexShader" );
112     ValidatePixelShader = (void*)GetProcAddress (d3d8_handle, "ValidatePixelShader" );
113     test_ValidateVertexShader();
114     test_ValidatePixelShader();
115 }