59 if (
fb_[i] !=
nullptr) {
145 if (
fb_[i] ==
nullptr) {
151 BLI_assert(!
"GPU: Error: Texture: Not enough attachment");
163 BLI_assert(!
"GPU: Error: Texture: Framebuffer is not attached");
169 int extent[3], offset[3] = {0, 0, 0};
206 bool success =
false;
210 success =
tex->init_1D(
w, h, tex_format);
214 success =
tex->init_2D(
w, h, d, tex_format);
217 success =
tex->init_3D(
w, h, d, tex_format);
221 success =
tex->init_cubemap(
w, d, tex_format);
232 tex->update(data_format, pixels);
294 bool success =
tex->init_2D(
w, h, 0, tex_format);
302 for (
int mip = 0; mip < miplen; mip++) {
303 int extent[3], offset[3] = {0, 0, 0};
304 tex->mip_size_get(mip, extent);
306 size_t size = ((extent[0] + 3) / 4) * ((extent[1] + 3) / 4) *
to_block_size(tex_format);
320 bool success =
tex->init_buffer(vert, tex_format);
331 float pixel[4] = {1.0f, 0.0f, 1.0f, 1.0f};
333 int h = (dimension < 2 && !is_array) ? 0 : 1;
334 int d = (dimension < 3 && !is_array) ? 0 : 1;
351 int extent[3] = {1, 1, 1}, offset[3] = {0, 0, 0};
352 tex->mip_size_get(miplvl, extent);
353 reinterpret_cast<Texture *
>(
tex)->update_sub(miplvl, offset, extent, data_format, pixels);
366 int offset[3] = {offset_x, offset_y, offset_z};
368 reinterpret_cast<Texture *
>(
tex)->update_sub(0, offset, extent, data_format, pixels);
374 return tex->read(miplvl, data_format);
408 const bool UNUSED(set_number))
449 reinterpret_cast<Texture *
>(
tex)->generate_mipmap();
505 reinterpret_cast<Texture *
>(
tex)->swizzle_set(swizzle);
513 if (
tex->refcount < 0) {
514 fprintf(stderr,
"GPUTexture: negative refcount\n");
517 if (
tex->refcount == 0) {
529 return reinterpret_cast<const Texture *
>(
tex)->width_get();
534 return reinterpret_cast<const Texture *
>(
tex)->height_get();
539 return reinterpret_cast<const Texture *
>(
tex)->src_w;
544 return reinterpret_cast<const Texture *
>(
tex)->src_h;
556 return reinterpret_cast<const Texture *
>(
tex)->format_get();
587 return reinterpret_cast<const Texture *
>(
tex)->gl_bindcode_get();
592 return reinterpret_cast<Texture *
>(
tex)->mip_size_get(lvl, r_size);
MINLINE int max_ii(int a, int b)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
#define SET_FLAG_FROM_TEST(value, test, flag)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
@ GPU_SAMPLER_CLAMP_BORDER
struct GPUTexture GPUTexture
static const int GPU_SAMPLER_MAX
const GPUVertFormat * GPU_vertbuf_get_format(const GPUVertBuf *verts)
uint GPU_vertbuf_get_vertex_len(const GPUVertBuf *verts)
struct GPUVertBuf GPUVertBuf
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
StateManager * state_manager
static Context * get(void)
void attachment_remove(GPUAttachmentType type)
virtual Texture * texture_alloc(const char *name)=0
virtual void samplers_update(void)=0
static GPUBackend * get(void)
virtual void texture_unbind(Texture *tex)=0
virtual void image_unbind(Texture *tex)=0
virtual void texture_unbind_all(void)=0
virtual void image_unbind_all(void)=0
virtual void texture_bind(Texture *tex, eGPUSamplerState sampler, int unit)=0
virtual void image_bind(Texture *tex, int unit)=0
virtual void texture_unpack_row_length_set(uint len)=0
bool init_3D(int w, int h, int d, eGPUTextureFormat format)
bool init_1D(int w, int layers, eGPUTextureFormat format)
virtual bool init_internal(void)=0
void attach_to(FrameBuffer *fb, GPUAttachmentType type)
eGPUTextureFormat format_
bool init_cubemap(int w, int layers, eGPUTextureFormat format)
eGPUTextureFormatFlag format_flag_
void update(eGPUDataFormat format, const void *data)
char name_[DEBUG_NAME_LEN]
FrameBuffer * fb_[GPU_TEX_MAX_FBO_ATTACHED]
bool init_2D(int w, int h, int layers, eGPUTextureFormat format)
bool init_buffer(GPUVertBuf *vbo, eGPUTextureFormat format)
GPUAttachmentType fb_attachment_[GPU_TEX_MAX_FBO_ATTACHED]
eGPUSamplerState sampler_state
virtual void update_sub(int mip, int offset[3], int extent[3], eGPUDataFormat format, const void *data)=0
void mip_size_get(int mip, int r_size[3]) const
virtual void copy_to(Texture *tex)=0
Texture(const char *name)
void detach_from(FrameBuffer *fb)
void GPU_texture_unbind_all(void)
GPUTexture * GPU_texture_create_2d(const char *name, int w, int h, int mips, eGPUTextureFormat format, const float *data)
bool GPU_texture_cube(const GPUTexture *tex)
size_t GPU_texture_component_len(eGPUTextureFormat tex_format)
void GPU_texture_swizzle_set(GPUTexture *tex, const char swizzle[4])
void GPU_texture_compare_mode(GPUTexture *tex_, bool use_compare)
void GPU_texture_filter_mode(GPUTexture *tex_, bool use_filter)
void GPU_texture_image_bind(GPUTexture *tex, int unit)
void GPU_texture_bind_ex(GPUTexture *tex_, eGPUSamplerState state, int unit, const bool UNUSED(set_number))
void GPU_texture_update_sub(GPUTexture *tex, eGPUDataFormat data_format, const void *pixels, int offset_x, int offset_y, int offset_z, int width, int height, int depth)
size_t GPU_texture_dataformat_size(eGPUDataFormat data_format)
GPUTexture * GPU_texture_create_cube_array(const char *name, int w, int d, int mips, eGPUTextureFormat format, const float *data)
int GPU_texture_height(const GPUTexture *tex)
void GPU_texture_mipmap_mode(GPUTexture *tex_, bool use_mipmap, bool use_filter)
void GPU_texture_orig_size_set(GPUTexture *tex_, int w, int h)
void GPU_texture_clear(GPUTexture *tex, eGPUDataFormat data_format, const void *data)
GPUTexture * GPU_texture_create_error(int dimension, bool is_array)
void * GPU_texture_read(GPUTexture *tex_, eGPUDataFormat data_format, int miplvl)
void GPU_texture_get_mipmap_size(GPUTexture *tex, int lvl, int *r_size)
int GPU_texture_width(const GPUTexture *tex)
void GPU_texture_image_unbind_all(void)
void GPU_texture_unbind(GPUTexture *tex_)
GPUTexture * GPU_texture_create_from_vertbuf(const char *name, GPUVertBuf *vert)
void GPU_texture_image_unbind(GPUTexture *tex)
GPUTexture * GPU_texture_create_1d_array(const char *name, int w, int h, int mips, eGPUTextureFormat format, const float *data)
int GPU_texture_opengl_bindcode(const GPUTexture *tex)
bool GPU_texture_integer(const GPUTexture *tex)
bool GPU_texture_array(const GPUTexture *tex)
void GPU_texture_update(GPUTexture *tex, eGPUDataFormat data_format, const void *data)
void GPU_texture_ref(GPUTexture *tex)
static GPUTexture * gpu_texture_create(const char *name, const int w, const int h, const int d, const eGPUTextureType type, int UNUSED(mips), eGPUTextureFormat tex_format, eGPUDataFormat data_format, const void *pixels)
void GPU_texture_free(GPUTexture *tex_)
void GPU_texture_bind(GPUTexture *tex_, int unit)
GPUTexture * GPU_texture_create_cube(const char *name, int w, int mips, eGPUTextureFormat format, const float *data)
GPUTexture * GPU_texture_create_1d(const char *name, int w, int mips, eGPUTextureFormat format, const float *data)
bool GPU_texture_stencil(const GPUTexture *tex)
int GPU_texture_orig_width(const GPUTexture *tex)
GPUTexture * GPU_texture_create_compressed_2d(const char *name, int w, int h, int miplen, eGPUTextureFormat tex_format, const void *data)
void GPU_texture_anisotropic_filter(GPUTexture *tex_, bool use_aniso)
eGPUTextureFormat GPU_texture_format(const GPUTexture *tex)
bool GPU_texture_depth(const GPUTexture *tex)
void GPU_unpack_row_length_set(uint len)
void GPU_samplers_update(void)
int GPU_texture_orig_height(const GPUTexture *tex)
void GPU_texture_wrap_mode(GPUTexture *tex_, bool use_repeat, bool use_clamp)
void GPU_texture_update_mipmap(GPUTexture *tex_, int miplvl, eGPUDataFormat data_format, const void *pixels)
uint GPU_texture_memory_usage_get(void)
GPUTexture * GPU_texture_create_2d_array(const char *name, int w, int h, int d, int mips, eGPUTextureFormat format, const float *data)
void GPU_texture_copy(GPUTexture *dst_, GPUTexture *src_)
void GPU_texture_generate_mipmap(GPUTexture *tex)
GPUTexture * GPU_texture_create_3d(const char *name, int w, int h, int d, int mips, eGPUTextureFormat texture_format, eGPUDataFormat data_format, const void *data)
BLI_INLINE float fb(float length, float L)
static void clear(Message *msg)
size_t to_block_size(eGPUTextureFormat data_type)
static Context * unwrap(GPUContext *ctx)
@ GPU_FORMAT_DEPTH_STENCIL
eGPUDataFormat to_data_format(eGPUTextureFormat tex_format)
static eGPUTextureFormat to_texture_format(const GPUVertFormat *format)
eGPUTextureFormatFlag to_format_flag(eGPUTextureFormat format)
static size_t to_bytesize(GPUIndexBufType type)
int to_component_len(eGPUTextureFormat format)
static void update(bNodeTree *ntree)