71 return blender::gpu::TextureFormat::SFLOAT_16;
74 return blender::gpu::TextureFormat::SFLOAT_16_16_16_16;
78 return blender::gpu::TextureFormat::SFLOAT_16_16_16_16;
80 return blender::gpu::TextureFormat::SFLOAT_16_16;
82 return blender::gpu::TextureFormat::SINT_16;
84 return blender::gpu::TextureFormat::SINT_16_16;
87 return blender::gpu::TextureFormat::SINT_8;
91 return blender::gpu::TextureFormat::SINT_8;
102 return blender::gpu::TextureFormat::SFLOAT_32;
105 return blender::gpu::TextureFormat::SFLOAT_32_32_32_32;
109 return blender::gpu::TextureFormat::SFLOAT_32_32_32_32;
111 return blender::gpu::TextureFormat::SFLOAT_32_32;
113 return blender::gpu::TextureFormat::SINT_32;
115 return blender::gpu::TextureFormat::SINT_32_32;
118 return blender::gpu::TextureFormat::SINT_8;
122 return blender::gpu::TextureFormat::SINT_8;
133 return blender::gpu::TextureFormat::SFLOAT_32_32_32_32;
168 case blender::gpu::TextureFormat::SFLOAT_16:
169 case blender::gpu::TextureFormat::SFLOAT_16_16:
170 case blender::gpu::TextureFormat::SFLOAT_16_16_16:
171 case blender::gpu::TextureFormat::SFLOAT_16_16_16_16:
172 case blender::gpu::TextureFormat::SINT_16:
173 case blender::gpu::TextureFormat::SINT_16_16:
177 case blender::gpu::TextureFormat::SINT_8:
180 case blender::gpu::TextureFormat::SFLOAT_32:
181 return blender::gpu::TextureFormat::SFLOAT_16;
182 case blender::gpu::TextureFormat::SFLOAT_32_32:
183 return blender::gpu::TextureFormat::SFLOAT_16_16;
184 case blender::gpu::TextureFormat::SFLOAT_32_32_32:
185 return blender::gpu::TextureFormat::SFLOAT_16_16_16;
186 case blender::gpu::TextureFormat::SFLOAT_32_32_32_32:
187 return blender::gpu::TextureFormat::SFLOAT_16_16_16_16;
188 case blender::gpu::TextureFormat::SINT_32:
189 return blender::gpu::TextureFormat::SINT_16;
190 case blender::gpu::TextureFormat::SINT_32_32:
191 return blender::gpu::TextureFormat::SINT_16_16;
199 case blender::gpu::TextureFormat::SFLOAT_32:
200 case blender::gpu::TextureFormat::SFLOAT_32_32:
201 case blender::gpu::TextureFormat::SFLOAT_32_32_32:
202 case blender::gpu::TextureFormat::SFLOAT_32_32_32_32:
203 case blender::gpu::TextureFormat::SINT_32:
204 case blender::gpu::TextureFormat::SINT_32_32:
208 case blender::gpu::TextureFormat::SINT_8:
211 case blender::gpu::TextureFormat::SFLOAT_16:
212 return blender::gpu::TextureFormat::SFLOAT_32;
213 case blender::gpu::TextureFormat::SFLOAT_16_16:
214 return blender::gpu::TextureFormat::SFLOAT_32_32;
215 case blender::gpu::TextureFormat::SFLOAT_16_16_16:
216 return blender::gpu::TextureFormat::SFLOAT_32_32_32;
217 case blender::gpu::TextureFormat::SFLOAT_16_16_16_16:
218 return blender::gpu::TextureFormat::SFLOAT_32_32_32_32;
219 case blender::gpu::TextureFormat::SINT_16:
220 return blender::gpu::TextureFormat::SINT_32;
221 case blender::gpu::TextureFormat::SINT_16_16:
222 return blender::gpu::TextureFormat::SINT_32_32;
236 case blender::gpu::TextureFormat::SFLOAT_16:
237 case blender::gpu::TextureFormat::SFLOAT_16_16:
238 case blender::gpu::TextureFormat::SFLOAT_16_16_16:
239 case blender::gpu::TextureFormat::SFLOAT_16_16_16_16:
240 case blender::gpu::TextureFormat::SINT_16:
241 case blender::gpu::TextureFormat::SINT_16_16:
243 case blender::gpu::TextureFormat::SFLOAT_32:
244 case blender::gpu::TextureFormat::SFLOAT_32_32:
245 case blender::gpu::TextureFormat::SFLOAT_32_32_32:
246 case blender::gpu::TextureFormat::SFLOAT_32_32_32_32:
247 case blender::gpu::TextureFormat::SINT_32:
248 case blender::gpu::TextureFormat::SINT_32_32:
251 case blender::gpu::TextureFormat::SINT_8:
264 case blender::gpu::TextureFormat::SFLOAT_16:
265 case blender::gpu::TextureFormat::SFLOAT_32:
267 case blender::gpu::TextureFormat::SFLOAT_16_16:
268 case blender::gpu::TextureFormat::SFLOAT_32_32:
270 case blender::gpu::TextureFormat::SFLOAT_16_16_16:
271 case blender::gpu::TextureFormat::SFLOAT_32_32_32:
273 case blender::gpu::TextureFormat::SFLOAT_16_16_16_16:
274 case blender::gpu::TextureFormat::SFLOAT_32_32_32_32:
276 case blender::gpu::TextureFormat::SINT_16:
277 case blender::gpu::TextureFormat::SINT_32:
279 case blender::gpu::TextureFormat::SINT_16_16:
280 case blender::gpu::TextureFormat::SINT_32_32:
282 case blender::gpu::TextureFormat::SINT_8:
390 const bool from_pool,
391 const std::optional<ResultStorageType> storage_type)
397 is_single_value_ =
false;
398 this->allocate_data(
domain.size, from_pool, storage_type);
407 is_single_value_ =
true;
416 this->allocate_data(
int2(1),
true);
536 (*data_reference_count_)++;
551 source =
Result(*context_, type_, precision_);
562 data_reference_count_ =
new int(1);
592 is_single_value_ =
false;
622 domain_.transformation = transformation;
627 domain_.transform(transformation);
632 return domain_.realization_options;
637 return domain_.realization_options;
642 reference_count_ =
count;
647 reference_count_ +=
count;
652 reference_count_ -=
count;
660 if (reference_count_ != 0) {
680 if (*data_reference_count_ != 1) {
681 (*data_reference_count_)--;
683 switch (storage_type_) {
692 data_reference_count_ =
nullptr;
693 derived_resources_ =
nullptr;
698 switch (storage_type_) {
714 delete data_reference_count_;
715 data_reference_count_ =
nullptr;
717 delete derived_resources_;
718 derived_resources_ =
nullptr;
723 return reference_count_ != 0;
728 if (!derived_resources_) {
731 return *derived_resources_;
760 return is_single_value_;
765 switch (storage_type_) {
777 return reference_count_;
787 return pixel_size * image_size.x * image_size.y;
792 return std::visit([](
const auto &value) {
return GPointer(&value); }, single_value_);
797 return std::visit([](
auto &value) {
return GMutablePointer(&value); }, single_value_);
805 switch (storage_type_) {
839void Result::allocate_data(
const int2 size,
840 const bool from_pool,
841 const std::optional<ResultStorageType> storage_type)
849 is_from_pool_ = from_pool;
867 const int64_t memory_size = array_size * item_size;
875 data_reference_count_ =
new int(1);
#define BLI_assert_unreachable()
int GPU_shader_get_sampler_binding(blender::gpu::Shader *shader, const char *name)
@ GPU_BARRIER_TEXTURE_FETCH
@ GPU_BARRIER_SHADER_IMAGE_ACCESS
@ GPU_BARRIER_TEXTURE_UPDATE
void GPU_memory_barrier(GPUBarrier barrier)
int GPU_texture_height(const blender::gpu::Texture *texture)
blender::gpu::TextureFormat GPU_texture_format(const blender::gpu::Texture *texture)
void GPU_texture_unbind(blender::gpu::Texture *texture)
int GPU_texture_width(const blender::gpu::Texture *texture)
@ GPU_TEXTURE_USAGE_GENERAL
void * GPU_texture_read(blender::gpu::Texture *texture, eGPUDataFormat data_format, int mip_level)
void GPU_texture_image_bind(blender::gpu::Texture *texture, int unit)
void GPU_texture_image_unbind(blender::gpu::Texture *texture)
blender::gpu::Texture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, blender::gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_texture_bind(blender::gpu::Texture *texture, int unit)
void GPU_texture_free(blender::gpu::Texture *texture)
void GPU_texture_update(blender::gpu::Texture *texture, eGPUDataFormat data_format, const void *data)
Read Guarded memory(de)allocation.
BMesh const char void * data
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
static const CPPType & get()
void copy_assign(const void *src, void *dst) const
const void * data() const
virtual bool use_gpu() const =0
void decrement_reference_count(int count=1)
void share_data(const Result &source)
RealizationOptions & get_realization_options()
Result upload_to_gpu(const bool from_pool) const
const CPPType & get_cpp_type() const
int reference_count() const
void allocate_texture(const Domain domain, const bool from_pool=true, const std::optional< ResultStorageType > storage_type=std::nullopt)
static eGPUDataFormat gpu_data_format(const ResultType type)
int64_t size_in_bytes() const
void wrap_external(blender::gpu::Texture *texture)
void unbind_as_texture() const
Result download_to_cpu() const
static blender::gpu::TextureFormat gpu_texture_format(ResultType type, ResultPrecision precision)
static const char * type_name(const ResultType type)
bool is_allocated() const
void set_transformation(const float3x3 &transformation)
static bool is_single_value_only_type(ResultType type)
GPointer single_value() const
blender::gpu::Texture * gpu_texture_
blender::gpu::TextureFormat get_gpu_texture_format() const
eGPUDataFormat get_gpu_data_format() const
void set_single_value(const T &value)
static ResultType type(blender::gpu::TextureFormat format)
void bind_as_texture(gpu::Shader *shader, const char *texture_name) const
ResultPrecision precision() const
void update_single_value_data()
blender::gpu::Texture * gpu_texture() const
static ResultType float_type(const int channels_count)
void set_precision(ResultPrecision precision)
void transform(const float3x3 &transformation)
void increment_reference_count(int count=1)
const Domain & domain() const
static const CPPType & cpp_type(const ResultType type)
int64_t channels_count() const
void unbind_as_image() const
void allocate_single_value()
static ResultPrecision precision(blender::gpu::TextureFormat format)
DerivedResources & derived_resources()
void bind_as_image(gpu::Shader *shader, const char *image_name, bool read=false) const
void set_reference_count(int count)
bool is_single_value() const
void steal_data(Result &source)
const T & get_single_value() const
void set_type(ResultType type)
blender::gpu::Texture * acquire_texture(int width, int height, blender::gpu::TextureFormat format, eGPUTextureUsage usage)
static TexturePool & get()
void release_texture(blender::gpu::Texture *tmp_tex)
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
void * MEM_mallocN_aligned(size_t len, size_t alignment, const char *str)
void MEM_freeN(void *vmemh)
static bool is_compatible_texture(const blender::gpu::Texture *texture, const Result &result)
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
MatBase< float, 3, 3 > float3x3
VecBase< float, 3 > float3