|
Blender
V2.93
|
#include "MEM_guardedalloc.h"#include "DNA_customdata_types.h"#include "DNA_image_types.h"#include "BLI_blenlib.h"#include "BLI_dynstr.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 "gpu_codegen.h"#include "gpu_material_library.h"#include "gpu_node_graph.h"#include <stdarg.h>#include <string.h>Go to the source code of this file.
Variables | |
| char | datatoc_gpu_shader_codegen_lib_glsl [] |
| char | datatoc_gpu_shader_common_obinfos_lib_glsl [] |
| static GPUPass * | pass_cache = NULL |
| static SpinLock | pass_cache_spin |
Convert material node-trees to GLSL.
Definition in file gpu_codegen.c.
|
static |
Definition at line 644 of file gpu_codegen.c.
References BLI_assert, CD_AUTO_FROM_NAME, CD_MCOL, CD_MTFACE, CD_ORCO, CD_PROP_COLOR, CD_TANGENT, and type.
Referenced by code_generate_vertex().
|
static |
Definition at line 519 of file gpu_codegen.c.
References BLI_dynstr_append(), BLI_dynstr_appendf(), BLI_dynstr_free(), BLI_dynstr_get_cstring(), BLI_dynstr_new(), BLI_gset_add(), BLI_gset_free(), BLI_gset_haskey(), BLI_gset_int_new(), codegen_call_functions(), codegen_declare_tmps(), codegen_final_output(), codegen_process_uniforms_functions(), codegen_set_unique_ids(), datatoc_gpu_shader_codegen_lib_glsl, datatoc_gpu_shader_common_obinfos_lib_glsl, G, G_DEBUG, GPU_BARYCENTRIC_TEXCO, GPU_CAMERA_TEXCO_FACTORS, GPU_INVERSE_LOC_TO_VIEW_MATRIX, GPU_INVERSE_OBJECT_MATRIX, GPU_INVERSE_VIEW_MATRIX, GPU_LOC_TO_VIEW_MATRIX, GPU_OBJECT_COLOR, GPU_OBJECT_INFO, GPU_OBJECT_MATRIX, GPU_VIEW_MATRIX, GPU_VIEW_NORMAL, GPU_VIEW_POSITION, GPU_WORLD_NORMAL, graph, LISTBASE_FOREACH, material, NULL, and POINTER_FROM_INT.
Referenced by GPU_generate_pass().
|
static |
Definition at line 779 of file gpu_codegen.c.
References BLI_dynstr_append(), BLI_dynstr_appendf(), BLI_dynstr_free(), BLI_dynstr_get_cstring(), BLI_dynstr_new(), datatoc_gpu_shader_codegen_lib_glsl, GPU_BARYCENTRIC_DIST, GPU_BARYCENTRIC_TEXCO, graph, LISTBASE_FOREACH, and NULL.
Referenced by GPU_generate_pass().
|
static |
Definition at line 666 of file gpu_codegen.c.
References BLI_dynstr_append(), BLI_dynstr_appendf(), BLI_dynstr_free(), BLI_dynstr_get_cstring(), BLI_dynstr_new(), BLI_listbase_is_empty(), GPU_BARYCENTRIC_DIST, GPU_BARYCENTRIC_TEXCO, gpu_data_type_to_string(), graph, LISTBASE_FOREACH, and NULL.
Referenced by GPU_generate_pass().
|
static |
Definition at line 694 of file gpu_codegen.c.
References attr_prefix_get(), BLI_dynstr_append(), BLI_dynstr_appendf(), BLI_dynstr_free(), BLI_dynstr_get_cstring(), BLI_dynstr_new(), CD_ORCO, CD_TANGENT, datatoc_gpu_shader_codegen_lib_glsl, datatoc_gpu_shader_common_obinfos_lib_glsl, G, G_DEBUG, GPU_BARYCENTRIC_DIST, GPU_BARYCENTRIC_TEXCO, gpu_data_type_to_string(), GPU_MAX_SAFE_ATTR_NAME, GPU_vertformat_safe_attr_name(), graph, and LISTBASE_FOREACH.
Referenced by GPU_generate_pass().
|
static |
Definition at line 414 of file gpu_codegen.c.
References BLI_dynstr_append(), BLI_dynstr_appendf(), codegen_convert_datatype(), GPU_BARYCENTRIC_DIST, GPU_BARYCENTRIC_TEXCO, gpu_builtin_name(), GPU_CAMERA_TEXCO_FACTORS, GPU_INVERSE_LOC_TO_VIEW_MATRIX, GPU_INVERSE_OBJECT_MATRIX, GPU_INVERSE_VIEW_MATRIX, GPU_LOC_TO_VIEW_MATRIX, GPU_OBJECT_COLOR, GPU_OBJECT_INFO, GPU_OBJECT_MATRIX, GPU_SOURCE_ATTR, GPU_SOURCE_BUILTIN, GPU_SOURCE_CONSTANT, GPU_SOURCE_OUTPUT, GPU_SOURCE_STRUCT, GPU_SOURCE_TEX, GPU_SOURCE_TEX_TILED_MAPPING, GPU_SOURCE_UNIFORM, GPU_SOURCE_UNIFORM_ATTR, GPU_SOURCE_VOLUME_GRID, GPU_SOURCE_VOLUME_GRID_TRANSFORM, GPU_VIEW_MATRIX, GPU_VIEW_NORMAL, GPU_VIEW_POSITION, GPU_WORLD_NORMAL, graph, LISTBASE_FOREACH, node, and output.
Referenced by code_generate_fragment().
|
static |
Definition at line 129 of file gpu_codegen.c.
References BLI_dynstr_append(), BLI_dynstr_appendf(), BLI_snprintf(), from, GPU_CLOSURE, GPU_FLOAT, GPU_VEC2, GPU_VEC3, and GPU_VEC4.
Referenced by codegen_call_functions().
|
static |
Definition at line 398 of file gpu_codegen.c.
References BLI_dynstr_append(), BLI_dynstr_appendf(), GPU_CLOSURE, gpu_data_type_to_string(), graph, LISTBASE_FOREACH, node, and output.
Referenced by code_generate_fragment().
Definition at line 514 of file gpu_codegen.c.
References BLI_dynstr_appendf(), and GPUOutput::id.
Referenced by code_generate_fragment().
Definition at line 201 of file gpu_codegen.c.
References BLI_dynstr_append(), BLI_dynstr_appendf(), data, gpu_data_type_to_string(), and type.
Referenced by codegen_process_uniforms_functions().
|
static |
It will create an UBO for GPUMaterial if there is any GPU_DYNAMIC_UBO.
Definition at line 300 of file gpu_codegen.c.
References BLI_addtail(), BLI_dynstr_append(), BLI_dynstr_appendf(), BLI_freelistN(), BLI_genericNodeN(), BLI_listbase_is_empty(), BLI_str_startswith(), codegen_print_datatype(), GPU_ATTRIBUTE_UBO_BLOCK_NAME, gpu_builtin_name(), gpu_data_type_to_string(), GPU_material_uniform_buffer_create(), GPU_SOURCE_BUILTIN, GPU_SOURCE_CONSTANT, GPU_SOURCE_STRUCT, GPU_SOURCE_UNIFORM, GPU_UBO_BLOCK_NAME, graph, GPUInput::id, LISTBASE_FOREACH, material, node, NULL, tex, and GPUInput::type.
Referenced by code_generate_fragment().
|
static |
Definition at line 280 of file gpu_codegen.c.
References graph, LISTBASE_FOREACH, node, and output.
Referenced by code_generate_fragment().
|
static |
Definition at line 941 of file gpu_codegen.c.
References BLI_gset_add(), BLI_gset_free(), BLI_gset_int_new(), BLI_str_startswith(), ELEM, GPU_shader_get_uniform(), gpu_str_skip_token(), NULL, POINTER_FROM_INT, and shader().
Referenced by gpu_pass_shader_validate().
|
static |
Definition at line 218 of file gpu_codegen.c.
References GPU_AUTO_BUMPSCALE, GPU_BARYCENTRIC_DIST, GPU_BARYCENTRIC_TEXCO, GPU_CAMERA_TEXCO_FACTORS, GPU_INVERSE_LOC_TO_VIEW_MATRIX, GPU_INVERSE_OBJECT_MATRIX, GPU_INVERSE_VIEW_MATRIX, GPU_LOC_TO_VIEW_MATRIX, GPU_OBJECT_COLOR, GPU_OBJECT_INFO, GPU_OBJECT_MATRIX, GPU_PARTICLE_ANG_VELOCITY, GPU_PARTICLE_LOCATION, GPU_PARTICLE_SCALAR_PROPS, GPU_PARTICLE_VELOCITY, GPU_VIEW_MATRIX, GPU_VIEW_NORMAL, GPU_VIEW_POSITION, and GPU_WORLD_NORMAL.
Referenced by codegen_call_functions(), and codegen_process_uniforms_functions().
| void gpu_codegen_exit | ( | void | ) |
Definition at line 1120 of file gpu_codegen.c.
References BKE_material_defaults_free_gpu(), and GPU_shader_free_builtin_shaders().
Referenced by GPU_exit().
| void gpu_codegen_init | ( | void | ) |
Definition at line 1116 of file gpu_codegen.c.
Referenced by GPU_init().
| GPUPass* GPU_generate_pass | ( | GPUMaterial * | material, |
| GPUNodeGraph * | graph, | ||
| const char * | vert_code, | ||
| const char * | geom_code, | ||
| const char * | frag_lib, | ||
| const char * | defines | ||
| ) |
Definition at line 839 of file gpu_codegen.c.
References BLI_LINKS_PREPEND, BLI_spin_lock(), BLI_spin_unlock(), BLI_strdup(), BLI_strdupcat(), code_generate_fragment(), code_generate_geometry(), code_generate_interface(), code_generate_vertex(), GPUPass::compiled, GPUPass::defines, GPUPass::fragmentcode, GPUPass::geometrycode, gpu_material_library_generate_code(), gpu_material_used_libraries(), gpu_node_graph_finalize_uniform_attrs(), gpu_node_graph_prune_unused(), gpu_pass_cache_lookup(), gpu_pass_cache_resolve_collision(), gpu_pass_hash(), gpu_pass_is_valid(), GPU_SOURCE_BUILTIN, graph, hash, GPUPass::hash, LISTBASE_FOREACH, material, MEM_callocN, MEM_freeN, MEM_SAFE_FREE, GPUPass::next, node, NULL, pass_cache, pass_cache_spin, GPUPass::refcount, GPUPass::shader, and GPUPass::vertexcode.
Referenced by GPU_material_from_nodetree().
| void GPU_pass_cache_free | ( | void | ) |
Definition at line 1101 of file gpu_codegen.c.
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 | ( | void | ) |
Definition at line 1068 of file gpu_codegen.c.
References BLI_spin_lock(), BLI_spin_unlock(), gpu_pass_free(), GPUPass::next, next, pass_cache, pass_cache_spin, and PIL_check_seconds_timer().
Referenced by view3d_main_region_draw().
| void GPU_pass_cache_init | ( | void | ) |
Definition at line 1096 of file gpu_codegen.c.
References BLI_spin_init(), and pass_cache_spin.
Referenced by WM_init_opengl().
Definition at line 89 of file gpu_codegen.c.
References BLI_spin_lock(), BLI_spin_unlock(), hash, GPUPass::next, NULL, pass_cache, and pass_cache_spin.
Referenced by GPU_generate_pass().
|
static |
Definition at line 104 of file gpu_codegen.c.
References BLI_spin_lock(), BLI_spin_unlock(), GPUPass::defines, GPUPass::fragmentcode, GPUPass::geometrycode, hash, GPUPass::hash, GPUPass::next, NULL, pass_cache_spin, STREQ, and GPUPass::vertexcode.
Referenced by GPU_generate_pass().
| bool GPU_pass_compile | ( | GPUPass * | pass, |
| const char * | shname | ||
| ) |
Definition at line 1025 of file gpu_codegen.c.
References GPUPass::compiled, GPUPass::defines, GPUPass::fragmentcode, GPUPass::geometrycode, gpu_pass_shader_validate(), GPU_shader_create(), GPU_shader_free(), NULL, shader(), GPUPass::shader, and GPUPass::vertexcode.
Referenced by GPU_material_compile().
|
static |
Definition at line 1055 of file gpu_codegen.c.
References BLI_assert, GPUPass::defines, GPUPass::fragmentcode, GPUPass::geometrycode, GPU_shader_free(), MEM_freeN, MEM_SAFE_FREE, GPUPass::refcount, GPUPass::shader, and GPUPass::vertexcode.
Referenced by GPU_pass_cache_free(), and GPU_pass_cache_garbage_collect().
|
static |
Definition at line 72 of file gpu_codegen.c.
References BLI_hash_mm2a_add(), BLI_hash_mm2a_end(), BLI_hash_mm2a_init(), and LISTBASE_FOREACH.
Referenced by GPU_generate_pass().
|
static |
Definition at line 833 of file gpu_codegen.c.
References GPUPass::compiled, NULL, and GPUPass::shader.
Referenced by GPU_generate_pass().
| void GPU_pass_release | ( | GPUPass * | pass | ) |
Definition at line 1049 of file gpu_codegen.c.
References BLI_assert, and GPUPass::refcount.
Referenced by GPU_material_compile(), and gpu_material_free_single().
Definition at line 826 of file gpu_codegen.c.
References GPUPass::shader.
Referenced by DRW_shgroup_material_create(), drw_shgroup_material_create_ex(), GPU_material_compile(), GPU_material_from_nodetree(), and GPU_material_get_shader().
Definition at line 994 of file gpu_codegen.c.
References count_active_texture_sampler(), GPUPass::fragmentcode, GPUPass::geometrycode, GPU_max_textures(), GPU_max_textures_frag(), GPU_max_textures_geom(), GPU_max_textures_vert(), NULL, shader(), and GPUPass::vertexcode.
Referenced by GPU_pass_compile().
|
extern |
Referenced by code_generate_fragment(), code_generate_geometry(), and code_generate_vertex().
|
extern |
Referenced by code_generate_fragment(), and code_generate_vertex().
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.
Definition at line 69 of file gpu_codegen.c.
Referenced by GPU_generate_pass(), GPU_pass_cache_free(), GPU_pass_cache_garbage_collect(), and gpu_pass_cache_lookup().
|
static |
Definition at line 70 of file gpu_codegen.c.
Referenced by GPU_generate_pass(), GPU_pass_cache_free(), GPU_pass_cache_garbage_collect(), GPU_pass_cache_init(), gpu_pass_cache_lookup(), and gpu_pass_cache_resolve_collision().