Blender  V3.3
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
blender::gpu::GPUSource Struct Reference

Public Member Functions

 GPUSource (const char *path, const char *file, const char *datatoc, GPUFunctionDictionnary *g_functions)
 
void print_error (const StringRef &input, int64_t offset, const StringRef message)
 
void check_no_quotes ()
 
void quote_preprocess ()
 
void enum_preprocess ()
 
void material_functions_parse (GPUFunctionDictionnary *g_functions)
 
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)0
 
std::string processed_source
 

Detailed Description

Definition at line 39 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 
)
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

◆ 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 T97545)

Definition at line 185 of file gpu_shader_dependency.cc.

References blender::StringRefBase::find(), 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 251 of file gpu_shader_dependency.cc.

References CHECK, blender::StringRefBase::endswith(), filename, find_keyword, find_token, input, output, processed_source, rfind_token, and source.

Referenced by GPUSource().

◆ find_str()

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

Definition at line 119 of file gpu_shader_dependency.cc.

References ELEM, input, is_in_comment(), and offset.

◆ init_dependencies()

int blender::gpu::GPUSource::init_dependencies ( const GPUSourceDictionnary dict,
const GPUFunctionDictionnary g_functions 
)
inline

◆ is_from_material_library()

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

◆ is_in_comment()

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

Definition at line 112 of file gpu_shader_dependency.cc.

References input, and offset.

Referenced by check_no_quotes(), and find_str().

◆ material_functions_parse()

void blender::gpu::GPUSource::material_functions_parse ( GPUFunctionDictionnary g_functions)
inline

◆ print_error()

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

◆ 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 T97545) TODO(fclem): This could be done during the datatoc step.

Definition at line 206 of file gpu_shader_dependency.cc.

References blender::StringRefBase::find_first_of(), processed_source, and source.

Referenced by GPUSource().

Member Data Documentation

◆ builtins

shader::BuiltinBits blender::gpu::GPUSource::builtins = (shader::BuiltinBits)0

Definition at line 45 of file gpu_shader_dependency.cc.

Referenced by GPUSource().

◆ dependencies

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

Definition at line 43 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 44 of file gpu_shader_dependency.cc.

◆ filename

StringRefNull blender::gpu::GPUSource::filename

◆ fullpath

StringRefNull blender::gpu::GPUSource::fullpath

Definition at line 40 of file gpu_shader_dependency.cc.

Referenced by print_error().

◆ processed_source

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

Definition at line 46 of file gpu_shader_dependency.cc.

Referenced by enum_preprocess(), and quote_preprocess().

◆ source

StringRefNull blender::gpu::GPUSource::source

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