28struct GPUShaderCreateInfo;
197 GPUShader *shader,
int location,
int length,
int array_size,
const float *value);
199 GPUShader *shader,
int location,
int length,
int array_size,
const int *value);
300 std::optional<blender::StringRefNull> fragcode,
301 std::optional<blender::StringRefNull> geomcode,
302 std::optional<blender::StringRefNull> libcode,
303 std::optional<blender::StringRefNull> defines,
306 std::optional<blender::StringRefNull> libcode,
307 std::optional<blender::StringRefNull> defines,
310 std::optional<blender::StringRefNull> fragcode,
311 std::optional<blender::StringRefNull> geomcode,
312 std::optional<blender::StringRefNull> libcode,
313 std::optional<blender::StringRefNull> defines,
314 std::optional<blender::StringRefNull> name);
316 std::optional<blender::StringRefNull> fragcode,
317 std::optional<blender::StringRefNull> geomcode,
318 std::optional<blender::StringRefNull> computecode,
319 std::optional<blender::StringRefNull> libcode,
320 std::optional<blender::StringRefNull> defines,
391#define GPU_NUM_UNIFORMS (GPU_UNIFORM_SRGB_TRANSFORM + 1)
430#define GPU_SHADER_FREE_SAFE(shader) \
432 if (shader != nullptr) { \
433 GPU_shader_free(shader); \
449 std::string info_name_;
450 std::atomic<GPUShader *> shader_ =
nullptr;
452 std::atomic<bool> failed_ =
false;
459 std::scoped_lock lock1(mutex_);
460 std::scoped_lock lock2(other.mutex_);
461 BLI_assert(shader_ ==
nullptr && info_name_.empty());
462 std::swap(info_name_, other.info_name_);
464 shader_.exchange(other.shader_.exchange(shader_));
465 failed_.exchange(other.failed_.exchange(failed_));
466 std::swap(compilation_handle_, other.compilation_handle_);
475 move(std::move(other));
479 move(std::move(other));
485 if (compilation_handle_) {
498 std::scoped_lock
lock(mutex_);
500 if (compilation_handle_) {
503 failed_ = shader_ ==
nullptr;
508 if (!shader_ && !failed_ && !compilation_handle_) {
517 return shader_ || failed_;
526 std::scoped_lock
lock(mutex_);
528 if (!shader_ && !failed_) {
529 if (compilation_handle_) {
536 failed_ = shader_ ==
nullptr;
546 std::scoped_lock
lock(mutex_);
555 std::atomic<T *> cache_ =
nullptr;
564 template<
typename... Args>
T &
get(Args &&...constructor_args)
570 std::lock_guard
lock(mutex_);
572 if (cache_ ==
nullptr) {
573 cache_ =
new T(std::forward<Args>(constructor_args)...);
584 std::lock_guard
lock(mutex_);
594 return std::lock_guard(mutex_);
int GPU_shader_get_sampler_binding(GPUShader *shader, const char *name)
int GPU_shader_get_uniform(GPUShader *shader, const char *name)
GPUShader * GPU_shader_create_from_info_python(const GPUShaderCreateInfo *_info)
void GPU_shader_uniform_2fv(GPUShader *sh, const char *name, const float data[2])
GPUShader * GPU_shader_create_compute(std::optional< blender::StringRefNull > computecode, std::optional< blender::StringRefNull > libcode, std::optional< blender::StringRefNull > defines, blender::StringRefNull shname)
bool GPU_shader_get_attribute_info(const GPUShader *shader, int attr_location, char r_name[256], int *r_type)
const char * GPU_shader_get_name(GPUShader *shader)
void GPU_shader_uniform_1i(GPUShader *sh, const char *name, int value)
int GPU_shader_get_ubo_binding(GPUShader *shader, const char *name)
#define GPU_SHADER_FREE_SAFE(shader)
void GPU_shader_uniform_3f(GPUShader *sh, const char *name, float x, float y, float z)
void GPU_shader_uniform_3iv(GPUShader *sh, const char *name, const int data[3])
blender::Vector< GPUShader * > GPU_shader_batch_finalize(BatchHandle &handle)
void GPU_shader_uniform_2f(GPUShader *sh, const char *name, float x, float y)
static constexpr int GPU_MAX_ATTR
uint GPU_shader_get_ssbo_input_len(const GPUShader *shader)
void GPU_shader_uniform_2fv_array(GPUShader *sh, const char *name, int len, const float(*val)[2])
GPUShader * GPU_shader_create_ex(std::optional< blender::StringRefNull > vertcode, std::optional< blender::StringRefNull > fragcode, std::optional< blender::StringRefNull > geomcode, std::optional< blender::StringRefNull > computecode, std::optional< blender::StringRefNull > libcode, std::optional< blender::StringRefNull > defines, blender::StringRefNull shname)
void GPU_shader_uniform_int_ex(GPUShader *shader, int location, int length, int array_size, const int *value)
GPUShader * GPU_shader_create_from_info_name(const char *info_name)
void GPU_shader_cache_dir_clear_old()
void GPU_shader_uniform_1f(GPUShader *sh, const char *name, float value)
void GPU_shader_bind(GPUShader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_shader_uniform_mat3_as_mat4(GPUShader *sh, const char *name, const float data[3][3])
void GPU_shader_uniform_3fv(GPUShader *sh, const char *name, const float data[3])
void GPU_shader_uniform_1f_array(GPUShader *sh, const char *name, int len, const float *val)
uint GPU_shader_get_attribute_len(const GPUShader *shader)
int GPU_shader_get_ssbo_binding(GPUShader *shader, const char *name)
int GPU_shader_get_attribute(const GPUShader *shader, const char *name)
bool GPU_shader_batch_is_compiling()
void GPU_shader_batch_wait_for_all()
void GPU_shader_uniform_2iv(GPUShader *sh, const char *name, const int data[2])
void GPU_shader_uniform_4fv_array(GPUShader *sh, const char *name, int len, const float(*val)[4])
GPUShader * GPU_shader_create_from_python(std::optional< blender::StringRefNull > vertcode, std::optional< blender::StringRefNull > fragcode, std::optional< blender::StringRefNull > geomcode, std::optional< blender::StringRefNull > libcode, std::optional< blender::StringRefNull > defines, std::optional< blender::StringRefNull > name)
void GPU_shader_set_parent(GPUShader *shader, GPUShader *parent)
bool GPU_shader_batch_is_ready(BatchHandle handle)
int GPU_shader_get_builtin_block(GPUShader *shader, int builtin)
void GPU_shader_uniform_float_ex(GPUShader *shader, int location, int length, int array_size, const float *value)
std::string GPU_shader_preprocess_source(blender::StringRefNull original)
SpecializationBatchHandle GPU_shader_batch_specializations(blender::Span< ShaderSpecialization > specializations, CompilationPriority priority=CompilationPriority::High)
const GPUShaderCreateInfo * GPU_shader_create_info_get(const char *info_name)
void GPU_shader_batch_specializations_cancel(SpecializationBatchHandle &handle)
static constexpr int GPU_MAX_UNIFORM_ATTR
void GPU_shader_uniform_1b(GPUShader *sh, const char *name, bool value)
@ GPU_UNIFORM_VIEWPROJECTION_INV
@ GPU_UNIFORM_RESOURCE_ID
@ GPU_UNIFORM_VIEWPROJECTION
@ GPU_UNIFORM_SRGB_TRANSFORM
@ GPU_UNIFORM_BASE_INSTANCE
@ GPU_UNIFORM_PROJECTION_INV
@ GPU_UNIFORM_MODELVIEW_INV
@ GPU_UNIFORM_RESOURCE_CHUNK
GPUShader * GPU_shader_create_from_info(const GPUShaderCreateInfo *_info)
void GPU_shader_uniform_4fv(GPUShader *sh, const char *name, const float data[4])
void GPU_shader_uniform_4f(GPUShader *sh, const char *name, float x, float y, float z, float w)
int GPU_shader_get_uniform_block(GPUShader *shader, const char *name)
int64_t SpecializationBatchHandle
GPUShader * GPU_shader_create(std::optional< blender::StringRefNull > vertcode, std::optional< blender::StringRefNull > fragcode, std::optional< blender::StringRefNull > geomcode, std::optional< blender::StringRefNull > libcode, std::optional< blender::StringRefNull > defines, blender::StringRefNull shname)
void GPU_shader_uniform_mat4(GPUShader *sh, const char *name, const float data[4][4])
int GPU_shader_get_constant(GPUShader *shader, const char *name)
int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin)
void GPU_shader_batch_cancel(BatchHandle &handle)
void GPU_shader_free(GPUShader *shader)
bool GPU_shader_create_info_check_error(const GPUShaderCreateInfo *_info, char r_error[128])
GPUShader * GPU_shader_get_bound()
BatchHandle GPU_shader_batch_create_from_infos(blender::Span< const GPUShaderCreateInfo * > infos, CompilationPriority priority=CompilationPriority::High)
void GPU_shader_warm_cache(GPUShader *shader, int limit)
@ GPU_UNIFORM_BLOCK_DRW_VIEW
@ GPU_UNIFORM_BLOCK_DRW_MODEL
@ GPU_UNIFORM_BLOCK_MODEL
@ GPU_UNIFORM_BLOCK_DRW_CLIPPING
@ GPU_UNIFORM_BLOCK_DRW_INFOS
bool GPU_shader_batch_specializations_is_ready(SpecializationBatchHandle &handle)
const blender::gpu::shader::SpecializationConstants & GPU_shader_get_default_constant_state(GPUShader *sh)
void GPU_shader_compile_static()
bool GPU_shader_get_ssbo_input_info(const GPUShader *shader, int ssbo_location, char r_name[256])
BMesh const char void * data
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
NonCopyable(const NonCopyable &other)=delete
T & get(Args &&...constructor_args)
std::lock_guard< std::mutex > lock_guard()
StaticShader & operator=(StaticShader &&other)
void set(GPUShader *shader)
StaticShader(StaticShader &&other)
void ensure_compile_async()
StaticShader(std::string info_name)
float length(VecOp< float, D >) RET
blender::gpu::shader::SpecializationConstants constants