Commit 556adfa6 authored by Chris Wilson's avatar Chris Wilson 🤔 Committed by Eric Anholt

Fixup glx support

Renaming glamor_priv->dispatch and wrapping the access to
the dispatch table with a function that also ensured the
context was bound.

 dispatch = glamor_get_dispatch(glamor_priv);
 ...
 glamor_put_dispatch(glamor_priv);

So that we catch all places where we attempt to call into GL withouta
context. As an optimisation we can then do glamor_get_context();
glamor_put_context() around the rendering entry points to reduce the
frequency of having to restore the old context. (Along with allowing
the context to be recursively acquired and making the old context part of
the glamor_egl state.)
Reviewed-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
parent 430bc16c
......@@ -196,24 +196,25 @@ glamor_block_handler(ScreenPtr screen)
{
glamor_screen_private *glamor_priv =
glamor_get_screen_private(screen);
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
GLAMOR_DEFINE_CONTEXT;
glamor_gl_dispatch *dispatch;
GLAMOR_SET_CONTEXT(glamor_priv);
dispatch = glamor_get_dispatch(glamor_priv);
glamor_priv->tick++;
dispatch->glFlush();
dispatch->glFinish();
glamor_fbo_expire(glamor_priv);
GLAMOR_RESTORE_CONTEXT(glamor_priv);
glamor_put_dispatch(glamor_priv);
}
static void
_glamor_block_handler(void *data, OSTimePtr timeout,
void *last_select_mask)
{
glamor_gl_dispatch *dispatch = data;
glamor_screen_private *glamor_priv = data;
glamor_gl_dispatch *dispatch = glamor_get_dispatch(glamor_priv);
dispatch->glFlush();
dispatch->glFinish();
glamor_put_dispatch(glamor_priv);
}
static void
......@@ -289,8 +290,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
}
#endif
glamor_gl_dispatch_init(screen, &glamor_priv->dispatch,
gl_version);
glamor_gl_dispatch_init(screen, &glamor_priv->_dispatch, gl_version);
#ifdef GLAMOR_GLES2
if (!glamor_gl_has_extension("GL_EXT_texture_format_BGRA8888")) {
......@@ -303,7 +303,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
glamor_gl_has_extension("GL_MESA_pack_invert");
glamor_priv->has_fbo_blit =
glamor_gl_has_extension("GL_EXT_framebuffer_blit");
glamor_priv->dispatch.glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE,
glamor_priv->_dispatch.glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE,
&glamor_priv->max_fbo_size);
glamor_set_debug_level(&glamor_debug_level);
......@@ -324,8 +324,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
if (flags & GLAMOR_USE_SCREEN) {
if (!RegisterBlockAndWakeupHandlers(_glamor_block_handler,
_glamor_wakeup_handler,
(void *)
&glamor_priv->dispatch)) {
glamor_priv)) {
goto fail;
}
......
......@@ -28,18 +28,16 @@
#ifndef GLAMOR_H
#define GLAMOR_H
#include "scrnintstr.h"
#include <scrnintstr.h>
#ifdef GLAMOR_FOR_XORG
#include "xf86str.h"
#include <xf86str.h>
#endif
#include "pixmapstr.h"
#include "windowstr.h"
#include "gcstruct.h"
#include "picturestr.h"
#include "fb.h"
#include "fbpict.h"
#endif /* GLAMOR_H */
#include <pixmapstr.h>
#include <windowstr.h>
#include <gcstruct.h>
#include <picturestr.h>
#include <fb.h>
#include <fbpict.h>
/*
* glamor_pixmap_type : glamor pixmap's type.
......@@ -145,9 +143,8 @@ extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h,
extern _X_EXPORT void glamor_egl_screen_init(ScreenPtr screen);
extern _X_EXPORT void * glamor_egl_make_current(ScreenPtr screen);
extern _X_EXPORT void glamor_egl_restore_context(ScreenPtr screen, void *context);
extern _X_EXPORT void glamor_egl_make_current(ScreenPtr screen);
extern _X_EXPORT void glamor_egl_restore_context(ScreenPtr screen);
#ifdef GLAMOR_FOR_XORG
......@@ -320,3 +317,4 @@ extern _X_EXPORT Bool glamor_poly_line_nf(DrawablePtr pDrawable, GCPtr pGC, int
extern _X_EXPORT Bool glamor_poly_lines_nf(DrawablePtr drawable, GCPtr gc, int mode, int n,
DDXPointPtr points);
#endif /* GLAMOR_H */
......@@ -26,10 +26,6 @@
*
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "glamor_priv.h"
static Bool
......
......@@ -21,10 +21,6 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "glamor_priv.h"
/** @file glamor_copyarea.c
......@@ -43,7 +39,7 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
glamor_pixmap_private *src_pixmap_priv;
glamor_screen_private *glamor_priv =
glamor_get_screen_private(screen);
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
glamor_gl_dispatch *dispatch;
int dst_x_off, dst_y_off, src_x_off, src_y_off, i;
if (!glamor_priv->has_fbo_blit) {
......@@ -78,6 +74,7 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
}
glamor_validate_pixmap(dst_pixmap);
dispatch = glamor_get_dispatch(glamor_priv);
dispatch->glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT,
src_pixmap_priv->fbo->fb);
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off,
......@@ -136,6 +133,7 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
GL_NEAREST);
}
}
glamor_put_dispatch(glamor_priv);
return TRUE;
}
#endif
......@@ -147,7 +145,7 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
{
glamor_screen_private *glamor_priv =
glamor_get_screen_private(dst->pScreen);
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
glamor_gl_dispatch *dispatch;
PixmapPtr src_pixmap = glamor_get_drawable_pixmap(src);
PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(dst);
int i;
......@@ -158,23 +156,24 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
enum glamor_pixmap_status src_status = GLAMOR_NONE;
GLfloat dst_xscale, dst_yscale, src_xscale, src_yscale;
int flush_needed = 0;
int alu = GXcopy;
src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
dst_pixmap_priv = glamor_get_pixmap_private(dst_pixmap);
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dst_pixmap_priv)) {
glamor_delayed_fallback(dst->pScreen, "dst has no fbo.\n");
goto fail;
return FALSE;
}
if (!src_pixmap_priv || !src_pixmap_priv->gl_fbo) {
#ifndef GLAMOR_PIXMAP_DYNAMIC_UPLOAD
glamor_delayed_fallback(dst->pScreen, "src has no fbo.\n");
goto fail;
return FALSE;
#else
src_status = glamor_upload_pixmap_to_texture(src_pixmap);
if (src_status != GLAMOR_UPLOAD_DONE)
goto fail;
return FALSE;
src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
#endif
......@@ -182,25 +181,26 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
flush_needed = 1;
if (gc) {
glamor_set_alu(dispatch, gc->alu);
if (!glamor_set_planemask(dst_pixmap, gc->planemask))
goto fail;
if (gc->alu != GXcopy) {
glamor_set_destination_pixmap_priv_nc
(src_pixmap_priv);
glamor_validate_pixmap(src_pixmap);
}
return FALSE;
alu = gc->alu;
}
glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
glamor_validate_pixmap(dst_pixmap);
pixmap_priv_get_scale(dst_pixmap_priv, &dst_xscale, &dst_yscale);
pixmap_priv_get_scale(src_pixmap_priv, &src_xscale, &src_yscale);
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off,
&dst_y_off);
dispatch = glamor_get_dispatch(glamor_priv);
glamor_set_alu(dispatch, alu);
if (alu != GXcopy) {
glamor_set_destination_pixmap_priv_nc (src_pixmap_priv);
glamor_validate_pixmap(src_pixmap);
}
glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
glamor_validate_pixmap(dst_pixmap);
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
GL_FALSE, 2 * sizeof(float),
vertices);
......@@ -284,12 +284,8 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
/* The source texture is bound to a fbo, we have to flush it here. */
if (flush_needed)
dispatch->glFlush();
glamor_put_dispatch(glamor_priv);
return TRUE;
fail:
glamor_set_alu(dispatch, GXcopy);
glamor_set_planemask(dst_pixmap, ~0);
return FALSE;
}
static Bool
......@@ -317,7 +313,6 @@ _glamor_copy_n_to_n(DrawablePtr src,
int i;
int overlaped = 0;
Bool ret = FALSE;
GLAMOR_DEFINE_CONTEXT;
dst_pixmap = glamor_get_drawable_pixmap(dst);
dst_pixmap_priv = glamor_get_pixmap_private(dst_pixmap);
......@@ -326,7 +321,6 @@ _glamor_copy_n_to_n(DrawablePtr src,
screen = dst_pixmap->drawable.pScreen;
glamor_priv = glamor_get_screen_private(dst->pScreen);
GLAMOR_SET_CONTEXT(glamor_priv);
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dst_pixmap_priv)) {
glamor_fallback("dest pixmap %p has no fbo. \n",
......@@ -448,7 +442,6 @@ _glamor_copy_n_to_n(DrawablePtr src,
glamor_clear_delayed_fallbacks(dst->pScreen);
if (temp_src != src)
glamor_destroy_pixmap(temp_pixmap);
GLAMOR_RESTORE_CONTEXT(glamor_priv);
return ret;
}
......
......@@ -26,10 +26,6 @@
*
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "glamor_priv.h"
static Bool
......@@ -37,7 +33,6 @@ _glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
int srcx, int srcy, int w, int h, int dstx, int dsty,
unsigned long bitPlane, RegionPtr *pRegion, Bool fallback)
{
GLAMOR_DEFINE_CONTEXT;
glamor_screen_private *glamor_priv;
if (!fallback
......@@ -47,14 +42,12 @@ _glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
goto fail;
glamor_priv = glamor_get_screen_private(pDst->pScreen);
GLAMOR_SET_CONTEXT(glamor_priv);
glamor_prepare_access(pDst, GLAMOR_ACCESS_RW);
glamor_prepare_access(pSrc, GLAMOR_ACCESS_RO);
*pRegion = fbCopyPlane(pSrc, pDst, pGC, srcx, srcy, w, h,
dstx, dsty, bitPlane);
glamor_finish_access(pSrc, GLAMOR_ACCESS_RO);
glamor_finish_access(pDst, GLAMOR_ACCESS_RW);
GLAMOR_RESTORE_CONTEXT(glamor_priv);
return TRUE;
fail:
......
......@@ -21,10 +21,6 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "glamor_priv.h"
/** @file glamor_copywindow.c
......
......@@ -31,10 +31,6 @@
* This file covers core X rendering in glamor.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <stdlib.h>
#include "glamor_priv.h"
......@@ -174,7 +170,7 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
GLint sampler_uniform_location;
glamor_priv = glamor_get_screen_private(screen);
dispatch = &glamor_priv->dispatch;
dispatch = glamor_get_dispatch(glamor_priv);
glamor_priv->finish_access_prog[0] = dispatch->glCreateProgram();
glamor_priv->finish_access_prog[1] = dispatch->glCreateProgram();
......@@ -248,7 +244,7 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
dispatch->glUniform1i(sampler_uniform_location, 0);
dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[1], 0);
dispatch->glUseProgram(0);
glamor_put_dispatch(glamor_priv);
}
void
......@@ -258,9 +254,10 @@ glamor_fini_finish_access_shaders(ScreenPtr screen)
glamor_gl_dispatch *dispatch;
glamor_priv = glamor_get_screen_private(screen);
dispatch = &glamor_priv->dispatch;
dispatch = glamor_get_dispatch(glamor_priv);
dispatch->glDeleteProgram(glamor_priv->finish_access_prog[0]);
dispatch->glDeleteProgram(glamor_priv->finish_access_prog[1]);
glamor_put_dispatch(glamor_priv);
}
void
......@@ -271,7 +268,6 @@ glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode)
glamor_get_pixmap_private(pixmap);
glamor_screen_private *glamor_priv =
glamor_get_screen_private(drawable->pScreen);
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO_DOWNLOADED(pixmap_priv))
return;
......@@ -281,11 +277,17 @@ glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode)
}
if (pixmap_priv->fbo->pbo != 0 && pixmap_priv->fbo->pbo_valid) {
glamor_gl_dispatch *dispatch;
assert(glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP);
dispatch = glamor_get_dispatch(glamor_priv);
dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
dispatch->glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
pixmap_priv->fbo->pbo_valid = FALSE;
dispatch->glDeleteBuffers(1, &pixmap_priv->fbo->pbo);
glamor_put_dispatch(glamor_priv);
pixmap_priv->fbo->pbo_valid = FALSE;
pixmap_priv->fbo->pbo = 0;
} else {
free(pixmap->devPrivate.ptr);
......
......@@ -31,11 +31,8 @@
#include "config.h"
#endif
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#define GLAMOR_FOR_XORG
#include "xorg-server.h"
#include <xorg-server.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
......@@ -93,7 +90,8 @@ struct glamor_egl_screen_private {
struct gbm_device *gbm;
#endif
int has_gem;
void *gl_context;
void *gl_context, *old_context;
int gl_context_depth;
PFNEGLCREATEIMAGEKHRPROC egl_create_image_khr;
PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image_khr;
......@@ -112,13 +110,18 @@ glamor_egl_get_screen_private(ScrnInfoPtr scrn)
scrn->privates[xf86GlamorEGLPrivateIndex].ptr;
}
#ifdef GLX_USE_SHARED_DISPATCH
_X_EXPORT void *
_X_EXPORT void
glamor_egl_make_current(ScreenPtr screen)
{
ScrnInfoPtr scrn = xf86Screens[screen->myNum];
struct glamor_egl_screen_private *glamor_egl =
glamor_egl_get_screen_private(scrn);
if (glamor_egl->gl_context_depth++)
return;
GET_CURRENT_CONTEXT(current);
glamor_egl->old_context = current;
if (glamor_egl->gl_context != current) {
eglMakeCurrent(glamor_egl->display, EGL_NO_SURFACE,
......@@ -126,24 +129,28 @@ glamor_egl_make_current(ScreenPtr screen)
if (!eglMakeCurrent(glamor_egl->display,
EGL_NO_SURFACE, EGL_NO_SURFACE,
glamor_egl->context)) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
"Failed to make EGL context current\n");
return NULL;
FatalError("Failed to make EGL context current\n");
}
return current;
}
return NULL;
}
_X_EXPORT void
glamor_egl_restore_context(ScreenPtr screen, void *context)
glamor_egl_restore_context(ScreenPtr screen)
{
if (context)
SET_CURRENT_CONTEXT(context);
ScrnInfoPtr scrn = xf86Screens[screen->myNum];
struct glamor_egl_screen_private *glamor_egl =
glamor_egl_get_screen_private(scrn);
if (--glamor_egl->gl_context_depth)
return;
if (glamor_egl->old_context &&
glamor_egl->gl_context != glamor_egl->old_context)
SET_CURRENT_CONTEXT(glamor_egl->old_context);
}
#else
#define glamor_egl_make_current(x) NULL
#define glamor_egl_restore_context(s, c)
#define glamor_egl_make_current(x)
#define glamor_egl_restore_context(s)
#endif
static EGLImageKHR
......@@ -252,12 +259,11 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
EGLImageKHR image;
GLuint texture;
int name;
void *prev_context;
Bool ret = FALSE;
glamor_egl = glamor_egl_get_screen_private(scrn);
prev_context = glamor_egl_make_current(screen);
glamor_egl_make_current(screen);
if (glamor_egl->has_gem) {
if (!glamor_get_flink_name(glamor_egl->fd, handle, &name)) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
......@@ -285,8 +291,7 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
ret = TRUE;
done:
if (prev_context)
glamor_egl_restore_context(screen, prev_context);
glamor_egl_restore_context(screen);
return ret;
}
......@@ -497,6 +502,13 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
#endif
glamor_egl->saved_free_screen = scrn->FreeScreen;
scrn->FreeScreen = glamor_egl_free_screen;
#ifdef GLAMOR_GLES2
xf86DrvMsg(scrn->scrnIndex, X_INFO, "Using GLES2.\n");
#ifdef GLX_USE_SHARED_DISPATCH
xf86DrvMsg(scrn->scrnIndex, X_WARNING, "Glamor is using GLES2 but GLX needs GL. "
"Indirect GLX may not work correctly.\n");
#endif
#endif
return TRUE;
}
......
......@@ -28,10 +28,10 @@
#include "config.h"
#endif
#include <xorg-server.h>
#define GLAMOR_FOR_XORG
#include "glamor.h"
#include "xf86Module.h"
#include <xf86Module.h>
#include <xorg-server.h>
static XF86ModuleVersionInfo VersRec = {
GLAMOR_EGL_MODULE_NAME,
......
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <stdlib.h>
#include "glamor_priv.h"
......@@ -126,17 +122,14 @@ glamor_pixmap_fbo_cache_get(glamor_screen_private *glamor_priv,
void
glamor_purge_fbo(glamor_pixmap_fbo *fbo)
{
GLAMOR_DEFINE_CONTEXT;
GLAMOR_SET_CONTEXT(fbo->glamor_priv);
glamor_gl_dispatch *dispatch = &fbo->glamor_priv->dispatch;
glamor_gl_dispatch *dispatch = glamor_get_dispatch(fbo->glamor_priv);
if (fbo->fb)
dispatch->glDeleteFramebuffers(1, &fbo->fb);
if (fbo->tex)
dispatch->glDeleteTextures(1, &fbo->tex);
if (fbo->pbo)
dispatch->glDeleteBuffers(1, &fbo->pbo);
GLAMOR_RESTORE_CONTEXT(fbo->glamor_priv);
glamor_put_dispatch(fbo->glamor_priv);
free(fbo);
}
......@@ -292,7 +285,6 @@ glamor_create_tex_obj(glamor_screen_private *glamor_priv,
glamor_pixmap_fbo *fbo;
int cache_flag = GLAMOR_CACHE_TEXTURE;
GLuint tex;
GLAMOR_DEFINE_CONTEXT;
if (flag == GLAMOR_CREATE_TEXTURE_EXACT_SIZE)
cache_flag |= GLAMOR_CACHE_EXACT_SIZE;
......@@ -305,10 +297,9 @@ glamor_create_tex_obj(glamor_screen_private *glamor_priv,
if (fbo == NULL)
return NULL;
GLAMOR_SET_CONTEXT(glamor_priv);
list_init(&fbo->list);
dispatch = &glamor_priv->dispatch;
dispatch = glamor_get_dispatch(glamor_priv);
dispatch->glGenTextures(1, &tex);
dispatch->glBindTexture(GL_TEXTURE_2D, tex);
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
......@@ -317,12 +308,13 @@ glamor_create_tex_obj(glamor_screen_private *glamor_priv,
GL_NEAREST);
dispatch->glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0, format,
GL_UNSIGNED_BYTE, NULL);
glamor_put_dispatch(glamor_priv);
fbo->tex = tex;
fbo->width = w;
fbo->height = h;
fbo->format = format;
fbo->glamor_priv = glamor_priv;
GLAMOR_RESTORE_CONTEXT(glamor_priv);
return fbo;
}
......@@ -344,7 +336,6 @@ glamor_create_fbo(glamor_screen_private *glamor_priv,
GLenum format;
GLint tex;
int cache_flag;
GLAMOR_DEFINE_CONTEXT;
if (!glamor_check_fbo_size(glamor_priv, w, h)
|| !glamor_check_fbo_depth(depth))
......@@ -364,9 +355,7 @@ glamor_create_fbo(glamor_screen_private *glamor_priv,
if (fbo)
return fbo;
new_fbo:
GLAMOR_SET_CONTEXT(glamor_priv);
dispatch = &glamor_priv->dispatch;
dispatch = glamor_get_dispatch(glamor_priv);
dispatch->glGenTextures(1, &tex);
dispatch->glBindTexture(GL_TEXTURE_2D, tex);
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
......@@ -377,7 +366,7 @@ new_fbo:
GL_UNSIGNED_BYTE, NULL);
fbo = glamor_create_fbo_from_tex(glamor_priv, w, h, depth, tex, flag);
GLAMOR_RESTORE_CONTEXT(glamor_priv);
glamor_put_dispatch(glamor_priv);
return fbo;
}
......
......@@ -21,10 +21,6 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "glamor_priv.h"
/** @file glamor_fillspans.c
......@@ -112,7 +108,7 @@ glamor_init_solid_shader(ScreenPtr screen)
GLint fs_prog, vs_prog;
glamor_priv = glamor_get_screen_private(screen);
dispatch = &glamor_priv->dispatch;
dispatch = glamor_get_dispatch(glamor_priv);
glamor_priv->solid_prog = dispatch->glCreateProgram();
vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, solid_vs);
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
......@@ -127,6 +123,7 @@ glamor_init_solid_shader(ScreenPtr screen)
glamor_priv->solid_color_uniform_location =
dispatch->glGetUniformLocation(glamor_priv->solid_prog,
"color");
glamor_put_dispatch(glamor_priv);
}
void
......@@ -136,8 +133,9 @@ glamor_fini_solid_shader(ScreenPtr screen)
glamor_gl_dispatch *dispatch;
glamor_priv = glamor_get_screen_private(screen);
dispatch = &glamor_priv->dispatch;
dispatch = glamor_get_dispatch(glamor_priv);
dispatch->glDeleteProgram(glamor_priv->solid_prog);
glamor_put_dispatch(glamor_priv);
}
Bool
......@@ -150,7 +148,7 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
glamor_get_screen_private(screen);
glamor_pixmap_private *pixmap_priv =
glamor_get_pixmap_private(pixmap);
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
glamor_gl_dispatch *dispatch;
int x1 = x;
int x2 = x + width;
int y1 = y;
......@@ -158,15 +156,16 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
GLfloat color[4];
float vertices[8];
GLfloat xscale, yscale;
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
glamor_fallback("dest %p has no fbo.\n", pixmap);
goto fail;
return FALSE;
}
glamor_set_alu(dispatch, alu);
if (!glamor_set_planemask(pixmap, planemask)) {
glamor_fallback
("Failedto set planemask in glamor_solid.\n");
goto fail;
return FALSE;
}
glamor_get_rgba_from_pixel(fg_pixel,
......@@ -189,6 +188,8 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
glamor_validate_pixmap(pixmap);
dispatch = glamor_get_dispatch(glamor_priv);
glamor_set_alu(dispatch, alu);
dispatch->glUseProgram(glamor_priv->solid_prog);
dispatch->glUniform4fv(glamor_priv->solid_color_uniform_location,
......@@ -205,9 +206,6 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
dispatch->glUseProgram(0);
glamor_put_dispatch(glamor_priv);
return TRUE;
fail:
glamor_set_alu(dispatch, GXcopy);
glamor_set_planemask(pixmap, ~0);
return FALSE;
}
......@@ -20,10 +20,6 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
/** @file glamor_fillspans.c
*
* FillSpans implementation, taken from fb_fillsp.c
......@@ -41,11 +37,9 @@ _glamor_fill_spans(DrawablePtr drawable,
int x1, x2, y;
RegionPtr pClip = fbGetCompositeClip(gc);
glamor_screen_private *glamor_priv;
GLAMOR_DEFINE_CONTEXT;
Bool ret = FALSE;
glamor_priv = glamor_get_screen_private(drawable->pScreen);
GLAMOR_SET_CONTEXT(glamor_priv);
if (gc->fillStyle != FillSolid && gc->fillStyle != FillTiled)
goto fail;
......@@ -99,7 +93,6 @@ fail:
ret = TRUE;
done:
GLAMOR_RESTORE_CONTEXT(glamor_priv);
return ret;
}
......