diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-02-25 17:05:53 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-02-25 17:14:32 +0300 |
commit | 4e9fffc2892601b3b11366f115f342ebeeb026f1 (patch) | |
tree | 88c969530d82f12952fbee0d96abd576e84031a6 /source/blender/gpu | |
parent | 1bbc1eed6221fcdfad9c160d2979040d44aa888e (diff) |
GPU: Add Image property to allow high bitdepth support on a per image basis
This adds the `Half Float Precision` option in the image property panel.
This option is only available on float textures and is enabled by default.
Adding a flag inside the imbuf (IB_halffloat) on load is done for EXR and PSD formats that can store half floating point (16bits/channels).
The option is then not displayed in this case and forced.
Related task T73086
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D6891
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/GPU_draw.h | 1 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 17 |
2 files changed, 14 insertions, 4 deletions
diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index f89a76cf49c..cc681c02009 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -71,6 +71,7 @@ void GPU_create_gl_tex(unsigned int *bind, int recth, int textarget, bool mipmap, + bool half_float, bool use_srgb, struct Image *ima); void GPU_create_gl_tex_compressed(unsigned int *bind, diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 6afff4f68f1..62a5de7ebe6 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -328,7 +328,9 @@ static uint gpu_texture_create_tile_array(Image *ima, ImBuf *main_ibuf) GLenum data_type, internal_format; if (main_ibuf->rect_float) { data_type = GL_FLOAT; - internal_format = GL_RGBA16F; + internal_format = (!(main_ibuf->flags & IB_halffloat) && (ima->flag & IMA_HIGH_BITDEPTH)) ? + GL_RGBA32F : + GL_RGBA16F; } else { data_type = GL_UNSIGNED_BYTE; @@ -472,6 +474,7 @@ static uint gpu_texture_create_from_ibuf(Image *ima, ImBuf *ibuf, int textarget) { uint bindcode = 0; const bool mipmap = GPU_get_mipmap(); + const bool half_float = (ibuf->flags & IB_halffloat) != 0; #ifdef WITH_DDS if (ibuf->ftype == IMB_FTYPE_DDS) { @@ -536,6 +539,7 @@ static uint gpu_texture_create_from_ibuf(Image *ima, ImBuf *ibuf, int textarget) ibuf->y, textarget, mipmap, + half_float, compress_as_srgb, ima); @@ -1043,6 +1047,7 @@ void GPU_create_gl_tex(uint *bind, int recth, int textarget, bool mipmap, + bool half_float, bool use_srgb, Image *ima) { @@ -1072,7 +1077,8 @@ void GPU_create_gl_tex(uint *bind, glGenTextures(1, (GLuint *)bind); glBindTexture(textarget, *bind); - GLenum internal_format = (frect) ? GL_RGBA16F : (use_srgb) ? GL_SRGB8_ALPHA8 : GL_RGBA8; + GLenum float_format = (!half_float && ima->flag & IMA_HIGH_BITDEPTH) ? GL_RGBA32F : GL_RGBA16F; + GLenum internal_format = (frect) ? float_format : (use_srgb) ? GL_SRGB8_ALPHA8 : GL_RGBA8; if (textarget == GL_TEXTURE_2D) { if (frect) { @@ -1236,18 +1242,21 @@ void GPU_create_gl_tex_compressed(unsigned int *bind, int textarget, Image *ima, const bool use_srgb = !(IMB_colormanagement_space_is_data(ibuf->rect_colorspace) || IMB_colormanagement_space_is_scene_linear(ibuf->rect_colorspace)); const bool mipmap = GPU_get_mipmap(); + const bool half_float = (ibuf->flags & IB_halffloat) != 0; #ifndef WITH_DDS (void)ibuf; /* Fall back to uncompressed if DDS isn't enabled */ - GPU_create_gl_tex(bind, ibuf->rect, NULL, ibuf->x, ibuf->y, textarget, mipmap, use_srgb, ima); + GPU_create_gl_tex( + bind, ibuf->rect, NULL, ibuf->x, ibuf->y, textarget, mipmap, half_float, use_srgb, ima); #else glGenTextures(1, (GLuint *)bind); glBindTexture(textarget, *bind); if (textarget == GL_TEXTURE_2D && GPU_upload_dxt_texture(ibuf, use_srgb) == 0) { glDeleteTextures(1, (GLuint *)bind); - GPU_create_gl_tex(bind, ibuf->rect, NULL, ibuf->x, ibuf->y, textarget, mipmap, use_srgb, ima); + GPU_create_gl_tex( + bind, ibuf->rect, NULL, ibuf->x, ibuf->y, textarget, mipmap, half_float, use_srgb, ima); } glBindTexture(textarget, 0); |