25 : context_(&context), type_(type), precision_(precision)
176 switch (channels_count) {
193Result::operator GPUTexture *()
const
214 is_single_value_ =
false;
215 this->allocate_data(domain.size, from_pool);
223 is_single_value_ =
true;
224 this->allocate_data(
int2(1),
true);
297 const int initial_reference_count = target.initial_reference_count_;
299 target.initial_reference_count_ = initial_reference_count;
301 target.master_ =
this;
309 BLI_assert(master_ ==
nullptr && source.master_ ==
nullptr);
313 const int initial_reference_count = initial_reference_count_;
316 initial_reference_count_ = initial_reference_count;
330 is_single_value_ =
false;
419 return default_value;
428 return default_value;
437 return default_value;
446 return default_value;
455 return default_value;
464 return default_value;
474 switch (storage_type_) {
494 switch (storage_type_) {
514 switch (storage_type_) {
534 switch (storage_type_) {
554 switch (storage_type_) {
574 switch (storage_type_) {
589 initial_reference_count_ =
count;
594 const int initial_reference_count = initial_reference_count_;
595 *
this =
Result(*context_, type_, precision_);
596 initial_reference_count_ = initial_reference_count;
597 reference_count_ = initial_reference_count;
608 reference_count_ +=
count;
622 if (reference_count_ != 0) {
634 switch (storage_type_) {
657 return initial_reference_count_ != 0;
686 return is_single_value_;
691 switch (storage_type_) {
709 return reference_count_;
726 if (is_single_value_) {
730 this->copy_pixel(pixel_value, this->get_float_pixel(texel));
737 this->copy_pixel(this->get_float_pixel(texel), pixel_value);
740void Result::allocate_data(
int2 size,
bool from_pool)
743 is_from_pool_ = from_pool;
752 this->get_gpu_texture_format(),
765 int64_t(size.x) *
int64_t(size.y), this->channels_count() *
sizeof(
float), __func__));
770 int64_t(size.x) *
int64_t(size.y), this->channels_count() *
sizeof(
int), __func__));
777int64_t Result::channels_count()
const
794float *Result::get_float_pixel(
const int2 &texel)
const
799void Result::copy_pixel(
float *target,
const float *source)
const
#define BLI_assert_unreachable()
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v2_v2_int(int r[2], const int a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
int GPU_shader_get_sampler_binding(GPUShader *shader, const char *name)
void GPU_memory_barrier(eGPUBarrier barrier)
@ GPU_BARRIER_TEXTURE_FETCH
@ GPU_BARRIER_SHADER_IMAGE_ACCESS
int GPU_texture_height(const GPUTexture *texture)
void GPU_texture_bind(GPUTexture *texture, int unit)
GPUTexture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_texture_free(GPUTexture *texture)
int GPU_texture_width(const GPUTexture *texture)
void GPU_texture_unbind(GPUTexture *texture)
@ GPU_TEXTURE_USAGE_GENERAL
void GPU_texture_image_unbind(GPUTexture *texture)
void GPU_texture_image_bind(GPUTexture *texture, int unit)
void GPU_texture_update(GPUTexture *texture, eGPUDataFormat data_format, const void *data)
eGPUTextureFormat GPU_texture_format(const GPUTexture *texture)
Read Guarded memory(de)allocation.
struct GPUShader GPUShader
virtual bool use_gpu() const =0
TexturePool & texture_pool()
void transform(const float3x3 &input_transformation)
RealizationOptions realization_options
float get_float_value_default(float default_value) const
float get_float_value() const
float4 load_pixel(const int2 &texel) const
void set_int2_value(const int2 &value)
void wrap_external(GPUTexture *texture)
ResultPrecision precision() const
void bind_as_image(GPUShader *shader, const char *image_name, bool read=false) const
float2 get_float2_value() const
int2 get_int2_value() const
void pass_through(Result &target)
void set_float3_value(const float3 &value)
bool is_allocated() const
void unbind_as_texture() const
eGPUTextureFormat get_gpu_texture_format() const
float3 get_float3_value_default(const float3 &default_value) const
const Domain & domain() const
int reference_count() const
void set_precision(ResultPrecision precision)
float4 get_vector_value() const
float4 get_color_value() const
float4 get_vector_value_default(const float4 &default_value) const
void transform(const float3x3 &transformation)
static eGPUTextureFormat gpu_texture_format(ResultType type, ResultPrecision precision)
void set_transformation(const float3x3 &transformation)
float4 get_color_value_default(const float4 &default_value) const
float2 get_float2_value_default(const float2 &default_value) const
void store_pixel(const int2 &texel, const float4 &pixel_value)
void unbind_as_image() const
void set_float_value(float value)
bool is_single_value() const
void set_float2_value(const float2 &value)
void increment_reference_count(int count=1)
void allocate_texture(Domain domain, bool from_pool=true)
void set_type(ResultType type)
float3 get_float3_value() const
int2 get_int2_value_default(const int2 &default_value) const
void set_vector_value(const float4 &value)
void steal_data(Result &source)
GPUTexture * gpu_texture_
void set_initial_reference_count(int count)
void set_color_value(const float4 &value)
RealizationOptions & get_realization_options()
void bind_as_texture(GPUShader *shader, const char *texture_name) const
static ResultType float_type(const int channels_count)
void allocate_single_value()
void release(GPUTexture *texture)
GPUTexture * acquire(int2 size, eGPUTextureFormat format)
additional_info("compositor_sum_float_shared") .push_constant(Type additional_info("compositor_sum_float_shared") .push_constant(Type GPU_RGBA32F
local_group_size(16, 16) .push_constant(Type texture
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< float, 3 > float3