Commit 172e8cfc authored by Zhigang Gong's avatar Zhigang Gong Committed by Zhigang Gong

glamor: Remove GLEW dependency.

Glamor doesn't need to use GLEW. We can parse the extension by
ourself. This patch also fix the fbo size checking from a hard
coded style to a dynamic checking style.
Signed-off-by: Zhigang Gong's avatarZhigang Gong <zhigang.gong@gmail.com>
parent 2146a25b
...@@ -2,48 +2,6 @@ ...@@ -2,48 +2,6 @@
1. Prerequirement. 1. Prerequirement.
Please install makedepend and libudev-devel firstly. Please install makedepend and libudev-devel firstly.
Glamor need patch glew-1.5.8, here is the patch:
diff -ur ../Downloads/glew-1.5.8/Makefile glew-1.5.8/Makefile
--- ../Downloads/glew-1.5.8/Makefile 2011-01-31 22:17:27.000000000 +0800
+++ glew-1.5.8/Makefile 2011-06-28 10:13:54.147700479 +0800
@@ -63,8 +63,12 @@
else
OPT = $(POPT)
endif
-INCLUDE = -Iinclude
+
+INCLUDE = -Iinclude
CFLAGS = $(OPT) $(WARN) $(INCLUDE) $(CFLAGS.EXTRA)
+ifeq ($(NO_GLX), 1)
+CFLAGS += -D_NO_GLX_
+endif
LIB.SRCS = src/glew.c
LIB.OBJS = $(LIB.SRCS:.c=.o)
diff -ur ../Downloads/glew-1.5.8/src/glew.c glew-1.5.8/src/glew.c
--- ../Downloads/glew-1.5.8/src/glew.c 2011-01-31 22:17:27.000000000 +0800
+++ glew-1.5.8/src/glew.c 2011-06-28 10:06:45.952700777 +0800
@@ -11379,6 +11379,10 @@
{
GLenum r;
if ( (r = glewContextInit()) ) return r;
+#if defined(_NO_GLX_)
+ return r;
+#endif
+
#if defined(_WIN32)
return wglewContextInit();
#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) /* _UNIX */
As xserver's glx extension code has conflicts with glew's glx related
initialization, we have to disable it in glew currently. Please apply the
above patch to glew and then build the glew as follow which will
workaround the problem.
glew-1.5.8# NO_GLX=1 make
2. Build xserver-glamor. 2. Build xserver-glamor.
......
...@@ -2036,15 +2036,6 @@ if test "$KDRIVE" = yes; then ...@@ -2036,15 +2036,6 @@ if test "$KDRIVE" = yes; then
AC_MSG_ERROR([Xephyr dependencies missing]) AC_MSG_ERROR([Xephyr dependencies missing])
fi fi
AC_CHECK_LIB(GLEW, glewInit, [
AC_CHECK_HEADER(GL/glew.h, [], [
AC_MSG_ERROR([requires glew http://glew.sourceforge.net/])
])
], [
AC_MSG_ERROR([requires glew http://glew.sourceforge.net/])
])
XEPHYR_LIBS="$XEPHYR_LIBS -lGLEW"
# Xephyr needs nanosleep() which is in librt on Solaris # Xephyr needs nanosleep() which is in librt on Solaris
AC_CHECK_FUNC([nanosleep], [], AC_CHECK_FUNC([nanosleep], [],
AC_CHECK_LIB([rt], [nanosleep], XEPHYR_LIBS="$XEPHYR_LIBS -lrt")) AC_CHECK_LIB([rt], [nanosleep], XEPHYR_LIBS="$XEPHYR_LIBS -lrt"))
......
...@@ -110,10 +110,11 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, ...@@ -110,10 +110,11 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
GLuint tex; GLuint tex;
int type = GLAMOR_PIXMAP_TEXTURE; int type = GLAMOR_PIXMAP_TEXTURE;
glamor_pixmap_private *pixmap_priv; glamor_pixmap_private *pixmap_priv;
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
if (w > 32767 || h > 32767) if (w > 32767 || h > 32767)
return NullPixmap; return NullPixmap;
if (!glamor_check_fbo_width_height(w,h) if (!glamor_check_fbo_size(glamor_priv, w,h)
|| !glamor_check_fbo_depth(depth) || !glamor_check_fbo_depth(depth)
|| usage == GLAMOR_CREATE_PIXMAP_CPU) { || usage == GLAMOR_CREATE_PIXMAP_CPU) {
/* MESA can only support upto MAX_WIDTH*MAX_HEIGHT fbo. /* MESA can only support upto MAX_WIDTH*MAX_HEIGHT fbo.
...@@ -249,6 +250,7 @@ Bool ...@@ -249,6 +250,7 @@ Bool
glamor_init(ScreenPtr screen, unsigned int flags) glamor_init(ScreenPtr screen, unsigned int flags)
{ {
glamor_screen_private *glamor_priv; glamor_screen_private *glamor_priv;
int gl_version;
#ifdef RENDER #ifdef RENDER
PictureScreenPtr ps = GetPictureScreenIfSet(screen); PictureScreenPtr ps = GetPictureScreenIfSet(screen);
...@@ -271,7 +273,7 @@ glamor_init(ScreenPtr screen, unsigned int flags) ...@@ -271,7 +273,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
LogMessage(X_WARNING, LogMessage(X_WARNING,
"glamor%d: Failed to allocate screen private\n", "glamor%d: Failed to allocate screen private\n",
screen->myNum); screen->myNum);
return FALSE; goto fail;
} }
dixSetPrivate(&screen->devPrivates, glamor_screen_private_key, glamor_priv); dixSetPrivate(&screen->devPrivates, glamor_screen_private_key, glamor_priv);
...@@ -281,36 +283,27 @@ glamor_init(ScreenPtr screen, unsigned int flags) ...@@ -281,36 +283,27 @@ glamor_init(ScreenPtr screen, unsigned int flags)
LogMessage(X_WARNING, LogMessage(X_WARNING,
"glamor%d: Failed to allocate pixmap private\n", "glamor%d: Failed to allocate pixmap private\n",
screen->myNum); screen->myNum);
return FALSE; goto fail;;
} }
gl_version = glamor_gl_get_version();
#ifndef GLAMOR_GLES2 if (gl_version < GLAMOR_GL_VERSION_ENCODE(1,3)) {
glewInit(); ErrorF("Require Opengl 1.3 or latter.\n");
if (!GLEW_EXT_framebuffer_object) { goto fail;
ErrorF("GL_EXT_framebuffer_object required\n");
goto fail;
}
if (!GLEW_ARB_shader_objects) {
ErrorF("GL_ARB_shader_objects required\n");
goto fail;
}
if (!GLEW_ARB_vertex_shader) {
ErrorF("GL_ARB_vertex_shader required\n");
goto fail;
} }
if (!GLEW_ARB_pixel_buffer_object) {
ErrorF("GL_ARB_pixel_buffer_object required\n"); #ifdef GLAMOR_GLES2
goto fail; if (!glamor_gl_has_extension("GL_EXT_texture_format_BGRA8888")) {
} ErrorF("GL_EXT_texture_format_BGRA8888 required\n");
if (!GLEW_EXT_bgra) {
ErrorF("GL_EXT_bgra required\n");
goto fail; goto fail;
} }
#endif #endif
glamor_priv->has_pack_invert = glamor_gl_has_extension("GL_MESA_pack_invert");
glamor_priv->has_fbo_blit = glamor_gl_has_extension("GL_EXT_framebuffer_blit");
glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &glamor_priv->max_fbo_size);
if (!RegisterBlockAndWakeupHandlers(glamor_block_handler, if (!RegisterBlockAndWakeupHandlers(glamor_block_handler,
glamor_wakeup_handler, glamor_wakeup_handler,
......
...@@ -48,7 +48,7 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src, ...@@ -48,7 +48,7 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
int dst_x_off, dst_y_off, src_x_off, src_y_off, i; int dst_x_off, dst_y_off, src_x_off, src_y_off, i;
if (!GLEW_EXT_framebuffer_blit) { if (!glamor_priv->has_fbo_blit) {
glamor_delayed_fallback(screen,"no EXT_framebuffer_blit\n"); glamor_delayed_fallback(screen,"no EXT_framebuffer_blit\n");
return FALSE; return FALSE;
} }
...@@ -85,7 +85,7 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src, ...@@ -85,7 +85,7 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
for (i = 0; i < nbox; i++) { for (i = 0; i < nbox; i++) {
if(glamor_priv->yInverted) { if(glamor_priv->yInverted) {
glBlitFramebufferEXT((box[i].x1 + dx + src_x_off), glBlitFramebuffer((box[i].x1 + dx + src_x_off),
(box[i].y1 + src_y_off), (box[i].y1 + src_y_off),
(box[i].x2 + dx + src_x_off), (box[i].x2 + dx + src_x_off),
(box[i].y2 + src_y_off), (box[i].y2 + src_y_off),
...@@ -101,7 +101,7 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src, ...@@ -101,7 +101,7 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
int flip_src_y1 = src_pixmap->drawable.height - (box[i].y2 + src_y_off); int flip_src_y1 = src_pixmap->drawable.height - (box[i].y2 + src_y_off);
int flip_src_y2 = src_pixmap->drawable.height - (box[i].y1 + src_y_off); int flip_src_y2 = src_pixmap->drawable.height - (box[i].y1 + src_y_off);
glBlitFramebufferEXT(box[i].x1 + dx + src_x_off, glBlitFramebuffer(box[i].x1 + dx + src_x_off,
flip_src_y1, flip_src_y1,
box[i].x2 + dx + src_x_off, box[i].x2 + dx + src_x_off,
flip_src_y2, flip_src_y2,
......
...@@ -201,35 +201,27 @@ glamor_init_finish_access_shaders(ScreenPtr screen) ...@@ -201,35 +201,27 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
glamor_priv->finish_access_prog[2] = glCreateProgram(); glamor_priv->finish_access_prog[2] = glCreateProgram();
glamor_priv->finish_access_prog[3] = glCreateProgram(); glamor_priv->finish_access_prog[3] = glCreateProgram();
if (GLEW_ARB_fragment_shader) {
#ifndef GLAMOR_GLES2 #ifndef GLAMOR_GLES2
vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, vs_source); vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, vs_source);
fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, fs_source); fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, fs_source);
glAttachShader(glamor_priv->finish_access_prog[0], vs_prog); glAttachShader(glamor_priv->finish_access_prog[0], vs_prog);
glAttachShader(glamor_priv->finish_access_prog[0], fs_prog); glAttachShader(glamor_priv->finish_access_prog[0], fs_prog);
avs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, vs_source); avs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, vs_source);
aswizzle_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, aswizzle_source); aswizzle_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, aswizzle_source);
glAttachShader(glamor_priv->finish_access_prog[1], avs_prog); glAttachShader(glamor_priv->finish_access_prog[1], avs_prog);
glAttachShader(glamor_priv->finish_access_prog[1], aswizzle_prog); glAttachShader(glamor_priv->finish_access_prog[1], aswizzle_prog);
#endif #endif
es_vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, es_vs_source); es_vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, es_vs_source);
es_fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, es_fs_source); es_fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, es_fs_source);
glAttachShader(glamor_priv->finish_access_prog[2], es_vs_prog); glAttachShader(glamor_priv->finish_access_prog[2], es_vs_prog);
glAttachShader(glamor_priv->finish_access_prog[2], es_fs_prog); glAttachShader(glamor_priv->finish_access_prog[2], es_fs_prog);
es_avs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, es_vs_source); es_avs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, es_vs_source);
es_aswizzle_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, es_aswizzle_source); es_aswizzle_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, es_aswizzle_source);
glAttachShader(glamor_priv->finish_access_prog[3], es_avs_prog); glAttachShader(glamor_priv->finish_access_prog[3], es_avs_prog);
glAttachShader(glamor_priv->finish_access_prog[3], es_aswizzle_prog); glAttachShader(glamor_priv->finish_access_prog[3], es_aswizzle_prog);
} else {
#ifndef GLAMOR_GLES2
vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, vs_source);
glAttachShader(glamor_priv->finish_access_prog[0], vs_prog);
ErrorF("Lack of framgment shader support.\n");
#endif
}
#ifndef GLAMOR_GLES2 #ifndef GLAMOR_GLES2
...@@ -244,34 +236,32 @@ glamor_init_finish_access_shaders(ScreenPtr screen) ...@@ -244,34 +236,32 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
glBindAttribLocation(glamor_priv->finish_access_prog[3], GLAMOR_VERTEX_SOURCE, "v_texcoord0"); glBindAttribLocation(glamor_priv->finish_access_prog[3], GLAMOR_VERTEX_SOURCE, "v_texcoord0");
glamor_link_glsl_prog(glamor_priv->finish_access_prog[3]); glamor_link_glsl_prog(glamor_priv->finish_access_prog[3]);
if (GLEW_ARB_fragment_shader) { GLint sampler_uniform_location;
GLint sampler_uniform_location;
#ifndef GLAMOR_GLES2 #ifndef GLAMOR_GLES2
sampler_uniform_location = sampler_uniform_location =
glGetUniformLocation(glamor_priv->finish_access_prog[0], "sampler"); glGetUniformLocation(glamor_priv->finish_access_prog[0], "sampler");
glUseProgram(glamor_priv->finish_access_prog[0]); glUseProgram(glamor_priv->finish_access_prog[0]);
glUniform1i(sampler_uniform_location, 0); glUniform1i(sampler_uniform_location, 0);
glUseProgram(0); glUseProgram(0);
sampler_uniform_location = sampler_uniform_location =
glGetUniformLocation(glamor_priv->finish_access_prog[1], "sampler"); glGetUniformLocation(glamor_priv->finish_access_prog[1], "sampler");
glUseProgram(glamor_priv->finish_access_prog[1]); glUseProgram(glamor_priv->finish_access_prog[1]);
glUniform1i(sampler_uniform_location, 0); glUniform1i(sampler_uniform_location, 0);
glUseProgram(0); glUseProgram(0);
#endif #endif
sampler_uniform_location = sampler_uniform_location =
glGetUniformLocation(glamor_priv->finish_access_prog[2], "sampler"); glGetUniformLocation(glamor_priv->finish_access_prog[2], "sampler");
glUseProgram(glamor_priv->finish_access_prog[2]); glUseProgram(glamor_priv->finish_access_prog[2]);
glUniform1i(sampler_uniform_location, 0); glUniform1i(sampler_uniform_location, 0);
glUseProgram(0); glUseProgram(0);
sampler_uniform_location = sampler_uniform_location =
glGetUniformLocation(glamor_priv->finish_access_prog[3], "sampler"); glGetUniformLocation(glamor_priv->finish_access_prog[3], "sampler");
glUseProgram(glamor_priv->finish_access_prog[3]); glUseProgram(glamor_priv->finish_access_prog[3]);
glUniform1i(sampler_uniform_location, 0); glUniform1i(sampler_uniform_location, 0);
glUseProgram(0); glUseProgram(0);
}
} }
void void
...@@ -494,3 +484,50 @@ glamor_bitmap_to_region(PixmapPtr pixmap) ...@@ -494,3 +484,50 @@ glamor_bitmap_to_region(PixmapPtr pixmap)
glamor_finish_access(&pixmap->drawable); glamor_finish_access(&pixmap->drawable);
return ret; return ret;
} }
/* Borrow from cairo. */
Bool
glamor_gl_has_extension(char *extension)
{
const char *gl_extensions;
char *pext;
int ext_len;
ext_len = strlen(extension);
gl_extensions = (const char*)glGetString(GL_EXTENSIONS);
pext = (char*)gl_extensions;
if (pext == NULL || extension == NULL)
return FALSE;
while((pext = strstr(pext, extension)) != NULL) {
if (pext[ext_len] == ' ' || pext[ext_len] == '\0')
return TRUE;
pext += ext_len;
}
return FALSE;
}
int
glamor_gl_get_version (void)
{
int major, minor;
const char *version = (const char *) glGetString (GL_VERSION);
const char *dot = version == NULL ? NULL : strchr (version, '.');
const char *major_start = dot;
/* Sanity check */
if (dot == NULL || dot == version || *(dot + 1) == '\0') {
major = 0;
minor = 0;
} else {
/* Find the start of the major version in the string */
while (major_start > version && *major_start != ' ')
--major_start;
major = strtol (major_start, NULL, 10);
minor = strtol (dot + 1, NULL, 10);
}
return GLAMOR_GL_VERSION_ENCODE (major, minor);
}
...@@ -139,15 +139,10 @@ glamor_init_solid_shader(ScreenPtr screen) ...@@ -139,15 +139,10 @@ glamor_init_solid_shader(ScreenPtr screen)
GLint fs_prog, vs_prog; GLint fs_prog, vs_prog;
glamor_priv->solid_prog = glCreateProgram(); glamor_priv->solid_prog = glCreateProgram();
if (GLEW_ARB_fragment_shader) { 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); glAttachShader(glamor_priv->solid_prog, vs_prog);
glAttachShader(glamor_priv->solid_prog, vs_prog); glAttachShader(glamor_priv->solid_prog, fs_prog);
glAttachShader(glamor_priv->solid_prog, fs_prog);
} else {
vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, solid_vs_only);
glAttachShader(glamor_priv->solid_prog, vs_prog);
}
glBindAttribLocation(glamor_priv->solid_prog, GLAMOR_VERTEX_POS, "v_position"); glBindAttribLocation(glamor_priv->solid_prog, GLAMOR_VERTEX_POS, "v_position");
glamor_link_glsl_prog(glamor_priv->solid_prog); glamor_link_glsl_prog(glamor_priv->solid_prog);
......
...@@ -407,7 +407,7 @@ glamor_pixmap_upload_prepare(PixmapPtr pixmap, int ax) ...@@ -407,7 +407,7 @@ glamor_pixmap_upload_prepare(PixmapPtr pixmap, int ax)
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap); glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
glamor_screen_private *glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen); glamor_screen_private *glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
if (!glamor_check_fbo_width_height(pixmap->drawable.width , pixmap->drawable.height) if (!glamor_check_fbo_size(glamor_priv, pixmap->drawable.width , pixmap->drawable.height)
|| !glamor_check_fbo_depth(pixmap->drawable.depth)) { || !glamor_check_fbo_depth(pixmap->drawable.depth)) {
glamor_fallback("upload failed reason: bad size or depth %d x %d @depth %d \n", glamor_fallback("upload failed reason: bad size or depth %d x %d @depth %d \n",
pixmap->drawable.width, pixmap->drawable.height, pixmap->drawable.depth); pixmap->drawable.width, pixmap->drawable.height, pixmap->drawable.depth);
...@@ -571,7 +571,7 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access) ...@@ -571,7 +571,7 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
// glPixelStorei(GL_PACK_ROW_LENGTH, 0); // glPixelStorei(GL_PACK_ROW_LENGTH, 0);
} }
if (GLEW_MESA_pack_invert || glamor_priv->yInverted) { if (glamor_priv->has_pack_invert || glamor_priv->yInverted) {
if (!glamor_priv->yInverted) { if (!glamor_priv->yInverted) {
assert(glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP); assert(glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP);
......
...@@ -37,8 +37,6 @@ ...@@ -37,8 +37,6 @@
#ifdef GLAMOR_GLES2 #ifdef GLAMOR_GLES2
#define GLEW_ES_ONLY 1
#define GL_BGRA GL_BGRA_EXT #define GL_BGRA GL_BGRA_EXT
#define GL_COLOR_INDEX 0x1900 #define GL_COLOR_INDEX 0x1900
#define GL_BITMAP 0x1A00 #define GL_BITMAP 0x1A00
...@@ -49,7 +47,6 @@ ...@@ -49,7 +47,6 @@
#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 #define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 #define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
#define GLEW_ARB_fragment_shader 1
#define GL_PIXEL_PACK_BUFFER 0x88EB #define GL_PIXEL_PACK_BUFFER 0x88EB
#define GL_PIXEL_UNPACK_BUFFER 0x88EC #define GL_PIXEL_UNPACK_BUFFER 0x88EC
#define GL_CLAMP_TO_BORDER 0x812D #define GL_CLAMP_TO_BORDER 0x812D
...@@ -66,7 +63,6 @@ ...@@ -66,7 +63,6 @@
#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC #define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
#define GLEW_MESA_pack_invert 0
#define GL_PACK_INVERT_MESA 0x8758 #define GL_PACK_INVERT_MESA 0x8758
#define glMapBuffer(x, y) NULL #define glMapBuffer(x, y) NULL
...@@ -76,12 +72,13 @@ ...@@ -76,12 +72,13 @@
#endif #endif
#ifdef GLAMOR_GLES2
#define GL_GLEXT_PROTOTYPES #define GL_GLEXT_PROTOTYPES
#ifdef GLAMOR_GLES2
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
#include <GLES2/gl2ext.h> #include <GLES2/gl2ext.h>
#else #else
#include <GL/glew.h> #include <GL/gl.h>
#include <GL/glext.h>
#endif #endif
...@@ -90,19 +87,11 @@ ...@@ -90,19 +87,11 @@
#endif #endif
#ifndef MAX_WIDTH
#define MAX_WIDTH 4096
#endif
#ifndef MAX_HEIGHT
#define MAX_HEIGHT 4096
#endif
#include "glamor_debug.h" #include "glamor_debug.h"
#define glamor_check_fbo_width_height(_w_, _h_) ((_w_) > 0 && (_h_) > 0 \ #define glamor_check_fbo_size(_glamor_,_w_, _h_) ((_w_) > 0 && (_h_) > 0 \
&& (_w_) < MAX_WIDTH \ && (_w_) < _glamor_->max_fbo_size \
&& (_h_) < MAX_HEIGHT) && (_h_) < _glamor_->max_fbo_size)
#define glamor_check_fbo_depth(_depth_) ( \ #define glamor_check_fbo_depth(_depth_) ( \
_depth_ == 8 \ _depth_ == 8 \
...@@ -241,6 +230,9 @@ typedef struct glamor_screen_private { ...@@ -241,6 +230,9 @@ typedef struct glamor_screen_private {
char *vb; char *vb;
int vb_stride; int vb_stride;
enum glamor_gl_flavor gl_flavor; enum glamor_gl_flavor gl_flavor;
int has_pack_invert;
int has_fbo_blit;
int max_fbo_size;
/* glamor_finishaccess */ /* glamor_finishaccess */
GLint finish_access_prog[4]; GLint finish_access_prog[4];
...@@ -674,6 +666,15 @@ void glamor_set_transform_for_pixmap(PixmapPtr pixmap, ...@@ -674,6 +666,15 @@ void glamor_set_transform_for_pixmap(PixmapPtr pixmap,
glamor_transform_uniforms *uniform_locations); glamor_transform_uniforms *uniform_locations);
Bool glamor_change_window_attributes(WindowPtr pWin, unsigned long mask); Bool glamor_change_window_attributes(WindowPtr pWin, unsigned long mask);
RegionPtr glamor_bitmap_to_region(PixmapPtr pixmap); RegionPtr glamor_bitmap_to_region(PixmapPtr pixmap);
Bool glamor_gl_has_extension(char *extension);
int glamor_gl_get_version(void);
#define GLAMOR_GL_VERSION_ENCODE(major, minor) ( \
((major) * 256) \
+ ((minor) * 1))
/* glamor_fill.c */ /* glamor_fill.c */
void glamor_fill(DrawablePtr drawable, void glamor_fill(DrawablePtr drawable,
......
...@@ -1154,6 +1154,7 @@ glamor_composite(CARD8 op, ...@@ -1154,6 +1154,7 @@ glamor_composite(CARD8 op,
PicturePtr temp_src = source, temp_mask = mask; PicturePtr temp_src = source, temp_mask = mask;
int x_temp_src, y_temp_src, x_temp_mask, y_temp_mask; int x_temp_src, y_temp_src, x_temp_mask, y_temp_mask;
glamor_composite_rect_t rect; glamor_composite_rect_t rect;
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
x_temp_src = x_source; x_temp_src = x_source;
y_temp_src = y_source; y_temp_src = y_source;
...@@ -1181,7 +1182,7 @@ glamor_composite(CARD8 op, ...@@ -1181,7 +1182,7 @@ glamor_composite(CARD8 op,
&& !GLAMOR_PIXMAP_PRIV_HAS_FBO(source_pixmap_priv) && !GLAMOR_PIXMAP_PRIV_HAS_FBO(source_pixmap_priv)
&& ((width * height * 4 && ((width * height * 4
< (source_pixmap->drawable.width * source_pixmap->drawable.height)) < (source_pixmap->drawable.width * source_pixmap->drawable.height))
|| !(glamor_check_fbo_width_height(source_pixmap->drawable.width, || !(glamor_check_fbo_size(glamor_priv, source_pixmap->drawable.width,
source_pixmap->drawable.height))))) { source_pixmap->drawable.height))))) {
temp_src = glamor_convert_gradient_picture(screen, source, x_source, y_source, width, height); temp_src = glamor_convert_gradient_picture(screen, source, x_source, y_source, width, height);
if (!temp_src) { if (!temp_src) {
...@@ -1197,7 +1198,7 @@ glamor_composite(CARD8 op, ...@@ -1197,7 +1198,7 @@ glamor_composite(CARD8 op,
&& (!GLAMOR_PIXMAP_PRIV_HAS_FBO(mask_pixmap_priv)) && (!GLAMOR_PIXMAP_PRIV_HAS_FBO(mask_pixmap_priv))
&& ((width * height * 4 && ((width * height * 4
< (mask_pixmap->drawable.width * mask_pixmap->drawable.height)) < (mask_pixmap->drawable.width * mask_pixmap->drawable.height))
|| !(glamor_check_fbo_width_height(mask_pixmap->drawable.width, || !(glamor_check_fbo_size(glamor_priv, mask_pixmap->drawable.width,
mask_pixmap->drawable.height)))))) { mask_pixmap->drawable.height)))))) {
/* XXX if mask->pDrawable is the same as source->pDrawable, we have an opportunity /* XXX if mask->pDrawable is the same as source->pDrawable, we have an opportunity
* to do reduce one convertion. */ * to do reduce one convertion. */
......
...@@ -74,9 +74,6 @@ glamor_init_tile_shader(ScreenPtr screen) ...@@ -74,9 +74,6 @@ glamor_init_tile_shader(ScreenPtr screen)
GLint fs_prog, vs_prog; GLint fs_prog, vs_prog;
GLint sampler_uniform_location; GLint sampler_uniform_location;
if (!GLEW_ARB_fragment_shader)
return;
glamor_priv->tile_prog = glCreateProgram(); glamor_priv->tile_prog = glCreateProgram();
vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, tile_vs); vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, tile_vs);
fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, tile_fs); fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, tile_fs);
......
...@@ -66,6 +66,12 @@ libxephyr_la_SOURCES = $(XEPHYR_SRCS) ...@@ -66,6 +66,12 @@ libxephyr_la_SOURCES = $(XEPHYR_SRCS)
Xephyr_SOURCES = \ Xephyr_SOURCES = \
ephyrinit.c ephyrinit.c
if GLAMOR_GLES2
GLAMOR_GL_LIB = -lGLESv2
else
GLAMOR_GL_LIB = -lGL
endif
Xephyr_LDADD = \ Xephyr_LDADD = \
libxephyr.la \ libxephyr.la \
libxephyr-hostx.la \ libxephyr-hostx.la \
...@@ -74,7 +80,8 @@ Xephyr_LDADD = \ ...@@ -74,7 +80,8 @@ Xephyr_LDADD = \
$(top_builddir)/exa/libexa.la \ $(top_builddir)/exa/libexa.la \
$(top_builddir)/glamor/libglamor.la \