diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-09-12 18:29:37 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-09-12 18:29:37 +0300 |
commit | bf3f4da9472516be12dcc69740fa69b6d72f1274 (patch) | |
tree | 8e8eaaee61d0570026c46eeeb8ea882146b04ca7 /source/blender/gpu | |
parent | 6bc0a8424e9b794accf70534ed55478337f0e3e3 (diff) |
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
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/GPU_state.h | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_state.cc | 18 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_state_private.hh | 1 | ||||
-rw-r--r-- | source/blender/gpu/opengl/gl_state.cc | 11 | ||||
-rw-r--r-- | source/blender/gpu/opengl/gl_state.hh | 1 |
5 files changed, 27 insertions, 6 deletions
diff --git a/source/blender/gpu/GPU_state.h b/source/blender/gpu/GPU_state.h index aa32c6c75ba..a857736acd5 100644 --- a/source/blender/gpu/GPU_state.h +++ b/source/blender/gpu/GPU_state.h @@ -159,6 +159,8 @@ eGPUStencilTest GPU_stencil_test_get(void); void GPU_flush(void); void GPU_finish(void); +void GPU_apply_state(void); +void GPU_force_state(void); void GPU_memory_barrier(eGPUBarrier barrier); diff --git a/source/blender/gpu/intern/gpu_state.cc b/source/blender/gpu/intern/gpu_state.cc index a3d07b1e1db..b63abb3d57f 100644 --- a/source/blender/gpu/intern/gpu_state.cc +++ b/source/blender/gpu/intern/gpu_state.cc @@ -305,6 +305,17 @@ void GPU_finish(void) Context::get()->finish(); } +void GPU_apply_state(void) +{ + Context::get()->state_manager->apply_state(); +} + +/* Will set all the states regardless of the current ones. */ +void GPU_force_state(void) +{ + Context::get()->state_manager->force_state(); +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -319,12 +330,7 @@ void GPU_memory_barrier(eGPUBarrier barrier) /** \} */ /* -------------------------------------------------------------------- */ -/** \name Default OpenGL State - * - * This is called on startup, for opengl offscreen render. - * Generally we should always return to this state when - * temporarily modifying the state for drawing, though that are (undocumented) - * exceptions that we should try to get rid of. +/** \name Default State * \{ */ StateManager::StateManager(void) diff --git a/source/blender/gpu/intern/gpu_state_private.hh b/source/blender/gpu/intern/gpu_state_private.hh index d85375a85bb..b8d247ec175 100644 --- a/source/blender/gpu/intern/gpu_state_private.hh +++ b/source/blender/gpu/intern/gpu_state_private.hh @@ -159,6 +159,7 @@ class StateManager { virtual ~StateManager(){}; virtual void apply_state(void) = 0; + virtual void force_state(void) = 0; virtual void issue_barrier(eGPUBarrier barrier_bits) = 0; diff --git a/source/blender/gpu/opengl/gl_state.cc b/source/blender/gpu/opengl/gl_state.cc index 3c577bf1ccd..cd24fa0e0e4 100644 --- a/source/blender/gpu/opengl/gl_state.cc +++ b/source/blender/gpu/opengl/gl_state.cc @@ -80,6 +80,17 @@ void GLStateManager::apply_state(void) active_fb->apply_state(); }; +void GLStateManager::force_state(void) +{ + /* Little exception for clip distances since they need to keep the old count correct. */ + uint32_t clip_distances = current_.clip_distances; + current_ = ~this->state; + current_.clip_distances = clip_distances; + current_mutable_ = ~this->mutable_state; + this->set_state(this->state); + this->set_mutable_state(this->mutable_state); +}; + void GLStateManager::set_state(const GPUState &state) { GPUState changed = state ^ current_; diff --git a/source/blender/gpu/opengl/gl_state.hh b/source/blender/gpu/opengl/gl_state.hh index b98c4b300f3..cab654006c6 100644 --- a/source/blender/gpu/opengl/gl_state.hh +++ b/source/blender/gpu/opengl/gl_state.hh @@ -72,6 +72,7 @@ class GLStateManager : public StateManager { GLStateManager(); void apply_state(void) override; + void force_state(void) override; void issue_barrier(eGPUBarrier barrier_bits) override; |