Commit Graph

14 Commits

Author SHA1 Message Date
Dave Airlie a2f5b917f5 glamor: add glamor_glsl_has_ints wrapper
This should make adding gpu shader4 support cleaner

Reviewed-by: Adam Jackson <ajax@redhat.com>
2021-07-07 08:41:50 +10:00
Michel Dänzer be334f42a1 glamor: Declare "pos" in the composite glyph GLSL 1.20 vertex shader
Fixes shader compile failure:

 Failed to compile VS: 0:13(43): error: `pos' undeclared
0:13(14): error: operands to arithmetic operators must be numeric
0:13(13): error: operands to arithmetic operators must be numeric

 Program source:
#define ATLAS_DIM_INV 0.000976562500000000
attribute vec2 primitive;
attribute vec2 source;
varying vec2 glyph_pos;
uniform vec2 fill_offset;
uniform vec2 fill_size_inv;
varying vec2 fill_pos;
uniform vec4 v_matrix;
void main() {
       gl_Position.xy = primitive.xy * v_matrix.xz + v_matrix.yw;
       gl_Position.zw = vec2(0.0,1.0);
       glyph_pos = source.xy * ATLAS_DIM_INV;
       fill_pos = (fill_offset + primitive.xy + pos) * fill_size_inv;
}
 (EE) Fatal server error:
 (EE) GLSL compile failure

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97300
Reviewed-by: Keith Packard <keithp@keithp.com>
2016-08-23 12:59:55 +09:00
Keith Packard 2d6230e773 glamor: Use DestroyPixmap instead of FreePicture for glyph atlas pixmap
Nice of FreePicture to take a void * instead of a PicturPtr so that
this error wasn't caught by the compiler.

Noticed when resetting the X server left a dangling pixmap around.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-06-14 22:47:00 -07:00
Keith Packard 181a4bd0cc glamor: Preserve GL_RED bits in R channel when destination is GL_RED [v2]
A1 and A8 pixmaps are usually stored in the Red channel to conform
with more recent GL versions. When using these pixmaps as mask values,
that works great. When using these pixmaps as source values, then the
value we want depends on what the destination looks like.

For RGBA or RGB destinations, then we want to use the Red channel
for A values and leave RGB all set to zero.

For A destinations, then we want to leave the R values in the Red
channel so that they end up in the Red channel of the output.

This patch adds a helper function, glamor_bind_texture, which performs
the glBindTexture call along with setting the swizzle parameter
correctly for the Red channel. The swizzle parameter for the Alpha
channel doesn't depend on the destination as it's safe to leave it
always swizzled from the Red channel.

This fixes incorrect rendering in firefox for this page:

	https://gfycat.com/HoarseCheapAmericankestrel

while not breaking rendering for this page:

	https://feedly.com

v2: Add change accidentally left in patch for missing
    glDisable(GL_COLOR_LOGIC_OP).
    Found by Emil Velikov <emil.l.velikov@gmail.com>

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=63397
Signed-off-by: Keith Packard <keithp@keithp.com>
Tested-by: Michel Dänzer <michel.daenzer@amd.com>
2016-05-26 09:17:59 -07:00
Eric Anholt 07f0d90e4a glamor: Simplify the pixmap box looping.
We had a double loop across h and w, and passed the current x and y
out to callers who then used w to multiply/add to an index.  Instead,
just single loop across w * h.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-01-29 18:13:09 -08:00
Dave Airlie e7308b6c77 glamor: Add support for CA rendering in a single pass.
It's been on the list to add dual source blending support to avoid the
two pass componentAlpha code.  Radeon has done this for a while in
EXA, so let's add support to bring glamor up to using it.

This adds dual blend to both render and composite glyphs paths.

Initial results show close to doubling of speed of x11perf -rgb10text.

v2: Fix breakage of all of CA acceleration for systems without
    GL_ARB_blend_func_extended.  Add CA support for all the ops we
    support in non-CA mode when blend_func_extended is present.  Clean
    up some comments and formatting.  (changes by anholt)

Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
2016-01-26 12:02:42 -08:00
Eric Anholt a6b05d10da glamor: Fix crashes when the glyph atlas allocation fails.
We already have a fallback path, so we just need to jump to it when we
hit the failure.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2015-11-10 13:55:44 -08:00
Eric Anholt cd608a516d glamor: Reuse the glamor_is_memory helper.
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2015-07-10 09:42:57 -07:00
Keith Packard c268d2fc33 glamor: Fix bad rendering of glyphs after an a1 glyph upload. (v3)
Fixes regressions since Eric's "don't make an FBO for the glyph atlas"
change.  The a1 upload was a fallback, as expected.  However, fallback
reads use glReadPixels() because there's no glGetTexSubImage2D() to
match glTexSubImage2D().  We were just binding the 0 FBO value, so the
glReadPixels() would throw a GL error instead of getting any data.
After the fallback was done we'd write back the undefined data to the
atlas, blowing away the entire rest of the atlas because we didn't
specify any bounds on our prepare.

To fix the fallbacks to actually work, we'd need a prepare path that
allocates some memory memory do a full glGetTexImage() into, then
memcpy out of that.  Instead, just dodge the general fallback by
implementing the specific upload we need to do here, which should also
be *much* faster at uploading a1 glyphs since it's not
readpixels/texsubimaging back and forth.

v3: Use CopyPlane to a temp pixmap for the upload
v4: Rewrite anholt's commit message to be from keithp's perspective
    (changes by anholt)

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
2015-07-06 12:01:07 -07:00
Eric Anholt 3d6dcad00d glamor: Fix text rendering on GLES2.
The GL_QUADS helper takes a number of quads, not a number of vertices.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2015-06-29 21:43:08 -07:00
Eric Anholt 790311cec3 glamor: Don't try to disable attrib divisors without the extension.
Fixes epoxy assertion failures on vc4.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2015-06-19 19:11:05 -07:00
Eric Anholt 9c679d0605 glamor: Skip actual FBO setup in our glyph atlas.
VC4 (and many GLES2 renderers) can't render to GL_ALPHA, so our pixmap
would end up as GLAMOR_MEMORY and our dereference of the FBO would
setfault.  Instead, tell the pixmap creation that we don't need an FBO
at all.  Our glyph upload path was already glTexImage for non-a1, and
a more general software fallback for a1 (since the glyph is also in
system memory).

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2015-06-19 19:11:03 -07:00
Eric Anholt 077bb1bdea glamor: Clean up some declarations in glyph rendering.
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2015-06-19 19:11:01 -07:00
Keith Packard b0d2e01031 glamor: Replace CompositeGlyphs code [v2]
New composite glyphs code uses the updated glamor program
infrastructure to create efficient shaders for drawing render text.

Glyphs are cached in two atlases (one 8-bit, one 32-bit) in a simple
linear fashion. When the atlas fills, it is discarded and a new one
constructed.

v2: Eric Anholt changed the non-GLSL 130 path to use quads instead of
two triangles for a significant performance improvement on hardware
with quads. Someone can fix the GLES quads emulation if they want to
make it faster there.

v3: Eric found more dead code to delete

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2015-05-14 16:32:07 -07:00