Blender V5.3
gpu_shader_dependency.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
11
12#include <algorithm>
13#include <fmt/format.h>
14#include <iomanip>
15#include <iostream>
16#include <regex>
17#include <string>
18
19#include "BLI_map.hh"
20#include "BLI_string_ref.hh"
21
22#include "CLG_log.h"
23
29
30#ifdef WITH_OPENSUBDIV
33#endif
34
37
38namespace blender {
39
40extern "C" {
41#define SHADER_SOURCE(filename_underscore, filename, filepath) \
42 extern char datatoc_##filename_underscore[];
43#include "glsl_compositor_source_list.h"
44#include "glsl_draw_source_list.h"
45#include "glsl_eevee_source_list.h"
46#include "glsl_gpencil_source_list.h"
47#include "glsl_gpu_source_list.h"
48#include "glsl_image_source_list.h"
49#include "glsl_ocio_source_list.h"
50#include "glsl_overlay_source_list.h"
51#include "glsl_select_id_source_list.h"
52#include "glsl_workbench_source_list.h"
53#ifdef WITH_OPENSUBDIV
54# include "glsl_osd_source_list.h"
55#endif
56#undef SHADER_SOURCE
57}
58
59static CLG_LogRef LOG = {"gpu.shader.deps"};
60
61namespace gpu::shader {
62
63static bool g_shader_use_printf = false;
64
66{
67 using namespace blender::gpu::shader;
68 using namespace blender::gpu::shader::metadata;
69 switch (builtin) {
103#ifndef NDEBUG
105#else
106 return BuiltinBits::NONE;
107#endif
108 case Builtin::assert:
109 case Builtin::printf:
110#if GPU_SHADER_PRINTF_ENABLE
111 g_shader_use_printf = true;
113#else
114 return BuiltinBits::NONE;
115#endif
118 }
120 return BuiltinBits::NONE;
121}
122
123} // namespace gpu::shader
124
125namespace gpu {
126
130
131struct GPUSource {
135 std::string patched_source;
138 bool dependencies_init = false;
140 /* True if this file content is supposed to be generated at runtime. */
141 bool generated = false;
142
144
145 /* NOTE: The next few functions are needed to keep isolation of the preprocessor.
146 * Eventually, this should be revisited and the preprocessor should output
147 * GPU structures. */
148
150 {
151 using namespace blender::gpu::shader;
152 switch (qualifier) {
154 return FUNCTION_QUAL_IN;
156 return FUNCTION_QUAL_OUT;
158 return FUNCTION_QUAL_INOUT;
159 }
161 return FUNCTION_QUAL_IN;
162 }
163
165 {
166 using namespace blender::gpu::shader;
167 switch (type) {
169 return GPU_FLOAT;
171 return GPU_VEC2;
173 return GPU_VEC3;
175 return GPU_VEC4;
177 return GPU_MAT3;
179 return GPU_MAT4;
181 return GPU_INT;
183 return GPU_INT2;
185 return GPU_INT3;
187 return GPU_INT4;
189 return GPU_BOOL;
191 return GPU_TEX1D_ARRAY;
193 return GPU_TEX2D_ARRAY;
195 return GPU_TEX2D;
197 return GPU_TEX3D;
199 return GPU_CLOSURE;
201 return GPU_KERNEL_GLOBALS;
203 return GPU_SHADING_DATA;
204 }
206 return GPU_NONE;
207 }
208
210 const char *path,
211 const char *file,
212 const char *datatoc,
215 std::function<void(GPUSource &, GPUFunctionDictionary *, GPUPrintFormatMap *)> metadata_fn)
216 : fullpath(path), filename(file), source(datatoc)
217 {
218 BLI_assert_msg(source.find("//") == std::string::npos &&
219 source.find("/*") == std::string::npos,
220 "Input source should have no comments.");
221 metadata_fn(*this, g_functions, g_formats);
222 };
223
228
230 {
231 dependencies_names.append(line);
232 }
233
234 void add_shared_variable(const shader::Type type, const StringRefNull name)
235 {
236 shared_variables.append({type, name});
237 }
238
239 void add_printf_format(uint32_t format_hash, std::string format, GPUPrintFormatMap *format_map)
240 {
241 /* TODO(fclem): Move this to gpu log. */
242 if (format_map->contains(format_hash)) {
243 if (format_map->lookup(format_hash).format_str != format) {
244 print_error(format, 0, "printf format hash collision.");
245 }
246 else {
247 /* The format map already have the same format. */
248 }
249 }
250 else {
252 /* Save for hash collision comparison. */
253 fmt.format_str = format;
254
255 /* Escape characters replacement. Do the most common ones. */
256 format = std::regex_replace(format, std::regex(R"(\\n)"), "\n");
257 format = std::regex_replace(format, std::regex(R"(\\v)"), "\v");
258 format = std::regex_replace(format, std::regex(R"(\\t)"), "\t");
259 format = std::regex_replace(format, std::regex(R"(\\')"), "\'");
260 format = std::regex_replace(format, std::regex(R"(\\")"), "\"");
261 format = std::regex_replace(format, std::regex(R"(\\\\)"), "\\");
262
265 int64_t start = 0, end = 0, cursor = -1;
266 while ((end = format.find_first_of('%', cursor + 1)) != -1) {
267 if (end - start > 0) {
268 /* Add the previous block without the newly found % character. */
269 fmt.format_blocks.append({type, format.substr(start, end - start)});
270 }
271 /* Format type of the next block. */
272 /* TODO(fclem): This doesn't support advance formats like `%3.2f`. */
273 switch (format[end + 1]) {
274 case 's':
276 break;
277 case 'x':
278 case 'u':
280 break;
281 case 'd':
283 break;
284 case 'f':
286 break;
287 default:
288 BLI_assert_msg(0, "Printing format unsupported");
289 break;
290 }
291 /* Start of the next block. */
292 start = end;
293 cursor = end;
294 }
295 fmt.format_blocks.append({type, format.substr(start, format.size() - start)});
296
297 format_map->add(format_hash, fmt);
298 }
299 }
300
304 {
305 GPUFunction *func = MEM_new<GPUFunction>(__func__);
306 name.copy_utf8_truncated(func->name, sizeof(func->name));
307 func->source = reinterpret_cast<void *>(this);
308 func->totparam = 0;
309 for (auto arg : arguments) {
310 if (func->totparam >= ARRAY_SIZE(func->paramtype)) {
311 print_error(source, source.find(name), "Too many parameters in function");
312 break;
313 }
314 func->paramqual[func->totparam] = convert_qualifier(arg.qualifier);
315 func->paramtype[func->totparam] = convert_type(arg.type);
316 func->totparam++;
317 }
318
319 bool insert = g_functions->add(func->name, func);
320 /* NOTE: We allow overloading non void function, but only if the function comes from the
321 * same file. Otherwise the dependency system breaks. */
322 if (!insert) {
323 GPUSource *other_source = reinterpret_cast<GPUSource *>(g_functions->lookup(name)->source);
324 if (other_source != this) {
325 const char *msg = "Function redefinition or overload in two different files ...";
326 print_error(source, source.find(name), msg);
327 print_error(other_source->source,
328 other_source->source.find(name),
329 "... previous definition was here");
330 }
331 else {
332 /* Non-void function overload. */
333 MEM_delete(func);
334 }
335 }
336 }
337
338 void print_error(const StringRef &input, int64_t offset, const StringRef message)
339 {
340 StringRef sub = input.substr(0, offset);
341 int64_t line_number = std::count(sub.begin(), sub.end(), '\n') + 1;
342 int64_t line_end = input.find("\n", offset);
343 int64_t line_start = input.rfind("\n", offset) + 1;
344 int64_t char_number = offset - line_start + 1;
345
346 /* TODO Use clog. */
347
348 std::cerr << fullpath << ":" << line_number << ":" << char_number;
349
350 std::cerr << " error: " << message << "\n";
351 std::cerr << std::setw(5) << line_number << " | "
352 << input.substr(line_start, line_end - line_start) << "\n";
353 std::cerr << " | ";
354 for (int64_t i = 0; i < char_number - 1; i++) {
355 std::cerr << " ";
356 }
357 std::cerr << "^\n";
358 }
359
360 /* Return 1 one error. */
362 {
363 if (this->dependencies_init) {
364 return 0;
365 }
366 this->dependencies_init = true;
367
368 using namespace shader;
369 /* Auto dependency injection for debug capabilities. */
370 if (flag_is_set(builtins, BuiltinBits::USE_PRINTF)) {
371 dependencies.append_non_duplicates(dict.lookup("gpu_shader_print_lib.glsl"));
372 }
373 if (flag_is_set(builtins, BuiltinBits::USE_DEBUG_DRAW)) {
374 dependencies.append_non_duplicates(dict.lookup("draw_debug_draw.bsl.hh"));
375 }
376
377 for (auto dependency_name : dependencies_names) {
378 GPUSource *dependency_source = dict.lookup_default(dependency_name, nullptr);
379 if (dependency_source == nullptr) {
380 std::string error = std::string("Dependency not found : ") + dependency_name;
381 print_error(source, 0, error.c_str());
382 return 1;
383 }
384
385 /* Recursive. */
386 int result = dependency_source->init_dependencies(dict);
387 if (result != 0) {
388 return 1;
389 }
390 dependencies.append_non_duplicates(dependency_source);
391
392 this->shared_variables.extend(dependency_source->shared_variables);
393 }
394 dependencies_names.clear();
395 return 0;
396 }
397
399 Vector<StringRefNull> &included,
400 const shader::GeneratedSourceList &generated_sources,
401 const GPUSourceDictionary &dict,
402 const GPUSource &from) const
403 {
404#define CLOG_FILE_INCLUDE(_from, _include) \
405 if (CLOG_CHECK(&LOG, CLG_LEVEL_TRACE) && \
406 (from).filename.c_str() != (_include).filename.c_str()) \
407 { \
408 const char *from_filename = (_from).filename.c_str(); \
409 const char *include_filename = (_include).filename.c_str(); \
410 const int from_size = int((_from).source.size()); \
411 const int include_size = int((_include).source.size()); \
412 std::string link = fmt::format( \
413 "{}_{} --> {}_{}\n", from_filename, from_size, include_filename, include_size); \
414 std::string style = fmt::format("style {}_{} fill:#{:x}{:x}0\n", \
415 include_filename, \
416 include_size, \
417 min_uu(15, include_size / 1000), \
418 15 - min_uu(15, include_size / 1000)); \
419 CLG_log_raw(LOG.type, link.c_str()); \
420 CLG_log_raw(LOG.type, style.c_str()); \
421 }
422
423 const shader::GeneratedSource *gen_src = nullptr;
424 if (flag_is_set(this->builtins, shader::BuiltinBits::RUNTIME_GENERATED)) {
425 /* Linear lookup since we won't have more than a few per shaders.
426 * Also avoid the complexity of a Map in info creation. */
427 for (const shader::GeneratedSource &generated_src : generated_sources) {
428 if (generated_src.filename == this->filename) {
429 gen_src = &generated_src;
430 break;
431 }
432 }
433 }
434
435 /* Check if this file was already included. */
436 for (const StringRefNull &source_content : included) {
437 /* Yes, compare pointer instead of string for speed.
438 * Each source is guaranteed to be unique and non-moving during the building process. */
439 if (source_content.c_str() == (gen_src ? gen_src->content.c_str() : this->source.c_str())) {
440 /* Already included. */
441 CLOG_FILE_INCLUDE(from, *this);
442 return;
443 }
444 }
445
446 if (!flag_is_set(this->builtins, shader::BuiltinBits::RUNTIME_GENERATED)) {
447 included.append(this->source);
448 for (const auto &dependency : this->dependencies) {
449 /* WATCH: Recursive. */
450 dependency->source_get(result, included, generated_sources, dict, *this);
451 }
452 CLOG_FILE_INCLUDE(from, *this);
453 result.append(this->source);
454 return;
455 }
456
457 if (gen_src) {
458 included.append(gen_src->content);
459 /* Include dependencies before the generated file. */
460 for (const auto &dependency_name : gen_src->dependencies) {
461 BLI_assert_msg(dependency_name != this->filename, "Recursive include");
462
463 GPUSource *dependency_source = dict.lookup_default(dependency_name, nullptr);
464 if (dependency_source == nullptr) {
465 /* Will certainly fail compilation. But avoid crashing the application. */
466 std::cerr << "Generated dependency not found : " + dependency_name << std::endl;
467 return;
468 }
469 /* WATCH: Recursive. */
470 dependency_source->source_get(result, included, generated_sources, dict, *this);
471 }
472 CLOG_FILE_INCLUDE(from, *this);
473 result.append(gen_src->content);
474 return;
475 }
476
477 std::cerr << "warn: Generated source not provided. Using fallback for : " << this->filename
478 << std::endl;
479 included.append(this->source);
480 /* Dependencies for generated sources are not folded on startup.
481 * This allows for different set of dependencies at runtime. */
482 for (const auto &dependency : this->dependencies) {
483 /* WATCH: Recursive. */
484 dependency->source_get(result, included, generated_sources, dict, *this);
485 }
486 CLOG_FILE_INCLUDE(from, *this);
487 result.append(this->source);
488 }
489
490 /* Returns the final string with all includes done. */
492 const shader::GeneratedSourceList &generated_sources,
493 const GPUSourceDictionary &dict) const
494 {
495 /* List of visited files. Avoid infinite or double includes. */
496 Vector<StringRefNull> included;
497 source_get(result, included, generated_sources, dict, *this);
498 }
499
501 {
502 shader::BuiltinBits out_builtins = builtins;
503 for (auto *dep : dependencies) {
504 out_builtins |= dep->builtins_get();
505 }
506 return out_builtins;
507 }
508
510 {
511 return (filename.startswith("gpu_shader_material_") ||
512 filename.startswith("gpu_shader_common_") ||
513 filename.startswith("gpu_shader_compositor_")) &&
514 filename.endswith(".glsl");
515 }
516};
517
518namespace shader {
519
520#include "glsl_compositor_metadata_list.hh"
521#include "glsl_draw_metadata_list.hh"
522#include "glsl_eevee_metadata_list.hh"
523#include "glsl_gpencil_metadata_list.hh"
524#include "glsl_gpu_metadata_list.hh"
525#include "glsl_image_metadata_list.hh"
526#include "glsl_ocio_metadata_list.hh"
527#include "glsl_overlay_metadata_list.hh"
528#include "glsl_select_id_metadata_list.hh"
529#include "glsl_workbench_metadata_list.hh"
530#ifdef WITH_OPENSUBDIV
531# include "glsl_osd_metadata_list.hh"
532#endif
533
534} // namespace shader
535
536} // namespace gpu
537
538using namespace blender::gpu;
539
540static GPUPrintFormatMap *g_formats = nullptr;
543static bool force_printf_injection = false;
544
545#ifdef WITH_OPENSUBDIV
546/* Using a global string to avoid dealing with memory allocation/ownership. */
547static std::string osd_patch_basis;
548#endif
549
551{
555
556#define SHADER_SOURCE(filename_underscore, filename, filepath) \
557 g_sources->add_new(filename, \
558 new GPUSource(filepath, \
559 filename, \
560 datatoc_##filename_underscore, \
561 g_functions, \
562 g_formats, \
563 gpu::shader::metadata_##filename_underscore));
564
565#include "glsl_gpu_source_list.h"
566
567#include "glsl_compositor_source_list.h"
568#include "glsl_draw_source_list.h"
569#include "glsl_eevee_source_list.h"
570#include "glsl_gpencil_source_list.h"
571#include "glsl_image_source_list.h"
572#include "glsl_ocio_source_list.h"
573#include "glsl_overlay_source_list.h"
574#include "glsl_select_id_source_list.h"
575#include "glsl_workbench_source_list.h"
576#ifdef WITH_OPENSUBDIV
577# include "glsl_osd_source_list.h"
578#endif
579#undef SHADER_SOURCE
580#ifdef WITH_OPENSUBDIV
581 osd_patch_basis = openSubdiv_getGLSLPatchBasisSource();
582 osd_patch_basis = shader::SourceProcessor(
583 osd_patch_basis, "osd_patch_basis.glsl", gpu::shader::Language::GLSL, {})
584 .remove_comments();
585 auto source_ptr_opt = g_sources->pop_try("osd_patch_basis.glsl");
586 if (source_ptr_opt) {
587 delete source_ptr_opt.value();
588 }
590 "osd_patch_basis.glsl",
591 new GPUSource("osd_patch_basis.glsl",
592 "osd_patch_basis.glsl",
593 (osd_patch_basis).c_str(),
595 g_formats,
597#endif
598
599 int errors = 0;
600 for (auto *value : g_sources->values()) {
601 errors += value->init_dependencies(*g_sources);
602 }
603 BLI_assert_msg(errors == 0, "Dependency errors detected: Aborting");
604 UNUSED_VARS_NDEBUG(errors);
605
606#if GPU_SHADER_PRINTF_ENABLE
607 if (!g_formats->is_empty()) {
608 /* Detect if there is any printf in node lib files.
609 * See gpu_shader_dependency_force_gpu_print_injection(). */
610 for (auto *value : g_sources->values()) {
611 if (flag_is_set(value->builtins, shader::BuiltinBits::USE_PRINTF)) {
612 if (value->filename.startswith("gpu_shader_material_")) {
614 break;
615 }
616 }
617 }
618 }
619#endif
620}
621
623{
624 for (auto *value : g_sources->values()) {
625 delete value;
626 }
627 for (auto *value : g_functions->values()) {
628 MEM_delete(value);
629 }
630 delete g_formats;
631 delete g_sources;
632 delete g_functions;
633 g_formats = nullptr;
634 g_sources = nullptr;
635 g_functions = nullptr;
636}
637
639{
640 GPUFunction *function = g_functions->lookup_default(name, nullptr);
641 BLI_assert_msg(function != nullptr, "Requested function not in the function library");
642 return function;
643}
644
645void gpu_material_library_use_function(Set<StringRefNull> &used_libraries, const char *name)
646{
647 GPUFunction *function = g_functions->lookup_default(name, nullptr);
648 BLI_assert_msg(function != nullptr, "Requested function not in the function library");
649 GPUSource *source = reinterpret_cast<GPUSource *>(function->source);
650 used_libraries.add(source->filename.c_str());
651}
652
653namespace gpu::shader {
654
656{
657 /* WORKAROUND: We cannot know what shader will require printing if the printf is inside shader
658 * node code. In this case, we just force injection inside all shaders. */
660}
661
663{
664 return (g_formats != nullptr) && g_shader_use_printf;
665}
666
668{
669 return g_formats->lookup(format_hash);
670}
671
673{
674 if (shader_source_name.is_empty()) {
676 }
677 if (g_sources->contains(shader_source_name) == false) {
678 std::cerr << "Error: Could not find \"" << shader_source_name
679 << "\" in the list of registered source.\n";
680 BLI_assert(0);
682 }
683 GPUSource *source = g_sources->lookup(shader_source_name);
684 return source->builtins_get();
685}
686
688 const StringRefNull shader_source_name)
689{
690 if (shader_source_name.is_empty()) {
691 return {};
692 }
693 if (g_sources->contains(shader_source_name) == false) {
694 std::cerr << "Error: Could not find \"" << shader_source_name
695 << "\" in the list of registered source.\n";
696 BLI_assert(0);
697 return {};
698 }
699 GPUSource *source = g_sources->lookup(shader_source_name);
700 return source->shared_variables;
701}
702
704 const StringRefNull shader_source_name,
705 const shader::GeneratedSourceList &generated_sources,
706 const StringRefNull shader_name)
707{
709 GPUSource *src = g_sources->lookup_default(shader_source_name, nullptr);
710 if (src == nullptr) {
711 std::cerr << "Error source not found : " << shader_source_name << std::endl;
712 }
713 CLOG_TRACE(&LOG, "Resolved Source Tree (Mermaid flowchart) %s", shader_name.c_str());
715 CLG_log_raw(LOG.type, "flowchart LR\n");
716 }
717 src->build(result, generated_sources, *g_sources);
719 CLG_log_raw(LOG.type, "\n");
720 }
721 return result;
722}
723
725{
726 GPUSource *src = g_sources->lookup_default(shader_source_name, nullptr);
727 if (src == nullptr) {
728 std::cerr << "Error source not found : " << shader_source_name << std::endl;
729 }
730 return src->source;
731}
732
734{
735 for (auto &source : g_sources->values()) {
736 if (source->source == source_string) {
737 return source->filename;
738 }
739 }
740 return "";
741}
742
743} // namespace gpu::shader
744} // namespace blender
void CLG_log_raw(const CLG_LogType *lg, const char *message)
Definition clog.cc:697
#define CLOG_CHECK(clg_ref, verbose_level,...)
Definition CLG_log.h:147
@ CLG_LEVEL_TRACE
Definition CLG_log.h:64
#define CLOG_TRACE(clg_ref,...)
Definition CLG_log.h:192
__forceinline const float4 insert(const float4 &a, const float b)
Definition binning.cpp:31
#define BLI_assert_unreachable()
#define UNUSED_VARS_NDEBUG(...)
#define BLI_assert_msg(a, msg)
std::optional< Value > pop_try(const Key &key)
Definition BLI_map.hh:419
ValueIterator values() const &
Definition BLI_map.hh:884
bool add(const Key &key, const Value &value)
Definition BLI_map.hh:295
const Value & lookup(const Key &key) const
Definition BLI_map.hh:545
Value lookup_default(const Key &key, const Value &default_value) const
Definition BLI_map.hh:570
void add_new(const Key &key, const Value &value)
Definition BLI_map.hh:265
bool is_empty() const
Definition BLI_map.hh:986
bool contains(const Key &key) const
Definition BLI_map.hh:353
bool add(const Key &key)
Definition BLI_set.hh:248
constexpr const char * c_str() const
constexpr int64_t rfind(char c, int64_t pos=INT64_MAX) const
constexpr const char * end() const
constexpr const char * begin() const
constexpr bool is_empty() const
constexpr int64_t find(char c, int64_t pos=0) const
constexpr StringRef substr(int64_t start, int64_t size) const
void copy_utf8_truncated(char *dst, int64_t dst_size) const
Definition string_ref.cc:28
constexpr const char * c_str() const
const char * openSubdiv_getGLSLPatchBasisSource()
#define CLOG_FILE_INCLUDE(_from, _include)
size_t line_number(const std::string_view &str, size_t pos)
size_t char_number(const std::string_view &str, size_t pos)
Vector< shader::GeneratedSource, 0 > GeneratedSourceList
Vector< StringRefNull > gpu_shader_dependency_get_resolved_source(const StringRefNull shader_source_name, const shader::GeneratedSourceList &generated_sources, const StringRefNull shader_name)
shader::BuiltinBits convert_builtin_bit(shader::metadata::Builtin builtin)
Span< ShaderCreateInfo::SharedVariable > gpu_shader_dependency_get_shared_variables(const StringRefNull shader_source_name)
const PrintfFormat & gpu_shader_dependency_get_printf_format(uint32_t format_hash)
BuiltinBits gpu_shader_dependency_get_builtins(const StringRefNull shader_source_name)
bool gpu_shader_dependency_force_gpu_print_injection()
StringRefNull gpu_shader_dependency_get_filename_from_source_string(const StringRef source_string)
Find the name of the file from which the given string was generated.
StringRefNull gpu_shader_dependency_get_source(const StringRefNull shader_source_name)
Map< StringRef, GPUSource * > GPUSourceDictionary
Map< uint32_t, shader::PrintfFormat > GPUPrintFormatMap
Map< StringRef, GPUFunction * > GPUFunctionDictionary
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
__int64 int64_t
Definition BKE_text.h:90
static GPUPrintFormatMap * g_formats
void gpu_material_library_use_function(Set< StringRefNull > &used_libraries, const char *name)
void gpu_shader_dependency_exit()
@ GPU_KERNEL_GLOBALS
GPUFunction * gpu_material_library_get_function(const char *name)
static bool force_printf_injection
unsigned int uint32_t
Definition BKE_text.h:81
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
static GPUSourceDictionary * g_sources
void gpu_shader_dependency_init()
static GPUFunctionDictionary * g_functions
static CLG_LogRef LOG
Definition logging.cpp:12
GPUFunctionQual paramqual[MAX_PARAMETER]
char name[MAX_FUNCTION_NAME]
GPUType paramtype[MAX_PARAMETER]
Vector< GPUSource * > dependencies
void add_function(StringRefNull name, Span< shader::metadata::ArgumentFormat > arguments, GPUFunctionDictionary *g_functions)
GPUType convert_type(shader::metadata::Type type)
void build(Vector< StringRefNull > &result, const shader::GeneratedSourceList &generated_sources, const GPUSourceDictionary &dict) const
void source_get(Vector< StringRefNull > &result, Vector< StringRefNull > &included, const shader::GeneratedSourceList &generated_sources, const GPUSourceDictionary &dict, const GPUSource &from) const
Vector< shader::ShaderCreateInfo::SharedVariable, 0 > shared_variables
shader::BuiltinBits builtins_get() const
void add_shared_variable(const shader::Type type, const StringRefNull name)
void add_dependency(StringRef line)
Vector< StringRef > dependencies_names
GPUFunctionQual convert_qualifier(shader::metadata::Qualifier qualifier)
int init_dependencies(const GPUSourceDictionary &dict)
void add_builtin(shader::metadata::Builtin builtin)
void add_printf_format(uint32_t format_hash, std::string format, GPUPrintFormatMap *format_map)
void print_error(const StringRef &input, int64_t offset, const StringRef message)
GPUSource(const char *path, const char *file, const char *datatoc, GPUFunctionDictionary *g_functions, GPUPrintFormatMap *g_formats, std::function< void(GPUSource &, GPUFunctionDictionary *, GPUPrintFormatMap *)> metadata_fn)