From 523796808ae9de6f8fc778a2f5599a8314989189 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Mon, 10 Dec 2018 13:46:35 +0100 Subject: [PATCH] vrend: cache GL_DRAW_INDIRECT_BUFFER binding This is only updated from one place, and it's usually going to stay zero. So let's cache it to prevent excessive state emission. Signed-off-by: Erik Faye-Lund Reviewed-by: Gurchetan Singh Signed-off-by: Dave Airlie --- src/vrend_renderer.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index bea203d..e11fa81 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -538,6 +538,8 @@ struct vrend_sub_context { GLuint program_id; int last_shader_idx; + GLint draw_indirect_buffer; + struct pipe_rasterizer_state hw_rs_state; struct pipe_blend_state hw_blend_state; @@ -4044,10 +4046,11 @@ int vrend_draw_vbo(struct vrend_context *ctx, } if (has_feature(feat_indirect_draw)) { - if (indirect_res) - glBindBuffer(GL_DRAW_INDIRECT_BUFFER, indirect_res->id); - else - glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0); + GLint buf = indirect_res ? indirect_res->id : 0; + if (ctx->sub->draw_indirect_buffer != buf) { + glBindBuffer(GL_DRAW_INDIRECT_BUFFER, buf); + ctx->sub->draw_indirect_buffer = buf; + } } if (info->vertices_per_patch && has_feature(feat_tessellation))