Blender V4.3
gpu_shader.cc File Reference
#include "MEM_guardedalloc.h"
#include "BLI_math_matrix.h"
#include "BLI_string.h"
#include "BLI_string_utils.hh"
#include "GPU_capabilities.hh"
#include "GPU_debug.hh"
#include "GPU_matrix.hh"
#include "GPU_platform.hh"
#include "gpu_backend.hh"
#include "gpu_context_private.hh"
#include "gpu_shader_create_info.hh"
#include "gpu_shader_create_info_private.hh"
#include "gpu_shader_dependency_private.hh"
#include "gpu_shader_private.hh"
#include <string>

Go to the source code of this file.

Namespaces

namespace  blender
 
namespace  blender::gpu
 

Functions

Creation / Destruction
static void standard_defines (Vector< const char * > &sources)
 
GPUShaderGPU_shader_create_ex (const char *vertcode, const char *fragcode, const char *geomcode, const char *computecode, const char *libcode, const char *defines, const eGPUShaderTFBType tf_type, const char **tf_names, const int tf_count, const char *shname)
 
void GPU_shader_free (GPUShader *shader)
 
Creation utils
GPUShaderGPU_shader_create (const char *vertcode, const char *fragcode, const char *geomcode, const char *libcode, const char *defines, const char *shname)
 
GPUShaderGPU_shader_create_compute (const char *computecode, const char *libcode, const char *defines, const char *shname)
 
const GPUShaderCreateInfo * GPU_shader_create_info_get (const char *info_name)
 
void GPU_shader_create_info_get_unfinalized_copy (const char *info_name, GPUShaderCreateInfo &r_info)
 
bool GPU_shader_create_info_check_error (const GPUShaderCreateInfo *_info, char r_error[128])
 
GPUShaderGPU_shader_create_from_info_name (const char *info_name)
 
GPUShaderGPU_shader_create_from_info (const GPUShaderCreateInfo *_info)
 
GPUShaderGPU_shader_create_from_python (const char *vertcode, const char *fragcode, const char *geomcode, const char *libcode, const char *defines, const char *name)
 
BatchHandle GPU_shader_batch_create_from_infos (Span< const GPUShaderCreateInfo * > infos)
 
bool GPU_shader_batch_is_ready (BatchHandle handle)
 
Vector< GPUShader * > GPU_shader_batch_finalize (BatchHandle &handle)
 
void GPU_shader_compile_static ()
 
void GPU_shader_cache_dir_clear_old ()
 
Binding
void GPU_shader_bind (GPUShader *gpu_shader)
 
void GPU_shader_unbind ()
 
GPUShaderGPU_shader_get_bound ()
 
Shader name
const char * GPU_shader_get_name (GPUShader *shader)
 
Shader cache warming
void GPU_shader_set_parent (GPUShader *shader, GPUShader *parent)
 
void GPU_shader_warm_cache (GPUShader *shader, int limit)
 
Transform feedback

TODO(fclem): Should be replaced by compute shaders.

bool GPU_shader_transform_feedback_enable (GPUShader *shader, blender::gpu::VertBuf *vertbuf)
 
void GPU_shader_transform_feedback_disable (GPUShader *shader)
 
Assign specialization constants.
void GPU_shader_constant_int_ex (GPUShader *sh, int location, int value)
 
void GPU_shader_constant_uint_ex (GPUShader *sh, int location, uint value)
 
void GPU_shader_constant_float_ex (GPUShader *sh, int location, float value)
 
void GPU_shader_constant_bool_ex (GPUShader *sh, int location, bool value)
 
void GPU_shader_constant_int (GPUShader *sh, const char *name, int value)
 
void GPU_shader_constant_uint (GPUShader *sh, const char *name, uint value)
 
void GPU_shader_constant_float (GPUShader *sh, const char *name, float value)
 
void GPU_shader_constant_bool (GPUShader *sh, const char *name, bool value)
 
SpecializationBatchHandle GPU_shader_batch_specializations (blender::Span< ShaderSpecialization > specializations)
 
bool GPU_shader_batch_specializations_is_ready (SpecializationBatchHandle &handle)
 
Uniforms / Resource location
int GPU_shader_get_uniform (GPUShader *shader, const char *name)
 
int GPU_shader_get_constant (GPUShader *shader, const char *name)
 
int GPU_shader_get_builtin_uniform (GPUShader *shader, int builtin)
 
int GPU_shader_get_builtin_block (GPUShader *shader, int builtin)
 
int GPU_shader_get_ssbo_binding (GPUShader *shader, const char *name)
 
int GPU_shader_get_uniform_block (GPUShader *shader, const char *name)
 
int GPU_shader_get_ubo_binding (GPUShader *shader, const char *name)
 
int GPU_shader_get_sampler_binding (GPUShader *shader, const char *name)
 
uint GPU_shader_get_attribute_len (const GPUShader *shader)
 
int GPU_shader_get_attribute (const GPUShader *shader, const char *name)
 
bool GPU_shader_get_attribute_info (const GPUShader *shader, int attr_location, char r_name[256], int *r_type)
 
Getters
int GPU_shader_get_program (GPUShader *shader)
 
int GPU_shader_get_ssbo_vertex_fetch_num_verts_per_prim (GPUShader *shader)
 
bool GPU_shader_uses_ssbo_vertex_fetch (GPUShader *shader)
 
Uniforms setters
void GPU_shader_uniform_float_ex (GPUShader *shader, int loc, int len, int array_size, const float *value)
 
void GPU_shader_uniform_int_ex (GPUShader *shader, int loc, int len, int array_size, const int *value)
 
void GPU_shader_uniform_1i (GPUShader *sh, const char *name, int value)
 
void GPU_shader_uniform_1b (GPUShader *sh, const char *name, bool value)
 
void GPU_shader_uniform_2f (GPUShader *sh, const char *name, float x, float y)
 
void GPU_shader_uniform_3f (GPUShader *sh, const char *name, float x, float y, float z)
 
void GPU_shader_uniform_4f (GPUShader *sh, const char *name, float x, float y, float z, float w)
 
void GPU_shader_uniform_1f (GPUShader *sh, const char *name, float value)
 
void GPU_shader_uniform_2fv (GPUShader *sh, const char *name, const float data[2])
 
void GPU_shader_uniform_3fv (GPUShader *sh, const char *name, const float data[3])
 
void GPU_shader_uniform_4fv (GPUShader *sh, const char *name, const float data[4])
 
void GPU_shader_uniform_2iv (GPUShader *sh, const char *name, const int data[2])
 
void GPU_shader_uniform_mat4 (GPUShader *sh, const char *name, const float data[4][4])
 
void GPU_shader_uniform_mat3_as_mat4 (GPUShader *sh, const char *name, const float data[3][3])
 
void GPU_shader_uniform_1f_array (GPUShader *sh, const char *name, int len, const float *val)
 
void GPU_shader_uniform_2fv_array (GPUShader *sh, const char *name, int len, const float(*val)[2])
 
void GPU_shader_uniform_4fv_array (GPUShader *sh, const char *name, int len, const float(*val)[4])
 

Variables

char datatoc_gpu_shader_colorspace_lib_glsl []
 
sRGB Rendering Workaround

The viewport overlay frame-buffer is sRGB and will expect shaders to output display referred Linear colors. But other frame-buffers (i.e: the area frame-buffers) are not sRGB and require the shader output color to be in sRGB space (assumed display encoded color-space as the time of writing). For this reason we have a uniform to switch the transform on and off depending on the current frame-buffer color-space.

static int blender::gpu::g_shader_builtin_srgb_transform = 0
 
static bool blender::gpu::g_shader_builtin_srgb_is_dirty = false
 

Function Documentation

◆ GPU_shader_batch_create_from_infos()

BatchHandle GPU_shader_batch_create_from_infos ( blender::Span< const GPUShaderCreateInfo * > infos)

Request the creation of multiple shaders at once, allowing the backend to use multithreaded compilation. Returns a handle that can be used to poll if all shaders have been compiled, and to retrieve the compiled shaders. NOTE: This function is asynchronous on OpenGL, but it's blocking on Vulkan and Metal. WARNING: The GPUShaderCreateInfo pointers should be valid until GPU_shader_batch_finalize has returned.

Definition at line 336 of file gpu_shader.cc.

References blender::gpu::ShaderCompiler::batch_compile(), blender::gpu::Context::compiler, and blender::gpu::Context::get().

