Blender V5.0
gpu_shader_dependency.cc File Reference
#include <algorithm>
#include <fmt/format.h>
#include <iomanip>
#include <iostream>
#include <regex>
#include <string>
#include "BLI_map.hh"
#include "BLI_string_ref.hh"
#include "CLG_log.h"
#include "gpu_capabilities_private.hh"
#include "gpu_material_library.hh"
#include "gpu_shader_create_info.hh"
#include "gpu_shader_dependency_private.hh"
#include "../glsl_preprocess/glsl_preprocess.hh"
#include "glsl_compositor_source_list.h"
#include "glsl_draw_source_list.h"
#include "glsl_gpu_source_list.h"
#include "glsl_ocio_source_list.h"
#include "glsl_compositor_metadata_list.hh"
#include "glsl_draw_metadata_list.hh"
#include "glsl_gpu_metadata_list.hh"
#include "glsl_ocio_metadata_list.hh"

Go to the source code of this file.

Classes

struct  blender::gpu::GPUSource

Namespaces

namespace  blender
namespace  blender::gpu
namespace  blender::gpu::shader

Macros

#define SHADER_SOURCE(filename_underscore, filename, filepath)
#define CLOG_FILE_INCLUDE(_from, _include)
#define SHADER_SOURCE(filename_underscore, filename, filepath)

Typedefs

using blender::gpu::GPUPrintFormatMap = Map<uint32_t, shader::PrintfFormat>
using blender::gpu::GPUSourceDictionary = Map<StringRef, GPUSource *>
using blender::gpu::GPUFunctionDictionary = Map<StringRef, GPUFunction *>

Functions

void gpu_shader_dependency_init ()
void gpu_shader_dependency_exit ()
GPUFunctiongpu_material_library_get_function (const char *name)
void gpu_material_library_use_function (blender::Set< blender::StringRefNull > &used_libraries, const char *name)
bool blender::gpu::shader::gpu_shader_dependency_force_gpu_print_injection ()
bool blender::gpu::shader::gpu_shader_dependency_has_printf ()
const PrintfFormatblender::gpu::shader::gpu_shader_dependency_get_printf_format (uint32_t format_hash)
BuiltinBits blender::gpu::shader::gpu_shader_dependency_get_builtins (const StringRefNull shader_source_name)
Vector< StringRefNullblender::gpu::shader::gpu_shader_dependency_get_resolved_source (const StringRefNull shader_source_name, const shader::GeneratedSourceList &generated_sources, const StringRefNull shader_name)
StringRefNull blender::gpu::shader::gpu_shader_dependency_get_source (const StringRefNull shader_source_name)
StringRefNull blender::gpu::shader::gpu_shader_dependency_get_filename_from_source_string (StringRef source_string)
 Find the name of the file from which the given string was generated.

Variables

static CLG_LogRef LOG = {"shader.dependencies"}
static GPUPrintFormatMapg_formats = nullptr
static GPUSourceDictionaryg_sources = nullptr
static GPUFunctionDictionaryg_functions = nullptr
static bool force_printf_injection = false

Detailed Description

Shader source dependency builder that make possible to support #include directive inside the shader files.

Definition in file gpu_shader_dependency.cc.

Macro Definition Documentation

◆ CLOG_FILE_INCLUDE

#define CLOG_FILE_INCLUDE ( _from,
_include )
Value:
if (CLOG_CHECK(&LOG, CLG_LEVEL_INFO) && (from).filename.c_str() != (_include).filename.c_str()) \
{ \
const char *from_filename = (_from).filename.c_str(); \
const char *include_filename = (_include).filename.c_str(); \
const int from_size = int((_from).source.size()); \
const int include_size = int((_include).source.size()); \
std::string link = fmt::format( \
"{}_{} --> {}_{}\n", from_filename, from_size, include_filename, include_size); \
std::string style = fmt::format("style {}_{} fill:#{:x}{:x}0\n", \
include_filename, \
include_size, \
min_uu(15, include_size / 1000), \
15 - min_uu(15, include_size / 1000)); \
CLG_log_raw(LOG.type, link.c_str()); \
CLG_log_raw(LOG.type, style.c_str()); \
}
MINLINE uint min_uu(uint a, uint b)
#define CLOG_CHECK(clg_ref, verbose_level,...)
Definition CLG_log.h:147
@ CLG_LEVEL_INFO
Definition CLG_log.h:60
#define LOG(level)
Definition log.h:97

Referenced by blender::gpu::GPUSource::source_get().

◆ SHADER_SOURCE [1/2]

#define SHADER_SOURCE ( filename_underscore,
filename,
filepath )
Value:
g_sources->add_new(filename, \
new GPUSource(filepath, \
filename, \
datatoc_##filename_underscore, \
blender::gpu::shader::metadata_##filename_underscore));
static GPUSourceDictionary * g_sources
static GPUPrintFormatMap * g_formats
static GPUFunctionDictionary * g_functions

Definition at line 37 of file gpu_shader_dependency.cc.

◆ SHADER_SOURCE [2/2]

#define SHADER_SOURCE ( filename_underscore,
filename,
filepath )
Value:
extern char datatoc_##filename_underscore[];

Definition at line 37 of file gpu_shader_dependency.cc.

Function Documentation

◆ gpu_material_library_get_function()

GPUFunction * gpu_material_library_get_function ( const char * name)

Definition at line 545 of file gpu_shader_dependency.cc.

References BLI_assert_msg, g_functions, and name.

Referenced by GPU_link(), and gpu_stack_link_v().

◆ gpu_material_library_use_function()

◆ gpu_shader_dependency_exit()

void gpu_shader_dependency_exit ( )

Definition at line 529 of file gpu_shader_dependency.cc.

References g_formats, g_functions, and g_sources.

Referenced by GPU_exit().

◆ gpu_shader_dependency_init()

Variable Documentation

◆ force_printf_injection

bool force_printf_injection = false
static

◆ g_formats

◆ g_functions

◆ g_sources

◆ LOG

CLG_LogRef LOG = {"shader.dependencies"}
static

Definition at line 49 of file gpu_shader_dependency.cc.