Blender V4.3
blender::gpu::GPUSource Struct Reference

Public Member Functions

 GPUSource (const char *path, const char *file, const char *datatoc, GPUFunctionDictionnary *g_functions, GPUPrintFormatMap *g_formats)
void print_error (const StringRef &input, int64_t offset, const StringRef message)
void check_no_quotes ()
void quote_preprocess ()
void small_types_check ()
void enum_preprocess ()
void material_functions_parse (GPUFunctionDictionnary *g_functions)
void char_literals_preprocess ()
void string_preprocess ()
void printf_preprocess (GPUPrintFormatMap *format_map)
int init_dependencies (const GPUSourceDictionnary &dict, const GPUFunctionDictionnary &g_functions)
void build (Vector< const char * > &result) const
shader::BuiltinBits builtins_get () const
bool is_from_material_library () const

Static Public Member Functions

static bool is_in_comment (const StringRef &input, int64_t offset)
template<bool check_whole_word = true, bool reversed = false, typename T>
static int64_t find_str (const StringRef &input, const T keyword, int64_t offset=0)

Public Attributes

StringRefNull fullpath
StringRefNull filename
StringRefNull source
Vector< GPUSource * > dependencies
bool dependencies_init = false
shader::BuiltinBits builtins = shader::BuiltinBits::NONE
std::string processed_source

Detailed Description

Definition at line 46 of file gpu_shader_dependency.cc.

Constructor & Destructor Documentation

◆ GPUSource()

blender::gpu::GPUSource::GPUSource ( const char * path,
const char * file,
const char * datatoc,
GPUFunctionDictionnary * g_functions,
GPUPrintFormatMap * g_formats )
inline

Member Function Documentation

◆ build()

void blender::gpu::GPUSource::build ( Vector< const char * > & result) const
inline

◆ builtins_get()

shader::BuiltinBits blender::gpu::GPUSource::builtins_get ( ) const
inline

◆ char_literals_preprocess()

void blender::gpu::GPUSource::char_literals_preprocess ( )
inline

◆ check_no_quotes()

void blender::gpu::GPUSource::check_no_quotes ( )
inline

Some drivers completely forbid quote characters even in unused preprocessor directives. We fix the cases where we can't manually patch in enum_preprocess(). This check ensure none are present in non-patched sources. (see #97545)

Definition at line 217 of file gpu_shader_dependency.cc.

References is_in_comment(), pos, print_error(), and source.

Referenced by GPUSource().

◆ enum_preprocess()

void blender::gpu::GPUSource::enum_preprocess ( )
inline

Transform C,C++ enum declaration into GLSL compatible defines and constants:

enum eMyEnum : uint32_t {
ENUM_1 = 0u,
ENUM_2 = 1u,
ENUM_3 = 2u,
};
unsigned int uint32_t
Definition stdint.h:80

or

enum eMyEnum {
ENUM_1 = 0u,
ENUM_2 = 1u,
ENUM_3 = 2u,
};

becomes

#define eMyEnum uint
const uint ENUM_1 = 0u, ENUM_2 = 1u, ENUM_3 = 2u;

IMPORTANT: This has some requirements:

  • Enums needs to have underlying types specified to uint32_t to make them usable in UBO/SSBO.
  • All values needs to be specified using constant literals to avoid compiler differences.
  • All values needs to have the 'u' suffix to avoid GLSL compiler errors.

Definition at line 322 of file gpu_shader_dependency.cc.

References CHECK, filename, blender::StringRefBase::find(), find_keyword, find_token, GPU_backend_get_type(), GPU_BACKEND_METAL, output, processed_source, rfind_token, source, and blender::StringRefBase::substr().

◆ find_str()

template<bool check_whole_word = true, bool reversed = false, typename T>
int64_t blender::gpu::GPUSource::find_str ( const StringRef & input,
const T keyword,
int64_t offset = 0 )
inlinestatic

◆ init_dependencies()

◆ is_from_material_library()

bool blender::gpu::GPUSource::is_from_material_library ( ) const
inline

Definition at line 1086 of file gpu_shader_dependency.cc.

References filename.

◆ is_in_comment()

bool blender::gpu::GPUSource::is_in_comment ( const StringRef & input,
int64_t offset )
inlinestatic

Definition at line 144 of file gpu_shader_dependency.cc.

References blender::StringRefBase::rfind().

Referenced by check_no_quotes(), and find_str().

◆ material_functions_parse()

◆ print_error()

void blender::gpu::GPUSource::print_error ( const StringRef & input,
int64_t offset,
const StringRef message )
inline

◆ printf_preprocess()

◆ quote_preprocess()

void blender::gpu::GPUSource::quote_preprocess ( )
inline

Some drivers completely forbid string characters even in unused preprocessor directives. This fixes the cases we cannot manually patch: Shared headers #includes. (see #97545) TODO(fclem): This could be done during the datatoc step.

Definition at line 238 of file gpu_shader_dependency.cc.

References processed_source, and source.

◆ small_types_check()

void blender::gpu::GPUSource::small_types_check ( )
inline

Assert not small types are present inside shader shared files.

Definition at line 253 of file gpu_shader_dependency.cc.

References find_keyword, print_error(), and source.

◆ string_preprocess()

Member Data Documentation

◆ builtins

shader::BuiltinBits blender::gpu::GPUSource::builtins = shader::BuiltinBits::NONE

◆ dependencies

Vector<GPUSource *> blender::gpu::GPUSource::dependencies

Definition at line 50 of file gpu_shader_dependency.cc.

Referenced by build(), builtins_get(), and init_dependencies().

◆ dependencies_init

bool blender::gpu::GPUSource::dependencies_init = false

Definition at line 51 of file gpu_shader_dependency.cc.

◆ filename

◆ fullpath

StringRefNull blender::gpu::GPUSource::fullpath

Definition at line 47 of file gpu_shader_dependency.cc.

Referenced by GPUSource(), and print_error().

◆ processed_source

std::string blender::gpu::GPUSource::processed_source

◆ source


The documentation for this struct was generated from the following file: