From b6117386b9683ecebd810fdc1e574e79b91f3894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Sat, 27 Aug 2022 15:49:50 +0200 Subject: Fix backfacing lingering state --- source/blender/draw/intern/draw_command.hh | 23 +++++++++++++++++++---- source/blender/draw/intern/draw_manager.cc | 9 +++------ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/source/blender/draw/intern/draw_command.hh b/source/blender/draw/intern/draw_command.hh index 88a934c1a50..b368a463828 100644 --- a/source/blender/draw/intern/draw_command.hh +++ b/source/blender/draw/intern/draw_command.hh @@ -9,6 +9,7 @@ * Passes record draw commands. */ +#include "BKE_global.h" #include "BLI_map.hh" #include "DRW_gpu_wrapper.hh" @@ -39,13 +40,27 @@ struct RecordingState { /** Used for gl_BaseInstance workaround. */ GPUStorageBuf *resource_id_buf = nullptr; - void front_facing_set(bool front_facing) + void front_facing_set(bool facing) { /* Facing is inverted if view is not in expected handedness. */ - front_facing = this->inverted_view == front_facing; + facing = this->inverted_view == facing; /* Remove redundant changes. */ - if (assign_if_different(this->front_facing, front_facing)) { - GPU_front_facing(!front_facing); + if (assign_if_different(this->front_facing, facing)) { + GPU_front_facing(!facing); + } + } + + void cleanup() + { + if (front_facing == false) { + GPU_front_facing(false); + } + + if (G.debug & G_DEBUG_GPU) { + GPU_storagebuf_unbind_all(); + GPU_texture_image_unbind_all(); + GPU_texture_unbind_all(); + GPU_uniformbuf_unbind_all(); } } }; diff --git a/source/blender/draw/intern/draw_manager.cc b/source/blender/draw/intern/draw_manager.cc index f48f56b80d3..b9a24d5a9fa 100644 --- a/source/blender/draw/intern/draw_manager.cc +++ b/source/blender/draw/intern/draw_manager.cc @@ -102,6 +102,8 @@ void Manager::submit(PassSimple &pass, View &view) // GPU_storagebuf_bind(attribute_buf, DRW_OBJ_ATTR_SLOT); /* TODO */ pass.submit(state); + + state.cleanup(); } void Manager::submit(PassMain &pass, View &view) @@ -122,12 +124,7 @@ void Manager::submit(PassMain &pass, View &view) pass.submit(state); - if (G.debug & G_DEBUG_GPU) { - GPU_storagebuf_unbind_all(); - GPU_texture_image_unbind_all(); - GPU_texture_unbind_all(); - GPU_uniformbuf_unbind_all(); - } + state.cleanup(); } Manager::SubmitDebugOutput Manager::submit_debug(PassSimple &pass, View &view) -- cgit v1.2.3