vrend: Don't cache blend enable state and set it directly

When enabling/disabling GL_BLEND via vrend_blend_enable the context
cached the last state and doesn't call glEnable/glDisable if the state
didn't change. However, when gl(Enable|Disable)IndexedEXT is used with
index 0, then this vrenderer internal state is not updated even though
the corresponding GL state may be changed, and calling vrend_blend_enable
later may not update the actual OpenGL state correctly.

In order to avoid this and to simplify the setting the blend enabled state
remove the caching and always call glEnable/glDisable directly.

v2: remove caching for blend enabled/disabled (Dave)

Closes: #23

Fixes state leak with:
  dEQP-GLES31.functional.draw_buffers_indexed.overwrite_common.
    common_separate_blend_eq_buffer_separate_blend_eq
    common_separate_blend_eq_buffer_advanced_blend_eq

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
macos/master
Gert Wollny 6 years ago committed by Dave Airlie
parent a5bfadaab5
commit 10ae7e399c
  1. 20
      src/vrend_renderer.c

@ -512,7 +512,6 @@ struct vrend_sub_context {
struct pipe_clip_state ucp_state;
bool blend_enabled;
bool depth_test_enabled;
bool alpha_test_enabled;
bool stencil_test_enabled;
@ -890,17 +889,6 @@ static void vrend_init_pstipple_texture(struct vrend_context *ctx)
ctx->pstip_inited = true;
}
static void vrend_blend_enable(struct vrend_context *ctx, bool blend_enable)
{
if (ctx->sub->blend_enabled != blend_enable) {
ctx->sub->blend_enabled = blend_enable;
if (blend_enable)
glEnable(GL_BLEND);
else
glDisable(GL_BLEND);
}
}
static void vrend_depth_test_enable(struct vrend_context *ctx, bool depth_test_enable)
{
if (ctx->sub->depth_test_enabled != depth_test_enable) {
@ -4262,10 +4250,10 @@ static void vrend_hw_emit_blend(struct vrend_context *ctx, struct pipe_blend_sta
translate_blend_factor(state->rt[0].alpha_dst_factor));
glBlendEquationSeparate(translate_blend_func(state->rt[0].rgb_func),
translate_blend_func(state->rt[0].alpha_func));
vrend_blend_enable(ctx, true);
glEnable(GL_BLEND);
}
else
vrend_blend_enable(ctx, false);
glDisable(GL_BLEND);
if (state->rt[0].colormask != ctx->sub->hw_blend_state.rt[0].colormask) {
int i;
@ -4367,7 +4355,7 @@ void vrend_object_bind_blend(struct vrend_context *ctx,
if (handle == 0) {
memset(&ctx->sub->blend_state, 0, sizeof(ctx->sub->blend_state));
vrend_blend_enable(ctx, false);
glDisable(GL_BLEND);
return;
}
state = vrend_object_lookup(ctx->sub->object_hash, handle, VIRGL_OBJECT_BLEND);
@ -6122,7 +6110,7 @@ static int vrend_renderer_transfer_write_iov(struct vrend_context *ctx,
buffers = GL_COLOR_ATTACHMENT0_EXT;
glDrawBuffers(1, &buffers);
vrend_blend_enable(ctx, false);
glDisable(GL_BLEND);
vrend_depth_test_enable(ctx, false);
vrend_alpha_test_enable(ctx, false);
vrend_stencil_test_enable(ctx, false);

Loading…
Cancel
Save