xserver: Branch 'master' - 15 commits
Keith Packard
keithp at kemper.freedesktop.org
Thu Apr 3 13:12:35 PDT 2014
fb/fbpict.c | 4
fb/fbpict.h | 15 -
glamor/Makefile.am | 10
glamor/glamor.c | 24 +
glamor/glamor.h | 17 -
glamor/glamor_core.c | 14
glamor/glamor_fillspans.c | 107 -------
glamor/glamor_font.c | 186 +++++++++++++
glamor/glamor_font.h | 49 +++
glamor/glamor_getspans.c | 92 ------
glamor/glamor_glyphblt.c | 261 +++++++-----------
glamor/glamor_pixmap.c | 4
glamor/glamor_points.c | 21 +
glamor/glamor_polyfillrect.c | 123 --------
glamor/glamor_priv.h | 68 +++-
glamor/glamor_program.c | 18 -
glamor/glamor_rects.c | 189 +++++++++++++
glamor/glamor_setspans.c | 118 --------
glamor/glamor_spans.c | 438 ++++++++++++++++++++++++++++++
glamor/glamor_text.c | 526 +++++++++++++++++++++++++++++++++++++
glamor/glamor_transfer.c | 264 ++++++++++++++++++
glamor/glamor_transfer.h | 55 +++
glamor/glamor_xv.c | 14
hw/kdrive/ephyr/ephyr_glamor_glx.c | 1
24 files changed, 1948 insertions(+), 670 deletions(-)
New commits:
commit 3c34dd3603989c0365654ca1b6809395c7f3b169
Author: Keith Packard <keithp at keithp.com>
Date: Tue Apr 1 21:15:48 2014 -0700
glamor: Add glamor_program based poly_text and image_text
Accelerates text painting with GPU-based geometry computation and stippling
v2: Simplify get_glyphs, expand single character variable names to
more descriptive ones. (Markus Wick)
v3: Rebase against the glamor_prepare_* un-renaming (changes by anholt).
Improves x11perf -f8text by 417.908% +/- 11.0144% (n=10)
Signed-off-by: Keith Packard <keithp at keithp.com>
Signed-off-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Eric Anholt <eric at anholt.net>
diff --git a/glamor/Makefile.am b/glamor/Makefile.am
index dccd923..4d0cc81 100644
--- a/glamor/Makefile.am
+++ b/glamor/Makefile.am
@@ -12,6 +12,7 @@ libglamor_la_SOURCES = \
glamor_core.c \
glamor_debug.h \
glamor_fill.c \
+ glamor_font.c \
glamor_glx.c \
glamor_glyphs.c \
glamor_polylines.c \
@@ -22,6 +23,7 @@ libglamor_la_SOURCES = \
glamor_program.c \
glamor_rects.c \
glamor_spans.c \
+ glamor_text.c \
glamor_transfer.c \
glamor_transfer.h \
glamor_transform.c \
diff --git a/glamor/glamor.c b/glamor/glamor.c
index d7192c1..59548b7 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -424,6 +424,9 @@ glamor_init(ScreenPtr screen, unsigned int flags)
screen->CreateScreenResources;
screen->CreateScreenResources = glamor_create_screen_resources;
+ if (!glamor_font_init(screen))
+ goto fail;
+
if (flags & GLAMOR_USE_SCREEN) {
if (!RegisterBlockAndWakeupHandlers(_glamor_block_handler,
_glamor_wakeup_handler,
diff --git a/glamor/glamor.h b/glamor/glamor.h
index 2ff0409..5d988da 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -434,6 +434,20 @@ extern _X_EXPORT Bool glamor_poly_segment_nf(DrawablePtr pDrawable, GCPtr pGC,
extern _X_EXPORT Bool glamor_poly_lines_nf(DrawablePtr drawable, GCPtr gc,
int mode, int n, DDXPointPtr points);
+extern _X_EXPORT Bool glamor_poly_text8_nf(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, char *chars, int *final_pos);
+
+extern _X_EXPORT Bool glamor_poly_text16_nf(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, unsigned short *chars, int *final_pos);
+
+extern _X_EXPORT Bool glamor_image_text8_nf(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, char *chars);
+
+extern _X_EXPORT Bool glamor_image_text16_nf(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, unsigned short *chars);
+
+#define HAS_GLAMOR_TEXT 1
+
#ifdef GLAMOR_FOR_XORG
extern _X_EXPORT XF86VideoAdaptorPtr glamor_xv_init(ScreenPtr pScreen,
int num_texture_ports);
diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c
index cdf41ec..7b1615d 100644
--- a/glamor/glamor_core.c
+++ b/glamor/glamor_core.c
@@ -426,10 +426,10 @@ GCOps glamor_gc_ops = {
.FillPolygon = miFillPolygon,
.PolyFillRect = glamor_poly_fill_rect,
.PolyFillArc = miPolyFillArc,
- .PolyText8 = miPolyText8,
- .PolyText16 = miPolyText16,
- .ImageText8 = miImageText8,
- .ImageText16 = miImageText16,
+ .PolyText8 = glamor_poly_text8,
+ .PolyText16 = glamor_poly_text16,
+ .ImageText8 = glamor_image_text8,
+ .ImageText16 = glamor_image_text16,
.ImageGlyphBlt = miImageGlyphBlt,
.PolyGlyphBlt = glamor_poly_glyph_blt,
.PushPixels = glamor_push_pixels,
diff --git a/glamor/glamor_font.c b/glamor/glamor_font.c
new file mode 100644
index 0000000..47dfe2a
--- /dev/null
+++ b/glamor/glamor_font.c
@@ -0,0 +1,186 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include "glamor_priv.h"
+#include "glamor_font.h"
+#include <dixfontstr.h>
+
+static int glamor_font_generation;
+static int glamor_font_private_index;
+static int glamor_font_screen_count;
+
+glamor_font_t *
+glamor_font_get(ScreenPtr screen, FontPtr font)
+{
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+
+ glamor_font_t *privates;
+ glamor_font_t *glamor_font;
+ int overall_width, overall_height;
+ int num_rows;
+ int num_cols;
+ int glyph_width_pixels;
+ int glyph_width_bytes;
+ int glyph_height;
+ int row, col;
+ unsigned char c[2];
+ CharInfoPtr glyph;
+ unsigned long count;
+
+
+ privates = FontGetPrivate(font, glamor_font_private_index);
+ if (!privates) {
+ privates = calloc(glamor_font_screen_count, sizeof (glamor_font_t));
+ if (!privates)
+ return NULL;
+ FontSetPrivate(font, glamor_font_private_index, privates);
+ }
+
+ glamor_font = &privates[screen->myNum];
+
+ if (glamor_font->realized)
+ return glamor_font;
+
+ glamor_font->realized = TRUE;
+
+ /* Figure out how many glyphs are in the font */
+ num_cols = font->info.lastCol - font->info.firstCol + 1;
+ num_rows = font->info.lastRow - font->info.firstRow + 1;
+
+ /* Figure out the size of each glyph */
+ glyph_width_pixels = font->info.maxbounds.rightSideBearing - font->info.minbounds.leftSideBearing;
+ glyph_height = font->info.maxbounds.ascent + font->info.maxbounds.descent;
+
+ glyph_width_bytes = (glyph_width_pixels + 7) >> 3;
+
+ glamor_font->glyph_width_pixels = glyph_width_pixels;
+ glamor_font->glyph_width_bytes = glyph_width_bytes;
+ glamor_font->glyph_height = glyph_height;
+
+ overall_width = glyph_width_bytes * num_cols;
+ overall_height = glyph_height * num_rows;
+
+ /* Check whether the font has a default character */
+ c[0] = font->info.lastRow + 1;
+ c[1] = font->info.lastCol + 1;
+ (*font->get_glyphs)(font, 1, c, TwoD16Bit, &count, &glyph);
+
+ glamor_font->default_char = count ? glyph : NULL;
+ glamor_font->default_row = font->info.defaultCh >> 8;
+ glamor_font->default_col = font->info.defaultCh;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ glamor_get_context(glamor_priv);
+
+ glGenTextures(1, &glamor_font->texture_id);
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, glamor_font->texture_id);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+ /* Allocate storage */
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_R8UI, overall_width, overall_height,
+ 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, NULL);
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+
+ /* Paint all of the glyphs */
+ for (row = 0; row < num_rows; row++) {
+ for (col = 0; col < num_cols; col++) {
+ c[0] = row + font->info.firstRow;
+ c[1] = col + font->info.firstCol;
+
+ (*font->get_glyphs)(font, 1, c, TwoD16Bit, &count, &glyph);
+
+ if (count)
+ glTexSubImage2D(GL_TEXTURE_2D, 0, col * glyph_width_bytes, row * glyph_height,
+ GLYPHWIDTHBYTES(glyph), GLYPHHEIGHTPIXELS(glyph),
+ GL_RED_INTEGER, GL_UNSIGNED_BYTE, glyph->bits);
+ }
+ }
+
+ glamor_put_context(glamor_priv);
+
+ return glamor_font;
+}
+
+static Bool
+glamor_realize_font(ScreenPtr screen, FontPtr font)
+{
+ return TRUE;
+}
+
+static Bool
+glamor_unrealize_font(ScreenPtr screen, FontPtr font)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_font_t *privates = FontGetPrivate(font, glamor_font_private_index);
+ glamor_font_t *glamor_font;
+ int s;
+
+ if (!privates)
+ return TRUE;
+
+ glamor_font = &privates[screen->myNum];
+
+ if (!glamor_font->realized)
+ return TRUE;
+
+ /* Unrealize the font, freeing the allocated texture */
+ glamor_font->realized = FALSE;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ glamor_get_context(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
+ */
+ for (s = 0; s < glamor_font_screen_count; s++)
+ if (privates[s].realized)
+ return TRUE;
+
+ free(privates);
+ FontSetPrivate(font, glamor_font_private_index, NULL);
+ return TRUE;
+}
+
+Bool
+glamor_font_init(ScreenPtr screen)
+{
+ if (glamor_font_generation != serverGeneration) {
+ glamor_font_private_index = AllocateFontPrivateIndex();
+ if (glamor_font_private_index == -1)
+ return FALSE;
+ glamor_font_screen_count = 0;
+ glamor_font_generation = serverGeneration;
+ }
+
+ if (screen->myNum >= glamor_font_screen_count)
+ glamor_font_screen_count = screen->myNum + 1;
+
+ screen->RealizeFont = glamor_realize_font;
+ screen->UnrealizeFont = glamor_unrealize_font;
+ return TRUE;
+}
diff --git a/glamor/glamor_font.h b/glamor/glamor_font.h
new file mode 100644
index 0000000..36d2062
--- /dev/null
+++ b/glamor/glamor_font.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifndef _GLAMOR_FONT_H_
+#define _GLAMOR_FONT_H_
+
+typedef struct {
+ Bool realized;
+ CharInfoPtr default_char;
+ CARD8 default_row;
+ CARD8 default_col;
+
+ GLuint texture_id;
+
+ CARD16 glyph_width_bytes;
+ CARD16 glyph_width_pixels;
+ CARD16 glyph_height;
+
+} glamor_font_t;
+
+glamor_font_t *
+glamor_font_get(ScreenPtr screen, FontPtr font);
+
+Bool
+glamor_font_init(ScreenPtr screen);
+
+void
+glamor_fini_glyph_shader(ScreenPtr screen);
+
+#endif /* _GLAMOR_FONT_H_ */
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 2a8cae1..47f9efe 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -233,6 +233,11 @@ typedef struct glamor_screen_private {
/* glamor glyphblt shaders */
glamor_program_fill poly_glyph_blt_progs;
+ /* glamor text shaders */
+ glamor_program_fill poly_text_progs;
+ glamor_program te_text_prog;
+ glamor_program image_text_prog;
+
/* vertext/elment_index buffer object for render */
GLuint vbo, ebo;
/** Next offset within the VBO that glamor_get_vbo_space() will use. */
@@ -959,6 +964,19 @@ RegionPtr glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
int dstx, int dsty,
unsigned long bitPlane);
+/* glamor_text.c */
+int glamor_poly_text8(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, char *chars);
+
+int glamor_poly_text16(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, unsigned short *chars);
+
+void glamor_image_text8(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, char *chars);
+
+void glamor_image_text16(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, unsigned short *chars);
+
/* glamor_spans.c */
void
glamor_fill_spans(DrawablePtr drawable,
@@ -1051,4 +1069,6 @@ void glamor_fini_xv_shader(ScreenPtr screen);
//#define GLYPHS_NO_EDEGEMAP_OVERLAP_CHECK
#define GLYPHS_EDEGE_OVERLAP_LOOSE_CHECK
+#include "glamor_font.h"
+
#endif /* GLAMOR_PRIV_H */
diff --git a/glamor/glamor_text.c b/glamor/glamor_text.c
new file mode 100644
index 0000000..0e4b74c
--- /dev/null
+++ b/glamor/glamor_text.c
@@ -0,0 +1,526 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include "glamor_priv.h"
+#include <dixfontstr.h>
+#include "glamor_transform.h"
+
+/*
+ * Fill in the array of charinfo pointers for the provided characters. For
+ * missing characters, place a NULL in the array so that the charinfo array
+ * aligns exactly with chars
+ */
+
+static void
+glamor_get_glyphs(FontPtr font, glamor_font_t *glamor_font,
+ int count, char *chars, Bool sixteen, CharInfoPtr *charinfo)
+{
+ unsigned long nglyphs;
+ FontEncoding encoding;
+ int char_step;
+
+ if (sixteen) {
+ char_step = 2;
+ if (FONTLASTROW(font) == 0)
+ encoding = Linear16Bit;
+ else
+ encoding = TwoD16Bit;
+ } else {
+ char_step = 1;
+ encoding = Linear8Bit;
+ }
+
+ /* If the font has a default character, then we don't have to
+ * worry about missing glyphs, so just get the whole string all at
+ * once. Otherwise, we have to fetch chars one at a time to notice
+ * missing ones.
+ */
+ if (glamor_font->default_char) {
+ GetGlyphs(font, (unsigned long) count, (unsigned char *) chars,
+ encoding, &nglyphs, charinfo);
+ } else {
+ int c;
+ for (c = 0; c < count; c++) {
+ GetGlyphs(font, 1, (unsigned char *) chars,
+ encoding, &nglyphs, &charinfo[c]);
+ if (!nglyphs)
+ charinfo[c] = NULL;
+ chars += char_step;
+ }
+ }
+}
+
+/*
+ * Construct quads for the provided list of characters and draw them
+ */
+
+static int
+glamor_text(DrawablePtr drawable, GCPtr gc,
+ glamor_font_t *glamor_font,
+ glamor_program *prog,
+ int x, int y,
+ int count, char *s_chars, CharInfoPtr *charinfo,
+ Bool sixteen)
+{
+ unsigned char *chars = (unsigned char *) s_chars;
+ FontPtr font = gc->font;
+ int off_x, off_y;
+ int c;
+ int nglyph;
+ GLshort *v;
+ char *vbo_offset;
+ CharInfoPtr ci;
+ int firstRow = font->info.firstRow;
+ int firstCol = font->info.firstCol;
+ int glyph_spacing_x = glamor_font->glyph_width_bytes * 8;
+ int glyph_spacing_y = glamor_font->glyph_height;
+ int box_x, box_y;
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
+
+ /* Set the font as texture 1 */
+
+ glActiveTexture(GL_TEXTURE1);
+ glBindTexture(GL_TEXTURE_2D, glamor_font->texture_id);
+ glUniform1i(prog->font_uniform, 1);
+
+ /* Set up the vertex buffers for the font and destination */
+
+ v = glamor_get_vbo_space(drawable->pScreen, count * (6 * sizeof (GLshort)), &vbo_offset);
+
+ glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+ glVertexAttribDivisor(GLAMOR_VERTEX_POS, 1);
+ glVertexAttribPointer(GLAMOR_VERTEX_POS, 4, GL_SHORT, GL_FALSE,
+ 6 * sizeof (GLshort), vbo_offset);
+
+ glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+ glVertexAttribDivisor(GLAMOR_VERTEX_SOURCE, 1);
+ glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_SHORT, GL_FALSE,
+ 6 * sizeof (GLshort), vbo_offset + 4 * sizeof (GLshort));
+
+ /* Set the vertex coordinates */
+ nglyph = 0;
+
+ for (c = 0; c < count; c++) {
+ if ((ci = *charinfo++)) {
+ int x1 = x + ci->metrics.leftSideBearing;
+ int y1 = y - ci->metrics.ascent;
+ int width = GLYPHWIDTHPIXELS(ci);
+ int height = GLYPHHEIGHTPIXELS(ci);
+ int tx, ty = 0;
+ int row = 0, col;
+
+ x += ci->metrics.characterWidth;
+
+ if (sixteen) {
+ if (ci == glamor_font->default_char) {
+ row = glamor_font->default_row;
+ col = glamor_font->default_col;
+ } else {
+ row = chars[0];
+ col = chars[1];
+ }
+ if (FONTLASTROW(font) != 0)
+ ty = (row - firstRow) * glyph_spacing_y;
+ else
+ col += row << 8;
+ } else {
+ if (ci == glamor_font->default_char)
+ col = glamor_font->default_col;
+ else
+ col = chars[0];
+ }
+
+ tx = (col - firstCol) * glyph_spacing_x;
+
+ v[ 0] = x1;
+ v[ 1] = y1;
+ v[ 2] = width;
+ v[ 3] = height;
+ v[ 4] = tx;
+ v[ 5] = ty;
+
+ v += 6;
+ nglyph++;
+ }
+ chars += 1 + sixteen;
+ }
+ glamor_put_vbo_space(drawable->pScreen);
+
+ if (nglyph != 0) {
+
+ glEnable(GL_SCISSOR_TEST);
+
+ glamor_pixmap_loop(pixmap_priv, box_x, box_y) {
+ BoxPtr box = RegionRects(gc->pCompositeClip);
+ int nbox = RegionNumRects(gc->pCompositeClip);
+
+ glamor_set_destination_drawable(drawable, box_x, box_y, TRUE, FALSE, prog->matrix_uniform, &off_x, &off_y);
+
+ /* Run over the clip list, drawing the glyphs
+ * in each box
+ */
+
+ while (nbox--) {
+ glScissor(box->x1 + off_x,
+ box->y1 + off_y,
+ box->x2 - box->x1,
+ box->y2 - box->y1);
+ box++;
+ glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, nglyph);
+ }
+ }
+ glDisable(GL_SCISSOR_TEST);
+ }
+
+ glVertexAttribDivisor(GLAMOR_VERTEX_SOURCE, 0);
+ glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+ glVertexAttribDivisor(GLAMOR_VERTEX_POS, 0);
+ glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+ glDisable(GL_COLOR_LOGIC_OP);
+
+ return x;
+}
+
+static const char vs_vars_text[] =
+ "attribute vec4 primitive;\n"
+ "attribute vec2 source;\n"
+ "varying vec2 glyph_pos;\n";
+
+static const char vs_exec_text[] =
+ " vec2 pos = primitive.zw * vec2(gl_VertexID&1, (gl_VertexID&2)>>1);\n"
+ GLAMOR_POS(gl_Position, (primitive.xy + pos))
+ " glyph_pos = source + pos;\n";
+
+static const char fs_vars_text[] =
+ "varying vec2 glyph_pos;\n";
+
+static const char fs_exec_text[] =
+ " ivec2 itile_texture = ivec2(glyph_pos);\n"
+ " uint x = uint(itile_texture.x & 7);\n"
+ " itile_texture.x >>= 3;\n"
+ " uint texel = texelFetch(font, itile_texture, 0).x;\n"
+ " uint bit = (texel >> x) & uint(1);\n"
+ " if (bit == uint(0))\n"
+ " discard;\n";
+
+static const char fs_exec_te[] =
+ " ivec2 itile_texture = ivec2(glyph_pos);\n"
+ " uint x = uint(itile_texture.x & 7);\n"
+ " itile_texture.x >>= 3;\n"
+ " uint texel = texelFetch(font, itile_texture, 0).x;\n"
+ " uint bit = (texel >> x) & uint(1);\n"
+ " if (bit == uint(0))\n"
+ " gl_FragColor = bg;\n"
+ " else\n"
+ " gl_FragColor = fg;\n";
+
+static const glamor_facet glamor_facet_poly_text = {
+ .name = "poly_text",
+ .version = 130,
+ .vs_vars = vs_vars_text,
+ .vs_exec = vs_exec_text,
+ .fs_vars = fs_vars_text,
+ .fs_exec = fs_exec_text,
+ .source_name = "source",
+ .locations = glamor_program_location_font,
+};
+
+static Bool
+glamor_poly_text(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, char *chars, Bool sixteen, int *final_pos)
+{
+ ScreenPtr screen = drawable->pScreen;
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_program *prog;
+ glamor_pixmap_private *pixmap_priv;
+ glamor_font_t *glamor_font;
+ CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */
+
+ glamor_font = glamor_font_get(drawable->pScreen, gc->font);
+ if (!glamor_font)
+ goto bail;
+
+ glamor_get_glyphs(gc->font, glamor_font, count, chars, sixteen, charinfo);
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ goto bail;
+
+ glamor_get_context(glamor_priv);
+
+ prog = glamor_use_program_fill(pixmap, gc, &glamor_priv->poly_text_progs, &glamor_facet_poly_text);
+
+ if (!prog)
+ goto bail_ctx;
+
+ x = glamor_text(drawable, gc, glamor_font, prog,
+ x, y, count, chars, charinfo, sixteen);
+
+ glDisable(GL_COLOR_LOGIC_OP);
+
+ glamor_put_context(glamor_priv);
+
+ glamor_priv->state = RENDER_STATE;
+ glamor_priv->render_idle_cnt = 0;
+
+ *final_pos = x;
+ return TRUE;
+
+bail_ctx:
+ glDisable(GL_COLOR_LOGIC_OP);
+ glamor_put_context(glamor_priv);
+bail:
+ return FALSE;
+}
+
+Bool
+glamor_poly_text8_nf(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, char *chars, int *final_pos)
+{
+ if (glamor_poly_text(drawable, gc, x, y, count, chars, FALSE, final_pos))
+ return TRUE;
+ if (glamor_ddx_fallback_check_pixmap(drawable) && glamor_ddx_fallback_check_gc(gc))
+ return FALSE;
+ *final_pos = miPolyText8(drawable, gc, x, y, count, chars);
+ return TRUE;
+}
+
+int
+glamor_poly_text8(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, char *chars)
+{
+ int final_pos;
+
+ if (glamor_poly_text(drawable, gc, x, y, count, chars, FALSE, &final_pos))
+ return final_pos;
+ return miPolyText8(drawable, gc, x, y, count, chars);
+}
+
+Bool
+glamor_poly_text16_nf(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, unsigned short *chars, int *final_pos)
+{
+ if (glamor_poly_text(drawable, gc, x, y, count, (char *) chars, TRUE, final_pos))
+ return TRUE;
+
+ if (glamor_ddx_fallback_check_pixmap(drawable) && glamor_ddx_fallback_check_gc(gc))
+ return FALSE;
+ *final_pos = miPolyText16(drawable, gc, x, y, count, chars);
+ return TRUE;
+}
+
+int
+glamor_poly_text16(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, unsigned short *chars)
+{
+ int final_pos;
+
+ if (glamor_poly_text(drawable, gc, x, y, count, (char *) chars, TRUE, &final_pos))
+ return final_pos;
+ return miPolyText16(drawable, gc, x, y, count, chars);
+}
+
+/*
+ * Draw image text, which is always solid in copy mode and has the
+ * background cleared while painting the text. For fonts which have
+ * their bitmap metrics exactly equal to the area to clear, we can use
+ * the accelerated version which paints both fg and bg at the same
+ * time. Otherwise, clear the whole area and then paint the glyphs on
+ * top
+ */
+
+static const glamor_facet glamor_facet_image_text = {
+ .name = "image_text",
+ .version = 130,
+ .vs_vars = vs_vars_text,
+ .vs_exec = vs_exec_text,
+ .fs_vars = fs_vars_text,
+ .fs_exec = fs_exec_text,
+ .source_name = "source",
+ .locations = glamor_program_location_font,
+};
+
+static Bool
+use_image_solid(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg)
+{
+ return glamor_set_solid(pixmap, gc, FALSE, prog->fg_uniform);
+}
+
+static const glamor_facet glamor_facet_image_fill = {
+ .name = "solid",
+ .fs_exec = " gl_FragColor = fg;\n",
+ .locations = glamor_program_location_fg,
+ .use = use_image_solid,
+};
+
+static Bool
+glamor_te_text_use(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg)
+{
+ if (!glamor_set_solid(pixmap, gc, FALSE, prog->fg_uniform))
+ return FALSE;
+ glamor_set_color(pixmap, gc->bgPixel, prog->bg_uniform);
+ return TRUE;
+}
+
+static const glamor_facet glamor_facet_te_text = {
+ .name = "te_text",
+ .version = 130,
+ .vs_vars = vs_vars_text,
+ .vs_exec = vs_exec_text,
+ .fs_vars = fs_vars_text,
+ .fs_exec = fs_exec_te,
+ .locations = glamor_program_location_fg | glamor_program_location_bg | glamor_program_location_font,
+ .source_name = "source",
+ .use = glamor_te_text_use,
+};
+
+static Bool
+glamor_image_text(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, char *chars,
+ Bool sixteen)
+{
+ ScreenPtr screen = drawable->pScreen;
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_program *prog;
+ glamor_pixmap_private *pixmap_priv;
+ glamor_font_t *glamor_font;
+ const glamor_facet *prim_facet;
+ const glamor_facet *fill_facet;
+ CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ return FALSE;
+
+ glamor_font = glamor_font_get(drawable->pScreen, gc->font);
+ if (!glamor_font)
+ return FALSE;
+
+ glamor_get_glyphs(gc->font, glamor_font, count, chars, sixteen, charinfo);
+
+ glamor_get_context(glamor_priv);
+
+ if (TERMINALFONT(gc->font))
+ prog = &glamor_priv->te_text_prog;
+ else
+ prog = &glamor_priv->image_text_prog;
+
+ if (prog->failed)
+ goto bail;
+
+ if (!prog->prog) {
+ if (TERMINALFONT(gc->font)) {
+ prim_facet = &glamor_facet_te_text;
+ fill_facet = NULL;
+ } else {
+ prim_facet = &glamor_facet_image_text;
+ fill_facet = &glamor_facet_image_fill;
+ }
+
+ if (!glamor_build_program(screen, prog, prim_facet, fill_facet))
+ goto bail;
+ }
+
+ if (!TERMINALFONT(gc->font)) {
+ int width = 0;
+ int c;
+ RegionRec region;
+ BoxRec box;
+ int off_x, off_y;
+
+ /* Check planemask before drawing background to
+ * bail early if it's not OK
+ */
+ if (!glamor_set_planemask(pixmap, gc->planemask))
+ goto bail;
+ for (c = 0; c < count; c++)
+ if (charinfo[c])
+ width += charinfo[c]->metrics.characterWidth;
+
+ glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y);
+
+ if (width >= 0) {
+ box.x1 = off_x + drawable->x + x;
+ box.x2 = off_x + drawable->x + x + width;
+ } else {
+ box.x1 = off_x + drawable->x + x + width;
+ box.x2 = off_x + drawable->x + x;
+ }
+ box.y1 = off_y + drawable->y + y - gc->font->info.fontAscent;
+ box.y2 = off_y + drawable->y + y + gc->font->info.fontDescent;
+ RegionInit(®ion, &box, 1);
+ RegionIntersect(®ion, ®ion, gc->pCompositeClip);
+ glamor_solid_boxes(pixmap, RegionRects(®ion), RegionNumRects(®ion), gc->bgPixel);
+ RegionUninit(®ion);
+ }
+
+ if (!glamor_use_program(pixmap, gc, prog, NULL))
+ goto bail;
+
+ (void) glamor_text(drawable, gc, glamor_font, prog,
+ x, y, count, chars, charinfo, sixteen);
+
+ glamor_put_context(glamor_priv);
+
+ glamor_priv->state = RENDER_STATE;
+ glamor_priv->render_idle_cnt = 0;
+
+ return TRUE;
+
+bail:
+ glDisable(GL_COLOR_LOGIC_OP);
+ glamor_put_context(glamor_priv);
+ return FALSE;
+}
+
+Bool
+glamor_image_text8_nf(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, char *chars)
+{
+ return glamor_image_text(drawable, gc, x, y, count, chars, FALSE);
+}
+
+void
+glamor_image_text8(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, char *chars)
+{
+ if (!glamor_image_text(drawable, gc, x, y, count, chars, FALSE))
+ miImageText8(drawable, gc, x, y, count, chars);
+}
+
+Bool
+glamor_image_text16_nf(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, unsigned short *chars)
+{
+ return glamor_image_text(drawable, gc, x, y, count, (char *) chars, FALSE);
+}
+
+void
+glamor_image_text16(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, unsigned short *chars)
+{
+ if (!glamor_image_text(drawable, gc, x, y, count, (char *) chars, TRUE))
+ miImageText16(drawable, gc, x, y, count, chars);
+}
commit 5f700c3ac31db52f02f6ef11ea7823a8ce4f6f6f
Author: Keith Packard <keithp at keithp.com>
Date: Tue Apr 1 21:15:47 2014 -0700
glamor: Use glamor_program for glamor_glyphblt
This constructs suitable shaders using the glamor_program
infrastructure for poly glyph blt, and then gets rid of the no-op
wrapper of miImageGlyphBlt.
Improves x11perf -f8text by 11.6221% +/- 1.04585% (n=10)
Signed-off-by: Keith Packard <keithp at keithp.com>
Signed-off-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Eric Anholt <eric at anholt.net>
diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c
index 5711be7..cdf41ec 100644
--- a/glamor/glamor_core.c
+++ b/glamor/glamor_core.c
@@ -430,9 +430,9 @@ GCOps glamor_gc_ops = {
.PolyText16 = miPolyText16,
.ImageText8 = miImageText8,
.ImageText16 = miImageText16,
- .ImageGlyphBlt = glamor_image_glyph_blt, //miImageGlyphBlt,
- .PolyGlyphBlt = glamor_poly_glyph_blt, //miPolyGlyphBlt,
- .PushPixels = glamor_push_pixels, //miPushPixels,
+ .ImageGlyphBlt = miImageGlyphBlt,
+ .PolyGlyphBlt = glamor_poly_glyph_blt,
+ .PushPixels = glamor_push_pixels,
};
/**
diff --git a/glamor/glamor_glyphblt.c b/glamor/glamor_glyphblt.c
index a58cef9..c031747 100644
--- a/glamor/glamor_glyphblt.c
+++ b/glamor/glamor_glyphblt.c
@@ -28,203 +28,156 @@
#include "glamor_priv.h"
#include <dixfontstr.h>
+#include "glamor_transform.h"
+
+static const glamor_facet glamor_facet_poly_glyph_blt = {
+ .name = "poly_glyph_blt",
+ .vs_vars = "attribute vec2 primitive;\n",
+ .vs_exec = (" vec2 pos = vec2(0,0);\n"
+ GLAMOR_POS(gl_Position, primitive)),
+};
static Bool
-glamor_poly_glyph_blt_pixels(DrawablePtr drawable, GCPtr gc,
- int x, int y, unsigned int nglyph,
- CharInfoPtr *ppci)
+glamor_poly_glyph_blt_gl(DrawablePtr drawable, GCPtr gc,
+ int start_x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, void *pglyph_base)
{
ScreenPtr screen = drawable->pScreen;
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
glamor_pixmap_private *pixmap_priv;
- int off_x, off_y;
- GLfloat xscale, yscale;
- float color[4];
- unsigned long fg_pixel = gc->fgPixel;
- char *vbo_offset;
- RegionPtr clip;
- int num_points, max_points;
- float *points = NULL;
-
- x += drawable->x;
- y += drawable->y;
-
- if (gc->fillStyle != FillSolid) {
- glamor_fallback("gc fillstyle not solid\n");
- return FALSE;
- }
+ glamor_program *prog;
+ RegionPtr clip = gc->pCompositeClip;
+ int box_x, box_y;
pixmap_priv = glamor_get_pixmap_private(pixmap);
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
- return FALSE;
+ goto bail;
glamor_get_context(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;
- }
-
- glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y);
-
- glamor_set_destination_pixmap_priv_nc(pixmap_priv);
- pixmap_priv_get_dest_scale(pixmap_priv, &xscale, &yscale);
-
- glUseProgram(glamor_priv->solid_prog);
- glamor_get_rgba_from_pixel(fg_pixel,
- &color[0], &color[1], &color[2], &color[3],
- format_for_pixmap(pixmap));
- glUniform4fv(glamor_priv->solid_color_uniform_location, 1, color);
-
- clip = fbGetCompositeClip(gc);
+ prog = glamor_use_program_fill(pixmap, gc, &glamor_priv->poly_glyph_blt_progs,
+ &glamor_facet_poly_glyph_blt);
+ if (!prog)
+ goto bail_ctx;
glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
- max_points = 500;
- num_points = 0;
- while (nglyph--) {
- CharInfoPtr charinfo = *ppci++;
- int w = GLYPHWIDTHPIXELS(charinfo);
- int h = GLYPHHEIGHTPIXELS(charinfo);
- uint8_t *glyphbits = FONTGLYPHBITS(NULL, charinfo);
-
- if (w && h) {
- int glyph_x = x + charinfo->metrics.leftSideBearing;
- int glyph_y = y - charinfo->metrics.ascent;
- int glyph_stride = GLYPHWIDTHBYTESPADDED(charinfo);
- int xx, yy;
-
- for (yy = 0; yy < h; yy++) {
- uint8_t *glyph_row = glyphbits + glyph_stride * yy;
- for (xx = 0; xx < w; xx++) {
- int pt_x_i = glyph_x + xx;
- int pt_y_i = glyph_y + yy;
- float pt_x_f, pt_y_f;
- if (!(glyph_row[xx / 8] & (1 << xx % 8)))
- continue;
-
- if (!RegionContainsPoint(clip, pt_x_i, pt_y_i, NULL))
- continue;
-
- if (!num_points) {
- points = glamor_get_vbo_space(screen,
- max_points * 2 * sizeof(float),
- &vbo_offset);
-
- glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
- GL_FALSE, 2 * sizeof(float),
- vbo_offset);
- }
-
- pt_x_f = v_from_x_coord_x(xscale, pt_x_i + off_x + 0.5);
- if (glamor_priv->yInverted)
- pt_y_f = v_from_x_coord_y_inverted(yscale, pt_y_i + off_y + 0.5);
- else
- pt_y_f = v_from_x_coord_y(yscale, pt_y_i + off_y + 0.5);
-
- points[num_points * 2 + 0] = pt_x_f;
- points[num_points * 2 + 1] = pt_y_f;
- num_points++;
+ start_x += drawable->x;
+ y += drawable->y;
- if (num_points == max_points) {
- glamor_put_vbo_space(screen);
- glDrawArrays(GL_POINTS, 0, num_points);
- num_points = 0;
+ glamor_pixmap_loop(pixmap_priv, box_x, box_y) {
+ int x;
+ int n;
+ int num_points, max_points;
+ INT16 *points = NULL;
+ int off_x, off_y;
+ char *vbo_offset;
+
+ glamor_set_destination_drawable(drawable, box_x, box_y, FALSE, TRUE, prog->matrix_uniform, &off_x, &off_y);
+
+ max_points = 500;
+ num_points = 0;
+ x = start_x;
+ for (n = 0; n < nglyph; n++) {
+ CharInfoPtr charinfo = ppci[n];
+ int w = GLYPHWIDTHPIXELS(charinfo);
+ int h = GLYPHHEIGHTPIXELS(charinfo);
+ uint8_t *glyphbits = FONTGLYPHBITS(NULL, charinfo);
+
+ if (w && h) {
+ int glyph_x = x + charinfo->metrics.leftSideBearing;
+ int glyph_y = y - charinfo->metrics.ascent;
+ int glyph_stride = GLYPHWIDTHBYTESPADDED(charinfo);
+ int xx, yy;
+
+ for (yy = 0; yy < h; yy++) {
+ uint8_t *glyph = glyphbits;
+ for (xx = 0; xx < w; glyph += ((xx&7) == 7), xx++) {
+ int pt_x_i = glyph_x + xx;
+ int pt_y_i = glyph_y + yy;
+
+ if (!(*glyph & (1 << (xx & 7))))
+ continue;
+
+ if (!RegionContainsPoint(clip, pt_x_i, pt_y_i, NULL))
+ continue;
+
+ if (!num_points) {
+ points = glamor_get_vbo_space(screen,
+ max_points * (2 * sizeof (INT16)),
+ &vbo_offset);
+
+ glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_SHORT,
+ GL_FALSE, 0, vbo_offset);
+ }
+
+ *points++ = pt_x_i;
+ *points++ = pt_y_i;
+ num_points++;
+
+ if (num_points == max_points) {
+ glamor_put_vbo_space(screen);
+ glDrawArrays(GL_POINTS, 0, num_points);
+ num_points = 0;
+ }
}
+ glyphbits += glyph_stride;
}
}
+ x += charinfo->metrics.characterWidth;
}
- x += charinfo->metrics.characterWidth;
- }
-
- if (num_points) {
- glamor_put_vbo_space(screen);
- glDrawArrays(GL_POINTS, 0, num_points);
+ if (num_points) {
+ glamor_put_vbo_space(screen);
+ glDrawArrays(GL_POINTS, 0, num_points);
+ }
}
+ glDisable(GL_COLOR_LOGIC_OP);
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
glamor_put_context(glamor_priv);
-
- return TRUE;
-}
-
-static Bool
-_glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
- int x, int y, unsigned int nglyph,
- CharInfoPtr *ppci, void *pglyphBase, Bool fallback)
-{
- if (!fallback && glamor_ddx_fallback_check_pixmap(pDrawable)
- && glamor_ddx_fallback_check_gc(pGC))
- return FALSE;
-
- miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
return TRUE;
+bail_ctx:
+ glDisable(GL_COLOR_LOGIC_OP);
+ glamor_put_context(glamor_priv);
+bail:
+ return FALSE;
}
void
-glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
- int x, int y, unsigned int nglyph,
- CharInfoPtr *ppci, void *pglyphBase)
+glamor_poly_glyph_blt(DrawablePtr drawable, GCPtr gc,
+ int start_x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, void *pglyph_base)
{
- _glamor_image_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase,
- TRUE);
+ if (glamor_poly_glyph_blt_gl(drawable, gc, start_x, y, nglyph, ppci, pglyph_base))
+ return;
+ miPolyGlyphBlt(drawable, gc, start_x, y, nglyph,
+ ppci, pglyph_base);
}
Bool
-glamor_image_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
- int x, int y, unsigned int nglyph,
- CharInfoPtr *ppci, void *pglyphBase)
-{
- return _glamor_image_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci,
- pglyphBase, FALSE);
-}
-
-static Bool
-_glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
- int x, int y, unsigned int nglyph,
- CharInfoPtr *ppci, void *pglyphBase, Bool fallback)
+glamor_poly_glyph_blt_nf(DrawablePtr drawable, GCPtr gc,
+ int start_x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, void *pglyph_base)
{
- if (glamor_poly_glyph_blt_pixels(pDrawable, pGC, x, y, nglyph, ppci))
+ if (glamor_poly_glyph_blt_gl(drawable, gc, start_x, y, nglyph, ppci, pglyph_base))
return TRUE;
-
- if (!fallback && glamor_ddx_fallback_check_pixmap(pDrawable)
- && glamor_ddx_fallback_check_gc(pGC))
+ if (glamor_ddx_fallback_check_pixmap(drawable) && glamor_ddx_fallback_check_gc(gc))
return FALSE;
-
- miPolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ miPolyGlyphBlt(drawable, gc, start_x, y, nglyph,
+ ppci, pglyph_base);
return TRUE;
}
-void
-glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
- int x, int y, unsigned int nglyph,
- CharInfoPtr *ppci, void *pglyphBase)
-{
- _glamor_poly_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase,
- TRUE);
-}
-
Bool
-glamor_poly_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
- int x, int y, unsigned int nglyph,
- CharInfoPtr *ppci, void *pglyphBase)
+glamor_image_glyph_blt_nf(DrawablePtr drawable, GCPtr gc,
+ int start_x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, void *pglyph_base)
{
- return _glamor_poly_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci,
- pglyphBase, FALSE);
+ miImageGlyphBlt(drawable, gc, start_x, y, nglyph, ppci, pglyph_base);
+ return TRUE;
}
static Bool
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 74bb789..2a8cae1 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -230,6 +230,9 @@ typedef struct glamor_screen_private {
/* glamor rect shaders */
glamor_program_fill poly_fill_rect_program;
+ /* glamor glyphblt shaders */
+ glamor_program_fill poly_glyph_blt_progs;
+
/* vertext/elment_index buffer object for render */
GLuint vbo, ebo;
/** Next offset within the VBO that glamor_get_vbo_space() will use. */
commit 3411e8c538476443cafbb70082ef7457932e4a38
Author: Keith Packard <keithp at keithp.com>
Date: Tue Apr 1 21:15:46 2014 -0700
glamor: Add glamor_program based poly_fill_rect
This accelerates poly_fill_rect using GPU-based geometry computation
Improves x11perf -rect100 by 41.5127% +/- 7.63888% (n=10)
Improves x11perf -rect10 by 3745.72% +/- 94.7503% (n=6)
v2: Rebase on skipping the prepare rewrite for now, and fix the GLSL
1.20 and GLES2 cases (changes by anholt).
Signed-off-by: Keith Packard <keithp at keithp.com>
Signed-off-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Eric Anholt <eric at anholt.net>
diff --git a/glamor/Makefile.am b/glamor/Makefile.am
index 4be9f34..dccd923 100644
--- a/glamor/Makefile.am
+++ b/glamor/Makefile.am
@@ -14,13 +14,13 @@ libglamor_la_SOURCES = \
glamor_fill.c \
glamor_glx.c \
glamor_glyphs.c \
- glamor_polyfillrect.c \
glamor_polylines.c \
glamor_putimage.c \
glamor_segment.c \
glamor_render.c \
glamor_gradient.c \
glamor_program.c \
+ glamor_rects.c \
glamor_spans.c \
glamor_transfer.c \
glamor_transfer.h \
diff --git a/glamor/glamor_polyfillrect.c b/glamor/glamor_polyfillrect.c
deleted file mode 100644
index 1e361a4..0000000
--- a/glamor/glamor_polyfillrect.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright © 2009 Intel Corporation
- * Copyright © 1998 Keith Packard
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- *
- * Authors:
- * Eric Anholt <eric at anholt.net>
- *
- */
-
-#include "glamor_priv.h"
-
-/** @file glamor_fillspans.c
- *
- * GC PolyFillRect implementation, taken straight from fb_fill.c
- */
-
-static Bool
-_glamor_poly_fill_rect(DrawablePtr drawable,
- GCPtr gc, int nrect, xRectangle *prect, Bool fallback)
-{
- int fullX1, fullX2, fullY1, fullY2;
- int xorg, yorg;
- int n;
- register BoxPtr pbox;
- RegionPtr pClip = fbGetCompositeClip(gc);
- Bool ret = FALSE;
-
- xorg = drawable->x;
- yorg = drawable->y;
-
- while (nrect--) {
- fullX1 = prect->x + xorg;
- fullY1 = prect->y + yorg;
- fullX2 = fullX1 + (int) prect->width;
- fullY2 = fullY1 + (int) prect->height;
-
- n = REGION_NUM_RECTS(pClip);
- pbox = REGION_RECTS(pClip);
- /*
- * clip the rectangle to each box in the clip region
- * this is logically equivalent to calling Intersect(),
- * but rectangles may overlap each other here.
- */
- while (n--) {
- int x1 = fullX1;
- int x2 = fullX2;
- int y1 = fullY1;
- int y2 = fullY2;
-
- if (pbox->x1 > x1)
- x1 = pbox->x1;
- if (pbox->x2 < x2)
- x2 = pbox->x2;
- if (pbox->y1 > y1)
- y1 = pbox->y1;
- if (pbox->y2 < y2)
- y2 = pbox->y2;
-
- pbox++;
- if (x1 >= x2 || y1 >= y2)
- continue;
- if (!glamor_fill(drawable, gc, x1, y1, x2 - x1, y2 - y1, fallback)) {
- nrect++;
- goto fail;
- }
- }
- prect++;
- }
- ret = TRUE;
- goto done;
-
- fail:
-
- if (!fallback && glamor_ddx_fallback_check_pixmap(drawable)
- && glamor_ddx_fallback_check_gc(gc))
- goto done;
-
- glamor_fallback(" to %p (%c)\n",
- drawable, glamor_get_drawable_location(drawable));
- if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) &&
- glamor_prepare_access_gc(gc)) {
- fbPolyFillRect(drawable, gc, nrect, prect);
- }
- glamor_finish_access_gc(gc);
- glamor_finish_access(drawable);
- ret = TRUE;
-
- done:
- return ret;
-}
-
-void
-glamor_poly_fill_rect(DrawablePtr drawable,
- GCPtr gc, int nrect, xRectangle *prect)
-{
- _glamor_poly_fill_rect(drawable, gc, nrect, prect, TRUE);
-}
-
-Bool
-glamor_poly_fill_rect_nf(DrawablePtr drawable,
- GCPtr gc, int nrect, xRectangle *prect)
-{
- return _glamor_poly_fill_rect(drawable, gc, nrect, prect, FALSE);
-}
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 430ca59..74bb789 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -227,6 +227,9 @@ typedef struct glamor_screen_private {
/* glamor spans shaders */
glamor_program_fill fill_spans_program;
+ /* glamor rect shaders */
+ glamor_program_fill poly_fill_rect_program;
+
/* vertext/elment_index buffer object for render */
GLuint vbo, ebo;
/** Next offset within the VBO that glamor_get_vbo_space() will use. */
@@ -691,10 +694,6 @@ void glamor_glyphs(CARD8 op,
INT16 xSrc,
INT16 ySrc, int nlist, GlyphListPtr list, GlyphPtr *glyphs);
-/* glamor_polyfillrect.c */
-void glamor_poly_fill_rect(DrawablePtr drawable,
- GCPtr gc, int nrect, xRectangle *prect);
-
/* glamor_polylines.c */
void glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
DDXPointPtr points);
@@ -971,6 +970,11 @@ void
glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
DDXPointPtr points, int *widths, int numPoints, int sorted);
+/* glamor_rects.c */
+void
+glamor_poly_fill_rect(DrawablePtr drawable,
+ GCPtr gc, int nrect, xRectangle *prect);
+
/* glamor_glyphblt.c */
void glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
int x, int y, unsigned int nglyph,
diff --git a/glamor/glamor_rects.c b/glamor/glamor_rects.c
new file mode 100644
index 0000000..7731ede
--- /dev/null
+++ b/glamor/glamor_rects.c
@@ -0,0 +1,189 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include "glamor_priv.h"
+#include "glamor_program.h"
+#include "glamor_transform.h"
+
+static const glamor_facet glamor_facet_polyfillrect_130 = {
+ .name = "poly_fill_rect",
+ .version = 130,
+ .vs_vars = "attribute vec4 primitive;\n",
+ .vs_exec = (" vec2 pos = primitive.zw * vec2(gl_VertexID&1, (gl_VertexID&2)>>1);\n"
+ GLAMOR_POS(gl_Position, (primitive.xy + pos))),
+};
+
+static const glamor_facet glamor_facet_polyfillrect_120 = {
+ .name = "poly_fill_rect",
+ .vs_vars = "attribute vec2 primitive;\n",
+ .vs_exec = (" vec2 pos = vec2(0,0);\n"
+ GLAMOR_POS(gl_Position, primitive.xy)),
+};
+
+static Bool
+glamor_poly_fill_rect_gl(DrawablePtr drawable,
+ GCPtr gc, int nrect, xRectangle *prect)
+{
+ ScreenPtr screen = drawable->pScreen;
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_pixmap_private *pixmap_priv;
+ glamor_program *prog;
+ int off_x, off_y;
+ GLshort *v;
+ char *vbo_offset;
+ int box_x, box_y;
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ goto bail;
+
+ glamor_get_context(glamor_priv);
+
+ if (glamor_priv->glsl_version >= 130) {
+ prog = glamor_use_program_fill(pixmap, gc,
+ &glamor_priv->poly_fill_rect_program,
+ &glamor_facet_polyfillrect_130);
+
+ if (!prog)
+ goto bail_ctx;
+
+ /* Set up the vertex buffers for the points */
+
+ v = glamor_get_vbo_space(drawable->pScreen, nrect * sizeof (xRectangle), &vbo_offset);
+
+ glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+ glVertexAttribDivisor(GLAMOR_VERTEX_POS, 1);
+ glVertexAttribPointer(GLAMOR_VERTEX_POS, 4, GL_SHORT, GL_FALSE,
+ 4 * sizeof (short), vbo_offset);
+
+ memcpy(v, prect, nrect * sizeof (xRectangle));
+
+ glamor_put_vbo_space(screen);
+ } else {
+ int n;
+
+ prog = glamor_use_program_fill(pixmap, gc,
+ &glamor_priv->poly_fill_rect_program,
+ &glamor_facet_polyfillrect_120);
+
+ if (!prog)
+ goto bail_ctx;
+
+ /* Set up the vertex buffers for the points */
+
+ v = glamor_get_vbo_space(drawable->pScreen, nrect * 8 * sizeof (short), &vbo_offset);
+
+ glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+ glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_SHORT, GL_FALSE,
+ 2 * sizeof (short), vbo_offset);
+
+ for (n = 0; n < nrect; n++) {
+ v[0] = prect->x; v[1] = prect->y;
+ v[2] = prect->x; v[3] = prect->y + prect->height;
+ v[4] = prect->x + prect->width; v[5] = prect->y + prect->height;
+ v[6] = prect->x + prect->width; v[7] = prect->y;
+ prect++;
+ v += 8;
+ }
+
+ glamor_put_vbo_space(screen);
+ }
+
+ glEnable(GL_SCISSOR_TEST);
+
+ glamor_pixmap_loop(pixmap_priv, box_x, box_y) {
+ int nbox = RegionNumRects(gc->pCompositeClip);
+ BoxPtr box = RegionRects(gc->pCompositeClip);
+
+ glamor_set_destination_drawable(drawable, box_x, box_y, TRUE, FALSE, prog->matrix_uniform, &off_x, &off_y);
+
+ while (nbox--) {
+ glScissor(box->x1 + off_x,
+ box->y1 + off_y,
+ box->x2 - box->x1,
+ box->y2 - box->y1);
+ box++;
+ if (glamor_priv->glsl_version >= 130)
+ glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, nrect);
+ else {
+ if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
+ glDrawArrays(GL_QUADS, 0, nrect * 4);
+ } else {
+ int i;
+ for (i = 0; i < nrect; i++) {
+ glDrawArrays(GL_TRIANGLE_FAN, i * 4, 4);
+ }
+ }
+ }
+ }
+ }
+
+ glDisable(GL_SCISSOR_TEST);
+ glDisable(GL_COLOR_LOGIC_OP);
+ if (glamor_priv->glsl_version >= 130)
+ 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;
+}
+
+static void
+glamor_poly_fill_rect_bail(DrawablePtr drawable,
+ GCPtr gc, int nrect, xRectangle *prect)
+{
+ glamor_fallback("to %p (%c)\n", drawable,
+ glamor_get_drawable_location(drawable));
+ if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) &&
+ glamor_prepare_access_gc(gc)) {
+ fbPolyFillRect(drawable, gc, nrect, prect);
+ }
+ glamor_finish_access_gc(gc);
+ glamor_finish_access(drawable);
+}
+
+void
+glamor_poly_fill_rect(DrawablePtr drawable,
+ GCPtr gc, int nrect, xRectangle *prect)
+{
+ if (glamor_poly_fill_rect_gl(drawable, gc, nrect, prect))
+ return;
+ glamor_poly_fill_rect_bail(drawable, gc, nrect, prect);
+}
+
+Bool
+glamor_poly_fill_rect_nf(DrawablePtr drawable,
+ GCPtr gc, int nrect, xRectangle *prect)
+{
+ if (glamor_poly_fill_rect_gl(drawable, gc, nrect, prect))
+ return TRUE;
+ if (glamor_ddx_fallback_check_pixmap(drawable) && glamor_ddx_fallback_check_gc(gc))
+ return FALSE;
+ glamor_poly_fill_rect_bail(drawable, gc, nrect, prect);
+ return TRUE;
+}
commit 0a6d31161811c422799d6f065ea2842d42707530
Author: Keith Packard <keithp at keithp.com>
Date: Tue Apr 1 21:15:45 2014 -0700
glamor: Add glamor_program based fill/set/get spans
This accelerates spans operations using GPU-based geometry computation
-wellipse500 goes from about 4k/sec before the patch, to ~8k/sec in
the GLES2 fallback loop, to ~100k/sec in desktop mode.
v2: Rebase on skipping the prepare rewrite for now, and fix the GLSL
1.20 and GLES2 cases (changes by anholt).
Signed-off-by: Keith Packard <keithp at keithp.com>
Signed-off-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Eric Anholt <eric at anholt.net>
diff --git a/glamor/Makefile.am b/glamor/Makefile.am
index 3664fd3..4be9f34 100644
--- a/glamor/Makefile.am
+++ b/glamor/Makefile.am
@@ -12,18 +12,16 @@ libglamor_la_SOURCES = \
glamor_core.c \
glamor_debug.h \
glamor_fill.c \
- glamor_fillspans.c \
- glamor_getspans.c \
glamor_glx.c \
glamor_glyphs.c \
glamor_polyfillrect.c \
glamor_polylines.c \
glamor_putimage.c \
- glamor_setspans.c \
glamor_segment.c \
glamor_render.c \
glamor_gradient.c \
glamor_program.c \
+ glamor_spans.c \
glamor_transfer.c \
glamor_transfer.h \
glamor_transform.c \
diff --git a/glamor/glamor_fillspans.c b/glamor/glamor_fillspans.c
deleted file mode 100644
index 8cbd79f..0000000
--- a/glamor/glamor_fillspans.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright © 1998 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-/** @file glamor_fillspans.c
- *
- * FillSpans implementation, taken from fb_fillsp.c
- */
-#include "glamor_priv.h"
-
-static Bool
-_glamor_fill_spans(DrawablePtr drawable,
- GCPtr gc,
- int n, DDXPointPtr points, int *widths, int sorted,
- Bool fallback)
-{
- DDXPointPtr ppt;
- int nbox;
- BoxPtr pbox;
- int x1, x2, y;
- RegionPtr pClip = fbGetCompositeClip(gc);
- Bool ret = FALSE;
-
- if (gc->fillStyle != FillSolid && gc->fillStyle != FillTiled)
- goto fail;
-
- ppt = points;
- while (n--) {
- x1 = ppt->x;
- y = ppt->y;
- x2 = x1 + (int) *widths;
- ppt++;
- widths++;
-
- nbox = REGION_NUM_RECTS(pClip);
- pbox = REGION_RECTS(pClip);
- while (nbox--) {
- int real_x1 = x1, real_x2 = x2;
-
- if (real_x1 < pbox->x1)
- real_x1 = pbox->x1;
-
- if (real_x2 > pbox->x2)
- real_x2 = pbox->x2;
-
- if (real_x2 > real_x1 && pbox->y1 <= y && pbox->y2 > y) {
- if (!glamor_fill(drawable, gc, real_x1, y,
- real_x2 - real_x1, 1, fallback))
- goto fail;
- }
- pbox++;
- }
- }
- ret = TRUE;
- goto done;
-
- fail:
- if (!fallback && glamor_ddx_fallback_check_pixmap(drawable)
- && glamor_ddx_fallback_check_gc(gc)) {
- goto done;
- }
- glamor_fallback("to %p (%c)\n", drawable,
- glamor_get_drawable_location(drawable));
- if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) &&
- glamor_prepare_access_gc(gc)) {
- fbFillSpans(drawable, gc, n, points, widths, sorted);
- }
- glamor_finish_access_gc(gc);
- glamor_finish_access(drawable);
- ret = TRUE;
-
- done:
- return ret;
-}
-
-void
-glamor_fill_spans(DrawablePtr drawable,
- GCPtr gc, int n, DDXPointPtr points, int *widths, int sorted)
-{
- _glamor_fill_spans(drawable, gc, n, points, widths, sorted, TRUE);
-}
-
-Bool
-glamor_fill_spans_nf(DrawablePtr drawable,
- GCPtr gc,
- int n, DDXPointPtr points, int *widths, int sorted)
-{
- return _glamor_fill_spans(drawable, gc, n, points, widths, sorted, FALSE);
-}
diff --git a/glamor/glamor_getspans.c b/glamor/glamor_getspans.c
deleted file mode 100644
index 42df87f..0000000
--- a/glamor/glamor_getspans.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright © 2009 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- *
- * Authors:
- * Eric Anholt <eric at anholt.net>
- * Zhigang Gong <zhigang.gong at linux.intel.com>
- *
- */
-
-#include "glamor_priv.h"
-
-static Bool
-_glamor_get_spans(DrawablePtr drawable,
- int wmax,
- DDXPointPtr points, int *widths, int count, char *dst,
- Bool fallback)
-{
- PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
- glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
- int i;
- uint8_t *readpixels_dst = (uint8_t *) dst;
- void *data;
- int x_off, y_off;
- Bool ret = FALSE;
-
- if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
- goto fail;
-
- glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
- for (i = 0; i < count; i++) {
- data = glamor_download_sub_pixmap_to_cpu(pixmap, points[i].x + x_off,
- points[i].y + y_off, widths[i],
- 1, PixmapBytePad(widths[i],
- drawable->
- depth),
- readpixels_dst, 0,
- GLAMOR_ACCESS_RO);
- (void)data;
- assert(data == readpixels_dst);
- readpixels_dst += PixmapBytePad(widths[i], drawable->depth);
- }
-
- ret = TRUE;
- goto done;
- fail:
-
- if (!fallback && glamor_ddx_fallback_check_pixmap(drawable))
- goto done;
-
- ret = TRUE;
- if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RO)) {
- fbGetSpans(drawable, wmax, points, widths, count, dst);
- }
- glamor_finish_access(drawable);
- done:
- return ret;
-}
-
-void
-glamor_get_spans(DrawablePtr drawable,
- int wmax,
- DDXPointPtr points, int *widths, int count, char *dst)
-{
- _glamor_get_spans(drawable, wmax, points, widths, count, dst, TRUE);
-}
-
-Bool
-glamor_get_spans_nf(DrawablePtr drawable,
- int wmax,
- DDXPointPtr points, int *widths, int count, char *dst)
-{
- return _glamor_get_spans(drawable, wmax, points, widths, count, dst, FALSE);
-}
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 36f9b71..430ca59 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -224,6 +224,9 @@ typedef struct glamor_screen_private {
/* glamor point shader */
glamor_program point_prog;
+ /* glamor spans shaders */
+ glamor_program_fill fill_spans_program;
+
/* vertext/elment_index buffer object for render */
GLuint vbo, ebo;
/** Next offset within the VBO that glamor_get_vbo_space() will use. */
@@ -675,19 +678,9 @@ Bool glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
Bool glamor_solid_boxes(PixmapPtr pixmap,
BoxPtr box, int nbox, unsigned long fg_pixel);
-/* glamor_fillspans.c */
-void glamor_fill_spans(DrawablePtr drawable,
- GCPtr gc,
- int n, DDXPointPtr points, int *widths, int sorted);
-
void glamor_init_solid_shader(ScreenPtr screen);
void glamor_fini_solid_shader(ScreenPtr screen);
-/* glamor_getspans.c */
-void glamor_get_spans(DrawablePtr drawable,
- int wmax, DDXPointPtr points, int *widths,
- int nspans, char *dst_start);
-
/* glamor_glyphs.c */
Bool glamor_realize_glyph_caches(ScreenPtr screen);
void glamor_glyphs_fini(ScreenPtr screen);
@@ -698,10 +691,6 @@ void glamor_glyphs(CARD8 op,
INT16 xSrc,
INT16 ySrc, int nlist, GlyphListPtr list, GlyphPtr *glyphs);
-/* glamor_setspans.c */
-void glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
- DDXPointPtr points, int *widths, int n, int sorted);
-
/* glamor_polyfillrect.c */
void glamor_poly_fill_rect(DrawablePtr drawable,
GCPtr gc, int nrect, xRectangle *prect);
@@ -968,6 +957,21 @@ RegionPtr glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
int dstx, int dsty,
unsigned long bitPlane);
+/* glamor_spans.c */
+void
+glamor_fill_spans(DrawablePtr drawable,
+ GCPtr gc,
+ int n, DDXPointPtr points, int *widths, int sorted);
+
+void
+glamor_get_spans(DrawablePtr drawable, int wmax,
+ DDXPointPtr points, int *widths, int count, char *dst);
+
+void
+glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
+ DDXPointPtr points, int *widths, int numPoints, int sorted);
+
+/* glamor_glyphblt.c */
void glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
int x, int y, unsigned int nglyph,
CharInfoPtr *ppci, void *pglyphBase);
diff --git a/glamor/glamor_setspans.c b/glamor/glamor_setspans.c
deleted file mode 100644
index a51e4c5..0000000
--- a/glamor/glamor_setspans.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright © 2009 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- *
- * Authors:
- * Eric Anholt <eric at anholt.net>
- * Zhigang Gong <zhigang.gong at linux.intel.com>
- *
- */
-
-#include "glamor_priv.h"
-
-static Bool
-_glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
- DDXPointPtr points, int *widths, int numPoints, int sorted,
- Bool fallback)
-{
- PixmapPtr dest_pixmap = glamor_get_drawable_pixmap(drawable);
- glamor_pixmap_private *dest_pixmap_priv;
- int i;
- uint8_t *drawpixels_src = (uint8_t *) src;
- RegionPtr clip = fbGetCompositeClip(gc);
- BoxRec *pbox;
- int x_off, y_off;
- Bool ret = FALSE;
-
- dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap);
- if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)) {
- glamor_fallback("pixmap has no fbo.\n");
- goto fail;
- }
-
- if (gc->alu != GXcopy) {
- glamor_fallback("SetSpans with non-copy ALU.\n");
- goto fail;
- }
-
- if (!glamor_set_planemask(dest_pixmap, gc->planemask))
- goto fail;
-
- glamor_get_drawable_deltas(drawable, dest_pixmap, &x_off, &y_off);
- for (i = 0; i < numPoints; i++) {
-
- int n = REGION_NUM_RECTS(clip);
-
- pbox = REGION_RECTS(clip);
- while (n--) {
- int x1 = points[i].x;
- int x2 = x1 + widths[i];
- int y1 = points[i].y;
-
- if (pbox->y1 > points[i].y || pbox->y2 < points[i].y)
- break;
- x1 = x1 > pbox->x1 ? x1 : pbox->x1;
- x2 = x2 < pbox->x2 ? x2 : pbox->x2;
- if (x1 >= x2)
- continue;
- glamor_upload_sub_pixmap_to_texture(dest_pixmap, x1 + x_off,
- y1 + y_off, x2 - x1, 1,
- PixmapBytePad(widths[i],
- drawable->depth),
- drawpixels_src, 0);
- }
- drawpixels_src += PixmapBytePad(widths[i], drawable->depth);
- }
- ret = TRUE;
- goto done;
-
- fail:
- if (!fallback && glamor_ddx_fallback_check_pixmap(drawable))
- goto done;
-
- glamor_fallback("to %p (%c)\n",
- drawable, glamor_get_drawable_location(drawable));
- if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) &&
- glamor_prepare_access_gc(gc)) {
- fbSetSpans(drawable, gc, src, points, widths, numPoints, sorted);
- }
- glamor_finish_access_gc(gc);
- glamor_finish_access(drawable);
- ret = TRUE;
-
- done:
- return ret;
-}
-
-void
-glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
- DDXPointPtr points, int *widths, int n, int sorted)
-{
- _glamor_set_spans(drawable, gc, src, points, widths, n, sorted, TRUE);
-}
-
-Bool
-glamor_set_spans_nf(DrawablePtr drawable, GCPtr gc, char *src,
- DDXPointPtr points, int *widths, int n, int sorted)
-{
- return _glamor_set_spans(drawable, gc, src, points,
- widths, n, sorted, FALSE);
-}
diff --git a/glamor/glamor_spans.c b/glamor/glamor_spans.c
new file mode 100644
index 0000000..98842cd
--- /dev/null
+++ b/glamor/glamor_spans.c
@@ -0,0 +1,438 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include "glamor_priv.h"
+#include "glamor_transform.h"
+#include "glamor_transfer.h"
+
+glamor_program fill_spans_progs[4];
+
+static const glamor_facet glamor_facet_fillspans_130 = {
+ .name = "fill_spans",
+ .version = 130,
+ .vs_vars = "attribute vec3 primitive;\n",
+ .vs_exec = (" vec2 pos = vec2(primitive.z,1) * vec2(gl_VertexID&1, (gl_VertexID&2)>>1);\n"
+ GLAMOR_POS(gl_Position, (primitive.xy + pos))),
+};
+
+static const glamor_facet glamor_facet_fillspans_120 = {
+ .name = "fill_spans",
+ .vs_vars = "attribute vec2 primitive;\n",
+ .vs_exec = (" vec2 pos = vec2(0,0);\n"
+ GLAMOR_POS(gl_Position, primitive.xy)),
+};
+
+static Bool
+glamor_fill_spans_gl(DrawablePtr drawable,
+ GCPtr gc,
+ int n, DDXPointPtr points, int *widths, int sorted)
+{
+ ScreenPtr screen = drawable->pScreen;
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_pixmap_private *pixmap_priv;
+ glamor_program *prog;
+ int off_x, off_y;
+ GLshort *v;
+ char *vbo_offset;
+ int c;
+ int box_x, box_y;
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ goto bail;
+
+ glamor_get_context(glamor_priv);
+
+ if (glamor_priv->glsl_version >= 130) {
+ prog = glamor_use_program_fill(pixmap, gc, &glamor_priv->fill_spans_program,
+ &glamor_facet_fillspans_130);
+
+ if (!prog)
+ goto bail_ctx;
+
+ /* Set up the vertex buffers for the points */
+
+ v = glamor_get_vbo_space(drawable->pScreen, n * (4 * sizeof (GLshort)), &vbo_offset);
+
+ glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+ glVertexAttribDivisor(GLAMOR_VERTEX_POS, 1);
+ glVertexAttribPointer(GLAMOR_VERTEX_POS, 3, GL_SHORT, GL_FALSE,
+ 4 * sizeof (GLshort), vbo_offset);
+
+ for (c = 0; c < n; c++) {
+ v[0] = points->x;
+ v[1] = points->y;
+ v[2] = *widths++;
+ points++;
+ v += 4;
+ }
+
+ glamor_put_vbo_space(screen);
+ } else {
+ prog = glamor_use_program_fill(pixmap, gc, &glamor_priv->fill_spans_program,
+ &glamor_facet_fillspans_120);
+
+ if (!prog)
+ goto bail_ctx;
+
+ /* Set up the vertex buffers for the points */
+
+ v = glamor_get_vbo_space(drawable->pScreen, n * 8 * sizeof (short), &vbo_offset);
+
+ glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+ glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_SHORT, GL_FALSE,
+ 2 * sizeof (short), vbo_offset);
+
+ for (c = 0; c < n; c++) {
+ v[0] = points->x; v[1] = points->y;
+ v[2] = points->x; v[3] = points->y + 1;
+ v[4] = points->x + *widths; v[5] = points->y + 1;
+ v[6] = points->x + *widths; v[7] = points->y;
+
+ widths++;
+ points++;
+ v += 8;
+ }
+
+ glamor_put_vbo_space(screen);
+ }
+
+ glEnable(GL_SCISSOR_TEST);
+
+ glamor_pixmap_loop(pixmap_priv, box_x, box_y) {
+ int nbox = RegionNumRects(gc->pCompositeClip);
+ BoxPtr box = RegionRects(gc->pCompositeClip);
+
+ glamor_set_destination_drawable(drawable, box_x, box_y, FALSE, FALSE, prog->matrix_uniform, &off_x, &off_y);
+
+ while (nbox--) {
+ glScissor(box->x1 + off_x,
+ box->y1 + off_y,
+ box->x2 - box->x1,
+ box->y2 - box->y1);
+ box++;
+ if (glamor_priv->glsl_version >= 130)
+ glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, n);
+ else {
+ if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
+ glDrawArrays(GL_QUADS, 0, 4 * n);
+ } else {
+ int i;
+ for (i = 0; i < n; i++) {
+ glDrawArrays(GL_TRIANGLE_FAN, i * 4, 4);
+ }
+ }
+ }
+ }
+ }
+
+ glDisable(GL_SCISSOR_TEST);
+ glDisable(GL_COLOR_LOGIC_OP);
+ if (glamor_priv->glsl_version >= 130)
+ 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;
+}
+
+static void
+glamor_fill_spans_bail(DrawablePtr drawable,
+ GCPtr gc,
+ int n, DDXPointPtr points, int *widths, int sorted)
+{
+ if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) &&
+ glamor_prepare_access_gc(gc)) {
+ fbFillSpans(drawable, gc, n, points, widths, sorted);
+ }
+ glamor_finish_access_gc(gc);
+ glamor_finish_access(drawable);
+}
+
+void
+glamor_fill_spans(DrawablePtr drawable,
+ GCPtr gc,
+ int n, DDXPointPtr points, int *widths, int sorted)
+{
+ if (glamor_fill_spans_gl(drawable, gc, n, points, widths, sorted))
+ return;
+ glamor_fill_spans_bail(drawable, gc, n, points, widths, sorted);
+}
+
+Bool
+glamor_fill_spans_nf(DrawablePtr drawable,
+ GCPtr gc,
+ int n, DDXPointPtr points, int *widths, int sorted)
+{
+ if (glamor_fill_spans_gl(drawable, gc, n, points, widths, sorted))
+ return TRUE;
+
+ if (glamor_ddx_fallback_check_pixmap(drawable) && glamor_ddx_fallback_check_gc(gc))
+ return FALSE;
+
+ glamor_fill_spans_bail(drawable, gc, n, points, widths, sorted);
+ return TRUE;
+}
+
+static Bool
+glamor_get_spans_gl(DrawablePtr drawable, int wmax,
+ DDXPointPtr points, int *widths, int count, char *dst)
+{
+ ScreenPtr screen = drawable->pScreen;
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_pixmap_private *pixmap_priv;
+ int box_x, box_y;
+ int n;
+ char *d;
+ GLenum type;
+ GLenum format;
+ int off_x, off_y;
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ goto bail;
+
+ glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y);
+
+ glamor_format_for_pixmap(pixmap, &format, &type);
+
+ glamor_get_context(glamor_priv);
+
+ glamor_pixmap_loop(pixmap_priv, box_x, box_y) {
+ BoxPtr box = glamor_pixmap_box_at(pixmap_priv, box_x, box_y);
+ glamor_pixmap_fbo *fbo = glamor_pixmap_fbo_at(pixmap_priv, box_x, box_y);
+
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo->fb);
+ glPixelStorei(GL_PACK_ALIGNMENT, 4);
+
+ d = dst;
+ for (n = 0; n < count; n++) {
+ int x1 = points[n].x + off_x;
+ int y = points[n].y + off_y;
+ int w = widths[n];
+ int x2 = x1 + w;
+ char *l;
+
+ l = d;
+ d += PixmapBytePad(w, drawable->depth);
+
+ /* clip */
+ if (x1 < box->x1) {
+ l += (box->x1 - x1) * (drawable->bitsPerPixel >> 3);
+ x1 = box->x1;
+ }
+ if (x2 > box->x2)
+ x2 = box->x2;
+
+ if (x1 >= x2)
+ continue;
+ if (y < box->y1)
+ continue;
+ if (y >= box->y2)
+ continue;
+
+ glReadPixels(x1 - box->x1, y - box->y1, x2 - x1, 1, format, type, l);
+ }
+ }
+
+ glamor_put_context(glamor_priv);
+ return TRUE;
+bail:
+ return FALSE;
+}
+
+static void
+glamor_get_spans_bail(DrawablePtr drawable, int wmax,
+ DDXPointPtr points, int *widths, int count, char *dst)
+{
+ if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RO))
+ fbGetSpans(drawable, wmax, points, widths, count, dst);
+ glamor_finish_access(drawable);
+}
+
+void
+glamor_get_spans(DrawablePtr drawable, int wmax,
+ DDXPointPtr points, int *widths, int count, char *dst)
+{
+ if (glamor_get_spans_gl(drawable, wmax, points, widths, count, dst))
+ return;
+ glamor_get_spans_bail(drawable, wmax, points, widths, count, dst);
+}
+
+Bool
+glamor_get_spans_nf(DrawablePtr drawable, int wmax,
+ DDXPointPtr points, int *widths, int count, char *dst)
+{
+ if (glamor_get_spans_gl(drawable, wmax, points, widths, count, dst))
+ return TRUE;
+
+ if (glamor_ddx_fallback_check_pixmap(drawable))
+ return FALSE;
+
+ glamor_get_spans_bail(drawable, wmax, points, widths, count, dst);
+ return TRUE;
+}
+
+static Bool
+glamor_set_spans_gl(DrawablePtr drawable, GCPtr gc, char *src,
+ DDXPointPtr points, int *widths, int numPoints, int sorted)
+{
+ ScreenPtr screen = drawable->pScreen;
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_pixmap_private *pixmap_priv;
+ int box_x, box_y;
+ int n;
+ char *s;
+ GLenum type;
+ GLenum format;
+ int off_x, off_y;
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ goto bail;
+
+ if (gc->alu != GXcopy)
+ goto bail;
+
+ if (!glamor_pm_is_solid(&pixmap->drawable, gc->planemask))
+ goto bail;
+
+ glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y);
+ glamor_format_for_pixmap(pixmap, &format, &type);
+
+ glamor_get_context(glamor_priv);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+
+ glamor_pixmap_loop(pixmap_priv, box_x, box_y) {
+ BoxPtr box = glamor_pixmap_box_at(pixmap_priv, box_x, box_y);
+ glamor_pixmap_fbo *fbo = glamor_pixmap_fbo_at(pixmap_priv, box_x, box_y);
+
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, fbo->tex);
+
+ s = src;
+ for (n = 0; n < numPoints; n++) {
+
+ BoxPtr clip_box = RegionRects(gc->pCompositeClip);
+ int nclip_box = RegionNumRects(gc->pCompositeClip);
+ int w = widths[n];
+ int y = points[n].y;
+ int x = points[n].x;
+
+ while (nclip_box--) {
+ int x1 = x;
+ int x2 = x + w;
+ int y1 = y;
+ char *l = s;
+
+ /* clip to composite clip */
+ if (x1 < clip_box->x1) {
+ l += (clip_box->x1 - x1) * (drawable->bitsPerPixel >> 3);
+ x1 = clip_box->x1;
+ }
+ if (x2 > clip_box->x2)
+ x2 = clip_box->x2;
+
+ if (y < clip_box->y1)
+ continue;
+ if (y >= clip_box->y2)
+ continue;
+
+ /* adjust to pixmap coordinates */
+ x1 += off_x;
+ x2 += off_x;
+ y1 += off_y;
+
+ if (x1 < box->x1) {
+ l += (box->x1 - x1) * (drawable->bitsPerPixel >> 3);
+ x1 = box->x1;
+ }
+ if (x2 > box->x2)
+ x2 = box->x2;
+
+ if (x1 >= x2)
+ continue;
+ if (y1 < box->y1)
+ continue;
+ if (y1 >= box->y2)
+ continue;
+
+ glTexSubImage2D(GL_TEXTURE_2D, 0,
+ x1 - box->x1, y1 - box->y1, x2 - x1, 1,
+ format, type,
+ l);
+ }
+ s += PixmapBytePad(w, drawable->depth);
+ }
+ }
+
+ glamor_put_context(glamor_priv);
+ return TRUE;
+
+bail:
+ return FALSE;
+}
+
+static void
+glamor_set_spans_bail(DrawablePtr drawable, GCPtr gc, char *src,
+ DDXPointPtr points, int *widths, int numPoints, int sorted)
+{
+ if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) && glamor_prepare_access_gc(gc))
+ fbSetSpans(drawable, gc, src, points, widths, numPoints, sorted);
+ glamor_finish_access_gc(gc);
+ glamor_finish_access(drawable);
+}
+
+void
+glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
+ DDXPointPtr points, int *widths, int numPoints, int sorted)
+{
+ if (glamor_set_spans_gl(drawable, gc, src, points, widths, numPoints, sorted))
+ return;
+ glamor_set_spans_bail(drawable, gc, src, points, widths, numPoints, sorted);
+}
+
+Bool
+glamor_set_spans_nf(DrawablePtr drawable, GCPtr gc, char *src,
+ DDXPointPtr points, int *widths, int numPoints, int sorted)
+{
+ if (glamor_set_spans_gl(drawable, gc, src, points, widths, numPoints, sorted))
+ return TRUE;
+
+ if (glamor_ddx_fallback_check_pixmap(drawable) && glamor_ddx_fallback_check_gc(gc))
+ return FALSE;
+
+ glamor_set_spans_bail(drawable, gc, src, points, widths, numPoints, sorted);
+ return TRUE;
+}
commit d78c257f523908760c1b872cc4bef3d42eb31f50
Author: Keith Packard <keithp at keithp.com>
Date: Tue Apr 1 21:15:43 2014 -0700
glamor: Add simple upload/download functions in glamor_transfer
These use glTexSubimage2D for upload and glReadPixels for
download. There are a variety of interfaces to the basic function as
needed by the callers.
Signed-off-by: Keith Packard <keithp at keithp.com>
Signed-off-by: Eric Anholt <eric at anholt.net>
diff --git a/glamor/Makefile.am b/glamor/Makefile.am
index 8555e40..3664fd3 100644
--- a/glamor/Makefile.am
+++ b/glamor/Makefile.am
@@ -24,6 +24,8 @@ libglamor_la_SOURCES = \
glamor_render.c \
glamor_gradient.c \
glamor_program.c \
+ glamor_transfer.c \
+ glamor_transfer.h \
glamor_transform.c \
glamor_trapezoid.c \
glamor_tile.c \
diff --git a/glamor/glamor_transfer.c b/glamor/glamor_transfer.c
new file mode 100644
index 0000000..0378bb0
--- /dev/null
+++ b/glamor/glamor_transfer.c
@@ -0,0 +1,264 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include "glamor_priv.h"
+#include "glamor_transfer.h"
+
+/* XXX a kludge for now */
+void
+glamor_format_for_pixmap(PixmapPtr pixmap, GLenum *format, GLenum *type)
+{
+ switch (pixmap->drawable.depth) {
+ case 24:
+ case 32:
+ *format = GL_BGRA;
+ *type = GL_UNSIGNED_INT_8_8_8_8_REV;
+ break;
+ case 16:
+ *format = GL_RGB;
+ *type = GL_UNSIGNED_SHORT_5_6_5;
+ break;
+ case 15:
+ *format = GL_BGRA;
+ *type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
+ break;
+ case 8:
+ *format = GL_ALPHA;
+ *type = GL_UNSIGNED_BYTE;
+ break;
+ default:
+ FatalError("Invalid pixmap depth %d\n", pixmap->drawable.depth);
+ break;
+ }
+}
+
+/*
+ * Write a region of bits into a pixmap
+ */
+void
+glamor_upload_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
+ int dx_src, int dy_src,
+ int dx_dst, int dy_dst,
+ uint8_t *bits, uint32_t byte_stride)
+{
+ ScreenPtr screen = pixmap->drawable.pScreen;
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
+ int box_x, box_y;
+ int bytes_per_pixel = pixmap->drawable.bitsPerPixel >> 3;
+ GLenum type;
+ GLenum format;
+
+ glamor_format_for_pixmap(pixmap, &format, &type);
+
+ glamor_get_context(glamor_priv);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, byte_stride / bytes_per_pixel);
+
+ glamor_pixmap_loop(priv, box_x, box_y) {
+ BoxPtr box = glamor_pixmap_box_at(priv, box_x, box_y);
+ glamor_pixmap_fbo *fbo = glamor_pixmap_fbo_at(priv, box_x, box_y);
+ BoxPtr boxes = in_boxes;
+ int nbox = in_nbox;
+
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, fbo->tex);
+
+ while (nbox--) {
+
+ /* compute drawable coordinates */
+ int x1 = boxes->x1 + dx_dst;
+ int x2 = boxes->x2 + dx_dst;
+ int y1 = boxes->y1 + dy_dst;
+ int y2 = boxes->y2 + dy_dst;
+
+ boxes++;
+
+ if (x1 < box->x1)
+ x1 = box->x1;
+ if (box->x2 < x2)
+ x2 = box->x2;
+
+ if (x2 <= x1)
+ continue;
+
+ if (y1 < box->y1)
+ y1 = box->y1;
+ if (box->y2 < y2)
+ y2 = box->y2;
+
+ if (y2 <= y1)
+ continue;
+
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, y1 - dy_dst + dy_src);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, x1 - dx_dst + dx_src);
+
+ glTexSubImage2D(GL_TEXTURE_2D, 0,
+ x1 - box->x1, y1 - box->y1,
+ x2 - x1, y2 - y1,
+ format, type,
+ bits);
+ }
+ }
+
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
+ glamor_put_context(glamor_priv);
+}
+
+/*
+ * Upload a region of data
+ */
+
+void
+glamor_upload_region(PixmapPtr pixmap, RegionPtr region,
+ int region_x, int region_y,
+ uint8_t *bits, uint32_t byte_stride)
+{
+ glamor_upload_boxes(pixmap, RegionRects(region), RegionNumRects(region),
+ -region_x, -region_y,
+ 0, 0,
+ bits, byte_stride);
+}
+
+/*
+ * Take the data in the pixmap and stuff it back into the FBO
+ */
+void
+glamor_upload_pixmap(PixmapPtr pixmap)
+{
+ BoxRec box;
+
+ box.x1 = 0;
+ box.x2 = pixmap->drawable.width;
+ box.y1 = 0;
+ box.y2 = pixmap->drawable.height;
+ glamor_upload_boxes(pixmap, &box, 1, 0, 0, 0, 0,
+ pixmap->devPrivate.ptr, pixmap->devKind);
+}
+
+/*
+ * Read stuff from the pixmap FBOs and write to memory
+ */
+void
+glamor_download_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
+ int dx_src, int dy_src,
+ int dx_dst, int dy_dst,
+ uint8_t *bits, uint32_t byte_stride)
+{
+ ScreenPtr screen = pixmap->drawable.pScreen;
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
+ int box_x, box_y;
+ int bytes_per_pixel = pixmap->drawable.bitsPerPixel >> 3;
+ GLenum type;
+ GLenum format;
+
+ glamor_format_for_pixmap(pixmap, &format, &type);
+
+ glamor_get_context(glamor_priv);
+
+ glPixelStorei(GL_PACK_ALIGNMENT, 4);
+ glPixelStorei(GL_PACK_ROW_LENGTH, byte_stride / bytes_per_pixel);
+
+ glamor_pixmap_loop(priv, box_x, box_y) {
+ BoxPtr box = glamor_pixmap_box_at(priv, box_x, box_y);
+ glamor_pixmap_fbo *fbo = glamor_pixmap_fbo_at(priv, box_x, box_y);
+ BoxPtr boxes = in_boxes;
+ int nbox = in_nbox;
+
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo->fb);
+
+ while (nbox--) {
+
+ /* compute drawable coordinates */
+ int x1 = boxes->x1 + dx_src;
+ int x2 = boxes->x2 + dx_src;
+ int y1 = boxes->y1 + dy_src;
+ int y2 = boxes->y2 + dy_src;
+
+ boxes++;
+
+ if (x1 < box->x1)
+ x1 = box->x1;
+ if (box->x2 < x2)
+ x2 = box->x2;
+
+ if (y1 < box->y1)
+ y1 = box->y1;
+ if (box->y2 < y2)
+ y2 = box->y2;
+
+ if (x2 <= x1)
+ continue;
+ if (y2 <= y1)
+ continue;
+
+ glPixelStorei(GL_PACK_SKIP_PIXELS, x1 - dx_src + dx_dst);
+ glPixelStorei(GL_PACK_SKIP_ROWS, y1 - dy_src + dy_dst);
+ glReadPixels(x1 - box->x1, y1 - box->y1, x2 - x1, y2 - y1, format, type, bits);
+ }
+ }
+ glPixelStorei(GL_PACK_ROW_LENGTH, 0);
+ glPixelStorei(GL_PACK_SKIP_ROWS, 0);
+ glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
+ glamor_put_context(glamor_priv);
+}
+
+/*
+ * Read data from the pixmap FBO
+ */
+void
+glamor_download_rect(PixmapPtr pixmap, int x, int y, int w, int h, uint8_t *bits)
+{
+ BoxRec box;
+
+ box.x1 = x;
+ box.x2 = x + w;
+ box.y1 = y;
+ box.y2 = y + h;
+
+ glamor_download_boxes(pixmap, &box, 1, 0, 0, -x, -y,
+ bits, PixmapBytePad(w, pixmap->drawable.depth));
+}
+
+/*
+ * Pull the data from the FBO down to the pixmap
+ */
+void
+glamor_download_pixmap(PixmapPtr pixmap)
+{
+ BoxRec box;
+
+ box.x1 = 0;
+ box.x2 = pixmap->drawable.width;
+ box.y1 = 0;
+ box.y2 = pixmap->drawable.height;
+
+ glamor_download_boxes(pixmap, &box, 1, 0, 0, 0, 0,
+ pixmap->devPrivate.ptr, pixmap->devKind);
+}
diff --git a/glamor/glamor_transfer.h b/glamor/glamor_transfer.h
new file mode 100644
index 0000000..de8186a
--- /dev/null
+++ b/glamor/glamor_transfer.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifndef _GLAMOR_TRANSFER_H_
+#define _GLAMOR_TRANSFER_H_
+
+void
+glamor_format_for_pixmap(PixmapPtr pixmap, GLenum *format, GLenum *type);
+
+void
+glamor_upload_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
+ int dx_src, int dy_src,
+ int dx_dst, int dy_dst,
+ uint8_t *bits, uint32_t byte_stride);
+
+void
+glamor_upload_region(PixmapPtr pixmap, RegionPtr region,
+ int region_x, int region_y,
+ uint8_t *bits, uint32_t byte_stride);
+
+void
+glamor_upload_pixmap(PixmapPtr pixmap);
+
+void
+glamor_download_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
+ int dx_src, int dy_src,
+ int dx_dst, int dy_dst,
+ uint8_t *bits, uint32_t byte_stride);
+
+void
+glamor_download_rect(PixmapPtr pixmap, int x, int y, int w, int h, uint8_t *bits);
+
+void
+glamor_download_pixmap(PixmapPtr pixmap);
+
+#endif /* _GLAMOR_TRANSFER_H_ */
commit 693e6bea897e4c9473a9f22dd8b90df3437e04a1
Author: Keith Packard <keithp at keithp.com>
Date: Tue Apr 1 21:15:42 2014 -0700
glamor: Use plain GLSL 1.20 features for fill code.
This prevents performance regressions from losing acceleration support
on older hardware as we transition to using glamor_program.c for
acceleration.
Signed-off-by: Keith Packard <keithp at keithp.com>
Signed-off-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Eric Anholt <eric at anholt.net>
diff --git a/glamor/glamor_program.c b/glamor/glamor_program.c
index 5996ed9..0f4d0f0 100644
--- a/glamor/glamor_program.c
+++ b/glamor/glamor_program.c
@@ -45,9 +45,8 @@ use_tile(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg)
static const glamor_facet glamor_fill_tile = {
.name = "tile",
- .version = 130,
- .vs_exec = " fill_pos = fill_offset + primitive.xy + pos;\n",
- .fs_exec = " gl_FragColor = texelFetch(sampler, ivec2(mod(fill_pos,fill_size)), 0);\n",
+ .vs_exec = " fill_pos = (fill_offset + primitive.xy + pos) / fill_size;\n",
+ .fs_exec = " gl_FragColor = texture2D(sampler, fill_pos);\n",
.locations = glamor_program_location_fill,
.use = use_tile,
};
@@ -108,6 +107,7 @@ static glamor_location_var location_vars[] = {
{
.location = glamor_program_location_fill,
.vs_vars = ("uniform vec2 fill_offset;\n"
+ "uniform vec2 fill_size;\n"
"varying vec2 fill_pos;\n"),
.fs_vars = ("uniform sampler2D sampler;\n"
"uniform vec2 fill_size;\n"
commit 5b76b3978d792c92b23a691204b473209782476e
Author: Keith Packard <keithp at keithp.com>
Date: Tue Apr 1 21:15:42 2014 -0700
glamor: Compute supported GLSL version and save in screen private
This currently computes the GLSL version in a fairly naïve fashion,
and leaves that in the screen private for other users. This will let
us update the version computation in one place later on.
v2: Drop an accidental rebase-squashed hunk (change by anholt).
Signed-off-by: Keith Packard <keithp at keithp.com>
Signed-off-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Eric Anholt <eric at anholt.net>
diff --git a/glamor/glamor.c b/glamor/glamor.c
index a7d981c..d7192c1 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -353,6 +353,15 @@ glamor_init(ScreenPtr screen, unsigned int flags)
gl_version = epoxy_gl_version();
+ /* Would be nice to have a cleaner test for GLSL 1.30 support,
+ * but for now this should suffice
+ */
+ if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP && gl_version >= 30)
+ glamor_priv->glsl_version = 130;
+ else
+ glamor_priv->glsl_version = 120;
+
+
/* We'd like to require GL_ARB_map_buffer_range or
* GL_OES_map_buffer_range, since it offers more information to
* the driver than plain old glMapBuffer() or glBufferSubData().
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 4c305ab..36f9b71 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -205,6 +205,7 @@ typedef struct glamor_screen_private {
Bool yInverted;
unsigned int tick;
enum glamor_gl_flavor gl_flavor;
+ int glsl_version;
int has_pack_invert;
int has_fbo_blit;
int has_map_buffer_range;
diff --git a/glamor/glamor_program.c b/glamor/glamor_program.c
index e2e1434..5996ed9 100644
--- a/glamor/glamor_program.c
+++ b/glamor/glamor_program.c
@@ -240,16 +240,8 @@ glamor_build_program(ScreenPtr screen,
flags |= fill->flags;
version = MAX(version, fill->version);
- if (version >= 130) {
-
- /* Would be nice to have a cleaner test for GLSL 1.30 support,
- * but for now this should suffice
- */
- if (glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP ||
- epoxy_gl_version() < 30) {
- goto fail;
- }
- }
+ if (version > glamor_priv->glsl_version)
+ goto fail;
vs_vars = vs_location_vars(locations);
fs_vars = fs_location_vars(locations);
commit 3c2c59eed3c68c0e5a93c38cf01eedad015e3157
Author: Keith Packard <keithp at keithp.com>
Date: Tue Apr 1 21:15:41 2014 -0700
fb: Publish fbGlyphs and fbUnrealizeGlyph
This lets other code jump directly into the fb code for fallbacks
Signed-off-by: Keith Packard <keithp at keithp.com>
Signed-off-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Eric Anholt <eric at anholt.net>
diff --git a/fb/fbpict.c b/fb/fbpict.c
index b503858..c2ee8a5 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -82,7 +82,7 @@ fbDestroyGlyphCache(void)
}
}
-static void
+void
fbUnrealizeGlyph(ScreenPtr pScreen,
GlyphPtr pGlyph)
{
@@ -90,7 +90,7 @@ fbUnrealizeGlyph(ScreenPtr pScreen,
pixman_glyph_cache_remove (glyphCache, pGlyph, NULL);
}
-static void
+void
fbGlyphs(CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
diff --git a/fb/fbpict.h b/fb/fbpict.h
index 110f32d..8b0f59f 100644
--- a/fb/fbpict.h
+++ b/fb/fbpict.h
@@ -65,11 +65,24 @@ fbTrapezoids(CARD8 op,
INT16 xSrc, INT16 ySrc, int ntrap, xTrapezoid * traps);
extern _X_EXPORT void
-
fbTriangles(CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris);
+extern _X_EXPORT void
+fbUnrealizeGlyph(ScreenPtr pScreen,
+ GlyphPtr pGlyph);
+
+extern _X_EXPORT void
+fbGlyphs(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc, int nlist,
+ GlyphListPtr list,
+ GlyphPtr *glyphs);
+
#endif /* _FBPICT_H_ */
commit 9dffcda804b2609f0b319d35dd47fd401d4fafce
Author: Keith Packard <keithp at keithp.com>
Date: Tue Apr 1 20:54:22 2014 -0700
glamor: Bail from composite when pixmap cannot be uploaded
I think the sense of the return value was just flipped here; if you
return TRUE, then the calling code assumes that the pixmap *has* been
uploaded and that an FBO is available. When it tries to use it, it
crashes though. Returning false makes the caller bail back to software.
Signed-off-by: Keith Packard <keithp at keithp.com>
Signed-off-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Eric Anholt <eric at anholt.net>
diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
index c275af7..a811f60 100644
--- a/glamor/glamor_pixmap.c
+++ b/glamor/glamor_pixmap.c
@@ -978,7 +978,7 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w,
&no_alpha,
&revert, &swap_rb, 1)) {
glamor_fallback("Unknown pixmap depth %d.\n", pixmap->drawable.depth);
- return TRUE;
+ return FALSE;
}
if (glamor_pixmap_upload_prepare(pixmap, format, no_alpha, revert, swap_rb))
return FALSE;
commit 15fec3bc3a2d29c903f35b5a30ac09e196eb36b1
Author: Keith Packard <keithp at keithp.com>
Date: Tue Apr 1 20:54:21 2014 -0700
glamor: Remove warning message when pixmap cannot be stored in a texture
This happens when you have 4bpp pixmaps; it's not an error, so stop
flooding the log file when it happens.
Signed-off-by: Keith Packard <keithp at keithp.com>
Signed-off-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Eric Anholt <eric at anholt.net>
diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
index 891ecdd..c275af7 100644
--- a/glamor/glamor_pixmap.c
+++ b/glamor/glamor_pixmap.c
@@ -283,8 +283,6 @@ glamor_get_tex_format_type_from_pictformat_gl(PictFormatShort format,
break;
default:
- LogMessageVerb(X_INFO, 0,
- "fail to get matched format for %x \n", format);
return -1;
}
return 0;
commit 5f177f3582323b6c1791e9e2c107548b607369de
Author: Keith Packard <keithp at keithp.com>
Date: Tue Apr 1 20:54:20 2014 -0700
glamor: Public polyLines function is glamor_poly_lines_nf
There was a spurious declaratoin in glamor.h for glamor_poly_line_nf
Signed-off-by: Keith Packard <keithp at keithp.com>
Signed-off-by: Eric Anholt <eric at anholt.net>
diff --git a/glamor/glamor.h b/glamor/glamor.h
index 11ec493..2ff0409 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -431,9 +431,6 @@ extern _X_EXPORT Bool glamor_poly_point_nf(DrawablePtr pDrawable, GCPtr pGC,
extern _X_EXPORT Bool glamor_poly_segment_nf(DrawablePtr pDrawable, GCPtr pGC,
int nseg, xSegment *pSeg);
-extern _X_EXPORT Bool glamor_poly_line_nf(DrawablePtr pDrawable, GCPtr pGC,
- int mode, int npt, DDXPointPtr ppt);
-
extern _X_EXPORT Bool glamor_poly_lines_nf(DrawablePtr drawable, GCPtr gc,
int mode, int n, DDXPointPtr points);
commit 6aac97198f60de9d4e415fb4fa2fc11cac6c6790
Author: Keith Packard <keithp at keithp.com>
Date: Tue Apr 1 20:54:19 2014 -0700
glamor: Initialize XV shaders from glamor_xv_init instead of glamor_init
The glamor_init calls to glamor_init_xv_shader were never getting run
because GLAMOR_XV was never defined. Instead of trying to make that
work, fix glamor_xv_init to make the call instead.
Further, just get rid of the glamor_fini_xv_shader function entirely
as the shader program will be destroyed when the context is destroyed
at server reset time.
Signed-off-by: Keith Packard <keithp at keithp.com>
Signed-off-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Eric Anholt <eric at anholt.net>
diff --git a/glamor/glamor.c b/glamor/glamor.c
index 971dbf8..a7d981c 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -494,9 +494,6 @@ glamor_init(ScreenPtr screen, unsigned int flags)
#ifdef GLAMOR_GRADIENT_SHADER
glamor_init_gradient_shader(screen);
#endif
-#ifdef GLAMOR_XV
- glamor_init_xv_shader(screen);
-#endif
glamor_pixmap_init(screen);
glamor_glyphs_init(screen);
@@ -516,9 +513,6 @@ glamor_release_screen_priv(ScreenPtr screen)
glamor_screen_private *glamor_priv;
glamor_priv = glamor_get_screen_private(screen);
-#ifdef GLAMOR_XV
- glamor_fini_xv_shader(screen);
-#endif
#ifdef RENDER
glamor_fini_composite_shaders(screen);
#endif
diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
index 17745a4..4e60fa3 100644
--- a/glamor/glamor_xv.c
+++ b/glamor/glamor_xv.c
@@ -114,18 +114,6 @@ glamor_init_xv_shader(ScreenPtr screen)
glamor_put_context(glamor_priv);
}
-void
-glamor_fini_xv_shader(ScreenPtr screen)
-{
- glamor_screen_private *glamor_priv;
-
- glamor_priv = glamor_get_screen_private(screen);
- glamor_get_context(glamor_priv);
-
- glDeleteProgram(glamor_priv->xv_prog);
- glamor_put_context(glamor_priv);
-}
-
#define ClipValue(v,min,max) ((v) < (min) ? (min) : (v) > (max) ? (max) : (v))
#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
@@ -559,6 +547,8 @@ glamor_xv_init(ScreenPtr screen, int num_texture_ports)
XF86VideoAdaptorPtr adapt;
int i;
+ glamor_init_xv_shader(screen);
+
adapt = calloc(1, sizeof(XF86VideoAdaptorRec) + num_texture_ports *
(sizeof(glamor_port_private) + sizeof(DevUnion)));
if (adapt == NULL)
commit 1707faf36d49a63efc462dfef133a555fe093832
Author: Keith Packard <keithp at keithp.com>
Date: Tue Apr 1 20:54:18 2014 -0700
glamor: SetWindowPixmap is not related to RENDER
Move the configuration of screen->SetWindowPixmap out from under it.
Signed-off-by: Keith Packard <keithp at keithp.com>
Signed-off-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Eric Anholt <eric at anholt.net>
diff --git a/glamor/glamor.c b/glamor/glamor.c
index 3094432..971dbf8 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -475,13 +475,13 @@ glamor_init(ScreenPtr screen, unsigned int flags)
glamor_priv->saved_procs.create_picture = ps->CreatePicture;
ps->CreatePicture = glamor_create_picture;
- glamor_priv->saved_procs.set_window_pixmap = screen->SetWindowPixmap;
- screen->SetWindowPixmap = glamor_set_window_pixmap;
-
glamor_priv->saved_procs.destroy_picture = ps->DestroyPicture;
ps->DestroyPicture = glamor_destroy_picture;
glamor_init_composite_shaders(screen);
#endif
+ glamor_priv->saved_procs.set_window_pixmap = screen->SetWindowPixmap;
+ screen->SetWindowPixmap = glamor_set_window_pixmap;
+
glamor_init_vbo(screen);
glamor_init_pixmap_fbo(screen);
glamor_init_solid_shader(screen);
commit 8d88b90953471ead3b480b6ae9d7280b8bd6b216
Author: Keith Packard <keithp at keithp.com>
Date: Tue Apr 1 20:54:15 2014 -0700
glamor: glamor_poly_point_nf cannot fail for non-DDX pixmaps
All of the glamor _nf functions must check to see if the DDX can
access the pixmap directly before returning failure back to the
driver; this restructures the point code to split out the _nf checking
from the _gl code.
Signed-off-by: Keith Packard <keithp at keithp.com>
Signed-off-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Eric Anholt <eric at anholt.net>
diff --git a/glamor/glamor_points.c b/glamor/glamor_points.c
index 5399f96..0d58e55 100644
--- a/glamor/glamor_points.c
+++ b/glamor/glamor_points.c
@@ -35,8 +35,8 @@ static const glamor_facet glamor_facet_point = {
.vs_exec = GLAMOR_POS(gl_Position, primitive),
};
-Bool
-glamor_poly_point_nf(DrawablePtr drawable, GCPtr gc, int mode, int npt, DDXPointPtr ppt)
+static Bool
+glamor_poly_point_gl(DrawablePtr drawable, GCPtr gc, int mode, int npt, DDXPointPtr ppt)
{
ScreenPtr screen = drawable->pScreen;
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
@@ -123,7 +123,22 @@ void
glamor_poly_point(DrawablePtr drawable, GCPtr gc, int mode, int npt,
DDXPointPtr ppt)
{
- if (glamor_poly_point_nf(drawable, gc, mode, npt, ppt))
+ if (glamor_poly_point_gl(drawable, gc, mode, npt, ppt))
return;
miPolyPoint(drawable, gc, mode, npt, ppt);
}
+
+Bool
+glamor_poly_point_nf(DrawablePtr drawable, GCPtr gc, int mode, int npt,
+ DDXPointPtr ppt)
+{
+ if (glamor_poly_point_gl(drawable, gc, mode, npt, ppt))
+ return TRUE;
+
+ if (glamor_ddx_fallback_check_pixmap(drawable) && glamor_ddx_fallback_check_gc(gc))
+ return FALSE;
+
+ miPolyPoint(drawable, gc, mode, npt, ppt);
+ return TRUE;
+}
+
commit d5dd1d6371021c2aad94e33c5837ccd4bf9bf0f4
Author: Eric Anholt <eric at anholt.net>
Date: Fri Mar 21 13:13:27 2014 -0700
Revert "glx: Make sure we get an FBConfig the root window's visual."
This reverts commit b5a61239e2fef167c229154d7919ff862503e3f3.
Not only did I screw up and introduce a warning, it turns out
glXChooseFBConfig() explicitly ignores this attribute. Thanks, GLX.
Signed-off-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Julien Cristau <jcristau at debian.org>
diff --git a/hw/kdrive/ephyr/ephyr_glamor_glx.c b/hw/kdrive/ephyr/ephyr_glamor_glx.c
index 9903cc7..eaf5654 100644
--- a/hw/kdrive/ephyr/ephyr_glamor_glx.c
+++ b/hw/kdrive/ephyr/ephyr_glamor_glx.c
@@ -313,7 +313,6 @@ ephyr_glamor_get_visual(void)
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER, 1,
- GLX_VISUAL_ID, DefaultVisual(dpy, DefaultScreen(dpy)),
None
};
int event_base = 0, error_base = 0, nelements;
More information about the xorg-commit
mailing list