Blender V5.0
GPU_shader.hh File Reference
#include <mutex>
#include <optional>
#include "BLI_span.hh"
#include "BLI_string_ref.hh"
#include "BLI_vector.hh"
#include "GPU_common_types.hh"
#include "GPU_shader_builtin.hh"
#include "BLI_utility_mixins.hh"
#include <atomic>

Go to the source code of this file.

Classes

struct  ShaderSpecialization
class  blender::gpu::StaticShader
class  blender::gpu::StaticShaderCache< T >

Namespaces

namespace  blender
namespace  blender::gpu

Macros

#define GPU_SHADER_FREE_SAFE(shader)

Functions

Free
void GPU_shader_free (blender::gpu::Shader *shader)
Binding
void GPU_shader_bind (blender::gpu::Shader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_shader_unbind ()
blender::gpu::ShaderGPU_shader_get_bound ()
Debugging introspection API.
const char * GPU_shader_get_name (blender::gpu::Shader *shader)
Uniform API.
int GPU_shader_get_ubo_binding (blender::gpu::Shader *shader, const char *name)
int GPU_shader_get_ssbo_binding (blender::gpu::Shader *shader, const char *name)
int GPU_shader_get_sampler_binding (blender::gpu::Shader *shader, const char *name)
int GPU_shader_get_uniform (blender::gpu::Shader *shader, const char *name)
int GPU_shader_get_constant (blender::gpu::Shader *shader, const char *name)
void GPU_shader_uniform_float_ex (blender::gpu::Shader *shader, int location, int length, int array_size, const float *value)
void GPU_shader_uniform_int_ex (blender::gpu::Shader *shader, int location, int length, int array_size, const int *value)
void GPU_shader_uniform_1i (blender::gpu::Shader *sh, const char *name, int value)
void GPU_shader_uniform_1b (blender::gpu::Shader *sh, const char *name, bool value)
void GPU_shader_uniform_1f (blender::gpu::Shader *sh, const char *name, float value)
void GPU_shader_uniform_2f (blender::gpu::Shader *sh, const char *name, float x, float y)
void GPU_shader_uniform_3f (blender::gpu::Shader *sh, const char *name, float x, float y, float z)
void GPU_shader_uniform_4f (blender::gpu::Shader *sh, const char *name, float x, float y, float z, float w)
void GPU_shader_uniform_2fv (blender::gpu::Shader *sh, const char *name, const float data[2])
void GPU_shader_uniform_3fv (blender::gpu::Shader *sh, const char *name, const float data[3])
void GPU_shader_uniform_4fv (blender::gpu::Shader *sh, const char *name, const float data[4])
void GPU_shader_uniform_2iv (blender::gpu::Shader *sh, const char *name, const int data[2])
void GPU_shader_uniform_3iv (blender::gpu::Shader *sh, const char *name, const int data[3])
void GPU_shader_uniform_mat4 (blender::gpu::Shader *sh, const char *name, const float data[4][4])
void GPU_shader_uniform_mat3_as_mat4 (blender::gpu::Shader *sh, const char *name, const float data[3][3])
void GPU_shader_uniform_1f_array (blender::gpu::Shader *sh, const char *name, int len, const float *val)
void GPU_shader_uniform_2fv_array (blender::gpu::Shader *sh, const char *name, int len, const float(*val)[2])
void GPU_shader_uniform_4fv_array (blender::gpu::Shader *sh, const char *name, int len, const float(*val)[4])
Attribute API.

Used to create #GPUVertexFormat from the shader's vertex input layout.

uint GPU_shader_get_attribute_len (const blender::gpu::Shader *shader)
uint GPU_shader_get_ssbo_input_len (const blender::gpu::Shader *shader)
int GPU_shader_get_attribute (const blender::gpu::Shader *shader, const char *name)
bool GPU_shader_get_attribute_info (const blender::gpu::Shader *shader, int attr_location, char r_name[256], int *r_type)
bool GPU_shader_get_ssbo_input_info (const blender::gpu::Shader *shader, int ssbo_location, char r_name[256])

Variables

static constexpr int GPU_MAX_ATTR = 15
static constexpr int GPU_MAX_UNIFORM_ATTR = 8

Legacy API

All of this section is deprecated and should be ported to use the API described above.

#define GPU_NUM_UNIFORMS   (GPU_UNIFORM_SCENE_LINEAR_XFORM + 1)
enum  GPUUniformBuiltin {
  GPU_UNIFORM_MODEL = 0 , GPU_UNIFORM_VIEW , GPU_UNIFORM_MODELVIEW , GPU_UNIFORM_PROJECTION ,
  GPU_UNIFORM_VIEWPROJECTION , GPU_UNIFORM_MVP , GPU_UNIFORM_MODEL_INV , GPU_UNIFORM_VIEW_INV ,
  GPU_UNIFORM_MODELVIEW_INV , GPU_UNIFORM_PROJECTION_INV , GPU_UNIFORM_VIEWPROJECTION_INV , GPU_UNIFORM_NORMAL ,
  GPU_UNIFORM_CLIPPLANES , GPU_UNIFORM_COLOR , GPU_UNIFORM_BASE_INSTANCE , GPU_UNIFORM_RESOURCE_CHUNK ,
  GPU_UNIFORM_RESOURCE_ID , GPU_UNIFORM_SRGB_TRANSFORM , GPU_UNIFORM_SCENE_LINEAR_XFORM
}
enum  GPUUniformBlockBuiltin {
  GPU_UNIFORM_BLOCK_VIEW = 0 , GPU_UNIFORM_BLOCK_MODEL , GPU_UNIFORM_BLOCK_INFO , GPU_UNIFORM_BLOCK_DRW_VIEW ,
  GPU_UNIFORM_BLOCK_DRW_MODEL , GPU_UNIFORM_BLOCK_DRW_INFOS , GPU_UNIFORM_BLOCK_DRW_CLIPPING , GPU_NUM_UNIFORM_BLOCKS
}
void GPU_shader_warm_cache (blender::gpu::Shader *shader, int limit)
void GPU_shader_set_parent (blender::gpu::Shader *shader, blender::gpu::Shader *parent)
int GPU_shader_get_builtin_uniform (blender::gpu::Shader *shader, int builtin)
void GPU_shader_compile_static ()
void GPU_shader_cache_dir_clear_old ()
int GPU_shader_get_uniform_block (blender::gpu::Shader *shader, const char *name)

Creation

enum class  CompilationPriority { Low , Medium , High }
using BatchHandle = int64_t
std::string GPU_shader_preprocess_source (blender::StringRefNull original)
blender::gpu::ShaderGPU_shader_create_from_info (const GPUShaderCreateInfo *_info)
blender::gpu::ShaderGPU_shader_create_from_info_python (const GPUShaderCreateInfo *_info)
blender::gpu::ShaderGPU_shader_create_from_info_name (const char *info_name)
const GPUShaderCreateInfo * GPU_shader_create_info_get (const char *info_name)
bool GPU_shader_create_info_check_error (const GPUShaderCreateInfo *_info, char r_error[128])
BatchHandle GPU_shader_batch_create_from_infos (blender::Span< const GPUShaderCreateInfo * > infos, CompilationPriority priority=CompilationPriority::High)
bool GPU_shader_batch_is_ready (BatchHandle handle)
blender::Vector< blender::gpu::Shader * > GPU_shader_batch_finalize (BatchHandle &handle)
void GPU_shader_batch_cancel (BatchHandle &handle)
bool GPU_shader_batch_is_compiling ()
void GPU_shader_batch_wait_for_all ()

Specialization API.

Used to allow specialization constants. IMPORTANT: All constants must be specified before binding a shader that needs specialization. Otherwise, it will produce undefined behavior.

using SpecializationBatchHandle = int64_t
const blender::gpu::shader::SpecializationConstantsGPU_shader_get_default_constant_state (blender::gpu::Shader *sh)
SpecializationBatchHandle GPU_shader_batch_specializations (blender::Span< ShaderSpecialization > specializations, CompilationPriority priority=CompilationPriority::High)
bool GPU_shader_batch_specializations_is_ready (SpecializationBatchHandle &handle)
void GPU_shader_batch_specializations_cancel (SpecializationBatchHandle &handle)

Detailed Description

A blender::gpu::Shader is a container for backend specific shader program.

Definition in file GPU_shader.hh.

Macro Definition Documentation

◆ GPU_NUM_UNIFORMS

◆ GPU_SHADER_FREE_SAFE

Typedef Documentation

◆ BatchHandle

Definition at line 82 of file GPU_shader.hh.

◆ SpecializationBatchHandle

Definition at line 269 of file GPU_shader.hh.

Enumeration Type Documentation

◆ CompilationPriority

enum class CompilationPriority
strong
Enumerator
Low 
Medium 
High 

Definition at line 80 of file GPU_shader.hh.

◆ GPUUniformBlockBuiltin

DEPRECATED: Use hard-coded buffer location instead.

Enumerator
GPU_UNIFORM_BLOCK_VIEW 
GPU_UNIFORM_BLOCK_MODEL 
GPU_UNIFORM_BLOCK_INFO 
GPU_UNIFORM_BLOCK_DRW_VIEW 
GPU_UNIFORM_BLOCK_DRW_MODEL 
GPU_UNIFORM_BLOCK_DRW_INFOS 
GPU_UNIFORM_BLOCK_DRW_CLIPPING 
GPU_NUM_UNIFORM_BLOCKS 

Definition at line 399 of file GPU_shader.hh.

◆ GPUUniformBuiltin

Indexed commonly used uniform name for faster lookup into the uniform cache.

Enumerator
GPU_UNIFORM_MODEL 
GPU_UNIFORM_VIEW 
GPU_UNIFORM_MODELVIEW 
GPU_UNIFORM_PROJECTION 
GPU_UNIFORM_VIEWPROJECTION 
GPU_UNIFORM_MVP 
GPU_UNIFORM_MODEL_INV 
GPU_UNIFORM_VIEW_INV 
GPU_UNIFORM_MODELVIEW_INV 
GPU_UNIFORM_PROJECTION_INV 
GPU_UNIFORM_VIEWPROJECTION_INV 
GPU_UNIFORM_NORMAL 
GPU_UNIFORM_CLIPPLANES 
GPU_UNIFORM_COLOR 
GPU_UNIFORM_BASE_INSTANCE 
GPU_UNIFORM_RESOURCE_CHUNK 
GPU_UNIFORM_RESOURCE_ID 
GPU_UNIFORM_SRGB_TRANSFORM 
GPU_UNIFORM_SCENE_LINEAR_XFORM 

Definition at line 357 of file GPU_shader.hh.

Function Documentation

◆ GPU_shader_batch_cancel()

void GPU_shader_batch_cancel ( BatchHandle & handle)

Cancel the compilation of the batch. WARNING: The handle will be invalidated by this call.

Definition at line 222 of file gpu_shader.cc.

References blender::gpu::ShaderCompiler::batch_cancel(), blender::gpu::GPUBackend::get(), and blender::gpu::GPUBackend::get_compiler().

Referenced by GPUPass::~GPUPass(), and blender::gpu::StaticShader::~StaticShader().

◆ GPU_shader_batch_create_from_infos()

BatchHandle GPU_shader_batch_create_from_infos ( blender::Span< const GPUShaderCreateInfo * > infos,
CompilationPriority priority = CompilationPriority::High )

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. WARNING: The GPUShaderCreateInfo pointers should be valid until GPU_shader_batch_finalize has returned.

Definition at line 202 of file gpu_shader.cc.

References blender::gpu::ShaderCompiler::batch_compile(), blender::gpu::GPUBackend::get(), and blender::gpu::GPUBackend::get_compiler().

Referenced by blender::gpu::StaticShader::ensure_compile_async(), gpu_shader_create_info_compile(), GPUPass::GPUPass(), and GPUPass::update_compilation().

◆ GPU_shader_batch_finalize()

blender::Vector< blender::gpu::Shader * > 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 216 of file gpu_shader.cc.

References blender::gpu::ShaderCompiler::batch_finalize(), blender::gpu::GPUBackend::get(), blender::gpu::GPUBackend::get_compiler(), and result.

Referenced by blender::gpu::StaticShader::ensure_compile_async(), GPUPass::finalize_compilation(), blender::gpu::StaticShader::get(), and gpu_shader_create_info_compile().

◆ GPU_shader_batch_is_compiling()

bool GPU_shader_batch_is_compiling ( )

Returns true if there's any batch still being compiled.

Definition at line 227 of file gpu_shader.cc.

References blender::gpu::GPUBackend::get(), blender::gpu::GPUBackend::get_compiler(), and blender::gpu::ShaderCompiler::is_compiling().

Referenced by bpy_app_is_job_running().

◆ 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 211 of file gpu_shader.cc.

References blender::gpu::ShaderCompiler::batch_is_ready(), blender::gpu::GPUBackend::get(), and blender::gpu::GPUBackend::get_compiler().

Referenced by blender::gpu::StaticShader::ensure_compile_async(), and GPUPass::update_compilation().

◆ GPU_shader_batch_specializations()

SpecializationBatchHandle GPU_shader_batch_specializations ( blender::Span< ShaderSpecialization > specializations,
CompilationPriority priority = CompilationPriority::High )

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 370 of file gpu_shader.cc.

References blender::gpu::GPUBackend::get(), blender::gpu::GPUBackend::get_compiler(), and blender::gpu::ShaderCompiler::precompile_specializations().

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

◆ GPU_shader_batch_specializations_cancel()

void GPU_shader_batch_specializations_cancel ( SpecializationBatchHandle & handle)

Cancel the specialization batch. WARNING: The handle will be invalidated by this call.

Definition at line 381 of file gpu_shader.cc.

References blender::gpu::ShaderCompiler::batch_cancel(), blender::gpu::GPUBackend::get(), and blender::gpu::GPUBackend::get_compiler().

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

◆ 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 376 of file gpu_shader.cc.

References blender::gpu::GPUBackend::get(), blender::gpu::GPUBackend::get_compiler(), and blender::gpu::ShaderCompiler::specialization_batch_is_ready().

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

◆ GPU_shader_batch_wait_for_all()

void GPU_shader_batch_wait_for_all ( )

Wait until all the requested batches have been compiled.

Definition at line 232 of file gpu_shader.cc.

References blender::gpu::GPUBackend::get(), blender::gpu::GPUBackend::get_compiler(), and blender::gpu::ShaderCompiler::wait_for_all().

Referenced by GPU_pass_cache_wait_for_all().

◆ GPU_shader_bind()

void GPU_shader_bind ( blender::gpu::Shader * shader,
const blender::gpu::shader::SpecializationConstants * constants_state = nullptr )

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 254 of file gpu_shader.cc.

References BLI_assert_msg, 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::Shader::set_scene_linear_to_xyz_uniform(), blender::gpu::Shader::set_srgb_uniform(), blender::gpu::Context::shader, and blender::gpu::Context::shader_builtin_srgb_is_dirty.

Referenced by blender::nodes::node_composite_glare_cc::GlareOperation::accumulate_ghosts_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::accumulate_streak_gpu(), blender::compositor::apply_morphological_operator_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::apply_streak_filter_gpu(), BlenderFallbackDisplayShader::bind(), blender::compositor::blend_neighborhood_gpu(), blender::compositor::blur_pass_gpu(), blender::compositor::blur_pass_gpu(), blender::compositor::calculate_blending_weights_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::compute_base_ghost_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::compute_bloom_downsample_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::compute_bloom_upsample_gpu(), blender::nodes::node_composite_double_edge_mask_cc::DoubleEdgeMaskOperation::compute_boundary_gpu(), blender::compositor::compute_complete_blocks(), blender::compositor::compute_complete_x_prologues(), blender::compositor::compute_complete_y_prologues(), blender::nodes::node_composite_defocus_cc::DefocusOperation::compute_defocus_radius_from_depth_gpu(), blender::nodes::node_composite_defocus_cc::DefocusOperation::compute_defocus_radius_from_scale_gpu(), blender::nodes::node_composite_double_edge_mask_cc::DoubleEdgeMaskOperation::compute_gradient_gpu(), blender::nodes::node_composite_base_cryptomatte_cc::BaseCryptoMatteOperation::compute_image_gpu(), blender::nodes::node_composite_keying_cc::KeyingOperation::compute_image_gpu(), blender::compositor::compute_incomplete_prologues(), blender::nodes::node_composite_inpaint_cc::InpaintOperation::compute_inpainting_boundary_gpu(), blender::nodes::node_composite_inpaint_cc::InpaintOperation::compute_inpainting_region_gpu(), blender::nodes::node_composite_zcombine_cc::ZCombineOperation::compute_mask_gpu(), blender::nodes::node_composite_base_cryptomatte_cc::BaseCryptoMatteOperation::compute_matte_gpu(), blender::nodes::node_composite_keying_cc::KeyingOperation::compute_matte_gpu(), 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_gpu(), blender::nodes::node_composite_cornerpin_cc::CornerPinOperation::compute_plane_gpu(), blender::nodes::node_composite_planetrackdeform_cc::PlaneTrackDeformOperation::compute_plane_gpu(), blender::nodes::node_composite_cornerpin_cc::CornerPinOperation::compute_plane_mask_gpu(), blender::nodes::node_composite_planetrackdeform_cc::PlaneTrackDeformOperation::compute_plane_mask_gpu(), blender::compositor::compute_preview_gpu(), blender::draw::View::compute_procedural_bounds(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::compute_structure_tensor_gpu(), blender::nodes::node_composite_keying_cc::KeyingOperation::compute_tweaked_matte_gpu(), blender::draw::View::compute_visibility(), blender::compositor::detect_edges_gpu(), blender::nodes::node_composite_vec_blur_cc::VectorBlurOperation::dilate_max_velocity(), draw_filled_lasso(), 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_paint_overlay_flag_buffer(), blender::draw::draw_subdiv_build_sculpt_data_buffer(), blender::draw::draw_subdiv_build_tris_buffer(), blender::draw::draw_subdiv_extract_pos(), blender::draw::draw_subdiv_extract_uvs(), blender::draw::draw_subdiv_interp_corner_normals(), blender::draw::draw_subdiv_interp_custom_data(), blender::gpu::GLImmediate::end(), blender::gpu::MTLImmediate::end(), blender::draw::Manager::end_sync(), blender::compositor::ConversionOperation::execute(), blender::compositor::ShaderOperation::execute(), blender::draw::command::ShaderBind::execute(), blender::nodes::node_composite_crop_cc::CropOperation::execute_alpha_crop_gpu(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::execute_anisotropic_gpu(), blender::nodes::node_composite_zcombine_cc::ZCombineOperation::execute_anti_aliased_depth_gpu(), blender::nodes::node_composite_zcombine_cc::ZCombineOperation::execute_anti_aliased_image_gpu(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::execute_classic_convolution_gpu(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::execute_classic_summed_area_table_gpu(), blender::nodes::node_composite_blur_cc::BlurOperation::execute_constant_size_gpu(), blender::nodes::node_composite_bokehblur_cc::BokehBlurOperation::execute_constant_size_gpu(), blender::nodes::node_composite_group_output_cc::GroupOutputOperation::execute_copy_gpu(), blender::nodes::node_composite_viewer_cc::ViewerOperation::execute_copy_gpu(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::execute_distance_threshold_gpu(), blender::nodes::node_composite_bilateralblur_cc::BilateralBlurOperation::execute_gpu(), blender::nodes::node_composite_boxmask_cc::BoxMaskOperation::execute_gpu(), blender::nodes::node_composite_defocus_cc::DefocusOperation::execute_gpu(), blender::nodes::node_composite_despeckle_cc::DespeckleOperation::execute_gpu(), blender::nodes::node_composite_directionalblur_cc::DirectionalBlurOperation::execute_gpu(), blender::nodes::node_composite_displace_cc::DisplaceOperation::execute_gpu(), blender::nodes::node_composite_ellipsemask_cc::EllipseMaskOperation::execute_gpu(), blender::nodes::node_composite_filter_cc::FilterOperation::execute_gpu(), blender::nodes::node_composite_flip_cc::FlipOperation::execute_gpu(), blender::nodes::node_composite_id_mask_cc::IDMaskOperation::execute_gpu(), blender::nodes::node_composite_map_uv_cc::MapUVOperation::execute_gpu(), blender::nodes::node_composite_moviedistortion_cc::MovieDistortionOperation::execute_gpu(), blender::nodes::node_composite_normalize_cc::NormalizeOperation::execute_gpu(), blender::nodes::node_composite_pixelate_cc::PixelateOperation::execute_gpu(), blender::nodes::node_composite_split_cc::SplitOperation::execute_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_highlights_gpu(), blender::nodes::node_composite_lensdist_cc::LensDistortionOperation::execute_horizontal_distortion_gpu(), blender::nodes::node_composite_crop_cc::CropOperation::execute_image_crop_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_mix_gpu(), blender::nodes::node_composite_group_input_cc::GroupInputOperation::execute_pass_gpu(), blender::nodes::node_composite_render_layer_cc::RenderLayerOperation::execute_pass_gpu(), blender::nodes::node_composite_tonemap_cc::ToneMapOperation::execute_photoreceptor_gpu(), blender::nodes::node_composite_lensdist_cc::LensDistortionOperation::execute_radial_distortion_gpu(), blender::nodes::node_composite_zcombine_cc::ZCombineOperation::execute_simple_depth_gpu(), blender::nodes::node_composite_tonemap_cc::ToneMapOperation::execute_simple_gpu(), blender::nodes::node_composite_zcombine_cc::ZCombineOperation::execute_simple_image_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_anti_diagonal_pass_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_diagonal_pass_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_horizontal_pass_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_vertical_pass_gpu(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::execute_step_horizontal_pass_gpu(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::execute_step_vertical_pass_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_sun_beams_gpu(), blender::nodes::node_composite_blur_cc::BlurOperation::execute_variable_size_gpu(), blender::nodes::node_composite_bokehblur_cc::BokehBlurOperation::execute_variable_size_gpu(), blender::nodes::node_composite_scale_cc::ScaleOperation::execute_variable_size_gpu(), blender::compositor::extract_alpha_gpu(), blender::nodes::node_composite_keying_cc::KeyingOperation::extract_input_chroma_gpu(), blender::nodes::node_composite_inpaint_cc::InpaintOperation::fill_inpainting_region_gpu(), blender::ed::vse::StripsDrawBatch::flush_batch(), blender::ed::vse::ThumbsDrawBatch::flush_batch(), blender::draw::command::DrawMultiBuf::generate_commands(), 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::compositor::horizontal_pass_gpu(), blender::compositor::horizontal_pass_gpu(), blender::compositor::horizontal_pass_gpu(), immBindShader(), blender::gpu::tests::Shader::init_shader(), blender::compositor::jump_flooding_pass_gpu(), blender::compositor::maximum_float2_gpu(), blender::compositor::maximum_float_gpu(), blender::compositor::maximum_float_in_range_gpu(), blender::compositor::maximum_luminance_gpu(), blender::compositor::minimum_float_gpu(), blender::compositor::minimum_float_in_range_gpu(), blender::compositor::minimum_luminance_gpu(), blender::compositor::morphological_distance_gpu(), 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::render::hydra::ViewportEngine::render(), blender::nodes::node_composite_keying_cc::KeyingOperation::replace_input_chroma_gpu(), blender::compositor::sample_pixel_gpu(), blender::ed::vse::sequencer_draw_scopes(), blender::compositor::sum_blue_gpu(), blender::compositor::sum_blue_squared_difference_gpu(), blender::compositor::sum_causal_and_non_causal_results_gpu(), blender::compositor::sum_causal_and_non_causal_results_gpu(), blender::compositor::sum_color_gpu(), blender::compositor::sum_green_gpu(), blender::compositor::sum_green_squared_difference_gpu(), blender::compositor::sum_log_luminance_gpu(), blender::compositor::sum_luminance_gpu(), blender::compositor::sum_luminance_squared_difference_gpu(), blender::compositor::sum_red_gpu(), blender::compositor::sum_red_squared_difference_gpu(), 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::compositor::vertical_pass_gpu(), blender::compositor::vertical_pass_gpu(), blender::compositor::vertical_pass_gpu(), wm_draw_region_blend(), blender::nodes::node_composite_glare_cc::GlareOperation::write_glare_output_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::write_highlights_output_gpu(), and blender::compositor::zero_pad_gpu().

◆ 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 237 of file gpu_shader.cc.

References gpu_shader_create_info_compile(), and printf.

Referenced by WM_init_gpu().

◆ GPU_shader_create_from_info()

◆ GPU_shader_create_from_info_name()

blender::gpu::Shader * 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 148 of file gpu_shader.cc.

References ShaderCreateInfo::do_static_compilation_, GPU_shader_create_from_info(), gpu_shader_create_info_get(), and ShaderCreateInfo::name_.

Referenced by compile_fallback_shader(), blender::gpu::StaticShader::get(), blender::draw::edit_select::Instance::init(), blender::gpu::tests::Shader::init_shader(), blender::gpu::tests::ShaderSpecializationConst::init_shader(), blender::eevee::Precompute::Precompute(), blender::gpu::tests::test_buffer_texture(), blender::gpu::tests::test_compute_direct(), blender::gpu::tests::test_compute_indirect(), blender::draw::test_draw_curves_interpolate_attributes(), blender::draw::test_draw_curves_interpolate_position(), blender::draw::test_draw_curves_lib(), blender::draw::test_draw_curves_topology(), 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(), blender::draw::TestDefrag::TestDefrag(), and blender::gpu::VKDevice::vk_backbuffer_blit_sh_get().

◆ GPU_shader_create_from_info_python()

◆ 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 135 of file gpu_shader.cc.

References BLI_strncpy(), 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 130 of file gpu_shader.cc.

References gpu_shader_create_info_get().

Referenced by blender::compositor::CachedShader::CachedShader(), blender::gpu::StaticShader::ensure_compile_async(), and blender::eevee::ShaderModule::ShaderModule().

◆ GPU_shader_free()

void GPU_shader_free ( blender::gpu::Shader * shader)

Definition at line 119 of file gpu_shader.cc.

Referenced by blender::gpu::MTLContextTextureUtils::cleanup(), BlenderFallbackDisplayShader::destroy_shader(), gpu_shader_create_info_compile(), 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::compositor::CachedShader::~CachedShader(), blender::ocio::internal::GPUDisplayShader::~GPUDisplayShader(), blender::gpu::tests::Shader::~Shader(), and blender::gpu::tests::ShaderSpecializationConst::~ShaderSpecializationConst().

◆ GPU_shader_get_attribute()

int GPU_shader_get_attribute ( const blender::gpu::Shader * shader,
const char * name )

◆ GPU_shader_get_attribute_info()

bool GPU_shader_get_attribute_info ( const blender::gpu::Shader * shader,
int attr_location,
char r_name[256],
int * r_type )

Definition at line 459 of file gpu_shader.cc.

References BLI_strncpy(), and interface.

Referenced by GPU_vertformat_from_shader(), and pygpu_shader_attrs_info_get().

◆ GPU_shader_get_attribute_len()

uint GPU_shader_get_attribute_len ( const blender::gpu::Shader * shader)

Definition at line 440 of file gpu_shader.cc.

References interface.

Referenced by GPU_vertformat_from_shader(), and pygpu_shader_attrs_info_get().

◆ GPU_shader_get_bound()

blender::gpu::Shader * 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 305 of file gpu_shader.cc.

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

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

◆ GPU_shader_get_builtin_uniform()

int GPU_shader_get_builtin_uniform ( blender::gpu::Shader * 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 406 of file gpu_shader.cc.

References interface.

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

◆ GPU_shader_get_constant()

◆ GPU_shader_get_default_constant_state()

◆ GPU_shader_get_name()

const char * GPU_shader_get_name ( blender::gpu::Shader * shader)

◆ GPU_shader_get_sampler_binding()

◆ GPU_shader_get_ssbo_binding()

int GPU_shader_get_ssbo_binding ( blender::gpu::Shader * shader,
const char * name )

Definition at line 412 of file gpu_shader.cc.

References interface, and name.

Referenced by 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::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(), blender::draw::Manager::end_sync(), blender::draw::command::DrawMultiBuf::generate_commands(), GPU_indexbuf_build_curves_on_device(), pygpu_shader_format_calc(), blender::ed::vse::sequencer_draw_scopes(), 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_input_info()

bool GPU_shader_get_ssbo_input_info ( const blender::gpu::Shader * shader,
int ssbo_location,
char r_name[256] )

Definition at line 476 of file gpu_shader.cc.

References BLI_strncpy(), and interface.

Referenced by pygpu_shader_attrs_info_get().

◆ GPU_shader_get_ssbo_input_len()

uint GPU_shader_get_ssbo_input_len ( const blender::gpu::Shader * shader)

Definition at line 446 of file gpu_shader.cc.

References interface.

Referenced by pygpu_shader_attrs_info_get().

◆ GPU_shader_get_ubo_binding()

◆ GPU_shader_get_uniform()

◆ GPU_shader_get_uniform_block()

int GPU_shader_get_uniform_block ( blender::gpu::Shader * shader,
const char * name )

DEPRECATED: Kept only because of Python GPU API.

Definition at line 419 of file gpu_shader.cc.

References interface, and name.

Referenced by pygpu_shader_uniform_block_from_name().

◆ GPU_shader_preprocess_source()

std::string GPU_shader_preprocess_source ( blender::StringRefNull original)

Preprocess a raw GLSL source to adhere to our backend compatible shader language. Needed if the string was not part of our build system and is used in a #GPUShaderCreateInfo.

Definition at line 167 of file gpu_shader.cc.

References blender::StringRefBase::is_empty(), and blender::gpu::shader::Preprocessor::process().

Referenced by GPU_shader_create_from_info_python().

◆ GPU_shader_set_parent()

void GPU_shader_set_parent ( blender::gpu::Shader * shader,
blender::gpu::Shader * parent )

Definition at line 331 of file gpu_shader.cc.

References BLI_assert, and blender::gpu::Shader::parent_set().

◆ 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 291 of file gpu_shader.cc.

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

Referenced by blender::nodes::node_composite_glare_cc::GlareOperation::accumulate_ghosts_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::accumulate_streak_gpu(), blender::compositor::apply_morphological_operator_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::apply_streak_filter_gpu(), blender::compositor::blend_neighborhood_gpu(), blender::compositor::blur_pass_gpu(), blender::compositor::blur_pass_gpu(), blender::compositor::calculate_blending_weights_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::compute_base_ghost_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::compute_bloom_downsample_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::compute_bloom_upsample_gpu(), blender::nodes::node_composite_double_edge_mask_cc::DoubleEdgeMaskOperation::compute_boundary_gpu(), blender::compositor::compute_complete_blocks(), blender::compositor::compute_complete_x_prologues(), blender::compositor::compute_complete_y_prologues(), blender::nodes::node_composite_defocus_cc::DefocusOperation::compute_defocus_radius_from_depth_gpu(), blender::nodes::node_composite_defocus_cc::DefocusOperation::compute_defocus_radius_from_scale_gpu(), blender::nodes::node_composite_double_edge_mask_cc::DoubleEdgeMaskOperation::compute_gradient_gpu(), blender::nodes::node_composite_base_cryptomatte_cc::BaseCryptoMatteOperation::compute_image_gpu(), blender::nodes::node_composite_keying_cc::KeyingOperation::compute_image_gpu(), blender::compositor::compute_incomplete_prologues(), blender::nodes::node_composite_inpaint_cc::InpaintOperation::compute_inpainting_boundary_gpu(), blender::nodes::node_composite_inpaint_cc::InpaintOperation::compute_inpainting_region_gpu(), blender::nodes::node_composite_zcombine_cc::ZCombineOperation::compute_mask_gpu(), blender::nodes::node_composite_base_cryptomatte_cc::BaseCryptoMatteOperation::compute_matte_gpu(), blender::nodes::node_composite_keying_cc::KeyingOperation::compute_matte_gpu(), 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_gpu(), blender::nodes::node_composite_cornerpin_cc::CornerPinOperation::compute_plane_gpu(), blender::nodes::node_composite_planetrackdeform_cc::PlaneTrackDeformOperation::compute_plane_gpu(), blender::nodes::node_composite_cornerpin_cc::CornerPinOperation::compute_plane_mask_gpu(), blender::nodes::node_composite_planetrackdeform_cc::PlaneTrackDeformOperation::compute_plane_mask_gpu(), blender::compositor::compute_preview_gpu(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::compute_structure_tensor_gpu(), blender::nodes::node_composite_keying_cc::KeyingOperation::compute_tweaked_matte_gpu(), blender::compositor::detect_edges_gpu(), blender::nodes::node_composite_vec_blur_cc::VectorBlurOperation::dilate_max_velocity(), draw_filled_lasso(), 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_paint_overlay_flag_buffer(), blender::draw::draw_subdiv_build_sculpt_data_buffer(), blender::draw::draw_subdiv_build_tris_buffer(), blender::draw::draw_subdiv_extract_pos(), blender::draw::draw_subdiv_extract_uvs(), blender::draw::draw_subdiv_interp_corner_normals(), blender::draw::draw_subdiv_interp_custom_data(), DRW_shaders_free(), blender::compositor::ConversionOperation::execute(), blender::compositor::ShaderOperation::execute(), blender::nodes::node_composite_crop_cc::CropOperation::execute_alpha_crop_gpu(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::execute_anisotropic_gpu(), blender::nodes::node_composite_zcombine_cc::ZCombineOperation::execute_anti_aliased_depth_gpu(), blender::nodes::node_composite_zcombine_cc::ZCombineOperation::execute_anti_aliased_image_gpu(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::execute_classic_convolution_gpu(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::execute_classic_summed_area_table_gpu(), blender::nodes::node_composite_blur_cc::BlurOperation::execute_constant_size_gpu(), blender::nodes::node_composite_bokehblur_cc::BokehBlurOperation::execute_constant_size_gpu(), blender::nodes::node_composite_group_output_cc::GroupOutputOperation::execute_copy_gpu(), blender::nodes::node_composite_viewer_cc::ViewerOperation::execute_copy_gpu(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::execute_distance_threshold_gpu(), blender::nodes::node_composite_bilateralblur_cc::BilateralBlurOperation::execute_gpu(), blender::nodes::node_composite_boxmask_cc::BoxMaskOperation::execute_gpu(), blender::nodes::node_composite_defocus_cc::DefocusOperation::execute_gpu(), blender::nodes::node_composite_despeckle_cc::DespeckleOperation::execute_gpu(), blender::nodes::node_composite_directionalblur_cc::DirectionalBlurOperation::execute_gpu(), blender::nodes::node_composite_displace_cc::DisplaceOperation::execute_gpu(), blender::nodes::node_composite_ellipsemask_cc::EllipseMaskOperation::execute_gpu(), blender::nodes::node_composite_filter_cc::FilterOperation::execute_gpu(), blender::nodes::node_composite_flip_cc::FlipOperation::execute_gpu(), blender::nodes::node_composite_id_mask_cc::IDMaskOperation::execute_gpu(), blender::nodes::node_composite_map_uv_cc::MapUVOperation::execute_gpu(), blender::nodes::node_composite_moviedistortion_cc::MovieDistortionOperation::execute_gpu(), blender::nodes::node_composite_normalize_cc::NormalizeOperation::execute_gpu(), blender::nodes::node_composite_pixelate_cc::PixelateOperation::execute_gpu(), blender::nodes::node_composite_split_cc::SplitOperation::execute_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_highlights_gpu(), blender::nodes::node_composite_lensdist_cc::LensDistortionOperation::execute_horizontal_distortion_gpu(), blender::nodes::node_composite_crop_cc::CropOperation::execute_image_crop_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_mix_gpu(), blender::nodes::node_composite_group_input_cc::GroupInputOperation::execute_pass_gpu(), blender::nodes::node_composite_render_layer_cc::RenderLayerOperation::execute_pass_gpu(), blender::nodes::node_composite_tonemap_cc::ToneMapOperation::execute_photoreceptor_gpu(), blender::nodes::node_composite_lensdist_cc::LensDistortionOperation::execute_radial_distortion_gpu(), blender::nodes::node_composite_zcombine_cc::ZCombineOperation::execute_simple_depth_gpu(), blender::nodes::node_composite_tonemap_cc::ToneMapOperation::execute_simple_gpu(), blender::nodes::node_composite_zcombine_cc::ZCombineOperation::execute_simple_image_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_anti_diagonal_pass_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_diagonal_pass_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_horizontal_pass_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_vertical_pass_gpu(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::execute_step_horizontal_pass_gpu(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::execute_step_vertical_pass_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_sun_beams_gpu(), blender::nodes::node_composite_blur_cc::BlurOperation::execute_variable_size_gpu(), blender::nodes::node_composite_bokehblur_cc::BokehBlurOperation::execute_variable_size_gpu(), blender::nodes::node_composite_scale_cc::ScaleOperation::execute_variable_size_gpu(), blender::compositor::extract_alpha_gpu(), blender::nodes::node_composite_keying_cc::KeyingOperation::extract_input_chroma_gpu(), blender::nodes::node_composite_inpaint_cc::InpaintOperation::fill_inpainting_region_gpu(), GPU_context_active_set(), GPU_indexbuf_build_curves_on_device(), GPU_shader_free_builtin_shaders(), blender::gpu::tests::gpu_shader_lib_test(), blender::compositor::horizontal_pass_gpu(), blender::compositor::horizontal_pass_gpu(), blender::compositor::horizontal_pass_gpu(), immUnbindProgram(), blender::compositor::jump_flooding_pass_gpu(), blender::compositor::maximum_float2_gpu(), blender::compositor::maximum_float_gpu(), blender::compositor::maximum_float_in_range_gpu(), blender::compositor::maximum_luminance_gpu(), blender::compositor::minimum_float_gpu(), blender::compositor::minimum_float_in_range_gpu(), blender::compositor::minimum_luminance_gpu(), blender::compositor::morphological_distance_gpu(), blender::eevee::Precompute::Precompute(), pygpu_batch_program_use_end(), pygpu_shader_unbind(), blender::render::hydra::ViewportEngine::render(), blender::nodes::node_composite_keying_cc::KeyingOperation::replace_input_chroma_gpu(), blender::compositor::sample_pixel_gpu(), blender::ed::vse::sequencer_draw_scopes(), blender::compositor::sum_blue_gpu(), blender::compositor::sum_blue_squared_difference_gpu(), blender::compositor::sum_causal_and_non_causal_results_gpu(), blender::compositor::sum_causal_and_non_causal_results_gpu(), blender::compositor::sum_color_gpu(), blender::compositor::sum_green_gpu(), blender::compositor::sum_green_squared_difference_gpu(), blender::compositor::sum_log_luminance_gpu(), blender::compositor::sum_luminance_gpu(), blender::compositor::sum_luminance_squared_difference_gpu(), blender::compositor::sum_red_gpu(), blender::compositor::sum_red_squared_difference_gpu(), blender::gpu::tests::test_buffer_texture(), blender::gpu::tests::test_compute_direct(), blender::gpu::tests::test_compute_indirect(), blender::draw::test_draw_curves_interpolate_attributes(), blender::draw::test_draw_curves_interpolate_position(), blender::draw::test_draw_curves_lib(), blender::draw::test_draw_curves_topology(), 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::draw::TestAlloc::TestAlloc(), blender::draw::TestDefrag::TestDefrag(), BlenderFallbackDisplayShader::unbind(), blender::compositor::vertical_pass_gpu(), blender::compositor::vertical_pass_gpu(), blender::compositor::vertical_pass_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::write_glare_output_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::write_highlights_output_gpu(), blender::compositor::zero_pad_gpu(), blender::gpu::tests::Shader::~Shader(), and blender::gpu::tests::ShaderSpecializationConst::~ShaderSpecializationConst().

◆ GPU_shader_uniform_1b()

◆ GPU_shader_uniform_1f()

void GPU_shader_uniform_1f ( blender::gpu::Shader * sh,
const char * name,
float value )

Definition at line 539 of file gpu_shader.cc.

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

Referenced by blender::nodes::node_composite_glare_cc::GlareOperation::accumulate_streak_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::apply_streak_filter_gpu(), blender::compositor::blur_pass_gpu(), blender::compositor::blur_pass_gpu(), blender::nodes::node_composite_defocus_cc::DefocusOperation::compute_defocus_radius_from_depth_gpu(), blender::nodes::node_composite_defocus_cc::DefocusOperation::compute_defocus_radius_from_scale_gpu(), blender::nodes::node_composite_keying_cc::KeyingOperation::compute_image_gpu(), blender::nodes::node_composite_keying_cc::KeyingOperation::compute_matte_gpu(), blender::nodes::node_composite_vec_blur_cc::VectorBlurOperation::compute_motion_blur(), blender::nodes::node_composite_keying_cc::KeyingOperation::compute_tweaked_matte_gpu(), blender::compositor::detect_edges_gpu(), blender::nodes::node_composite_vec_blur_cc::VectorBlurOperation::dilate_max_velocity(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::execute_anisotropic_gpu(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::execute_distance_threshold_gpu(), blender::nodes::node_composite_bilateralblur_cc::BilateralBlurOperation::execute_gpu(), blender::nodes::node_composite_boxmask_cc::BoxMaskOperation::execute_gpu(), blender::nodes::node_composite_despeckle_cc::DespeckleOperation::execute_gpu(), blender::nodes::node_composite_directionalblur_cc::DirectionalBlurOperation::execute_gpu(), blender::nodes::node_composite_ellipsemask_cc::EllipseMaskOperation::execute_gpu(), blender::nodes::node_composite_normalize_cc::NormalizeOperation::execute_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_highlights_gpu(), blender::nodes::node_composite_lensdist_cc::LensDistortionOperation::execute_horizontal_distortion_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_mix_gpu(), blender::nodes::node_composite_tonemap_cc::ToneMapOperation::execute_photoreceptor_gpu(), blender::nodes::node_composite_lensdist_cc::LensDistortionOperation::execute_radial_distortion_gpu(), blender::nodes::node_composite_tonemap_cc::ToneMapOperation::execute_simple_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_anti_diagonal_pass_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_diagonal_pass_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_horizontal_pass_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_vertical_pass_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_sun_beams_gpu(), immUniform1f(), blender::compositor::maximum_float_in_range_gpu(), blender::compositor::minimum_float_in_range_gpu(), blender::ed::vse::sequencer_draw_scopes(), blender::compositor::sum_blue_squared_difference_gpu(), blender::compositor::sum_green_squared_difference_gpu(), blender::compositor::sum_luminance_squared_difference_gpu(), blender::compositor::sum_red_squared_difference_gpu(), blender::gpu::VKContext::update_pipeline_data(), blender::gpu::tests::Shader::update_push_constants(), and blender::nodes::node_composite_glare_cc::GlareOperation::write_glare_output_gpu().

◆ GPU_shader_uniform_1f_array()

void GPU_shader_uniform_1f_array ( blender::gpu::Shader * sh,
const char * name,
int len,
const float * val )

◆ GPU_shader_uniform_1i()

void GPU_shader_uniform_1i ( blender::gpu::Shader * 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 509 of file gpu_shader.cc.

References GPU_shader_get_uniform(), GPU_shader_uniform_int_ex(), and name.

Referenced by bind_attribute_as_ssbo(), blender::compositor::calculate_blending_weights_gpu(), blender::nodes::node_composite_inpaint_cc::InpaintOperation::compute_inpainting_region_gpu(), blender::nodes::node_composite_base_cryptomatte_cc::BaseCryptoMatteOperation::compute_matte_gpu(), blender::nodes::node_composite_vec_blur_cc::VectorBlurOperation::compute_motion_blur(), blender::nodes::node_composite_planetrackdeform_cc::PlaneTrackDeformOperation::compute_plane_gpu(), blender::nodes::node_composite_planetrackdeform_cc::PlaneTrackDeformOperation::compute_plane_mask_gpu(), blender::nodes::node_composite_keying_cc::KeyingOperation::compute_tweaked_matte_gpu(), blender::draw::View::compute_visibility(), blender::render::hydra::DrawTexture::draw(), blender::draw::Manager::end_sync(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::execute_classic_convolution_gpu(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::execute_classic_summed_area_table_gpu(), blender::nodes::node_composite_bokehblur_cc::BokehBlurOperation::execute_constant_size_gpu(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::execute_distance_threshold_gpu(), blender::nodes::node_composite_bilateralblur_cc::BilateralBlurOperation::execute_gpu(), blender::nodes::node_composite_defocus_cc::DefocusOperation::execute_gpu(), blender::nodes::node_composite_directionalblur_cc::DirectionalBlurOperation::execute_gpu(), blender::nodes::node_composite_id_mask_cc::IDMaskOperation::execute_gpu(), blender::nodes::node_composite_pixelate_cc::PixelateOperation::execute_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_highlights_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_anti_diagonal_pass_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_diagonal_pass_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_horizontal_pass_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_simple_star_vertical_pass_gpu(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::execute_step_horizontal_pass_gpu(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::execute_step_vertical_pass_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_sun_beams_gpu(), blender::nodes::node_composite_bokehblur_cc::BokehBlurOperation::execute_variable_size_gpu(), blender::nodes::node_composite_inpaint_cc::InpaintOperation::fill_inpainting_region_gpu(), blender::draw::command::DrawMultiBuf::generate_commands(), GPU_batch_bind_as_resources(), GPU_indexbuf_build_curves_on_device(), GPU_shader_get_builtin_shader_with_config(), GPU_shader_uniform_1b(), immUniform1i(), blender::compositor::jump_flooding_pass_gpu(), blender::compositor::morphological_distance_gpu(), blender::gpu::Immediate::polyline_draw_workaround(), pygpu_shader_uniform_sampler(), and blender::ed::vse::sequencer_draw_scopes().

◆ GPU_shader_uniform_2f()

void GPU_shader_uniform_2f ( blender::gpu::Shader * sh,
const char * name,
float x,
float y )

Definition at line 520 of file gpu_shader.cc.

References data, GPU_shader_uniform_2fv(), name, x, and y.

Referenced by immUniform2f().

◆ GPU_shader_uniform_2fv()

◆ GPU_shader_uniform_2fv_array()

void GPU_shader_uniform_2fv_array ( blender::gpu::Shader * sh,
const char * name,
int len,
const float(*) val[2] )

Definition at line 599 of file gpu_shader.cc.

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

◆ GPU_shader_uniform_2iv()

◆ GPU_shader_uniform_3f()

void GPU_shader_uniform_3f ( blender::gpu::Shader * sh,
const char * name,
float x,
float y,
float z )

Definition at line 526 of file gpu_shader.cc.

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

Referenced by immUniform3f().

◆ GPU_shader_uniform_3fv()

◆ GPU_shader_uniform_3iv()

void GPU_shader_uniform_3iv ( blender::gpu::Shader * sh,
const char * name,
const int data[3] )

◆ GPU_shader_uniform_4f()

void GPU_shader_uniform_4f ( blender::gpu::Shader * sh,
const char * name,
float x,
float y,
float z,
float w )

Definition at line 532 of file gpu_shader.cc.

References data, GPU_shader_uniform_4fv(), name, 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 ( blender::gpu::Shader * 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 ( blender::gpu::Shader * sh,
const char * name,
const float data[4][4] )

◆ GPU_shader_warm_cache()

void GPU_shader_warm_cache ( blender::gpu::Shader * 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 GPUVertFormat and #gpu::FrameBuffer 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 342 of file gpu_shader.cc.

Variable Documentation

◆ GPU_MAX_ATTR

◆ GPU_MAX_UNIFORM_ATTR

int GPU_MAX_UNIFORM_ATTR = 8
staticconstexpr

Definition at line 36 of file GPU_shader.hh.

Referenced by gpu_node_graph_add_uniform_attribute().