Referenced by GPU_pass_begin_async_compilation(), and blender::eevee::ShaderModule::ShaderModule().

◆ GPU_shader_batch_finalize()

Vector< GPUShader * > GPU_shader_batch_finalize ( BatchHandle & handle)

Retrieve the compiled shaders, in the same order as the GPUShaderCreateInfos. If the compilation has not finished yet, this call will block the thread until all the shaders are ready. Shaders with compilation errors are returned as null pointers. WARNING: The handle will be invalidated by this call, you can't request the same batch twice.

Definition at line 349 of file gpu_shader.cc.

References blender::gpu::ShaderCompiler::batch_finalize(), blender::gpu::Context::compiler, blender::gpu::Context::get(), and result.

Referenced by GPU_pass_async_compilation_try_finalize(), GPU_pass_compile(), and blender::eevee::ShaderModule::is_ready().

◆ GPU_shader_batch_is_ready()

bool GPU_shader_batch_is_ready ( BatchHandle handle)

Returns true if all the shaders from the batch have finished their compilation.

Definition at line 344 of file gpu_shader.cc.

References blender::gpu::ShaderCompiler::batch_is_ready(), blender::gpu::Context::compiler, and blender::gpu::Context::get().

Referenced by GPU_pass_async_compilation_try_finalize(), and blender::eevee::ShaderModule::is_ready().

◆ GPU_shader_batch_specializations()

SpecializationBatchHandle GPU_shader_batch_specializations ( blender::Span< ShaderSpecialization > specializations)

Request the compilation of multiple specialization constant variations at once, allowing the backend to use multi-threaded compilation. Returns a handle that can be used to poll if all variations have been compiled. A NULL handle indicates no compilation of any variant was possible (likely due to some state being currently available) and so no batch was created. Compilation of the specialized variant will instead occur at draw/dispatch time. NOTE: This function is asynchronous on OpenGL and Metal and a no-op on Vulkan. Batches are processed one by one in FIFO order. WARNING: Binding a specialization before the batch finishes will fail.

Definition at line 534 of file gpu_shader.cc.

References blender::gpu::Context::compiler, blender::gpu::Context::get(), and blender::gpu::ShaderCompiler::precompile_specializations().

Referenced by blender::eevee::ShaderModule::precompile_specializations().

◆ GPU_shader_batch_specializations_is_ready()

bool GPU_shader_batch_specializations_is_ready ( SpecializationBatchHandle & handle)

Returns true if all the specializations from the batch have finished their compilation. NOTE: Polling this function is required for the compilation process to keep progressing. WARNING: Invalidates the handle if it returns true.

Definition at line 540 of file gpu_shader.cc.

References blender::gpu::Context::compiler, blender::gpu::Context::get(), and blender::gpu::ShaderCompiler::specialization_batch_is_ready().

Referenced by blender::eevee::ShaderModule::is_ready().

◆ GPU_shader_bind()

void GPU_shader_bind ( GPUShader * shader)

Set the given shader as active shader for the active GPU context. It replaces any already bound shader. All following draw-calls and dispatches will use this shader. Uniform functions need to have the shader bound in order to work. (TODO: until we use glProgramUniform)

Definition at line 372 of file gpu_shader.cc.

References blender::gpu::Shader::bind(), blender::gpu::Context::get(), GPU_matrix_bind(), GPU_matrix_dirty_get(), GPU_SHADER_PRINTF_SLOT, GPU_storagebuf_bind(), blender::gpu::Context::printf_buf, blender::gpu::Context::shader, and blender::gpu::unwrap().

