diff --git a/source/blender/blenfont/BLF_api.hh b/source/blender/blenfont/BLF_api.hh index 9aac88e9a49..33fe75bbc37 100644 --- a/source/blender/blenfont/BLF_api.hh +++ b/source/blender/blenfont/BLF_api.hh @@ -175,6 +175,10 @@ void BLF_batch_draw_begin(); void BLF_batch_draw_flush(); void BLF_batch_draw_end(); +/* Discard any batching in process and restart. + * Only used as a workaround for glitchy driver sync. */ +void BLF_batch_discard(); + /** * Draw the string using the current font. */ diff --git a/source/blender/blenfont/intern/blf_font.cc b/source/blender/blenfont/intern/blf_font.cc index 22348399c76..fd61af0d32c 100644 --- a/source/blender/blenfont/intern/blf_font.cc +++ b/source/blender/blenfont/intern/blf_font.cc @@ -343,6 +343,15 @@ static void blf_batch_draw_end() } } +void BLF_batch_discard() +{ + if (g_batch.glyph_buf) { + GPU_storagebuf_free(g_batch.glyph_buf); + } + g_batch.glyph_buf = GPU_storagebuf_create_ex( + sizeof(g_batch.glyph_data), nullptr, GPU_USAGE_STREAM, __func__); +} + /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/screen/area.cc b/source/blender/editors/screen/area.cc index 96d2434704c..3bad1bbc5de 100644 --- a/source/blender/editors/screen/area.cc +++ b/source/blender/editors/screen/area.cc @@ -46,6 +46,7 @@ #include "GPU_immediate.hh" #include "GPU_immediate_util.hh" #include "GPU_matrix.hh" +#include "GPU_platform.hh" #include "GPU_state.hh" #include "BLF_api.hh" @@ -3902,6 +3903,13 @@ void ED_region_header_draw(const bContext *C, ARegion *region) { /* clear */ ED_region_clear(C, region, region_background_color_id(C, region)); + + if (GPU_type_matches_ex(GPU_DEVICE_ANY, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE, GPU_BACKEND_OPENGL)) + { + /* WORKAROUND: Driver bug. Fixes invalid glyph being rendered (see #147168). */ + BLF_batch_discard(); + } + region_draw_blocks_in_view2d(C, region); ED_region_draw_overflow_indication(CTX_wm_area(C), region); }