Commit fab0a4a4 authored by Eric Anholt's avatar Eric Anholt

glamor: Replace glamor_get/put_context() with just glamor_make_current().

Now that we have the DIX global state for the current context, we
don't need to track nesting to try to reduce MakeCurrent overhead.

v2: Fix a mistaken replacement of a put_context with make_current in
    glamor_fill_spans_gl() (caught by keithp).
Signed-off-by: Eric Anholt's avatarEric Anholt <eric@anholt.net>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> (v1)
Reviewed-by: Adam Jackson <ajax@redhat.com> (v1)
parent 11ff12d4
......@@ -248,11 +248,10 @@ glamor_block_handler(ScreenPtr screen)
{
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
glamor_priv->tick++;
glFlush();
glamor_fbo_expire(glamor_priv);
glamor_put_context(glamor_priv);
if (glamor_priv->state == RENDER_STATE
&& glamor_priv->render_idle_cnt++ > RENDER_IDEL_MAX) {
glamor_priv->state = IDLE_STATE;
......@@ -265,9 +264,8 @@ _glamor_block_handler(void *data, OSTimePtr timeout, void *last_select_mask)
{
glamor_screen_private *glamor_priv = data;
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
glFlush();
glamor_put_context(glamor_priv);
}
static void
......
......@@ -43,14 +43,7 @@ struct glamor_context {
/** The GLXDrawable we should MakeCurrent to */
uint32_t drawable_xid;
/**
* Count of how deep in glamor_get_context() we are, to reduce
* MakeCurrent calls.
*/
int get_count;
void (*get_context)(struct glamor_context *glamor_ctx);
void (*put_context)(struct glamor_context *glamor_ctx);
void (*make_current)(struct glamor_context *glamor_ctx);
};
Bool glamor_glx_screen_init(struct glamor_context *glamor_ctx);
......@@ -70,7 +70,7 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
pixmap_priv_get_fbo_off(dst_pixmap_priv, &fbo_x_off, &fbo_y_off);
pixmap_priv_get_fbo_off(src_pixmap_priv, &src_fbo_x_off, &src_fbo_y_off);
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, src_pixmap_priv->base.fbo->fb);
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off);
......@@ -112,7 +112,6 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
GL_COLOR_BUFFER_BIT, GL_NEAREST);
}
}
glamor_put_context(glamor_priv);
glamor_priv->state = BLIT_STATE;
return TRUE;
}
......@@ -155,7 +154,7 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
......@@ -206,7 +205,6 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
/* The source texture is bound to a fbo, we have to flush it here. */
glamor_put_context(glamor_priv);
glamor_priv->state = RENDER_STATE;
glamor_priv->render_idle_cnt = 0;
return TRUE;
......@@ -367,12 +365,10 @@ _glamor_copy_n_to_n(DrawablePtr src,
if (gc) {
if (!glamor_set_planemask(dst_pixmap, gc->planemask))
goto fall_back;
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
if (!glamor_set_alu(screen, gc->alu)) {
glamor_put_context(glamor_priv);
goto fail;
}
glamor_put_context(glamor_priv);
}
if (!src_pixmap_priv) {
......@@ -545,9 +541,8 @@ _glamor_copy_n_to_n(DrawablePtr src,
}
fail:
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
glamor_set_alu(screen, GXcopy);
glamor_put_context(glamor_priv);
if (ok)
return TRUE;
......
......@@ -241,7 +241,7 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
char *source;
glamor_priv = glamor_get_screen_private(screen);
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
glamor_priv->finish_access_prog[0] = glCreateProgram();
glamor_priv->finish_access_prog[1] = glCreateProgram();
......@@ -300,7 +300,6 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
glUniform1i(glamor_priv->finish_access_revert[1], 0);
glUniform1i(sampler_uniform_location, 0);
glUniform1i(glamor_priv->finish_access_swap_rb[1], 0);
glamor_put_context(glamor_priv);
}
void
......@@ -309,10 +308,9 @@ glamor_fini_finish_access_shaders(ScreenPtr screen)
glamor_screen_private *glamor_priv;
glamor_priv = glamor_get_screen_private(screen);
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
glDeleteProgram(glamor_priv->finish_access_prog[0]);
glDeleteProgram(glamor_priv->finish_access_prog[1]);
glamor_put_context(glamor_priv);
}
void
......@@ -341,11 +339,10 @@ glamor_finish_access(DrawablePtr drawable)
if (pixmap_priv->base.fbo->pbo != 0 && pixmap_priv->base.fbo->pbo_valid) {
assert(glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP);
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
glDeleteBuffers(1, &pixmap_priv->base.fbo->pbo);
glamor_put_context(glamor_priv);
pixmap_priv->base.fbo->pbo_valid = FALSE;
pixmap_priv->base.fbo->pbo = 0;
......
......@@ -95,11 +95,8 @@ glamor_egl_get_screen_private(ScrnInfoPtr scrn)
}
static void
glamor_egl_get_context(struct glamor_context *glamor_ctx)
glamor_egl_make_current(struct glamor_context *glamor_ctx)
{
if (glamor_ctx->get_count++)
return;
eglMakeCurrent(glamor_ctx->display, EGL_NO_SURFACE,
EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (!eglMakeCurrent(glamor_ctx->display,
......@@ -109,12 +106,6 @@ glamor_egl_get_context(struct glamor_context *glamor_ctx)
}
}
static void
glamor_egl_put_context(struct glamor_context *glamor_ctx)
{
--glamor_ctx->get_count;
}
static EGLImageKHR
_glamor_egl_create_image(struct glamor_egl_screen_private *glamor_egl,
int width, int height, int stride, int name, int depth)
......@@ -166,7 +157,7 @@ glamor_create_texture_from_image(ScreenPtr screen,
struct glamor_screen_private *glamor_priv =
glamor_get_screen_private(screen);
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
glGenTextures(1, texture);
glBindTexture(GL_TEXTURE_2D, *texture);
......@@ -176,8 +167,6 @@ glamor_create_texture_from_image(ScreenPtr screen,
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
glBindTexture(GL_TEXTURE_2D, 0);
glamor_put_context(glamor_priv);
return TRUE;
}
......@@ -290,7 +279,7 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
glamor_egl = glamor_egl_get_screen_private(scrn);
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
if (glamor_egl->has_gem) {
if (!glamor_get_flink_name(glamor_egl->fd, handle, &name)) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
......@@ -320,7 +309,6 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
ret = TRUE;
done:
glamor_put_context(glamor_priv);
return ret;
}
......@@ -340,7 +328,7 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo)
glamor_egl = glamor_egl_get_screen_private(scrn);
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
image = eglCreateImageKHR(glamor_egl->display,
glamor_egl->context,
......@@ -356,7 +344,6 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo)
ret = TRUE;
done:
glamor_put_context(glamor_priv);
return ret;
}
......@@ -414,7 +401,7 @@ glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
glamor_egl = glamor_egl_get_screen_private(scrn);
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
image = pixmap_priv->base.image;
if (!image) {
......@@ -449,7 +436,6 @@ glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
gbm_bo_destroy(bo);
failure:
glamor_put_context(glamor_priv);
return fd;
#else
return -1;
......@@ -679,8 +665,7 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
glamor_ctx->ctx = glamor_egl->context;
glamor_ctx->display = glamor_egl->display;
glamor_ctx->get_context = glamor_egl_get_context;
glamor_ctx->put_context = glamor_egl_put_context;
glamor_ctx->make_current = glamor_egl_make_current;
if (glamor_egl->dri3_capable) {
/* Tell the core that we have the interfaces for import/export
......
......@@ -129,7 +129,7 @@ glamor_pixmap_fbo_cache_get(glamor_screen_private *glamor_priv,
void
glamor_purge_fbo(glamor_pixmap_fbo *fbo)
{
glamor_get_context(fbo->glamor_priv);
glamor_make_current(fbo->glamor_priv);
if (fbo->fb)
glDeleteFramebuffers(1, &fbo->fb);
......@@ -137,7 +137,6 @@ glamor_purge_fbo(glamor_pixmap_fbo *fbo)
glDeleteTextures(1, &fbo->tex);
if (fbo->pbo)
glDeleteBuffers(1, &fbo->pbo);
glamor_put_context(fbo->glamor_priv);
free(fbo);
}
......@@ -180,7 +179,7 @@ glamor_pixmap_ensure_fb(glamor_pixmap_fbo *fbo)
{
int status;
glamor_get_context(fbo->glamor_priv);
glamor_make_current(fbo->glamor_priv);
if (fbo->fb == 0)
glGenFramebuffers(1, &fbo->fb);
......@@ -219,7 +218,6 @@ glamor_pixmap_ensure_fb(glamor_pixmap_fbo *fbo)
FatalError("destination is framebuffer incomplete: %s [%x]\n",
str, status);
}
glamor_put_context(fbo->glamor_priv);
}
glamor_pixmap_fbo *
......@@ -241,9 +239,8 @@ glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv,
fbo->glamor_priv = glamor_priv;
if (flag == GLAMOR_CREATE_PIXMAP_MAP) {
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
glGenBuffers(1, &fbo->pbo);
glamor_put_context(glamor_priv);
goto done;
}
......@@ -341,14 +338,13 @@ _glamor_create_tex(glamor_screen_private *glamor_priv,
w, h);
}
if (!tex) {
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0,
format, GL_UNSIGNED_BYTE, NULL);
glamor_put_context(glamor_priv);
}
return tex;
}
......
......@@ -156,7 +156,7 @@ glamor_init_solid_shader(ScreenPtr screen)
GLint fs_prog, vs_prog;
glamor_priv = glamor_get_screen_private(screen);
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
glamor_priv->solid_prog = glCreateProgram();
vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, solid_vs);
fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, solid_fs);
......@@ -169,7 +169,6 @@ glamor_init_solid_shader(ScreenPtr screen)
glamor_priv->solid_color_uniform_location =
glGetUniformLocation(glamor_priv->solid_prog, "color");
glamor_put_context(glamor_priv);
}
void
......@@ -178,9 +177,8 @@ glamor_fini_solid_shader(ScreenPtr screen)
glamor_screen_private *glamor_priv;
glamor_priv = glamor_get_screen_private(screen);
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
glDeleteProgram(glamor_priv->solid_prog);
glamor_put_context(glamor_priv);
}
static void
......@@ -196,7 +194,7 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
glUseProgram(glamor_priv->solid_prog);
glUniform4fv(glamor_priv->solid_color_uniform_location, 1, color);
......@@ -255,7 +253,6 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
free(vertices);
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
glamor_put_context(glamor_priv);
glamor_priv->state = RENDER_STATE;
glamor_priv->render_idle_cnt = 0;
}
......@@ -338,13 +335,12 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
return FALSE;
}
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
if (!glamor_set_alu(screen, alu)) {
if (alu == GXclear)
fg_pixel = 0;
else {
glamor_fallback("unsupported alu %x\n", alu);
glamor_put_context(glamor_priv);
return FALSE;
}
}
......@@ -355,7 +351,6 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
glamor_solid_boxes(pixmap, &box, 1, fg_pixel);
glamor_set_alu(screen, GXcopy);
glamor_put_context(glamor_priv);
return TRUE;
}
......@@ -89,7 +89,7 @@ glamor_font_get(ScreenPtr screen, FontPtr font)
glamor_font->default_col = font->info.defaultCh;
glamor_priv = glamor_get_screen_private(screen);
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
glGenTextures(1, &glamor_font->texture_id);
glActiveTexture(GL_TEXTURE0);
......@@ -119,8 +119,6 @@ glamor_font_get(ScreenPtr screen, FontPtr font)
}
}
glamor_put_context(glamor_priv);
return glamor_font;
}
......@@ -150,9 +148,8 @@ glamor_unrealize_font(ScreenPtr screen, FontPtr font)
glamor_font->realized = FALSE;
glamor_priv = glamor_get_screen_private(screen);
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
glDeleteTextures(1, &glamor_font->texture_id);
glamor_put_context(glamor_priv);
/* Check to see if all of the screens are done with this font
* and free the private when that happens
......
......@@ -34,22 +34,13 @@
*/
static void
glamor_glx_get_context(struct glamor_context *glamor_ctx)
glamor_glx_make_current(struct glamor_context *glamor_ctx)
{
if (glamor_ctx->get_count++)
return;
glXMakeCurrent(glamor_ctx->display, glamor_ctx->drawable_xid,
glamor_ctx->ctx);
}
static void
glamor_glx_put_context(struct glamor_context *glamor_ctx)
{
--glamor_ctx->get_count;
}
Bool
glamor_glx_screen_init(struct glamor_context *glamor_ctx)
{
......@@ -63,8 +54,7 @@ glamor_glx_screen_init(struct glamor_context *glamor_ctx)
glamor_ctx->drawable_xid = glXGetCurrentDrawable();
glamor_ctx->get_context = glamor_glx_get_context;
glamor_ctx->put_context = glamor_glx_put_context;
glamor_ctx->make_current = glamor_glx_make_current;
return True;
}
......@@ -54,7 +54,7 @@ glamor_poly_glyph_blt_gl(DrawablePtr drawable, GCPtr gc,
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
goto bail;
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
prog = glamor_use_program_fill(pixmap, gc, &glamor_priv->poly_glyph_blt_progs,
&glamor_facet_poly_glyph_blt);
......@@ -137,11 +137,9 @@ glamor_poly_glyph_blt_gl(DrawablePtr drawable, GCPtr gc,
glDisable(GL_COLOR_LOGIC_OP);
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
glamor_put_context(glamor_priv);
return TRUE;
bail_ctx:
glDisable(GL_COLOR_LOGIC_OP);
glamor_put_context(glamor_priv);
bail:
return FALSE;
}
......@@ -212,20 +210,18 @@ glamor_push_pixels_points(GCPtr gc, PixmapPtr bitmap,
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
return FALSE;
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
if (!glamor_set_alu(screen, gc->alu)) {
if (gc->alu == GXclear)
fg_pixel = 0;
else {
glamor_fallback("unsupported alu %x\n", gc->alu);
glamor_put_context(glamor_priv);
return FALSE;
}
}
if (!glamor_set_planemask(pixmap, gc->planemask)) {
glamor_fallback("Failed to set planemask in %s.\n", __FUNCTION__);
glamor_put_context(glamor_priv);
return FALSE;
}
......@@ -281,8 +277,6 @@ glamor_push_pixels_points(GCPtr gc, PixmapPtr bitmap,
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
glamor_put_context(glamor_priv);
return TRUE;
}
......
......@@ -1285,9 +1285,8 @@ glamor_buffer_glyph(glamor_screen_private *glamor_priv,
* thus we have to composite from the cache picture
* to the cache picture, we need a flush here to make
* sure latter we get the corret glyphs data.*/
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
glFlush();
glamor_put_context(glamor_priv);
}
}
else {
......
......@@ -324,7 +324,7 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count,
return;
}
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
if (dyn_gen && glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][2]) {
glDeleteProgram(glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][2]);
......@@ -371,8 +371,6 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count,
}
glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][index] = gradient_prog;
glamor_put_context(glamor_priv);
}
static void
......@@ -519,7 +517,7 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count,
return;
}
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
if (dyn_gen && glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][2]) {
glDeleteProgram(glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][2]);
glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][2] = 0;
......@@ -562,8 +560,6 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count,
}
glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][index] = gradient_prog;
glamor_put_context(glamor_priv);
}
void
......@@ -595,7 +591,7 @@ glamor_fini_gradient_shader(ScreenPtr screen)
int i = 0;
glamor_priv = glamor_get_screen_private(screen);
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
for (i = 0; i < 3; i++) {
/* Linear Gradient */
......@@ -607,8 +603,6 @@ glamor_fini_gradient_shader(ScreenPtr screen)
glDeleteProgram(glamor_priv->gradient_prog
[SHADER_GRADIENT_RADIAL][i]);
}
glamor_put_context(glamor_priv);
}
static void
......@@ -739,7 +733,7 @@ _glamor_gradient_set_pixmap_destination(ScreenPtr screen,
tex_vertices[0], tex_vertices[1], tex_vertices[2], tex_vertices[3],
tex_vertices[4], tex_vertices[5], tex_vertices[6], tex_vertices[7]);
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
GL_FALSE, 0, vertices);
......@@ -749,8 +743,6 @@ _glamor_gradient_set_pixmap_destination(ScreenPtr screen,
glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
glamor_put_context(glamor_priv);
return 1;
}
......@@ -892,7 +884,7 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
GLint r2_uniform_location = 0;
glamor_priv = glamor_get_screen_private(screen);
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
/* Create a pixmap with VBO. */
pixmap = glamor_create_pixmap(screen,
......@@ -1123,7 +1115,6 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
glamor_put_context(glamor_priv);
return dst_picture;
GRADIENT_FAIL:
......@@ -1140,7 +1131,6 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
glamor_put_context(glamor_priv);
return NULL;
}
......@@ -1204,7 +1194,7 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
GLint pt_distance_uniform_location = 0;
glamor_priv = glamor_get_screen_private(screen);
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
/* Create a pixmap with VBO. */
pixmap = glamor_create_pixmap(screen,
......@@ -1468,7 +1458,6 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
glamor_put_context(glamor_priv);
return dst_picture;
GRADIENT_FAIL:
......@@ -1485,7 +1474,6 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
glamor_put_context(glamor_priv);
return NULL;
}
......
......@@ -66,12 +66,10 @@ void
glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo *fbo, int x0, int y0,
int width, int height)
{
glamor_get_context(fbo->glamor_priv);
glamor_make_current(fbo->glamor_priv);
glBindFramebuffer(GL_FRAMEBUFFER, fbo->fb);
glViewport(x0, y0, width, height);
glamor_put_context(fbo->glamor_priv);
}
void
......@@ -707,7 +705,7 @@ __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, unsigned int *tex,
int non_sub = 0;
unsigned int iformat = 0;
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
if (*tex == 0) {
glGenTextures(1, tex);
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
......@@ -735,7 +733,6 @@ __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, unsigned int *tex,
if (bits == NULL)
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
glamor_put_context(glamor_priv);
}
static Bool
......@@ -832,7 +829,7 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format,
x + w, y + h,
glamor_priv->yInverted, vertices);
/* Slow path, we need to flip y or wire alpha to 1. */
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
GL_FALSE, 2 * sizeof(float), vertices);
glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
......@@ -859,8 +856,6 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format,
glDeleteTextures(1, &tex);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glamor_put_context(glamor_priv);
if (need_free_bits)
free(bits);
return TRUE;
......@@ -1140,7 +1135,7 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h,
if (temp_fbo == NULL)
return NULL;
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
temp_xscale = 1.0 / w;
temp_yscale = 1.0 / h;
......@@ -1177,7 +1172,6 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h,
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
glamor_put_context(glamor_priv);
return temp_fbo;
}
......@@ -1255,7 +1249,7 @@ _glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, GLenum format,
fbo_y_off = 0;
}
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
glPixelStorei(GL_PACK_ALIGNMENT, 4);
if (glamor_priv->has_pack_invert || glamor_priv->yInverted) {
......@@ -1286,7 +1280,7 @@ _glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, GLenum format,
unsigned int temp_pbo;
int yy;
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
glGenBuffers(1, &temp_pbo);
glBindBuffer(GL_PIXEL_PACK_BUFFER, temp_pbo);
glBufferData(GL_PIXEL_PACK_BUFFER, stride * h, NULL, GL_STREAM_READ);
......@@ -1301,7 +1295,6 @@ _glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, GLenum format,
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glamor_put_context(glamor_priv);
if (need_post_conversion) {
/* As OpenGL desktop version never enters here.
......@@ -1473,10 +1466,9 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
data = malloc(stride * pixmap->drawable.height);
}
else {
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
if (pixmap_priv->base.fbo->pbo == 0)
glGenBuffers(1, &pixmap_priv->base.fbo->pbo);
glamor_put_context(glamor_priv);
pbo = pixmap_priv->base.fbo->pbo;
}
......
......@@ -52,7 +52,7 @@ glamor_poly_point_gl(DrawablePtr drawable, GCPtr gc, int mode, int npt, DDXPoint
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
goto bail;
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
if (prog->failed)
goto bail_ctx;
......@@ -105,8 +105,6 @@ glamor_poly_point_gl(DrawablePtr drawable, GCPtr gc, int mode, int npt, DDXPoint
glDisable(GL_COLOR_LOGIC_OP);
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
glamor_put_context(glamor_priv);
glamor_priv->state = RENDER_STATE;
glamor_priv->render_idle_cnt = 0;
......@@ -114,7 +112,6 @@ glamor_poly_point_gl(DrawablePtr drawable, GCPtr gc, int mode, int npt, DDXPoint
bail_ctx:
glDisable(GL_COLOR_LOGIC_OP);
glamor_put_context(glamor_priv);
bail:
return FALSE;
}
......
......@@ -57,7 +57,7 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
goto bail;
glamor_get_context(glamor_priv);
glamor_make_current(glamor_priv);
if (glamor_priv->glsl_version >= 130) {
prog = glamor_use_program_fill(pixmap, gc,
......@@ -144,11 +144,9 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
glVertexAttribDivisor(GLAMOR_VERTEX_POS, 0);
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
glamor_put_context(glamor_priv);
return TRUE;
bail_ctx:
glDisable(GL_COLOR_LOGIC_OP);
glamor_put_context(glamor_priv);
bail:
return FALSE;
}
......
......@@ -316,13 +316,13 @@ glamor_create_composite_shader(ScreenPtr screen, struct shader_key *key,
GLint source_sampler_uniform_location, mask_sampler_uniform_location;
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
glamor_get_context(glamor_priv);