Referenced by blender::realtime_compositor::apply_morphological_operator(), blender::nodes::node_composite_glare_cc::GlareOperation::apply_streak_filter(), blender::draw::command::DrawMultiBuf::bind(), BlenderFallbackDisplayShader::bind(), blender::realtime_compositor::blend_neighborhood(), blender::realtime_compositor::blur_pass(), blender::realtime_compositor::BokehKernel::BokehKernel(), blender::realtime_compositor::calculate_blending_weights(), blender::nodes::node_composite_movieclip_cc::MovieClipOperation::compute_alpha(), blender::nodes::node_composite_glare_cc::GlareOperation::compute_base_ghost(), blender::nodes::node_composite_glare_cc::GlareOperation::compute_bloom_downsample_chain(), blender::nodes::node_composite_double_edge_mask_cc::DoubleEdgeMaskOperation::compute_boundary(), blender::realtime_compositor::compute_complete_blocks(), blender::realtime_compositor::compute_complete_x_prologues(), blender::realtime_compositor::compute_complete_y_prologues(), blender::nodes::node_composite_defocus_cc::DefocusOperation::compute_defocus_radius_from_depth(), blender::nodes::node_composite_defocus_cc::DefocusOperation::compute_defocus_radius_from_scale(), blender::nodes::node_composite_double_edge_mask_cc::DoubleEdgeMaskOperation::compute_gradient(), blender::nodes::node_composite_base_cryptomatte_cc::BaseCryptoMatteOperation::compute_image(), blender::nodes::node_composite_keying_cc::KeyingOperation::compute_image(), blender::nodes::node_composite_movieclip_cc::MovieClipOperation::compute_image(), blender::realtime_compositor::compute_incomplete_prologues(), blender::nodes::node_composite_inpaint_cc::InpaintOperation::compute_inpainting_boundary(), blender::nodes::node_composite_inpaint_cc::InpaintOperation::compute_inpainting_region(), blender::nodes::node_composite_zcombine_cc::ZCombineOperation::compute_mask(), blender::nodes::node_composite_base_cryptomatte_cc::BaseCryptoMatteOperation::compute_matte(), blender::nodes::node_composite_keying_cc::KeyingOperation::compute_matte(), blender::nodes::node_composite_vec_blur_cc::VectorBlurOperation::compute_max_tile_velocity(), blender::nodes::node_composite_vec_blur_cc::VectorBlurOperation::compute_motion_blur(), blender::nodes::node_composite_base_cryptomatte_cc::BaseCryptoMatteOperation::compute_pick(), blender::nodes::node_composite_cornerpin_cc::CornerPinOperation::compute_plane(), blender::nodes::node_composite_planetrackdeform_cc::PlaneTrackDeformOperation::compute_plane(), blender::nodes::node_composite_cornerpin_cc::CornerPinOperation::compute_plane_mask(), blender::nodes::node_composite_planetrackdeform_cc::PlaneTrackDeformOperation::compute_plane_mask(), blender::realtime_compositor::compute_preview_from_result(), blender::draw::View::compute_procedural_bounds(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::compute_structure_tensor(), blender::nodes::node_composite_keying_cc::KeyingOperation::compute_tweaked_matte(), blender::draw::View::compute_visibility(), blender::realtime_compositor::detect_edges(), blender::nodes::node_composite_vec_blur_cc::VectorBlurOperation::dilate_max_velocity(), draw_filled_lasso(), draw_shgroup(), blender::draw::draw_subdiv_accumulate_normals(), blender::draw::draw_subdiv_build_edge_fac_buffer(), blender::draw::draw_subdiv_build_edituv_stretch_angle_buffer(), blender::draw::draw_subdiv_build_edituv_stretch_area_buffer(), blender::draw::draw_subdiv_build_fdots_buffers(), blender::draw::draw_subdiv_build_lines_buffer(), blender::draw::draw_subdiv_build_lines_loose_buffer(), blender::draw::draw_subdiv_build_lnor_buffer(), blender::draw::draw_subdiv_build_sculpt_data_buffer(), blender::draw::draw_subdiv_build_tris_buffer(), blender::draw::draw_subdiv_extract_pos_nor(), blender::draw::draw_subdiv_extract_uvs(), blender::draw::draw_subdiv_finalize_custom_normals(), blender::draw::draw_subdiv_finalize_normals(), blender::draw::draw_subdiv_interp_custom_data(), blender::gpu::GLImmediate::end(), blender::gpu::MTLImmediate::end(), blender::draw::Manager::end_sync(), blender::draw::command::ShaderBind::execute(), blender::nodes::node_composite_bilateralblur_cc::BilateralBlurOperation::execute(), blender::nodes::node_composite_boxmask_cc::BoxMaskOperation::execute(), blender::nodes::node_composite_defocus_cc::DefocusOperation::execute(), blender::nodes::node_composite_despeckle_cc::DespeckleOperation::execute(), blender::nodes::node_composite_directionalblur_cc::DirectionalBlurOperation::execute(), blender::nodes::node_composite_displace_cc::DisplaceOperation::execute(), blender::nodes::node_composite_ellipsemask_cc::EllipseMaskOperation::execute(), blender::nodes::node_composite_filter_cc::FilterOperation::execute(), blender::nodes::node_composite_flip_cc::FlipOperation::execute(), blender::nodes::node_composite_id_mask_cc::IDMaskOperation::execute(), blender::nodes::node_composite_map_uv_cc::MapUVOperation::execute(), blender::nodes::node_composite_moviedistortion_cc::MovieDistortionOperation::execute(), blender::nodes::node_composite_normalize_cc::NormalizeOperation::execute(), blender::nodes::node_composite_pixelate_cc::PixelateOperation::execute(), blender::nodes::node_composite_split_cc::SplitOperation::execute(), blender::nodes::node_composite_sunbeams_cc::SunBeamsOperation::execute(), blender::realtime_compositor::ConversionOperation::execute(), blender::realtime_compositor::ShaderOperation::execute(), blender::nodes::node_composite_crop_cc::CropOperation::execute_alpha_crop(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::execute_anisotropic(), blender::nodes::node_composite_zcombine_cc::ZCombineOperation::execute_anti_aliased(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_bloom(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::execute_classic(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::execute_classic_summed_area_table(), blender::nodes::node_composite_blur_cc::BlurOperation::execute_constant_size(), blender::nodes::node_composite_bokehblur_cc::BokehBlurOperation::execute_constant_size(), blender::nodes::node_composite_composite_cc::CompositeOperation::execute_copy_gpu(), blender::nodes::node_composite_viewer_cc::ViewerOperation::execute_copy_gpu(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::execute_distance_threshold(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_ghost(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_highlights(), blender::nodes::node_composite_composite_cc::CompositeOperation::execute_ignore_alpha_gpu(), blender::nodes::node_composite_viewer_cc::ViewerOperation::execute_ignore_alpha_gpu(), blender::nodes::node_composite_crop_cc::CropOperation::execute_image_crop(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_mix(), blender::nodes::node_composite_render_layer_cc::RenderLayerOperation::execute_pass(), blender::nodes::node_composite_tonemap_cc::ToneMapOperation::execute_photoreceptor(), blender::nodes::node_composite_lensdist_cc::LensDistortionOperation::execute_projector_distortion(), blender::nodes::node_composite_lensdist_cc::LensDistortionOperation::execute_screen_distortion(), blender::nodes::node_composite_composite_cc::CompositeOperation::execute_set_alpha_gpu(), blender::nodes::node_composite_viewer_cc::ViewerOperation::execute_set_alpha_gpu(), blender::nodes::node_composite_tonemap_cc::ToneMapOperation::execute_simple(), blender::nodes::node_composite_zcombine_cc::ZCombineOperation::execute_simple(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_axis_aligned(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_diagonal(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_diagonal_pass(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_horizontal_pass(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::execute_step_horizontal_pass(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::execute_step_vertical_pass(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_streaks(), blender::nodes::node_composite_blur_cc::BlurOperation::execute_variable_size(), blender::nodes::node_composite_bokehblur_cc::BokehBlurOperation::execute_variable_size(), blender::nodes::node_composite_scale_cc::ScaleOperation::execute_variable_size(), blender::realtime_compositor::extract_alpha_gpu(), blender::nodes::node_composite_keying_cc::KeyingOperation::extract_input_chroma(), blender::nodes::node_composite_inpaint_cc::InpaintOperation::fill_inpainting_region(), blender::ed::seq::StripsDrawBatch::flush_batch(), ThumbsDrawBatch::flush_batch(), GPU_batch_bind_as_resources(), GPU_batch_draw(), GPU_batch_draw_instance_range(), GPU_batch_draw_range(), GPU_batch_set_shader(), GPU_compute_dispatch(), GPU_compute_dispatch_indirect(), GPU_indexbuf_build_curves_on_device(), GPU_shader_get_builtin_shader_with_config(), blender::realtime_compositor::horizontal_pass(), blender::realtime_compositor::horizontal_pass(), blender::realtime_compositor::horizontal_pass(), immBindShader(), blender::gpu::tests::Shader::init_shader(), blender::realtime_compositor::jump_flooding_pass(), blender::realtime_compositor::KeyingScreen::KeyingScreen(), blender::realtime_compositor::maximum_float(), blender::realtime_compositor::maximum_float_in_range(), blender::realtime_compositor::maximum_luminance(), blender::realtime_compositor::minimum_float(), blender::realtime_compositor::minimum_float_in_range(), blender::realtime_compositor::minimum_luminance(), blender::realtime_compositor::morphological_distance(), pygpu_batch_program_use_begin(), pygpu_shader_bind(), pygpu_shader_image(), pygpu_shader_uniform_block(), pygpu_shader_uniform_bool(), pygpu_shader_uniform_float(), pygpu_shader_uniform_int(), pygpu_shader_uniform_sampler(), pygpu_shader_uniform_vector_float(), pygpu_shader_uniform_vector_int(), blender::realtime_compositor::realize_on_domain(), blender::render::hydra::ViewportEngine::render(), blender::nodes::node_composite_keying_cc::KeyingOperation::replace_input_chroma(), blender::realtime_compositor::sum_blue(), blender::realtime_compositor::sum_blue_squared_difference(), blender::realtime_compositor::sum_causal_and_non_causal_results(), blender::realtime_compositor::sum_causal_and_non_causal_results(), blender::realtime_compositor::sum_color(), blender::realtime_compositor::sum_green(), blender::realtime_compositor::sum_green_squared_difference(), blender::realtime_compositor::sum_log_luminance(), blender::realtime_compositor::sum_luminance(), blender::realtime_compositor::sum_luminance_squared_difference(), blender::realtime_compositor::sum_red(), blender::realtime_compositor::sum_red_squared_difference(), blender::gpu::tests::test_buffer_texture(), blender::gpu::tests::test_compute_direct(), blender::gpu::tests::test_compute_indirect(), blender::gpu::tests::test_shader_compute_1d(), blender::gpu::tests::test_shader_compute_2d(), blender::gpu::tests::test_shader_compute_ibo(), blender::gpu::tests::test_shader_compute_ssbo(), blender::gpu::tests::test_shader_compute_vbo(), blender::realtime_compositor::vertical_pass(), blender::realtime_compositor::vertical_pass(), blender::realtime_compositor::vertical_pass(), and wm_draw_region_blend().

◆ GPU_shader_cache_dir_clear_old()

void GPU_shader_cache_dir_clear_old ( )

◆ GPU_shader_compile_static()

void GPU_shader_compile_static ( )

Compile all statically defined shaders and print a report to the console.

This is used for platform support, where bug reports can list all failing shaders.

Definition at line 355 of file gpu_shader.cc.

References gpu_shader_create_info_compile(), and printf.

Referenced by WM_init_gpu().

◆ GPU_shader_constant_bool()

void GPU_shader_constant_bool ( GPUShader * sh,
const char * name,
bool value )

◆ GPU_shader_constant_bool_ex()

void GPU_shader_constant_bool_ex ( GPUShader * sh,
int location,
bool value )

◆ GPU_shader_constant_float()

void GPU_shader_constant_float ( GPUShader * sh,
const char * name,
float value )

◆ GPU_shader_constant_float_ex()

void GPU_shader_constant_float_ex ( GPUShader * sh,
int location,
float value )

◆ GPU_shader_constant_int()

void GPU_shader_constant_int ( GPUShader * sh,
const char * name,
int value )

◆ GPU_shader_constant_int_ex()

void GPU_shader_constant_int_ex ( GPUShader * sh,
int location,
int value )

◆ GPU_shader_constant_uint()

void GPU_shader_constant_uint ( GPUShader * sh,
const char * name,
uint value )

◆ GPU_shader_constant_uint_ex()

void GPU_shader_constant_uint_ex ( GPUShader * sh,
int location,
uint value )

◆ GPU_shader_create()

GPUShader * GPU_shader_create ( const char * vertcode,
const char * fragcode,
const char * geomcode,
const char * libcode,
const char * defines,
const char * shname )

Definition at line 223 of file gpu_shader.cc.

References GPU_shader_create_ex(), and GPU_SHADER_TFB_NONE.

◆ GPU_shader_create_compute()

GPUShader * GPU_shader_create_compute ( const char * computecode,
const char * libcode,
const char * defines,
const char * shname )

◆ GPU_shader_create_ex()

GPUShader * GPU_shader_create_ex ( const char * vertcode,
const char * fragcode,
const char * geomcode,
const char * computecode,
const char * libcode,
const char * defines,
const eGPUShaderTFBType tf_type,
const char ** tf_names,
const int tf_count,
const char * shname )

◆ GPU_shader_create_from_info()

◆ GPU_shader_create_from_info_name()

GPUShader * GPU_shader_create_from_info_name ( const char * info_name)

Create a shader using a named #GPUShaderCreateInfo registered at startup. These are declared inside *_info.hh files using the GPU_SHADER_CREATE_INFO() macro. They are also expected to have been flagged using do_static_compilation. Can return a null pointer if compilation fails.

Definition at line 283 of file gpu_shader.cc.

References blender::StringRefNull::c_str(), blender::gpu::shader::ShaderCreateInfo::do_static_compilation_, GPU_shader_create_from_info(), gpu_shader_create_info_get(), and blender::gpu::shader::ShaderCreateInfo::name_.

Referenced by BASIC_shaders_curves_depth_sh_get(), BASIC_shaders_depth_conservative_sh_get(), BASIC_shaders_depth_sh_get(), BASIC_shaders_pointcloud_depth_conservative_sh_get(), BASIC_shaders_pointcloud_depth_sh_get(), compile_fallback_shader(), DRW_shader_debug_draw_display_get(), DRW_shader_debug_print_display_get(), DRW_shader_draw_command_generate_get(), DRW_shader_draw_resource_finalize_get(), DRW_shader_draw_view_finalize_get(), DRW_shader_draw_visibility_compute_get(), external_engine_init(), blender::workbench::StaticShader::get(), GPENCIL_shader_antialiasing(), GPENCIL_shader_depth_merge_get(), GPENCIL_shader_fx_blur_get(), GPENCIL_shader_fx_colorize_get(), GPENCIL_shader_fx_composite_get(), GPENCIL_shader_fx_glow_get(), GPENCIL_shader_fx_pixelize_get(), GPENCIL_shader_fx_rim_get(), GPENCIL_shader_fx_shadow_get(), GPENCIL_shader_fx_transform_get(), GPENCIL_shader_geometry_get(), GPENCIL_shader_layer_blend_get(), GPENCIL_shader_mask_invert_get(), GPU_shader_get_builtin_shader_with_config(), hair_refine_shader_compute_create(), blender::draw::image_engine::IMAGE_shader_depth_get(), blender::draw::image_engine::IMAGE_shader_image_get(), blender::gpu::tests::Shader::init_shader(), blender::gpu::tests::ShaderSpecializationConst::init_shader(), OVERLAY_shader_antialiasing(), OVERLAY_shader_armature_degrees_of_freedom_solid(), OVERLAY_shader_armature_degrees_of_freedom_wire(), OVERLAY_shader_armature_envelope(), OVERLAY_shader_armature_shape(), OVERLAY_shader_armature_shape_wire(), OVERLAY_shader_armature_sphere(), OVERLAY_shader_armature_stick(), OVERLAY_shader_armature_wire(), OVERLAY_shader_background(), OVERLAY_shader_clipbound(), OVERLAY_shader_depth_only(), OVERLAY_shader_edit_curve_handle(), OVERLAY_shader_edit_curve_point(), OVERLAY_shader_edit_curve_wire(), OVERLAY_shader_edit_curves_handle(), OVERLAY_shader_edit_gpencil_guide_point(), OVERLAY_shader_edit_gpencil_point(), OVERLAY_shader_edit_gpencil_wire(), OVERLAY_shader_edit_lattice_point(), OVERLAY_shader_edit_lattice_wire(), OVERLAY_shader_edit_mesh_analysis(), OVERLAY_shader_edit_mesh_depth(), OVERLAY_shader_edit_mesh_edge(), OVERLAY_shader_edit_mesh_face(), OVERLAY_shader_edit_mesh_facedot(), OVERLAY_shader_edit_mesh_normal(), OVERLAY_shader_edit_mesh_skin_root(), OVERLAY_shader_edit_mesh_vert(), OVERLAY_shader_edit_particle_point(), OVERLAY_shader_edit_particle_strand(), OVERLAY_shader_edit_uv_edges_for_edge_select_get(), OVERLAY_shader_edit_uv_edges_get(), OVERLAY_shader_edit_uv_face_dots_get(), OVERLAY_shader_edit_uv_face_get(), OVERLAY_shader_edit_uv_mask_image(), OVERLAY_shader_edit_uv_stencil_image(), OVERLAY_shader_edit_uv_stretching_angle_get(), OVERLAY_shader_edit_uv_stretching_area_get(), OVERLAY_shader_edit_uv_tiled_image_borders_get(), OVERLAY_shader_edit_uv_verts_get(), OVERLAY_shader_extra(), OVERLAY_shader_extra_grid(), OVERLAY_shader_extra_groundline(), OVERLAY_shader_extra_loose_point(), OVERLAY_shader_extra_point(), OVERLAY_shader_extra_wire(), OVERLAY_shader_facing(), OVERLAY_shader_gpencil_canvas(), OVERLAY_shader_grid(), OVERLAY_shader_grid_background(), OVERLAY_shader_grid_image(), OVERLAY_shader_image(), OVERLAY_shader_motion_path_line(), OVERLAY_shader_motion_path_vert(), OVERLAY_shader_outline_detect(), OVERLAY_shader_outline_prepass(), OVERLAY_shader_outline_prepass_curves(), OVERLAY_shader_outline_prepass_gpencil(), OVERLAY_shader_outline_prepass_pointcloud(), OVERLAY_shader_paint_face(), OVERLAY_shader_paint_point(), OVERLAY_shader_paint_texture(), OVERLAY_shader_paint_vertcol(), OVERLAY_shader_paint_weight(), OVERLAY_shader_paint_wire(), OVERLAY_shader_particle_dot(), OVERLAY_shader_particle_shape(), OVERLAY_shader_sculpt_curves_cage(), OVERLAY_shader_sculpt_curves_selection(), OVERLAY_shader_sculpt_mask(), OVERLAY_shader_uniform_color(), OVERLAY_shader_uniform_color_pointcloud(), OVERLAY_shader_viewer_attribute_curve(), OVERLAY_shader_viewer_attribute_curves(), OVERLAY_shader_viewer_attribute_mesh(), OVERLAY_shader_viewer_attribute_pointcloud(), OVERLAY_shader_volume_gridlines(), OVERLAY_shader_volume_velocity(), OVERLAY_shader_wireframe(), OVERLAY_shader_wireframe_select(), OVERLAY_shader_xray_fade(), blender::eevee::Precompute::Precompute(), select_debug_engine_init(), select_engine_init(), blender::eevee::ShaderModule::static_shader_get(), blender::gpu::tests::test_buffer_texture(), blender::gpu::tests::test_compute_direct(), blender::gpu::tests::test_compute_indirect(), blender::draw::test_eevee_shadow_finalize(), blender::draw::test_eevee_shadow_free(), blender::draw::test_eevee_shadow_page_mask_ex(), blender::draw::test_eevee_shadow_shift(), blender::draw::test_eevee_shadow_shift_clear(), blender::draw::test_eevee_shadow_tag_update(), blender::draw::test_eevee_shadow_tilemap_amend(), blender::draw::test_eevee_surfel_list(), blender::gpu::tests::test_shader_compute_1d(), blender::gpu::tests::test_shader_compute_2d(), blender::gpu::tests::test_shader_compute_ibo(), blender::gpu::tests::test_shader_compute_ssbo(), blender::gpu::tests::test_shader_compute_vbo(), blender::gpu::tests::test_shader_ssbo_binding(), blender::draw::TestAlloc::TestAlloc(), and blender::draw::TestDefrag::TestDefrag().

◆ GPU_shader_create_from_python()

GPUShader * GPU_shader_create_from_python ( const char * vertcode,
const char * fragcode,
const char * geomcode,
const char * libcode,
const char * defines,
const char * name )

◆ GPU_shader_create_info_check_error()

bool GPU_shader_create_info_check_error ( const GPUShaderCreateInfo * _info,
char r_error[128] )

Error checking for user created shaders.

Returns
true is create info is valid.

Definition at line 270 of file gpu_shader.cc.

References BLI_strncpy(), blender::gpu::shader::ShaderCreateInfo::check_error(), and error().

Referenced by pygpu_shader_create_from_info().

◆ GPU_shader_create_info_get()

const GPUShaderCreateInfo * GPU_shader_create_info_get ( const char * info_name)

Fetch a named #GPUShaderCreateInfo registered at startup. These are declared inside *_info.hh files using the GPU_SHADER_CREATE_INFO() macro. Can return a null pointer if no match is found.

Definition at line 259 of file gpu_shader.cc.

References gpu_shader_create_info_get().

Referenced by blender::realtime_compositor::CachedShader::CachedShader(), and blender::eevee::ShaderModule::ShaderModule().

◆ GPU_shader_create_info_get_unfinalized_copy()

void GPU_shader_create_info_get_unfinalized_copy ( const char * info_name,
GPUShaderCreateInfo & r_info )

Definition at line 264 of file gpu_shader.cc.

References gpu_shader_create_info_get_unfinalized_copy().

◆ GPU_shader_free()

void GPU_shader_free ( GPUShader * shader)

Definition at line 212 of file gpu_shader.cc.

References blender::gpu::unwrap().

Referenced by blender::gpu::MTLContextTextureUtils::cleanup(), BlenderFallbackDisplayShader::destroy_shader(), DRW_shader_free(), blender::draw::DRW_subdiv_free(), GPU_pass_finalize_compilation(), gpu_pass_free(), gpu_shader_create_info_compile(), GPU_shader_free_builtin_shaders(), blender::gpu::tests::gpu_shader_lib_test(), blender::eevee::Precompute::Precompute(), pygpu_shader__tp_dealloc(), blender::gpu::tests::test_buffer_texture(), blender::gpu::tests::test_compute_direct(), blender::gpu::tests::test_compute_indirect(), blender::draw::test_eevee_shadow_finalize(), blender::draw::test_eevee_shadow_free(), blender::draw::test_eevee_shadow_page_mask_ex(), blender::draw::test_eevee_shadow_shift(), blender::draw::test_eevee_shadow_shift_clear(), blender::draw::test_eevee_shadow_tag_update(), blender::draw::test_eevee_shadow_tilemap_amend(), blender::draw::test_eevee_surfel_list(), blender::gpu::tests::test_framebuffer_multi_viewport(), blender::gpu::tests::test_framebuffer_subpass_input(), blender::gpu::tests::test_shader_compute_1d(), blender::gpu::tests::test_shader_compute_2d(), blender::gpu::tests::test_shader_compute_ibo(), blender::gpu::tests::test_shader_compute_ssbo(), blender::gpu::tests::test_shader_compute_vbo(), blender::gpu::tests::test_shader_ssbo_binding(), blender::draw::TestAlloc::TestAlloc(), blender::draw::TestDefrag::TestDefrag(), blender::realtime_compositor::CachedShader::~CachedShader(), OCIO_GPUShader::~OCIO_GPUShader(), blender::gpu::tests::Shader::~Shader(), and blender::gpu::tests::ShaderSpecializationConst::~ShaderSpecializationConst().

◆ GPU_shader_get_attribute()

int GPU_shader_get_attribute ( const GPUShader * shader,
const char * name )

◆ GPU_shader_get_attribute_info()

bool GPU_shader_get_attribute_info ( const GPUShader * shader,
int attr_location,
char r_name[256],
int * r_type )

Definition at line 618 of file gpu_shader.cc.

References BLI_strncpy().

Referenced by GPU_vertformat_from_shader(), and pygpu_shader_attrs_info_get().

◆ GPU_shader_get_attribute_len()

uint GPU_shader_get_attribute_len ( const GPUShader * shader)

◆ GPU_shader_get_bound()

GPUShader * GPU_shader_get_bound ( )

Return the currently bound shader to the active GPU context.

Returns
null pointer if no shader is bound of if no context is active.

Definition at line 415 of file gpu_shader.cc.

References blender::gpu::Context::get(), blender::gpu::Context::shader, and blender::gpu::wrap().

Referenced by BlenderDisplaySpaceShader::bind(), and BlenderDisplaySpaceShader::get_shader_program().

◆ GPU_shader_get_builtin_block()

int GPU_shader_get_builtin_block ( GPUShader * shader,
int builtin )

DEPRECATED: Use hard-coded buffer location instead.

Definition at line 571 of file gpu_shader.cc.

References blender::gpu::ShaderInterface::ubo_builtin().

Referenced by drw_shgroup_init().

◆ GPU_shader_get_builtin_uniform()

int GPU_shader_get_builtin_uniform ( GPUShader * shader,
int builtin )

TODO: To be moved as private API. Not really used outside of gpu_matrix.cc and doesn't really offer a noticeable performance boost.

Definition at line 565 of file gpu_shader.cc.

References blender::gpu::ShaderInterface::uniform_builtin().

Referenced by drw_shgroup_init(), GPU_matrix_bind(), immUniformColor4f(), blender::gpu::Shader::set_srgb_uniform(), and wm_draw_region_blend().

◆ GPU_shader_get_constant()

◆ GPU_shader_get_name()

const char * GPU_shader_get_name ( GPUShader * shader)

◆ GPU_shader_get_program()

int GPU_shader_get_program ( GPUShader * shader)

DEPRECATED: Kept only because of BGL API.

Definition at line 641 of file gpu_shader.cc.

References blender::gpu::unwrap().

Referenced by pygpu_shader_program_get().

◆ GPU_shader_get_sampler_binding()

int GPU_shader_get_sampler_binding ( GPUShader * shader,
const char * name )

Definition at line 598 of file gpu_shader.cc.

References tex.

Referenced by blender::realtime_compositor::SMAAPrecomputedTextures::bind_area_texture(), blender::realtime_compositor::Result::bind_as_image(), blender::realtime_compositor::DistortionGrid::bind_as_texture(), blender::realtime_compositor::KeyingScreen::bind_as_texture(), blender::realtime_compositor::Result::bind_as_texture(), blender::realtime_compositor::SymmetricBlurWeights::bind_as_texture(), blender::realtime_compositor::SymmetricSeparableBlurWeights::bind_as_texture(), blender::realtime_compositor::MorphologicalDistanceFeatherWeights::bind_distance_falloffs_as_texture(), blender::draw::detail::PassBase< DrawCommandBufType >::bind_image(), blender::draw::detail::PassBase< DrawCommandBufType >::bind_image(), blender::realtime_compositor::SMAAPrecomputedTextures::bind_search_texture(), blender::draw::detail::PassBase< DrawCommandBufType >::bind_texture(), blender::draw::detail::PassBase< DrawCommandBufType >::bind_texture(), blender::draw::detail::PassBase< DrawCommandBufType >::bind_texture(), blender::draw::detail::PassBase< DrawCommandBufType >::bind_texture(), blender::realtime_compositor::MorphologicalDistanceFeatherWeights::bind_weights_as_texture(), blender::nodes::node_composite_movieclip_cc::MovieClipOperation::compute_alpha(), blender::nodes::node_composite_movieclip_cc::MovieClipOperation::compute_image(), blender::nodes::node_composite_base_cryptomatte_cc::BaseCryptoMatteOperation::compute_matte(), blender::nodes::node_composite_base_cryptomatte_cc::BaseCryptoMatteOperation::compute_pick(), blender::render::hydra::DrawTexture::draw(), DRW_shgroup_buffer_texture(), DRW_shgroup_buffer_texture_ref(), DRW_shgroup_uniform_image(), DRW_shgroup_uniform_image_ref(), DRW_shgroup_uniform_texture_ex(), DRW_shgroup_uniform_texture_ref_ex(), blender::nodes::node_composite_render_layer_cc::RenderLayerOperation::execute_pass(), immBindTexture(), immBindTextureSampler(), blender::realtime_compositor::KeyingScreen::KeyingScreen(), blender::realtime_compositor::parallel_reduction_dispatch(), pygpu_shader_image(), pygpu_shader_uniform_sampler(), blender::gpu::tests::test_buffer_texture(), blender::gpu::tests::test_compute_direct(), blender::gpu::tests::test_compute_indirect(), blender::gpu::tests::test_shader_compute_1d(), blender::gpu::tests::test_shader_compute_2d(), ThumbsDrawBatch::ThumbsDrawBatch(), and wm_draw_region_blend().

◆ GPU_shader_get_ssbo_binding()

int GPU_shader_get_ssbo_binding ( GPUShader * shader,
const char * name )

Definition at line 577 of file gpu_shader.cc.

References blender::gpu::ShaderInput::location.

Referenced by blender::draw::command::DrawMultiBuf::bind(), blender::gpu::tests::Shader::bind(), blender::draw::detail::PassBase< DrawCommandBufType >::bind_ssbo(), blender::draw::detail::PassBase< DrawCommandBufType >::bind_ssbo(), blender::draw::detail::PassBase< DrawCommandBufType >::bind_ssbo(), blender::draw::detail::PassBase< DrawCommandBufType >::bind_ssbo(), blender::draw::detail::PassBase< DrawCommandBufType >::bind_ssbo(), blender::draw::detail::PassBase< DrawCommandBufType >::bind_ssbo(), blender::draw::detail::PassBase< DrawCommandBufType >::bind_ssbo(), blender::draw::detail::PassBase< DrawCommandBufType >::bind_ssbo(), blender::nodes::node_composite_vec_blur_cc::VectorBlurOperation::compute_motion_blur(), blender::draw::View::compute_procedural_bounds(), blender::draw::View::compute_visibility(), blender::nodes::node_composite_vec_blur_cc::VectorBlurOperation::dilate_max_velocity(), DRW_shgroup_storage_block_ex(), DRW_shgroup_storage_block_ref_ex(), DRW_shgroup_vertex_buffer_ex(), DRW_shgroup_vertex_buffer_ref_ex(), blender::draw::Manager::end_sync(), GPU_indexbuf_build_curves_on_device(), blender::realtime_compositor::KeyingScreen::KeyingScreen(), blender::gpu::tests::ShaderSpecializationConst::ShaderSpecializationConst(), blender::gpu::tests::test_buffer_texture(), blender::gpu::tests::test_shader_compute_ibo(), blender::gpu::tests::test_shader_compute_ssbo(), blender::gpu::tests::test_shader_compute_vbo(), and blender::gpu::tests::test_shader_ssbo_binding().

◆ GPU_shader_get_ssbo_vertex_fetch_num_verts_per_prim()

int GPU_shader_get_ssbo_vertex_fetch_num_verts_per_prim ( GPUShader * shader)

SSBO Vertex-fetch is used as an alternative path to geometry shaders wherein the vertex count is expanded up-front. This function fetches the number of specified output vertices per input primitive.

Definition at line 646 of file gpu_shader.cc.

References blender::gpu::unwrap().

Referenced by blender::draw::command::DrawMultiBuf::bind().

◆ GPU_shader_get_ubo_binding()

◆ GPU_shader_get_uniform()

◆ GPU_shader_get_uniform_block()

int GPU_shader_get_uniform_block ( GPUShader * shader,
const char * name )

DEPRECATED: Kept only because of Python GPU API.

Definition at line 584 of file gpu_shader.cc.

References blender::gpu::ShaderInput::location.

Referenced by pygpu_shader_uniform_block_from_name().

◆ GPU_shader_set_parent()

void GPU_shader_set_parent ( GPUShader * shader,
GPUShader * parent )

◆ GPU_shader_transform_feedback_disable()

void GPU_shader_transform_feedback_disable ( GPUShader * shader)

Definition at line 470 of file gpu_shader.cc.

References blender::gpu::unwrap().

Referenced by draw_shgroup().

◆ GPU_shader_transform_feedback_enable()

bool GPU_shader_transform_feedback_enable ( GPUShader * shader,
blender::gpu::VertBuf * vertbuf )

Returns true if transform feedback was successfully enabled.

Definition at line 465 of file gpu_shader.cc.

References blender::gpu::unwrap().

Referenced by draw_update_uniforms().

◆ GPU_shader_unbind()

void GPU_shader_unbind ( )

Unbind the active shader.

Note
this is a no-op in release builds. But it make sense to actually do it in user land code to detect incorrect API usage.

Definition at line 404 of file gpu_shader.cc.

References blender::gpu::Context::get(), blender::gpu::Context::shader, and blender::gpu::Shader::unbind().

Referenced by blender::realtime_compositor::apply_morphological_operator(), blender::nodes::node_composite_glare_cc::GlareOperation::apply_streak_filter(), blender::realtime_compositor::blend_neighborhood(), blender::realtime_compositor::blur_pass(), blender::realtime_compositor::BokehKernel::BokehKernel(), blender::realtime_compositor::calculate_blending_weights(), blender::nodes::node_composite_movieclip_cc::MovieClipOperation::compute_alpha(), blender::nodes::node_composite_glare_cc::GlareOperation::compute_base_ghost(), blender::nodes::node_composite_glare_cc::GlareOperation::compute_bloom_downsample_chain(), blender::nodes::node_composite_double_edge_mask_cc::DoubleEdgeMaskOperation::compute_boundary(), blender::realtime_compositor::compute_complete_blocks(), blender::realtime_compositor::compute_complete_x_prologues(), blender::realtime_compositor::compute_complete_y_prologues(), blender::nodes::node_composite_defocus_cc::DefocusOperation::compute_defocus_radius_from_depth(), blender::nodes::node_composite_defocus_cc::DefocusOperation::compute_defocus_radius_from_scale(), blender::nodes::node_composite_double_edge_mask_cc::DoubleEdgeMaskOperation::compute_gradient(), blender::nodes::node_composite_base_cryptomatte_cc::BaseCryptoMatteOperation::compute_image(), blender::nodes::node_composite_keying_cc::KeyingOperation::compute_image(), blender::nodes::node_composite_movieclip_cc::MovieClipOperation::compute_image(), blender::realtime_compositor::compute_incomplete_prologues(), blender::nodes::node_composite_inpaint_cc::InpaintOperation::compute_inpainting_boundary(), blender::nodes::node_composite_inpaint_cc::InpaintOperation::compute_inpainting_region(), blender::nodes::node_composite_zcombine_cc::ZCombineOperation::compute_mask(), blender::nodes::node_composite_base_cryptomatte_cc::BaseCryptoMatteOperation::compute_matte(), blender::nodes::node_composite_keying_cc::KeyingOperation::compute_matte(), blender::nodes::node_composite_vec_blur_cc::VectorBlurOperation::compute_max_tile_velocity(), blender::nodes::node_composite_vec_blur_cc::VectorBlurOperation::compute_motion_blur(), blender::nodes::node_composite_base_cryptomatte_cc::BaseCryptoMatteOperation::compute_pick(), blender::nodes::node_composite_cornerpin_cc::CornerPinOperation::compute_plane(), blender::nodes::node_composite_planetrackdeform_cc::PlaneTrackDeformOperation::compute_plane(), blender::nodes::node_composite_cornerpin_cc::CornerPinOperation::compute_plane_mask(), blender::nodes::node_composite_planetrackdeform_cc::PlaneTrackDeformOperation::compute_plane_mask(), blender::realtime_compositor::compute_preview_from_result(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::compute_structure_tensor(), blender::nodes::node_composite_keying_cc::KeyingOperation::compute_tweaked_matte(), blender::realtime_compositor::detect_edges(), blender::nodes::node_composite_vec_blur_cc::VectorBlurOperation::dilate_max_velocity(), draw_filled_lasso(), draw_shgroup(), blender::draw::draw_subdiv_accumulate_normals(), blender::draw::draw_subdiv_build_edge_fac_buffer(), blender::draw::draw_subdiv_build_edituv_stretch_angle_buffer(), blender::draw::draw_subdiv_build_edituv_stretch_area_buffer(), blender::draw::draw_subdiv_build_fdots_buffers(), blender::draw::draw_subdiv_build_lines_buffer(), blender::draw::draw_subdiv_build_lines_loose_buffer(), blender::draw::draw_subdiv_build_lnor_buffer(), blender::draw::draw_subdiv_build_sculpt_data_buffer(), blender::draw::draw_subdiv_build_tris_buffer(), blender::draw::draw_subdiv_extract_pos_nor(), blender::draw::draw_subdiv_extract_uvs(), blender::draw::draw_subdiv_finalize_custom_normals(), blender::draw::draw_subdiv_finalize_normals(), blender::draw::draw_subdiv_interp_custom_data(), drw_draw_pass_ex(), blender::nodes::node_composite_bilateralblur_cc::BilateralBlurOperation::execute(), blender::nodes::node_composite_boxmask_cc::BoxMaskOperation::execute(), blender::nodes::node_composite_defocus_cc::DefocusOperation::execute(), blender::nodes::node_composite_despeckle_cc::DespeckleOperation::execute(), blender::nodes::node_composite_directionalblur_cc::DirectionalBlurOperation::execute(), blender::nodes::node_composite_displace_cc::DisplaceOperation::execute(), blender::nodes::node_composite_ellipsemask_cc::EllipseMaskOperation::execute(), blender::nodes::node_composite_filter_cc::FilterOperation::execute(), blender::nodes::node_composite_flip_cc::FlipOperation::execute(), blender::nodes::node_composite_id_mask_cc::IDMaskOperation::execute(), blender::nodes::node_composite_map_uv_cc::MapUVOperation::execute(), blender::nodes::node_composite_moviedistortion_cc::MovieDistortionOperation::execute(), blender::nodes::node_composite_normalize_cc::NormalizeOperation::execute(), blender::nodes::node_composite_pixelate_cc::PixelateOperation::execute(), blender::nodes::node_composite_split_cc::SplitOperation::execute(), blender::nodes::node_composite_sunbeams_cc::SunBeamsOperation::execute(), blender::realtime_compositor::ConversionOperation::execute(), blender::realtime_compositor::ShaderOperation::execute(), blender::nodes::node_composite_crop_cc::CropOperation::execute_alpha_crop(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::execute_anisotropic(), blender::nodes::node_composite_zcombine_cc::ZCombineOperation::execute_anti_aliased(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_bloom(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::execute_classic(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::execute_classic_summed_area_table(), blender::nodes::node_composite_blur_cc::BlurOperation::execute_constant_size(), blender::nodes::node_composite_bokehblur_cc::BokehBlurOperation::execute_constant_size(), blender::nodes::node_composite_composite_cc::CompositeOperation::execute_copy_gpu(), blender::nodes::node_composite_viewer_cc::ViewerOperation::execute_copy_gpu(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::execute_distance_threshold(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_ghost(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_highlights(), blender::nodes::node_composite_composite_cc::CompositeOperation::execute_ignore_alpha_gpu(), blender::nodes::node_composite_viewer_cc::ViewerOperation::execute_ignore_alpha_gpu(), blender::nodes::node_composite_crop_cc::CropOperation::execute_image_crop(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_mix(), blender::nodes::node_composite_render_layer_cc::RenderLayerOperation::execute_pass(), blender::nodes::node_composite_tonemap_cc::ToneMapOperation::execute_photoreceptor(), blender::nodes::node_composite_lensdist_cc::LensDistortionOperation::execute_projector_distortion(), blender::nodes::node_composite_lensdist_cc::LensDistortionOperation::execute_screen_distortion(), blender::nodes::node_composite_composite_cc::CompositeOperation::execute_set_alpha_gpu(), blender::nodes::node_composite_viewer_cc::ViewerOperation::execute_set_alpha_gpu(), blender::nodes::node_composite_tonemap_cc::ToneMapOperation::execute_simple(), blender::nodes::node_composite_zcombine_cc::ZCombineOperation::execute_simple(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_axis_aligned(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_diagonal(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_diagonal_pass(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_horizontal_pass(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::execute_step_horizontal_pass(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::execute_step_vertical_pass(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_streaks(), blender::nodes::node_composite_blur_cc::BlurOperation::execute_variable_size(), blender::nodes::node_composite_bokehblur_cc::BokehBlurOperation::execute_variable_size(), blender::nodes::node_composite_scale_cc::ScaleOperation::execute_variable_size(), blender::realtime_compositor::extract_alpha_gpu(), blender::nodes::node_composite_keying_cc::KeyingOperation::extract_input_chroma(), blender::nodes::node_composite_inpaint_cc::InpaintOperation::fill_inpainting_region(), GPU_indexbuf_build_curves_on_device(), blender::gpu::tests::gpu_shader_lib_test(), blender::realtime_compositor::horizontal_pass(), blender::realtime_compositor::horizontal_pass(), blender::realtime_compositor::horizontal_pass(), immUnbindProgram(), blender::realtime_compositor::jump_flooding_pass(), blender::realtime_compositor::KeyingScreen::KeyingScreen(), blender::realtime_compositor::maximum_float(), blender::realtime_compositor::maximum_float_in_range(), blender::realtime_compositor::maximum_luminance(), blender::realtime_compositor::minimum_float(), blender::realtime_compositor::minimum_float_in_range(), blender::realtime_compositor::minimum_luminance(), blender::realtime_compositor::morphological_distance(), pygpu_batch_program_use_end(), pygpu_shader_unbind(), blender::realtime_compositor::realize_on_domain(), blender::render::hydra::ViewportEngine::render(), blender::nodes::node_composite_keying_cc::KeyingOperation::replace_input_chroma(), blender::realtime_compositor::sum_blue(), blender::realtime_compositor::sum_blue_squared_difference(), blender::realtime_compositor::sum_causal_and_non_causal_results(), blender::realtime_compositor::sum_causal_and_non_causal_results(), blender::realtime_compositor::sum_color(), blender::realtime_compositor::sum_green(), blender::realtime_compositor::sum_green_squared_difference(), blender::realtime_compositor::sum_log_luminance(), blender::realtime_compositor::sum_luminance(), blender::realtime_compositor::sum_luminance_squared_difference(), blender::realtime_compositor::sum_red(), blender::realtime_compositor::sum_red_squared_difference(), blender::gpu::tests::test_buffer_texture(), blender::gpu::tests::test_compute_direct(), blender::gpu::tests::test_compute_indirect(), blender::gpu::tests::test_shader_compute_1d(), blender::gpu::tests::test_shader_compute_2d(), blender::gpu::tests::test_shader_compute_ibo(), blender::gpu::tests::test_shader_compute_ssbo(), blender::gpu::tests::test_shader_compute_vbo(), BlenderFallbackDisplayShader::unbind(), blender::realtime_compositor::vertical_pass(), blender::realtime_compositor::vertical_pass(), blender::realtime_compositor::vertical_pass(), blender::gpu::tests::Shader::~Shader(), and blender::gpu::tests::ShaderSpecializationConst::~ShaderSpecializationConst().

◆ GPU_shader_uniform_1b()

◆ GPU_shader_uniform_1f()

void GPU_shader_uniform_1f ( GPUShader * sh,
const char * name,
float value )

Definition at line 703 of file gpu_shader.cc.

References GPU_shader_get_uniform(), and GPU_shader_uniform_float_ex().

Referenced by blender::nodes::node_composite_glare_cc::GlareOperation::apply_streak_filter(), blender::realtime_compositor::blur_pass(), blender::realtime_compositor::BokehKernel::BokehKernel(), blender::nodes::node_composite_defocus_cc::DefocusOperation::compute_defocus_radius_from_depth(), blender::nodes::node_composite_defocus_cc::DefocusOperation::compute_defocus_radius_from_scale(), blender::nodes::node_composite_keying_cc::KeyingOperation::compute_image(), blender::nodes::node_composite_keying_cc::KeyingOperation::compute_matte(), blender::nodes::node_composite_vec_blur_cc::VectorBlurOperation::compute_motion_blur(), blender::nodes::node_composite_keying_cc::KeyingOperation::compute_tweaked_matte(), blender::realtime_compositor::detect_edges(), blender::nodes::node_composite_vec_blur_cc::VectorBlurOperation::dilate_max_velocity(), blender::nodes::node_composite_bilateralblur_cc::BilateralBlurOperation::execute(), blender::nodes::node_composite_boxmask_cc::BoxMaskOperation::execute(), blender::nodes::node_composite_despeckle_cc::DespeckleOperation::execute(), blender::nodes::node_composite_directionalblur_cc::DirectionalBlurOperation::execute(), blender::nodes::node_composite_ellipsemask_cc::EllipseMaskOperation::execute(), blender::nodes::node_composite_map_uv_cc::MapUVOperation::execute(), blender::nodes::node_composite_normalize_cc::NormalizeOperation::execute(), blender::nodes::node_composite_split_cc::SplitOperation::execute(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::execute_anisotropic(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::execute_distance_threshold(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_highlights(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_mix(), blender::nodes::node_composite_tonemap_cc::ToneMapOperation::execute_photoreceptor(), blender::nodes::node_composite_lensdist_cc::LensDistortionOperation::execute_projector_distortion(), blender::nodes::node_composite_lensdist_cc::LensDistortionOperation::execute_screen_distortion(), blender::nodes::node_composite_tonemap_cc::ToneMapOperation::execute_simple(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_axis_aligned(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_diagonal(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_diagonal_pass(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_horizontal_pass(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_streaks(), blender::nodes::node_composite_bokehblur_cc::BokehBlurOperation::execute_variable_size(), immUniform1f(), blender::realtime_compositor::KeyingScreen::KeyingScreen(), blender::realtime_compositor::maximum_float_in_range(), blender::realtime_compositor::minimum_float_in_range(), blender::realtime_compositor::sum_blue_squared_difference(), blender::realtime_compositor::sum_green_squared_difference(), blender::realtime_compositor::sum_luminance_squared_difference(), blender::realtime_compositor::sum_red_squared_difference(), and blender::gpu::tests::Shader::update_push_constants().

◆ GPU_shader_uniform_1f_array()

void GPU_shader_uniform_1f_array ( GPUShader * sh,
const char * name,
int len,
const float * val )

◆ GPU_shader_uniform_1i()

void GPU_shader_uniform_1i ( GPUShader * sh,
const char * name,
int value )

Sets a generic push constant (a.k.a. uniform). length and array_size should match the create info push_constant declaration. These functions need to have the shader bound in order to work. (TODO: until we use glProgramUniform)

Definition at line 674 of file gpu_shader.cc.

References GPU_shader_get_uniform(), and GPU_shader_uniform_int_ex().

Referenced by blender::draw::command::DrawMultiBuf::bind(), blender::realtime_compositor::calculate_blending_weights(), blender::nodes::node_composite_inpaint_cc::InpaintOperation::compute_inpainting_region(), blender::nodes::node_composite_base_cryptomatte_cc::BaseCryptoMatteOperation::compute_matte(), blender::nodes::node_composite_vec_blur_cc::VectorBlurOperation::compute_motion_blur(), blender::nodes::node_composite_planetrackdeform_cc::PlaneTrackDeformOperation::compute_plane(), blender::nodes::node_composite_planetrackdeform_cc::PlaneTrackDeformOperation::compute_plane_mask(), blender::nodes::node_composite_keying_cc::KeyingOperation::compute_tweaked_matte(), blender::draw::View::compute_visibility(), blender::render::hydra::DrawTexture::draw(), blender::draw::Manager::end_sync(), blender::nodes::node_composite_bilateralblur_cc::BilateralBlurOperation::execute(), blender::nodes::node_composite_defocus_cc::DefocusOperation::execute(), blender::nodes::node_composite_directionalblur_cc::DirectionalBlurOperation::execute(), blender::nodes::node_composite_id_mask_cc::IDMaskOperation::execute(), blender::nodes::node_composite_pixelate_cc::PixelateOperation::execute(), blender::nodes::node_composite_sunbeams_cc::SunBeamsOperation::execute(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::execute_classic(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::execute_classic_summed_area_table(), blender::nodes::node_composite_bokehblur_cc::BokehBlurOperation::execute_constant_size(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::execute_distance_threshold(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_axis_aligned(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_diagonal(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_diagonal_pass(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_horizontal_pass(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::execute_step_horizontal_pass(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::execute_step_vertical_pass(), blender::nodes::node_composite_bokehblur_cc::BokehBlurOperation::execute_variable_size(), blender::nodes::node_composite_inpaint_cc::InpaintOperation::fill_inpainting_region(), GPU_batch_bind_as_resources(), GPU_indexbuf_build_curves_on_device(), GPU_shader_get_builtin_shader_with_config(), GPU_shader_uniform_1b(), immUniform1i(), blender::realtime_compositor::jump_flooding_pass(), blender::realtime_compositor::KeyingScreen::KeyingScreen(), blender::realtime_compositor::morphological_distance(), and pygpu_shader_uniform_sampler().

◆ GPU_shader_uniform_2f()

void GPU_shader_uniform_2f ( GPUShader * sh,
const char * name,
float x,
float y )

Definition at line 685 of file gpu_shader.cc.

References GPU_shader_uniform_2fv(), and x.

Referenced by immUniform2f().

◆ GPU_shader_uniform_2fv()

◆ GPU_shader_uniform_2fv_array()

void GPU_shader_uniform_2fv_array ( GPUShader * sh,
const char * name,
int len,
const float(*) val[2] )

Definition at line 752 of file gpu_shader.cc.

References GPU_shader_get_uniform(), GPU_shader_uniform_float_ex(), and len.

◆ GPU_shader_uniform_2iv()

void GPU_shader_uniform_2iv ( GPUShader * sh,
const char * name,
const int data[2] )

◆ GPU_shader_uniform_3f()

void GPU_shader_uniform_3f ( GPUShader * sh,
const char * name,
float x,
float y,
float z )

Definition at line 691 of file gpu_shader.cc.

References GPU_shader_uniform_3fv(), x, y, and z().

Referenced by immUniform3f().

◆ GPU_shader_uniform_3fv()

◆ GPU_shader_uniform_4f()

void GPU_shader_uniform_4f ( GPUShader * sh,
const char * name,
float x,
float y,
float z,
float w )

Definition at line 697 of file gpu_shader.cc.

References GPU_shader_uniform_4fv(), w(), x, y, and z().

Referenced by button2d_draw_intern(), and immUniform4f().

◆ GPU_shader_uniform_4fv()

◆ GPU_shader_uniform_4fv_array()

void GPU_shader_uniform_4fv_array ( GPUShader * sh,
const char * name,
int len,
const float(*) val[4] )

◆ GPU_shader_uniform_float_ex()

◆ GPU_shader_uniform_int_ex()

◆ GPU_shader_uniform_mat3_as_mat4()

◆ GPU_shader_uniform_mat4()

void GPU_shader_uniform_mat4 ( GPUShader * sh,
const char * name,
const float data[4][4] )

◆ GPU_shader_uses_ssbo_vertex_fetch()

bool GPU_shader_uses_ssbo_vertex_fetch ( GPUShader * shader)

◆ GPU_shader_warm_cache()

void GPU_shader_warm_cache ( GPUShader * shader,
int limit )

Shader cache warming. For each shader, rendering APIs perform a two-step compilation:

  • The first stage is Front-End compilation which only needs to be performed once, and generates a portable intermediate representation. This happens during gpu::Shader::finalize().
  • The second is Back-End compilation which compiles a device-specific executable shader program. This compilation requires some contextual pipeline state which is baked into the executable shader source, producing a Pipeline State Object (PSO). In OpenGL, backend compilation happens in the background, within the driver, but can still incur runtime stutters. In Metal/Vulkan, PSOs are compiled explicitly. These are currently resolved within the backend based on the current pipeline state and can incur runtime stalls when they occur.

Shader Cache warming uses the specified parent shader set using GPU_shader_set_parent(..) as a template reference for pre-compiling Render Pipeline State Objects (PSOs) outside of the main render pipeline.

PSOs require descriptors containing information on the render state for a given shader, which includes input vertex data layout and output pixel formats, along with some state such as blend mode and color output masks. As this state information is usually consistent between similar draws, we can assign a parent shader and use this shader's cached pipeline state's to prime compilations.

Shaders do not necessarily have to be similar in functionality to be used as a parent, so long as the #GPUVertFormt and #GPUFrameBuffer which they are used with remain the same. Other bindings such as textures, uniforms and UBOs are all assigned independently as dynamic state.

This function should be called asynchronously, mitigating the impact of run-time stuttering from dynamic compilation of PSOs during normal rendering.

Parameters
shader: The shader whose cache to warm.
limitThe maximum number of PSOs to compile within a call. Specifying a limit <= 0 will compile a PSO for all cached PSOs in the parent shader.

Definition at line 452 of file gpu_shader.cc.

References blender::gpu::unwrap().

Referenced by gpu_material_finalize(), and GPU_material_optimize().

◆ standard_defines()

Variable Documentation

◆ datatoc_gpu_shader_colorspace_lib_glsl

char datatoc_gpu_shader_colorspace_lib_glsl[]

Definition at line 29 of file gpu_shader.cc.

Referenced by GPU_shader_create_from_python().