glamor: Just set the logic op to what we want at the start of all rendering.
By dropping the unconditional logic op disable at the end of rendering, this fixes GL errors being thrown in GLES2 contexts (which don't have logic ops). On desktop, this also means a little less overhead per draw call from taking one less trip through the glEnable/glDisable switch statement of doom in Mesa. The exchange here is that we end up taking a trip through it in the XV, Render, and gradient-generation paths. If the glEnable() is actually costly, we should probably cache our logic op state in our screen, since there's no way the GL could make that switch statement as cheap as the caller caching it would be. v2: Don't forget to set the logic op in Xephyr's drawing. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
8102927282
commit
6ba6cc57e1
|
@ -404,11 +404,9 @@ glamor_copy_fbo_fbo_draw(DrawablePtr src,
|
|||
glDisable(GL_SCISSOR_TEST);
|
||||
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
return TRUE;
|
||||
|
||||
bail_ctx:
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -452,7 +450,6 @@ glamor_copy_fbo_fbo_temp(DrawablePtr src,
|
|||
|
||||
if (!glamor_set_alu(screen, gc ? gc->alu : GXcopy))
|
||||
goto bail_ctx;
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
|
||||
/* Find the size of the area to copy
|
||||
*/
|
||||
|
@ -521,7 +518,6 @@ bail:
|
|||
return FALSE;
|
||||
|
||||
bail_ctx:
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -159,11 +159,11 @@ glamor_dash_setup(DrawablePtr drawable, GCPtr gc)
|
|||
&glamor_priv->on_off_dash_line_progs,
|
||||
&glamor_facet_on_off_dash_lines);
|
||||
if (!prog)
|
||||
goto bail_ctx;
|
||||
goto bail;
|
||||
break;
|
||||
case LineDoubleDash:
|
||||
if (gc->fillStyle != FillSolid)
|
||||
goto bail_ctx;
|
||||
goto bail;
|
||||
|
||||
prog = &glamor_priv->double_dash_line_prog;
|
||||
|
||||
|
@ -171,18 +171,18 @@ glamor_dash_setup(DrawablePtr drawable, GCPtr gc)
|
|||
if (!glamor_build_program(screen, prog,
|
||||
&glamor_facet_double_dash_lines,
|
||||
NULL))
|
||||
goto bail_ctx;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
if (!glamor_use_program(pixmap, gc, prog, NULL))
|
||||
goto bail_ctx;
|
||||
goto bail;
|
||||
|
||||
glamor_set_color(pixmap, gc->fgPixel, prog->fg_uniform);
|
||||
glamor_set_color(pixmap, gc->bgPixel, prog->bg_uniform);
|
||||
break;
|
||||
|
||||
default:
|
||||
goto bail_ctx;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
|
||||
|
@ -195,8 +195,6 @@ glamor_dash_setup(DrawablePtr drawable, GCPtr gc)
|
|||
|
||||
return prog;
|
||||
|
||||
bail_ctx:
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
bail:
|
||||
return NULL;
|
||||
}
|
||||
|
@ -230,7 +228,6 @@ glamor_dash_loop(DrawablePtr drawable, GCPtr gc, glamor_program *prog,
|
|||
}
|
||||
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ glamor_poly_glyph_blt_gl(DrawablePtr drawable, GCPtr gc,
|
|||
&glamor_priv->poly_glyph_blt_progs,
|
||||
&glamor_facet_poly_glyph_blt);
|
||||
if (!prog)
|
||||
goto bail_ctx;
|
||||
goto bail;
|
||||
|
||||
glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
|
||||
|
@ -138,12 +138,9 @@ glamor_poly_glyph_blt_gl(DrawablePtr drawable, GCPtr gc,
|
|||
}
|
||||
}
|
||||
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
|
||||
return TRUE;
|
||||
bail_ctx:
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
bail:
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -191,7 +188,7 @@ glamor_push_pixels_gl(GCPtr gc, PixmapPtr bitmap,
|
|||
&glamor_priv->poly_glyph_blt_progs,
|
||||
&glamor_facet_poly_glyph_blt);
|
||||
if (!prog)
|
||||
goto bail_ctx;
|
||||
goto bail;
|
||||
|
||||
glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
|
||||
|
@ -230,12 +227,9 @@ glamor_push_pixels_gl(GCPtr gc, PixmapPtr bitmap,
|
|||
glDrawArrays(GL_POINTS, 0, num_points);
|
||||
}
|
||||
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
return TRUE;
|
||||
|
||||
bail_ctx:
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
bail:
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -993,6 +993,8 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
|
|||
vertices, tex_vertices, 0))
|
||||
goto GRADIENT_FAIL;
|
||||
|
||||
glamor_set_alu(screen, GXcopy);
|
||||
|
||||
/* Set all the stops and colors to shader. */
|
||||
if (stops_count > RADIAL_SMALL_STOPS) {
|
||||
stop_colors = malloc(4 * stops_count * sizeof(float));
|
||||
|
@ -1309,6 +1311,8 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
|
|||
vertices, tex_vertices, 1))
|
||||
goto GRADIENT_FAIL;
|
||||
|
||||
glamor_set_alu(screen, GXcopy);
|
||||
|
||||
/* Normalize the PTs. */
|
||||
glamor_set_normalize_pt(xscale, yscale,
|
||||
pixman_fixed_to_double(src_picture->pSourcePict->
|
||||
|
|
|
@ -65,7 +65,7 @@ glamor_poly_lines_solid_gl(DrawablePtr drawable, GCPtr gc,
|
|||
&glamor_facet_poly_lines);
|
||||
|
||||
if (!prog)
|
||||
goto bail_ctx;
|
||||
goto bail;
|
||||
|
||||
/* Set up the vertex buffers for the points */
|
||||
|
||||
|
@ -117,12 +117,9 @@ glamor_poly_lines_solid_gl(DrawablePtr drawable, GCPtr gc,
|
|||
}
|
||||
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
|
||||
return TRUE;
|
||||
bail_ctx:
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
bail:
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -748,6 +748,7 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format,
|
|||
int swap_rb, int x, int y, int w, int h,
|
||||
int stride, void *bits, int pbo)
|
||||
{
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
|
@ -833,6 +834,7 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format,
|
|||
glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
|
||||
glamor_set_destination_pixmap_priv_nc(glamor_priv, pixmap, pixmap_priv);
|
||||
glamor_set_alu(screen, GXcopy);
|
||||
__glamor_upload_pixmap_to_texture(pixmap, &tex,
|
||||
format, type, 0, 0, w, h, bits, pbo);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
@ -1131,6 +1133,7 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h,
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
glamor_set_destination_pixmap_fbo(glamor_priv, temp_fbo, 0, 0, w, h);
|
||||
glamor_set_alu(screen, GXcopy);
|
||||
glUseProgram(glamor_priv->finish_access_prog[no_alpha]);
|
||||
glUniform1i(glamor_priv->finish_access_revert[no_alpha], revert);
|
||||
glUniform1i(glamor_priv->finish_access_swap_rb[no_alpha], swap_rb);
|
||||
|
|
|
@ -55,17 +55,17 @@ glamor_poly_point_gl(DrawablePtr drawable, GCPtr gc, int mode, int npt, DDXPoint
|
|||
glamor_make_current(glamor_priv);
|
||||
|
||||
if (prog->failed)
|
||||
goto bail_ctx;
|
||||
goto bail;
|
||||
|
||||
if (!prog->prog) {
|
||||
if (!glamor_build_program(screen, prog,
|
||||
&glamor_facet_point,
|
||||
&glamor_fill_solid))
|
||||
goto bail_ctx;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
if (!glamor_use_program(pixmap, gc, prog, NULL))
|
||||
goto bail_ctx;
|
||||
goto bail;
|
||||
|
||||
vbo_ppt = glamor_get_vbo_space(screen, npt * (2 * sizeof (INT16)), &vbo_offset);
|
||||
glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
|
@ -102,13 +102,10 @@ glamor_poly_point_gl(DrawablePtr drawable, GCPtr gc, int mode, int npt, DDXPoint
|
|||
}
|
||||
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
|
||||
return TRUE;
|
||||
|
||||
bail_ctx:
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
bail:
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
|
|||
&glamor_facet_polyfillrect_130);
|
||||
|
||||
if (!prog)
|
||||
goto bail_ctx;
|
||||
goto bail;
|
||||
|
||||
/* Set up the vertex buffers for the points */
|
||||
|
||||
|
@ -87,7 +87,7 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
|
|||
&glamor_facet_polyfillrect_120);
|
||||
|
||||
if (!prog)
|
||||
goto bail_ctx;
|
||||
goto bail;
|
||||
|
||||
/* Set up the vertex buffers for the points */
|
||||
|
||||
|
@ -139,14 +139,11 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
|
|||
}
|
||||
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
if (glamor_priv->glsl_version >= 130)
|
||||
glVertexAttribDivisor(GLAMOR_VERTEX_POS, 0);
|
||||
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
|
||||
return TRUE;
|
||||
bail_ctx:
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
bail:
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -1172,6 +1172,7 @@ glamor_composite_with_shader(CARD8 op,
|
|||
|
||||
glamor_set_destination_pixmap_priv_nc(glamor_priv, dest_pixmap, dest_pixmap_priv);
|
||||
glamor_composite_set_shader_blend(glamor_priv, dest_pixmap_priv, &key, shader, &op_info);
|
||||
glamor_set_alu(screen, GXcopy);
|
||||
|
||||
glamor_make_current(glamor_priv);
|
||||
|
||||
|
|
|
@ -109,12 +109,10 @@ glamor_poly_segment_solid_gl(DrawablePtr drawable, GCPtr gc,
|
|||
}
|
||||
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
|
||||
return TRUE;
|
||||
bail_ctx:
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
bail:
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ glamor_fill_spans_gl(DrawablePtr drawable,
|
|||
&glamor_facet_fillspans_130);
|
||||
|
||||
if (!prog)
|
||||
goto bail_ctx;
|
||||
goto bail;
|
||||
|
||||
/* Set up the vertex buffers for the points */
|
||||
|
||||
|
@ -93,7 +93,7 @@ glamor_fill_spans_gl(DrawablePtr drawable,
|
|||
&glamor_facet_fillspans_120);
|
||||
|
||||
if (!prog)
|
||||
goto bail_ctx;
|
||||
goto bail;
|
||||
|
||||
/* Set up the vertex buffers for the points */
|
||||
|
||||
|
@ -147,14 +147,11 @@ glamor_fill_spans_gl(DrawablePtr drawable,
|
|||
}
|
||||
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
if (glamor_priv->glsl_version >= 130)
|
||||
glVertexAttribDivisor(GLAMOR_VERTEX_POS, 0);
|
||||
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
|
||||
return TRUE;
|
||||
bail_ctx:
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
bail:
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -210,7 +210,6 @@ glamor_text(DrawablePtr drawable, GCPtr gc,
|
|||
glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
glVertexAttribDivisor(GLAMOR_VERTEX_POS, 0);
|
||||
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
@ -286,18 +285,14 @@ glamor_poly_text(DrawablePtr drawable, GCPtr gc,
|
|||
prog = glamor_use_program_fill(pixmap, gc, &glamor_priv->poly_text_progs, &glamor_facet_poly_text);
|
||||
|
||||
if (!prog)
|
||||
goto bail_ctx;
|
||||
goto bail;
|
||||
|
||||
x = glamor_text(drawable, gc, glamor_font, prog,
|
||||
x, y, count, chars, charinfo, sixteen);
|
||||
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
|
||||
*final_pos = x;
|
||||
return TRUE;
|
||||
|
||||
bail_ctx:
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
bail:
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -468,7 +463,6 @@ glamor_image_text(DrawablePtr drawable, GCPtr gc,
|
|||
return TRUE;
|
||||
|
||||
bail:
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -286,6 +286,7 @@ glamor_xv_render(glamor_port_private *port_priv)
|
|||
glamor_get_drawable_deltas(port_priv->pDraw, port_priv->pPixmap, &dst_x_off,
|
||||
&dst_y_off);
|
||||
glamor_set_destination_pixmap_priv_nc(glamor_priv, pixmap, pixmap_priv);
|
||||
glamor_set_alu(screen, GXcopy);
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (port_priv->src_pix[i]) {
|
||||
|
|
|
@ -214,6 +214,8 @@ ephyr_glamor_damage_redisplay(struct ephyr_glamor *glamor,
|
|||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glUseProgram(glamor->texture_shader);
|
||||
glViewport(0, 0, glamor->width, glamor->height);
|
||||
if (!ephyr_glamor_gles2)
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
|
||||
glVertexAttribPointer(glamor->texture_shader_position_loc,
|
||||
2, GL_FLOAT, FALSE, 0, position);
|
||||
|
|
Loading…
Reference in New Issue