ReactOS 0.4.17-dev-923-g4c9a150
compiler.c
Go to the documentation of this file.
1/*
2 * Copyright 2009 Matteo Bruni
3 * Copyright 2010 Matteo Bruni for CodeWeavers
4 * Copyright 2016,2018 Józef Kucia for CodeWeavers
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#define COBJMACROS
22#include <stdarg.h>
23#include <time.h>
24#include "wine/debug.h"
25
26#include "d3dcompiler_private.h"
27
29
31{
32 switch (vkd3d_result)
33 {
34 case VKD3D_OK:
35 return S_OK;
37 WARN("Invalid shader bytecode.\n");
38 /* fall-through */
39 case VKD3D_ERROR:
40 return E_FAIL;
42 return E_OUTOFMEMORY;
44 return E_INVALIDARG;
46 return E_NOTIMPL;
47 default:
48 FIXME("Unhandled vkd3d result %d.\n", vkd3d_result);
49 return E_FAIL;
50 }
51}
52
53#define D3DXERR_INVALIDDATA 0x88760b59
54
55/* Mutex used to guarantee a single invocation of the D3DAssemble function at
56 * a time. This is needed as the assembler isn't thread-safe. */
59{
60 0, 0, &wpp_mutex,
63 0, 0, { (DWORD_PTR)(__FILE__ ": wpp_mutex") }
64};
65static CRITICAL_SECTION wpp_mutex = { &wpp_mutex_debug, -1, 0, 0, 0, 0 };
66
68{
70 const char *initial_filename;
71};
72
74{
76}
77
78static HRESULT WINAPI d3dcompiler_include_from_file_open(ID3DInclude *iface, D3D_INCLUDE_TYPE include_type,
79 const char *filename, const void *parent_data, const void **data, UINT *bytes)
80{
82 char *fullpath, *buffer = NULL, current_dir[MAX_PATH + 1];
83 const char *initial_dir;
86 ULONG read;
87 DWORD len;
88
89 if ((initial_dir = strrchr(include->initial_filename, '\\')))
90 {
91 len = initial_dir - include->initial_filename + 1;
92 initial_dir = include->initial_filename;
93 }
94 else
95 {
96 len = GetCurrentDirectoryA(MAX_PATH, current_dir);
97 current_dir[len] = '\\';
98 len++;
99 initial_dir = current_dir;
100 }
101 fullpath = malloc(len + strlen(filename) + 1);
102 if (!fullpath)
103 return E_OUTOFMEMORY;
104 memcpy(fullpath, initial_dir, len);
105 strcpy(fullpath + len, filename);
106
109 goto error;
110
111 TRACE("Include file found at %s.\n", debugstr_a(fullpath));
112
114 if (size == INVALID_FILE_SIZE)
115 goto error;
116 buffer = malloc(size);
117 if (!buffer)
118 goto error;
119 if (!ReadFile(file, buffer, size, &read, NULL) || read != size)
120 goto error;
121
122 *bytes = size;
123 *data = buffer;
124
125 free(fullpath);
127 return S_OK;
128
129error:
130 free(fullpath);
131 free(buffer);
133 WARN("Returning E_FAIL.\n");
134 return E_FAIL;
135}
136
138{
139 free((void *)data);
140 return S_OK;
141}
142
143const struct ID3DIncludeVtbl d3dcompiler_include_from_file_vtbl =
144{
147};
148
149static int open_include(const char *filename, bool local, const char *parent_data, void *context,
150 struct vkd3d_shader_code *code)
151{
152 ID3DInclude *iface = context;
153 unsigned int size = 0;
154
155 if (!iface)
156 return VKD3D_ERROR;
157
158 memset(code, 0, sizeof(*code));
159 if (FAILED(ID3DInclude_Open(iface, local ? D3D_INCLUDE_LOCAL : D3D_INCLUDE_SYSTEM,
160 filename, parent_data, &code->code, &size)))
161 return VKD3D_ERROR;
162
163 code->size = size;
164 return VKD3D_OK;
165}
166
167static void close_include(const struct vkd3d_shader_code *code, void *context)
168{
169 ID3DInclude *iface = context;
170
171 ID3DInclude_Close(iface, code->code);
172}
173
174static const char *get_line(const char **ptr)
175{
176 const char *p, *q;
177
178 p = *ptr;
179 if (!(q = strstr(p, "\n")))
180 {
181 if (!*p)
182 return NULL;
183 *ptr += strlen(p);
184 return p;
185 }
186 *ptr = q + 1;
187
188 return p;
189}
190
191static HRESULT preprocess_shader(const void *data, SIZE_T data_size, const char *filename,
192 const D3D_SHADER_MACRO *defines, ID3DInclude *include, ID3DBlob **shader_blob,
193 ID3DBlob **messages_blob)
194{
195 struct d3dcompiler_include_from_file include_from_file;
196 struct vkd3d_shader_preprocess_info preprocess_info;
197 struct vkd3d_shader_compile_info compile_info;
198 const D3D_SHADER_MACRO *def = defines;
199 struct vkd3d_shader_code byte_code;
200 char *messages;
201 HRESULT hr;
202 int ret;
203
205 {
206 include_from_file.ID3DInclude_iface.lpVtbl = &d3dcompiler_include_from_file_vtbl;
207 include_from_file.initial_filename = filename ? filename : "";
208 include = &include_from_file.ID3DInclude_iface;
209 }
210
212 compile_info.next = &preprocess_info;
213 compile_info.source.code = data;
214 compile_info.source.size = data_size;
217 compile_info.options = NULL;
218 compile_info.option_count = 0;
219 compile_info.log_level = VKD3D_SHADER_LOG_INFO;
220 compile_info.source_name = filename;
221
223 preprocess_info.next = NULL;
224 preprocess_info.macros = (const struct vkd3d_shader_macro *)defines;
225 preprocess_info.macro_count = 0;
226 if (defines)
227 {
228 for (def = defines; def->Name; ++def)
229 ++preprocess_info.macro_count;
230 }
231 preprocess_info.pfn_open_include = open_include;
232 preprocess_info.pfn_close_include = close_include;
233 preprocess_info.include_context = include;
234
235 ret = vkd3d_shader_preprocess(&compile_info, &byte_code, &messages);
236
237 if (ret)
238 ERR("Failed to preprocess shader, vkd3d result %d.\n", ret);
239
240 if (messages)
241 {
242 if (*messages && ERR_ON(d3dcompiler))
243 {
244 const char *ptr = messages;
245 const char *line;
246
247 ERR("Shader log:\n");
248 while ((line = get_line(&ptr)))
249 {
250 ERR(" %.*s", (int)(ptr - line), line);
251 }
252 ERR("\n");
253 }
254
255 if (messages_blob)
256 {
257 size_t size = strlen(messages);
258 if (FAILED(hr = D3DCreateBlob(size, messages_blob)))
259 {
262 return hr;
263 }
264 memcpy(ID3D10Blob_GetBufferPointer(*messages_blob), messages, size);
265 }
266 else
267 {
269 }
270 }
271
272 if (!ret)
273 {
274 if (FAILED(hr = D3DCreateBlob(byte_code.size, shader_blob)))
275 {
277 return hr;
278 }
279 memcpy(ID3D10Blob_GetBufferPointer(*shader_blob), byte_code.code, byte_code.size);
280 }
281
283}
284
285static HRESULT assemble_shader(const char *preproc_shader, ID3DBlob **shader_blob, ID3DBlob **error_messages)
286{
287 struct bwriter_shader *shader;
288 char *messages = NULL;
289 uint32_t *res, size;
291 HRESULT hr;
292 char *pos;
293
294 shader = SlAssembleShader(preproc_shader, &messages);
295
296 if (messages)
297 {
298 TRACE("Assembler messages:\n");
299 TRACE("%s\n", debugstr_a(messages));
300
301 TRACE("Shader source:\n");
302 TRACE("%s\n", debugstr_a(preproc_shader));
303
304 if (error_messages)
305 {
306 const char *preproc_messages = *error_messages ? ID3D10Blob_GetBufferPointer(*error_messages) : NULL;
307
308 size = strlen(messages) + (preproc_messages ? strlen(preproc_messages) : 0) + 1;
310 if (FAILED(hr))
311 {
312 free(messages);
314 return hr;
315 }
316 pos = ID3D10Blob_GetBufferPointer(buffer);
317 if (preproc_messages)
318 {
319 CopyMemory(pos, preproc_messages, strlen(preproc_messages) + 1);
320 pos += strlen(preproc_messages);
321 }
323
324 if (*error_messages) ID3D10Blob_Release(*error_messages);
326 }
327 free(messages);
328 }
329
330 if (shader == NULL)
331 {
332 ERR("Asm reading failed\n");
333 return D3DXERR_INVALIDDATA;
334 }
335
338 if (FAILED(hr))
339 {
340 ERR("Failed to write bytecode, hr %#lx.\n", hr);
341 return D3DXERR_INVALIDDATA;
342 }
343
344 if (shader_blob)
345 {
347 if (FAILED(hr))
348 {
349 free(res);
350 return hr;
351 }
352 CopyMemory(ID3D10Blob_GetBufferPointer(buffer), res, size);
353 *shader_blob = buffer;
354 }
355
356 free(res);
357
358 return S_OK;
359}
360
364{
365 unsigned int preproc_size;
366 ID3DBlob *preproc_shader;
367 char *preproc_terminated;
368 HRESULT hr;
369
370 TRACE("data %p, datasize %Iu, filename %s, defines %p, include %p, sflags %#x, "
371 "shader %p, error_messages %p.\n",
373
375
376 /* TODO: flags */
377 if (flags) FIXME("flags %x\n", flags);
378
379 if (shader) *shader = NULL;
381
383 if (SUCCEEDED(hr))
384 {
385 preproc_size = ID3D10Blob_GetBufferSize(preproc_shader);
386 if ((preproc_terminated = malloc(preproc_size + 1)))
387 {
388 memcpy(preproc_terminated, ID3D10Blob_GetBufferPointer(preproc_shader), preproc_size);
389 ID3D10Blob_Release(preproc_shader);
390 preproc_terminated[preproc_size] = 0;
391
392 hr = assemble_shader(preproc_terminated, shader, error_messages);
393 free(preproc_terminated);
394 }
395 }
397 return hr;
398}
399
401{
402 size_t profile_len, i;
403
404 static const char * const d3dbc_profiles[] =
405 {
406 "ps.1.",
407 "ps.2.",
408 "ps.3.",
409
410 "ps_1_",
411 "ps_2_",
412 "ps_3_",
413
414 "vs.1.",
415 "vs.2.",
416 "vs.3.",
417
418 "vs_1_",
419 "vs_2_",
420 "vs_3_",
421
422 "tx_1_",
423 };
424
425 static const char * const fx_profiles[] =
426 {
427 "fx_2_0",
428 "fx_4_0",
429 "fx_4_1",
430 "fx_5_0",
431 };
432
433 profile_len = strlen(profile);
434 for (i = 0; i < ARRAY_SIZE(d3dbc_profiles); ++i)
435 {
436 size_t len = strlen(d3dbc_profiles[i]);
437
438 if (len <= profile_len && !memcmp(profile, d3dbc_profiles[i], len))
440 }
441
442 for (i = 0; i < ARRAY_SIZE(fx_profiles); ++i)
443 {
444 if (!strcmp(profile, fx_profiles[i]))
446 }
447
449}
450
451HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filename,
452 const D3D_SHADER_MACRO *macros, ID3DInclude *include, const char *entry_point,
453 const char *profile, UINT flags, UINT effect_flags, UINT secondary_flags,
454 const void *secondary_data, SIZE_T secondary_data_size, ID3DBlob **shader_blob,
455 ID3DBlob **messages_blob)
456{
457 struct d3dcompiler_include_from_file include_from_file;
458 struct vkd3d_shader_preprocess_info preprocess_info;
459 struct vkd3d_shader_hlsl_source_info hlsl_info;
461 struct vkd3d_shader_compile_info compile_info;
463 struct vkd3d_shader_code byte_code;
464 const D3D_SHADER_MACRO *macro;
465 char *messages;
466 HRESULT hr;
467 int ret;
468
469 TRACE("data %p, data_size %Iu, filename %s, macros %p, include %p, entry_point %s, "
470 "profile %s, flags %#x, effect_flags %#x, secondary_flags %#x, secondary_data %p, "
471 "secondary_data_size %Iu, shader_blob %p, messages_blob %p.\n",
472 data, data_size, debugstr_a(filename), macros, include, debugstr_a(entry_point),
473 debugstr_a(profile), flags, effect_flags, secondary_flags, secondary_data,
474 secondary_data_size, shader_blob, messages_blob);
475
477 {
478 include_from_file.ID3DInclude_iface.lpVtbl = &d3dcompiler_include_from_file_vtbl;
479 include_from_file.initial_filename = filename ? filename : "";
480 include = &include_from_file.ID3DInclude_iface;
481 }
482
485 {
486 FIXME("Ignoring flags %#x.\n", flags);
487 }
488 if (effect_flags & ~D3DCOMPILE_EFFECT_CHILD_EFFECT)
489 FIXME("Ignoring effect flags %#x.\n", effect_flags & ~D3DCOMPILE_EFFECT_CHILD_EFFECT);
490 if (secondary_flags)
491 FIXME("Ignoring secondary flags %#x.\n", secondary_flags);
492
493 if (shader_blob)
494 *shader_blob = NULL;
495 if (messages_blob)
496 *messages_blob = NULL;
497
498 option = &options[0];
501
503 compile_info.next = &preprocess_info;
504 compile_info.source.code = data;
505 compile_info.source.size = data_size;
508 compile_info.options = options;
509 compile_info.option_count = 1;
510 compile_info.log_level = VKD3D_SHADER_LOG_INFO;
511 compile_info.source_name = filename;
512
514 preprocess_info.next = &hlsl_info;
515 preprocess_info.macros = (const struct vkd3d_shader_macro *)macros;
516 preprocess_info.macro_count = 0;
517 if (macros)
518 {
519 for (macro = macros; macro->Name; ++macro)
520 ++preprocess_info.macro_count;
521 }
522 preprocess_info.pfn_open_include = open_include;
523 preprocess_info.pfn_close_include = close_include;
524 preprocess_info.include_context = include;
525
527 hlsl_info.next = NULL;
528 hlsl_info.profile = profile;
529 hlsl_info.entry_point = entry_point;
530 hlsl_info.secondary_code.code = secondary_data;
531 hlsl_info.secondary_code.size = secondary_data_size;
532
533 if (!(flags & D3DCOMPILE_DEBUG))
534 {
535 option = &options[compile_info.option_count++];
537 option->value = true;
538 }
539
541 {
542 option = &options[compile_info.option_count++];
545 }
547 {
548 option = &options[compile_info.option_count++];
551 }
552
554 {
555 option = &options[compile_info.option_count++];
558 }
559
560 if (effect_flags & D3DCOMPILE_EFFECT_CHILD_EFFECT)
561 {
562 option = &options[compile_info.option_count++];
564 option->value = true;
565 }
566
567#if D3D_COMPILER_VERSION <= 39
568 option = &options[compile_info.option_count++];
570 option->value = true;
571#endif
572
573 ret = vkd3d_shader_compile(&compile_info, &byte_code, &messages);
574
575 if (ret)
576 ERR("Failed to compile shader, vkd3d result %d.\n", ret);
577
578 if (messages)
579 {
580 if (*messages && ERR_ON(d3dcompiler))
581 {
582 const char *ptr = messages;
583 const char *line;
584
585 ERR("Shader log:\n");
586 while ((line = get_line(&ptr)))
587 {
588 ERR(" %.*s", (int)(ptr - line), line);
589 }
590 ERR("\n");
591 }
592
593 if (messages_blob)
594 {
595 size_t size = strlen(messages);
596 if (FAILED(hr = D3DCreateBlob(size, messages_blob)))
597 {
600 return hr;
601 }
602 memcpy(ID3D10Blob_GetBufferPointer(*messages_blob), messages, size);
603 }
604
606 }
607
608 if (ret)
610
611 if (!shader_blob)
612 {
614 return S_OK;
615 }
616
617 /* Unlike other effect profiles fx_4_x is using DXBC container. */
618 if (!strcmp(profile, "fx_4_0") || !strcmp(profile, "fx_4_1"))
619 {
620 struct vkd3d_shader_dxbc_section_desc section = { .tag = TAG_FX10, .data = byte_code };
621 struct vkd3d_shader_code dxbc;
622
625 if (ret)
627
628 byte_code = dxbc;
629 }
630
631 if (SUCCEEDED(hr = D3DCreateBlob(byte_code.size, shader_blob)))
632 memcpy(ID3D10Blob_GetBufferPointer(*shader_blob), byte_code.code, byte_code.size);
633
635
636 return hr;
637}
638
639HRESULT WINAPI D3DCompile(const void *data, SIZE_T data_size, const char *filename,
640 const D3D_SHADER_MACRO *defines, ID3DInclude *include, const char *entrypoint,
642{
643 TRACE("data %p, data_size %Iu, filename %s, defines %p, include %p, entrypoint %s, "
644 "target %s, sflags %#x, eflags %#x, shader %p, error_messages %p.\n",
645 data, data_size, debugstr_a(filename), defines, include, debugstr_a(entrypoint),
647
648 return D3DCompile2(data, data_size, filename, defines, include, entrypoint, target, sflags,
650}
651
655{
656 TRACE("data %p, size %Iu, filename %s, defines %p, include %p, shader %p, error_messages %p.\n",
658
659 if (!data)
660 return E_INVALIDARG;
661
662 if (shader) *shader = NULL;
664
666}
667
669 ID3DBlob **disassembly)
670{
671 struct vkd3d_shader_compile_info compile_info;
673 struct vkd3d_shader_code asm_code;
674 const char *ptr = data;
675 char *messages;
676 HRESULT hr;
677 int ret;
678
679 TRACE("data %p, size %Iu, flags %#x, comments %p, disassembly %p.\n",
680 data, size, flags, comments, disassembly);
681
682 if (flags)
683 FIXME("Ignoring flags %#x.\n", flags);
684
685 if (comments)
686 FIXME("Ignoring comments %s.\n", debugstr_a(comments));
687
688#if D3D_COMPILER_VERSION >= 46
689 if (!size)
690 return E_INVALIDARG;
691#endif
692
693 if (size >= 4 && read_u32(&ptr) == TAG_DXBC)
694 source_type = VKD3D_SHADER_SOURCE_DXBC_TPF;
695 else
697
699 compile_info.next = NULL;
700 compile_info.source.code = data;
701 compile_info.source.size = size;
702 compile_info.source_type = source_type;
704 compile_info.options = NULL;
705 compile_info.option_count = 0;
706 compile_info.log_level = VKD3D_SHADER_LOG_INFO;
707 compile_info.source_name = NULL;
708
709 ret = vkd3d_shader_compile(&compile_info, &asm_code, &messages);
710
711 if (ret)
712 ERR("Failed to disassemble shader, vkd3d result %d.\n", ret);
713
714 if (messages)
715 {
716 if (*messages && ERR_ON(d3dcompiler))
717 {
718 const char *ptr = messages;
719 const char *line;
720
721 ERR("Shader log:\n");
722 while ((line = get_line(&ptr)))
723 {
724 ERR(" %.*s", (int)(ptr - line), line);
725 }
726 ERR("\n");
727 }
728
730 }
731
732 if (ret)
734
735 if (SUCCEEDED(hr = D3DCreateBlob(asm_code.size, disassembly)))
736 memcpy(ID3D10Blob_GetBufferPointer(*disassembly), asm_code.code, asm_code.size);
737
739
740 return hr;
741}
742
744 const char *entrypoint, const char *target, UINT flags1, UINT flags2, ID3DBlob **code, ID3DBlob **errors)
745{
746 char filename_a[MAX_PATH], *source = NULL;
747 DWORD source_size, read_size;
748 HANDLE file;
749 HRESULT hr;
750
751 TRACE("filename %s, defines %p, include %p, entrypoint %s, target %s, flags1 %#x, flags2 %#x, "
752 "code %p, errors %p.\n", debugstr_w(filename), defines, include, debugstr_a(entrypoint),
753 debugstr_a(target), flags1, flags2, code, errors);
754
758
759 source_size = GetFileSize(file, NULL);
760 if (source_size == INVALID_FILE_SIZE)
761 {
763 goto end;
764 }
765
766 if (!(source = malloc(source_size)))
767 {
769 goto end;
770 }
771
772 if (!ReadFile(file, source, source_size, &read_size, NULL) || read_size != source_size)
773 {
774 WARN("Failed to read file contents.\n");
775 hr = E_FAIL;
776 goto end;
777 }
778
779 WideCharToMultiByte(CP_ACP, 0, filename, -1, filename_a, sizeof(filename_a), NULL, NULL);
780
781 hr = D3DCompile(source, source_size, filename_a, defines, include, entrypoint, target,
782 flags1, flags2, code, errors);
783
784end:
785 free(source);
787 return hr;
788}
789
790HRESULT WINAPI D3DCreateLinker(ID3D11Linker **linker)
791{
792 FIXME("linker %p stub!\n", linker);
793 return E_NOTIMPL;
794}
795
796HRESULT WINAPI D3DLoadModule(const void *data, SIZE_T size, ID3D11Module **module)
797{
798 FIXME("data %p, size %Iu, module %p stub!\n", data, size, module);
799 return E_NOTIMPL;
800}
#define read
Definition: acwin.h:97
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
static WCHAR *(* get_line)(FILE *)
Definition: import.c:55
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
HRESULT shader_write_bytecode(const struct bwriter_shader *shader, uint32_t **result, uint32_t *size)
void SlDeleteShader(struct bwriter_shader *shader)
#define D3DCOMPILE_DEBUG
Definition: d3dcompiler.h:42
#define D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY
Definition: d3dcompiler.h:54
#define D3DCOMPILE_PACK_MATRIX_ROW_MAJOR
Definition: d3dcompiler.h:45
#define D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR
Definition: d3dcompiler.h:46
#define D3DCOMPILE_EFFECT_CHILD_EFFECT
Definition: d3dcompiler.h:69
#define D3D_COMPILE_STANDARD_FILE_INCLUDE
Definition: d3dcompiler.h:85
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
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:652
static HRESULT WINAPI d3dcompiler_include_from_file_open(ID3DInclude *iface, D3D_INCLUDE_TYPE include_type, const char *filename, const void *parent_data, const void **data, UINT *bytes)
Definition: compiler.c:78
static CRITICAL_SECTION wpp_mutex
Definition: compiler.c:57
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:639
static int open_include(const char *filename, bool local, const char *parent_data, void *context, struct vkd3d_shader_code *code)
Definition: compiler.c:149
static void close_include(const struct vkd3d_shader_code *code, void *context)
Definition: compiler.c:167
HRESULT WINAPI D3DDisassemble(const void *data, SIZE_T size, UINT flags, const char *comments, ID3DBlob **disassembly)
Definition: compiler.c:668
static CRITICAL_SECTION_DEBUG wpp_mutex_debug
Definition: compiler.c:58
static HRESULT hresult_from_vkd3d_result(int vkd3d_result)
Definition: compiler.c:30
static HRESULT preprocess_shader(const void *data, SIZE_T data_size, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, ID3DBlob **shader_blob, ID3DBlob **messages_blob)
Definition: compiler.c:191
#define D3DXERR_INVALIDDATA
Definition: compiler.c:53
static HRESULT WINAPI d3dcompiler_include_from_file_close(ID3DInclude *iface, const void *data)
Definition: compiler.c:137
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:361
HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filename, const D3D_SHADER_MACRO *macros, ID3DInclude *include, const char *entry_point, const char *profile, UINT flags, UINT effect_flags, UINT secondary_flags, const void *secondary_data, SIZE_T secondary_data_size, ID3DBlob **shader_blob, ID3DBlob **messages_blob)
Definition: compiler.c:451
HRESULT WINAPI D3DCompileFromFile(const WCHAR *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, const char *entrypoint, const char *target, UINT flags1, UINT flags2, ID3DBlob **code, ID3DBlob **errors)
Definition: compiler.c:743
static enum vkd3d_shader_target_type get_target_for_profile(const char *profile)
Definition: compiler.c:400
HRESULT WINAPI D3DLoadModule(const void *data, SIZE_T size, ID3D11Module **module)
Definition: compiler.c:796
const struct ID3DIncludeVtbl d3dcompiler_include_from_file_vtbl
Definition: compiler.c:143
HRESULT WINAPI D3DCreateLinker(ID3D11Linker **linker)
Definition: compiler.c:790
static HRESULT assemble_shader(const char *preproc_shader, ID3DBlob **shader_blob, ID3DBlob **error_messages)
Definition: compiler.c:285
static struct d3dcompiler_include_from_file * impl_from_ID3DInclude(ID3DInclude *iface)
Definition: compiler.c:73
#define TAG_DXBC
struct bwriter_shader * SlAssembleShader(const char *text, char **messages)
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#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
HRESULT hr
Definition: delayimp.cpp:582
char comments[4096]
#define NULL
Definition: types.h:112
UINT32 uint32_t
Definition: types.h:75
#define TAG_FX10
Definition: effect.c:32
HRESULT WINAPI D3DCreateBlob(SIZE_T data_size, ID3DBlob **blob)
Definition: blob.c:133
static uint32_t read_u32(const char **ptr)
Definition: utils.h:24
#define CloseHandle
Definition: compat.h:739
#define CP_ACP
Definition: compat.h:109
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define WideCharToMultiByte
Definition: compat.h:111
#define FILE_SHARE_READ
Definition: compat.h:136
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2164
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
_ACRTIMP char *__cdecl strstr(const char *, const char *)
Definition: string.c:3420
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
_ACRTIMP char *__cdecl strrchr(const char *, int)
Definition: string.c:3303
return ret
Definition: mutex.c:147
unsigned long DWORD
Definition: ntddk_ex.h:95
#define local
Definition: zutil.h:30
struct macel macros[16]
Definition: main.c:109
GLuint GLuint end
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLuint shader
Definition: glext.h:6030
GLbitfield flags
Definition: glext.h:7161
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
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
unsigned int UINT
Definition: sysinfo.c:13
#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 profile
Definition: kernel32.h:12
#define debugstr_w
Definition: kernel32.h:32
#define CopyMemory
Definition: minwinbase.h:29
#define error(str)
Definition: mkdosfs.c:1605
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PVOID ptr
Definition: dispmode.c:27
short WCHAR
Definition: pedump.c:58
strcpy
Definition: string.h:131
#define ERR_ON(ch)
Definition: debug.h:423
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
const char * Name
Definition: d3dcommon.idl:24
Definition: inflate.c:139
Definition: http.c:7252
ID3DInclude ID3DInclude_iface
Definition: compiler.c:69
const char * initial_filename
Definition: compiler.c:70
Definition: fci.c:123
Definition: parser.c:49
Definition: getopt.h:109
WCHAR * name
Definition: getopt.h:110
Definition: parser.c:56
Definition: tools.h:99
const void * code
Definition: vkd3d_shader.h:413
const struct vkd3d_shader_compile_option * options
struct vkd3d_shader_code source
enum vkd3d_shader_log_level log_level
enum vkd3d_shader_structure_type type
enum vkd3d_shader_source_type source_type
enum vkd3d_shader_target_type target_type
enum vkd3d_shader_structure_type type
struct vkd3d_shader_code secondary_code
enum vkd3d_shader_structure_type type
const struct vkd3d_shader_macro * macros
PFN_vkd3d_shader_open_include pfn_open_include
PFN_vkd3d_shader_close_include pfn_close_include
#define DWORD_PTR
Definition: treelist.c:76
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
@ VKD3D_SHADER_COMPILE_OPTION_BACKWARD_COMPATIBILITY
Definition: vkd3d_shader.h:310
@ VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ORDER
Definition: vkd3d_shader.h:302
@ VKD3D_SHADER_COMPILE_OPTION_CHILD_EFFECT
Definition: vkd3d_shader.h:341
@ VKD3D_SHADER_COMPILE_OPTION_API_VERSION
Definition: vkd3d_shader.h:279
@ VKD3D_SHADER_COMPILE_OPTION_STRIP_DEBUG
Definition: vkd3d_shader.h:273
@ VKD3D_SHADER_COMPILE_OPTION_INCLUDE_EMPTY_BUFFERS_IN_EFFECTS
Definition: vkd3d_shader.h:360
VKD3D_SHADER_API void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *code)
@ VKD3D_SHADER_COMPILE_OPTION_BACKCOMPAT_MAP_SEMANTIC_NAMES
Definition: vkd3d_shader.h:193
vkd3d_shader_source_type
@ VKD3D_SHADER_SOURCE_D3D_BYTECODE
@ VKD3D_SHADER_SOURCE_HLSL
@ VKD3D_SHADER_SOURCE_DXBC_TPF
VKD3D_SHADER_API int vkd3d_shader_serialize_dxbc(size_t section_count, const struct vkd3d_shader_dxbc_section_desc *sections, struct vkd3d_shader_code *dxbc, char **messages)
Definition: dxbc.c:53
@ VKD3D_SHADER_LOG_INFO
@ VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO
Definition: vkd3d_shader.h:68
@ VKD3D_SHADER_STRUCTURE_TYPE_PREPROCESS_INFO
Definition: vkd3d_shader.h:89
@ VKD3D_SHADER_STRUCTURE_TYPE_HLSL_SOURCE_INFO
Definition: vkd3d_shader.h:84
@ VKD3D_SHADER_API_VERSION_1_3
Definition: vkd3d_shader.h:48
VKD3D_SHADER_API int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, char **messages)
VKD3D_SHADER_API int vkd3d_shader_preprocess(const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, char **messages)
vkd3d_shader_target_type
@ VKD3D_SHADER_TARGET_D3D_ASM
@ VKD3D_SHADER_TARGET_NONE
@ VKD3D_SHADER_TARGET_DXBC_TPF
@ VKD3D_SHADER_TARGET_D3D_BYTECODE
@ VKD3D_SHADER_TARGET_FX
@ VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_COLUMN_MAJOR
Definition: vkd3d_shader.h:174
@ VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ROW_MAJOR
Definition: vkd3d_shader.h:173
VKD3D_SHADER_API void vkd3d_shader_free_messages(char *messages)
vkd3d_result
Definition: vkd3d_types.h:41
@ VKD3D_ERROR_INVALID_ARGUMENT
Definition: vkd3d_types.h:51
@ VKD3D_ERROR_NOT_IMPLEMENTED
Definition: vkd3d_types.h:55
@ VKD3D_ERROR_INVALID_SHADER
Definition: vkd3d_types.h:53
@ VKD3D_ERROR
Definition: vkd3d_types.h:47
@ VKD3D_OK
Definition: vkd3d_types.h:43
@ VKD3D_ERROR_OUT_OF_MEMORY
Definition: vkd3d_types.h:49
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define INVALID_FILE_SIZE
Definition: winbase.h:528
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define WINAPI
Definition: msvc.h:6
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210