ReactOS 0.4.17-dev-934-g091855f
vkd3d_shader_main.c
Go to the documentation of this file.
1/*
2 * Copyright 2017 Józef Kucia for CodeWeavers
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
20#include "vkd3d_version.h"
21#include "hlsl.h"
22
23#include <stdio.h>
24#include <math.h>
25
26static inline int char_to_int(char c)
27{
28 if ('0' <= c && c <= '9')
29 return c - '0';
30 if ('A' <= c && c <= 'F')
31 return c - 'A' + 10;
32 if ('a' <= c && c <= 'f')
33 return c - 'a' + 10;
34 return -1;
35}
36
38{
39 uint32_t base = 10, ret = 0;
40 int digit;
41
42 if (*s == '0')
43 {
44 base = 8;
45 ++s;
46 if (*s == 'x' || *s == 'X')
47 {
48 base = 16;
49 ++s;
50 }
51 }
52
53 while ((digit = char_to_int(*s++)) >= 0)
54 ret = ret * base + (uint32_t)digit;
55 return ret;
56}
57
59{
60 buffer->buffer_size = 16;
61 buffer->content_size = 0;
62 buffer->buffer = vkd3d_malloc(buffer->buffer_size);
63 VKD3D_ASSERT(buffer->buffer);
64 memset(buffer->buffer, 0, buffer->buffer_size);
65}
66
68{
69 vkd3d_free(buffer->buffer);
70}
71
73{
75}
76
78{
79 if (size < buffer->content_size)
80 {
81 buffer->buffer[size] = '\0';
82 buffer->content_size = size;
83 }
84}
85
87{
88 unsigned int new_buffer_size = rc >= 0 ? buffer->content_size + rc + 1 : buffer->buffer_size * 2;
89
90 if (!vkd3d_array_reserve((void **)&buffer->buffer, &buffer->buffer_size, new_buffer_size, 1))
91 {
92 ERR("Failed to grow buffer.\n");
93 buffer->buffer[buffer->content_size] = '\0';
94 return false;
95 }
96 return true;
97}
98
100{
101 unsigned int rem;
102 va_list a;
103 int rc;
104
105 for (;;)
106 {
107 rem = buffer->buffer_size - buffer->content_size;
108 va_copy(a, args);
109 rc = vsnprintf(&buffer->buffer[buffer->content_size], rem, format, a);
110 va_end(a);
111 if (rc >= 0 && (unsigned int)rc < rem)
112 {
113 buffer->content_size += rc;
114 return 0;
115 }
116
118 return -1;
119 }
120}
121
123{
125 int ret;
126
129 va_end(args);
130
131 return ret;
132}
133
135{
136 unsigned int idx = buffer->content_size + 1;
137 int ret;
138
139 if (!(ret = vkd3d_string_buffer_printf(buffer, "%.8e", f)) && isfinite(f))
140 {
141 if (signbit(f))
142 ++idx;
143 buffer->buffer[idx] = '.';
144 }
145
146 return ret;
147}
148
150{
151 unsigned int idx = buffer->content_size + 1;
152 int ret;
153
154 if (!(ret = vkd3d_string_buffer_printf(buffer, "%.16e", d)) && isfinite(d))
155 {
156 if (signbit(d))
157 ++idx;
158 buffer->buffer[idx] = '.';
159 }
160
161 return ret;
162}
163
164void vkd3d_string_buffer_trace_(const struct vkd3d_string_buffer *buffer, const char *function)
165{
166 vkd3d_shader_trace_text_(buffer->buffer, buffer->content_size, function);
167}
168
169void vkd3d_shader_trace_text_(const char *text, size_t size, const char *function)
170{
171 const char *p, *q, *end = text + size;
172
173 if (!TRACE_ON())
174 return;
175
176 for (p = text; p < end; p = q)
177 {
178 if (!(q = memchr(p, '\n', end - p)))
179 q = end;
180 else
181 ++q;
182 vkd3d_dbg_printf(VKD3D_DBG_LEVEL_TRACE, function, "%.*s", (int)(q - p), p);
183 }
184}
185
187{
188 memset(cache, 0, sizeof(*cache));
189}
190
192{
193 unsigned int i;
194
195 for (i = 0; i < cache->count; ++i)
196 {
198 vkd3d_free(cache->buffers[i]);
199 }
200 vkd3d_free(cache->buffers);
202}
203
205{
207
208 if (!cache->count)
209 {
210 if (!vkd3d_array_reserve((void **)&cache->buffers, &cache->capacity,
211 cache->max_count + 1, sizeof(*cache->buffers)))
212 return NULL;
213 ++cache->max_count;
214
215 if (!(buffer = vkd3d_malloc(sizeof(*buffer))))
216 return NULL;
218 }
219 else
220 {
221 buffer = cache->buffers[--cache->count];
222 }
224 return buffer;
225}
226
228{
229 if (!buffer)
230 return;
231 VKD3D_ASSERT(cache->count + 1 <= cache->max_count);
232 cache->buffers[cache->count++] = buffer;
233}
234
236{
237 code->code = buffer->buffer;
238 code->size = buffer->content_size;
239
240 buffer->buffer = NULL;
241 buffer->buffer_size = 0;
242 buffer->content_size = 0;
243}
244
246 enum vkd3d_shader_log_level log_level)
247{
248 context->log_level = log_level;
250}
251
253{
255}
256
258 const char *function)
259{
260 vkd3d_string_buffer_trace_(&context->messages, function);
261}
262
264{
265 char *messages;
266
267 if (!out)
268 return true;
269
270 *out = NULL;
271
272 if (!context->messages.content_size)
273 return true;
274
275 if (!(messages = vkd3d_malloc(context->messages.content_size + 1)))
276 return false;
277 memcpy(messages, context->messages.buffer, context->messages.content_size + 1);
278 *out = messages;
279 return true;
280}
281
284{
285 if (context->log_level < level)
286 return;
287
288 if (location)
289 {
290 const char *source_name = location->source_name ? location->source_name : "<anonymous>";
291
292 if (location->line)
293 vkd3d_string_buffer_printf(&context->messages, "%s:%u:%u: ",
294 source_name, location->line, location->column);
295 else
296 vkd3d_string_buffer_printf(&context->messages, "%s: ", source_name);
297 }
299 vkd3d_string_buffer_printf(&context->messages, "\n");
300}
301
303 enum vkd3d_shader_error error, const char *format, va_list args)
304{
305 if (context->log_level < VKD3D_SHADER_LOG_WARNING)
306 return;
307
308 if (location)
309 {
310 const char *source_name = location->source_name ? location->source_name : "<anonymous>";
311
312 if (location->line)
313 vkd3d_string_buffer_printf(&context->messages, "%s:%u:%u: W%04u: ",
314 source_name, location->line, location->column, error);
315 else
316 vkd3d_string_buffer_printf(&context->messages, "%s: W%04u: ", source_name, error);
317 }
318 else
319 {
320 vkd3d_string_buffer_printf(&context->messages, "W%04u: ", error);
321 }
323 vkd3d_string_buffer_printf(&context->messages, "\n");
324}
325
327 enum vkd3d_shader_error error, const char *format, ...)
328{
330
333 va_end(args);
334}
335
337 enum vkd3d_shader_error error, const char *format, va_list args)
338{
339 if (context->log_level < VKD3D_SHADER_LOG_ERROR)
340 return;
341
342 if (location)
343 {
344 const char *source_name = location->source_name ? location->source_name : "<anonymous>";
345
346 if (location->line)
347 vkd3d_string_buffer_printf(&context->messages, "%s:%u:%u: E%04u: ",
348 source_name, location->line, location->column, error);
349 else
350 vkd3d_string_buffer_printf(&context->messages, "%s: E%04u: ", source_name, error);
351 }
352 else
353 {
354 vkd3d_string_buffer_printf(&context->messages, "E%04u: ", error);
355 }
357 vkd3d_string_buffer_printf(&context->messages, "\n");
358}
359
361 enum vkd3d_shader_error error, const char *format, ...)
362{
364
367 va_end(args);
368}
369
371{
372 size_t aligned_size = align(buffer->size, 4);
373
374 if (!vkd3d_array_reserve((void **)&buffer->data, &buffer->capacity, aligned_size, 1))
375 {
377 return aligned_size;
378 }
379
380 memset(buffer->data + buffer->size, 0xab, aligned_size - buffer->size);
381 buffer->size = aligned_size;
382 return aligned_size;
383}
384
386{
387 size_t offset = buffer->size;
388
389 if (buffer->status)
390 return offset;
391
392 if (!vkd3d_array_reserve((void **)&buffer->data, &buffer->capacity, offset + size, 1))
393 {
395 return offset;
396 }
397 memcpy(buffer->data + offset, bytes, size);
398 buffer->size = offset + size;
399 return offset;
400}
401
402size_t bytecode_put_bytes(struct vkd3d_bytecode_buffer *buffer, const void *bytes, size_t size)
403{
406}
407
409{
410 size_t offset = bytecode_align(buffer);
411
412 if (buffer->status)
413 return offset;
414
415 if (!vkd3d_array_reserve((void **)&buffer->data, &buffer->capacity, offset + size, 1))
416 {
418 return offset;
419 }
420
421 memset(buffer->data + offset, 0, size);
422 buffer->size = offset + size;
423 return offset;
424}
425
427 const void *value, size_t size)
428{
429 if (buffer->status)
430 return;
431
433 memcpy(buffer->data + offset, value, size);
434}
435
437{
439}
440
441void set_string(struct vkd3d_bytecode_buffer *buffer, size_t offset, const char *string, size_t length)
442{
444}
445
447{
449 const char *path;
450 const char *profile;
451 const char *source_suffix;
452 const char *target_suffix;
453};
454
455static void vkd3d_shader_dump_shader(const struct shader_dump_data *dump_data,
456 const void *data, size_t size, bool source)
457{
458 static const char hexadecimal_digits[] = "0123456789abcdef";
459 const uint8_t *checksum = dump_data->checksum;
460 char str_checksum[33];
461 unsigned int pos = 0;
462 char filename[1024];
463 unsigned int i;
464 FILE *f;
465
466 if (!dump_data->path)
467 return;
468
469 for (i = 0; i < ARRAY_SIZE(dump_data->checksum); ++i)
470 {
471 str_checksum[2 * i] = hexadecimal_digits[checksum[i] >> 4];
472 str_checksum[2 * i + 1] = hexadecimal_digits[checksum[i] & 0xf];
473 }
474 str_checksum[32] = '\0';
475
476 pos = snprintf(filename, ARRAY_SIZE(filename), "%s/vkd3d-shader-%s", dump_data->path, str_checksum);
477
478 if (dump_data->profile)
479 pos += snprintf(filename + pos, ARRAY_SIZE(filename) - pos, "-%s", dump_data->profile);
480
481 if (source)
482 pos += snprintf(filename + pos, ARRAY_SIZE(filename) - pos, "-source.%s", dump_data->source_suffix);
483 else
484 pos += snprintf(filename + pos, ARRAY_SIZE(filename) - pos, "-target.%s", dump_data->target_suffix);
485
486 TRACE("Dumping shader to \"%s\".\n", filename);
487 if ((f = fopen(filename, "wb")))
488 {
489 if (fwrite(data, 1, size, f) != size)
490 WARN("Failed to write shader to %s.\n", filename);
491 if (fclose(f))
492 WARN("Failed to close stream %s.\n", filename);
493 }
494 else
495 {
496 WARN("Failed to open %s for dumping shader.\n", filename);
497 }
498}
499
501{
502 switch (type)
503 {
505 return "dxbc";
507 return "hlsl";
509 return "d3dbc";
511 return "dxil";
512 default:
513 FIXME("Unhandled source type %#x.\n", type);
514 return "bin";
515 }
516}
517
519{
520 switch (type)
521 {
523 return "spv";
525 return "spv.s";
527 return "d3d.s";
529 return "d3dbc";
531 return "dxbc";
533 return "glsl";
535 return "fx";
537 return "msl";
538 default:
539 FIXME("Unhandled target type %#x.\n", type);
540 return "bin";
541 }
542}
543
544static void fill_shader_dump_data(const struct vkd3d_shader_compile_info *compile_info,
545 struct shader_dump_data *data)
546{
547 static bool enabled = true;
548
549 data->path = NULL;
550
551 if (!enabled)
552 return;
553
554 if (!(data->path = getenv("VKD3D_SHADER_DUMP_PATH")))
555 {
556 enabled = false;
557 return;
558 }
559
560 data->profile = NULL;
561 if (compile_info->source_type == VKD3D_SHADER_SOURCE_HLSL)
562 {
563 const struct vkd3d_shader_hlsl_source_info *hlsl_source_info;
564
565 if ((hlsl_source_info = vkd3d_find_struct(compile_info->next, HLSL_SOURCE_INFO)))
566 data->profile = hlsl_source_info->profile;
567 }
568
569 vkd3d_compute_md5(compile_info->source.code, compile_info->source.size,
570 (uint32_t *)data->checksum, VKD3D_MD5_STANDARD);
571 data->source_suffix = shader_get_source_type_suffix(compile_info->source_type);
572 data->target_suffix = shader_get_target_type_suffix(compile_info->target_type);
573}
574
576{
577 struct vkd3d_shader_scan_signature_info *signature_info;
578
579 if ((signature_info = vkd3d_find_struct(info->next, SCAN_SIGNATURE_INFO)))
580 {
581 memset(&signature_info->input, 0, sizeof(signature_info->input));
582 memset(&signature_info->output, 0, sizeof(signature_info->output));
583 memset(&signature_info->patch_constant, 0, sizeof(signature_info->patch_constant));
584 }
585}
586
588{
589 {"force_validation", VKD3D_SHADER_CONFIG_FLAG_FORCE_VALIDATION}, /* force validation of internal shader representations */
590};
591
593{
594 uint64_t config_flags;
595 const char *config;
596
597 config = getenv("VKD3D_SHADER_CONFIG");
599
600 if (config_flags)
601 TRACE("VKD3D_SHADER_CONFIG='%s'.\n", config);
602
603 return config_flags;
604}
605
607 struct vkd3d_shader_message_context *message_context, const char *source_name)
608{
609 parser->message_context = message_context;
610 parser->location.source_name = source_name;
611 parser->location.line = 1;
612 parser->location.column = 0;
613 parser->program = program;
614}
615
618{
620
622 vkd3d_shader_verror(parser->message_context, &parser->location, error, format, args);
623 va_end(args);
624
625 parser->failed = true;
626}
627
630{
632
634 vkd3d_shader_vwarning(parser->message_context, &parser->location, error, format, args);
635 va_end(args);
636}
637
639 bool validate_target_type)
640{
641 const enum vkd3d_shader_source_type *source_types;
642 const enum vkd3d_shader_target_type *target_types;
643 unsigned int count, i;
644
646 {
647 WARN("Invalid structure type %#x.\n", compile_info->type);
649 }
650
652 for (i = 0; i < count; ++i)
653 {
654 if (source_types[i] == compile_info->source_type)
655 break;
656 }
657 if (i == count)
658 {
659 WARN("Invalid shader source type %#x.\n", compile_info->source_type);
661 }
662
663 if (validate_target_type)
664 {
665 target_types = vkd3d_shader_get_supported_target_types(compile_info->source_type, &count);
666 for (i = 0; i < count; ++i)
667 {
668 if (target_types[i] == compile_info->target_type)
669 break;
670 }
671 if (i == count)
672 {
673 WARN("Invalid shader target type %#x.\n", compile_info->target_type);
675 }
676 }
677
678 return VKD3D_OK;
679}
680
681static enum vkd3d_result vsir_parse(const struct vkd3d_shader_compile_info *compile_info, uint64_t config_flags,
682 struct vkd3d_shader_message_context *message_context, struct vsir_program *program)
683{
684 enum vkd3d_result ret;
685
686 switch (compile_info->source_type)
687 {
689 ret = d3dbc_parse(compile_info, config_flags, message_context, program);
690 break;
691
693 ret = tpf_parse(compile_info, config_flags, message_context, program);
694 break;
695
697 ret = dxil_parse(compile_info, config_flags, message_context, program);
698 break;
699
700 default:
701 ERR("Unsupported source type %#x.\n", compile_info->source_type);
703 break;
704 }
705
706 if (ret < 0)
707 {
708 WARN("Failed to parse shader.\n");
709 return ret;
710 }
711
712 if ((ret = vsir_program_validate(program, config_flags, compile_info->source_name, message_context)) < 0)
713 {
714 WARN("Failed to validate shader after parsing, ret %d.\n", ret);
715
716 if (TRACE_ON())
718
720 return ret;
721 }
722
723 if (compile_info->target_type != VKD3D_SHADER_TARGET_NONE)
724 ret = vsir_program_transform_early(program, config_flags, compile_info, message_context);
725 return ret;
726}
727
729{
730 TRACE("messages %p.\n", messages);
731
733}
734
736 const struct shader_signature *src)
737{
738 unsigned int i;
739
740 signature->element_count = src->element_count;
741 if (!src->elements)
742 {
743 VKD3D_ASSERT(!signature->element_count);
744 signature->elements = NULL;
745 return true;
746 }
747
748 if (!(signature->elements = vkd3d_calloc(signature->element_count, sizeof(*signature->elements))))
749 return false;
750
751 for (i = 0; i < signature->element_count; ++i)
752 {
753 struct vkd3d_shader_signature_element *d = &signature->elements[i];
754 struct signature_element *e = &src->elements[i];
755
756 if (!(d->semantic_name = vkd3d_strdup(e->semantic_name)))
757 {
758 for (unsigned int j = 0; j < i; ++j)
759 {
760 vkd3d_free((void *)signature->elements[j].semantic_name);
761 }
762 vkd3d_free(signature->elements);
763 return false;
764 }
765 d->semantic_index = e->semantic_index;
766 d->stream_index = e->stream_index;
767 d->sysval_semantic = e->sysval_semantic;
768 d->component_type = e->component_type;
769 d->register_index = e->register_index;
770 if (e->register_count > 1)
771 FIXME("Arrayed elements are not supported yet.\n");
772 d->mask = e->mask;
773 d->used_mask = e->used_mask;
774 d->min_precision = e->min_precision;
775 }
776
777 return true;
778}
779
781{
783
786
789
791 {
792 enum
793 {
803
805
808};
809
810static VKD3D_PRINTF_FUNC(3, 4) void vkd3d_shader_scan_error(struct vkd3d_shader_scan_context *context,
812{
814
816 vkd3d_shader_verror(context->message_context, &context->location, error, format, args);
817 va_end(args);
818}
819
820static void VKD3D_PRINTF_FUNC(3, 4) vkd3d_shader_scan_warning(struct vkd3d_shader_scan_context *context,
822{
824
826 vkd3d_shader_vwarning(context->message_context, &context->location, error, format, args);
827 va_end(args);
828}
829
831 const struct vkd3d_shader_version *version,
832 const struct vkd3d_shader_compile_info *compile_info,
833 struct vkd3d_shader_scan_descriptor_info1 *scan_descriptor_info,
834 struct vkd3d_shader_scan_combined_resource_sampler_info *combined_sampler_info,
835 struct vkd3d_shader_message_context *message_context)
836{
837 unsigned int i;
838
839 memset(context, 0, sizeof(*context));
840 context->version = version;
841 context->scan_descriptor_info = scan_descriptor_info;
842 context->message_context = message_context;
843 context->location.source_name = compile_info->source_name;
844 context->location.line = 2; /* Line 1 is the version token. */
846 context->combined_sampler_info = combined_sampler_info;
847
848 for (i = 0; i < compile_info->option_count; ++i)
849 {
850 const struct vkd3d_shader_compile_option *option = &compile_info->options[i];
851
853 context->api_version = option->value;
854 }
855}
856
858{
859 vkd3d_free(context->cf_info);
860}
861
863{
864 if (!context->cf_info_count)
865 return NULL;
866 return &context->cf_info[context->cf_info_count - 1];
867}
868
869static struct vkd3d_shader_cf_info *vkd3d_shader_scan_push_cf_info(struct vkd3d_shader_scan_context *context)
870{
871 struct vkd3d_shader_cf_info *cf_info;
872
873 if (!vkd3d_array_reserve((void **)&context->cf_info, &context->cf_info_size,
874 context->cf_info_count + 1, sizeof(*context->cf_info)))
875 {
876 ERR("Failed to allocate UAV range.\n");
877 return false;
878 }
879
880 cf_info = &context->cf_info[context->cf_info_count++];
881 memset(cf_info, 0, sizeof(*cf_info));
882
883 return cf_info;
884}
885
887{
888 VKD3D_ASSERT(context->cf_info_count);
889
890 --context->cf_info_count;
891}
892
893static struct vkd3d_shader_cf_info *vkd3d_shader_scan_find_innermost_breakable_cf_info(
895{
896 size_t count = context->cf_info_count;
897 struct vkd3d_shader_cf_info *cf_info;
898
899 while (count)
900 {
901 cf_info = &context->cf_info[--count];
902 if (cf_info->type == VKD3D_SHADER_BLOCK_LOOP
903 || cf_info->type == VKD3D_SHADER_BLOCK_SWITCH)
904 return cf_info;
905 }
906
907 return NULL;
908}
909
910static struct vkd3d_shader_cf_info *vkd3d_shader_scan_find_innermost_loop_cf_info(
912{
913 size_t count = context->cf_info_count;
914 struct vkd3d_shader_cf_info *cf_info;
915
916 while (count)
917 {
918 cf_info = &context->cf_info[--count];
919 if (cf_info->type == VKD3D_SHADER_BLOCK_LOOP)
920 return cf_info;
921 }
922
923 return NULL;
924}
925
927 const struct vkd3d_shader_register *reg, uint32_t flag)
928{
929 unsigned int range_id = reg->idx[0].offset;
930 unsigned int i;
931
932 if (!context->scan_descriptor_info)
933 return;
934
935 for (i = 0; i < context->scan_descriptor_info->descriptor_count; ++i)
936 {
937 if (context->scan_descriptor_info->descriptors[i].type == VKD3D_SHADER_DESCRIPTOR_TYPE_UAV
938 && context->scan_descriptor_info->descriptors[i].register_id == range_id)
939 {
940 context->scan_descriptor_info->descriptors[i].flags |= flag;
941 break;
942 }
943 }
944}
945
947{
949
950 return (VKD3DSIH_ATOMIC_AND <= opcode && opcode <= VKD3DSIH_ATOMIC_XOR)
951 || (VKD3DSIH_IMM_ATOMIC_ALLOC <= opcode && opcode <= VKD3DSIH_IMM_ATOMIC_XOR)
952 || opcode == VKD3DSIH_LD_UAV_TYPED
953 || (opcode == VKD3DSIH_LD_RAW && instruction->src[1].reg.type == VKD3DSPR_UAV)
954 || (opcode == VKD3DSIH_LD_STRUCTURED && instruction->src[2].reg.type == VKD3DSPR_UAV);
955}
956
958 const struct vkd3d_shader_register *reg)
959{
961}
962
964{
966
967 return opcode == VKD3DSIH_IMM_ATOMIC_ALLOC || opcode == VKD3DSIH_IMM_ATOMIC_CONSUME;
968}
969
971 const struct vkd3d_shader_register *reg)
972{
974}
975
977{
979
980 return (VKD3DSIH_ATOMIC_AND <= opcode && opcode <= VKD3DSIH_ATOMIC_XOR)
981 || (VKD3DSIH_IMM_ATOMIC_ALLOC <= opcode && opcode <= VKD3DSIH_IMM_ATOMIC_XOR);
982}
983
985 const struct vkd3d_shader_register *reg)
986{
988}
989
994{
995 struct vkd3d_shader_scan_descriptor_info1 *info = context->scan_descriptor_info;
997
998 if (!info)
999 return NULL;
1000
1001 if (!vkd3d_array_reserve((void **)&info->descriptors, &context->descriptors_size,
1002 info->descriptor_count + 1, sizeof(*info->descriptors)))
1003 {
1004 ERR("Failed to allocate descriptor info.\n");
1005 return NULL;
1006 }
1007
1008 d = &info->descriptors[info->descriptor_count];
1009 memset(d, 0, sizeof(*d));
1010 d->type = type;
1011 d->register_id = reg->idx[0].offset;
1012 d->register_space = range->space;
1013 d->register_index = range->first;
1014 d->resource_type = resource_type;
1015 d->resource_data_type = resource_data_type;
1016 d->count = (range->last == ~0u) ? ~0u : range->last - range->first + 1;
1017 ++info->descriptor_count;
1018
1019 return d;
1020}
1021
1024{
1025 const struct vkd3d_shader_constant_buffer *cb = &instruction->declaration.cb;
1027
1030 return;
1031 d->buffer_size = cb->size;
1032}
1033
1036{
1037 const struct vkd3d_shader_sampler *sampler = &instruction->declaration.sampler;
1039
1042 return;
1043
1046}
1047
1049 struct vkd3d_shader_scan_context *context, const struct vkd3d_shader_semantic *semantic)
1050{
1054 &semantic->resource.range, semantic->resource_type, VKD3D_SHADER_RESOURCE_DATA_FLOAT);
1055}
1056
1060{
1061 for (unsigned int i = 0; i < info->descriptor_count; ++i)
1062 {
1063 const struct vkd3d_shader_descriptor_info1 *d = &info->descriptors[i];
1064
1065 if (d->type == type && d->register_id == register_id)
1066 return d;
1067 }
1068
1069 return NULL;
1070}
1071
1073 const struct vkd3d_shader_register *resource, const struct vkd3d_shader_register *sampler)
1074{
1077 unsigned resource_space = 0, sampler_space = 0;
1078 unsigned int resource_idx, sampler_idx, i;
1079
1080 if (!(info = context->combined_sampler_info))
1081 return;
1082
1083 if (resource->type == VKD3DSPR_RESOURCE)
1084 resource_idx = resource->idx[1].offset;
1085 else
1086 resource_idx = resource->idx[0].offset;
1087
1088 if (!sampler)
1090 else if (sampler->type == VKD3DSPR_SAMPLER)
1091 sampler_idx = sampler->idx[1].offset;
1092 else
1093 sampler_idx = sampler->idx[0].offset;
1094
1095 if (vkd3d_shader_ver_ge(context->version, 5, 1))
1096 {
1097 const struct vkd3d_shader_descriptor_info1 *d;
1098 bool dynamic_resource, dynamic_sampler;
1099
1100 if ((dynamic_resource = resource->idx[1].rel_addr))
1102 "Resource descriptor array %u is being dynamically indexed, "
1103 "not recording a combined resource-sampler pair.", resource->idx[0].offset);
1104 if ((dynamic_sampler = sampler && sampler->idx[1].rel_addr))
1106 "Sampler descriptor array %u is being dynamically indexed, "
1107 "not recording a combined resource-sampler pair.", sampler->idx[0].offset);
1108 if (dynamic_resource || dynamic_sampler)
1109 return;
1110
1111 if ((d = find_descriptor(context->scan_descriptor_info,
1113 resource_space = d->register_space;
1114
1115 if (sampler && (d = find_descriptor(context->scan_descriptor_info,
1117 sampler_space = d->register_space;
1118 }
1119
1120 for (i = 0; i < info->combined_sampler_count; ++i)
1121 {
1122 s = &info->combined_samplers[i];
1123 if (s->resource_space == resource_space && s->resource_index == resource_idx
1124 && s->sampler_space == sampler_space && s->sampler_index == sampler_idx)
1125 return;
1126 }
1127
1128 if (!vkd3d_array_reserve((void **)&info->combined_samplers, &context->combined_samplers_size,
1129 info->combined_sampler_count + 1, sizeof(*info->combined_samplers)))
1130 {
1131 ERR("Failed to allocate combined sampler info.\n");
1132 return;
1133 }
1134
1135 s = &info->combined_samplers[info->combined_sampler_count++];
1136 s->resource_space = resource_space;
1137 s->resource_index = resource_idx;
1138 s->sampler_space = sampler_space;
1139 s->sampler_index = sampler_idx;
1140}
1141
1145 unsigned int sample_count, unsigned int structure_stride, bool raw, uint32_t flags)
1146{
1149
1150 if (resource->reg.reg.type == VKD3DSPR_UAV)
1152 else
1156 return;
1157 d->sample_count = sample_count;
1158 d->structure_stride = structure_stride;
1159 if (raw)
1162 d->uav_flags = flags;
1163}
1164
1167{
1168 const struct vkd3d_shader_semantic *semantic = &instruction->declaration.semantic;
1170
1171 if (semantic->resource_data_type[0] != semantic->resource_data_type[1] ||
1172 semantic->resource_data_type[0] != semantic->resource_data_type[2] ||
1173 semantic->resource_data_type[0] != semantic->resource_data_type[3])
1174 FIXME("Resource data types are different (%d, %d, %d, %d).\n",
1175 semantic->resource_data_type[0],
1176 semantic->resource_data_type[1],
1177 semantic->resource_data_type[2],
1178 semantic->resource_data_type[3]);
1179
1180 switch (semantic->resource_data_type[0])
1181 {
1182 case VKD3D_DATA_UNORM:
1184 break;
1185 case VKD3D_DATA_SNORM:
1187 break;
1188 case VKD3D_DATA_INT:
1190 break;
1191 case VKD3D_DATA_UINT:
1193 break;
1194 case VKD3D_DATA_FLOAT:
1196 break;
1197 case VKD3D_DATA_MIXED:
1199 break;
1200 case VKD3D_DATA_DOUBLE:
1202 break;
1205 break;
1206 default:
1207 ERR("Invalid resource data type %#x.\n", semantic->resource_data_type[0]);
1209 break;
1210 }
1211
1212 if (context->api_version < VKD3D_SHADER_API_VERSION_1_3
1214 {
1215 ERR("Invalid resource data type %#x for API version %#x.\n",
1216 semantic->resource_data_type[0], context->api_version);
1218 }
1219
1221 semantic->resource_type, resource_data_type, semantic->sample_count, 0, false, instruction->flags);
1222}
1223
1226{
1227 const struct vkd3d_shader_register *sampler_reg;
1228 struct vkd3d_shader_cf_info *cf_info;
1229 unsigned int i;
1230
1231 context->location = instruction->location;
1232
1233 switch (instruction->opcode)
1234 {
1237 break;
1240 break;
1241 case VKD3DSIH_DCL:
1242 if (instruction->declaration.semantic.resource_type == VKD3D_SHADER_RESOURCE_NONE)
1243 break;
1244
1245 if (instruction->declaration.semantic.resource.reg.reg.type == VKD3DSPR_COMBINED_SAMPLER)
1246 {
1248 break;
1249 }
1250 /* fall through */
1253 break;
1256 vkd3d_shader_scan_resource_declaration(context, &instruction->declaration.raw_resource.resource,
1258 break;
1261 vkd3d_shader_scan_resource_declaration(context, &instruction->declaration.structured_resource.resource,
1263 instruction->declaration.structured_resource.byte_stride, false, instruction->flags);
1264 break;
1265 case VKD3DSIH_IF:
1266 case VKD3DSIH_IFC:
1268 cf_info->type = VKD3D_SHADER_BLOCK_IF;
1269 cf_info->inside_block = true;
1270 break;
1271 case VKD3DSIH_ELSE:
1272 if (!(cf_info = vkd3d_shader_scan_get_current_cf_info(context)) || cf_info->type != VKD3D_SHADER_BLOCK_IF)
1273 {
1274 vkd3d_shader_scan_error(context, VKD3D_SHADER_ERROR_TPF_MISMATCHED_CF,
1275 "Encountered ‘else’ instruction without corresponding ‘if’ block.");
1277 }
1278 cf_info->inside_block = true;
1279 break;
1280 case VKD3DSIH_ENDIF:
1281 if (!(cf_info = vkd3d_shader_scan_get_current_cf_info(context)) || cf_info->type != VKD3D_SHADER_BLOCK_IF)
1282 {
1283 vkd3d_shader_scan_error(context, VKD3D_SHADER_ERROR_TPF_MISMATCHED_CF,
1284 "Encountered ‘endif’ instruction without corresponding ‘if’ block.");
1286 }
1288 break;
1289 case VKD3DSIH_LOOP:
1291 cf_info->type = VKD3D_SHADER_BLOCK_LOOP;
1292 cf_info->inside_block = true;
1293 break;
1294 case VKD3DSIH_ENDLOOP:
1295 if (!(cf_info = vkd3d_shader_scan_get_current_cf_info(context)) || cf_info->type != VKD3D_SHADER_BLOCK_LOOP)
1296 {
1297 vkd3d_shader_scan_error(context, VKD3D_SHADER_ERROR_TPF_MISMATCHED_CF,
1298 "Encountered ‘endloop’ instruction without corresponding ‘loop’ block.");
1300 }
1302 break;
1303 case VKD3DSIH_SWITCH:
1305 cf_info->type = VKD3D_SHADER_BLOCK_SWITCH;
1306 break;
1307 case VKD3DSIH_ENDSWITCH:
1309 || cf_info->type != VKD3D_SHADER_BLOCK_SWITCH || cf_info->inside_block)
1310 {
1311 vkd3d_shader_scan_error(context, VKD3D_SHADER_ERROR_TPF_MISMATCHED_CF,
1312 "Encountered ‘endswitch’ instruction without corresponding ‘switch’ block.");
1314 }
1316 break;
1317 case VKD3DSIH_CASE:
1319 || cf_info->type != VKD3D_SHADER_BLOCK_SWITCH)
1320 {
1321 vkd3d_shader_scan_error(context, VKD3D_SHADER_ERROR_TPF_MISMATCHED_CF,
1322 "Encountered ‘case’ instruction outside switch block.");
1324 }
1325 cf_info->inside_block = true;
1326 break;
1327 case VKD3DSIH_DEFAULT:
1329 || cf_info->type != VKD3D_SHADER_BLOCK_SWITCH)
1330 {
1331 vkd3d_shader_scan_error(context, VKD3D_SHADER_ERROR_TPF_MISMATCHED_CF,
1332 "Encountered ‘default’ instruction outside switch block.");
1334 }
1335 if (cf_info->has_default)
1336 {
1337 vkd3d_shader_scan_error(context, VKD3D_SHADER_ERROR_TPF_MISMATCHED_CF,
1338 "Encountered duplicate ‘default’ instruction inside the current switch block.");
1340 }
1341 cf_info->inside_block = true;
1342 cf_info->has_default = true;
1343 break;
1344 case VKD3DSIH_BREAK:
1346 {
1347 vkd3d_shader_scan_error(context, VKD3D_SHADER_ERROR_TPF_MISMATCHED_CF,
1348 "Encountered ‘break’ instruction outside breakable block.");
1350 }
1351 cf_info->inside_block = false;
1352 break;
1353 case VKD3DSIH_BREAKP:
1355 {
1356 vkd3d_shader_scan_error(context, VKD3D_SHADER_ERROR_TPF_MISMATCHED_CF,
1357 "Encountered ‘breakp’ instruction outside loop.");
1359 }
1360 break;
1361 case VKD3DSIH_CONTINUE:
1363 {
1364 vkd3d_shader_scan_error(context, VKD3D_SHADER_ERROR_TPF_MISMATCHED_CF,
1365 "Encountered ‘continue’ instruction outside loop.");
1367 }
1368 cf_info->inside_block = false;
1369 break;
1370 case VKD3DSIH_CONTINUEP:
1372 {
1373 vkd3d_shader_scan_error(context, VKD3D_SHADER_ERROR_TPF_MISMATCHED_CF,
1374 "Encountered ‘continue’ instruction outside loop.");
1376 }
1377 break;
1378 case VKD3DSIH_RET:
1379 if (context->cf_info_count)
1380 context->cf_info[context->cf_info_count - 1].inside_block = false;
1381 break;
1382 case VKD3DSIH_TEX:
1383 if (context->version->major == 1)
1384 sampler_reg = &instruction->dst[0].reg;
1385 else
1386 sampler_reg = &instruction->src[1].reg;
1387 vkd3d_shader_scan_combined_sampler_usage(context, sampler_reg, sampler_reg);
1388 break;
1389 case VKD3DSIH_TEXBEM:
1390 case VKD3DSIH_TEXBEML:
1391 case VKD3DSIH_TEXDP3TEX:
1396 case VKD3DSIH_TEXREG2AR:
1397 case VKD3DSIH_TEXREG2GB:
1399 sampler_reg = &instruction->dst[0].reg;
1400 vkd3d_shader_scan_combined_sampler_usage(context, sampler_reg, sampler_reg);
1401 break;
1402 case VKD3DSIH_GATHER4:
1403 case VKD3DSIH_GATHER4_C:
1404 case VKD3DSIH_SAMPLE:
1405 case VKD3DSIH_SAMPLE_B:
1406 case VKD3DSIH_SAMPLE_C:
1411 break;
1415 break;
1416 case VKD3DSIH_LD:
1417 case VKD3DSIH_LD2DMS:
1419 break;
1420 case VKD3DSIH_BUFINFO:
1422 if (instruction->src[0].reg.type == VKD3DSPR_RESOURCE)
1424 break;
1425 case VKD3DSIH_LD_RAW:
1426 case VKD3DSIH_RESINFO:
1427 if (instruction->src[1].reg.type == VKD3DSPR_RESOURCE)
1429 break;
1431 if (instruction->src[2].reg.type == VKD3DSPR_RESOURCE)
1433 break;
1434 default:
1435 break;
1436 }
1437
1439 {
1440 for (i = 0; i < instruction->dst_count; ++i)
1441 {
1442 if (instruction->dst[i].reg.type == VKD3DSPR_UAV)
1444 }
1445 for (i = 0; i < instruction->src_count; ++i)
1446 {
1447 if (instruction->src[i].reg.type == VKD3DSPR_UAV)
1449 }
1450 }
1451
1454
1456 {
1457 for (i = 0; i < instruction->dst_count; ++i)
1458 {
1459 if (instruction->dst[i].reg.type == VKD3DSPR_UAV)
1461 }
1462 }
1463
1464 return VKD3D_OK;
1465}
1466
1468 const struct vkd3d_shader_scan_descriptor_info1 *info1)
1469{
1470 unsigned int i;
1471
1472 if (!(info->descriptors = vkd3d_calloc(info1->descriptor_count, sizeof(*info->descriptors))))
1474
1475 for (i = 0; i < info1->descriptor_count; ++i)
1476 {
1477 const struct vkd3d_shader_descriptor_info1 *src = &info1->descriptors[i];
1478 struct vkd3d_shader_descriptor_info *dst = &info->descriptors[i];
1479
1480 dst->type = src->type;
1481 dst->register_space = src->register_space;
1482 dst->register_index = src->register_index;
1483 dst->resource_type = src->resource_type;
1484 dst->resource_data_type = src->resource_data_type;
1485 dst->flags = src->flags;
1486 dst->count = src->count;
1487 }
1488 info->descriptor_count = info1->descriptor_count;
1489
1490 return VKD3D_OK;
1491}
1492
1494{
1495 TRACE("scan_descriptor_info %p.\n", scan_descriptor_info);
1496
1497 vkd3d_free(scan_descriptor_info->descriptors);
1498}
1499
1500static int vsir_program_scan(struct vsir_program *program, const struct vkd3d_shader_compile_info *compile_info,
1501 struct vkd3d_shader_message_context *message_context,
1502 struct vkd3d_shader_scan_descriptor_info1 *descriptor_info1)
1503{
1504 struct vkd3d_shader_scan_combined_resource_sampler_info *combined_sampler_info;
1505 struct vkd3d_shader_scan_descriptor_info1 local_descriptor_info1 = {0};
1506 struct vkd3d_shader_scan_descriptor_info *descriptor_info;
1507 struct vkd3d_shader_scan_signature_info *signature_info;
1510 int ret = VKD3D_OK;
1511 unsigned int i;
1512
1513 descriptor_info = vkd3d_find_struct(compile_info->next, SCAN_DESCRIPTOR_INFO);
1514 if (descriptor_info1)
1515 {
1516 descriptor_info1->descriptors = NULL;
1517 descriptor_info1->descriptor_count = 0;
1518 }
1519 else if (descriptor_info)
1520 {
1521 descriptor_info1 = &local_descriptor_info1;
1522 }
1523 signature_info = vkd3d_find_struct(compile_info->next, SCAN_SIGNATURE_INFO);
1524
1525 if ((combined_sampler_info = vkd3d_find_struct(compile_info->next, SCAN_COMBINED_RESOURCE_SAMPLER_INFO)))
1526 {
1527 combined_sampler_info->combined_samplers = NULL;
1528 combined_sampler_info->combined_sampler_count = 0;
1529 if (!descriptor_info1)
1530 descriptor_info1 = &local_descriptor_info1;
1531 }
1532
1533 vkd3d_shader_scan_context_init(&context, &program->shader_version, compile_info,
1534 descriptor_info1, combined_sampler_info, message_context);
1535
1536 if (TRACE_ON())
1538
1539 for (i = 0; i < program->instructions.count; ++i)
1540 {
1541 instruction = &program->instructions.elements[i];
1543 break;
1544 }
1545
1546 for (i = 0; i < ARRAY_SIZE(program->flat_constant_count); ++i)
1547 {
1548 struct vkd3d_shader_register_range range = {.space = 0, .first = i, .last = i};
1549 struct vkd3d_shader_register reg = {.idx[0].offset = i, .idx_count = 1};
1550 unsigned int size = program->flat_constant_count[i];
1552
1553 if (size)
1554 {
1557 d->buffer_size = size * 16;
1558 }
1559 }
1560
1561 if (!ret && signature_info)
1562 {
1563 if (!vkd3d_shader_signature_from_shader_signature(&signature_info->input, &program->input_signature)
1565 &program->output_signature)
1567 &program->patch_constant_signature))
1568 {
1570 }
1571 }
1572
1573 if (!ret && descriptor_info)
1574 ret = convert_descriptor_info(descriptor_info, descriptor_info1);
1575
1576 if (ret < 0)
1577 {
1578 if (combined_sampler_info)
1580 if (descriptor_info)
1582 if (descriptor_info1)
1584 if (signature_info)
1586 }
1587 else
1588 {
1589 vkd3d_shader_free_scan_descriptor_info1(&local_descriptor_info1);
1590 }
1592 return ret;
1593}
1594
1595int vkd3d_shader_scan(const struct vkd3d_shader_compile_info *compile_info, char **messages)
1596{
1597 struct vkd3d_shader_message_context message_context;
1598 struct shader_dump_data dump_data;
1599 int ret;
1600
1601 TRACE("compile_info %p, messages %p.\n", compile_info, messages);
1602
1603 if (messages)
1604 *messages = NULL;
1605
1606 if ((ret = vkd3d_shader_validate_compile_info(compile_info, false)) < 0)
1607 return ret;
1608
1609 init_scan_signature_info(compile_info);
1610
1611 vkd3d_shader_message_context_init(&message_context, compile_info->log_level);
1612
1613 fill_shader_dump_data(compile_info, &dump_data);
1614 vkd3d_shader_dump_shader(&dump_data, compile_info->source.code, compile_info->source.size, true);
1615
1616 if (compile_info->source_type == VKD3D_SHADER_SOURCE_HLSL)
1617 {
1618 FIXME("HLSL support not implemented.\n");
1620 }
1621 else
1622 {
1624 struct vsir_program program;
1625
1626 if (!(ret = vsir_parse(compile_info, config_flags, &message_context, &program)))
1627 {
1628 ret = vsir_program_scan(&program, compile_info, &message_context, NULL);
1630 }
1631 }
1632
1636 vkd3d_shader_message_context_cleanup(&message_context);
1637 return ret;
1638}
1639
1641 const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out,
1642 struct vkd3d_shader_message_context *message_context)
1643{
1644 struct vkd3d_shader_scan_combined_resource_sampler_info combined_sampler_info;
1645 struct vkd3d_shader_scan_descriptor_info1 scan_descriptor_info;
1646 struct vkd3d_shader_compile_info scan_info;
1647 int ret;
1648
1649 scan_info = *compile_info;
1650
1651 switch (compile_info->target_type)
1652 {
1655 break;
1656
1659 combined_sampler_info.next = scan_info.next;
1660 scan_info.next = &combined_sampler_info;
1661 if ((ret = vsir_program_scan(program, &scan_info, message_context, &scan_descriptor_info)) < 0)
1662 return ret;
1663 ret = glsl_compile(program, config_flags, &scan_descriptor_info,
1664 &combined_sampler_info, compile_info, out, message_context);
1666 vkd3d_shader_free_scan_descriptor_info1(&scan_descriptor_info);
1667 break;
1668
1671 if ((ret = vsir_program_scan(program, &scan_info, message_context, &scan_descriptor_info)) < 0)
1672 return ret;
1673 ret = spirv_compile(program, config_flags, &scan_descriptor_info,
1674 compile_info, out, message_context);
1675 vkd3d_shader_free_scan_descriptor_info1(&scan_descriptor_info);
1676 break;
1677
1679 if ((ret = vsir_program_scan(program, &scan_info, message_context, &scan_descriptor_info)) < 0)
1680 return ret;
1681 ret = msl_compile(program, config_flags, &scan_descriptor_info, compile_info, out, message_context);
1682 vkd3d_shader_free_scan_descriptor_info1(&scan_descriptor_info);
1683 break;
1684
1685 default:
1686 /* Validation should prevent us from reaching this. */
1688 }
1689
1690 return ret;
1691}
1692
1693static int compile_hlsl(const struct vkd3d_shader_compile_info *compile_info,
1694 struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
1695{
1696 struct vkd3d_shader_code preprocessed;
1697 int ret;
1698
1699 if ((ret = preproc_lexer_parse(compile_info, &preprocessed, message_context)))
1700 return ret;
1701
1702 ret = hlsl_compile_shader(&preprocessed, compile_info, out, message_context);
1703
1704 vkd3d_shader_free_shader_code(&preprocessed);
1705 return ret;
1706}
1707
1709 struct vkd3d_shader_code *out, char **messages)
1710{
1711 struct vkd3d_shader_message_context message_context;
1712 struct shader_dump_data dump_data;
1713 int ret;
1714
1715 TRACE("compile_info %p, out %p, messages %p.\n", compile_info, out, messages);
1716
1717 if (messages)
1718 *messages = NULL;
1719
1720 if ((ret = vkd3d_shader_validate_compile_info(compile_info, true)) < 0)
1721 return ret;
1722
1723 init_scan_signature_info(compile_info);
1724
1725 vkd3d_shader_message_context_init(&message_context, compile_info->log_level);
1726
1727 fill_shader_dump_data(compile_info, &dump_data);
1728 vkd3d_shader_dump_shader(&dump_data, compile_info->source.code, compile_info->source.size, true);
1729
1730 if (compile_info->source_type == VKD3D_SHADER_SOURCE_HLSL)
1731 {
1732 ret = compile_hlsl(compile_info, out, &message_context);
1733 }
1734 else if (compile_info->source_type == VKD3D_SHADER_SOURCE_FX)
1735 {
1736 ret = fx_parse(compile_info, out, &message_context);
1737 }
1738 else
1739 {
1741 struct vsir_program program;
1742
1743 if (!(ret = vsir_parse(compile_info, config_flags, &message_context, &program)))
1744 {
1745 ret = vsir_program_compile(&program, config_flags, compile_info, out, &message_context);
1747 }
1748 }
1749
1750 if (ret >= 0)
1751 vkd3d_shader_dump_shader(&dump_data, out->code, out->size, false);
1752
1756 vkd3d_shader_message_context_cleanup(&message_context);
1757 return ret;
1758}
1759
1762{
1763 TRACE("info %p.\n", info);
1764
1765 vkd3d_free(info->combined_samplers);
1766}
1767
1769{
1770 TRACE("scan_descriptor_info %p.\n", scan_descriptor_info);
1771
1772 vkd3d_free(scan_descriptor_info->descriptors);
1773}
1774
1776{
1777 TRACE("info %p.\n", info);
1778
1781 vkd3d_shader_free_shader_signature(&info->patch_constant);
1782}
1783
1785{
1786 TRACE("shader_code %p.\n", shader_code);
1787
1788 vkd3d_free((void *)shader_code->code);
1789}
1790
1792{
1793 unsigned int i;
1794
1795 for (i = 0; i < root_signature->parameter_count; ++i)
1796 {
1797 const struct vkd3d_shader_root_parameter *parameter = &root_signature->parameters[i];
1798
1800 vkd3d_free((void *)parameter->u.descriptor_table.descriptor_ranges);
1801 }
1802 vkd3d_free((void *)root_signature->parameters);
1803 vkd3d_free((void *)root_signature->static_samplers);
1804
1805 memset(root_signature, 0, sizeof(*root_signature));
1806}
1807
1809{
1810 unsigned int i;
1811
1812 for (i = 0; i < root_signature->parameter_count; ++i)
1813 {
1814 const struct vkd3d_shader_root_parameter1 *parameter = &root_signature->parameters[i];
1815
1817 vkd3d_free((void *)parameter->u.descriptor_table.descriptor_ranges);
1818 }
1819 vkd3d_free((void *)root_signature->parameters);
1820 vkd3d_free((void *)root_signature->static_samplers);
1821
1822 memset(root_signature, 0, sizeof(*root_signature));
1823}
1824
1826{
1827 TRACE("desc %p.\n", desc);
1828
1830 {
1832 }
1833 else if (desc->version == VKD3D_SHADER_ROOT_SIGNATURE_VERSION_1_1)
1834 {
1836 }
1837 else if (desc->version)
1838 {
1839 FIXME("Unknown version %#x.\n", desc->version);
1840 return;
1841 }
1842
1843 desc->version = 0;
1844}
1845
1847{
1848 for (unsigned int i = 0; i < signature->element_count; ++i)
1849 {
1850 vkd3d_free((void *)signature->elements[i].semantic_name);
1851 }
1852 vkd3d_free(signature->elements);
1853 signature->elements = NULL;
1854 signature->elements_capacity = 0;
1855 signature->element_count = 0;
1856}
1857
1860{
1861 struct vkd3d_shader_message_context message_context;
1863 int ret;
1864
1865 TRACE("dxbc {%p, %zu}, signature %p, messages %p.\n", dxbc->code, dxbc->size, signature, messages);
1866
1867 if (messages)
1868 *messages = NULL;
1870
1871 ret = shader_parse_input_signature(dxbc, &message_context, &shader_signature);
1875
1876 vkd3d_shader_message_context_cleanup(&message_context);
1877
1880
1882 return ret;
1883}
1884
1886 const struct vkd3d_shader_signature *signature, const char *semantic_name,
1887 unsigned int semantic_index, unsigned int stream_index)
1888{
1890 unsigned int i;
1891
1892 TRACE("signature %p, semantic_name %s, semantic_index %u, stream_index %u.\n",
1894
1895 e = signature->elements;
1896 for (i = 0; i < signature->element_count; ++i)
1897 {
1901 return &e[i];
1902 }
1903
1904 return NULL;
1905}
1906
1908{
1909 TRACE("signature %p.\n", signature);
1910
1911 for (unsigned int i = 0; i < signature->element_count; ++i)
1912 {
1913 vkd3d_free((void *)signature->elements[i].semantic_name);
1914 }
1915 vkd3d_free(signature->elements);
1916 signature->elements = NULL;
1917}
1918
1919const char *vkd3d_shader_get_version(unsigned int *major, unsigned int *minor)
1920{
1921 int x, y;
1922
1923 TRACE("major %p, minor %p.\n", major, minor);
1924
1925 if (major || minor)
1926 {
1928 if (major)
1929 *major = x;
1930 if (minor)
1931 *minor = y;
1932 }
1933
1934 return "vkd3d-shader " PACKAGE_VERSION VKD3D_VCS_ID;
1935}
1936
1938{
1939 static const enum vkd3d_shader_source_type types[] =
1940 {
1944#ifdef VKD3D_SHADER_UNSUPPORTED_DXIL
1946#endif
1948 };
1949
1950 TRACE("count %p.\n", count);
1951
1953 return types;
1954}
1955
1957 enum vkd3d_shader_source_type source_type, unsigned int *count)
1958{
1959 static const enum vkd3d_shader_target_type dxbc_tpf_types[] =
1960 {
1962#ifdef HAVE_SPIRV_TOOLS
1964#endif
1966#ifdef VKD3D_SHADER_UNSUPPORTED_GLSL
1968#endif
1969#ifdef VKD3D_SHADER_UNSUPPORTED_MSL
1971#endif
1972 };
1973
1974 static const enum vkd3d_shader_target_type hlsl_types[] =
1975 {
1977#ifdef HAVE_SPIRV_TOOLS
1979#endif
1984 };
1985
1986 static const enum vkd3d_shader_target_type d3dbc_types[] =
1987 {
1989#ifdef HAVE_SPIRV_TOOLS
1991#endif
1993 };
1994
1995#ifdef VKD3D_SHADER_UNSUPPORTED_DXIL
1996 static const enum vkd3d_shader_target_type dxbc_dxil_types[] =
1997 {
1999# ifdef HAVE_SPIRV_TOOLS
2001# endif
2003 };
2004#endif
2005
2006 static const enum vkd3d_shader_target_type fx_types[] =
2007 {
2009 };
2010
2011 TRACE("source_type %#x, count %p.\n", source_type, count);
2012
2013 switch (source_type)
2014 {
2016 *count = ARRAY_SIZE(dxbc_tpf_types);
2017 return dxbc_tpf_types;
2018
2020 *count = ARRAY_SIZE(hlsl_types);
2021 return hlsl_types;
2022
2024 *count = ARRAY_SIZE(d3dbc_types);
2025 return d3dbc_types;
2026
2027#ifdef VKD3D_SHADER_UNSUPPORTED_DXIL
2029 *count = ARRAY_SIZE(dxbc_dxil_types);
2030 return dxbc_dxil_types;
2031#endif
2032
2034 *count = ARRAY_SIZE(fx_types);
2035 return fx_types;
2036
2037 default:
2038 *count = 0;
2039 return NULL;
2040 }
2041}
2042
2044 struct vkd3d_shader_code *out, char **messages)
2045{
2046 struct vkd3d_shader_message_context message_context;
2047 int ret;
2048
2049 TRACE("compile_info %p, out %p, messages %p.\n", compile_info, out, messages);
2050
2051 if (messages)
2052 *messages = NULL;
2053
2054 if ((ret = vkd3d_shader_validate_compile_info(compile_info, false)) < 0)
2055 return ret;
2056
2057 vkd3d_shader_message_context_init(&message_context, compile_info->log_level);
2058
2059 ret = preproc_lexer_parse(compile_info, out, &message_context);
2060
2064 vkd3d_shader_message_context_cleanup(&message_context);
2065 return ret;
2066}
2067
2069{
2071}
2072
2075{
2077
2078 if (!(node = vkd3d_malloc(offsetof(struct vkd3d_shader_param_node, param[allocator->count * allocator->stride]))))
2079 return NULL;
2080 node->next = NULL;
2081 return node;
2082}
2083
2085 unsigned int count, unsigned int stride)
2086{
2087 allocator->count = max(count, MAX_REG_OUTPUT);
2088 allocator->stride = stride;
2089 allocator->head = NULL;
2090 allocator->current = NULL;
2091 allocator->index = allocator->count;
2092}
2093
2095{
2097
2098 while (current)
2099 {
2100 struct vkd3d_shader_param_node *next = current->next;
2102 current = next;
2103 }
2104}
2105
2107{
2108 void *params;
2109
2110 if (!allocator->current || count > allocator->count - allocator->index)
2111 {
2113
2114 /* Monolithic switch has no definite parameter count limit. */
2115 allocator->count = max(allocator->count, count);
2116
2118 return NULL;
2119 if (allocator->current)
2120 allocator->current->next = next;
2121 else
2122 allocator->head = next;
2123 allocator->current = next;
2124 allocator->index = 0;
2125 }
2126
2127 params = &allocator->current->param[allocator->index * allocator->stride];
2128 allocator->index += count;
2129 return params;
2130}
2131
2133{
2134 memset(instructions, 0, sizeof(*instructions));
2135 /* Size the parameter initial allocations so they are large enough for most shaders. The
2136 * code path for chained allocations will be tested if a few shaders need to use it. */
2138 sizeof(*instructions->elements->dst));
2139 shader_param_allocator_init(&instructions->src_params, reserve * 2u, sizeof(*instructions->elements->src));
2140 return shader_instruction_array_reserve(instructions, reserve);
2141}
2142
2144{
2145 if (!vkd3d_array_reserve((void **)&instructions->elements, &instructions->capacity, reserve,
2146 sizeof(*instructions->elements)))
2147 {
2148 ERR("Failed to allocate instructions.\n");
2149 return false;
2150 }
2151 return true;
2152}
2153
2155 unsigned int idx, unsigned int count)
2156{
2157 VKD3D_ASSERT(idx <= instructions->count);
2158
2159 if (!shader_instruction_array_reserve(instructions, instructions->count + count))
2160 return false;
2161
2162 memmove(&instructions->elements[idx + count], &instructions->elements[idx],
2163 (instructions->count - idx) * sizeof(*instructions->elements));
2164 memset(&instructions->elements[idx], 0, count * sizeof(*instructions->elements));
2165
2166 instructions->count += count;
2167
2168 return true;
2169}
2170
2173{
2174 if (!vkd3d_array_reserve((void **)&instructions->icbs, &instructions->icb_capacity, instructions->icb_count + 1,
2175 sizeof(*instructions->icbs)))
2176 return false;
2177 instructions->icbs[instructions->icb_count++] = icb;
2178 return true;
2179}
2180
2182 struct vkd3d_shader_instruction_array *instructions, const struct vkd3d_shader_src_param *params,
2183 unsigned int count);
2184
2186 struct vkd3d_shader_instruction_array *instructions)
2187{
2188 unsigned int i;
2189
2190 for (i = 0; i < reg->idx_count; ++i)
2191 {
2192 if (!reg->idx[i].rel_addr)
2193 continue;
2194
2195 if (!(reg->idx[i].rel_addr = shader_instruction_array_clone_src_params(instructions, reg->idx[i].rel_addr, 1)))
2196 return false;
2197 }
2198
2199 return true;
2200}
2201
2203 struct vkd3d_shader_instruction_array *instructions, const struct vkd3d_shader_dst_param *params,
2204 unsigned int count)
2205{
2206 struct vkd3d_shader_dst_param *dst_params;
2207 unsigned int i;
2208
2209 if (!(dst_params = shader_dst_param_allocator_get(&instructions->dst_params, count)))
2210 return NULL;
2211
2212 memcpy(dst_params, params, count * sizeof(*params));
2213 for (i = 0; i < count; ++i)
2214 {
2215 if (!shader_register_clone_relative_addresses(&dst_params[i].reg, instructions))
2216 return NULL;
2217 }
2218
2219 return dst_params;
2220}
2221
2223 struct vkd3d_shader_instruction_array *instructions, const struct vkd3d_shader_src_param *params,
2224 unsigned int count)
2225{
2226 struct vkd3d_shader_src_param *src_params;
2227 unsigned int i;
2228
2229 if (!(src_params = shader_src_param_allocator_get(&instructions->src_params, count)))
2230 return NULL;
2231
2232 memcpy(src_params, params, count * sizeof(*params));
2233 for (i = 0; i < count; ++i)
2234 {
2235 if (!shader_register_clone_relative_addresses(&src_params[i].reg, instructions))
2236 return NULL;
2237 }
2238
2239 return src_params;
2240}
2241
2242/* NOTE: Immediate constant buffers are not cloned, so the source must not be destroyed while the
2243 * destination is in use. This seems like a reasonable requirement given how this is currently used. */
2245 unsigned int dst, unsigned int src)
2246{
2247 struct vkd3d_shader_instruction *ins = &instructions->elements[dst];
2248
2249 *ins = instructions->elements[src];
2250
2251 if (ins->dst_count && ins->dst && !(ins->dst = shader_instruction_array_clone_dst_params(instructions,
2252 ins->dst, ins->dst_count)))
2253 return false;
2254
2255 return !ins->src_count || !!(ins->src = shader_instruction_array_clone_src_params(instructions,
2256 ins->src, ins->src_count));
2257}
2258
2260{
2261 unsigned int i;
2262
2263 vkd3d_free(instructions->elements);
2266 for (i = 0; i < instructions->icb_count; ++i)
2267 vkd3d_free(instructions->icbs[i]);
2268 vkd3d_free(instructions->icbs);
2269}
2270
2271void vkd3d_shader_build_varying_map(const struct vkd3d_shader_signature *output_signature,
2272 const struct vkd3d_shader_signature *input_signature,
2273 unsigned int *ret_count, struct vkd3d_shader_varying_map *varyings)
2274{
2275 unsigned int count = 0;
2276 unsigned int i;
2277
2278 TRACE("output_signature %p, input_signature %p, ret_count %p, varyings %p.\n",
2279 output_signature, input_signature, ret_count, varyings);
2280
2281 for (i = 0; i < input_signature->element_count; ++i)
2282 {
2283 const struct vkd3d_shader_signature_element *input_element, *output_element;
2284
2285 input_element = &input_signature->elements[i];
2286
2287 if (input_element->sysval_semantic != VKD3D_SHADER_SV_NONE)
2288 continue;
2289
2290 varyings[count].input_register_index = input_element->register_index;
2291 varyings[count].input_mask = input_element->mask;
2292
2293 if ((output_element = vkd3d_shader_find_signature_element(output_signature,
2294 input_element->semantic_name, input_element->semantic_index, 0)))
2295 {
2296 varyings[count].output_signature_index = output_element - output_signature->elements;
2297 }
2298 else
2299 {
2300 varyings[count].output_signature_index = output_signature->element_count;
2301 }
2302
2303 ++count;
2304 }
2305
2306 *ret_count = count;
2307}
#define vsnprintf
Definition: acwin.h:108
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#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
void vsir_program_trace(const struct vsir_program *program)
Definition: d3d_asm.c:2550
enum vkd3d_result d3d_asm_compile(const struct vsir_program *program, const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, enum vsir_asm_flags flags)
Definition: d3d_asm.c:2370
int d3dbc_parse(const struct vkd3d_shader_compile_info *compile_info, uint64_t config_flags, struct vkd3d_shader_message_context *message_context, struct vsir_program *program)
Definition: d3dbc.c:1349
range
Definition: d3dx9_private.h:58
struct config_s config
#define NULL
Definition: types.h:112
UINT32 uint32_t
Definition: types.h:75
UINT64 uint64_t
Definition: types.h:77
static BOOL reserve(struct dynamic_array *array, int count, int itemsize)
Definition: mesh.c:5499
unsigned int idx
Definition: utils.c:40
static cab_ULONG checksum(const cab_UBYTE *data, cab_UWORD bytes, cab_ULONG csum)
Definition: fdi.c:353
#define TRACE_ON(x)
Definition: compat.h:75
static const WCHAR version[]
Definition: asmname.c:66
static MonoProfilerRuntimeShutdownBeginCallback cb
Definition: metahost.c:118
const WCHAR * text
Definition: package.c:1826
char *CDECL getenv(const char *name)
Definition: environ.c:227
int CDECL fclose(FILE *file)
Definition: file.c:3757
FILE *CDECL fopen(const char *path, const char *mode)
Definition: file.c:4310
size_t CDECL fwrite(const void *ptr, size_t size, size_t nmemb, FILE *file)
Definition: file.c:4129
#define isfinite(x)
Definition: math.h:363
#define signbit(x)
Definition: math.h:362
#define va_copy(d, s)
Definition: stdarg.h:29
#define va_end(v)
Definition: stdarg.h:28
#define va_start(v, l)
Definition: stdarg.h:26
unsigned char uint8_t
Definition: stdint.h:33
char * va_list
Definition: vadefs.h:50
return ret
Definition: mutex.c:147
int shader_parse_input_signature(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_message_context *message_context, struct shader_signature *signature)
Definition: dxbc.c:493
int dxil_parse(const struct vkd3d_shader_compile_info *compile_info, uint64_t config_flags, struct vkd3d_shader_message_context *message_context, struct vsir_program *program)
Definition: dxil.c:10606
int fx_parse(const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
Definition: fx.c:3789
GLint level
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
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
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glext.h:7750
GLsizei stride
Definition: glext.h:5848
GLsizei const GLchar *const * varyings
Definition: glext.h:6214
GLenum src
Definition: glext.h:6340
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
const GLubyte * c
Definition: glext.h:8905
GLuint sampler
Definition: glext.h:7283
GLuint program
Definition: glext.h:6723
GLfloat f
Definition: glext.h:7540
GLenum const GLfloat * params
Definition: glext.h:5645
GLenum GLenum dst
Definition: glext.h:6340
GLbitfield flags
Definition: glext.h:7161
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLfloat GLfloat p
Definition: glext.h:8902
GLfloat param
Definition: glext.h:5796
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
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 flag
Definition: glfuncs.h:52
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 * u
Definition: glfuncs.h:240
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
int glsl_compile(struct vsir_program *program, uint64_t config_flags, const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info, const struct vkd3d_shader_scan_combined_resource_sampler_info *combined_sampler_info, const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
Definition: glsl.c:2467
int hlsl_compile_shader(const struct vkd3d_shader_code *hlsl, const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
Definition: hlsl.c:4496
static int reg
Definition: i386-dis.c:1290
const char * filename
Definition: ioapi.h:137
void vsir_program_cleanup(struct vsir_program *program)
Definition: ir.c:105
enum vkd3d_result vsir_program_validate(struct vsir_program *program, uint64_t config_flags, const char *source_name, struct vkd3d_shader_message_context *message_context)
Definition: ir.c:8169
enum vkd3d_result vsir_program_transform_early(struct vsir_program *program, uint64_t config_flags, const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_message_context *message_context)
Definition: ir.c:8305
#define d
Definition: ke_i.h:81
#define e
Definition: ke_i.h:82
#define f
Definition: ke_i.h:83
#define a
Definition: ke_i.h:78
#define debugstr_a
Definition: kernel32.h:31
#define error(str)
Definition: mkdosfs.c:1605
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define memchr(s, c, n)
Definition: mkisofs.h:875
struct task_struct * current
Definition: linux.c:32
static IPrintDialogCallback callback
Definition: printdlg.c:325
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
int msl_compile(struct vsir_program *program, uint64_t config_flags, const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info, const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
Definition: msl.c:879
#define uint32_t
Definition: nsiface.idl:61
static unsigned __int64 next
Definition: rand_nt.c:6
#define offsetof(TYPE, MEMBER)
#define memset(x, y, z)
Definition: compat.h:39
void vkd3d_compute_md5(const void *data, size_t size, uint32_t checksum[4], enum vkd3d_md5_variant variant)
Definition: checksum.c:305
#define args
Definition: format.c:66
#define minor(rdev)
Definition: propsheet.cpp:929
#define major(rdev)
Definition: propsheet.cpp:928
#define TRACE(s)
Definition: solgame.cpp:4
int spirv_compile(struct vsir_program *program, uint64_t config_flags, const struct vkd3d_shader_scan_descriptor_info1 *scan_descriptor_info, const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
Definition: spirv.c:10835
Definition: match.c:390
Definition: cache.c:41
Definition: inflate.c:139
Definition: http.c:7252
unsigned int count
Definition: notification.c:73
struct shader_reg * src
struct shader_reg dst
Definition: getopt.h:109
WCHAR * name
Definition: getopt.h:110
Definition: import.c:81
PINFCACHELINE line
Definition: inffile.c:95
const char * target_suffix
const char * source_suffix
const char * profile
Definition: cmds.c:130
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_resource_data_type resource_data_type
enum vkd3d_shader_resource_type resource_type
struct vkd3d_shader_immediate_constant_buffer ** icbs
struct vkd3d_shader_param_allocator dst_params
struct vkd3d_shader_param_allocator src_params
struct vkd3d_shader_instruction * elements
struct vkd3d_shader_src_param * src
struct vkd3d_shader_dst_param * dst
struct vkd3d_shader_root_descriptor_table1 descriptor_table
enum vkd3d_shader_root_parameter_type parameter_type
union vkd3d_shader_root_parameter1::@5988 u
union vkd3d_shader_root_parameter::@5987 u
enum vkd3d_shader_root_parameter_type parameter_type
struct vkd3d_shader_root_descriptor_table descriptor_table
const struct vkd3d_shader_static_sampler_desc * static_samplers
const struct vkd3d_shader_root_parameter1 * parameters
const struct vkd3d_shader_root_parameter * parameters
const struct vkd3d_shader_static_sampler_desc * static_samplers
enum vkd3d_shader_structure_type type
enum vkd3d_shader_scan_context::vkd3d_shader_cf_info::@6018 type
struct vkd3d_shader_scan_descriptor_info1 * scan_descriptor_info
struct vkd3d_shader_scan_combined_resource_sampler_info * combined_sampler_info
struct vkd3d_shader_message_context * message_context
enum vkd3d_shader_api_version api_version
const struct vkd3d_shader_version * version
struct vkd3d_shader_scan_context::vkd3d_shader_cf_info * cf_info
struct vkd3d_shader_descriptor_info1 * descriptors
struct vkd3d_shader_descriptor_info * descriptors
struct vkd3d_shader_signature patch_constant
struct vkd3d_shader_signature output
struct vkd3d_shader_signature input
enum vkd3d_shader_resource_type resource_type
enum vkd3d_data_type resource_data_type[VKD3D_VEC4_SIZE]
struct vkd3d_shader_resource resource
enum vkd3d_shader_sysval_semantic sysval_semantic
struct vkd3d_shader_signature_element * elements
unsigned int element_count
#define max(a, b)
Definition: svc.c:63
int tpf_parse(const struct vkd3d_shader_compile_info *compile_info, uint64_t config_flags, struct vkd3d_shader_message_context *message_context, struct vsir_program *program)
Definition: tpf.c:2900
Definition: dlist.c:348
void * next
Definition: dlist.c:360
Definition: pdh_main.c:64
static bool vkd3d_bound_range(size_t start, size_t count, size_t limit)
Definition: vkd3d_common.h:360
void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function, const char *fmt,...) VKD3D_PRINTF_FUNC(3
@ VKD3D_DBG_LEVEL_TRACE
Definition: vkd3d_common.h:149
static void vkd3d_parse_version(const char *version, int *major, int *minor)
Definition: vkd3d_common.h:678
void void vkd3d_dbg_set_log_callback(PFN_vkd3d_log callback)
Definition: debug.c:119
#define VKD3D_PRINTF_FUNC(fmt, args)
Definition: vkd3d_common.h:114
uint64_t vkd3d_parse_debug_options(const char *string, const struct vkd3d_debug_option *options, unsigned int option_count)
Definition: debug.c:370
#define vkd3d_unreachable()
Definition: vkd3d_common.h:119
#define VKD3D_ASSERT(cond)
Definition: vkd3d_common.h:49
static int ascii_strcasecmp(const char *a, const char *b)
Definition: vkd3d_common.h:437
static void * vkd3d_calloc(size_t count, size_t size)
Definition: vkd3d_memory.h:43
static char * vkd3d_strdup(const char *string)
Definition: vkd3d_memory.h:57
static void vkd3d_free(void *ptr)
Definition: vkd3d_memory.h:52
static void * vkd3d_malloc(size_t size)
Definition: vkd3d_memory.h:28
bool vkd3d_array_reserve(void **elements, size_t *capacity, size_t element_count, size_t element_size)
Definition: memory.c:22
@ VKD3D_SHADER_COMPILE_OPTION_API_VERSION
Definition: vkd3d_shader.h:279
vkd3d_shader_resource_data_type
@ VKD3D_SHADER_RESOURCE_DATA_DOUBLE
@ VKD3D_SHADER_RESOURCE_DATA_MIXED
@ VKD3D_SHADER_RESOURCE_DATA_SNORM
@ VKD3D_SHADER_RESOURCE_DATA_CONTINUED
@ VKD3D_SHADER_RESOURCE_DATA_UINT
@ VKD3D_SHADER_RESOURCE_DATA_FLOAT
@ VKD3D_SHADER_RESOURCE_DATA_UNORM
@ VKD3D_SHADER_RESOURCE_DATA_INT
@ VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_RAW_BUFFER
@ VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_READ
@ VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_ATOMICS
@ VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_COUNTER
@ VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_SAMPLER_COMPARISON_MODE
@ VKD3D_SHADER_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE
@ VKD3D_SHADER_SV_NONE
vkd3d_shader_source_type
@ VKD3D_SHADER_SOURCE_DXBC_DXIL
@ VKD3D_SHADER_SOURCE_D3D_BYTECODE
@ VKD3D_SHADER_SOURCE_HLSL
@ VKD3D_SHADER_SOURCE_FX
@ VKD3D_SHADER_SOURCE_DXBC_TPF
#define VKD3D_SHADER_DUMMY_SAMPLER_INDEX
Definition: vkd3d_shader.h:964
vkd3d_shader_log_level
@ VKD3D_SHADER_LOG_ERROR
@ VKD3D_SHADER_LOG_WARNING
@ VKD3D_SHADER_LOG_INFO
@ VKD3D_SHADER_STRUCTURE_TYPE_SCAN_COMBINED_RESOURCE_SAMPLER_INFO
Definition: vkd3d_shader.h:109
@ VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO
Definition: vkd3d_shader.h:68
vkd3d_shader_api_version
Definition: vkd3d_shader.h:44
@ VKD3D_SHADER_API_VERSION_1_2
Definition: vkd3d_shader.h:47
@ VKD3D_SHADER_API_VERSION_1_3
Definition: vkd3d_shader.h:48
vkd3d_shader_descriptor_type
Definition: vkd3d_shader.h:420
@ VKD3D_SHADER_DESCRIPTOR_TYPE_UAV
Definition: vkd3d_shader.h:430
@ VKD3D_SHADER_DESCRIPTOR_TYPE_CBV
Definition: vkd3d_shader.h:435
@ VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER
Definition: vkd3d_shader.h:440
@ VKD3D_SHADER_DESCRIPTOR_TYPE_SRV
Definition: vkd3d_shader.h:425
vkd3d_shader_resource_type
@ VKD3D_SHADER_RESOURCE_NONE
@ VKD3D_SHADER_RESOURCE_BUFFER
@ VKD3D_SHADER_ROOT_SIGNATURE_VERSION_1_1
@ VKD3D_SHADER_ROOT_SIGNATURE_VERSION_1_0
vkd3d_shader_target_type
@ VKD3D_SHADER_TARGET_SPIRV_BINARY
@ VKD3D_SHADER_TARGET_D3D_ASM
@ VKD3D_SHADER_TARGET_NONE
@ VKD3D_SHADER_TARGET_SPIRV_TEXT
@ VKD3D_SHADER_TARGET_DXBC_TPF
@ VKD3D_SHADER_TARGET_GLSL
@ VKD3D_SHADER_TARGET_MSL
@ VKD3D_SHADER_TARGET_D3D_BYTECODE
@ VKD3D_SHADER_TARGET_FX
bool shader_instruction_array_init(struct vkd3d_shader_instruction_array *instructions, unsigned int reserve)
static void vkd3d_shader_scan_resource_declaration(struct vkd3d_shader_scan_context *context, const struct vkd3d_shader_resource *resource, enum vkd3d_shader_resource_type resource_type, enum vkd3d_shader_resource_data_type resource_data_type, unsigned int sample_count, unsigned int structure_stride, bool raw, uint32_t flags)
static struct vkd3d_shader_dst_param * shader_instruction_array_clone_dst_params(struct vkd3d_shader_instruction_array *instructions, const struct vkd3d_shader_dst_param *params, unsigned int count)
void vkd3d_shader_message_context_cleanup(struct vkd3d_shader_message_context *context)
static int char_to_int(char c)
void vkd3d_string_buffer_init(struct vkd3d_string_buffer *buffer)
bool vkd3d_shader_message_context_copy_messages(struct vkd3d_shader_message_context *context, char **out)
void vkd3d_shader_free_scan_signature_info(struct vkd3d_shader_scan_signature_info *info)
static int vsir_program_scan(struct vsir_program *program, const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_message_context *message_context, struct vkd3d_shader_scan_descriptor_info1 *descriptor_info1)
static void init_scan_signature_info(const struct vkd3d_shader_compile_info *info)
int vkd3d_shader_preprocess(const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, char **messages)
int vkd3d_string_buffer_vprintf(struct vkd3d_string_buffer *buffer, const char *format, va_list args)
bool shader_instruction_array_add_icb(struct vkd3d_shader_instruction_array *instructions, struct vkd3d_shader_immediate_constant_buffer *icb)
static struct vkd3d_shader_cf_info * vkd3d_shader_scan_get_current_cf_info(struct vkd3d_shader_scan_context *context)
struct vkd3d_string_buffer * vkd3d_string_buffer_get(struct vkd3d_string_buffer_cache *cache)
void vkd3d_shader_build_varying_map(const struct vkd3d_shader_signature *output_signature, const struct vkd3d_shader_signature *input_signature, unsigned int *ret_count, struct vkd3d_shader_varying_map *varyings)
static void bytecode_set_bytes(struct vkd3d_bytecode_buffer *buffer, size_t offset, const void *value, size_t size)
static struct vkd3d_shader_cf_info * vkd3d_shader_scan_find_innermost_loop_cf_info(struct vkd3d_shader_scan_context *context)
void vkd3d_shader_code_from_string_buffer(struct vkd3d_shader_code *code, struct vkd3d_string_buffer *buffer)
void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *shader_code)
void set_string(struct vkd3d_bytecode_buffer *buffer, size_t offset, const char *string, size_t length)
bool shader_instruction_array_insert_at(struct vkd3d_shader_instruction_array *instructions, unsigned int idx, unsigned int count)
static bool vkd3d_shader_instruction_is_uav_read(const struct vkd3d_shader_instruction *instruction)
void vkd3d_shader_verror(struct vkd3d_shader_message_context *context, const struct vkd3d_shader_location *location, enum vkd3d_shader_error error, const char *format, va_list args)
int vkd3d_string_buffer_print_f64(struct vkd3d_string_buffer *buffer, double d)
static void vkd3d_shader_free_root_signature_v_1_1(struct vkd3d_shader_root_signature_desc1 *root_signature)
int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, char **messages)
static int vkd3d_shader_scan_instruction(struct vkd3d_shader_scan_context *context, const struct vkd3d_shader_instruction *instruction)
static void vkd3d_shader_scan_record_uav_atomic_op(struct vkd3d_shader_scan_context *context, const struct vkd3d_shader_register *reg)
struct vkd3d_shader_signature_element * vkd3d_shader_find_signature_element(const struct vkd3d_shader_signature *signature, const char *semantic_name, unsigned int semantic_index, unsigned int stream_index)
static void shader_param_allocator_destroy(struct vkd3d_shader_param_allocator *allocator)
static int vkd3d_shader_validate_compile_info(const struct vkd3d_shader_compile_info *compile_info, bool validate_target_type)
static const char * shader_get_source_type_suffix(enum vkd3d_shader_source_type type)
static struct vkd3d_shader_param_node * shader_param_allocator_node_create(struct vkd3d_shader_param_allocator *allocator)
uint32_t vkd3d_parse_integer(const char *s)
void vkd3d_shader_free_shader_signature(struct vkd3d_shader_signature *signature)
static struct vkd3d_shader_src_param * shader_instruction_array_clone_src_params(struct vkd3d_shader_instruction_array *instructions, const struct vkd3d_shader_src_param *params, unsigned int count)
void vkd3d_string_buffer_release(struct vkd3d_string_buffer_cache *cache, struct vkd3d_string_buffer *buffer)
size_t bytecode_put_bytes_unaligned(struct vkd3d_bytecode_buffer *buffer, const void *bytes, size_t size)
static struct vkd3d_shader_descriptor_info1 * vkd3d_shader_scan_add_descriptor(struct vkd3d_shader_scan_context *context, enum vkd3d_shader_descriptor_type type, const struct vkd3d_shader_register *reg, const struct vkd3d_shader_register_range *range, enum vkd3d_shader_resource_type resource_type, enum vkd3d_shader_resource_data_type resource_data_type)
void vkd3d_shader_free_scan_combined_resource_sampler_info(struct vkd3d_shader_scan_combined_resource_sampler_info *info)
static void vkd3d_shader_scan_typed_resource_declaration(struct vkd3d_shader_scan_context *context, const struct vkd3d_shader_instruction *instruction)
void vkd3d_string_buffer_cleanup(struct vkd3d_string_buffer *buffer)
void vkd3d_string_buffer_truncate(struct vkd3d_string_buffer *buffer, size_t size)
size_t bytecode_reserve_bytes(struct vkd3d_bytecode_buffer *buffer, size_t size)
size_t bytecode_align(struct vkd3d_bytecode_buffer *buffer)
int vkd3d_string_buffer_print_f32(struct vkd3d_string_buffer *buffer, float f)
void shader_instruction_array_destroy(struct vkd3d_shader_instruction_array *instructions)
static bool vkd3d_shader_signature_from_shader_signature(struct vkd3d_shader_signature *signature, const struct shader_signature *src)
static void vkd3d_shader_scan_constant_buffer_declaration(struct vkd3d_shader_scan_context *context, const struct vkd3d_shader_instruction *instruction)
void vkd3d_string_buffer_clear(struct vkd3d_string_buffer *buffer)
void vkd3d_string_buffer_cache_init(struct vkd3d_string_buffer_cache *cache)
static const struct vkd3d_shader_descriptor_info1 * find_descriptor(const struct vkd3d_shader_scan_descriptor_info1 *info, enum vkd3d_shader_descriptor_type type, unsigned int register_id)
int vkd3d_shader_scan(const struct vkd3d_shader_compile_info *compile_info, char **messages)
static struct vkd3d_shader_cf_info * vkd3d_shader_scan_find_innermost_breakable_cf_info(struct vkd3d_shader_scan_context *context)
static void fill_shader_dump_data(const struct vkd3d_shader_compile_info *compile_info, struct shader_dump_data *data)
void * shader_param_allocator_get(struct vkd3d_shader_param_allocator *allocator, unsigned int count)
void vkd3d_shader_message_context_init(struct vkd3d_shader_message_context *context, enum vkd3d_shader_log_level log_level)
void vkd3d_shader_warning(struct vkd3d_shader_message_context *context, const struct vkd3d_shader_location *location, enum vkd3d_shader_error error, const char *format,...)
static void vkd3d_shader_dump_shader(const struct shader_dump_data *dump_data, const void *data, size_t size, bool source)
static void vkd3d_shader_free_scan_descriptor_info1(struct vkd3d_shader_scan_descriptor_info1 *scan_descriptor_info)
static void vkd3d_shader_scan_sampler_declaration(struct vkd3d_shader_scan_context *context, const struct vkd3d_shader_instruction *instruction)
static const char * shader_get_target_type_suffix(enum vkd3d_shader_target_type type)
static void vkd3d_shader_free_root_signature_v_1_0(struct vkd3d_shader_root_signature_desc *root_signature)
void vkd3d_shader_vwarning(struct vkd3d_shader_message_context *context, const struct vkd3d_shader_location *location, enum vkd3d_shader_error error, const char *format, va_list args)
static enum vkd3d_result vsir_parse(const struct vkd3d_shader_compile_info *compile_info, uint64_t config_flags, struct vkd3d_shader_message_context *message_context, struct vsir_program *program)
static void vkd3d_shader_scan_add_uav_flag(const struct vkd3d_shader_scan_context *context, const struct vkd3d_shader_register *reg, uint32_t flag)
void vkd3d_shader_free_messages(char *messages)
static void vkd3d_shader_scan_record_uav_counter(struct vkd3d_shader_scan_context *context, const struct vkd3d_shader_register *reg)
void vkd3d_shader_message_context_trace_messages_(const struct vkd3d_shader_message_context *context, const char *function)
static bool vkd3d_shader_instruction_is_uav_atomic_op(const struct vkd3d_shader_instruction *instruction)
void vkd3d_shader_set_log_callback(PFN_vkd3d_log callback)
static void vkd3d_shader_scan_pop_cf_info(struct vkd3d_shader_scan_context *context)
void shader_signature_cleanup(struct shader_signature *signature)
static enum vkd3d_result convert_descriptor_info(struct vkd3d_shader_scan_descriptor_info *info, const struct vkd3d_shader_scan_descriptor_info1 *info1)
void set_u32(struct vkd3d_bytecode_buffer *buffer, size_t offset, uint32_t value)
static const struct vkd3d_debug_option vkd3d_shader_config_options[]
static bool vkd3d_shader_instruction_is_uav_counter(const struct vkd3d_shader_instruction *instruction)
static void vkd3d_shader_scan_context_init(struct vkd3d_shader_scan_context *context, const struct vkd3d_shader_version *version, const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_scan_descriptor_info1 *scan_descriptor_info, struct vkd3d_shader_scan_combined_resource_sampler_info *combined_sampler_info, struct vkd3d_shader_message_context *message_context)
void vkd3d_shader_parser_init(struct vkd3d_shader_parser *parser, struct vsir_program *program, struct vkd3d_shader_message_context *message_context, const char *source_name)
static void vkd3d_shader_scan_combined_sampler_declaration(struct vkd3d_shader_scan_context *context, const struct vkd3d_shader_semantic *semantic)
static bool vkd3d_string_buffer_resize(struct vkd3d_string_buffer *buffer, int rc)
static bool shader_register_clone_relative_addresses(struct vkd3d_shader_register *reg, struct vkd3d_shader_instruction_array *instructions)
void vkd3d_string_buffer_cache_cleanup(struct vkd3d_string_buffer_cache *cache)
const char * vkd3d_shader_get_version(unsigned int *major, unsigned int *minor)
enum vkd3d_shader_target_type * vkd3d_shader_get_supported_target_types(enum vkd3d_shader_source_type source_type, unsigned int *count)
static void vkd3d_shader_scan_combined_sampler_usage(struct vkd3d_shader_scan_context *context, const struct vkd3d_shader_register *resource, const struct vkd3d_shader_register *sampler)
static struct vkd3d_shader_cf_info * vkd3d_shader_scan_push_cf_info(struct vkd3d_shader_scan_context *context)
bool shader_instruction_array_clone_instruction(struct vkd3d_shader_instruction_array *instructions, unsigned int dst, unsigned int src)
void vkd3d_shader_vnote(struct vkd3d_shader_message_context *context, const struct vkd3d_shader_location *location, enum vkd3d_shader_log_level level, const char *format, va_list args)
static void vkd3d_shader_scan_record_uav_read(struct vkd3d_shader_scan_context *context, const struct vkd3d_shader_register *reg)
uint64_t vkd3d_shader_init_config_flags(void)
static void shader_param_allocator_init(struct vkd3d_shader_param_allocator *allocator, unsigned int count, unsigned int stride)
int vsir_program_compile(struct vsir_program *program, uint64_t config_flags, const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
bool shader_instruction_array_reserve(struct vkd3d_shader_instruction_array *instructions, unsigned int reserve)
void vkd3d_shader_free_root_signature(struct vkd3d_shader_versioned_root_signature_desc *desc)
void vkd3d_shader_free_scan_descriptor_info(struct vkd3d_shader_scan_descriptor_info *scan_descriptor_info)
size_t bytecode_put_bytes(struct vkd3d_bytecode_buffer *buffer, const void *bytes, size_t size)
void vkd3d_string_buffer_trace_(const struct vkd3d_string_buffer *buffer, const char *function)
void vkd3d_shader_trace_text_(const char *text, size_t size, const char *function)
enum vkd3d_shader_source_type * vkd3d_shader_get_supported_source_types(unsigned int *count)
static void vkd3d_shader_scan_context_cleanup(struct vkd3d_shader_scan_context *context)
static int compile_hlsl(const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
int vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_signature *signature, char **messages)
int vkd3d_string_buffer_printf(struct vkd3d_string_buffer *buffer, const char *format,...)
#define vkd3d_find_struct(c, t)
static bool vkd3d_shader_ver_ge(const struct vkd3d_shader_version *v, unsigned int major, unsigned int minor)
@ VKD3DSPR_RESOURCE
@ VKD3DSPR_UAV
@ VKD3DSPR_COMBINED_SAMPLER
@ VKD3DSPR_SAMPLER
#define VKD3DSI_SAMPLER_COMPARISON_MODE
vkd3d_shader_error
@ VKD3D_SHADER_WARNING_VSIR_DYNAMIC_DESCRIPTOR_ARRAY
@ VKD3D_SHADER_ERROR_TPF_MISMATCHED_CF
@ VKD3D_DATA_SNORM
@ VKD3D_DATA_INT
@ VKD3D_DATA_DOUBLE
@ VKD3D_DATA_UINT
@ VKD3D_DATA_UNORM
@ VKD3D_DATA_FLOAT
@ VKD3D_DATA_MIXED
@ VKD3D_DATA_CONTINUED
vkd3d_shader_opcode
@ VKD3DSIH_RESINFO
@ VKD3DSIH_ENDSWITCH
@ VKD3DSIH_TEXM3x3SPEC
@ VKD3DSIH_TEXREG2RGB
@ VKD3DSIH_TEXDP3TEX
@ VKD3DSIH_TEX
@ VKD3DSIH_GATHER4_PO_C
@ VKD3DSIH_SAMPLE_C_LZ
@ VKD3DSIH_LOOP
@ VKD3DSIH_SAMPLE_INFO
@ VKD3DSIH_TEXREG2AR
@ VKD3DSIH_SWITCH
@ VKD3DSIH_IMM_ATOMIC_XOR
@ VKD3DSIH_LD_UAV_TYPED
@ VKD3DSIH_SAMPLE
@ VKD3DSIH_LD_STRUCTURED
@ VKD3DSIH_SAMPLE_C
@ VKD3DSIH_ATOMIC_XOR
@ VKD3DSIH_DCL_RESOURCE_RAW
@ VKD3DSIH_DCL_SAMPLER
@ VKD3DSIH_GATHER4_PO
@ VKD3DSIH_IMM_ATOMIC_CONSUME
@ VKD3DSIH_TEXREG2GB
@ VKD3DSIH_BREAK
@ VKD3DSIH_DCL_UAV_RAW
@ VKD3DSIH_LD2DMS
@ VKD3DSIH_TEXBEM
@ VKD3DSIH_IFC
@ VKD3DSIH_SAMPLE_LOD
@ VKD3DSIH_ATOMIC_AND
@ VKD3DSIH_CASE
@ VKD3DSIH_CONTINUE
@ VKD3DSIH_IF
@ VKD3DSIH_TEXM3x2TEX
@ VKD3DSIH_ENDIF
@ VKD3DSIH_DCL_UAV_STRUCTURED
@ VKD3DSIH_LD_RAW
@ VKD3DSIH_TEXM3x3VSPEC
@ VKD3DSIH_IMM_ATOMIC_ALLOC
@ VKD3DSIH_GATHER4_C
@ VKD3DSIH_CONTINUEP
@ VKD3DSIH_SAMPLE_B
@ VKD3DSIH_DCL_RESOURCE_STRUCTURED
@ VKD3DSIH_TEXBEML
@ VKD3DSIH_BUFINFO
@ VKD3DSIH_ENDLOOP
@ VKD3DSIH_DCL
@ VKD3DSIH_DCL_UAV_TYPED
@ VKD3DSIH_TEXM3x3TEX
@ VKD3DSIH_SAMPLE_GRAD
@ VKD3DSIH_ELSE
@ VKD3DSIH_DCL_CONSTANT_BUFFER
@ VKD3DSIH_LD
@ VKD3DSIH_BREAKP
@ VKD3DSIH_DEFAULT
@ VKD3DSIH_RET
@ VKD3DSIH_GATHER4
#define vkd3d_shader_message_context_trace_messages(context)
@ VSIR_ASM_FLAG_NONE
@ VKD3D_SHADER_CONFIG_FLAG_FORCE_VALIDATION
void vkd3d_shader_parser_error(struct vkd3d_shader_parser *parser, enum vkd3d_shader_error error, const char *format,...) VKD3D_PRINTF_FUNC(3
int preproc_lexer_parse(const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
void vkd3d_shader_parser_warning(struct vkd3d_shader_parser *parser, enum vkd3d_shader_error error, const char *format,...) VKD3D_PRINTF_FUNC(3
@ VKD3D_MD5_STANDARD
static struct vkd3d_shader_src_param * shader_src_param_allocator_get(struct vkd3d_shader_param_allocator *allocator, unsigned int count)
static struct vkd3d_shader_dst_param * shader_dst_param_allocator_get(struct vkd3d_shader_param_allocator *allocator, unsigned int count)
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_OK
Definition: vkd3d_types.h:43
@ VKD3D_ERROR_OUT_OF_MEMORY
Definition: vkd3d_types.h:49
void(* PFN_vkd3d_log)(const char *format, va_list args)
Definition: vkd3d_types.h:66
#define VKD3D_VCS_ID
Definition: vkd3d_version.h:1
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
#define MAX_REG_OUTPUT
static size_t align(size_t addr, size_t alignment)
#define snprintf
Definition: wintirpc.h:48
#define const
Definition: zconf.h:233