ReactOS 0.4.15-dev-7897-g78dc504
compiler.c
Go to the documentation of this file.
1/*
2 * Copyright 2009 Matteo Bruni
3 * Copyright 2010 Matteo Bruni for CodeWeavers
4 *
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.
9 *
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.
14 *
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
18 */
19
20#define COBJMACROS
21#include <stdarg.h>
22#include <time.h>
23#include "wine/debug.h"
24
25#include "d3dcompiler_private.h"
26#include "wpp_private.h"
27
29
30#define D3DXERR_INVALIDDATA 0x88760b59
31
32#define BUFFER_INITIAL_CAPACITY 256
33
35{
36 const char *buffer;
37 unsigned int size;
38 unsigned int pos;
39};
40
43static const char *initial_filename;
44
45#define INCLUDES_INITIAL_CAPACITY 4
46
48{
49 const char *name;
50 const char *data;
51};
52
53static struct loaded_include *includes;
55static const char *parent_include;
56
57static char *wpp_output;
59
60static char *wpp_messages;
62
63struct define
64{
65 struct define *next;
66 char *name;
67 char *value;
68};
69
70static struct define *cmdline_defines;
71
72/* Mutex used to guarantee a single invocation
73 of the D3DXAssembleShader function (or its variants) at a time.
74 This is needed as wpp isn't thread-safe */
77{
78 0, 0, &wpp_mutex,
81 0, 0, { (DWORD_PTR)(__FILE__ ": wpp_mutex") }
82};
83static CRITICAL_SECTION wpp_mutex = { &wpp_mutex_debug, -1, 0, 0, 0, 0 };
84
85/* Preprocessor error reporting functions */
86static void wpp_write_message(const char *fmt, __ms_va_list args)
87{
88 char* newbuffer;
89 int rc, newsize;
90
92 {
94 if(wpp_messages == NULL)
95 return;
96
98 }
99
100 while(1)
101 {
104
105 if (rc < 0 || /* C89 */
106 rc >= wpp_messages_capacity - wpp_messages_size) { /* C99 */
107 /* Resize the buffer */
108 newsize = wpp_messages_capacity * 2;
109 newbuffer = HeapReAlloc(GetProcessHeap(), 0, wpp_messages, newsize);
110 if(newbuffer == NULL)
111 {
112 ERR("Error reallocating memory for parser messages\n");
113 return;
114 }
115 wpp_messages = newbuffer;
116 wpp_messages_capacity = newsize;
117 }
118 else
119 {
120 wpp_messages_size += rc;
121 return;
122 }
123 }
124}
125
126static void WINAPIV PRINTF_ATTR(1,2) wpp_write_message_var(const char *fmt, ...)
127{
129
133}
134
135int WINAPIV ppy_error(const char *msg, ...)
136{
139 wpp_write_message_var("%s:%d:%d: %s: ",
140 pp_status.input ? pp_status.input : "'main file'",
143 wpp_write_message_var("\n");
145 pp_status.state = 1;
146 return 1;
147}
148
149int WINAPIV ppy_warning(const char *msg, ...)
150{
153 wpp_write_message_var("%s:%d:%d: %s: ",
154 pp_status.input ? pp_status.input : "'main file'",
157 wpp_write_message_var("\n");
159 return 0;
160}
161
162char *wpp_lookup(const char *filename, int type, const char *parent_name)
163{
164 /* We don't check for file existence here. We will potentially fail on
165 * the following wpp_open_mem(). */
166 char *path;
167 int i;
168
169 TRACE("Looking for include %s, parent %s.\n", debugstr_a(filename), debugstr_a(parent_name));
170
172 if (strcmp(parent_name, initial_filename))
173 {
174 for(i = 0; i < includes_size; i++)
175 {
176 if(!strcmp(parent_name, includes[i].name))
177 {
178 parent_include = includes[i].data;
179 break;
180 }
181 }
182 if(parent_include == NULL)
183 {
184 ERR("Parent include %s missing.\n", debugstr_a(parent_name));
185 return NULL;
186 }
187 }
188
189 path = malloc(strlen(filename) + 1);
190 if(path)
192 return path;
193}
194
195void *wpp_open(const char *filename, int type)
196{
197 struct mem_file_desc *desc;
198 HRESULT hr;
199
200 TRACE("Opening include %s.\n", debugstr_a(filename));
201
203 {
204 current_shader.pos = 0;
205 return &current_shader;
206 }
207
208 if(current_include == NULL) return NULL;
209 desc = HeapAlloc(GetProcessHeap(), 0, sizeof(*desc));
210 if(!desc)
211 return NULL;
212
214 filename, parent_include, (const void **)&desc->buffer, &desc->size)))
215 {
217 return NULL;
218 }
219
221 {
222 if(includes_capacity == 0)
223 {
225 if(includes == NULL)
226 {
227 ERR("Error allocating memory for the loaded includes structure\n");
228 goto error;
229 }
230 includes_capacity = INCLUDES_INITIAL_CAPACITY * sizeof(*includes);
231 }
232 else
233 {
234 int newcapacity = includes_capacity * 2;
235 struct loaded_include *newincludes =
236 HeapReAlloc(GetProcessHeap(), 0, includes, newcapacity);
237 if(newincludes == NULL)
238 {
239 ERR("Error reallocating memory for the loaded includes structure\n");
240 goto error;
241 }
242 includes = newincludes;
243 includes_capacity = newcapacity;
244 }
245 }
247 includes[includes_size++].data = desc->buffer;
248
249 desc->pos = 0;
250 return desc;
251
252error:
253 ID3DInclude_Close(current_include, desc->buffer);
255 return NULL;
256}
257
258void wpp_close(void *file)
259{
260 struct mem_file_desc *desc = file;
261
262 if(desc != &current_shader)
263 {
265 ID3DInclude_Close(current_include, desc->buffer);
266 else
267 ERR("current_include == NULL, desc == %p, buffer = %s\n",
268 desc, desc->buffer);
269
271 }
272}
273
274int wpp_read(void *file, char *buffer, unsigned int len)
275{
276 struct mem_file_desc *desc = file;
277
278 len = min(len, desc->size - desc->pos);
279 memcpy(buffer, desc->buffer + desc->pos, len);
280 desc->pos += len;
281 return len;
282}
283
284void wpp_write(const char *buffer, unsigned int len)
285{
286 char *new_wpp_output;
287
288 if(wpp_output_capacity == 0)
289 {
291 if(!wpp_output)
292 return;
293
295 }
297 {
299 {
301 }
302 new_wpp_output = HeapReAlloc(GetProcessHeap(), 0, wpp_output,
304 if(!new_wpp_output)
305 {
306 ERR("Error allocating memory\n");
307 return;
308 }
309 wpp_output = new_wpp_output;
310 }
313}
314
315static int wpp_close_output(void)
316{
317 char *new_wpp_output = HeapReAlloc(GetProcessHeap(), 0, wpp_output,
318 wpp_output_size + 1);
319 if(!new_wpp_output) return 0;
320 wpp_output = new_wpp_output;
323 return 1;
324}
325
326static void add_cmdline_defines(void)
327{
328 struct define *def;
329
330 for (def = cmdline_defines; def; def = def->next)
331 {
332 if (def->value) pp_add_define( def->name, def->value );
333 }
334}
335
336static void del_cmdline_defines(void)
337{
338 struct define *def;
339
340 for (def = cmdline_defines; def; def = def->next)
341 {
342 if (def->value) pp_del_define( def->name );
343 }
344}
345
346static void add_special_defines(void)
347{
348 time_t now = time(NULL);
349 pp_entry_t *ppp;
350 char buf[32];
351
352 strftime(buf, sizeof(buf), "\"%b %d %Y\"", localtime(&now));
353 pp_add_define( "__DATE__", buf );
354
355 strftime(buf, sizeof(buf), "\"%H:%M:%S\"", localtime(&now));
356 pp_add_define( "__TIME__", buf );
357
358 ppp = pp_add_define( "__FILE__", "" );
359 if(ppp)
360 ppp->type = def_special;
361
362 ppp = pp_add_define( "__LINE__", "" );
363 if(ppp)
364 ppp->type = def_special;
365}
366
367static void del_special_defines(void)
368{
369 pp_del_define( "__DATE__" );
370 pp_del_define( "__TIME__" );
371 pp_del_define( "__FILE__" );
372 pp_del_define( "__LINE__" );
373}
374
375
376/* add a define to the preprocessor list */
377int wpp_add_define( const char *name, const char *value )
378{
379 struct define *def;
380
381 if (!value) value = "";
382
383 for (def = cmdline_defines; def; def = def->next)
384 {
385 if (!strcmp( def->name, name ))
386 {
387 char *new_value = pp_xstrdup(value);
388 if(!new_value)
389 return 1;
390 free( def->value );
391 def->value = new_value;
392
393 return 0;
394 }
395 }
396
397 def = pp_xmalloc( sizeof(*def) );
398 if(!def)
399 return 1;
400 def->next = cmdline_defines;
401 def->name = pp_xstrdup(name);
402 if(!def->name)
403 {
404 free(def);
405 return 1;
406 }
407 def->value = pp_xstrdup(value);
408 if(!def->value)
409 {
410 free(def->name);
411 free(def);
412 return 1;
413 }
414 cmdline_defines = def;
415 return 0;
416}
417
418
419/* undefine a previously added definition */
420void wpp_del_define( const char *name )
421{
422 struct define *def;
423
424 for (def = cmdline_defines; def; def = def->next)
425 {
426 if (!strcmp( def->name, name ))
427 {
428 free( def->value );
429 def->value = NULL;
430 return;
431 }
432 }
433}
434
435
436/* the main preprocessor parsing loop */
437int wpp_parse( const char *input, FILE *output )
438{
439 int ret;
440
444 pp_status.state = 0;
445
447 if(ret)
448 return ret;
451
452 if (!input) pp_status.file = stdin;
453 else if (!(pp_status.file = wpp_open(input, 1)))
454 {
455 ppy_error("Could not open %s\n", input);
459 return 2;
460 }
461
463
464 ppy_out = output;
465 pp_writestring("# 1 \"%s\" 1\n", input ? input : "");
466
467 ret = ppy_parse();
468 /* If there were errors during processing, return an error code */
470
471 if (input)
472 {
475 }
476 /* Clean if_stack, it could remain dirty on errors */
477 while (pp_get_if_depth()) pp_pop_if();
481 return ret;
482}
483
484static HRESULT preprocess_shader(const void *data, SIZE_T data_size, const char *filename,
486{
487 int ret;
488 HRESULT hr = S_OK;
489 const D3D_SHADER_MACRO *def = defines;
490
491 if (def != NULL)
492 {
493 while (def->Name != NULL)
494 {
495 wpp_add_define(def->Name, def->Definition);
496 def++;
497 }
498 }
500 includes_size = 0;
501
504
507 current_shader.buffer = data;
508 current_shader.size = data_size;
510
512 if (!wpp_close_output())
513 ret = 1;
514 if (ret)
515 {
516 TRACE("Error during shader preprocessing\n");
517 if (wpp_messages)
518 {
519 int size;
521
522 TRACE("Preprocessor messages:\n%s\n", debugstr_a(wpp_messages));
523
524 if (error_messages)
525 {
526 size = strlen(wpp_messages) + 1;
528 if (FAILED(hr))
529 goto cleanup;
530 CopyMemory(ID3D10Blob_GetBufferPointer(buffer), wpp_messages, size);
532 }
533 }
534 if (data)
535 TRACE("Shader source:\n%s\n", debugstr_an(data, data_size));
536 hr = E_FAIL;
537 }
538
539cleanup:
540 /* Remove the previously added defines */
541 if (defines != NULL)
542 {
543 while (defines->Name != NULL)
544 {
546 defines++;
547 }
548 }
550 return hr;
551}
552
553static HRESULT assemble_shader(const char *preproc_shader,
554 ID3DBlob **shader_blob, ID3DBlob **error_messages)
555{
556 struct bwriter_shader *shader;
557 char *messages = NULL;
558 HRESULT hr;
559 DWORD *res, size;
561 char *pos;
562
563 shader = SlAssembleShader(preproc_shader, &messages);
564
565 if (messages)
566 {
567 TRACE("Assembler messages:\n");
568 TRACE("%s\n", debugstr_a(messages));
569
570 TRACE("Shader source:\n");
571 TRACE("%s\n", debugstr_a(preproc_shader));
572
573 if (error_messages)
574 {
575 const char *preproc_messages = *error_messages ? ID3D10Blob_GetBufferPointer(*error_messages) : NULL;
576
577 size = strlen(messages) + (preproc_messages ? strlen(preproc_messages) : 0) + 1;
579 if (FAILED(hr))
580 {
583 return hr;
584 }
585 pos = ID3D10Blob_GetBufferPointer(buffer);
586 if (preproc_messages)
587 {
588 CopyMemory(pos, preproc_messages, strlen(preproc_messages) + 1);
589 pos += strlen(preproc_messages);
590 }
592
593 if (*error_messages) ID3D10Blob_Release(*error_messages);
595 }
597 }
598
599 if (shader == NULL)
600 {
601 ERR("Asm reading failed\n");
602 return D3DXERR_INVALIDDATA;
603 }
604
605 hr = SlWriteBytecode(shader, 9, &res, &size);
607 if (FAILED(hr))
608 {
609 ERR("SlWriteBytecode failed with 0x%08x\n", hr);
610 return D3DXERR_INVALIDDATA;
611 }
612
613 if (shader_blob)
614 {
616 if (FAILED(hr))
617 {
619 return hr;
620 }
621 CopyMemory(ID3D10Blob_GetBufferPointer(buffer), res, size);
622 *shader_blob = buffer;
623 }
624
626
627 return S_OK;
628}
629
633{
634 HRESULT hr;
635
636 TRACE("data %p, datasize %lu, filename %s, defines %p, include %p, sflags %#x, "
637 "shader %p, error_messages %p.\n",
639
641
642 /* TODO: flags */
643 if (flags) FIXME("flags %x\n", flags);
644
645 if (shader) *shader = NULL;
647
649 if (SUCCEEDED(hr))
651
654 return hr;
655}
656
658 const char *name;
666};
667
668/* Must be kept sorted for binary search */
669static const struct target_info targets_info[] = {
670 { "cs_4_0", ST_UNKNOWN, 4, 0, 0, 0, FALSE, FALSE },
671 { "cs_4_1", ST_UNKNOWN, 4, 1, 0, 0, FALSE, FALSE },
672 { "cs_5_0", ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
673 { "ds_5_0", ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
674 { "fx_2_0", ST_UNKNOWN, 2, 0, 0, 0, FALSE, FALSE },
675 { "fx_4_0", ST_UNKNOWN, 4, 0, 0, 0, FALSE, FALSE },
676 { "fx_4_1", ST_UNKNOWN, 4, 1, 0, 0, FALSE, FALSE },
677 { "fx_5_0", ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
678 { "gs_4_0", ST_UNKNOWN, 4, 0, 0, 0, FALSE, FALSE },
679 { "gs_4_1", ST_UNKNOWN, 4, 1, 0, 0, FALSE, FALSE },
680 { "gs_5_0", ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
681 { "hs_5_0", ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
682 { "ps.1.0", ST_PIXEL, 1, 0, 0, 0, FALSE, TRUE },
683 { "ps.1.1", ST_PIXEL, 1, 1, 0, 0, FALSE, FALSE },
684 { "ps.1.2", ST_PIXEL, 1, 2, 0, 0, FALSE, FALSE },
685 { "ps.1.3", ST_PIXEL, 1, 3, 0, 0, FALSE, FALSE },
686 { "ps.1.4", ST_PIXEL, 1, 4, 0, 0, FALSE, FALSE },
687 { "ps.2.0", ST_PIXEL, 2, 0, 0, 0, FALSE, TRUE },
688 { "ps.2.a", ST_PIXEL, 2, 1, 0, 0, FALSE, FALSE },
689 { "ps.2.b", ST_PIXEL, 2, 2, 0, 0, FALSE, FALSE },
690 { "ps.2.sw", ST_PIXEL, 2, 0, 0, 0, TRUE, FALSE },
691 { "ps.3.0", ST_PIXEL, 3, 0, 0, 0, FALSE, TRUE },
692 { "ps_1_0", ST_PIXEL, 1, 0, 0, 0, FALSE, TRUE },
693 { "ps_1_1", ST_PIXEL, 1, 1, 0, 0, FALSE, FALSE },
694 { "ps_1_2", ST_PIXEL, 1, 2, 0, 0, FALSE, FALSE },
695 { "ps_1_3", ST_PIXEL, 1, 3, 0, 0, FALSE, FALSE },
696 { "ps_1_4", ST_PIXEL, 1, 4, 0, 0, FALSE, FALSE },
697 { "ps_2_0", ST_PIXEL, 2, 0, 0, 0, FALSE, TRUE },
698 { "ps_2_a", ST_PIXEL, 2, 1, 0, 0, FALSE, FALSE },
699 { "ps_2_b", ST_PIXEL, 2, 2, 0, 0, FALSE, FALSE },
700 { "ps_2_sw", ST_PIXEL, 2, 0, 0, 0, TRUE, FALSE },
701 { "ps_3_0", ST_PIXEL, 3, 0, 0, 0, FALSE, TRUE },
702 { "ps_3_sw", ST_PIXEL, 3, 0, 0, 0, TRUE, FALSE },
703 { "ps_4_0", ST_PIXEL, 4, 0, 0, 0, FALSE, TRUE },
704 { "ps_4_0_level_9_0", ST_PIXEL, 4, 0, 9, 0, FALSE, FALSE },
705 { "ps_4_0_level_9_1", ST_PIXEL, 4, 0, 9, 1, FALSE, FALSE },
706 { "ps_4_0_level_9_3", ST_PIXEL, 4, 0, 9, 3, FALSE, FALSE },
707 { "ps_4_1", ST_PIXEL, 4, 1, 0, 0, FALSE, TRUE },
708 { "ps_5_0", ST_PIXEL, 5, 0, 0, 0, FALSE, TRUE },
709 { "tx_1_0", ST_UNKNOWN, 1, 0, 0, 0, FALSE, FALSE },
710 { "vs.1.0", ST_VERTEX, 1, 0, 0, 0, FALSE, TRUE },
711 { "vs.1.1", ST_VERTEX, 1, 1, 0, 0, FALSE, TRUE },
712 { "vs.2.0", ST_VERTEX, 2, 0, 0, 0, FALSE, TRUE },
713 { "vs.2.a", ST_VERTEX, 2, 1, 0, 0, FALSE, FALSE },
714 { "vs.2.sw", ST_VERTEX, 2, 0, 0, 0, TRUE, FALSE },
715 { "vs.3.0", ST_VERTEX, 3, 0, 0, 0, FALSE, TRUE },
716 { "vs.3.sw", ST_VERTEX, 3, 0, 0, 0, TRUE, FALSE },
717 { "vs_1_0", ST_VERTEX, 1, 0, 0, 0, FALSE, TRUE },
718 { "vs_1_1", ST_VERTEX, 1, 1, 0, 0, FALSE, TRUE },
719 { "vs_2_0", ST_VERTEX, 2, 0, 0, 0, FALSE, TRUE },
720 { "vs_2_a", ST_VERTEX, 2, 1, 0, 0, FALSE, FALSE },
721 { "vs_2_sw", ST_VERTEX, 2, 0, 0, 0, TRUE, FALSE },
722 { "vs_3_0", ST_VERTEX, 3, 0, 0, 0, FALSE, TRUE },
723 { "vs_3_sw", ST_VERTEX, 3, 0, 0, 0, TRUE, FALSE },
724 { "vs_4_0", ST_VERTEX, 4, 0, 0, 0, FALSE, TRUE },
725 { "vs_4_0_level_9_0", ST_VERTEX, 4, 0, 9, 0, FALSE, FALSE },
726 { "vs_4_0_level_9_1", ST_VERTEX, 4, 0, 9, 1, FALSE, FALSE },
727 { "vs_4_0_level_9_3", ST_VERTEX, 4, 0, 9, 3, FALSE, FALSE },
728 { "vs_4_1", ST_VERTEX, 4, 1, 0, 0, FALSE, TRUE },
729 { "vs_5_0", ST_VERTEX, 5, 0, 0, 0, FALSE, TRUE },
730};
731
732static const struct target_info * get_target_info(const char *target)
733{
734 LONG min = 0;
736 LONG cur;
737 int res;
738
739 while (min <= max)
740 {
741 cur = (min + max) / 2;
743 if (res < 0)
744 max = cur - 1;
745 else if (res > 0)
746 min = cur + 1;
747 else
748 return &targets_info[cur];
749 }
750
751 return NULL;
752}
753
754static HRESULT compile_shader(const char *preproc_shader, const char *target, const char *entrypoint,
755 ID3DBlob **shader_blob, ID3DBlob **error_messages)
756{
757 struct bwriter_shader *shader;
758 char *messages = NULL;
759 HRESULT hr;
762 char *pos;
764 const struct target_info *info;
765
766 TRACE("Preprocessed shader source: %s\n", debugstr_a(preproc_shader));
767
768 TRACE("Checking compilation target %s\n", debugstr_a(target));
770 if (!info)
771 {
772 FIXME("Unknown compilation target %s\n", debugstr_a(target));
773 return D3DERR_INVALIDCALL;
774 }
775 else
776 {
777 if (!info->support)
778 {
779 FIXME("Compilation target %s not yet supported\n", debugstr_a(target));
780 return D3DERR_INVALIDCALL;
781 }
782 else
783 {
784 shader_type = info->type;
785 major = info->sm_major;
786 minor = info->sm_minor;
787 }
788 }
789
790 shader = parse_hlsl_shader(preproc_shader, shader_type, major, minor, entrypoint, &messages);
791
792 if (messages)
793 {
794 TRACE("Compiler messages:\n");
795 TRACE("%s\n", debugstr_a(messages));
796
797 TRACE("Shader source:\n");
798 TRACE("%s\n", debugstr_a(preproc_shader));
799
800 if (error_messages)
801 {
802 const char *preproc_messages = *error_messages ? ID3D10Blob_GetBufferPointer(*error_messages) : NULL;
803
804 size = strlen(messages) + (preproc_messages ? strlen(preproc_messages) : 0) + 1;
806 if (FAILED(hr))
807 {
810 return hr;
811 }
812 pos = ID3D10Blob_GetBufferPointer(buffer);
813 if (preproc_messages)
814 {
815 memcpy(pos, preproc_messages, strlen(preproc_messages) + 1);
816 pos += strlen(preproc_messages);
817 }
819
820 if (*error_messages) ID3D10Blob_Release(*error_messages);
822 }
824 }
825
826 if (!shader)
827 {
828 ERR("HLSL shader parsing failed.\n");
829 return D3DXERR_INVALIDDATA;
830 }
831
832 hr = SlWriteBytecode(shader, 9, &res, &size);
834 if (FAILED(hr))
835 {
836 ERR("SlWriteBytecode failed with error 0x%08x.\n", hr);
837 return D3DXERR_INVALIDDATA;
838 }
839
840 if (shader_blob)
841 {
843 if (FAILED(hr))
844 {
846 return hr;
847 }
848 memcpy(ID3D10Blob_GetBufferPointer(buffer), res, size);
849 *shader_blob = buffer;
850 }
851
853
854 return S_OK;
855}
856
857HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filename,
858 const D3D_SHADER_MACRO *defines, ID3DInclude *include, const char *entrypoint,
859 const char *target, UINT sflags, UINT eflags, UINT secondary_flags,
860 const void *secondary_data, SIZE_T secondary_data_size, ID3DBlob **shader,
862{
863 HRESULT hr;
864
865 TRACE("data %p, data_size %lu, filename %s, defines %p, include %p, entrypoint %s, "
866 "target %s, sflags %#x, eflags %#x, secondary_flags %#x, secondary_data %p, "
867 "secondary_data_size %lu, shader %p, error_messages %p.\n",
868 data, data_size, debugstr_a(filename), defines, include, debugstr_a(entrypoint),
869 debugstr_a(target), sflags, eflags, secondary_flags, secondary_data,
870 secondary_data_size, shader, error_messages);
871
872 if (secondary_data)
873 FIXME("secondary data not implemented yet\n");
874
875 if (shader) *shader = NULL;
877
879
881 if (SUCCEEDED(hr))
883
886 return hr;
887}
888
889HRESULT WINAPI D3DCompile(const void *data, SIZE_T data_size, const char *filename,
890 const D3D_SHADER_MACRO *defines, ID3DInclude *include, const char *entrypoint,
892{
893 TRACE("data %p, data_size %lu, filename %s, defines %p, include %p, entrypoint %s, "
894 "target %s, sflags %#x, eflags %#x, shader %p, error_messages %p.\n",
895 data, data_size, debugstr_a(filename), defines, include, debugstr_a(entrypoint),
897
898 return D3DCompile2(data, data_size, filename, defines, include, entrypoint, target, sflags,
900}
901
905{
906 HRESULT hr;
908
909 TRACE("data %p, size %lu, filename %s, defines %p, include %p, shader %p, error_messages %p\n",
911
912 if (!data)
913 return E_INVALIDARG;
914
916
917 if (shader) *shader = NULL;
919
921
922 if (SUCCEEDED(hr))
923 {
924 if (shader)
925 {
927 if (FAILED(hr))
928 goto cleanup;
929 CopyMemory(ID3D10Blob_GetBufferPointer(buffer), wpp_output, wpp_output_size);
930 *shader = buffer;
931 }
932 else
934 }
935
936cleanup:
939 return hr;
940}
941
942HRESULT WINAPI D3DDisassemble(const void *data, SIZE_T size, UINT flags, const char *comments, ID3DBlob **disassembly)
943{
944 FIXME("data %p, size %lu, flags %#x, comments %p, disassembly %p stub!\n",
945 data, size, flags, comments, disassembly);
946 return E_NOTIMPL;
947}
948
950 const char *entrypoint, const char *target, UINT flags1, UINT flags2, ID3DBlob **code, ID3DBlob **errors)
951{
952 FIXME("filename %s, defines %p, includes %p, entrypoint %s, target %s, flags1 %x, flags2 %x, code %p, errors %p\n",
953 debugstr_w(filename), defines, includes, debugstr_a(entrypoint), debugstr_a(target), flags1, flags2, code, errors);
954
955 return E_NOTIMPL;
956}
957
958#ifndef __REACTOS__
959HRESULT WINAPI D3DLoadModule(const void *data, SIZE_T size, ID3D11Module **module)
960{
961 FIXME("data %p, size %lu, module %p stub!\n", data, size, module);
962 return E_NOTIMPL;
963}
964#endif
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define msg(x)
Definition: auth_time.c:54
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ARRAY_SIZE(A)
Definition: main.h:33
#define FIXME(fmt,...)
Definition: debug.h:111
#define ERR(fmt,...)
Definition: debug.h:110
HRESULT SlWriteBytecode(const struct bwriter_shader *shader, int dxversion, DWORD **result, DWORD *size)
void SlDeleteShader(struct bwriter_shader *shader)
static HRESULT compile_shader(const char *preproc_shader, const char *target, const char *entrypoint, ID3DBlob **shader_blob, ID3DBlob **error_messages)
Definition: compiler.c:754
static void del_special_defines(void)
Definition: compiler.c:367
HRESULT WINAPI D3DPreprocess(const void *data, SIZE_T size, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, ID3DBlob **shader, ID3DBlob **error_messages)
Definition: compiler.c:902
static const struct target_info * get_target_info(const char *target)
Definition: compiler.c:732
void * wpp_open(const char *filename, int type)
Definition: compiler.c:195
static int wpp_output_capacity
Definition: compiler.c:58
static CRITICAL_SECTION wpp_mutex
Definition: compiler.c:75
HRESULT WINAPI D3DCompile(const void *data, SIZE_T data_size, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, const char *entrypoint, const char *target, UINT sflags, UINT eflags, ID3DBlob **shader, ID3DBlob **error_messages)
Definition: compiler.c:889
#define INCLUDES_INITIAL_CAPACITY
Definition: compiler.c:45
void wpp_write(const char *buffer, unsigned int len)
Definition: compiler.c:284
int WINAPIV ppy_error(const char *msg,...)
Definition: compiler.c:135
#define BUFFER_INITIAL_CAPACITY
Definition: compiler.c:32
static void wpp_write_message(const char *fmt, __ms_va_list args)
Definition: compiler.c:86
static void add_special_defines(void)
Definition: compiler.c:346
static int wpp_output_size
Definition: compiler.c:58
static int wpp_close_output(void)
Definition: compiler.c:315
HRESULT WINAPI D3DDisassemble(const void *data, SIZE_T size, UINT flags, const char *comments, ID3DBlob **disassembly)
Definition: compiler.c:942
static CRITICAL_SECTION_DEBUG wpp_mutex_debug
Definition: compiler.c:76
static char * wpp_messages
Definition: compiler.c:60
static int wpp_messages_capacity
Definition: compiler.c:61
static int wpp_messages_size
Definition: compiler.c:61
int wpp_add_define(const char *name, const char *value)
Definition: compiler.c:377
void wpp_close(void *file)
Definition: compiler.c:258
#define D3DXERR_INVALIDDATA
Definition: compiler.c:30
void wpp_del_define(const char *name)
Definition: compiler.c:420
int wpp_parse(const char *input, FILE *output)
Definition: compiler.c:437
static char * wpp_output
Definition: compiler.c:57
HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, const char *entrypoint, const char *target, UINT sflags, UINT eflags, UINT secondary_flags, const void *secondary_data, SIZE_T secondary_data_size, ID3DBlob **shader, ID3DBlob **error_messages)
Definition: compiler.c:857
int WINAPIV ppy_warning(const char *msg,...)
Definition: compiler.c:149
static ID3DInclude * current_include
Definition: compiler.c:42
HRESULT WINAPI D3DAssemble(const void *data, SIZE_T datasize, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, UINT flags, ID3DBlob **shader, ID3DBlob **error_messages)
Definition: compiler.c:630
int wpp_read(void *file, char *buffer, unsigned int len)
Definition: compiler.c:274
static struct loaded_include * includes
Definition: compiler.c:53
static const char * parent_include
Definition: compiler.c:55
char * wpp_lookup(const char *filename, int type, const char *parent_name)
Definition: compiler.c:162
static HRESULT preprocess_shader(const void *data, SIZE_T data_size, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, ID3DBlob **error_messages)
Definition: compiler.c:484
HRESULT WINAPI D3DLoadModule(const void *data, SIZE_T size, ID3D11Module **module)
Definition: compiler.c:959
static const char * initial_filename
Definition: compiler.c:43
static struct define * cmdline_defines
Definition: compiler.c:70
static const struct target_info targets_info[]
Definition: compiler.c:669
static struct mem_file_desc current_shader
Definition: compiler.c:41
HRESULT WINAPI D3DCompileFromFile(const WCHAR *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *includes, const char *entrypoint, const char *target, UINT flags1, UINT flags2, ID3DBlob **code, ID3DBlob **errors)
Definition: compiler.c:949
static void add_cmdline_defines(void)
Definition: compiler.c:326
static int includes_size
Definition: compiler.c:54
static HRESULT assemble_shader(const char *preproc_shader, ID3DBlob **shader_blob, ID3DBlob **error_messages)
Definition: compiler.c:553
static void del_cmdline_defines(void)
Definition: compiler.c:336
static int includes_capacity
Definition: compiler.c:54
@ D3D_INCLUDE_SYSTEM
Definition: d3dcommon.idl:49
@ D3D_INCLUDE_LOCAL
Definition: d3dcommon.idl:48
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:31
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ID3DBlob ** error_messages
Definition: asm.c:32
static SIZE_T const char const D3D_SHADER_MACRO * defines
Definition: asm.c:31
static SIZE_T datasize
Definition: asm.c:30
struct bwriter_shader * parse_hlsl_shader(const char *text, enum shader_type type, DWORD major, DWORD minor, const char *entrypoint, char **messages) DECLSPEC_HIDDEN
#define PRINTF_ATTR(fmt, args)
#define D3DERR_INVALIDCALL
struct bwriter_shader * SlAssembleShader(const char *text, char **messages) DECLSPEC_HIDDEN
@ ST_VERTEX
@ ST_UNKNOWN
@ ST_PIXEL
#define MESSAGEBUFFER_INITIAL_SIZE
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
char comments[4096]
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HRESULT WINAPI D3DCreateBlob(SIZE_T data_size, ID3DBlob **blob)
Definition: blob.c:133
pp_entry_t * pp_add_define(const char *def, const char *text)
Definition: preproc.c:194
char * pp_xstrdup(const char *str)
Definition: preproc.c:73
int pp_get_if_depth(void)
Definition: preproc.c:433
void * pp_xmalloc(size_t size)
Definition: preproc.c:45
int pp_push_define_state(void)
Definition: preproc.c:148
void pp_pop_define_state(void)
Definition: preproc.c:161
pp_if_state_t pp_pop_if(void)
Definition: preproc.c:380
void pp_del_define(const char *name)
Definition: preproc.c:176
void WINAPIV int ppy_parse(void)
FILE * ppy_out
@ def_special
Definition: wpp_private.h:92
void WINAPIV pp_writestring(const char *format,...) __attribute__((format(printf
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:55
#define HeapFree(x, y, z)
Definition: compat.h:735
static void cleanup(void)
Definition: main.c:1335
__kernel_time_t time_t
Definition: linux.h:252
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
time_t now
Definition: finger.c:65
FxCollectionEntry * cur
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
GLuint shader
Definition: glext.h:6030
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
GLenum GLenum GLenum input
Definition: glext.h:9031
GLenum target
Definition: glext.h:7315
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
#define stdin
Definition: stdio.h:98
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
const char * filename
Definition: ioapi.h:137
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_w
Definition: kernel32.h:32
__u16 time
Definition: mkdosfs.c:8
#define error(str)
Definition: mkdosfs.c:1605
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static const WCHAR desc[]
Definition: protectdata.c:36
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
long LONG
Definition: pedump.c:60
#define minor(rdev)
Definition: propsheet.cpp:929
#define major(rdev)
Definition: propsheet.cpp:928
#define WINAPIV
Definition: sdbpapi.h:64
_CRTIMP struct tm *__cdecl localtime(const time_t *_Time)
Definition: time.h:416
#define args
Definition: format.c:66
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
size_t CDECL strftime(char *str, size_t max, const char *format, const struct tm *mstm)
Definition: strftime.c:293
LIST_ENTRY ProcessLocksList
Definition: winbase.h:883
const char * Name
Definition: d3dcommon.idl:24
const char * Definition
Definition: d3dcommon.idl:25
Definition: match.c:390
Definition: inflate.c:139
struct define * next
Definition: compiler.c:65
char * value
Definition: compiler.c:67
char * name
Definition: compiler.c:66
Definition: fci.c:127
Definition: dsound.c:943
const char * data
Definition: compiler.c:50
const char * name
Definition: compiler.c:49
const char * buffer
Definition: compiler.c:36
unsigned int pos
Definition: compiler.c:38
unsigned int size
Definition: compiler.c:37
Definition: name.c:39
Definition: wpp_private.h:95
def_type_t type
Definition: wpp_private.h:98
void * file
Definition: wpp_private.h:221
int char_number
Definition: wpp_private.h:223
char * input
Definition: wpp_private.h:220
int line_number
Definition: wpp_private.h:222
DWORD sm_major
Definition: compiler.c:660
enum shader_type type
Definition: compiler.c:659
BOOL support
Definition: compiler.c:665
DWORD sm_minor
Definition: compiler.c:661
DWORD level_minor
Definition: compiler.c:663
const char * name
Definition: compiler.c:658
DWORD level_major
Definition: compiler.c:662
#define max(a, b)
Definition: svc.c:63
#define vsnprintf
Definition: tif_win32.c:406
#define DWORD_PTR
Definition: treelist.c:76
ULONG_PTR SIZE_T
Definition: typedefs.h:80
Definition: pdh_main.c:94
int ret
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define CopyMemory
Definition: winbase.h:1710
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define __ms_va_list
Definition: windef.h:456
#define __ms_va_end(list)
Definition: windef.h:458
#define __ms_va_start(list, arg)
Definition: windef.h:457
#define WINAPI
Definition: msvc.h:6
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define const
Definition: zconf.h:233