ReactOS 0.4.15-dev-7842-g558ab78
asm.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010 Matteo Bruni
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#define COBJMACROS
19#define CONST_VTABLE
20#include "wine/test.h"
21
22#include <d3d9types.h>
23#include <d3dcommon.h>
24#include <d3dcompiler.h>
25
26/* TODO: maybe this is defined in some header file,
27 perhaps with a different name? */
28#define D3DXERR_INVALIDDATA 0x88760b59
29
30static HRESULT (WINAPI *pD3DAssemble)(const void *data, SIZE_T datasize, const char *filename,
34
36 const char *text;
37 const DWORD bytes[128];
38};
39
40static void dump_shader(DWORD *shader) {
41 unsigned int i = 0, j = 0;
42 do {
43 trace("0x%08x ", shader[i]);
44 j++;
45 i++;
46 if(j == 6) trace("\n");
47 } while(shader[i - 1] != D3DSIO_END);
48 if(j != 6) trace("\n");
49}
50
51static void exec_tests(const char *name, struct shader_test tests[], unsigned int count) {
52 HRESULT hr;
53 DWORD *res;
54 unsigned int i, j;
55 BOOL diff;
57
58 for(i = 0; i < count; i++) {
59 /* D3DAssemble sets messages to 0 if there aren't error messages */
60 messages = NULL;
61 hr = pD3DAssemble(tests[i].text, strlen(tests[i].text), NULL,
63 &shader, &messages);
64 ok(hr == S_OK, "Test %s, shader %d: D3DAssemble failed with error 0x%x - %d\n", name, i, hr, hr & 0x0000FFFF);
65 if(messages) {
66 trace("D3DAssemble messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
67 ID3D10Blob_Release(messages);
68 }
69 if(FAILED(hr)) continue;
70
71 j = 0;
72 diff = FALSE;
73 res = ID3D10Blob_GetBufferPointer(shader);
74 while(res[j] != D3DSIO_END && tests[i].bytes[j] != D3DSIO_END) {
75 if(res[j] != tests[i].bytes[j]) diff = TRUE;
76 j++;
77 };
78 /* Both must have an end token */
79 if(res[j] != tests[i].bytes[j]) diff = TRUE;
80
81 if(diff) {
82 ok(FALSE, "Test %s, shader %d: Generated code differs\n", name, i);
84 }
85 ID3D10Blob_Release(shader);
86 }
87}
88
89static void preproc_test(void) {
90 struct shader_test tests[] = {
91 { /* shader 0 */
92 "vs.1.1\r\n"
93 "//some comments\r\n"
94 "//other comments\n"
95 "; yet another comment\r\n"
96 "add r0, r0, r1\n",
97 {0xfffe0101, 0x00000002, 0x800f0000, 0x80e40000, 0x80e40001, 0x0000ffff}
98 },
99 { /* shader 1 */
100 "#line 1 \"vertex.vsh\"\n"
101 "vs.1.1\n",
102 {0xfffe0101, 0x0000ffff}
103 },
104 { /* shader 2 */
105 "#define REG 1 + 2 +\\\n"
106 "3 + 4\n"
107 "vs.1.1\n"
108 "mov r0, c0[ REG ]\n",
109 {0xfffe0101, 0x00000001, 0x800f0000, 0xa0e4000a, 0x0000ffff}
110 },
111 };
112
113 exec_tests("preproc", tests, ARRAY_SIZE(tests));
114}
115
116static void ps_1_1_test(void) {
117 struct shader_test tests[] = {
118 { /* shader 0 */
119 "ps.1.1\r\n"
120 "tex t0\r\n"
121 "add r0.rgb, r0, r1\r\n"
122 "+mov r0.a, t0\r\n",
123 {0xffff0101, 0x00000042, 0xb00f0000, 0x00000002, 0x80070000, 0x80e40000,
124 0x80e40001, 0x40000001, 0x80080000, 0xb0e40000, 0x0000ffff}
125 },
126 { /* shader 1 */
127 "ps.1.1\n"
128 "mov_d4 r0, r1\n",
129 {0xffff0101, 0x00000001, 0x8e0f0000, 0x80e40001, 0x0000ffff}
130 },
131 { /* shader 2 */
132 "ps_1_1\n"
133 "def c2, 0, 0., 0, 0.\n",
134 {0xffff0101, 0x00000051, 0xa00f0002, 0x00000000, 0x00000000, 0x00000000,
135 0x00000000, 0x0000ffff}
136 },
137 };
138
139 exec_tests("ps_1_1", tests, ARRAY_SIZE(tests));
140}
141
142static void vs_1_1_test(void) {
143 struct shader_test tests[] = {
144 /* Basic instruction tests */
145 { /* shader 0 */
146 "vs_1_1\n"
147 "add r0, r1, r2\n",
148 {0xfffe0101, 0x00000002, 0x800f0000, 0x80e40001, 0x80e40002, 0x0000ffff}
149 },
150 { /* shader 1 */
151 "vs_1_1\n"
152 "nop\n",
153 {0xfffe0101, 0x00000000, 0x0000ffff}
154 },
155 /* Output register tests */
156 { /* shader 2 */
157 "vs_1_1\n"
158 "mov oPos, c0\n",
159 {0xfffe0101, 0x00000001, 0xc00f0000, 0xa0e40000, 0x0000ffff}
160 },
161 { /* shader 3 */
162 "vs_1_1\n"
163 "mov oT0, c0\n",
164 {0xfffe0101, 0x00000001, 0xe00f0000, 0xa0e40000, 0x0000ffff}
165 },
166 { /* shader 4 */
167 "vs_1_1\n"
168 "mov oT5, c0\n",
169 {0xfffe0101, 0x00000001, 0xe00f0005, 0xa0e40000, 0x0000ffff}
170 },
171 { /* shader 5 */
172 "vs_1_1\n"
173 "mov oD0, c0\n",
174 {0xfffe0101, 0x00000001, 0xd00f0000, 0xa0e40000, 0x0000ffff}
175 },
176 { /* shader 6 */
177 "vs_1_1\n"
178 "mov oD1, c0\n",
179 {0xfffe0101, 0x00000001, 0xd00f0001, 0xa0e40000, 0x0000ffff}
180 },
181 { /* shader 7 */
182 "vs_1_1\n"
183 "mov oFog, c0.x\n",
184 {0xfffe0101, 0x00000001, 0xc00f0001, 0xa0000000, 0x0000ffff}
185 },
186 { /* shader 8 */
187 "vs_1_1\n"
188 "mov oPts, c0.x\n",
189 {0xfffe0101, 0x00000001, 0xc00f0002, 0xa0000000, 0x0000ffff}
190 },
191 /* A bunch of tests for declarations */
192 { /* shader 9 */
193 "vs_1_1\n"
194 "dcl_position0 v0",
195 {0xfffe0101, 0x0000001f, 0x80000000, 0x900f0000, 0x0000ffff}
196 },
197 { /* shader 10 */
198 "vs_1_1\n"
199 "dcl_position v1",
200 {0xfffe0101, 0x0000001f, 0x80000000, 0x900f0001, 0x0000ffff}
201 },
202 { /* shader 11 */
203 "vs_1_1\n"
204 "dcl_normal12 v15",
205 {0xfffe0101, 0x0000001f, 0x800c0003, 0x900f000f, 0x0000ffff}
206 },
207 { /* shader 12 */
208 "vs_1_1\n"
209 "add r0, v0, v1\n",
210 {0xfffe0101, 0x00000002, 0x800f0000, 0x90e40000, 0x90e40001, 0x0000ffff}
211 },
212 { /* shader 13 */
213 "vs_1_1\n"
214 "def c12, 0, -1, -0.5, 1024\n",
215 {0xfffe0101, 0x00000051, 0xa00f000c, 0x00000000, 0xbf800000, 0xbf000000,
216 0x44800000, 0x0000ffff}
217 },
218 { /* shader 14: writemasks, swizzles */
219 "vs_1_1\n"
220 "dp4 r0.xw, r1.wzyx, r2.xxww\n",
221 {0xfffe0101, 0x00000009, 0x80090000, 0x801b0001, 0x80f00002, 0x0000ffff}
222 },
223 { /* shader 15: negation input modifier. Other modifiers not supprted in vs_1_1 */
224 "vs_1_1\n"
225 "add r0, -r0.x, -r1\n",
226 {0xfffe0101, 0x00000002, 0x800f0000, 0x81000000, 0x81e40001, 0x0000ffff}
227 },
228 { /* shader 16: relative addressing */
229 "vs_1_1\n"
230 "mov r0, c0[a0.x]\n",
231 {0xfffe0101, 0x00000001, 0x800f0000, 0xa0e42000, 0x0000ffff}
232 },
233 { /* shader 17: relative addressing */
234 "vs_1_1\n"
235 "mov r0, c1[a0.x + 2]\n",
236 {0xfffe0101, 0x00000001, 0x800f0000, 0xa0e42003, 0x0000ffff}
237 },
238 { /* shader 18 */
239 "vs_1_1\n"
240 "def c0, 1.0f, 1.0f, 1.0f, 0.5f\n",
241 {0xfffe0101, 0x00000051, 0xa00f0000, 0x3f800000, 0x3f800000, 0x3f800000,
242 0x3f000000, 0x0000ffff}
243 },
244 /* Other relative addressing tests */
245 { /* shader 19 */
246 "vs_1_1\n"
247 "mov r0, c[ a0.x + 12 ]\n",
248 {0xfffe0101, 0x00000001, 0x800f0000, 0xa0e4200c, 0x0000ffff}
249 },
250 { /* shader 20 */
251 "vs_1_1\n"
252 "mov r0, c[ 2 + a0.x ]\n",
253 {0xfffe0101, 0x00000001, 0x800f0000, 0xa0e42002, 0x0000ffff}
254 },
255 { /* shader 21 */
256 "vs_1_1\n"
257 "mov r0, c[ 2 + a0.x + 12 ]\n",
258 {0xfffe0101, 0x00000001, 0x800f0000, 0xa0e4200e, 0x0000ffff}
259 },
260 { /* shader 22 */
261 "vs_1_1\n"
262 "mov r0, c[ 2 + 10 + 12 ]\n",
263 {0xfffe0101, 0x00000001, 0x800f0000, 0xa0e40018, 0x0000ffff}
264 },
265 { /* shader 23 */
266 "vs_1_1\n"
267 "mov r0, c4[ 2 ]\n",
268 {0xfffe0101, 0x00000001, 0x800f0000, 0xa0e40006, 0x0000ffff}
269 },
270 { /* shader 24 */
271 "vs_1_1\n"
272 "rcp r0, v0.x\n",
273 {0xfffe0101, 0x00000006, 0x800f0000, 0x90000000, 0x0000ffff}
274 },
275 { /* shader 25 */
276 "vs.1.1\n"
277 "rsq r0, v0.x\n",
278 {0xfffe0101, 0x00000007, 0x800f0000, 0x90000000, 0x0000ffff}
279 },
280 };
281
282 exec_tests("vs_1_1", tests, ARRAY_SIZE(tests));
283}
284
285static void ps_1_3_test(void) {
286 struct shader_test tests[] = {
287 /* Basic instruction tests */
288 { /* shader 0 */
289 "ps_1_3\n"
290 "mov r0, r1\n",
291 {0xffff0103, 0x00000001, 0x800f0000, 0x80e40001, 0x0000ffff}
292 },
293 { /* shader 1 */
294 "ps_1_3\n"
295 "add r0, r1, r0\n",
296 {0xffff0103, 0x00000002, 0x800f0000, 0x80e40001, 0x80e40000, 0x0000ffff}
297 },
298 /* Color interpolator tests */
299 { /* shader 2 */
300 "ps_1_3\n"
301 "mov r0, v0\n",
302 {0xffff0103, 0x00000001, 0x800f0000, 0x90e40000, 0x0000ffff}
303 },
304 { /* shader 3 */
305 "ps_1_3\n"
306 "mov r0, v1\n",
307 {0xffff0103, 0x00000001, 0x800f0000, 0x90e40001, 0x0000ffff}
308 },
309 /* Texture sampling instructions */
310 { /* shader 4 */
311 "ps_1_3\n"
312 "tex t0\n",
313 {0xffff0103, 0x00000042, 0xb00f0000, 0x0000ffff}
314 },
315 { /* shader 5 */
316 "ps_1_3\n"
317 "tex t0\n"
318 "texreg2ar t1, t0\n",
319 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000045, 0xb00f0001, 0xb0e40000,
320 0x0000ffff}
321 },
322 { /* shader 6 */
323 "ps_1_3\n"
324 "tex t0\n"
325 "texreg2gb t1, t0\n",
326 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000046, 0xb00f0001, 0xb0e40000,
327 0x0000ffff}
328 },
329 { /* shader 7 */
330 "ps_1_3\n"
331 "tex t0\n"
332 "texreg2rgb t1, t0\n",
333 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000052, 0xb00f0001, 0xb0e40000,
334 0x0000ffff}
335 },
336 { /* shader 8 */
337 "ps_1_3\n"
338 "cnd r0, r1, r0, v0\n",
339 {0xffff0103, 0x00000050, 0x800f0000, 0x80e40001, 0x80e40000, 0x90e40000,
340 0x0000ffff}
341 },
342 { /* shader 9 */
343 "ps_1_3\n"
344 "cmp r0, r1, r0, v0\n",
345 {0xffff0103, 0x00000058, 0x800f0000, 0x80e40001, 0x80e40000, 0x90e40000,
346 0x0000ffff}
347 },
348 { /* shader 10 */
349 "ps_1_3\n"
350 "texkill t0\n",
351 {0xffff0103, 0x00000041, 0xb00f0000, 0x0000ffff}
352 },
353 { /* shader 11 */
354 "ps_1_3\n"
355 "tex t0\n"
356 "texm3x2pad t1, t0\n"
357 "texm3x2tex t2, t0\n",
358 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000047, 0xb00f0001, 0xb0e40000,
359 0x00000048, 0xb00f0002, 0xb0e40000, 0x0000ffff}
360 },
361 { /* shader 12 */
362 "ps_1_3\n"
363 "tex t0\n"
364 "texm3x2pad t1, t0\n"
365 "texm3x2depth t2, t0\n",
366 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000047, 0xb00f0001, 0xb0e40000,
367 0x00000054, 0xb00f0002, 0xb0e40000, 0x0000ffff}
368 },
369 { /* shader 13 */
370 "ps_1_3\n"
371 "tex t0\n"
372 "texbem t1, t0\n",
373 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000043, 0xb00f0001, 0xb0e40000,
374 0x0000ffff}
375 },
376 { /* shader 14 */
377 "ps_1_3\n"
378 "tex t0\n"
379 "texbeml t1, t0\n",
380 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000044, 0xb00f0001, 0xb0e40000,
381 0x0000ffff}
382 },
383 { /* shader 15 */
384 "ps_1_3\n"
385 "tex t0\n"
386 "texdp3tex t1, t0\n",
387 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000053, 0xb00f0001, 0xb0e40000,
388 0x0000ffff}
389 },
390 { /* shader 16 */
391 "ps_1_3\n"
392 "tex t0\n"
393 "texdp3 t1, t0\n",
394 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000055, 0xb00f0001, 0xb0e40000,
395 0x0000ffff}
396 },
397 { /* shader 17 */
398 "ps_1_3\n"
399 "tex t0\n"
400 "texm3x3pad t1, t0\n"
401 "texm3x3pad t2, t0\n"
402 "texm3x3tex t3, t0\n",
403 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000049, 0xb00f0001, 0xb0e40000,
404 0x00000049, 0xb00f0002, 0xb0e40000, 0x0000004a, 0xb00f0003, 0xb0e40000,
405 0x0000ffff}
406 },
407 { /* shader 18 */
408 "ps_1_3\n"
409 "tex t0\n"
410 "texm3x3pad t1, t0\n"
411 "texm3x3pad t2, t0\n"
412 "texm3x3 t3, t0\n",
413 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000049, 0xb00f0001, 0xb0e40000,
414 0x00000049, 0xb00f0002, 0xb0e40000, 0x00000056, 0xb00f0003, 0xb0e40000,
415 0x0000ffff}
416 },
417 { /* shader 19 */
418 "ps_1_3\n"
419 "tex t0\n"
420 "texm3x3pad t1, t0\n"
421 "texm3x3pad t2, t0\n"
422 "texm3x3spec t3, t0, c0\n",
423 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000049, 0xb00f0001, 0xb0e40000,
424 0x00000049, 0xb00f0002, 0xb0e40000, 0x0000004c, 0xb00f0003, 0xb0e40000,
425 0xa0e40000, 0x0000ffff}
426 },
427 { /* shader 20 */
428 "ps_1_3\n"
429 "tex t0\n"
430 "texm3x3pad t1, t0\n"
431 "texm3x3pad t2, t0\n"
432 "texm3x3vspec t3, t0\n",
433 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000049, 0xb00f0001, 0xb0e40000,
434 0x00000049, 0xb00f0002, 0xb0e40000, 0x0000004d, 0xb00f0003, 0xb0e40000,
435 0x0000ffff}
436 },
437 { /* shader 21 */
438 "ps_1_3\n"
439 "texcoord t0\n",
440 {0xffff0103, 0x00000040, 0xb00f0000, 0x0000ffff}
441 },
442 /* Modifiers, shifts */
443 { /* shader 22 */
444 "ps_1_3\n"
445 "mov_x2_sat r0, 1 - r1\n",
446 {0xffff0103, 0x00000001, 0x811f0000, 0x86e40001, 0x0000ffff}
447 },
448 { /* shader 23 */
449 "ps_1_3\n"
450 "mov_d8 r0, -r1\n",
451 {0xffff0103, 0x00000001, 0x8d0f0000, 0x81e40001, 0x0000ffff}
452 },
453 { /* shader 24 */
454 "ps_1_3\n"
455 "mov_sat r0, r1_bx2\n",
456 {0xffff0103, 0x00000001, 0x801f0000, 0x84e40001, 0x0000ffff}
457 },
458 { /* shader 25 */
459 "ps_1_3\n"
460 "mov_sat r0, r1_bias\n",
461 {0xffff0103, 0x00000001, 0x801f0000, 0x82e40001, 0x0000ffff}
462 },
463 { /* shader 26 */
464 "ps_1_3\n"
465 "mov_sat r0, -r1_bias\n",
466 {0xffff0103, 0x00000001, 0x801f0000, 0x83e40001, 0x0000ffff}
467 },
468 { /* shader 27 */
469 "ps_1_3\n"
470 "mov_sat r0, -r1_bx2\n",
471 {0xffff0103, 0x00000001, 0x801f0000, 0x85e40001, 0x0000ffff}
472 },
473 { /* shader 28 */
474 "ps_1_3\n"
475 "mov_sat r0, -r1_x2\n",
476 {0xffff0103, 0x00000001, 0x801f0000, 0x88e40001, 0x0000ffff}
477 },
478 { /* shader 29 */
479 "ps_1_3\n"
480 "mov_x4_sat r0.a, -r1_bx2.a\n",
481 {0xffff0103, 0x00000001, 0x82180000, 0x85ff0001, 0x0000ffff}
482 },
483 { /* shader 30 */
484 "ps_1_3\n"
485 "texcoord_x2 t0\n",
486 {0xffff0103, 0x00000040, 0xb10f0000, 0x0000ffff}
487 },
488 { /* shader 31 */
489 "ps_1_3\n"
490 "tex_x2 t0\n",
491 {0xffff0103, 0x00000042, 0xb10f0000, 0x0000ffff}
492 },
493 { /* shader 32 */
494 "ps_1_3\n"
495 "texreg2ar_x4 t0, t1\n",
496 {0xffff0103, 0x00000045, 0xb20f0000, 0xb0e40001, 0x0000ffff}
497 },
498 { /* shader 33 */
499 "ps_1_3\n"
500 "texbem_d4 t1, t0\n",
501 {0xffff0103, 0x00000043, 0xbe0f0001, 0xb0e40000, 0x0000ffff}
502 },
503 { /* shader 34 */
504 "ps_1_3\n"
505 "tex t0\n"
506 "texm3x3pad_x2 t1, t0\n"
507 "texm3x3pad_x2 t2, t0\n"
508 "texm3x3tex_x2 t3, t0\n",
509 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000049, 0xb10f0001, 0xb0e40000,
510 0x00000049, 0xb10f0002, 0xb0e40000, 0x0000004a, 0xb10f0003, 0xb0e40000,
511 0x0000ffff}
512 },
513 { /* shader 35 */
514 "ps.1.3\n"
515 "tex t0\n"
516 "texdp3tex_x8 t1, t0\n",
517 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000053, 0xb30f0001, 0xb0e40000,
518 0x0000ffff}
519 },
520 };
521
522 exec_tests("ps_1_3", tests, ARRAY_SIZE(tests));
523}
524
525static void ps_1_4_test(void) {
526 struct shader_test tests[] = {
527 /* Basic instruction tests */
528 { /* shader 0 */
529 "ps_1_4\n"
530 "mov r0, r1\n",
531 {0xffff0104, 0x00000001, 0x800f0000, 0x80e40001, 0x0000ffff}
532 },
533 { /* shader 1 */
534 "ps_1_4\n"
535 "mov r0, r5\n",
536 {0xffff0104, 0x00000001, 0x800f0000, 0x80e40005, 0x0000ffff}
537 },
538 { /* shader 2 */
539 "ps_1_4\n"
540 "mov r0, c7\n",
541 {0xffff0104, 0x00000001, 0x800f0000, 0xa0e40007, 0x0000ffff}
542 },
543 { /* shader 3 */
544 "ps_1_4\n"
545 "mov r0, v1\n",
546 {0xffff0104, 0x00000001, 0x800f0000, 0x90e40001, 0x0000ffff}
547 },
548 { /* shader 4 */
549 "ps_1_4\n"
550 "phase\n",
551 {0xffff0104, 0x0000fffd, 0x0000ffff}
552 },
553 { /* shader 5 */
554 "ps_1_4\n"
555 "texcrd r0, t0\n",
556 {0xffff0104, 0x00000040, 0x800f0000, 0xb0e40000, 0x0000ffff}
557 },
558 { /* shader 6 */
559 "ps_1_4\n"
560 "texcrd r4, t3\n",
561 {0xffff0104, 0x00000040, 0x800f0004, 0xb0e40003, 0x0000ffff}
562 },
563 { /* shader 7 */
564 "ps_1_4\n"
565 "texcrd_sat r4, t3\n",
566 {0xffff0104, 0x00000040, 0x801f0004, 0xb0e40003, 0x0000ffff}
567 },
568 { /* shader 8 */
569 "ps_1_4\n"
570 "texld r0, t0\n",
571 {0xffff0104, 0x00000042, 0x800f0000, 0xb0e40000, 0x0000ffff}
572 },
573 { /* shader 9 */
574 "ps_1_4\n"
575 "texld r1, t4\n",
576 {0xffff0104, 0x00000042, 0x800f0001, 0xb0e40004, 0x0000ffff}
577 },
578 { /* shader 10 */
579 "ps_1_4\n"
580 "texld r5, r0\n",
581 {0xffff0104, 0x00000042, 0x800f0005, 0x80e40000, 0x0000ffff}
582 },
583 { /* shader 11 */
584 "ps_1_4\n"
585 "texld r5, c0\n", /* Assembly succeeds, validation fails */
586 {0xffff0104, 0x00000042, 0x800f0005, 0xa0e40000, 0x0000ffff}
587 },
588 { /* shader 12 */
589 "ps_1_4\n"
590 "texld r5, r2_dz\n",
591 {0xffff0104, 0x00000042, 0x800f0005, 0x89e40002, 0x0000ffff}
592 },
593 { /* shader 13 */
594 "ps_1_4\n"
595 "bem r1.rg, c0, r0\n",
596 {0xffff0104, 0x00000059, 0x80030001, 0xa0e40000, 0x80e40000, 0x0000ffff}
597 },
598 { /* shader 14 */
599 "ps_1_4\n"
600 "texdepth r5\n",
601 {0xffff0104, 0x00000057, 0x800f0005, 0x0000ffff}
602 },
603 { /* shader 15 */
604 "ps_1_4\n"
605 "add r0, r1, r2_bx2\n",
606 {0xffff0104, 0x00000002, 0x800f0000, 0x80e40001, 0x84e40002, 0x0000ffff}
607 },
608 { /* shader 16 */
609 "ps_1_4\n"
610 "add_x4 r0, r1, r2\n",
611 {0xffff0104, 0x00000002, 0x820f0000, 0x80e40001, 0x80e40002, 0x0000ffff}
612 },
613 { /* shader 17 */
614 "ps_1_4\n"
615 "add r0.rgb, r1, r2\n"
616 "+add r0.a, r1, r2\n",
617 {0xffff0104, 0x00000002, 0x80070000, 0x80e40001, 0x80e40002, 0x40000002,
618 0x80080000, 0x80e40001, 0x80e40002, 0x0000ffff}
619 },
620 { /* shader 18 */
621 "ps_1_4\n"
622 "texdepth_x2 r5\n",
623 {0xffff0104, 0x00000057, 0x810f0005, 0x0000ffff}
624 },
625 { /* shader 18 */
626 "ps.1.4\n"
627 "bem_d2 r1, c0, r0\n",
628 {0xffff0104, 0x00000059, 0x8f0f0001, 0xa0e40000, 0x80e40000, 0x0000ffff}
629 },
630 };
631
632 exec_tests("ps_1_4", tests, ARRAY_SIZE(tests));
633}
634
635static void vs_2_0_test(void) {
636 struct shader_test tests[] = {
637 /* Basic instruction tests */
638 { /* shader 0 */
639 "vs_2_0\n"
640 "mov r0, r1\n",
641 {0xfffe0200, 0x02000001, 0x800f0000, 0x80e40001, 0x0000ffff}
642 },
643 { /* shader 1 */
644 "vs_2_0\n"
645 "lrp r0, v0, c0, r1\n",
646 {0xfffe0200, 0x04000012, 0x800f0000, 0x90e40000, 0xa0e40000, 0x80e40001,
647 0x0000ffff}
648 },
649 { /* shader 2 */
650 "vs_2_0\n"
651 "dp4 oPos, v0, c0\n",
652 {0xfffe0200, 0x03000009, 0xc00f0000, 0x90e40000, 0xa0e40000, 0x0000ffff}
653 },
654 { /* shader 3 */
655 "vs_2_0\n"
656 "mov r0, c0[a0.x]\n",
657 {0xfffe0200, 0x03000001, 0x800f0000, 0xa0e42000, 0xb0000000, 0x0000ffff}
658 },
659 { /* shader 4 */
660 "vs_2_0\n"
661 "mov r0, c0[a0.y]\n",
662 {0xfffe0200, 0x03000001, 0x800f0000, 0xa0e42000, 0xb0550000, 0x0000ffff}
663 },
664 { /* shader 5 */
665 "vs_2_0\n"
666 "mov r0, c0[a0.z]\n",
667 {0xfffe0200, 0x03000001, 0x800f0000, 0xa0e42000, 0xb0aa0000, 0x0000ffff}
668 },
669 { /* shader 6 */
670 "vs_2_0\n"
671 "mov r0, c0[a0.w]\n",
672 {0xfffe0200, 0x03000001, 0x800f0000, 0xa0e42000, 0xb0ff0000, 0x0000ffff}
673 },
674 { /* shader 7 */
675 "vs_2_0\n"
676 "mov r0, c0[a0.w].x\n",
677 {0xfffe0200, 0x03000001, 0x800f0000, 0xa0002000, 0xb0ff0000, 0x0000ffff}
678 },
679 { /* shader 8 */
680 "vs_2_0\n"
681 "mov r0, -c0[a0.w+5].x\n",
682 {0xfffe0200, 0x03000001, 0x800f0000, 0xa1002005, 0xb0ff0000, 0x0000ffff}
683 },
684 { /* shader 9 */
685 "vs_2_0\n"
686 "mov r0, c0[a0]\n",
687 {0xfffe0200, 0x03000001, 0x800f0000, 0xa0e42000, 0xb0e40000, 0x0000ffff}
688 },
689 { /* shader 10 */
690 "vs_2_0\n"
691 "mov r0, c0[a0.xyww]\n",
692 {0xfffe0200, 0x03000001, 0x800f0000, 0xa0e42000, 0xb0f40000, 0x0000ffff}
693 },
694 { /* shader 11 */
695 "vs_2_0\n"
696 "add r0, c0[a0.x], c1[a0.y]\n", /* validation would fail on this line */
697 {0xfffe0200, 0x05000002, 0x800f0000, 0xa0e42000, 0xb0000000, 0xa0e42001,
698 0xb0550000, 0x0000ffff}
699 },
700 { /* shader 12 */
701 "vs_2_0\n"
702 "rep i0\n"
703 "endrep\n",
704 {0xfffe0200, 0x01000026, 0xf0e40000, 0x00000027, 0x0000ffff}
705 },
706 { /* shader 13 */
707 "vs_2_0\n"
708 "if b0\n"
709 "else\n"
710 "endif\n",
711 {0xfffe0200, 0x01000028, 0xe0e40800, 0x0000002a, 0x0000002b, 0x0000ffff}
712 },
713 { /* shader 14 */
714 "vs_2_0\n"
715 "loop aL, i0\n"
716 "endloop\n",
717 {0xfffe0200, 0x0200001b, 0xf0e40800, 0xf0e40000, 0x0000001d, 0x0000ffff}
718 },
719 { /* shader 15 */
720 "vs_2_0\n"
721 "nrm r0, c0\n",
722 {0xfffe0200, 0x02000024, 0x800f0000, 0xa0e40000, 0x0000ffff}
723 },
724 { /* shader 16 */
725 "vs_2_0\n"
726 "crs r0, r1, r2\n",
727 {0xfffe0200, 0x03000021, 0x800f0000, 0x80e40001, 0x80e40002, 0x0000ffff}
728 },
729 { /* shader 17 */
730 "vs_2_0\n"
731 "sgn r0, r1, r2, r3\n",
732 {0xfffe0200, 0x04000022, 0x800f0000, 0x80e40001, 0x80e40002, 0x80e40003,
733 0x0000ffff}
734 },
735 { /* shader 18 */
736 "vs_2_0\n"
737 "sincos r0, r1, r2, r3\n",
738 {0xfffe0200, 0x04000025, 0x800f0000, 0x80e40001, 0x80e40002, 0x80e40003,
739 0x0000ffff}
740 },
741 { /* shader 19 */
742 "vs_2_0\n"
743 "pow r0, r1, r2\n",
744 {0xfffe0200, 0x03000020, 0x800f0000, 0x80e40001, 0x80e40002, 0x0000ffff}
745 },
746 { /* shader 20 */
747 "vs_2_0\n"
748 "mova a0.y, c0.z\n",
749 {0xfffe0200, 0x0200002e, 0xb0020000, 0xa0aa0000, 0x0000ffff}
750 },
751 { /* shader 21 */
752 "vs_2_0\n"
753 "defb b0, true\n"
754 "defb b1, false\n",
755 {0xfffe0200, 0x0200002f, 0xe00f0800, 0x00000001, 0x0200002f, 0xe00f0801,
756 0x00000000, 0x0000ffff}
757 },
758 { /* shader 22 */
759 "vs_2_0\n"
760 "defi i0, -1, 1, 10, 0\n"
761 "defi i1, 0, 40, 30, 10\n",
762 {0xfffe0200, 0x05000030, 0xf00f0000, 0xffffffff, 0x00000001, 0x0000000a,
763 0x00000000, 0x05000030, 0xf00f0001, 0x00000000, 0x00000028, 0x0000001e,
764 0x0000000a, 0x0000ffff}
765 },
766 { /* shader 23 */
767 "vs_2_0\n"
768 "loop aL, i0\n"
769 "mov r0, c0[aL]\n"
770 "endloop\n",
771 {0xfffe0200, 0x0200001b, 0xf0e40800, 0xf0e40000, 0x03000001, 0x800f0000,
772 0xa0e42000, 0xf0e40800, 0x0000001d, 0x0000ffff}
773 },
774 { /* shader 24 */
775 "vs_2_0\n"
776 "call l0\n"
777 "ret\n"
778 "label l0\n"
779 "ret\n",
780 {0xfffe0200, 0x01000019, 0xa0e41000, 0x0000001c, 0x0100001e, 0xa0e41000,
781 0x0000001c, 0x0000ffff}
782 },
783 { /* shader 25 */
784 "vs_2_0\n"
785 "callnz l0, b0\n"
786 "ret\n"
787 "label l0\n"
788 "ret\n",
789 {0xfffe0200, 0x0200001a, 0xa0e41000, 0xe0e40800, 0x0000001c, 0x0100001e,
790 0xa0e41000, 0x0000001c, 0x0000ffff}
791 },
792 { /* shader 26 */
793 "vs_2_0\n"
794 "callnz l0, !b0\n"
795 "ret\n"
796 "label l0\n"
797 "ret\n",
798 {0xfffe0200, 0x0200001a, 0xa0e41000, 0xede40800, 0x0000001c, 0x0100001e,
799 0xa0e41000, 0x0000001c, 0x0000ffff}
800 },
801 { /* shader 27 */
802 "vs_2_0\n"
803 "if !b0\n"
804 "else\n"
805 "endif\n",
806 {0xfffe0200, 0x01000028, 0xede40800, 0x0000002a, 0x0000002b, 0x0000ffff}
807 },
808 { /* shader 28 */
809 "vs_2_0\n"
810 "call l3\n"
811 "ret\n"
812 "label l3\n"
813 "ret\n",
814 {0xfffe0200, 0x01000019, 0xa0e41003, 0x0000001c, 0x0100001e, 0xa0e41003, 0x0000001c, 0x0000ffff}
815 },
816 { /* shader 29: labels up to 2047 are accepted even in vs_2_0 */
817 "vs.2.0\n"
818 "call l2047\n",
819 {0xfffe0200, 0x01000019, 0xa0e417ff, 0x0000ffff}
820 },
821 };
822
823 exec_tests("vs_2_0", tests, ARRAY_SIZE(tests));
824}
825
826static void vs_2_x_test(void) {
827 struct shader_test tests[] = {
828 { /* shader 0 */
829 "vs_2_x\n"
830 "rep i0\n"
831 "break\n"
832 "endrep\n",
833 {0xfffe0201, 0x01000026, 0xf0e40000, 0x0000002c, 0x00000027, 0x0000ffff}
834 },
835 { /* shader 1 */
836 "vs_2_x\n"
837 "if_ge r0, r1\n"
838 "endif\n",
839 {0xfffe0201, 0x02030029, 0x80e40000, 0x80e40001, 0x0000002b, 0x0000ffff}
840 },
841 { /* shader 2 */
842 "vs_2_x\n"
843 "rep i0\n"
844 "break_ne r0, r1\n"
845 "endrep",
846 {0xfffe0201, 0x01000026, 0xf0e40000, 0x0205002d, 0x80e40000, 0x80e40001,
847 0x00000027, 0x0000ffff}
848 },
849
850 /* predicates */
851 { /* shader 3 */
852 "vs_2_x\n"
853 "setp_gt p0, r0, r1\n"
854 "(!p0) add r2, r2, r3\n",
855 {0xfffe0201, 0x0301005e, 0xb00f1000, 0x80e40000, 0x80e40001, 0x14000002,
856 0x800f0002, 0xbde41000, 0x80e40002, 0x80e40003, 0x0000ffff}
857 },
858 { /* shader 4 */
859 "vs_2_x\n"
860 "if p0.x\n"
861 "else\n"
862 "endif\n",
863 {0xfffe0201, 0x01000028, 0xb0001000, 0x0000002a, 0x0000002b, 0x0000ffff}
864 },
865 { /* shader 5 */
866 "vs_2_x\n"
867 "callnz l0, !p0.z\n"
868 "ret\n"
869 "label l0\n"
870 "ret\n",
871 {0xfffe0201, 0x0200001a, 0xa0e41000, 0xbdaa1000, 0x0000001c,
872 0x0100001e, 0xa0e41000, 0x0000001c, 0x0000ffff}
873 },
874 { /* shader 6 */
875 "vs.2.x\n"
876 "rep i0\n"
877 "breakp p0.w\n"
878 "endrep\n",
879 {0xfffe0201, 0x01000026, 0xf0e40000, 0x01000060, 0xb0ff1000,
880 0x00000027, 0x0000ffff}
881 },
882 };
883
884 exec_tests("vs_2_x", tests, ARRAY_SIZE(tests));
885}
886
887static void ps_2_0_test(void) {
888 struct shader_test tests[] = {
889 { /* shader 0 */
890 "ps_2_0\n"
891 "dcl_2d s0\n",
892 {0xffff0200, 0x0200001f, 0x90000000, 0xa00f0800, 0x0000ffff}
893 },
894 { /* shader 1 */
895 "ps_2_0\n"
896 "dcl_cube s0\n",
897 {0xffff0200, 0x0200001f, 0x98000000, 0xa00f0800, 0x0000ffff}
898 },
899 { /* shader 2 */
900 "ps_2_0\n"
901 "dcl_volume s0\n",
902 {0xffff0200, 0x0200001f, 0xa0000000, 0xa00f0800, 0x0000ffff}
903 },
904 { /* shader 3 */
905 "ps_2_0\n"
906 "dcl_volume s0\n"
907 "dcl_cube s1\n"
908 "dcl_2d s2\n",
909 {0xffff0200, 0x0200001f, 0xa0000000, 0xa00f0800, 0x0200001f, 0x98000000,
910 0xa00f0801, 0x0200001f, 0x90000000, 0xa00f0802, 0x0000ffff}
911 },
912 { /* shader 4 */
913 "ps_2_0\n"
914 "mov r0, t0\n",
915 {0xffff0200, 0x02000001, 0x800f0000, 0xb0e40000, 0x0000ffff}
916 },
917 { /* shader 5 */
918 "ps_2_0\n"
919 "dcl_2d s2\n"
920 "texld r0, t1, s2\n",
921 {0xffff0200, 0x0200001f, 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000,
922 0xb0e40001, 0xa0e40802, 0x0000ffff}
923 },
924 { /* shader 6 */
925 "ps_2_0\n"
926 "texkill t0\n",
927 {0xffff0200, 0x01000041, 0xb00f0000, 0x0000ffff}
928 },
929 { /* shader 7 */
930 "ps_2_0\n"
931 "mov oC0, c0\n"
932 "mov oC1, c1\n",
933 {0xffff0200, 0x02000001, 0x800f0800, 0xa0e40000, 0x02000001, 0x800f0801,
934 0xa0e40001, 0x0000ffff}
935 },
936 { /* shader 8 */
937 "ps_2_0\n"
938 "mov oDepth, c0.x\n",
939 {0xffff0200, 0x02000001, 0x900f0800, 0xa0000000, 0x0000ffff}
940 },
941 { /* shader 9 */
942 "ps_2_0\n"
943 "dcl_2d s2\n"
944 "texldp r0, t1, s2\n",
945 {0xffff0200, 0x0200001f, 0x90000000, 0xa00f0802, 0x03010042, 0x800f0000,
946 0xb0e40001, 0xa0e40802, 0x0000ffff}
947 },
948 { /* shader 10 */
949 "ps.2.0\n"
950 "dcl_2d s2\n"
951 "texldb r0, t1, s2\n",
952 {0xffff0200, 0x0200001f, 0x90000000, 0xa00f0802, 0x03020042, 0x800f0000,
953 0xb0e40001, 0xa0e40802, 0x0000ffff}
954 },
955 };
956
957 exec_tests("ps_2_0", tests, ARRAY_SIZE(tests));
958}
959
960static void ps_2_x_test(void) {
961 struct shader_test tests[] = {
962 /* defb and defi are not supposed to work in ps_2_0 (even if defb actually works in ps_2_0 with native) */
963 { /* shader 0 */
964 "ps_2_x\n"
965 "defb b0, true\n"
966 "defb b1, false\n",
967 {0xffff0201, 0x0200002f, 0xe00f0800, 0x00000001, 0x0200002f, 0xe00f0801,
968 0x00000000, 0x0000ffff}
969 },
970 { /* shader 1 */
971 "ps_2_x\n"
972 "defi i0, -1, 1, 10, 0\n"
973 "defi i1, 0, 40, 30, 10\n",
974 {0xffff0201, 0x05000030, 0xf00f0000, 0xffffffff, 0x00000001, 0x0000000a,
975 0x00000000, 0x05000030, 0xf00f0001, 0x00000000, 0x00000028, 0x0000001e,
976 0x0000000a, 0x0000ffff}
977 },
978 { /* shader 2 */
979 "ps_2_x\n"
980 "dsx r0, r0\n",
981 {0xffff0201, 0x0200005b, 0x800f0000, 0x80e40000, 0x0000ffff}
982 },
983 { /* shader 3 */
984 "ps_2_x\n"
985 "dsy r0, r0\n",
986 {0xffff0201, 0x0200005c, 0x800f0000, 0x80e40000, 0x0000ffff}
987 },
988 { /* shader 4 */
989 "ps_2_x\n"
990 "dcl_2d s2\n"
991 "texldd r0, v1, s2, r3, r4\n",
992 {0xffff0201, 0x0200001f, 0x90000000, 0xa00f0802, 0x0500005d, 0x800f0000,
993 0x90e40001, 0xa0e40802, 0x80e40003, 0x80e40004, 0x0000ffff}
994 },
995 /* Static flow control tests */
996 { /* shader 5 */
997 "ps_2_x\n"
998 "call l0\n"
999 "ret\n"
1000 "label l0\n"
1001 "ret\n",
1002 {0xffff0201, 0x01000019, 0xa0e41000, 0x0000001c, 0x0100001e, 0xa0e41000,
1003 0x0000001c, 0x0000ffff}
1004 },
1005 { /* shader 6 */
1006 "ps_2_x\n"
1007 "callnz l0, b0\n"
1008 "ret\n"
1009 "label l0\n"
1010 "ret\n",
1011 {0xffff0201, 0x0200001a, 0xa0e41000, 0xe0e40800, 0x0000001c, 0x0100001e,
1012 0xa0e41000, 0x0000001c, 0x0000ffff}
1013 },
1014 { /* shader 7 */
1015 "ps_2_x\n"
1016 "callnz l0, !b0\n"
1017 "ret\n"
1018 "label l0\n"
1019 "ret\n",
1020 {0xffff0201, 0x0200001a, 0xa0e41000, 0xede40800, 0x0000001c, 0x0100001e,
1021 0xa0e41000, 0x0000001c, 0x0000ffff}
1022 },
1023 { /* shader 8 */
1024 "ps_2_x\n"
1025 "if !b0\n"
1026 "else\n"
1027 "endif\n",
1028 {0xffff0201, 0x01000028, 0xede40800, 0x0000002a, 0x0000002b, 0x0000ffff}
1029 },
1030 /* Dynamic flow control tests */
1031 { /* shader 9 */
1032 "ps_2_x\n"
1033 "rep i0\n"
1034 "break\n"
1035 "endrep\n",
1036 {0xffff0201, 0x01000026, 0xf0e40000, 0x0000002c, 0x00000027, 0x0000ffff}
1037 },
1038 { /* shader 10 */
1039 "ps_2_x\n"
1040 "if_ge r0, r1\n"
1041 "endif\n",
1042 {0xffff0201, 0x02030029, 0x80e40000, 0x80e40001, 0x0000002b, 0x0000ffff}
1043 },
1044 { /* shader 11 */
1045 "ps_2_x\n"
1046 "rep i0\n"
1047 "break_ne r0, r1\n"
1048 "endrep",
1049 {0xffff0201, 0x01000026, 0xf0e40000, 0x0205002d, 0x80e40000, 0x80e40001,
1050 0x00000027, 0x0000ffff}
1051 },
1052 /* Predicates */
1053 { /* shader 12 */
1054 "ps_2_x\n"
1055 "setp_gt p0, r0, r1\n"
1056 "(!p0) add r2, r2, r3\n",
1057 {0xffff0201, 0x0301005e, 0xb00f1000, 0x80e40000, 0x80e40001, 0x14000002,
1058 0x800f0002, 0xbde41000, 0x80e40002, 0x80e40003, 0x0000ffff}
1059 },
1060 { /* shader 13 */
1061 "ps_2_x\n"
1062 "if p0.x\n"
1063 "else\n"
1064 "endif\n",
1065 {0xffff0201, 0x01000028, 0xb0001000, 0x0000002a, 0x0000002b, 0x0000ffff}
1066 },
1067 { /* shader 14 */
1068 "ps_2_x\n"
1069 "callnz l0, !p0.z\n"
1070 "ret\n"
1071 "label l0\n"
1072 "ret\n",
1073 {0xffff0201, 0x0200001a, 0xa0e41000, 0xbdaa1000, 0x0000001c,
1074 0x0100001e, 0xa0e41000, 0x0000001c, 0x0000ffff}
1075 },
1076 { /* shader 15 */
1077 "ps_2_x\n"
1078 "rep i0\n"
1079 "breakp p0.w\n"
1080 "endrep\n",
1081 {0xffff0201, 0x01000026, 0xf0e40000, 0x01000060, 0xb0ff1000,
1082 0x00000027, 0x0000ffff}
1083 },
1084 { /* shader 16 */
1085 "ps.2.x\n"
1086 "call l2047\n"
1087 "ret\n"
1088 "label l2047\n"
1089 "ret\n",
1090 {0xffff0201, 0x01000019, 0xa0e417ff, 0x0000001c, 0x0100001e, 0xa0e417ff,
1091 0x0000001c, 0x0000ffff}
1092 },
1093 };
1094
1095 exec_tests("ps_2_x", tests, ARRAY_SIZE(tests));
1096}
1097
1098static void vs_3_0_test(void) {
1099 struct shader_test tests[] = {
1100 { /* shader 0 */
1101 "vs_3_0\n"
1102 "mov r0, c0\n",
1103 {0xfffe0300, 0x02000001, 0x800f0000, 0xa0e40000, 0x0000ffff}
1104 },
1105 { /* shader 1 */
1106 "vs_3_0\n"
1107 "dcl_2d s0\n",
1108 {0xfffe0300, 0x0200001f, 0x90000000, 0xa00f0800, 0x0000ffff}
1109 },
1110 { /* shader 2 */
1111 "vs_3_0\n"
1112 "dcl_position o0\n",
1113 {0xfffe0300, 0x0200001f, 0x80000000, 0xe00f0000, 0x0000ffff}
1114 },
1115 { /* shader 3 */
1116 "vs_3_0\n"
1117 "dcl_texcoord12 o11\n",
1118 {0xfffe0300, 0x0200001f, 0x800c0005, 0xe00f000b, 0x0000ffff}
1119 },
1120 { /* shader 4 */
1121 "vs_3_0\n"
1122 "texldl r0, v0, s0\n",
1123 {0xfffe0300, 0x0300005f, 0x800f0000, 0x90e40000, 0xa0e40800, 0x0000ffff}
1124 },
1125 { /* shader 5 */
1126 "vs_3_0\n"
1127 "mov r0, c0[aL]\n",
1128 {0xfffe0300, 0x03000001, 0x800f0000, 0xa0e42000, 0xf0e40800, 0x0000ffff}
1129 },
1130 { /* shader 6 */
1131 "vs_3_0\n"
1132 "mov o[ a0.x + 12 ], r0\n",
1133 {0xfffe0300, 0x03000001, 0xe00f200c, 0xb0000000, 0x80e40000, 0x0000ffff}
1134 },
1135 { /* shader 7 */
1136 "vs_3_0\n"
1137 "add_sat r0, r0, r1\n",
1138 {0xfffe0300, 0x03000002, 0x801f0000, 0x80e40000, 0x80e40001, 0x0000ffff}
1139 },
1140 { /* shader 8 */
1141 "vs_3_0\n"
1142 "mov r2, r1_abs\n",
1143 {0xfffe0300, 0x02000001, 0x800f0002, 0x8be40001, 0x0000ffff}
1144 },
1145 { /* shader 9 */
1146 "vs_3_0\n"
1147 "mov r2, r1.xygb\n",
1148 {0xfffe0300, 0x02000001, 0x800f0002, 0x80940001, 0x0000ffff}
1149 },
1150 { /* shader 10 */
1151 "vs_3_0\n"
1152 "mov r2.xyb, r1\n",
1153 {0xfffe0300, 0x02000001, 0x80070002, 0x80e40001, 0x0000ffff}
1154 },
1155 { /* shader 11 */
1156 "vs_3_0\n"
1157 "mova_sat a0.x, r1\n",
1158 {0xfffe0300, 0x0200002e, 0xb0110000, 0x80e40001, 0x0000ffff}
1159 },
1160 { /* shader 12 */
1161 "vs_3_0\n"
1162 "sincos r0, r1\n",
1163 {0xfffe0300, 0x02000025, 0x800f0000, 0x80e40001, 0x0000ffff}
1164 },
1165 { /* shader 13 */
1166 "vs_3_0\n"
1167 "def c0, 1.0f, 1.0f, 1.0f, 0.5f\n",
1168 {0xfffe0300, 0x05000051, 0xa00f0000, 0x3f800000, 0x3f800000, 0x3f800000,
1169 0x3f000000, 0x0000ffff}
1170 },
1171 { /* shader 14: no register number checks with relative addressing */
1172 "vs.3.0\n"
1173 "add r0, v20[aL], r2\n",
1174 {0xfffe0300, 0x04000002, 0x800f0000, 0x90e42014, 0xf0e40800, 0x80e40002,
1175 0x0000ffff}
1176 },
1177
1178 };
1179
1180 exec_tests("vs_3_0", tests, ARRAY_SIZE(tests));
1181}
1182
1183static void ps_3_0_test(void) {
1184 struct shader_test tests[] = {
1185 { /* shader 0 */
1186 "ps_3_0\n"
1187 "mov r0, c0\n",
1188 {0xffff0300, 0x02000001, 0x800f0000, 0xa0e40000, 0x0000ffff}
1189 },
1190 { /* shader 1 */
1191 "ps_3_0\n"
1192 "dcl_normal5 v0\n",
1193 {0xffff0300, 0x0200001f, 0x80050003, 0x900f0000, 0x0000ffff}
1194 },
1195 { /* shader 2 */
1196 "ps_3_0\n"
1197 "mov r0, vPos\n",
1198 {0xffff0300, 0x02000001, 0x800f0000, 0x90e41000, 0x0000ffff}
1199 },
1200 { /* shader 3 */
1201 "ps_3_0\n"
1202 "mov r0, vFace\n",
1203 {0xffff0300, 0x02000001, 0x800f0000, 0x90e41001, 0x0000ffff}
1204 },
1205 { /* shader 4 */
1206 "ps_3_0\n"
1207 "mov r0, v[ aL + 12 ]\n",
1208 {0xffff0300, 0x03000001, 0x800f0000, 0x90e4200c, 0xf0e40800, 0x0000ffff}
1209 },
1210 { /* shader 5 */
1211 "ps_3_0\n"
1212 "loop aL, i0\n"
1213 "mov r0, v0[aL]\n"
1214 "endloop\n",
1215 {0xffff0300, 0x0200001b, 0xf0e40800, 0xf0e40000, 0x03000001, 0x800f0000,
1216 0x90e42000, 0xf0e40800, 0x0000001d, 0x0000ffff}
1217 },
1218 { /* shader 6 */
1219 "ps_3_0\n"
1220 "texldl r0, v0, s0\n",
1221 {0xffff0300, 0x0300005f, 0x800f0000, 0x90e40000, 0xa0e40800, 0x0000ffff}
1222 },
1223 { /* shader 7 */
1224 "ps_3_0\n"
1225 "add_pp r0, r0, r1\n",
1226 {0xffff0300, 0x03000002, 0x802f0000, 0x80e40000, 0x80e40001, 0x0000ffff}
1227 },
1228 { /* shader 8 */
1229 "ps_3_0\n"
1230 "dsx_sat r0, r1\n",
1231 {0xffff0300, 0x0200005b, 0x801f0000, 0x80e40001, 0x0000ffff}
1232 },
1233 { /* shader 9 */
1234 "ps_3_0\n"
1235 "texldd_pp r0, r1, r2, r3, r4\n",
1236 {0xffff0300, 0x0500005d, 0x802f0000, 0x80e40001, 0x80e40002, 0x80e40003,
1237 0x80e40004, 0x0000ffff}
1238 },
1239 { /* shader 10 */
1240 "ps_3_0\n"
1241 "texkill v0\n",
1242 {0xffff0300, 0x01000041, 0x900f0000, 0x0000ffff}
1243 },
1244 { /* shader 11 */
1245 "ps_3_0\n"
1246 "add oC3, r0, r1\n",
1247 {0xffff0300, 0x03000002, 0x800f0803, 0x80e40000, 0x80e40001, 0x0000ffff}
1248 },
1249 { /* shader 12 */
1250 "ps_3_0\n"
1251 "dcl_texcoord0_centroid v0\n",
1252 {0xffff0300, 0x0200001f, 0x80000005, 0x904f0000, 0x0000ffff}
1253 },
1254 { /* shader 13 */
1255 "ps_3_0\n"
1256 "dcl_2d_centroid s0\n",
1257 {0xffff0300, 0x0200001f, 0x90000000, 0xa04f0800, 0x0000ffff}
1258 },
1259 { /* shader 14 */
1260 "ps.3.0\n"
1261 "dcl_2d_pp s0\n",
1262 {0xffff0300, 0x0200001f, 0x90000000, 0xa02f0800, 0x0000ffff}
1263 },
1264 };
1265
1266 exec_tests("ps_3_0", tests, ARRAY_SIZE(tests));
1267}
1268
1269static void failure_test(void) {
1270 const char * tests[] = {
1271 /* shader 0: instruction modifier not allowed */
1272 "ps_3_0\n"
1273 "dcl_2d s2\n"
1274 "texldd_x2 r0, v1, s2, v3, v4\n",
1275 /* shader 1: coissue not supported in vertex shaders */
1276 "vs.1.1\r\n"
1277 "add r0.rgb, r0, r1\n"
1278 "+add r0.a, r0, r2\n",
1279 /* shader 2: coissue not supported in pixel shader version >= 2.0 */
1280 "ps_2_0\n"
1281 "texld r0, t0, s0\n"
1282 "add r0.rgb, r0, r1\n"
1283 "+add r0.a, r0, v1\n",
1284 /* shader 3: predicates not supported in vertex shader < 2.0 */
1285 "vs_1_1\n"
1286 "(p0) add r0, r0, v0\n",
1287 /* shader 4: register a0 doesn't exist in pixel shaders */
1288 "ps_3_0\n"
1289 "mov r0, v[ a0 + 12 ]\n",
1290 /* shader 5: s0 doesn't exist in vs_1_1 */
1291 "vs_1_1\n"
1292 "mov r0, s0\n",
1293 /* shader 6: aL is a scalar register, no swizzles allowed */
1294 "ps_3_0\n"
1295 "mov r0, v[ aL.x + 12 ]\n",
1296 /* shader 7: tn doesn't exist in ps_3_0 */
1297 "ps_3_0\n"
1298 "dcl_2d s2\n"
1299 "texldd r0, t1, s2, v3, v4\n",
1300 /* shader 8: two shift modifiers */
1301 "ps_1_3\n"
1302 "mov_x2_x2 r0, r1\n",
1303 /* shader 9: too many source registers for mov instruction */
1304 "vs_1_1\n"
1305 "mov r0, r1, r2\n",
1306 /* shader 10: invalid combination of negate and divide modifiers */
1307 "ps_1_4\n"
1308 "texld r5, -r2_dz\n",
1309 /* shader 11: complement modifier not allowed in >= PS 2 */
1310 "ps_2_0\n"
1311 "mov r2, 1 - r0\n",
1312 /* shader 12: invalid modifier */
1313 "vs_3_0\n"
1314 "mov r2, 2 - r0\n",
1315 /* shader 13: float value in relative addressing */
1316 "vs_3_0\n"
1317 "mov r2, c[ aL + 3.4 ]\n",
1318 /* shader 14: complement modifier not available in VS */
1319 "vs_3_0\n"
1320 "mov r2, 1 - r1\n",
1321 /* shader 15: _x2 modifier not available in VS */
1322 "vs_1_1\n"
1323 "mov r2, r1_x2\n",
1324 /* shader 16: _abs modifier not available in < VS 3.0 */
1325 "vs_1_1\n"
1326 "mov r2, r1_abs\n",
1327 /* shader 17: _x2 modifier not available in >= PS 2.0 */
1328 "ps_2_0\n"
1329 "mov r0, r1_x2\n",
1330 /* shader 18: wrong swizzle */
1331 "vs_2_0\n"
1332 "mov r0, r1.abcd\n",
1333 /* shader 19: wrong swizzle */
1334 "vs_2_0\n"
1335 "mov r0, r1.xyzwx\n",
1336 /* shader 20: wrong swizzle */
1337 "vs_2_0\n"
1338 "mov r0, r1.\n",
1339 /* shader 21: invalid writemask */
1340 "vs_2_0\n"
1341 "mov r0.xxyz, r1\n",
1342 /* shader 22: register r5 doesn't exist in PS < 1.4 */
1343 "ps_1_3\n"
1344 "mov r5, r0\n",
1345 /* shader 23: can't declare output registers in a pixel shader */
1346 "ps_3_0\n"
1347 "dcl_positiont o0\n",
1348 /* shader 24: _pp instruction modifier not allowed in vertex shaders */
1349 "vs_3_0\n"
1350 "add_pp r0, r0, r1\n",
1351 /* shader 25: _x4 instruction modified not allowed in > ps_1_x */
1352 "ps_3_0\n"
1353 "add_x4 r0, r0, r1\n",
1354 /* shader 26: there aren't oCx registers in ps_1_x */
1355 "ps_1_3\n"
1356 "add oC0, r0, r1\n",
1357 /* shader 27: oC3 is the max in >= ps_2_0 */
1358 "ps_3_0\n"
1359 "add oC4, r0, r1\n",
1360 /* shader 28: register v17 doesn't exist */
1361 "vs_3_0\n"
1362 "add r0, r0, v17\n",
1363 /* shader 29: register o13 doesn't exist */
1364 "vs_3_0\n"
1365 "add o13, r0, r1\n",
1366 /* shader 30: label > 2047 not allowed */
1367 "vs_3_0\n"
1368 "call l2048\n",
1369 /* shader 31: s20 register does not exist */
1370 "ps_3_0\n"
1371 "texld r0, r1, s20\n",
1372 /* shader 32: t5 not allowed in ps_1_3 */
1373 "ps_1_3\n"
1374 "tex t5\n",
1375 /* shader 33: no temporary registers relative addressing */
1376 "vs_3_0\n"
1377 "add r0, r0[ a0.x ], r1\n",
1378 /* shader 34: no input registers relative addressing in vs_2_0 */
1379 "vs_2_0\n"
1380 "add r0, v[ a0.x ], r1\n",
1381 /* shader 35: no aL register in ps_2_0 */
1382 "ps_2_0\n"
1383 "add r0, v[ aL ], r1\n",
1384 /* shader 36: no relative addressing in ps_2_0 */
1385 "ps_2_0\n"
1386 "add r0, v[ r0 ], r1\n",
1387 /* shader 37: no a0 register in ps_3_0 */
1388 "ps_3_0\n"
1389 "add r0, v[ a0.x ], r1\n",
1390 /* shader 38: only a0.x accepted in vs_1_1 */
1391 "vs_1_1\n"
1392 "mov r0, c0[ a0 ]\n",
1393 /* shader 39: invalid modifier for dcl instruction */
1394 "ps_3_0\n"
1395 "dcl_texcoord0_sat v0\n",
1396 /* shader 40: shift not allowed */
1397 "ps_3_0\n"
1398 "dcl_texcoord0_x2 v0\n",
1399 /* shader 41: no modifier allowed with dcl instruction in vs */
1400 "vs_3_0\n"
1401 "dcl_texcoord0_centroid v0\n",
1402 /* shader 42: no modifiers with vs dcl sampler instruction */
1403 "vs_3_0\n"
1404 "dcl_2d_pp s0\n",
1405 /* shader 43: */
1406 "ps_2_0\n"
1407 "texm3x3vspec t3, t0\n",
1408 };
1409 HRESULT hr;
1410 unsigned int i;
1412
1413 for(i = 0; i < ARRAY_SIZE(tests); i++)
1414 {
1415 shader = NULL;
1416 messages = NULL;
1417 hr = pD3DAssemble(tests[i], strlen(tests[i]), NULL,
1419 &shader, &messages);
1420 ok(hr == D3DXERR_INVALIDDATA, "Failure test, shader %d: "
1421 "expected D3DAssemble failure with D3DXERR_INVALIDDATA, "
1422 "got 0x%x - %d\n", i, hr, hr & 0x0000FFFF);
1423 if(messages) {
1424 trace("D3DAssemble messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
1425 ID3D10Blob_Release(messages);
1426 }
1427 if(shader) {
1428 DWORD *res = ID3D10Blob_GetBufferPointer(shader);
1430 ID3D10Blob_Release(shader);
1431 }
1432 }
1433}
1434
1436 const char *filename, const void *parent_data, const void **data, UINT *bytes)
1437{
1438 static const char include[] = "#define REGISTER r0\nvs.1.1\n";
1439 static const char include2[] = "#include \"incl3.vsh\"\n";
1440 static const char include3[] = "vs.1.1\n";
1441 static const char include4[] = "#include <incl3.vsh>\n";
1442 char *buffer;
1443
1444 trace("include_type = %d, filename %s\n", include_type, filename);
1445 trace("parent_data (%p) -> %s\n", parent_data, parent_data ? (char *)parent_data : "(null)");
1446
1447 if (!strcmp(filename, "incl.vsh"))
1448 {
1449 buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include));
1450 CopyMemory(buffer, include, sizeof(include));
1451 *bytes = sizeof(include);
1452 ok(!parent_data, "Wrong parent_data value.\n");
1453 }
1454 else if (!strcmp(filename, "incl2.vsh"))
1455 {
1456 buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include2));
1457 CopyMemory(buffer, include2, sizeof(include2));
1458 *bytes = sizeof(include2);
1459 ok(!parent_data, "Wrong parent_data value.\n");
1460 ok(include_type == D3D_INCLUDE_LOCAL, "Wrong include type %d.\n", include_type);
1461 }
1462 else if (!strcmp(filename, "incl3.vsh"))
1463 {
1464 buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include3));
1465 CopyMemory(buffer, include3, sizeof(include3));
1466 *bytes = sizeof(include3);
1467 /* Also check for the correct parent_data content */
1468 ok(parent_data != NULL
1469 && (!strncmp(include2, parent_data, strlen(include2))
1470 || !strncmp(include4, parent_data, strlen(include4))),
1471 "Wrong parent_data value.\n");
1472 }
1473 else if (!strcmp(filename, "incl4.vsh"))
1474 {
1475 buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include4));
1476 CopyMemory(buffer, include4, sizeof(include4));
1477 *bytes = sizeof(include4);
1478 ok(parent_data == NULL, "Wrong parent_data value.\n");
1479 ok(include_type == D3D_INCLUDE_SYSTEM, "Wrong include type %d.\n", include_type);
1480 }
1481 else if (!strcmp(filename, "includes/incl.vsh"))
1482 {
1483 buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include));
1484 CopyMemory(buffer, include, sizeof(include));
1485 *bytes = sizeof(include);
1486 ok(!parent_data, "Wrong parent_data value.\n");
1487 }
1488 else
1489 {
1490 ok(FALSE, "Unexpected file %s included.\n", filename);
1491 return E_FAIL;
1492 }
1493
1494 *data = buffer;
1495
1496 return S_OK;
1497}
1498
1500{
1501 HeapFree(GetProcessHeap(), 0, (void *)data);
1502 return S_OK;
1503}
1504
1505static const struct ID3DIncludeVtbl D3DInclude_Vtbl =
1506{
1509};
1510
1513};
1514
1515static void assembleshader_test(void) {
1516 static const char test1[] =
1517 {
1518 "vs.1.1\n"
1519 "mov DEF2, v0\n"
1520 };
1521 static const char testshader[] =
1522 {
1523 "#include \"incl.vsh\"\n"
1524 "mov REGISTER, v0\n"
1525 };
1526 static const D3D_SHADER_MACRO defines[] =
1527 {
1528 {
1529 "DEF1", "10 + 15"
1530 },
1531 {
1532 "DEF2", "r0"
1533 },
1534 {
1535 NULL, NULL
1536 }
1537 };
1538 HRESULT hr;
1540 struct D3DIncludeImpl include;
1541
1542 /* defines test */
1543 shader = NULL;
1544 messages = NULL;
1545 hr = pD3DAssemble(test1, strlen(test1), NULL,
1547 &shader, &messages);
1548 ok(hr == S_OK, "defines test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
1549 if(messages) {
1550 trace("D3DAssemble messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
1551 ID3D10Blob_Release(messages);
1552 }
1553 if(shader) ID3D10Blob_Release(shader);
1554
1555 /* NULL messages test */
1556 shader = NULL;
1557 hr = pD3DAssemble(test1, strlen(test1), NULL,
1559 &shader, NULL);
1560 ok(hr == S_OK, "NULL messages test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
1561 if(shader) ID3D10Blob_Release(shader);
1562
1563 /* NULL shader test */
1564 messages = NULL;
1565 hr = pD3DAssemble(test1, strlen(test1), NULL,
1567 NULL, &messages);
1568 ok(hr == S_OK, "NULL shader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
1569 if(messages) {
1570 trace("D3DAssemble messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
1571 ID3D10Blob_Release(messages);
1572 }
1573
1574 /* D3DInclude test */
1575 shader = NULL;
1576 messages = NULL;
1577 include.ID3DInclude_iface.lpVtbl = &D3DInclude_Vtbl;
1578 hr = pD3DAssemble(testshader, strlen(testshader), NULL, NULL, &include.ID3DInclude_iface,
1580 ok(hr == S_OK, "D3DInclude test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
1581 if(messages) {
1582 trace("D3DAssemble messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
1583 ID3D10Blob_Release(messages);
1584 }
1585 if(shader) ID3D10Blob_Release(shader);
1586
1587 /* NULL shader tests */
1588 shader = NULL;
1589 messages = NULL;
1590 hr = pD3DAssemble(NULL, 0, NULL,
1592 &shader, &messages);
1593 ok(hr == D3DXERR_INVALIDDATA, "NULL shader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
1594 if(messages) {
1595 trace("D3DAssemble messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
1596 ID3D10Blob_Release(messages);
1597 }
1598 if(shader) ID3D10Blob_Release(shader);
1599}
1600
1601static void d3dpreprocess_test(void)
1602{
1603 static const char test1[] =
1604 {
1605 "vs.1.1\n"
1606 "mov DEF2, v0\n"
1607 };
1608 static const char quotation_marks_test[] =
1609 {
1610 "vs.1.1\n"
1611 "; ' comment\n"
1612 "; \" comment\n"
1613 "mov 0, v0\n"
1614 };
1615 static const char *include_test_shaders[] =
1616 {
1617 "#include \"incl.vsh\"\n"
1618 "mov REGISTER, v0\n",
1619
1620 "#include \"incl2.vsh\"\n"
1621 "mov REGISTER, v0\n",
1622
1623 "#include <incl.vsh>\n"
1624 "mov REGISTER, v0\n",
1625
1626 "#include <incl4.vsh>\n"
1627 "mov REGISTER, v0\n",
1628
1629 "#include \"includes/incl.vsh\"\n"
1630 "mov REGISTER, v0\n"
1631 };
1632 HRESULT hr;
1634 static const D3D_SHADER_MACRO defines[] =
1635 {
1636 {
1637 "DEF1", "10 + 15"
1638 },
1639 {
1640 "DEF2", "r0"
1641 },
1642 {
1643 NULL, NULL
1644 }
1645 };
1646 struct D3DIncludeImpl include;
1647 unsigned int i;
1648
1649 /* pDefines test */
1650 shader = NULL;
1651 messages = NULL;
1654 ok(hr == S_OK, "pDefines test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
1655 if (messages)
1656 {
1657 trace("D3DPreprocess messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
1658 ID3D10Blob_Release(messages);
1659 }
1660 if (shader) ID3D10Blob_Release(shader);
1661
1662 /* NULL messages test */
1663 shader = NULL;
1665 defines, NULL, &shader, NULL);
1666 ok(hr == S_OK, "NULL messages test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
1667 if (shader) ID3D10Blob_Release(shader);
1668
1669 /* NULL shader test */
1670 messages = NULL;
1673 ok(hr == E_INVALIDARG, "NULL shader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
1674 if (messages)
1675 {
1676 trace("D3DPreprocess messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
1677 ID3D10Blob_Release(messages);
1678 }
1679
1680 /* quotation marks test */
1681 shader = NULL;
1682 messages = NULL;
1683 hr = ppD3DPreprocess(quotation_marks_test, strlen(quotation_marks_test), NULL,
1684 NULL, NULL, &shader, &messages);
1685 todo_wine ok(hr == S_OK, "quotation marks test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
1686 if (messages)
1687 {
1688 trace("D3DPreprocess messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
1689 ID3D10Blob_Release(messages);
1690 }
1691 if (shader) ID3D10Blob_Release(shader);
1692
1693 /* pInclude tests */
1694 include.ID3DInclude_iface.lpVtbl = &D3DInclude_Vtbl;
1695 for (i = 0; i < ARRAY_SIZE(include_test_shaders); ++i)
1696 {
1697 shader = NULL;
1698 messages = NULL;
1699 hr = ppD3DPreprocess(include_test_shaders[i], strlen(include_test_shaders[i]), NULL, NULL,
1700 &include.ID3DInclude_iface, &shader, &messages);
1701 ok(hr == S_OK, "pInclude test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
1702 if (messages)
1703 {
1704 trace("D3DPreprocess messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
1705 ID3D10Blob_Release(messages);
1706 }
1707 if (shader) ID3D10Blob_Release(shader);
1708 }
1709
1710 /* NULL shader tests */
1711 shader = NULL;
1712 messages = NULL;
1714 NULL, NULL, &shader, &messages);
1715 ok(hr == E_INVALIDARG, "NULL shader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
1716 if (messages)
1717 {
1718 trace("D3DPreprocess messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
1719 ID3D10Blob_Release(messages);
1720 }
1721 if (shader) ID3D10Blob_Release(shader);
1722}
1723
1725{
1727
1728 if (!(module = LoadLibraryA("d3dcompiler_43.dll"))) return FALSE;
1729
1730 pD3DAssemble = (void*)GetProcAddress(module, "D3DAssemble");
1731 ppD3DPreprocess = (void*)GetProcAddress(module, "D3DPreprocess");
1732 return TRUE;
1733}
1734
1736{
1737 if (!load_d3dcompiler())
1738 {
1739 win_skip("Could not load d3dcompiler_43.dll\n");
1740 return;
1741 }
1742
1743 preproc_test();
1744 ps_1_1_test();
1745 vs_1_1_test();
1746 ps_1_3_test();
1747 ps_1_4_test();
1748 vs_2_0_test();
1749 vs_2_x_test();
1750 ps_2_0_test();
1751 ps_2_x_test();
1752 vs_3_0_test();
1753 ps_3_0_test();
1754
1755 failure_test();
1756
1758
1760}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define ARRAY_SIZE(A)
Definition: main.h:33
@ D3DSIO_END
Definition: d3d8types.h:365
@ D3D_INCLUDE_SYSTEM
Definition: d3dcommon.idl:49
@ D3D_INCLUDE_LOCAL
Definition: d3dcommon.idl:48
enum _D3D_INCLUDE_TYPE D3D_INCLUDE_TYPE
HRESULT(WINAPI * pD3DPreprocess)(const void *data, SIZE_T size, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, ID3DBlob **shader, ID3DBlob **error_messages)
Definition: d3dcompiler.h:119
#define D3DCOMPILE_SKIP_VALIDATION
Definition: d3dcompiler.h:40
static void vs_3_0_test(void)
Definition: asm.c:1098
static const struct ID3DIncludeVtbl D3DInclude_Vtbl
Definition: asm.c:1505
static void ps_2_0_test(void)
Definition: asm.c:887
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:31
static void preproc_test(void)
Definition: asm.c:89
static void exec_tests(const char *name, struct shader_test tests[], unsigned int count)
Definition: asm.c:51
static void ps_1_4_test(void)
Definition: asm.c:525
#define D3DXERR_INVALIDDATA
Definition: asm.c:28
static void ps_1_1_test(void)
Definition: asm.c:116
static void vs_1_1_test(void)
Definition: asm.c:142
static void dump_shader(DWORD *shader)
Definition: asm.c:40
static HRESULT WINAPI testD3DInclude_close(ID3DInclude *iface, const void *data)
Definition: asm.c:1499
static void ps_1_3_test(void)
Definition: asm.c:285
static HRESULT WINAPI testD3DInclude_open(ID3DInclude *iface, D3D_INCLUDE_TYPE include_type, const char *filename, const void *parent_data, const void **data, UINT *bytes)
Definition: asm.c:1435
static void failure_test(void)
Definition: asm.c:1269
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ID3DBlob ** error_messages
Definition: asm.c:32
static void ps_2_x_test(void)
Definition: asm.c:960
static void ps_3_0_test(void)
Definition: asm.c:1183
static void vs_2_x_test(void)
Definition: asm.c:826
static pD3DPreprocess ppD3DPreprocess
Definition: asm.c:33
static void vs_2_0_test(void)
Definition: asm.c:635
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT flags
Definition: asm.c:31
static void assembleshader_test(void)
Definition: asm.c:1515
static void d3dpreprocess_test(void)
Definition: asm.c:1601
static SIZE_T const char * filename
Definition: asm.c:30
static SIZE_T const char const D3D_SHADER_MACRO * defines
Definition: asm.c:31
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ** shader
Definition: asm.c:31
static SIZE_T datasize
Definition: asm.c:30
static BOOL load_d3dcompiler(void)
Definition: asm.c:1724
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define GetProcAddress(x, y)
Definition: compat.h:753
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
const WCHAR * text
Definition: package.c:1799
void test1()
Definition: ehthrow.cxx:277
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
GLuint shader
Definition: glext.h:6030
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
const char * filename
Definition: ioapi.h:137
static struct test_info tests[]
#define todo_wine
Definition: custom.c:79
unsigned int UINT
Definition: ndis.h:50
#define win_skip
Definition: test.h:160
HRESULT hr
Definition: shlfolder.c:183
ID3DInclude ID3DInclude_iface
Definition: asm.c:1512
Definition: name.c:39
const DWORD bytes[128]
Definition: asm.c:37
const char * text
Definition: asm.c:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define CopyMemory
Definition: winbase.h:1710
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6