|
Blender V4.3
|
#include "MEM_guardedalloc.h"#include "DNA_customdata_types.h"#include "DNA_image_types.h"#include "DNA_material_types.h"#include "BLI_ghash.h"#include "BLI_hash_mm2a.hh"#include "BLI_link_utils.h"#include "BLI_listbase.h"#include "BLI_string.h"#include "BLI_threads.h"#include "BLI_time.h"#include "BLI_utildefines.h"#include "BKE_cryptomatte.hh"#include "BKE_material.h"#include "GPU_capabilities.hh"#include "GPU_context.hh"#include "GPU_material.hh"#include "GPU_shader.hh"#include "GPU_uniform_buffer.hh"#include "GPU_vertex_format.hh"#include "BLI_sys_types.h"#include "BLI_vector.hh"#include "gpu_codegen.hh"#include "gpu_node_graph.hh"#include "gpu_shader_create_info.hh"#include "gpu_shader_dependency_private.hh"#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 |
Type > string conversion | |
| #define | SRC_NAME(io, list, link, type) type |
| 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 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 GPUPass * | pass_cache = nullptr |
| static SpinLock | pass_cache_spin |
| static GPUPass * | gpu_pass_cache_lookup (eGPUMaterialEngine engine, uint32_t hash) |
| static void | gpu_pass_cache_insert_after (GPUPass *node, GPUPass *pass) |
| static GPUPass * | gpu_pass_cache_resolve_collision (GPUPass *pass, GPUShaderCreateInfo *info, uint32_t hash) |
| static bool | gpu_pass_is_valid (const GPUPass *pass) |
Convert material node-trees to GLSL.
Definition in file gpu_codegen.cc.
| #define SRC_NAME | ( | io, | |
| list, | |||
| link, | |||
| type ) type |
Definition at line 199 of file gpu_codegen.cc.
Referenced by operator<<(), and operator<<().
Definition at line 831 of file gpu_codegen.cc.
References GPU_shader_get_uniform().
Referenced by gpu_pass_shader_validate().
| void gpu_codegen_exit | ( | ) |
Definition at line 1045 of file gpu_codegen.cc.
References BKE_material_defaults_free_gpu(), and GPU_shader_free_builtin_shaders().
Referenced by GPU_exit().
| void gpu_codegen_init | ( | ) |
Definition at line 1043 of file gpu_codegen.cc.
Referenced by GPU_init().
| GPUPass * GPU_generate_pass | ( | GPUMaterial * | material, |
| GPUNodeGraph * | graph, | ||
| eGPUMaterialEngine | engine, | ||
| GPUCodegenCallbackFn | finalize_source_cb, | ||
| void * | thunk, | ||
| bool | optimize_graph ) |
Cache lookup: Reuse shaders already compiled. NOTE: We only perform cache look-up for non-optimized shader graphs, as baked constant data among other optimizations will generate too many shader source permutations, with minimal re-usability.
Definition at line 705 of file gpu_codegen.cc.
References BLI_mutex_init(), BLI_spin_lock(), BLI_spin_unlock(), GPUCodegen::create_info, GPUCodegenOutput::create_info, blender::gpu::shader::ShaderCreateInfo::finalize(), GPUCodegen::generate_attribs(), GPUCodegen::generate_cryptomatte(), GPUCodegen::generate_graphs(), GPUCodegen::generate_library(), GPUCodegen::generate_resources(), GPUCodegen::generate_uniform_buffer(), gpu_node_graph_finalize_uniform_attrs(), gpu_node_graph_optimize(), gpu_node_graph_prune_unused(), gpu_pass_cache_insert_after(), gpu_pass_cache_lookup(), gpu_pass_cache_resolve_collision(), gpu_pass_is_valid(), GPUPass::hash, GPUCodegen::hash_get(), MEM_callocN, GPUPass::next, GPUCodegen::output, pass_cache_spin, GPUPass::refcount, and GPUCodegen::should_optimize_heuristic().
Referenced by GPU_material_from_callbacks(), GPU_material_from_nodetree(), and GPU_material_optimize().
| void GPU_pass_acquire | ( | GPUPass * | pass | ) |
Definition at line 976 of file gpu_codegen.cc.
References BLI_assert, BLI_spin_lock(), BLI_spin_unlock(), and pass_cache_spin.
Referenced by GPU_material_from_nodetree().
| bool GPU_pass_async_compilation_try_finalize | ( | GPUPass * | pass | ) |
NOTE: Unlike the non-async version, this one returns true when compilation has finalized, regardless if it succeeded or not. To check for success, see if GPU_pass_shader_get() != nullptr.
Definition at line 923 of file gpu_codegen.cc.
References BLI_assert, BLI_mutex_lock(), BLI_mutex_unlock(), GPU_pass_finalize_compilation(), GPU_shader_batch_finalize(), and GPU_shader_batch_is_ready().
Referenced by GPU_material_async_try_finalize().
| void GPU_pass_begin_async_compilation | ( | GPUPass * | pass, |
| const char * | shname ) |
Definition at line 905 of file gpu_codegen.cc.
References BLI_assert, BLI_mutex_lock(), BLI_mutex_unlock(), GPU_pass_begin_compilation(), and GPU_shader_batch_create_from_infos().
Referenced by GPU_material_async_compile().
| GPUShaderCreateInfo * GPU_pass_begin_compilation | ( | GPUPass * | pass, |
| const char * | shname ) |
Definition at line 873 of file gpu_codegen.cc.
Referenced by GPU_pass_begin_async_compilation(), and GPU_pass_compile().
| void GPU_pass_cache_free | ( | ) |
Definition at line 1024 of file gpu_codegen.cc.
References BLI_spin_end(), BLI_spin_lock(), BLI_spin_unlock(), gpu_pass_free(), GPUPass::next, next, pass_cache, and pass_cache_spin.
Referenced by WM_exit_ex().
| void GPU_pass_cache_garbage_collect | ( | ) |
Definition at line 996 of file gpu_codegen.cc.
References BLI_spin_lock(), BLI_spin_unlock(), BLI_time_now_seconds(), GPUPass::gc_timestamp, gpu_pass_free(), int, GPUPass::next, next, pass_cache, and pass_cache_spin.
Referenced by view3d_main_region_draw().
| void GPU_pass_cache_init | ( | ) |
Definition at line 1019 of file gpu_codegen.cc.
References BLI_spin_init(), and pass_cache_spin.
Referenced by WM_init_gpu().
Definition at line 146 of file gpu_codegen.cc.
References BLI_LINKS_PREPEND, BLI_spin_lock(), BLI_spin_unlock(), pass_cache, and pass_cache_spin.
Referenced by GPU_generate_pass().
|
static |
Definition at line 132 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().
|
static |
Definition at line 163 of file gpu_codegen.cc.
References BLI_spin_lock(), BLI_spin_unlock(), GPUPass::engine, hash, and pass_cache_spin.
Referenced by GPU_generate_pass().
| bool GPU_pass_compile | ( | GPUPass * | pass, |
| const char * | shname ) |
Definition at line 940 of file gpu_codegen.cc.
References BLI_mutex_lock(), BLI_mutex_unlock(), GPU_pass_begin_compilation(), GPU_pass_finalize_compilation(), GPU_shader_batch_finalize(), and GPU_shader_create_from_info().
Referenced by GPU_material_compile(), and GPU_material_optimize().
Definition at line 885 of file gpu_codegen.cc.
References gpu_pass_shader_validate(), and GPU_shader_free().
Referenced by GPU_pass_async_compilation_try_finalize(), and GPU_pass_compile().
|
static |
Definition at line 965 of file gpu_codegen.cc.
References BLI_assert, BLI_mutex_end(), GPU_shader_free(), and MEM_freeN().
Referenced by GPU_pass_cache_free(), GPU_pass_cache_garbage_collect(), and GPU_pass_release().
|
static |
Definition at line 182 of file gpu_codegen.cc.
Referenced by GPU_generate_pass().
| void GPU_pass_release | ( | GPUPass * | pass | ) |
Definition at line 984 of file gpu_codegen.cc.
References BLI_assert, BLI_spin_lock(), BLI_spin_unlock(), gpu_pass_free(), and pass_cache_spin.
Referenced by gpu_material_finalize(), GPU_material_free_single(), and GPU_material_optimize().
Definition at line 960 of file gpu_codegen.cc.
Referenced by DRW_shgroup_material_create(), drw_shgroup_material_create_ex(), GPU_material_async_try_finalize(), gpu_material_finalize(), GPU_material_from_callbacks(), GPU_material_from_nodetree(), GPU_material_get_shader(), GPU_material_get_shader_base(), GPU_material_optimize(), blender::draw::detail::PassBase< DrawCommandBufType >::material_set(), and blender::eevee::CapturePipeline::surface_material_add().
Definition at line 846 of file gpu_codegen.cc.
References count_active_texture_sampler(), GPU_max_textures(), GPU_max_textures_frag(), GPU_max_textures_geom(), and GPU_max_textures_vert().
Referenced by GPU_pass_finalize_compilation().
| bool GPU_pass_should_optimize | ( | GPUPass * | pass | ) |
Definition at line 816 of file gpu_codegen.cc.
References GPU_backend_get_type(), and GPU_BACKEND_METAL.
Referenced by GPU_material_from_nodetree().
|
static |
Definition at line 239 of file gpu_codegen.cc.
References SNPRINTF, and GPUInput::type.
|
static |
Definition at line 202 of file gpu_codegen.cc.
References BLI_assert, GPU_SOURCE_ATTR, GPU_SOURCE_CONSTANT, GPU_SOURCE_FUNCTION_CALL, GPU_SOURCE_LAYER_ATTR, GPU_SOURCE_OUTPUT, GPU_SOURCE_STRUCT, GPU_SOURCE_TEX, GPU_SOURCE_TEX_TILED_MAPPING, GPU_SOURCE_UNIFORM, GPU_SOURCE_UNIFORM_ATTR, and SRC_NAME.
|
static |
Definition at line 230 of file gpu_codegen.cc.
References SRC_NAME.
|
static |
Definition at line 127 of file gpu_codegen.cc.
Referenced by GPU_pass_cache_free(), GPU_pass_cache_garbage_collect(), gpu_pass_cache_insert_after(), and gpu_pass_cache_lookup().
|
static |
Definition at line 128 of file gpu_codegen.cc.
Referenced by GPU_generate_pass(), GPU_pass_acquire(), GPU_pass_cache_free(), GPU_pass_cache_garbage_collect(), GPU_pass_cache_init(), gpu_pass_cache_insert_after(), gpu_pass_cache_lookup(), gpu_pass_cache_resolve_collision(), and GPU_pass_release().