2 * Copyright 2009 Matteo Bruni
3 * Copyright 2010 Matteo Bruni for CodeWeavers
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/port.h"
23 #include "wine/debug.h"
24 #include "wine/unicode.h"
26 #include "d3dcompiler_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(d3dcompiler
);
31 #define D3DXERR_INVALIDDATA 0x88760b59
33 #define BUFFER_INITIAL_CAPACITY 256
42 static struct mem_file_desc current_shader
;
43 static ID3DInclude
*current_include
;
44 static const char *initial_filename
;
46 #define INCLUDES_INITIAL_CAPACITY 4
54 static struct loaded_include
*includes
;
55 static int includes_capacity
, includes_size
;
56 static const char *parent_include
;
58 static char *wpp_output
;
59 static int wpp_output_capacity
, wpp_output_size
;
61 static char *wpp_messages
;
62 static int wpp_messages_capacity
, wpp_messages_size
;
64 /* Mutex used to guarantee a single invocation
65 of the D3DXAssembleShader function (or its variants) at a time.
66 This is needed as wpp isn't thread-safe */
67 static CRITICAL_SECTION wpp_mutex
;
68 static CRITICAL_SECTION_DEBUG wpp_mutex_debug
=
71 { &wpp_mutex_debug
.ProcessLocksList
,
72 &wpp_mutex_debug
.ProcessLocksList
},
73 0, 0, { (DWORD_PTR
)(__FILE__
": wpp_mutex") }
75 static CRITICAL_SECTION wpp_mutex
= { &wpp_mutex_debug
, -1, 0, 0, 0, 0 };
77 /* Preprocessor error reporting functions */
78 static void wpp_write_message(const char *fmt
, va_list args
)
83 if(wpp_messages_capacity
== 0)
85 wpp_messages
= HeapAlloc(GetProcessHeap(), 0, MESSAGEBUFFER_INITIAL_SIZE
);
86 if(wpp_messages
== NULL
)
89 wpp_messages_capacity
= MESSAGEBUFFER_INITIAL_SIZE
;
94 rc
= vsnprintf(wpp_messages
+ wpp_messages_size
,
95 wpp_messages_capacity
- wpp_messages_size
, fmt
, args
);
97 if (rc
< 0 || /* C89 */
98 rc
>= wpp_messages_capacity
- wpp_messages_size
) { /* C99 */
99 /* Resize the buffer */
100 newsize
= wpp_messages_capacity
* 2;
101 newbuffer
= HeapReAlloc(GetProcessHeap(), 0, wpp_messages
, newsize
);
102 if(newbuffer
== NULL
)
104 ERR("Error reallocating memory for parser messages\n");
107 wpp_messages
= newbuffer
;
108 wpp_messages_capacity
= newsize
;
112 wpp_messages_size
+= rc
;
118 static void PRINTF_ATTR(1,2) wpp_write_message_var(const char *fmt
, ...)
123 wpp_write_message(fmt
, args
);
127 static void wpp_error(const char *file
, int line
, int col
, const char *near
,
128 const char *msg
, va_list ap
)
130 wpp_write_message_var("%s:%d:%d: %s: ", file
? file
: "'main file'",
132 wpp_write_message(msg
, ap
);
133 wpp_write_message_var("\n");
136 static void wpp_warning(const char *file
, int line
, int col
, const char *near
,
137 const char *msg
, va_list ap
)
139 wpp_write_message_var("%s:%d:%d: %s: ", file
? file
: "'main file'",
140 line
, col
, "Warning");
141 wpp_write_message(msg
, ap
);
142 wpp_write_message_var("\n");
145 static char *wpp_lookup_mem(const char *filename
, int type
, const char *parent_name
,
146 char **include_path
, int include_path_count
)
148 /* We don't check for file existence here. We will potentially fail on
149 * the following wpp_open_mem(). */
153 TRACE("Looking for include %s, parent %s.\n", debugstr_a(filename
), debugstr_a(parent_name
));
155 parent_include
= NULL
;
156 if (strcmp(parent_name
, initial_filename
))
158 for(i
= 0; i
< includes_size
; i
++)
160 if(!strcmp(parent_name
, includes
[i
].name
))
162 parent_include
= includes
[i
].data
;
166 if(parent_include
== NULL
)
168 ERR("Parent include %s missing.\n", debugstr_a(parent_name
));
173 path
= malloc(strlen(filename
) + 1);
175 memcpy(path
, filename
, strlen(filename
) + 1);
179 static void *wpp_open_mem(const char *filename
, int type
)
181 struct mem_file_desc
*desc
;
184 TRACE("Opening include %s.\n", debugstr_a(filename
));
186 if(!strcmp(filename
, initial_filename
))
188 current_shader
.pos
= 0;
189 return ¤t_shader
;
192 if(current_include
== NULL
) return NULL
;
193 desc
= HeapAlloc(GetProcessHeap(), 0, sizeof(*desc
));
197 if (FAILED(hr
= ID3DInclude_Open(current_include
, type
? D3D_INCLUDE_LOCAL
: D3D_INCLUDE_SYSTEM
,
198 filename
, parent_include
, (const void **)&desc
->buffer
, &desc
->size
)))
200 HeapFree(GetProcessHeap(), 0, desc
);
204 if(includes_capacity
== includes_size
)
206 if(includes_capacity
== 0)
208 includes
= HeapAlloc(GetProcessHeap(), 0, INCLUDES_INITIAL_CAPACITY
* sizeof(*includes
));
211 ERR("Error allocating memory for the loaded includes structure\n");
214 includes_capacity
= INCLUDES_INITIAL_CAPACITY
* sizeof(*includes
);
218 int newcapacity
= includes_capacity
* 2;
219 struct loaded_include
*newincludes
=
220 HeapReAlloc(GetProcessHeap(), 0, includes
, newcapacity
);
221 if(newincludes
== NULL
)
223 ERR("Error reallocating memory for the loaded includes structure\n");
226 includes
= newincludes
;
227 includes_capacity
= newcapacity
;
230 includes
[includes_size
].name
= filename
;
231 includes
[includes_size
++].data
= desc
->buffer
;
237 ID3DInclude_Close(current_include
, desc
->buffer
);
238 HeapFree(GetProcessHeap(), 0, desc
);
242 static void wpp_close_mem(void *file
)
244 struct mem_file_desc
*desc
= file
;
246 if(desc
!= ¤t_shader
)
249 ID3DInclude_Close(current_include
, desc
->buffer
);
251 ERR("current_include == NULL, desc == %p, buffer = %s\n",
254 HeapFree(GetProcessHeap(), 0, desc
);
258 static int wpp_read_mem(void *file
, char *buffer
, unsigned int len
)
260 struct mem_file_desc
*desc
= file
;
262 len
= min(len
, desc
->size
- desc
->pos
);
263 memcpy(buffer
, desc
->buffer
+ desc
->pos
, len
);
268 static void wpp_write_mem(const char *buffer
, unsigned int len
)
270 char *new_wpp_output
;
272 if(wpp_output_capacity
== 0)
274 wpp_output
= HeapAlloc(GetProcessHeap(), 0, BUFFER_INITIAL_CAPACITY
);
278 wpp_output_capacity
= BUFFER_INITIAL_CAPACITY
;
280 if(len
> wpp_output_capacity
- wpp_output_size
)
282 while(len
> wpp_output_capacity
- wpp_output_size
)
284 wpp_output_capacity
*= 2;
286 new_wpp_output
= HeapReAlloc(GetProcessHeap(), 0, wpp_output
,
287 wpp_output_capacity
);
290 ERR("Error allocating memory\n");
293 wpp_output
= new_wpp_output
;
295 memcpy(wpp_output
+ wpp_output_size
, buffer
, len
);
296 wpp_output_size
+= len
;
299 static int wpp_close_output(void)
301 char *new_wpp_output
= HeapReAlloc(GetProcessHeap(), 0, wpp_output
,
302 wpp_output_size
+ 1);
303 if(!new_wpp_output
) return 0;
304 wpp_output
= new_wpp_output
;
305 wpp_output
[wpp_output_size
]='\0';
310 static HRESULT
preprocess_shader(const void *data
, SIZE_T data_size
, const char *filename
,
311 const D3D_SHADER_MACRO
*defines
, ID3DInclude
*include
, ID3DBlob
**error_messages
)
315 const D3D_SHADER_MACRO
*def
= defines
;
317 static const struct wpp_callbacks wpp_callbacks
=
330 while (def
->Name
!= NULL
)
332 wpp_add_define(def
->Name
, def
->Definition
);
336 current_include
= include
;
339 wpp_output_size
= wpp_output_capacity
= 0;
342 wpp_set_callbacks(&wpp_callbacks
);
343 wpp_messages_size
= wpp_messages_capacity
= 0;
345 current_shader
.buffer
= data
;
346 current_shader
.size
= data_size
;
347 initial_filename
= filename
? filename
: "";
349 ret
= wpp_parse(initial_filename
, NULL
);
350 if (!wpp_close_output())
354 TRACE("Error during shader preprocessing\n");
360 TRACE("Preprocessor messages:\n%s\n", debugstr_a(wpp_messages
));
364 size
= strlen(wpp_messages
) + 1;
365 hr
= D3DCreateBlob(size
, &buffer
);
368 CopyMemory(ID3D10Blob_GetBufferPointer(buffer
), wpp_messages
, size
);
369 *error_messages
= buffer
;
373 TRACE("Shader source:\n%s\n", debugstr_an(data
, data_size
));
378 /* Remove the previously added defines */
381 while (defines
->Name
!= NULL
)
383 wpp_del_define(defines
->Name
);
387 HeapFree(GetProcessHeap(), 0, wpp_messages
);
391 static HRESULT
assemble_shader(const char *preproc_shader
,
392 ID3DBlob
**shader_blob
, ID3DBlob
**error_messages
)
394 struct bwriter_shader
*shader
;
395 char *messages
= NULL
;
401 shader
= SlAssembleShader(preproc_shader
, &messages
);
405 TRACE("Assembler messages:\n");
406 TRACE("%s\n", debugstr_a(messages
));
408 TRACE("Shader source:\n");
409 TRACE("%s\n", debugstr_a(preproc_shader
));
413 const char *preproc_messages
= *error_messages
? ID3D10Blob_GetBufferPointer(*error_messages
) : NULL
;
415 size
= strlen(messages
) + (preproc_messages
? strlen(preproc_messages
) : 0) + 1;
416 hr
= D3DCreateBlob(size
, &buffer
);
419 HeapFree(GetProcessHeap(), 0, messages
);
420 if (shader
) SlDeleteShader(shader
);
423 pos
= ID3D10Blob_GetBufferPointer(buffer
);
424 if (preproc_messages
)
426 CopyMemory(pos
, preproc_messages
, strlen(preproc_messages
) + 1);
427 pos
+= strlen(preproc_messages
);
429 CopyMemory(pos
, messages
, strlen(messages
) + 1);
431 if (*error_messages
) ID3D10Blob_Release(*error_messages
);
432 *error_messages
= buffer
;
434 HeapFree(GetProcessHeap(), 0, messages
);
439 ERR("Asm reading failed\n");
440 return D3DXERR_INVALIDDATA
;
443 hr
= SlWriteBytecode(shader
, 9, &res
, &size
);
444 SlDeleteShader(shader
);
447 ERR("SlWriteBytecode failed with 0x%08x\n", hr
);
448 return D3DXERR_INVALIDDATA
;
453 hr
= D3DCreateBlob(size
, &buffer
);
456 HeapFree(GetProcessHeap(), 0, res
);
459 CopyMemory(ID3D10Blob_GetBufferPointer(buffer
), res
, size
);
460 *shader_blob
= buffer
;
463 HeapFree(GetProcessHeap(), 0, res
);
468 HRESULT WINAPI
D3DAssemble(const void *data
, SIZE_T datasize
, const char *filename
,
469 const D3D_SHADER_MACRO
*defines
, ID3DInclude
*include
, UINT flags
,
470 ID3DBlob
**shader
, ID3DBlob
**error_messages
)
474 TRACE("data %p, datasize %lu, filename %s, defines %p, include %p, sflags %#x, "
475 "shader %p, error_messages %p.\n",
476 data
, datasize
, debugstr_a(filename
), defines
, include
, flags
, shader
, error_messages
);
478 EnterCriticalSection(&wpp_mutex
);
481 if (flags
) FIXME("flags %x\n", flags
);
483 if (shader
) *shader
= NULL
;
484 if (error_messages
) *error_messages
= NULL
;
486 hr
= preprocess_shader(data
, datasize
, filename
, defines
, include
, error_messages
);
488 hr
= assemble_shader(wpp_output
, shader
, error_messages
);
490 HeapFree(GetProcessHeap(), 0, wpp_output
);
491 LeaveCriticalSection(&wpp_mutex
);
497 enum shader_type type
;
506 /* Must be kept sorted for binary search */
507 static const struct target_info targets_info
[] = {
508 { "cs_4_0", ST_UNKNOWN
, 4, 0, 0, 0, FALSE
, FALSE
},
509 { "cs_4_1", ST_UNKNOWN
, 4, 1, 0, 0, FALSE
, FALSE
},
510 { "cs_5_0", ST_UNKNOWN
, 5, 0, 0, 0, FALSE
, FALSE
},
511 { "ds_5_0", ST_UNKNOWN
, 5, 0, 0, 0, FALSE
, FALSE
},
512 { "fx_2_0", ST_UNKNOWN
, 2, 0, 0, 0, FALSE
, FALSE
},
513 { "fx_4_0", ST_UNKNOWN
, 4, 0, 0, 0, FALSE
, FALSE
},
514 { "fx_4_1", ST_UNKNOWN
, 4, 1, 0, 0, FALSE
, FALSE
},
515 { "fx_5_0", ST_UNKNOWN
, 5, 0, 0, 0, FALSE
, FALSE
},
516 { "gs_4_0", ST_UNKNOWN
, 4, 0, 0, 0, FALSE
, FALSE
},
517 { "gs_4_1", ST_UNKNOWN
, 4, 1, 0, 0, FALSE
, FALSE
},
518 { "gs_5_0", ST_UNKNOWN
, 5, 0, 0, 0, FALSE
, FALSE
},
519 { "hs_5_0", ST_UNKNOWN
, 5, 0, 0, 0, FALSE
, FALSE
},
520 { "ps.1.0", ST_PIXEL
, 1, 0, 0, 0, FALSE
, TRUE
},
521 { "ps.1.1", ST_PIXEL
, 1, 1, 0, 0, FALSE
, FALSE
},
522 { "ps.1.2", ST_PIXEL
, 1, 2, 0, 0, FALSE
, FALSE
},
523 { "ps.1.3", ST_PIXEL
, 1, 3, 0, 0, FALSE
, FALSE
},
524 { "ps.1.4", ST_PIXEL
, 1, 4, 0, 0, FALSE
, FALSE
},
525 { "ps.2.0", ST_PIXEL
, 2, 0, 0, 0, FALSE
, TRUE
},
526 { "ps.2.a", ST_PIXEL
, 2, 1, 0, 0, FALSE
, FALSE
},
527 { "ps.2.b", ST_PIXEL
, 2, 2, 0, 0, FALSE
, FALSE
},
528 { "ps.2.sw", ST_PIXEL
, 2, 0, 0, 0, TRUE
, FALSE
},
529 { "ps.3.0", ST_PIXEL
, 3, 0, 0, 0, FALSE
, TRUE
},
530 { "ps_1_0", ST_PIXEL
, 1, 0, 0, 0, FALSE
, TRUE
},
531 { "ps_1_1", ST_PIXEL
, 1, 1, 0, 0, FALSE
, FALSE
},
532 { "ps_1_2", ST_PIXEL
, 1, 2, 0, 0, FALSE
, FALSE
},
533 { "ps_1_3", ST_PIXEL
, 1, 3, 0, 0, FALSE
, FALSE
},
534 { "ps_1_4", ST_PIXEL
, 1, 4, 0, 0, FALSE
, FALSE
},
535 { "ps_2_0", ST_PIXEL
, 2, 0, 0, 0, FALSE
, TRUE
},
536 { "ps_2_a", ST_PIXEL
, 2, 1, 0, 0, FALSE
, FALSE
},
537 { "ps_2_b", ST_PIXEL
, 2, 2, 0, 0, FALSE
, FALSE
},
538 { "ps_2_sw", ST_PIXEL
, 2, 0, 0, 0, TRUE
, FALSE
},
539 { "ps_3_0", ST_PIXEL
, 3, 0, 0, 0, FALSE
, TRUE
},
540 { "ps_3_sw", ST_PIXEL
, 3, 0, 0, 0, TRUE
, FALSE
},
541 { "ps_4_0", ST_PIXEL
, 4, 0, 0, 0, FALSE
, TRUE
},
542 { "ps_4_0_level_9_0", ST_PIXEL
, 4, 0, 9, 0, FALSE
, FALSE
},
543 { "ps_4_0_level_9_1", ST_PIXEL
, 4, 0, 9, 1, FALSE
, FALSE
},
544 { "ps_4_0_level_9_3", ST_PIXEL
, 4, 0, 9, 3, FALSE
, FALSE
},
545 { "ps_4_1", ST_PIXEL
, 4, 1, 0, 0, FALSE
, TRUE
},
546 { "ps_5_0", ST_PIXEL
, 5, 0, 0, 0, FALSE
, TRUE
},
547 { "tx_1_0", ST_UNKNOWN
, 1, 0, 0, 0, FALSE
, FALSE
},
548 { "vs.1.0", ST_VERTEX
, 1, 0, 0, 0, FALSE
, TRUE
},
549 { "vs.1.1", ST_VERTEX
, 1, 1, 0, 0, FALSE
, TRUE
},
550 { "vs.2.0", ST_VERTEX
, 2, 0, 0, 0, FALSE
, TRUE
},
551 { "vs.2.a", ST_VERTEX
, 2, 1, 0, 0, FALSE
, FALSE
},
552 { "vs.2.sw", ST_VERTEX
, 2, 0, 0, 0, TRUE
, FALSE
},
553 { "vs.3.0", ST_VERTEX
, 3, 0, 0, 0, FALSE
, TRUE
},
554 { "vs.3.sw", ST_VERTEX
, 3, 0, 0, 0, TRUE
, FALSE
},
555 { "vs_1_0", ST_VERTEX
, 1, 0, 0, 0, FALSE
, TRUE
},
556 { "vs_1_1", ST_VERTEX
, 1, 1, 0, 0, FALSE
, TRUE
},
557 { "vs_2_0", ST_VERTEX
, 2, 0, 0, 0, FALSE
, TRUE
},
558 { "vs_2_a", ST_VERTEX
, 2, 1, 0, 0, FALSE
, FALSE
},
559 { "vs_2_sw", ST_VERTEX
, 2, 0, 0, 0, TRUE
, FALSE
},
560 { "vs_3_0", ST_VERTEX
, 3, 0, 0, 0, FALSE
, TRUE
},
561 { "vs_3_sw", ST_VERTEX
, 3, 0, 0, 0, TRUE
, FALSE
},
562 { "vs_4_0", ST_VERTEX
, 4, 0, 0, 0, FALSE
, TRUE
},
563 { "vs_4_0_level_9_0", ST_VERTEX
, 4, 0, 9, 0, FALSE
, FALSE
},
564 { "vs_4_0_level_9_1", ST_VERTEX
, 4, 0, 9, 1, FALSE
, FALSE
},
565 { "vs_4_0_level_9_3", ST_VERTEX
, 4, 0, 9, 3, FALSE
, FALSE
},
566 { "vs_4_1", ST_VERTEX
, 4, 1, 0, 0, FALSE
, TRUE
},
567 { "vs_5_0", ST_VERTEX
, 5, 0, 0, 0, FALSE
, TRUE
},
570 static const struct target_info
* get_target_info(const char *target
)
573 LONG max
= sizeof(targets_info
) / sizeof(targets_info
[0]) - 1;
579 cur
= (min
+ max
) / 2;
580 res
= strcmp(target
, targets_info
[cur
].name
);
586 return &targets_info
[cur
];
592 static HRESULT
compile_shader(const char *preproc_shader
, const char *target
, const char *entrypoint
,
593 ID3DBlob
**shader_blob
, ID3DBlob
**error_messages
)
595 struct bwriter_shader
*shader
;
596 char *messages
= NULL
;
598 DWORD
*res
, size
, major
, minor
;
601 enum shader_type shader_type
;
602 const struct target_info
*info
;
604 TRACE("Preprocessed shader source: %s\n", debugstr_a(preproc_shader
));
606 TRACE("Checking compilation target %s\n", debugstr_a(target
));
607 info
= get_target_info(target
);
610 FIXME("Unknown compilation target %s\n", debugstr_a(target
));
611 return D3DERR_INVALIDCALL
;
617 FIXME("Compilation target %s not yet supported\n", debugstr_a(target
));
618 return D3DERR_INVALIDCALL
;
622 shader_type
= info
->type
;
623 major
= info
->sm_major
;
624 minor
= info
->sm_minor
;
628 shader
= parse_hlsl_shader(preproc_shader
, shader_type
, major
, minor
, entrypoint
, &messages
);
632 TRACE("Compiler messages:\n");
633 TRACE("%s\n", debugstr_a(messages
));
635 TRACE("Shader source:\n");
636 TRACE("%s\n", debugstr_a(preproc_shader
));
640 const char *preproc_messages
= *error_messages
? ID3D10Blob_GetBufferPointer(*error_messages
) : NULL
;
642 size
= strlen(messages
) + (preproc_messages
? strlen(preproc_messages
) : 0) + 1;
643 hr
= D3DCreateBlob(size
, &buffer
);
646 HeapFree(GetProcessHeap(), 0, messages
);
647 if (shader
) SlDeleteShader(shader
);
650 pos
= ID3D10Blob_GetBufferPointer(buffer
);
651 if (preproc_messages
)
653 memcpy(pos
, preproc_messages
, strlen(preproc_messages
) + 1);
654 pos
+= strlen(preproc_messages
);
656 memcpy(pos
, messages
, strlen(messages
) + 1);
658 if (*error_messages
) ID3D10Blob_Release(*error_messages
);
659 *error_messages
= buffer
;
661 HeapFree(GetProcessHeap(), 0, messages
);
666 ERR("HLSL shader parsing failed.\n");
667 return D3DXERR_INVALIDDATA
;
670 hr
= SlWriteBytecode(shader
, 9, &res
, &size
);
671 SlDeleteShader(shader
);
674 ERR("SlWriteBytecode failed with error 0x%08x.\n", hr
);
675 return D3DXERR_INVALIDDATA
;
680 hr
= D3DCreateBlob(size
, &buffer
);
683 HeapFree(GetProcessHeap(), 0, res
);
686 memcpy(ID3D10Blob_GetBufferPointer(buffer
), res
, size
);
687 *shader_blob
= buffer
;
690 HeapFree(GetProcessHeap(), 0, res
);
695 HRESULT WINAPI
D3DCompile2(const void *data
, SIZE_T data_size
, const char *filename
,
696 const D3D_SHADER_MACRO
*defines
, ID3DInclude
*include
, const char *entrypoint
,
697 const char *target
, UINT sflags
, UINT eflags
, UINT secondary_flags
,
698 const void *secondary_data
, SIZE_T secondary_data_size
, ID3DBlob
**shader
,
699 ID3DBlob
**error_messages
)
703 TRACE("data %p, data_size %lu, filename %s, defines %p, include %p, entrypoint %s, "
704 "target %s, sflags %#x, eflags %#x, secondary_flags %#x, secondary_data %p, "
705 "secondary_data_size %lu, shader %p, error_messages %p.\n",
706 data
, data_size
, debugstr_a(filename
), defines
, include
, debugstr_a(entrypoint
),
707 debugstr_a(target
), sflags
, eflags
, secondary_flags
, secondary_data
,
708 secondary_data_size
, shader
, error_messages
);
711 FIXME("secondary data not implemented yet\n");
713 if (shader
) *shader
= NULL
;
714 if (error_messages
) *error_messages
= NULL
;
716 EnterCriticalSection(&wpp_mutex
);
718 hr
= preprocess_shader(data
, data_size
, filename
, defines
, include
, error_messages
);
720 hr
= compile_shader(wpp_output
, target
, entrypoint
, shader
, error_messages
);
722 HeapFree(GetProcessHeap(), 0, wpp_output
);
723 LeaveCriticalSection(&wpp_mutex
);
727 HRESULT WINAPI
D3DCompile(const void *data
, SIZE_T data_size
, const char *filename
,
728 const D3D_SHADER_MACRO
*defines
, ID3DInclude
*include
, const char *entrypoint
,
729 const char *target
, UINT sflags
, UINT eflags
, ID3DBlob
**shader
, ID3DBlob
**error_messages
)
731 TRACE("data %p, data_size %lu, filename %s, defines %p, include %p, entrypoint %s, "
732 "target %s, sflags %#x, eflags %#x, shader %p, error_messages %p.\n",
733 data
, data_size
, debugstr_a(filename
), defines
, include
, debugstr_a(entrypoint
),
734 debugstr_a(target
), sflags
, eflags
, shader
, error_messages
);
736 return D3DCompile2(data
, data_size
, filename
, defines
, include
, entrypoint
, target
, sflags
,
737 eflags
, 0, NULL
, 0, shader
, error_messages
);
740 HRESULT WINAPI
D3DPreprocess(const void *data
, SIZE_T size
, const char *filename
,
741 const D3D_SHADER_MACRO
*defines
, ID3DInclude
*include
,
742 ID3DBlob
**shader
, ID3DBlob
**error_messages
)
747 TRACE("data %p, size %lu, filename %s, defines %p, include %p, shader %p, error_messages %p\n",
748 data
, size
, debugstr_a(filename
), defines
, include
, shader
, error_messages
);
753 EnterCriticalSection(&wpp_mutex
);
755 if (shader
) *shader
= NULL
;
756 if (error_messages
) *error_messages
= NULL
;
758 hr
= preprocess_shader(data
, size
, filename
, defines
, include
, error_messages
);
764 hr
= D3DCreateBlob(wpp_output_size
, &buffer
);
767 CopyMemory(ID3D10Blob_GetBufferPointer(buffer
), wpp_output
, wpp_output_size
);
775 HeapFree(GetProcessHeap(), 0, wpp_output
);
776 LeaveCriticalSection(&wpp_mutex
);
780 HRESULT WINAPI
D3DDisassemble(const void *data
, SIZE_T size
, UINT flags
, const char *comments
, ID3DBlob
**disassembly
)
782 FIXME("data %p, size %lu, flags %#x, comments %p, disassembly %p stub!\n",
783 data
, size
, flags
, comments
, disassembly
);
787 HRESULT WINAPI
D3DCompileFromFile(const WCHAR
*filename
, const D3D_SHADER_MACRO
*defines
, ID3DInclude
*includes
,
788 const char *entrypoint
, const char *target
, UINT flags1
, UINT flags2
, ID3DBlob
**code
, ID3DBlob
**errors
)
790 FIXME("filename %s, defines %p, includes %p, entrypoint %s, target %s, flags1 %x, flags2 %x, code %p, errors %p\n",
791 debugstr_w(filename
), defines
, includes
, debugstr_a(entrypoint
), debugstr_a(target
), flags1
, flags2
, code
, errors
);
796 HRESULT WINAPI
D3DLoadModule(const void *data
, SIZE_T size
, ID3D11Module
**module
)
798 FIXME("data %p, size %lu, module %p stub!\n", data
, size
, module
);