88 const bool do_rescale,
89 const int rescale_size[2],
90 const bool store_premultiplied,
94 void *data_rect = (is_float_rect) ? (
void *)ibuf->
rect_float : (
void *)ibuf->
rect;
95 bool freedata =
false;
101 if (ibuf->
channels != 4 || !store_premultiplied) {
102 data_rect =
MEM_mallocN(
sizeof(
float[4]) * ibuf->
x * ibuf->
y, __func__);
103 *r_freedata = freedata =
true;
105 if (data_rect ==
NULL) {
110 (
float *)data_rect, 0, 0, ibuf->
x, ibuf->
y, ibuf, store_premultiplied);
125 *r_freedata = freedata =
true;
127 if (data_rect ==
NULL) {
137 (
uchar *)data_rect, 0, 0, ibuf->
x, ibuf->
y, ibuf, store_premultiplied);
141 data_rect =
MEM_mallocN(
sizeof(
float[4]) * ibuf->
x * ibuf->
y, __func__);
142 *r_freedata = freedata =
true;
144 if (data_rect ==
NULL) {
154 (
float *)data_rect, 0, 0, ibuf->
x, ibuf->
y, ibuf, store_premultiplied);
159 uint *rect = (is_float_rect) ?
NULL : (
uint *)data_rect;
160 float *rect_float = (is_float_rect) ? (
float *)data_rect :
NULL;
169 data_rect = (is_float_rect) ? (
void *)scale_ibuf->
rect_float : (
void *)scale_ibuf->
rect;
180 const char *name,
ImBuf *ibuf,
int w,
int h,
int layers,
bool use_high_bitdepth)
205 bool use_high_bitdepth,
208 const bool do_rescale = (ibuf->
x !=
w || ibuf->
y != h);
209 const int size[2] = {
w, h};
215 bool freebuf =
false;
229 bool use_high_bitdepth,
234 bool do_rescale = (ibuf->
x !=
size[0]) || (ibuf->
y !=
size[1]);
237 if (ibuf->
ftype == IMB_FTYPE_DDS) {
239 if (!IMB_gpu_get_compressed_format(ibuf, &compressed_format)) {
240 fprintf(stderr,
"Unable to find a suitable DXT compression,");
242 else if (do_rescale) {
243 fprintf(stderr,
"Unable to load DXT image resolution,");
246 fprintf(stderr,
"Unable to load non-power-of-two DXT image resolution,");
260 fprintf(stderr,
"ST3C support not found,");
263 fprintf(stderr,
" falling back to uncompressed.\n");
271 bool freebuf =
false;
296 const float half_min = -65504;
297 const float half_max = 65504;
302 int rect_float_len = image_buffer->
x * image_buffer->
y *
305 for (
int i = 0; i < rect_float_len; i++) {
MINLINE float clamp_f(float value, float min, float max)
MINLINE int max_ii(int a, int b)
MINLINE int is_power_of_2_i(int n)
static const uint FOURCC_DXT3
static const uint FOURCC_DXT5
static const uint FOURCC_DXT1
int GPU_texture_size_with_limit(int res)
_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 GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_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 y
GPUTexture * GPU_texture_create_2d_array(const char *name, int w, int h, int d, int mip_len, eGPUTextureFormat format, const float *data)
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)
struct GPUTexture GPUTexture
void GPU_texture_update(GPUTexture *tex, eGPUDataFormat data_format, const void *data)
GPUTexture * GPU_texture_create_2d(const char *name, int w, int h, int mip_len, eGPUTextureFormat format, const float *data)
GPUTexture * GPU_texture_create_compressed_2d(const char *name, int w, int h, int miplen, eGPUTextureFormat format, const void *data)
void GPU_texture_anisotropic_filter(GPUTexture *tex, bool use_aniso)
bool IMB_colormanagement_space_is_srgb(struct ColorSpace *colorspace)
bool IMB_colormanagement_space_is_scene_linear(struct ColorSpace *colorspace)
void IMB_colormanagement_imbuf_to_float_texture(float *out_buffer, int offset_x, int offset_y, int width, int height, const struct ImBuf *ibuf, bool store_premultiplied)
void IMB_colormanagement_imbuf_to_byte_texture(unsigned char *out_buffer, int x, int y, int width, int height, const struct ImBuf *ibuf, bool store_premultiplied)
bool IMB_colormanagement_space_is_data(struct ColorSpace *colorspace)
bool IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
struct ImBuf * IMB_allocFromBuffer(const unsigned int *rect, const float *rectf, unsigned int w, unsigned int h, unsigned int channels)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img GPU_RGBA16F
void IMB_freeImBuf(ImBuf *UNUSED(ibuf))
void(* MEM_freeN)(void *vmemh)
void *(* MEM_mallocN)(size_t len, const char *str)
struct ColorSpace * rect_colorspace
GPUTexture * IMB_create_gpu_texture(const char *name, ImBuf *ibuf, bool use_high_bitdepth, bool use_premult)
void IMB_update_gpu_texture_sub(GPUTexture *tex, ImBuf *ibuf, int x, int y, int z, int w, int h, bool use_high_bitdepth, bool use_premult)
static void * imb_gpu_get_data(const ImBuf *ibuf, const bool do_rescale, const int rescale_size[2], const bool store_premultiplied, bool *r_freedata)
GPUTexture * IMB_touch_gpu_texture(const char *name, ImBuf *ibuf, int w, int h, int layers, bool use_high_bitdepth)
static void imb_gpu_get_format(const ImBuf *ibuf, bool high_bitdepth, eGPUDataFormat *r_data_format, eGPUTextureFormat *r_texture_format)
void IMB_gpu_clamp_half_float(ImBuf *image_buffer)