28struct GPUShaderCreateInfo;
193 GPUShader *shader,
int location,
int length,
int array_size,
const float *value);
195 GPUShader *shader,
int location,
int length,
int array_size,
const int *value);
296 std::optional<blender::StringRefNull> fragcode,
297 std::optional<blender::StringRefNull> geomcode,
298 std::optional<blender::StringRefNull> libcode,
299 std::optional<blender::StringRefNull> defines,
302 std::optional<blender::StringRefNull> libcode,
303 std::optional<blender::StringRefNull> defines,
306 std::optional<blender::StringRefNull> fragcode,
307 std::optional<blender::StringRefNull> geomcode,
308 std::optional<blender::StringRefNull> libcode,
309 std::optional<blender::StringRefNull> defines,
310 std::optional<blender::StringRefNull> name);
312 std::optional<blender::StringRefNull> fragcode,
313 std::optional<blender::StringRefNull> geomcode,
314 std::optional<blender::StringRefNull> computecode,
315 std::optional<blender::StringRefNull> libcode,
316 std::optional<blender::StringRefNull> defines,
387#define GPU_NUM_UNIFORMS (GPU_UNIFORM_SRGB_TRANSFORM + 1)
426#define GPU_SHADER_FREE_SAFE(shader) \
428 if (shader != nullptr) { \
429 GPU_shader_free(shader); \
445 std::string info_name_;
446 std::atomic<GPUShader *> shader_ =
nullptr;
448 std::atomic<bool> failed_ =
false;
455 std::scoped_lock lock1(mutex_);
456 std::scoped_lock lock2(other.mutex_);
457 BLI_assert(shader_ ==
nullptr && info_name_.empty());
458 std::swap(info_name_, other.info_name_);
460 shader_.exchange(other.shader_.exchange(shader_));
461 failed_.exchange(other.failed_.exchange(failed_));
462 std::swap(compilation_handle_, other.compilation_handle_);
471 move(std::move(other));
475 move(std::move(other));
481 if (compilation_handle_) {
494 std::scoped_lock
lock(mutex_);
496 if (compilation_handle_) {
499 failed_ = shader_ ==
nullptr;
504 if (!shader_ && !failed_ && !compilation_handle_) {
513 return shader_ || failed_;
522 std::scoped_lock
lock(mutex_);
524 if (!shader_ && !failed_) {
525 if (compilation_handle_) {
532 failed_ = shader_ ==
nullptr;
542 std::scoped_lock
lock(mutex_);
551 std::atomic<T *> cache_ =
nullptr;
560 template<
typename... Args>
T &
get(Args &&...constructor_args)
566 std::lock_guard
lock(mutex_);
568 if (cache_ ==
nullptr) {
569 cache_ =
new T(std::forward<Args>(constructor_args)...);
580 std::lock_guard
lock(mutex_);
590 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)
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