|
Blender
V2.93
|
#include "DNA_material_types.h"#include "DNA_object_types.h"#include "DNA_world_types.h"#include "BLI_dynstr.h"#include "BLI_listbase.h"#include "BLI_string_utils.h"#include "BLI_threads.h"#include "BKE_context.h"#include "BKE_global.h"#include "BKE_main.h"#include "DEG_depsgraph_query.h"#include "GPU_capabilities.h"#include "GPU_material.h"#include "GPU_shader.h"#include "WM_api.h"#include "WM_types.h"#include "wm_window.h"#include "draw_manager.h"Go to the source code of this file.
Classes | |
| struct | DRWDeferredShader |
| struct | DRWShaderCompiler |
| struct | DRWShaderLibrary |
Macros | |
| #define | USE_DEFERRED_COMPILATION 1 |
Variables | |
| char | datatoc_gpu_shader_2D_vert_glsl [] |
| char | datatoc_gpu_shader_3D_vert_glsl [] |
| char | datatoc_gpu_shader_depth_only_frag_glsl [] |
| char | datatoc_common_fullscreen_vert_glsl [] |
Shader Library | |
Simple include system for glsl files. Usage: Create a DRWShaderLibrary and add the library in the right order. You can have nested dependencies but each new library needs to have all its dependencies already added to the DRWShaderLibrary. Finally you can use DRW_shader_library_create_shader_string to get a shader string that also contains the needed libraries for this shader. | |
| #define | MAX_LIB 32 |
| #define | MAX_LIB_NAME 64 |
| #define | MAX_LIB_DEPS 8 |
| DRWShaderLibrary * | DRW_shader_library_create (void) |
| void | DRW_shader_library_free (DRWShaderLibrary *lib) |
| static int | drw_shader_library_search (const DRWShaderLibrary *lib, const char *name) |
| static uint32_t | drw_shader_dependencies_get (const DRWShaderLibrary *lib, const char *lib_code) |
| void | DRW_shader_library_add_file (DRWShaderLibrary *lib, char *lib_code, const char *lib_name) |
| char * | DRW_shader_library_create_shader_string (const DRWShaderLibrary *lib, const char *shader_code) |
Deferred Compilation (DRW_deferred) | |
| typedef struct DRWDeferredShader | DRWDeferredShader |
| typedef struct DRWShaderCompiler | DRWShaderCompiler |
| static void | drw_deferred_shader_free (DRWDeferredShader *dsh) |
| static void | drw_deferred_shader_queue_free (ListBase *queue) |
| static void | drw_deferred_shader_compilation_exec (void *custom_data, short *stop, short *do_update, float *progress) |
| static void | drw_deferred_shader_compilation_free (void *custom_data) |
| static void | drw_deferred_shader_add (GPUMaterial *mat, bool deferred) |
| void | DRW_deferred_shader_remove (GPUMaterial *mat) |
| GPUShader * | DRW_shader_create_ex (const char *vert, const char *geom, const char *frag, const char *defines, const char *name) |
| GPUShader * | DRW_shader_create_with_lib_ex (const char *vert, const char *geom, const char *frag, const char *lib, const char *defines, const char *name) |
| GPUShader * | DRW_shader_create_with_shaderlib_ex (const char *vert, const char *geom, const char *frag, const DRWShaderLibrary *lib, const char *defines, const char *name) |
| GPUShader * | DRW_shader_create_with_transform_feedback (const char *vert, const char *geom, const char *defines, const eGPUShaderTFBType prim_type, const char **varying_names, const int varying_count) |
| GPUShader * | DRW_shader_create_fullscreen_ex (const char *frag, const char *defines, const char *name) |
| GPUShader * | DRW_shader_create_fullscreen_with_shaderlib_ex (const char *frag, const DRWShaderLibrary *lib, const char *defines, const char *name) |
| GPUMaterial * | DRW_shader_find_from_world (World *wo, const void *engine_type, const int options, bool deferred) |
| GPUMaterial * | DRW_shader_find_from_material (Material *ma, const void *engine_type, const int options, bool deferred) |
| GPUMaterial * | DRW_shader_create_from_world (struct Scene *scene, World *wo, struct bNodeTree *ntree, const void *engine_type, const int options, const bool is_volume_shader, const char *vert, const char *geom, const char *frag_lib, const char *defines, bool deferred, GPUMaterialEvalCallbackFn callback) |
| GPUMaterial * | DRW_shader_create_from_material (struct Scene *scene, Material *ma, struct bNodeTree *ntree, const void *engine_type, const int options, const bool is_volume_shader, const char *vert, const char *geom, const char *frag_lib, const char *defines, bool deferred, GPUMaterialEvalCallbackFn callback) |
| void | DRW_shader_free (GPUShader *shader) |
| #define MAX_LIB 32 |
Definition at line 564 of file draw_manager_shader.c.
| #define MAX_LIB_DEPS 8 |
Definition at line 566 of file draw_manager_shader.c.
| #define MAX_LIB_NAME 64 |
Definition at line 565 of file draw_manager_shader.c.
| #define USE_DEFERRED_COMPILATION 1 |
Definition at line 54 of file draw_manager_shader.c.
| typedef struct DRWDeferredShader DRWDeferredShader |
| typedef struct DRWShaderCompiler DRWShaderCompiler |
|
static |
Definition at line 208 of file draw_manager_shader.c.
References BLI_addtail(), BLI_assert, BLI_movelisttolist(), BLI_mutex_init(), BLI_spin_init(), BLI_spin_lock(), BLI_spin_unlock(), DRWShaderCompiler::compilation_lock, CTX_wm_manager(), CTX_wm_window(), DEG_get_original_id(), DRWManager::draw_ctx, drw_deferred_shader_compilation_exec(), drw_deferred_shader_compilation_free(), DRW_deferred_shader_remove(), DRW_state_is_image_render(), DST, DRWContextState::evil_C, G, DRWManager::gl_context, DRWShaderCompiler::gl_context, DRWManager::gpu_context, DRWShaderCompiler::gpu_context, GPU_context_active_set(), GPU_context_create(), GPU_material_compile(), GPU_use_main_context_workaround(), Scene::id, DRWShaderCompiler::list_lock, DRWDeferredShader::mat, MEM_callocN, NC_MATERIAL, ND_SHADING_DRAW, NULL, DRWShaderCompiler::own_context, DRWShaderCompiler::queue, scene, DRWContextState::scene, USE_DEFERRED_COMPILATION, WM_JOB_PROGRESS, WM_JOB_TYPE_SHADER_COMPILATION, WM_jobs_callbacks(), WM_jobs_customdata_get(), WM_jobs_customdata_set(), WM_jobs_delay_start(), WM_jobs_get(), WM_jobs_start(), WM_jobs_timer(), WM_opengl_context_activate(), and WM_opengl_context_create().
Referenced by DRW_shader_create_from_material(), and DRW_shader_create_from_world().
|
static |
Definition at line 99 of file draw_manager_shader.c.
References BLI_addtail(), BLI_assert, BLI_listbase_count(), BLI_mutex_lock(), BLI_mutex_unlock(), BLI_poptail(), BLI_spin_lock(), BLI_spin_unlock(), DRWShaderCompiler::compilation_lock, drw_deferred_shader_free(), DST, float(), DRWManager::gl_context, DRWShaderCompiler::gl_context, DRWShaderCompiler::gpu_context, GPU_context_active_set(), GPU_context_main_lock(), GPU_context_main_unlock(), GPU_flush(), GPU_MAT_QUEUED, GPU_material_compile(), GPU_material_status(), GPU_use_main_context_workaround(), DRWShaderCompiler::list_lock, DRWDeferredShader::mat, DRWShaderCompiler::mat_compiling, NULL, DRWShaderCompiler::queue, DRWShaderCompiler::queue_conclude, DRWShaderCompiler::shaders_done, WM_opengl_context_activate(), and WM_opengl_context_release().
Referenced by drw_deferred_shader_add().
|
static |
Definition at line 175 of file draw_manager_shader.c.
References BLI_listbase_is_empty(), BLI_mutex_end(), BLI_poptail(), BLI_spin_end(), DRWShaderCompiler::compilation_lock, drw_deferred_shader_free(), drw_deferred_shader_queue_free(), DRW_opengl_context_disable_ex(), DRW_opengl_context_enable_ex(), DRWShaderCompiler::gl_context, DRWShaderCompiler::gpu_context, GPU_context_active_set(), GPU_context_discard(), GPU_material_compile(), DRWShaderCompiler::list_lock, DRWDeferredShader::mat, MEM_freeN, DRWShaderCompiler::own_context, DRWShaderCompiler::queue, DRWShaderCompiler::queue_conclude, WM_opengl_context_activate(), WM_opengl_context_dispose(), and wm_window_reset_drawable().
Referenced by drw_deferred_shader_add().
|
static |
Definition at line 85 of file draw_manager_shader.c.
References MEM_freeN.
Referenced by drw_deferred_shader_compilation_exec(), drw_deferred_shader_compilation_free(), drw_deferred_shader_queue_free(), and DRW_deferred_shader_remove().
|
static |
Definition at line 91 of file draw_manager_shader.c.
References BLI_pophead(), drw_deferred_shader_free(), and blender::compositor::queue.
Referenced by drw_deferred_shader_compilation_free().
| void DRW_deferred_shader_remove | ( | GPUMaterial * | mat | ) |
Definition at line 287 of file draw_manager_shader.c.
References BLI_findptr(), BLI_mutex_lock(), BLI_mutex_unlock(), BLI_remlink(), BLI_spin_lock(), BLI_spin_unlock(), DRWShaderCompiler::compilation_lock, drw_deferred_shader_free(), G_MAIN, GPU_material_scene(), DRWShaderCompiler::list_lock, LISTBASE_FOREACH, DRWDeferredShader::mat, DRWShaderCompiler::mat_compiling, NULL, DRWShaderCompiler::queue, scene, WM_JOB_PROGRESS, WM_JOB_TYPE_SHADER_COMPILATION, WM_jobs_customdata_get(), WM_jobs_get(), and WM_jobs_test().
Referenced by drw_deferred_shader_add().
| GPUShader* DRW_shader_create_ex | ( | const char * | vert, |
| const char * | geom, | ||
| const char * | frag, | ||
| const char * | defines, | ||
| const char * | name | ||
| ) |
Definition at line 332 of file draw_manager_shader.c.
References GPU_shader_create(), and NULL.
| GPUMaterial* DRW_shader_create_from_material | ( | struct Scene * | scene, |
| Material * | ma, | ||
| struct bNodeTree * | ntree, | ||
| const void * | engine_type, | ||
| const int | options, | ||
| const bool | is_volume_shader, | ||
| const char * | vert, | ||
| const char * | geom, | ||
| const char * | frag_lib, | ||
| const char * | defines, | ||
| bool | deferred, | ||
| GPUMaterialEvalCallbackFn | callback | ||
| ) |
Definition at line 502 of file draw_manager_shader.c.
References callback, DEG_get_original_id(), DRWManager::draw_ctx, drw_deferred_shader_add(), DRW_state_is_image_render(), DST, GPU_MAT_QUEUED, GPU_material_from_nodetree(), GPU_material_from_nodetree_find(), GPU_material_status(), Material::gpumaterial, Material::id, Scene::id, ID::name, ntree, NULL, options, scene, and DRWContextState::scene.
Referenced by eevee_material_get_ex().
| GPUMaterial* DRW_shader_create_from_world | ( | struct Scene * | scene, |
| World * | wo, | ||
| struct bNodeTree * | ntree, | ||
| const void * | engine_type, | ||
| const int | options, | ||
| const bool | is_volume_shader, | ||
| const char * | vert, | ||
| const char * | geom, | ||
| const char * | frag_lib, | ||
| const char * | defines, | ||
| bool | deferred, | ||
| GPUMaterialEvalCallbackFn | callback | ||
| ) |
Definition at line 460 of file draw_manager_shader.c.
References callback, DEG_get_original_id(), DRWManager::draw_ctx, drw_deferred_shader_add(), DRW_state_is_image_render(), DST, GPU_MAT_QUEUED, GPU_material_from_nodetree(), GPU_material_from_nodetree_find(), GPU_material_status(), World::gpumaterial, Scene::id, World::id, ID::name, ntree, NULL, options, scene, and DRWContextState::scene.
Referenced by eevee_material_get_ex().
| GPUShader* DRW_shader_create_fullscreen_ex | ( | const char * | frag, |
| const char * | defines, | ||
| const char * | name | ||
| ) |
Definition at line 406 of file draw_manager_shader.c.
References datatoc_common_fullscreen_vert_glsl, GPU_shader_create(), and NULL.
| GPUShader* DRW_shader_create_fullscreen_with_shaderlib_ex | ( | const char * | frag, |
| const DRWShaderLibrary * | lib, | ||
| const char * | defines, | ||
| const char * | name | ||
| ) |
Definition at line 411 of file draw_manager_shader.c.
References datatoc_common_fullscreen_vert_glsl, DRW_shader_library_create_shader_string(), GPU_shader_create(), lib, MEM_SAFE_FREE, and NULL.
| GPUShader* DRW_shader_create_with_lib_ex | ( | const char * | vert, |
| const char * | geom, | ||
| const char * | frag, | ||
| const char * | lib, | ||
| const char * | defines, | ||
| const char * | name | ||
| ) |
Definition at line 338 of file draw_manager_shader.c.
References BLI_string_joinN, GPU_shader_create(), lib, MEM_freeN, and NULL.
| GPUShader* DRW_shader_create_with_shaderlib_ex | ( | const char * | vert, |
| const char * | geom, | ||
| const char * | frag, | ||
| const DRWShaderLibrary * | lib, | ||
| const char * | defines, | ||
| const char * | name | ||
| ) |
Definition at line 367 of file draw_manager_shader.c.
References DRW_shader_library_create_shader_string(), GPU_shader_create(), lib, MEM_SAFE_FREE, and NULL.
| GPUShader* DRW_shader_create_with_transform_feedback | ( | const char * | vert, |
| const char * | geom, | ||
| const char * | defines, | ||
| const eGPUShaderTFBType | prim_type, | ||
| const char ** | varying_names, | ||
| const int | varying_count | ||
| ) |
Definition at line 388 of file draw_manager_shader.c.
References datatoc_gpu_shader_depth_only_frag_glsl, GPU_shader_create_ex(), and NULL.
Referenced by hair_refine_shader_get().
|
static |
Definition at line 600 of file draw_manager_shader.c.
References BLI_assert, drw_shader_library_search(), and lib.
Referenced by DRW_shader_library_add_file(), and DRW_shader_library_create_shader_string().
| GPUMaterial* DRW_shader_find_from_material | ( | Material * | ma, |
| const void * | engine_type, | ||
| const int | options, | ||
| bool | deferred | ||
| ) |
Definition at line 444 of file draw_manager_shader.c.
References DRW_state_is_image_render(), GPU_MAT_QUEUED, GPU_material_from_nodetree_find(), GPU_material_status(), Material::gpumaterial, NULL, and options.
Referenced by eevee_material_get_ex().
| GPUMaterial* DRW_shader_find_from_world | ( | World * | wo, |
| const void * | engine_type, | ||
| const int | options, | ||
| bool | deferred | ||
| ) |
Definition at line 428 of file draw_manager_shader.c.
References DRW_state_is_image_render(), GPU_MAT_QUEUED, GPU_material_from_nodetree_find(), GPU_material_status(), World::gpumaterial, NULL, and options.
Referenced by eevee_material_get_ex().
| void DRW_shader_free | ( | GPUShader * | shader | ) |
Definition at line 544 of file draw_manager_shader.c.
References GPU_shader_free(), and shader().
| void DRW_shader_library_add_file | ( | DRWShaderLibrary * | lib, |
| char * | lib_code, | ||
| const char * | lib_name | ||
| ) |
Definition at line 631 of file draw_manager_shader.c.
References BLI_assert, BLI_strncpy(), drw_shader_dependencies_get(), lib, DRWShaderLibrary::libs, DRWShaderLibrary::libs_deps, DRWShaderLibrary::libs_name, MAX_LIB, MAX_LIB_NAME, and NULL.
| DRWShaderLibrary* DRW_shader_library_create | ( | void | ) |
Definition at line 574 of file draw_manager_shader.c.
References MEM_callocN.
Referenced by eevee_shader_library_ensure(), IMAGE_shader_library_ensure(), OVERLAY_shader_library_ensure(), and workbench_shader_library_ensure().
| char* DRW_shader_library_create_shader_string | ( | const DRWShaderLibrary * | lib, |
| const char * | shader_code | ||
| ) |
Definition at line 654 of file draw_manager_shader.c.
References BLI_dynstr_append(), BLI_dynstr_free(), BLI_dynstr_get_cstring(), BLI_dynstr_new(), drw_shader_dependencies_get(), lib, DRWShaderLibrary::libs, DRWShaderLibrary::libs_deps, MAX_LIB, and str.
Referenced by DRW_shader_create_fullscreen_with_shaderlib_ex(), DRW_shader_create_with_shaderlib_ex(), eevee_get_frag(), eevee_get_geom(), eevee_get_vert(), eevee_shader_library_ensure(), workbench_shader_antialiasing_accumulation_get(), workbench_shader_cavity_get(), workbench_shader_composite_get(), workbench_shader_get_ex(), workbench_shader_merge_infront_get(), workbench_shader_outline_get(), and workbench_shader_volume_get().
| void DRW_shader_library_free | ( | DRWShaderLibrary * | lib | ) |
Definition at line 579 of file draw_manager_shader.c.
References lib, and MEM_SAFE_FREE.
|
static |
Definition at line 584 of file draw_manager_shader.c.
References lib, DRWShaderLibrary::libs, DRWShaderLibrary::libs_name, and MAX_LIB.
Referenced by drw_shader_dependencies_get().
|
extern |
Referenced by DRW_shader_create_fullscreen_ex(), and DRW_shader_create_fullscreen_with_shaderlib_ex().
|
extern |
|
extern |
|
extern |
Referenced by DRW_shader_create_with_transform_feedback().