Fix T86450: Random dark UI elements when redrawing
Resolves occasional glitch/flicker drawing dark buttons in the UI.
Regression in 405a5d3bd7
which removed shader unbinding when the batch is drawn.
GPU_shader_bind could run with the sRGB uniform in an unexpected state.
Reviewed By: fclem
Ref D11124
This commit is contained in:
parent
37e16e3589
commit
b7f3ebe014
Notes:
blender-bot
2023-02-13 19:18:29 +01:00
Referenced by issue #86450, Random User Interface Colour Change (2.91+ Regression?)
|
@ -57,6 +57,8 @@ static CLG_LogRef LOG = {"gpu.shader"};
|
|||
using namespace blender;
|
||||
using namespace blender::gpu;
|
||||
|
||||
static bool gpu_shader_srgb_uniform_dirty_get();
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Debug functions
|
||||
* \{ */
|
||||
|
@ -501,9 +503,13 @@ void GPU_shader_bind(GPUShader *gpu_shader)
|
|||
GPU_matrix_bind(gpu_shader);
|
||||
GPU_shader_set_srgb_uniform(gpu_shader);
|
||||
}
|
||||
|
||||
if (GPU_matrix_dirty_get()) {
|
||||
GPU_matrix_bind(gpu_shader);
|
||||
else {
|
||||
if (gpu_shader_srgb_uniform_dirty_get()) {
|
||||
GPU_shader_set_srgb_uniform(gpu_shader);
|
||||
}
|
||||
if (GPU_matrix_dirty_get()) {
|
||||
GPU_matrix_bind(gpu_shader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -715,6 +721,12 @@ void GPU_shader_uniform_4fv_array(GPUShader *sh, const char *name, int len, cons
|
|||
* \{ */
|
||||
|
||||
static int g_shader_builtin_srgb_transform = 0;
|
||||
static bool g_shader_builtin_srgb_is_dirty = false;
|
||||
|
||||
static bool gpu_shader_srgb_uniform_dirty_get(void)
|
||||
{
|
||||
return g_shader_builtin_srgb_is_dirty;
|
||||
}
|
||||
|
||||
void GPU_shader_set_srgb_uniform(GPUShader *shader)
|
||||
{
|
||||
|
@ -722,11 +734,15 @@ void GPU_shader_set_srgb_uniform(GPUShader *shader)
|
|||
if (loc != -1) {
|
||||
GPU_shader_uniform_vector_int(shader, loc, 1, 1, &g_shader_builtin_srgb_transform);
|
||||
}
|
||||
g_shader_builtin_srgb_is_dirty = false;
|
||||
}
|
||||
|
||||
void GPU_shader_set_framebuffer_srgb_target(int use_srgb_to_linear)
|
||||
{
|
||||
g_shader_builtin_srgb_transform = use_srgb_to_linear;
|
||||
if (g_shader_builtin_srgb_transform != use_srgb_to_linear) {
|
||||
g_shader_builtin_srgb_transform = use_srgb_to_linear;
|
||||
g_shader_builtin_srgb_is_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
Loading…
Reference in New Issue