Revert "Revert "BGL: Workaround broken bgl usage caused by GPU refactor""
This reverts commit f23bf4cb10
.
This commit is contained in:
@@ -281,7 +281,7 @@ void ED_region_draw_cb_draw(const bContext *C, ARegion *region, int type)
|
|||||||
}
|
}
|
||||||
if (has_drawn_something) {
|
if (has_drawn_something) {
|
||||||
/* This is needed until we get rid of BGL which can change the states we are tracking. */
|
/* This is needed until we get rid of BGL which can change the states we are tracking. */
|
||||||
GPU_force_state();
|
GPU_bgl_end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -161,7 +161,10 @@ float GPU_line_width_get(void);
|
|||||||
void GPU_flush(void);
|
void GPU_flush(void);
|
||||||
void GPU_finish(void);
|
void GPU_finish(void);
|
||||||
void GPU_apply_state(void);
|
void GPU_apply_state(void);
|
||||||
void GPU_force_state(void);
|
|
||||||
|
void GPU_bgl_start(void);
|
||||||
|
void GPU_bgl_end(void);
|
||||||
|
bool GPU_bgl_get(void);
|
||||||
|
|
||||||
void GPU_memory_barrier(eGPUBarrier barrier);
|
void GPU_memory_barrier(eGPUBarrier barrier);
|
||||||
|
|
||||||
|
@@ -317,10 +317,39 @@ void GPU_apply_state(void)
|
|||||||
Context::get()->state_manager->apply_state();
|
Context::get()->state_manager->apply_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Will set all the states regardless of the current ones. */
|
/** \} */
|
||||||
void GPU_force_state(void)
|
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
/** \name BGL workaround
|
||||||
|
*
|
||||||
|
* bgl makes direct GL calls that makes our state tracking out of date.
|
||||||
|
* This flag make it so that the pyGPU calls will not override the state set by
|
||||||
|
* bgl functions.
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
void GPU_bgl_start(void)
|
||||||
{
|
{
|
||||||
Context::get()->state_manager->force_state();
|
StateManager &state_manager = *(Context::get()->state_manager);
|
||||||
|
if (state_manager.use_bgl == false) {
|
||||||
|
/* Expected by many addons (see T80169, T81289).
|
||||||
|
* This will reset the blend function. */
|
||||||
|
GPU_blend(GPU_BLEND_NONE);
|
||||||
|
state_manager.apply_state();
|
||||||
|
state_manager.use_bgl = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GPU_bgl_end(void)
|
||||||
|
{
|
||||||
|
StateManager &state_manager = *(Context::get()->state_manager);
|
||||||
|
state_manager.use_bgl = false;
|
||||||
|
/* Resync state tracking. */
|
||||||
|
state_manager.force_state();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GPU_bgl_get(void)
|
||||||
|
{
|
||||||
|
return Context::get()->state_manager->use_bgl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
@@ -153,6 +153,7 @@ class StateManager {
|
|||||||
public:
|
public:
|
||||||
GPUState state;
|
GPUState state;
|
||||||
GPUStateMutable mutable_state;
|
GPUStateMutable mutable_state;
|
||||||
|
bool use_bgl = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StateManager();
|
StateManager();
|
||||||
|
@@ -200,7 +200,7 @@ void check_gl_error(const char *info)
|
|||||||
|
|
||||||
void check_gl_resources(const char *info)
|
void check_gl_resources(const char *info)
|
||||||
{
|
{
|
||||||
if (!(G.debug & G_DEBUG_GPU)) {
|
if (!(G.debug & G_DEBUG_GPU) || GPU_bgl_get()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -73,13 +73,17 @@ GLStateManager::GLStateManager(void) : StateManager()
|
|||||||
|
|
||||||
void GLStateManager::apply_state(void)
|
void GLStateManager::apply_state(void)
|
||||||
{
|
{
|
||||||
this->set_state(this->state);
|
if (!this->use_bgl) {
|
||||||
this->set_mutable_state(this->mutable_state);
|
this->set_state(this->state);
|
||||||
this->texture_bind_apply();
|
this->set_mutable_state(this->mutable_state);
|
||||||
this->image_bind_apply();
|
this->texture_bind_apply();
|
||||||
|
this->image_bind_apply();
|
||||||
|
}
|
||||||
|
/* This is needed by gpu_py_offscreen. */
|
||||||
active_fb->apply_state();
|
active_fb->apply_state();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Will set all the states regardless of the current ones. */
|
||||||
void GLStateManager::force_state(void)
|
void GLStateManager::force_state(void)
|
||||||
{
|
{
|
||||||
/* Little exception for clip distances since they need to keep the old count correct. */
|
/* Little exception for clip distances since they need to keep the old count correct. */
|
||||||
|
@@ -29,6 +29,8 @@
|
|||||||
#include "BLI_utildefines.h"
|
#include "BLI_utildefines.h"
|
||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
|
#include "GPU_state.h"
|
||||||
|
|
||||||
#include "../generic/py_capi_utils.h"
|
#include "../generic/py_capi_utils.h"
|
||||||
|
|
||||||
#include "glew-mx.h"
|
#include "glew-mx.h"
|
||||||
@@ -1109,6 +1111,7 @@ static PyObject *Buffer_repr(Buffer *self)
|
|||||||
if (!PyArg_ParseTuple(args, arg_str arg_list, arg_ref arg_list)) { \
|
if (!PyArg_ParseTuple(args, arg_str arg_list, arg_ref arg_list)) { \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
} \
|
} \
|
||||||
|
GPU_bgl_start(); \
|
||||||
ret_set_##ret gl##funcname(arg_var arg_list); \
|
ret_set_##ret gl##funcname(arg_var arg_list); \
|
||||||
ret_ret_##ret; \
|
ret_ret_##ret; \
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user