d3dx9: Add a test for D3DXGetShaderSize().
[wine] / dlls / d3dx9_36 / tests / shader.c
1 /*
2  * Copyright 2008 Luis Busquets
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 #include "d3dx9.h"
21
22 static const DWORD simple_vs[] = {
23     0xfffe0101,                                                             /* vs_1_1                       */
24     0x0000001f, 0x80000000, 0x900f0000,                                     /* dcl_position0 v0             */
25     0x00000009, 0xc0010000, 0x90e40000, 0xa0e40000,                         /* dp4 oPos.x, v0, c0           */
26     0x00000009, 0xc0020000, 0x90e40000, 0xa0e40001,                         /* dp4 oPos.y, v0, c1           */
27     0x00000009, 0xc0040000, 0x90e40000, 0xa0e40002,                         /* dp4 oPos.z, v0, c2           */
28     0x00000009, 0xc0080000, 0x90e40000, 0xa0e40003,                         /* dp4 oPos.w, v0, c3           */
29     0x0000ffff};                                                            /* END                          */
30
31 static const DWORD simple_ps[] = {
32     0xffff0101,                                                             /* ps_1_1                       */
33     0x00000051, 0xa00f0001, 0x3f800000, 0x00000000, 0x00000000, 0x00000000, /* def c1 = 1.0, 0.0, 0.0, 0.0  */
34     0x00000042, 0xb00f0000,                                                 /* tex t0                       */
35     0x00000008, 0x800f0000, 0xa0e40001, 0xa0e40000,                         /* dp3 r0, c1, c0               */
36     0x00000005, 0x800f0000, 0x90e40000, 0x80e40000,                         /* mul r0, v0, r0               */
37     0x00000005, 0x800f0000, 0xb0e40000, 0x80e40000,                         /* mul r0, t0, r0               */
38     0x0000ffff};                                                            /* END                          */
39
40
41 static void test_get_shader_size(void)
42 {
43     UINT shader_size, expected;
44
45     shader_size = D3DXGetShaderSize(simple_vs);
46     expected = sizeof(simple_vs);
47     ok(shader_size == expected, "Got shader size %u, expected %u\n", shader_size, expected);
48
49     shader_size = D3DXGetShaderSize(simple_ps);
50     expected = sizeof(simple_ps);
51     ok(shader_size == expected, "Got shader size %u, expected %u\n", shader_size, expected);
52
53     shader_size = D3DXGetShaderSize(NULL);
54     ok(shader_size == 0, "Got shader size %u, expected 0\n", shader_size);
55 }
56
57 START_TEST(shader)
58 {
59     test_get_shader_size();
60 }