From dfd192ce41f7e4923db0642f22a587862656bbdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 10 Jul 2018 13:17:32 +0200 Subject: GPUTexture: Refactor of texture creation & new feature - Texture creation now requires explicit data type. - GPU_texture_add_mipmap enable explicit mipmap upload. - GPU_texture_get_mipmap_size can be used to get the size of a mipmap level of an existing GPUTexture - GPU_texture_read let you read back data from a gpu texture. --- source/blender/gpu/GPU_texture.h | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'source/blender/gpu/GPU_texture.h') diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h index 341abeba72f..3ed9014d431 100644 --- a/source/blender/gpu/GPU_texture.h +++ b/source/blender/gpu/GPU_texture.h @@ -144,8 +144,23 @@ typedef enum GPUTextureFormat { GPU_DEPTH_COMPONENT16, } GPUTextureFormat; +typedef enum GPUDataFormat { + GPU_DATA_FLOAT, + GPU_DATA_INT, + GPU_DATA_UNSIGNED_INT, + GPU_DATA_UNSIGNED_BYTE, + GPU_DATA_UNSIGNED_INT_24_8, + GPU_DATA_10_11_11_REV, +} GPUDataFormat; + unsigned int GPU_texture_memory_usage_get(void); +/* TODO make it static function again. (create function with GPUDataFormat exposed) */ +GPUTexture *GPU_texture_create_nD( + int w, int h, int d, int n, const void *pixels, + GPUTextureFormat tex_format, GPUDataFormat gpu_data_format, int samples, + const bool can_rescale, char err_out[256]); + GPUTexture *GPU_texture_create_1D( int w, GPUTextureFormat data_type, const float *pixels, char err_out[256]); GPUTexture *GPU_texture_create_2D( @@ -168,11 +183,15 @@ GPUTexture *GPU_texture_from_blender( struct Image *ima, struct ImageUser *iuser, int textarget, bool is_data, double time); GPUTexture *GPU_texture_from_preview(struct PreviewImage *prv, int mipmap); -void GPU_texture_update(GPUTexture *tex, const void *pixels); +void GPU_texture_add_mipmap(GPUTexture *tex, GPUDataFormat gpu_data_format, int miplvl, const void *pixels); + +void GPU_texture_update(GPUTexture *tex, GPUDataFormat data_format, const void *pixels); void GPU_texture_update_sub( - GPUTexture *tex, const void *pixels, + GPUTexture *tex, GPUDataFormat gpu_data_format, const void *pixels, int offset_x, int offset_y, int offset_z, int width, int height, int depth); +void *GPU_texture_read(GPUTexture *tex, GPUDataFormat gpu_data_format, int miplvl); + void GPU_invalid_tex_init(void); void GPU_invalid_tex_bind(int mode); void GPU_invalid_tex_free(void); @@ -202,6 +221,7 @@ int GPU_texture_detach_framebuffer(GPUTexture *tex, struct GPUFrameBuffer *fb); int GPU_texture_target(const GPUTexture *tex); int GPU_texture_width(const GPUTexture *tex); int GPU_texture_height(const GPUTexture *tex); +int GPU_texture_layers(const GPUTexture *tex); GPUTextureFormat GPU_texture_format(const GPUTexture *tex); int GPU_texture_samples(const GPUTexture *tex); bool GPU_texture_cube(const GPUTexture *tex); @@ -210,6 +230,8 @@ bool GPU_texture_stencil(const GPUTexture *tex); bool GPU_texture_integer(const GPUTexture *tex); int GPU_texture_opengl_bindcode(const GPUTexture *tex); +void GPU_texture_get_mipmap_size(GPUTexture *tex, int lvl, int *size); + #ifdef __cplusplus } #endif -- cgit v1.2.3