diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2019-07-04 09:27:17 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2019-08-06 09:34:39 +0300 |
commit | 85c3e1204991d5ce1e89eb6201727d82eb32be50 (patch) | |
tree | 91b4c91b36a920c5f3fc412737317d167aa8dd9e | |
parent | 0394f2ab30ba012fdc8f22ee817ef13a359ef6cf (diff) |
Fix T66100: WorkBench Banding Issues
Color banding issues can appear, as result of the 8 bitdepth RGBA that
is used in the viewport.
This change will use `GPU_RGBA16F` for final renderings and for drawing textures. This
allows displaying HDRI textures. Vertex Colors uses `GPU_RGBA16` to resolve
color banding issues. All other modes use `GPU_RGBA8` to reduce
bandwidth and gpu memory.
Reviewed By: fclem, brecht
Differential Revision: https://developer.blender.org/D5179
4 files changed, 28 insertions, 3 deletions
diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index 735a0dcf7a0..add49462de1 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -475,7 +475,7 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata) const eGPUTextureFormat nor_tex_format = NORMAL_ENCODING_ENABLED() ? GPU_RG16 : GPU_RGBA32F; const eGPUTextureFormat comp_tex_format = DRW_state_is_image_render() ? GPU_RGBA16F : GPU_R11F_G11F_B10F; - const eGPUTextureFormat col_tex_format = DRW_state_is_image_render() ? GPU_RGBA16F : GPU_RGBA8; + const eGPUTextureFormat col_tex_format = workbench_color_texture_format(wpd); const eGPUTextureFormat id_tex_format = OBJECT_ID_PASS_ENABLED(wpd) ? GPU_R32UI : GPU_R8; e_data.object_id_tx = NULL; diff --git a/source/blender/draw/engines/workbench/workbench_effect_taa.c b/source/blender/draw/engines/workbench/workbench_effect_taa.c index 88f1f30941a..06442060623 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_taa.c +++ b/source/blender/draw/engines/workbench/workbench_effect_taa.c @@ -170,10 +170,10 @@ DRWPass *workbench_taa_create_pass(WORKBENCH_Data *vedata, GPUTexture **color_bu WORKBENCH_TextureList *txl = vedata->txl; WORKBENCH_EffectInfo *effect_info = stl->effects; WORKBENCH_FramebufferList *fbl = vedata->fbl; + const WORKBENCH_PrivateData *wpd = stl->g_data; { - const eGPUTextureFormat hist_buffer_format = DRW_state_is_image_render() ? GPU_RGBA16F : - GPU_RGBA8; + const eGPUTextureFormat hist_buffer_format = workbench_color_texture_format(wpd); DRW_texture_ensure_fullscreen_2d(&txl->history_buffer_tx, hist_buffer_format, 0); DRW_texture_ensure_fullscreen_2d(&txl->depth_buffer_tx, GPU_DEPTH24_STENCIL8, 0); } diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index 17144c4dc10..cb9a97878e2 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -381,6 +381,30 @@ BLI_INLINE bool workbench_is_matdata_pass_enabled(WORKBENCH_PrivateData *wpd) workbench_is_in_texture_paint_mode(); } +/** + * Get the default texture format to be used by the color and history buffers. + * + * Use GPU_RGBA16F for final renderings and for drawing textures. This + * allows displaying HDRI textures. Vertex Colors uses GPU_RGBA16 to resolve + * color banding issues (T66100). All other modes use GPU_RGBA8 to reduce + * bandwidth and gpu memory. + */ +BLI_INLINE const eGPUTextureFormat workbench_color_texture_format(const WORKBENCH_PrivateData *wpd) +{ + eGPUTextureFormat result; + if (DRW_state_is_image_render() || workbench_is_in_texture_paint_mode() || + TEXTURE_DRAWING_ENABLED(wpd)) { + result = GPU_RGBA16F; + } + else if (VERTEX_COLORS_ENABLED(wpd)) { + result = GPU_RGBA16; + } + else { + result = GPU_RGBA8; + } + return result; +} + /* workbench_deferred.c */ void workbench_deferred_engine_init(WORKBENCH_Data *vedata); void workbench_deferred_engine_free(void); diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index ad3cbaeea46..f8ee29c94cc 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -960,6 +960,7 @@ typedef enum eUserpref_UI_Flag2 { USER_UIFLAG2_UNUSED_3 = (1 << 3), /* dirty */ } eUserpref_UI_Flag2; +/** #UserDef.gpu_flag */ typedef enum eUserpref_GPU_Flag { USER_GPU_FLAG_NO_DEPT_PICK = (1 << 0), USER_GPU_FLAG_NO_EDIT_MODE_SMOOTH_WIRE = (1 << 1), |