94 "Buffer size need to be aligned to size of float4.");
163 template<
typename T,
int64_t len,
bool device_only>
169 const char *
name_ =
typeid(
T).name();
171 const char *
name_ =
"UniformBuffer";
203 template<
typename T,
int64_t len,
bool device_only>
209 const char *
name_ =
typeid(
T).name();
211 const char *
name_ =
"StorageBuffer";
287 this->data_ =
static_cast<T *
>(
this);
292 *
static_cast<T *
>(
this) = other;
309 bool device_only =
false>
325 if (new_size != this->len_) {
328 memcpy(new_data_, this->data_,
min_uu(this->len_, new_size) *
sizeof(
T));
330 this->data_ = new_data_;
333 this->len_ = new_size;
343 if (index >= this->len_) {
347 return this->data_[index];
355 bool device_only =
false>
361 this->data_ =
static_cast<T *
>(
this);
366 *
static_cast<T *
>(
this) = other;
393 float *
data =
nullptr,
394 bool cubemap =
false,
398 tx_ = create(extent, 0, 0, mip_len,
format,
data,
false, cubemap);
405 float *
data =
nullptr,
406 bool cubemap =
false,
410 tx_ = create(extent, layers, 0, mip_len,
format,
data,
true, cubemap);
416 float *
data =
nullptr,
427 float *
data =
nullptr,
437 float *
data =
nullptr,
466 this->name_ =
a.name_;
478 return ensure_impl(extent, 0, 0, mip_len,
format,
data,
false,
false);
488 return ensure_impl(extent, layers, 0, mip_len,
format,
data,
true,
false);
525 return ensure_impl(extent, extent, 0, mip_len,
format,
data,
false,
true);
535 return ensure_impl(extent, extent, layers, mip_len,
format,
data,
false,
true);
606 return tx_ !=
nullptr;
711 SWAP(
const char *,
a.name_,
b.name_);
715 bool ensure_impl(
int w,
720 float *
data =
nullptr,
721 bool layered =
false,
722 bool cubemap =
false)
734 if (
tx_ ==
nullptr) {
791 if (this->tx_ !=
nullptr) {
794 if (tx_tmp_saved_ !=
nullptr) {
798 this->tx_tmp_saved_ =
nullptr;
801 this->tx_ = tx_tmp_saved_;
812 if (this->tx_ !=
nullptr) {
813 tx_tmp_saved_ = this->
tx_;
824 tx_tmp_saved_ =
nullptr;
859 GPU_FRAMEBUFFER_FREE_SAFE(fb_);
872 GPU_framebuffer_ensure_config(
873 &fb_, {depth, color1, color2, color3, color4, color5, color6, color7, color8});
880 this->name_ =
a.name_;
897 SWAP(
const char *,
a.name_,
b.name_);
911 std::array<T, len> chain_;
917 index_ = (index_ + 1) %
len;
922 return chain_[index_];
928 return chain_[(index_ +
len - 1) %
len];
933 return chain_[(index_ + 1) %
len];
938 return chain_[index_];
944 return chain_[(index_ +
len - 1) %
len];
949 return chain_[(index_ + 1) %
len];
MINLINE uint min_uu(uint a, uint b)
MINLINE unsigned int power_of_2_max_u(unsigned int x)
struct GPUFrameBuffer GPUFrameBuffer
void GPU_storagebuf_free(GPUStorageBuf *ssbo)
void GPU_storagebuf_update(GPUStorageBuf *ssbo, const void *data)
GPUStorageBuf * GPU_storagebuf_create_ex(size_t size, const void *data, GPUUsageType usage, const char *name)
struct GPUStorageBuf GPUStorageBuf
GPUTexture * GPU_texture_create_2d_array(const char *name, int w, int h, int d, int mip_len, eGPUTextureFormat format, const float *data)
bool GPU_texture_cube(const GPUTexture *tex)
GPUTexture * GPU_texture_create_1d_array(const char *name, int w, int h, int mip_len, eGPUTextureFormat format, const float *data)
int GPU_texture_height(const GPUTexture *tex)
GPUTexture * GPU_texture_create_1d(const char *name, int w, int mip_len, eGPUTextureFormat format, const float *data)
void GPU_texture_clear(GPUTexture *tex, eGPUDataFormat data_format, const void *data)
struct GPUTexture GPUTexture
int GPU_texture_width(const GPUTexture *tex)
void * GPU_texture_read(GPUTexture *tex, eGPUDataFormat data_format, int miplvl)
int GPU_texture_mip_count(const GPUTexture *tex)
bool GPU_texture_integer(const GPUTexture *tex)
bool GPU_texture_array(const GPUTexture *tex)
void GPU_texture_get_mipmap_size(GPUTexture *tex, int lvl, int *size)
GPUTexture * GPU_texture_create_view(const char *name, const GPUTexture *src, eGPUTextureFormat format, int mip_start, int mip_len, int layer_start, int layer_len, bool cube_as_array)
void GPU_texture_filter_mode(GPUTexture *tex, bool use_filter)
int GPU_texture_layer_count(const GPUTexture *tex)
void GPU_texture_stencil_texture_mode_set(GPUTexture *tex, bool use_stencil)
GPUTexture * GPU_texture_create_2d(const char *name, int w, int h, int mip_len, eGPUTextureFormat format, const float *data)
#define GPU_TEXTURE_FREE_SAFE(texture)
bool GPU_texture_stencil(const GPUTexture *tex)
GPUTexture * GPU_texture_create_3d(const char *name, int w, int h, int d, int mip_len, eGPUTextureFormat texture_format, eGPUDataFormat data_format, const void *data)
eGPUTextureFormat GPU_texture_format(const GPUTexture *tex)
bool GPU_texture_depth(const GPUTexture *tex)
GPUTexture * GPU_texture_create_cube(const char *name, int w, int mip_len, eGPUTextureFormat format, const float *data)
GPUTexture * GPU_texture_create_cube_array(const char *name, int w, int d, int mip_len, eGPUTextureFormat format, const float *data)
Read Guarded memory(de)allocation.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
void append(const T &value)
static void swap(Framebuffer &a, Framebuffer &b)
Framebuffer(const char *name)
Framebuffer & operator=(Framebuffer &&a)
void ensure(GPUAttachment depth=GPU_ATTACHMENT_NONE, GPUAttachment color1=GPU_ATTACHMENT_NONE, GPUAttachment color2=GPU_ATTACHMENT_NONE, GPUAttachment color3=GPU_ATTACHMENT_NONE, GPUAttachment color4=GPU_ATTACHMENT_NONE, GPUAttachment color5=GPU_ATTACHMENT_NONE, GPUAttachment color6=GPU_ATTACHMENT_NONE, GPUAttachment color7=GPU_ATTACHMENT_NONE, GPUAttachment color8=GPU_ATTACHMENT_NONE)
StorageArrayBuffer(const char *name=nullptr)
void resize(int64_t new_size)
T & get_or_resize(int64_t index)
StorageBuffer< T > & operator=(const T &other)
StorageBuffer(const char *name=nullptr)
const T & previous() const
const T & current() const
GPUTexture * layer_view(int)=delete
GPUTexture * mip_view(int)=delete
bool ensure_1d_array(int, int, int, eGPUTextureFormat, float *)=delete
bool ensure_cube(int, int, eGPUTextureFormat, float *)=delete
void acquire(int2 extent, eGPUTextureFormat format, void *owner_)
TextureFromPool(const char *name="gpu::Texture")
void filter_mode(bool)=delete
bool ensure_2d(int, int, int, eGPUTextureFormat, float *)=delete
bool ensure_2d_array(int, int, int, int, eGPUTextureFormat, float *)=delete
bool ensure_3d(int, int, int, int, eGPUTextureFormat, float *)=delete
bool ensure_1d(int, int, eGPUTextureFormat, float *)=delete
bool ensure_cube_array(int, int, int, eGPUTextureFormat, float *)=delete
GPUTexture * stencil_view()=delete
bool is_valid(void) const
bool ensure_cube_array(eGPUTextureFormat format, int extent, int layers, float *data=nullptr, int mip_len=1)
bool ensure_mip_views(bool cube_as_array=false)
bool ensure_1d(eGPUTextureFormat format, int extent, float *data=nullptr, int mip_len=1)
Texture(const char *name, eGPUTextureFormat format, int extent, float *data=nullptr, bool cubemap=false, int mip_len=1)
Vector< GPUTexture *, 0 > mip_views_
Texture(const char *name, eGPUTextureFormat format, int3 extent, float *data=nullptr, int mip_len=1)
bool is_integer(void) const
static void swap(Texture &a, Texture &b)
GPUTexture * layer_view(int layer)
bool ensure_2d_array(eGPUTextureFormat format, int2 extent, int layers, float *data=nullptr, int mip_len=1)
Texture(const char *name, eGPUTextureFormat format, int extent, int layers, float *data=nullptr, bool cubemap=false, int mip_len=1)
Texture(const char *name="gpu::Texture")
Texture(const char *name, eGPUTextureFormat format, int2 extent, int layers, float *data=nullptr, int mip_len=1)
GPUTexture * stencil_view_
void clear(float4 values)
Vector< GPUTexture *, 0 > layer_views_
GPUTexture * stencil_view(bool cube_as_array=false)
GPUTexture * mip_view(int miplvl)
void filter_mode(bool do_filter)
bool is_stencil(void) const
Texture & operator=(Texture &&a)
T * read(eGPUDataFormat format, int miplvl=0)
bool ensure_layer_views(bool cube_as_array=false)
bool is_array(void) const
bool ensure_3d(eGPUTextureFormat format, int3 extent, float *data=nullptr, int mip_len=1)
Texture(const char *name, eGPUTextureFormat format, int2 extent, float *data=nullptr, int mip_len=1)
int3 size(int miplvl=0) const
bool ensure_1d_array(eGPUTextureFormat format, int extent, int layers, float *data=nullptr, int mip_len=1)
GPUTexture ** operator&()
bool ensure_cube(eGPUTextureFormat format, int extent, float *data=nullptr, int mip_len=1)
bool ensure_2d(eGPUTextureFormat format, int2 extent, float *data=nullptr, int mip_len=1)
const T & operator[](int64_t index) const
BLI_STATIC_ASSERT(((sizeof(T) *len) % 16)==0, "Buffer size need to be aligned to size of float4.")
T & operator[](int64_t index)
GPUStorageBuf ** operator&()
StorageCommon(const char *name=nullptr)
GPUTexture * DRW_texture_pool_query_2d(int w, int h, eGPUTextureFormat format, DrawEngineType *engine_type)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_mallocN_aligned)(size_t len, size_t alignment, const char *str)
vec_base< int32_t, 3 > int3
static const pxr::TfToken b("b", pxr::TfToken::Immortal)