Blender  V3.3
Classes
gpu_codegen.cc File Reference
#include "MEM_guardedalloc.h"
#include "DNA_customdata_types.h"
#include "DNA_image_types.h"
#include "BLI_ghash.h"
#include "BLI_hash_mm2a.h"
#include "BLI_link_utils.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "PIL_time.h"
#include "BKE_material.h"
#include "GPU_capabilities.h"
#include "GPU_material.h"
#include "GPU_shader.h"
#include "GPU_uniform_buffer.h"
#include "GPU_vertex_format.h"
#include "BLI_sys_types.h"
#include "BLI_vector.hh"
#include "gpu_codegen.h"
#include "gpu_node_graph.h"
#include "gpu_shader_create_info.hh"
#include "gpu_shader_dependency_private.h"
#include <cstdarg>
#include <cstring>
#include <sstream>
#include <string>

Go to the source code of this file.

Classes

struct  GPUCodegenCreateInfo
 
struct  GPUCodegenCreateInfo::NameBuffer
 
struct  GPUPass
 
struct  GPUConstant
 
class  GPUCodegen
 

Functions

Type > string conversion
static std::ostream & operator<< (std::ostream &stream, const GPUInput *input)
 
static std::ostream & operator<< (std::ostream &stream, const GPUOutput *output)
 
static std::ostream & operator<< (std::ostream &stream, const GPUConstant *input)
 
GPUPass
GPUPassGPU_generate_pass (GPUMaterial *material, GPUNodeGraph *graph, GPUCodegenCallbackFn finalize_source_cb, void *thunk)
 
Compilation
static int count_active_texture_sampler (GPUPass *pass, GPUShader *shader)
 
static bool gpu_pass_shader_validate (GPUPass *pass, GPUShader *shader)
 
bool GPU_pass_compile (GPUPass *pass, const char *shname)
 
GPUShaderGPU_pass_shader_get (GPUPass *pass)
 
void GPU_pass_release (GPUPass *pass)
 
static void gpu_pass_free (GPUPass *pass)
 
void GPU_pass_cache_garbage_collect (void)
 
void GPU_pass_cache_init (void)
 
void GPU_pass_cache_free (void)
 
Module
void gpu_codegen_init (void)
 
void gpu_codegen_exit (void)
 

GPUPass Cache

Internal shader cache: This prevent the shader recompilation / stall when using undo/redo AND also allows for GPUPass reuse if the Shader code is the same for 2 different Materials. Unused GPUPasses are free by Garbage collection.

static GPUPasspass_cache = nullptr
 
static SpinLock pass_cache_spin
 
static GPUPassgpu_pass_cache_lookup (uint32_t hash)
 
static void gpu_pass_cache_insert_after (GPUPass *node, GPUPass *pass)
 
static GPUPassgpu_pass_cache_resolve_collision (GPUPass *pass, GPUShaderCreateInfo *info, uint32_t hash)
 
static bool gpu_pass_is_valid (GPUPass *pass)
 

Detailed Description

Convert material node-trees to GLSL.

Definition in file gpu_codegen.cc.

Function Documentation

◆ count_active_texture_sampler()

static int count_active_texture_sampler ( GPUPass pass,
GPUShader shader 
)
static

◆ gpu_codegen_exit()

void gpu_codegen_exit ( void  )

Definition at line 812 of file gpu_codegen.cc.

References BKE_material_defaults_free_gpu(), and GPU_shader_free_builtin_shaders().

Referenced by GPU_exit().

◆ gpu_codegen_init()

void gpu_codegen_init ( void  )

Definition at line 808 of file gpu_codegen.cc.

Referenced by GPU_init().

◆ GPU_generate_pass()

GPUPass* GPU_generate_pass ( GPUMaterial material,
GPUNodeGraph graph,
GPUCodegenCallbackFn  finalize_source_cb,
void thunk 
)

◆ GPU_pass_cache_free()

void GPU_pass_cache_free ( void  )

◆ GPU_pass_cache_garbage_collect()

void GPU_pass_cache_garbage_collect ( void  )

◆ GPU_pass_cache_init()

void GPU_pass_cache_init ( void  )

Definition at line 784 of file gpu_codegen.cc.

References BLI_spin_init(), and pass_cache_spin.

Referenced by WM_init_opengl().

◆ gpu_pass_cache_insert_after()

static void gpu_pass_cache_insert_after ( GPUPass node,
GPUPass pass 
)
static

◆ gpu_pass_cache_lookup()

static GPUPass* gpu_pass_cache_lookup ( uint32_t  hash)
static

Definition at line 112 of file gpu_codegen.cc.

References BLI_spin_lock(), BLI_spin_unlock(), hash, GPUPass::next, pass_cache, and pass_cache_spin.

Referenced by GPU_generate_pass().

◆ gpu_pass_cache_resolve_collision()

static GPUPass* gpu_pass_cache_resolve_collision ( GPUPass pass,
GPUShaderCreateInfo info,
uint32_t  hash 
)
static

◆ GPU_pass_compile()

bool GPU_pass_compile ( GPUPass pass,
const char *  shname 
)

◆ gpu_pass_free()

static void gpu_pass_free ( GPUPass pass)
static

◆ gpu_pass_is_valid()

static bool gpu_pass_is_valid ( GPUPass pass)
static

Definition at line 158 of file gpu_codegen.cc.

References GPUPass::compiled, and GPUPass::shader.

Referenced by GPU_generate_pass().

◆ GPU_pass_release()

void GPU_pass_release ( GPUPass pass)

◆ GPU_pass_shader_get()

GPUShader* GPU_pass_shader_get ( GPUPass pass)

◆ gpu_pass_shader_validate()

static bool gpu_pass_shader_validate ( GPUPass pass,
GPUShader shader 
)
static

◆ operator<<() [1/3]

static std::ostream& operator<< ( std::ostream &  stream,
const GPUConstant input 
)
static

Definition at line 206 of file gpu_codegen.cc.

References input, SNPRINTF, and type.

◆ operator<<() [2/3]

static std::ostream& operator<< ( std::ostream &  stream,
const GPUInput input 
)
static

◆ operator<<() [3/3]

static std::ostream& operator<< ( std::ostream &  stream,
const GPUOutput output 
)
static

Definition at line 196 of file gpu_codegen.cc.

References output.

Variable Documentation

◆ pass_cache

GPUPass* pass_cache = nullptr
static

◆ pass_cache_spin

SpinLock pass_cache_spin
static