From bf3f4da9472516be12dcc69740fa69b6d72f1274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Sat, 12 Sep 2020 17:29:37 +0200 Subject: GPU: Fix wrong state before python callbacks This was caused by a missing state apply. We force the GPUState to be set after the callbacks to avoid desync between our state tracker and the real gl state. This fixes some issues but a better general fix for all BGL would be better. This fix T80297 2.91 texture alpha is not transparent --- source/blender/editors/space_api/CMakeLists.txt | 1 + source/blender/editors/space_api/spacetypes.c | 8 ++++++++ 2 files changed, 9 insertions(+) (limited to 'source/blender/editors/space_api') diff --git a/source/blender/editors/space_api/CMakeLists.txt b/source/blender/editors/space_api/CMakeLists.txt index d948d84f1c3..573afb76f0e 100644 --- a/source/blender/editors/space_api/CMakeLists.txt +++ b/source/blender/editors/space_api/CMakeLists.txt @@ -20,6 +20,7 @@ set(INC ../io ../../blenkernel ../../blenlib + ../../gpu ../../makesdna ../../makesrna ../../windowmanager diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 29ad314cd65..2a18ffafc6c 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -33,6 +33,8 @@ #include "BKE_context.h" #include "BKE_screen.h" +#include "GPU_state.h" + #include "UI_interface.h" #include "UI_view2d.h" @@ -269,12 +271,18 @@ void ED_region_draw_cb_exit(ARegionType *art, void *handle) void ED_region_draw_cb_draw(const bContext *C, ARegion *region, int type) { RegionDrawCB *rdc; + bool has_drawn_something = false; for (rdc = region->type->drawcalls.first; rdc; rdc = rdc->next) { if (rdc->type == type) { rdc->draw(C, region, rdc->customdata); + has_drawn_something = true; } } + if (has_drawn_something) { + /* This is needed until we get rid of BGL which can change the states we are tracking. */ + GPU_force_state(); + } } /* ********************* space template *********************** */ -- cgit v1.2.3