Commit 9553020b authored by Eric Anholt's avatar Eric Anholt

glamor: Drop a bunch of GLES2 ifdefs.

Now that we're using epoxy, we can write code using both desktop and
ES symbols and decide what to use at runtime.

v2: Fix a spelling mistake (latter), since the lines were moved
    anyway (noticed by Rémi Cardona).  Fix condition invert in
    glamor_set_composite_texture (caught by Michel Dänzer).
Signed-off-by: Eric Anholt's avatarEric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com> (v1)
Reviewed-by: Adam Jackson <ajax@redhat.com> (v1)
parent c3c8a5f3
...@@ -301,26 +301,29 @@ glamor_init(ScreenPtr screen, unsigned int flags) ...@@ -301,26 +301,29 @@ glamor_init(ScreenPtr screen, unsigned int flags)
goto fail;; goto fail;;
} }
if (epoxy_is_desktop_gl())
glamor_priv->gl_flavor = GLAMOR_GL_DESKTOP;
else
glamor_priv->gl_flavor = GLAMOR_GL_ES2;
gl_version = glamor_gl_get_version(); gl_version = glamor_gl_get_version();
#ifndef GLAMOR_GLES2 if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
if (gl_version < GLAMOR_GL_VERSION_ENCODE(1, 3)) { if (gl_version < GLAMOR_GL_VERSION_ENCODE(1, 3)) {
ErrorF("Require OpenGL version 1.3 or latter.\n"); ErrorF("Require OpenGL version 1.3 or later.\n");
goto fail; goto fail;
} }
#else } else {
if (gl_version < GLAMOR_GL_VERSION_ENCODE(2, 0)) { if (gl_version < GLAMOR_GL_VERSION_ENCODE(2, 0)) {
ErrorF("Require Open GLES2.0 or latter.\n"); ErrorF("Require Open GLES2.0 or later.\n");
goto fail; goto fail;
} }
#endif
#ifdef GLAMOR_GLES2 if (!glamor_gl_has_extension("GL_EXT_texture_format_BGRA8888")) {
if (!glamor_gl_has_extension("GL_EXT_texture_format_BGRA8888")) { ErrorF("GL_EXT_texture_format_BGRA8888 required\n");
ErrorF("GL_EXT_texture_format_BGRA8888 required\n"); goto fail;
goto fail; }
} }
#endif
glamor_priv->has_pack_invert = glamor_priv->has_pack_invert =
glamor_gl_has_extension("GL_MESA_pack_invert"); glamor_gl_has_extension("GL_MESA_pack_invert");
...@@ -333,11 +336,6 @@ glamor_init(ScreenPtr screen, unsigned int flags) ...@@ -333,11 +336,6 @@ glamor_init(ScreenPtr screen, unsigned int flags)
glamor_set_debug_level(&glamor_debug_level); glamor_set_debug_level(&glamor_debug_level);
#ifdef GLAMOR_GLES2
glamor_priv->gl_flavor = GLAMOR_GL_ES2;
#else
glamor_priv->gl_flavor = GLAMOR_GL_DESKTOP;
#endif
/* If we are using egl screen, call egl screen init to /* If we are using egl screen, call egl screen init to
* register correct close screen function. */ * register correct close screen function. */
if (flags & GLAMOR_USE_EGL_SCREEN) { if (flags & GLAMOR_USE_EGL_SCREEN) {
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
* *
* GC CopyArea implementation * GC CopyArea implementation
*/ */
#ifndef GLAMOR_GLES2
static Bool static Bool
glamor_copy_n_to_n_fbo_blit(DrawablePtr src, glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
DrawablePtr dst, DrawablePtr dst,
...@@ -117,7 +116,6 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src, ...@@ -117,7 +116,6 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
glamor_priv->state = BLIT_STATE; glamor_priv->state = BLIT_STATE;
return TRUE; return TRUE;
} }
#endif
static Bool static Bool
glamor_copy_n_to_n_textured(DrawablePtr src, glamor_copy_n_to_n_textured(DrawablePtr src,
...@@ -170,10 +168,10 @@ glamor_copy_n_to_n_textured(DrawablePtr src, ...@@ -170,10 +168,10 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, src_pixmap_priv->base.fbo->tex); glBindTexture(GL_TEXTURE_2D, src_pixmap_priv->base.fbo->tex);
#ifndef GLAMOR_GLES2 if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
#endif }
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);
...@@ -266,15 +264,14 @@ __glamor_copy_n_to_n(DrawablePtr src, ...@@ -266,15 +264,14 @@ __glamor_copy_n_to_n(DrawablePtr src,
box[0].x1, box[0].y1, box[0].x1, box[0].y1,
box[0].x2 - box[0].x1, box[0].y2 - box[0].y1, box[0].x2 - box[0].x1, box[0].y2 - box[0].y1,
dx, dy, src_pixmap, dst_pixmap); dx, dy, src_pixmap, dst_pixmap);
#ifndef GLAMOR_GLES2 if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP &&
if (!overlaped && !overlaped &&
(glamor_priv->state != RENDER_STATE (glamor_priv->state != RENDER_STATE
|| !src_pixmap_priv->base.gl_tex || !dst_pixmap_priv->base.gl_tex) || !src_pixmap_priv->base.gl_tex || !dst_pixmap_priv->base.gl_tex)
&& glamor_copy_n_to_n_fbo_blit(src, dst, gc, box, nbox, dx, dy)) { && glamor_copy_n_to_n_fbo_blit(src, dst, gc, box, nbox, dx, dy)) {
ret = TRUE; ret = TRUE;
goto done; goto done;
} }
#endif
glamor_calculate_boxes_bound(&bound, box, nbox); glamor_calculate_boxes_bound(&bound, box, nbox);
/* Overlaped indicate the src and dst are the same pixmap. */ /* Overlaped indicate the src and dst are the same pixmap. */
......
...@@ -240,13 +240,15 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color) ...@@ -240,13 +240,15 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
} }
if (box_cnt == 1) if (box_cnt == 1)
glDrawArrays(GL_TRIANGLE_FAN, 0, box_cnt * 4); glDrawArrays(GL_TRIANGLE_FAN, 0, box_cnt * 4);
else else {
#ifndef GLAMOR_GLES2 if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
glDrawRangeElements(GL_TRIANGLES, 0, box_cnt * 4, box_cnt * 6, glDrawRangeElements(GL_TRIANGLES, 0, box_cnt * 4, box_cnt * 6,
GL_UNSIGNED_SHORT, NULL); GL_UNSIGNED_SHORT, NULL);
#else } else {
glDrawElements(GL_TRIANGLES, box_cnt * 6, GL_UNSIGNED_SHORT, NULL); glDrawElements(GL_TRIANGLES, box_cnt * 6, GL_UNSIGNED_SHORT,
#endif NULL);
}
}
nbox -= box_cnt; nbox -= box_cnt;
box += box_cnt; box += box_cnt;
} }
......
...@@ -535,14 +535,16 @@ glamor_set_composite_texture(glamor_screen_private *glamor_priv, int unit, ...@@ -535,14 +535,16 @@ glamor_set_composite_texture(glamor_screen_private *glamor_priv, int unit,
repeat_type = picture->repeatType; repeat_type = picture->repeatType;
switch (picture->repeatType) { switch (picture->repeatType) {
case RepeatNone: case RepeatNone:
#ifndef GLAMOR_GLES2 if (glamor_priv->gl_flavor != GLAMOR_GL_ES2) {
/* XXX GLES2 doesn't support GL_CLAMP_TO_BORDER. */ /* XXX GLES2 doesn't support GL_CLAMP_TO_BORDER. */
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); GL_CLAMP_TO_BORDER);
#else glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } else {
#endif glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
break; break;
case RepeatNormal: case RepeatNormal:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
...@@ -807,14 +809,14 @@ glamor_flush_composite_rects(ScreenPtr screen) ...@@ -807,14 +809,14 @@ glamor_flush_composite_rects(ScreenPtr screen)
if (!glamor_priv->render_nr_verts) if (!glamor_priv->render_nr_verts)
return; return;
#ifndef GLAMOR_GLES2 if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
glDrawRangeElements(GL_TRIANGLES, 0, glamor_priv->render_nr_verts, glDrawRangeElements(GL_TRIANGLES, 0, glamor_priv->render_nr_verts,
(glamor_priv->render_nr_verts * 3) / 2, (glamor_priv->render_nr_verts * 3) / 2,
GL_UNSIGNED_SHORT, NULL); GL_UNSIGNED_SHORT, NULL);
#else } else {
glDrawElements(GL_TRIANGLES, (glamor_priv->render_nr_verts * 3) / 2, glDrawElements(GL_TRIANGLES, (glamor_priv->render_nr_verts * 3) / 2,
GL_UNSIGNED_SHORT, NULL); GL_UNSIGNED_SHORT, NULL);
#endif }
glamor_put_context(glamor_priv); glamor_put_context(glamor_priv);
} }
......
...@@ -1554,16 +1554,16 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture, ...@@ -1554,16 +1554,16 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
glamor_priv->vb, GL_DYNAMIC_DRAW); glamor_priv->vb, GL_DYNAMIC_DRAW);
} }
#ifndef GLAMOR_GLES2 if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
glDrawRangeElements(GL_TRIANGLES, 0, glDrawRangeElements(GL_TRIANGLES, 0,
glamor_priv->render_nr_verts, glamor_priv->render_nr_verts,
(glamor_priv->render_nr_verts * 3) / 2, (glamor_priv->render_nr_verts * 3) / 2,
GL_UNSIGNED_SHORT, NULL); GL_UNSIGNED_SHORT, NULL);
#else } else {
glDrawElements(GL_TRIANGLES, glDrawElements(GL_TRIANGLES,
(glamor_priv->render_nr_verts * 3) / 2, (glamor_priv->render_nr_verts * 3) / 2,
GL_UNSIGNED_SHORT, NULL); GL_UNSIGNED_SHORT, NULL);
#endif }
} }
glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment