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) ...@@ -248,11 +248,10 @@ glamor_block_handler(ScreenPtr screen)
{ {
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
glamor_get_context(glamor_priv); glamor_make_current(glamor_priv);
glamor_priv->tick++; glamor_priv->tick++;
glFlush(); glFlush();
glamor_fbo_expire(glamor_priv); glamor_fbo_expire(glamor_priv);
glamor_put_context(glamor_priv);
if (glamor_priv->state == RENDER_STATE if (glamor_priv->state == RENDER_STATE
&& glamor_priv->render_idle_cnt++ > RENDER_IDEL_MAX) { && glamor_priv->render_idle_cnt++ > RENDER_IDEL_MAX) {
glamor_priv->state = IDLE_STATE; glamor_priv->state = IDLE_STATE;
...@@ -265,9 +264,8 @@ _glamor_block_handler(void *data, OSTimePtr timeout, void *last_select_mask) ...@@ -265,9 +264,8 @@ _glamor_block_handler(void *data, OSTimePtr timeout, void *last_select_mask)
{ {
glamor_screen_private *glamor_priv = data; glamor_screen_private *glamor_priv = data;
glamor_get_context(glamor_priv); glamor_make_current(glamor_priv);
glFlush(); glFlush();
glamor_put_context(glamor_priv);
} }
static void static void
......
...@@ -43,14 +43,7 @@ struct glamor_context { ...@@ -43,14 +43,7 @@ struct glamor_context {
/** The GLXDrawable we should MakeCurrent to */ /** The GLXDrawable we should MakeCurrent to */
uint32_t drawable_xid; uint32_t drawable_xid;
/** void (*make_current)(struct glamor_context *glamor_ctx);
* 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);
}; };
Bool glamor_glx_screen_init(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, ...@@ -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(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); 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); 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(dst, dst_pixmap, &dst_x_off, &dst_y_off);
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_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, ...@@ -112,7 +112,6 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
GL_COLOR_BUFFER_BIT, GL_NEAREST); GL_COLOR_BUFFER_BIT, GL_NEAREST);
} }
} }
glamor_put_context(glamor_priv);
glamor_priv->state = BLIT_STATE; glamor_priv->state = BLIT_STATE;
return TRUE; return TRUE;
} }
...@@ -155,7 +154,7 @@ glamor_copy_n_to_n_textured(DrawablePtr src, ...@@ -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_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); glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
...@@ -206,7 +205,6 @@ glamor_copy_n_to_n_textured(DrawablePtr src, ...@@ -206,7 +205,6 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
glDisableVertexAttribArray(GLAMOR_VERTEX_POS); glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE); glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
/* The source texture is bound to a fbo, we have to flush it here. */ /* 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->state = RENDER_STATE;
glamor_priv->render_idle_cnt = 0; glamor_priv->render_idle_cnt = 0;
return TRUE; return TRUE;
...@@ -367,12 +365,10 @@ _glamor_copy_n_to_n(DrawablePtr src, ...@@ -367,12 +365,10 @@ _glamor_copy_n_to_n(DrawablePtr src,
if (gc) { if (gc) {
if (!glamor_set_planemask(dst_pixmap, gc->planemask)) if (!glamor_set_planemask(dst_pixmap, gc->planemask))
goto fall_back; goto fall_back;
glamor_get_context(glamor_priv); glamor_make_current(glamor_priv);
if (!glamor_set_alu(screen, gc->alu)) { if (!glamor_set_alu(screen, gc->alu)) {
glamor_put_context(glamor_priv);
goto fail; goto fail;
} }
glamor_put_context(glamor_priv);
} }
if (!src_pixmap_priv) { if (!src_pixmap_priv) {
...@@ -545,9 +541,8 @@ _glamor_copy_n_to_n(DrawablePtr src, ...@@ -545,9 +541,8 @@ _glamor_copy_n_to_n(DrawablePtr src,
} }
fail: fail:
glamor_get_context(glamor_priv); glamor_make_current(glamor_priv);
glamor_set_alu(screen, GXcopy); glamor_set_alu(screen, GXcopy);
glamor_put_context(glamor_priv);
if (ok) if (ok)
return TRUE; return TRUE;
......
...@@ -241,7 +241,7 @@ glamor_init_finish_access_shaders(ScreenPtr screen) ...@@ -241,7 +241,7 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
char *source; char *source;
glamor_priv = glamor_get_screen_private(screen); 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[0] = glCreateProgram();
glamor_priv->finish_access_prog[1] = glCreateProgram(); glamor_priv->finish_access_prog[1] = glCreateProgram();
...@@ -300,7 +300,6 @@ glamor_init_finish_access_shaders(ScreenPtr screen) ...@@ -300,7 +300,6 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
glUniform1i(glamor_priv->finish_access_revert[1], 0); glUniform1i(glamor_priv->finish_access_revert[1], 0);
glUniform1i(sampler_uniform_location, 0); glUniform1i(sampler_uniform_location, 0);
glUniform1i(glamor_priv->finish_access_swap_rb[1], 0); glUniform1i(glamor_priv->finish_access_swap_rb[1], 0);
glamor_put_context(glamor_priv);
} }
void void
...@@ -309,10 +308,9 @@ glamor_fini_finish_access_shaders(ScreenPtr screen) ...@@ -309,10 +308,9 @@ glamor_fini_finish_access_shaders(ScreenPtr screen)
glamor_screen_private *glamor_priv; glamor_screen_private *glamor_priv;
glamor_priv = glamor_get_screen_private(screen); 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[0]);
glDeleteProgram(glamor_priv->finish_access_prog[1]); glDeleteProgram(glamor_priv->finish_access_prog[1]);
glamor_put_context(glamor_priv);
} }
void void
...@@ -341,11 +339,10 @@ glamor_finish_access(DrawablePtr drawable) ...@@ -341,11 +339,10 @@ glamor_finish_access(DrawablePtr drawable)
if (pixmap_priv->base.fbo->pbo != 0 && pixmap_priv->base.fbo->pbo_valid) { if (pixmap_priv->base.fbo->pbo != 0 && pixmap_priv->base.fbo->pbo_valid) {
assert(glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP); 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_PACK_BUFFER, 0);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
glDeleteBuffers(1, &pixmap_priv->base.fbo->pbo); glDeleteBuffers(1, &pixmap_priv->base.fbo->pbo);
glamor_put_context(glamor_priv);
pixmap_priv->base.fbo->pbo_valid = FALSE; pixmap_priv->base.fbo->pbo_valid = FALSE;
pixmap_priv->base.fbo->pbo = 0; pixmap_priv->base.fbo->pbo = 0;
......
...@@ -95,11 +95,8 @@ glamor_egl_get_screen_private(ScrnInfoPtr scrn) ...@@ -95,11 +95,8 @@ glamor_egl_get_screen_private(ScrnInfoPtr scrn)
} }
static void 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, eglMakeCurrent(glamor_ctx->display, EGL_NO_SURFACE,
EGL_NO_SURFACE, EGL_NO_CONTEXT); EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (!eglMakeCurrent(glamor_ctx->display, if (!eglMakeCurrent(glamor_ctx->display,
...@@ -109,12 +106,6 @@ glamor_egl_get_context(struct glamor_context *glamor_ctx) ...@@ -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 static EGLImageKHR
_glamor_egl_create_image(struct glamor_egl_screen_private *glamor_egl, _glamor_egl_create_image(struct glamor_egl_screen_private *glamor_egl,
int width, int height, int stride, int name, int depth) int width, int height, int stride, int name, int depth)
...@@ -166,7 +157,7 @@ glamor_create_texture_from_image(ScreenPtr screen, ...@@ -166,7 +157,7 @@ glamor_create_texture_from_image(ScreenPtr screen,
struct glamor_screen_private *glamor_priv = struct glamor_screen_private *glamor_priv =
glamor_get_screen_private(screen); glamor_get_screen_private(screen);
glamor_get_context(glamor_priv); glamor_make_current(glamor_priv);
glGenTextures(1, texture); glGenTextures(1, texture);
glBindTexture(GL_TEXTURE_2D, *texture); glBindTexture(GL_TEXTURE_2D, *texture);
...@@ -176,8 +167,6 @@ glamor_create_texture_from_image(ScreenPtr screen, ...@@ -176,8 +167,6 @@ glamor_create_texture_from_image(ScreenPtr screen,
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
glamor_put_context(glamor_priv);
return TRUE; return TRUE;
} }
...@@ -290,7 +279,7 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride) ...@@ -290,7 +279,7 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
glamor_egl = glamor_egl_get_screen_private(scrn); 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_egl->has_gem) {
if (!glamor_get_flink_name(glamor_egl->fd, handle, &name)) { if (!glamor_get_flink_name(glamor_egl->fd, handle, &name)) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR, xf86DrvMsg(scrn->scrnIndex, X_ERROR,
...@@ -320,7 +309,6 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride) ...@@ -320,7 +309,6 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
ret = TRUE; ret = TRUE;
done: done:
glamor_put_context(glamor_priv);
return ret; return ret;
} }
...@@ -340,7 +328,7 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo) ...@@ -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_egl = glamor_egl_get_screen_private(scrn);
glamor_get_context(glamor_priv); glamor_make_current(glamor_priv);
image = eglCreateImageKHR(glamor_egl->display, image = eglCreateImageKHR(glamor_egl->display,
glamor_egl->context, glamor_egl->context,
...@@ -356,7 +344,6 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo) ...@@ -356,7 +344,6 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo)
ret = TRUE; ret = TRUE;
done: done:
glamor_put_context(glamor_priv);
return ret; return ret;
} }
...@@ -414,7 +401,7 @@ glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen, ...@@ -414,7 +401,7 @@ glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
glamor_egl = glamor_egl_get_screen_private(scrn); glamor_egl = glamor_egl_get_screen_private(scrn);
glamor_get_context(glamor_priv); glamor_make_current(glamor_priv);
image = pixmap_priv->base.image; image = pixmap_priv->base.image;
if (!image) { if (!image) {
...@@ -449,7 +436,6 @@ glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen, ...@@ -449,7 +436,6 @@ glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
gbm_bo_destroy(bo); gbm_bo_destroy(bo);
failure: failure:
glamor_put_context(glamor_priv);
return fd; return fd;
#else #else
return -1; return -1;
...@@ -679,8 +665,7 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx) ...@@ -679,8 +665,7 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
glamor_ctx->ctx = glamor_egl->context; glamor_ctx->ctx = glamor_egl->context;
glamor_ctx->display = glamor_egl->display; glamor_ctx->display = glamor_egl->display;
glamor_ctx->get_context = glamor_egl_get_context; glamor_ctx->make_current = glamor_egl_make_current;
glamor_ctx->put_context = glamor_egl_put_context;
if (glamor_egl->dri3_capable) { if (glamor_egl->dri3_capable) {
/* Tell the core that we have the interfaces for import/export /* 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, ...@@ -129,7 +129,7 @@ glamor_pixmap_fbo_cache_get(glamor_screen_private *glamor_priv,
void void
glamor_purge_fbo(glamor_pixmap_fbo *fbo) glamor_purge_fbo(glamor_pixmap_fbo *fbo)
{ {
glamor_get_context(fbo->glamor_priv); glamor_make_current(fbo->glamor_priv);
if (fbo->fb) if (fbo->fb)
glDeleteFramebuffers(1, &fbo->fb); glDeleteFramebuffers(1, &fbo->fb);
...@@ -137,7 +137,6 @@ glamor_purge_fbo(glamor_pixmap_fbo *fbo) ...@@ -137,7 +137,6 @@ glamor_purge_fbo(glamor_pixmap_fbo *fbo)
glDeleteTextures(1, &fbo->tex); glDeleteTextures(1, &fbo->tex);
if (fbo->pbo) if (fbo->pbo)
glDeleteBuffers(1, &fbo->pbo); glDeleteBuffers(1, &fbo->pbo);
glamor_put_context(fbo->glamor_priv);
free(fbo); free(fbo);
} }
...@@ -180,7 +179,7 @@ glamor_pixmap_ensure_fb(glamor_pixmap_fbo *fbo) ...@@ -180,7 +179,7 @@ glamor_pixmap_ensure_fb(glamor_pixmap_fbo *fbo)
{ {
int status; int status;
glamor_get_context(fbo->glamor_priv); glamor_make_current(fbo->glamor_priv);
if (fbo->fb == 0) if (fbo->fb == 0)
glGenFramebuffers(1, &fbo->fb); glGenFramebuffers(1, &fbo->fb);
...@@ -219,7 +218,6 @@ glamor_pixmap_ensure_fb(glamor_pixmap_fbo *fbo) ...@@ -219,7 +218,6 @@ glamor_pixmap_ensure_fb(glamor_pixmap_fbo *fbo)
FatalError("destination is framebuffer incomplete: %s [%x]\n", FatalError("destination is framebuffer incomplete: %s [%x]\n",
str, status); str, status);
} }
glamor_put_context(fbo->glamor_priv);
} }
glamor_pixmap_fbo * glamor_pixmap_fbo *
...@@ -241,9 +239,8 @@ glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv, ...@@ -241,9 +239,8 @@ glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv,
fbo->glamor_priv = glamor_priv; fbo->glamor_priv = glamor_priv;
if (flag == GLAMOR_CREATE_PIXMAP_MAP) { if (flag == GLAMOR_CREATE_PIXMAP_MAP) {
glamor_get_context(glamor_priv); glamor_make_current(glamor_priv);
glGenBuffers(1, &fbo->pbo); glGenBuffers(1, &fbo->pbo);
glamor_put_context(glamor_priv);
goto done; goto done;
} }
...@@ -341,14 +338,13 @@ _glamor_create_tex(glamor_screen_private *glamor_priv, ...@@ -341,14 +338,13 @@ _glamor_create_tex(glamor_screen_private *glamor_priv,
w, h); w, h);
} }
if (!tex) { if (!tex) {
glamor_get_context(glamor_priv); glamor_make_current(glamor_priv);
glGenTextures(1, &tex); glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex); glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0, glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0,
format, GL_UNSIGNED_BYTE, NULL); format, GL_UNSIGNED_BYTE, NULL);
glamor_put_context(glamor_priv);
} }
return tex; return tex;
} }
......
...@@ -156,7 +156,7 @@ glamor_init_solid_shader(ScreenPtr screen) ...@@ -156,7 +156,7 @@ glamor_init_solid_shader(ScreenPtr screen)
GLint fs_prog, vs_prog; GLint fs_prog, vs_prog;
glamor_priv = glamor_get_screen_private(screen); glamor_priv = glamor_get_screen_private(screen);
glamor_get_context(glamor_priv); glamor_make_current(glamor_priv);
glamor_priv->solid_prog = glCreateProgram(); glamor_priv->solid_prog = glCreateProgram();
vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, solid_vs); vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, solid_vs);
fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, solid_fs); fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, solid_fs);
...@@ -169,7 +169,6 @@ glamor_init_solid_shader(ScreenPtr screen) ...@@ -169,7 +169,6 @@ glamor_init_solid_shader(ScreenPtr screen)
glamor_priv->solid_color_uniform_location = glamor_priv->solid_color_uniform_location =
glGetUniformLocation(glamor_priv->solid_prog, "color"); glGetUniformLocation(glamor_priv->solid_prog, "color");
glamor_put_context(glamor_priv);
} }
void void
...@@ -178,9 +177,8 @@ glamor_fini_solid_shader(ScreenPtr screen) ...@@ -178,9 +177,8 @@ glamor_fini_solid_shader(ScreenPtr screen)
glamor_screen_private *glamor_priv; glamor_screen_private *glamor_priv;
glamor_priv = glamor_get_screen_private(screen); glamor_priv = glamor_get_screen_private(screen);
glamor_get_context(glamor_priv); glamor_make_current(glamor_priv);
glDeleteProgram(glamor_priv->solid_prog); glDeleteProgram(glamor_priv->solid_prog);
glamor_put_context(glamor_priv);
} }
static void static void
...@@ -196,7 +194,7 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color) ...@@ -196,7 +194,7 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
glamor_set_destination_pixmap_priv_nc(pixmap_priv); glamor_set_destination_pixmap_priv_nc(pixmap_priv);
glamor_get_context(glamor_priv); glamor_make_current(glamor_priv);
glUseProgram(glamor_priv->solid_prog); glUseProgram(glamor_priv->solid_prog);
glUniform4fv(glamor_priv->solid_color_uniform_location, 1, color); glUniform4fv(glamor_priv->solid_color_uniform_location, 1, color);
...@@ -255,7 +253,6 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color) ...@@ -255,7 +253,6 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
free(vertices); free(vertices);
glDisableVertexAttribArray(GLAMOR_VERTEX_POS); glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
glamor_put_context(glamor_priv);
glamor_priv->state = RENDER_STATE; glamor_priv->state = RENDER_STATE;
glamor_priv->render_idle_cnt = 0; glamor_priv->render_idle_cnt = 0;
} }
...@@ -338,13 +335,12 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height, ...@@ -338,13 +335,12 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
return FALSE; return FALSE;
} }
glamor_get_context(glamor_priv); glamor_make_current(glamor_priv);
if (!glamor_set_alu(screen, alu)) { if (!glamor_set_alu(screen, alu)) {
if (alu == GXclear) if (alu == GXclear)
fg_pixel = 0; fg_pixel = 0;
else { else {
glamor_fallback("unsupported alu %x\n", alu); glamor_fallback("unsupported alu %x\n", alu);
glamor_put_context(glamor_priv);
return FALSE; return FALSE;
} }
} }
...@@ -355,7 +351,6 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height, ...@@ -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_solid_boxes(pixmap, &box, 1, fg_pixel);
glamor_set_alu(screen, GXcopy); glamor_set_alu(screen, GXcopy);
glamor_put_context(glamor_priv);
return TRUE; return TRUE;
} }
...@@ -89,7 +89,7 @@ glamor_font_get(ScreenPtr screen, FontPtr font) ...@@ -89,7 +89,7 @@ glamor_font_get(ScreenPtr screen, FontPtr font)
glamor_font->default_col = font->info.defaultCh; glamor_font->default_col = font->info.defaultCh;
glamor_priv = glamor_get_screen_private(screen); glamor_priv = glamor_get_screen_private(screen);
glamor_get_context(glamor_priv); glamor_make_current(glamor_priv);
glGenTextures(1, &glamor_font->texture_id); glGenTextures(1, &glamor_font->texture_id);
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
...@@ -119,8 +119,6 @@ glamor_font_get(ScreenPtr screen, FontPtr font) ...@@ -119,8 +119,6 @@ glamor_font_get(ScreenPtr screen, FontPtr font)
} }
} }
glamor_put_context(glamor_priv);
return glamor_font; return glamor_font;
} }
...@@ -150,9 +148,8 @@ glamor_unrealize_font(ScreenPtr screen, FontPtr font) ...@@ -150,9 +148,8 @@ glamor_unrealize_font(ScreenPtr screen, FontPtr font)
glamor_font->realized = FALSE; glamor_font->realized = FALSE;
glamor_priv = glamor_get_screen_private(screen); glamor_priv = glamor_get_screen_private(screen);
glamor_get_context(glamor_priv); glamor_make_current(glamor_priv);
glDeleteTextures(1, &glamor_font->texture_id); glDeleteTextures(1, &glamor_font->texture_id);
glamor_put_context(glamor_priv);
/* Check to see if all of the screens are done with this font /* Check to see if all of the screens are done with this font
* and free the private when that happens * and free the private when that happens
......
...@@ -34,22 +34,13 @@ ...@@ -34,22 +34,13 @@
*/ */
static void 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, glXMakeCurrent(glamor_ctx->display, glamor_ctx->drawable_xid,
glamor_ctx->ctx); glamor_ctx->ctx);
} }
static void
glamor_glx_put_context(struct glamor_context *glamor_ctx)
{
--glamor_ctx->get_count;
}
Bool Bool
glamor_glx_screen_init(struct glamor_context *glamor_ctx) glamor_glx_screen_init(struct glamor_context *glamor_ctx)
{ {
...@@ -63,8 +54,7 @@ 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->drawable_xid = glXGetCurrentDrawable();
glamor_ctx->get_context = glamor_glx_get_context; glamor_ctx->make_current = glamor_glx_make_current;
glamor_ctx->put_context = glamor_glx_put_context;
return True; return True;
} }
...@@ -54,7 +54,7 @@ glamor_poly_glyph_blt_gl(DrawablePtr drawable, GCPtr gc, ...@@ -54,7 +54,7 @@ glamor_poly_glyph_blt_gl(DrawablePtr drawable, GCPtr gc,
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
goto bail; 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, prog = glamor_use_program_fill(pixmap, gc, &glamor_priv->poly_glyph_blt_progs,
&glamor_facet_poly_glyph_blt); &glamor_facet_poly_glyph_blt);
...@@ -137,11 +137,9 @@ glamor_poly_glyph_blt_gl(DrawablePtr drawable, GCPtr gc, ...@@ -137,11 +137,9 @@ glamor_poly_glyph_blt_gl(DrawablePtr drawable, GCPtr gc,
glDisable(GL_COLOR_LOGIC_OP); glDisable(GL_COLOR_LOGIC_OP);
glDisableVertexAttribArray(GLAMOR_VERTEX_POS); glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
glamor_put_context(glamor_priv);
return TRUE; return TRUE;
bail_ctx: bail_ctx:
glDisable(GL_COLOR_LOGIC_OP); glDisable(GL_COLOR_LOGIC_OP);
glamor_put_context(glamor_priv);
bail: bail:
return FALSE; return FALSE;
} }
...@@ -212,20 +210,18 @@ glamor_push_pixels_points(GCPtr gc, PixmapPtr bitmap, ...@@ -212,20 +210,18 @@ glamor_push_pixels_points(GCPtr gc, PixmapPtr bitmap,
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
return FALSE; return FALSE;
glamor_get_context(glamor_priv); glamor_make_current(glamor_priv);
if (!glamor_set_alu(screen, gc->alu)) { if (!glamor_set_alu(screen, gc->alu)) {
if (gc->alu == GXclear) if (gc->alu == GXclear)
fg_pixel = 0; fg_pixel = 0;
else { else {
glamor_fallback("unsupported alu %x\n", gc->alu); glamor_fallback("unsupported alu %x\n", gc->alu);
glamor_put_context(glamor_priv);
return FALSE; return FALSE;
} }
} }
if (!glamor_set_planemask(pixmap, gc->planemask)) { if (!glamor_set_planemask(pixmap, gc->planemask)) {
glamor_fallback("Failed to set planemask in %s.\n", __FUNCTION__); glamor_fallback("Failed to set planemask in %s.\n", __FUNCTION__);
glamor_put_context(glamor_priv);
return FALSE; return FALSE;
} }
...@@ -281,8 +277,6 @@ glamor_push_pixels_points(GCPtr gc, PixmapPtr bitmap, ...@@ -281,8 +277,6 @@ glamor_push_pixels_points(GCPtr gc, PixmapPtr bitmap,
glDisableVertexAttribArray(GLAMOR_VERTEX_POS); glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
glamor_put_context(glamor_priv);
return TRUE; return TRUE;
} }
......
...@@ -1285,9 +1285,8 @@ glamor_buffer_glyph(glamor_screen_private *glamor_priv, ...@@ -1285,9 +1285,8 @@ glamor_buffer_glyph(glamor_screen_private *glamor_priv,
* thus we have to composite from the cache picture * thus we have to composite from the cache picture
* to the cache picture, we need a flush here to make * to the cache picture, we need a flush here to make
* sure latter we get the corret glyphs data.*/ * sure latter we get the corret glyphs data.*/
glamor_get_context(glamor_priv); glamor_make_current(glamor_priv);
glFlush(); glFlush();
glamor_put_context(glamor_priv);
} }
} }
else {