Commit Graph

200 Commits

Author SHA1 Message Date
Andrea Cavalli ea5e7c688e Test 2021-09-12 16:41:24 +02:00
Eric Anholt 8702c938b3 glamor: Introduce a central place for our pixmap format/type handling.
We had various helper functions trying to come up with the
internalformat/format/type/render formats for pixmaps, and it's much
nicer to just detect what those should be once at startup.  This gives
us a chance to do the right thing for GLES.

It also, notably, fixes our format/type for depth 15 and 16 setup for
desktop GL, so that we actually allocate 16bpp (GL_RGB/565) on most
drivers instead of 32bpp (GL_RGB/UBYTE).

GLES still has regressions over desktop (2 regressions in llvmpipe
XTS, many in rendercheck), but I think this is a good baseline.

Signed-off-by: Eric Anholt <eric@anholt.net>
2019-04-17 19:34:48 +00:00
Eric Anholt 34485be256 glamor: Stop trying to store the pixmap's "format" in glamor_pixmap_fbo.
"format" is a bit of a confused term (internalformat vs GL format),
and all we really needed was "is this GL_RED?"

Signed-off-by: Eric Anholt <eric@anholt.net>
2019-04-17 19:34:48 +00:00
Eric Anholt 1b2e224d7d glamor: Switch the gl_flavor to a boolean is_gles.
There are only 2 flavors we are distinguishing -- GL versions are
handled separately.

Signed-off-by: Eric Anholt <eric@anholt.net>
2019-04-17 19:34:48 +00:00
Michel Dänzer 2e256e8260 glamor: Allow HW acceleration for more RENDER formats
As long as the storage format is compatible.

v2:
* Remove explicit cases for formats handled by the default case.

Reviewed-by: Eric Anholt <eric@anholt.net>
2018-12-20 12:23:54 +01:00
Michel Dänzer 7e6faa5b3c glamor: Check that storage format is compatible with RENDER format
Fixes x2r10g10b10 related rendercheck failures.

Reviewed-by: Eric Anholt <eric@anholt.net>
2018-12-20 12:22:44 +01:00
Mario Kleiner 7a687da24c glamor: Enable composite acceleration for rgb10 formats. (v2)
Specifically for xrgb2101010 format.

Tested on KDE Plasma-5 with XRender based composite
acceleration backend. Much smoother and faster.

(v2) Dropped argb2101010, because of depth 32 confusion with
     argb8888, as pointed out by Eric. Thanks!
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Antoine Martin <antoine@nagafix.co.uk>
2018-02-27 10:18:06 -05:00
Adam Jackson 8171d4c2d6 render: Store and use all 16bpc of precision for solid pixels (v2.1)
This plumbs the full width color for solid pictures through to fb, exa,
and glamor. External drivers and acceleration code may wish to make a
similar change for sufficiently new servers.

v2: Don't break ABI (Michel Dänzer)
v2.1: Use the (correct) full color in fb too (Michel Dänzer)

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2018-02-26 16:46:34 -05:00
Adam Jackson 1edac5c1ce glamor: Unconditionalize GLAMOR_PIXMAP_DYNAMIC_UPLOAD
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2017-10-30 13:16:48 -04:00
Adam Jackson 13409b91b1 glamor: Unconditionalize GLAMOR_GRADIENT_SHADER
Effectively always true anyway.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2017-10-30 13:16:30 -04:00
Olivier Fourdan bd353e9b84 glamor: handle NULL source picture
COMPOSITE_REGION() can pass NULL as a source picture, make sure we
handle that nicely in both glamor_composite_clipped_region() and
glamor_composite_choose_shader().

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=101894
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2017-09-13 11:02:48 -04:00
Eric Anholt 27500ee82e glamor: Scissor Render composite operations to the bounds of the drawing.
Unlike the previous two fixes, this one introduces new GL calls and
statechanges of the scissor.  However, given that our Render drawing
already does CPU side transformation and inefficient box upload, this
shouldn't be a limiting factor for Render acceleration.

Surprisingly, it improves x11perf -comppixwin10 -repeat 1 -reps 10000
on i965 by 3.21191% +/- 1.79977% (n=50).

v2: Make the jump to the exit land after scissor disable.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2017-08-14 12:37:37 -07:00
Olivier Fourdan 8646398136 glamor: Two pass won't work on memory pixmaps
When selecting "CA_TWO_PASS" in glamor_composite_clipped_region() when
the hardware does not support "GL_ARB_blend_func_extended", we call
glamor_composite_choose_shader() twice in a row, which in turn calls
glamor_pixmap_ensure_fbo().

On memory pixmaps, the first call will set the FBO and the second one
will fail an assertion in glamor_upload_picture_to_texture() because
the FBO is already set.

Bail out earlier when the mask pixmap is in memory and the hardware
capabilities would require to use two pass, so that the assertion is not
failed and the rendering is correct.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99346
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2017-01-24 11:27:33 -08:00
Eric Anholt 20fcdfcf39 glamor: Remove #if 0-ed picture dumping code.
I don't think anybody has run this code since it was pulled into the
server.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2016-09-29 09:11:11 -07:00
Eric Anholt 117d614d1b glamor: Require GL_OES_texture_border_clamp for GLES2.
The extension came out in 2000, and all Mesa-supported hardware that
can do glamor supports it.  We were already relying on the ARB version
being present on desktop.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2016-09-29 09:10:53 -07:00
Eric Anholt 453f813bb4 glamor: Properly handle mask formats without alpha.
Even if the pixmap's storage has alpha, it may have been uploaded with
garbage in the alpha channel, so we need to force the shader to set
alpha to 1.  This was broken way back in
355334fcd9.

Fixes rendercheck -t composite -f x8r8g8b8.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-09-26 10:16:06 -07:00
Eric Anholt 905c877f09 glamor: Require that pixmap depths match for Render copies.
The copy optimization in d37329cba4
replicated a bug from last time we did a copy optimization: CopyArea
is only defined for matching depths.  This is only a problem at 15 vs
16 depth right now (24 vs 32 would also have matching Render formats,
but they should work) but be strict in case we store other depths
differently in the future.

Fixes rendercheck -t blend -o src -f x4r4g4b4,x3r4g4b4

v2: Drop excessive src->depth == dst->depth check that snuck in.
v3: Switch back to src->depth == dst->depth
v4: Touch up commit message (s/bpp/depth).

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-09-26 10:15:58 -07:00
Eric Anholt b87a075674 glamor: Fix some awful formatting of some fallback debug code.
This was clearly x-indent.sh damage.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-09-26 10:15:38 -07:00
Eric Engestrom 128d40b2dd glamor: fix spelling mistakes
v2: Fix "orignal" too (review feedback by ajax, change by anholt)_

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Eric Anholt <eric@anholt.net>
2016-09-25 10:40:08 -07:00
Michel Dänzer 5ff75da317 glamor: Cannot use copies when accessing outside of composite source
Commit b64108fa ("glamor: Check for composite operations which are
equivalent to copies") failed to copy conditions from exaComposite which
ensure that the composite operation doesn't access outside of the source
picture.

This fixes rendercheck regressions from the commit above.

Reviewed-by: Keith Packard <keithp@keithp.com>
2016-05-30 17:49:32 +09:00
Keith Packard 8b9b4387e8 glamor: Adjust for drawable x/y in composite's copy optimization
Patch b64108fa30 added a short cut that
identifies composite operations that can be performed with a simple
copy instead.

glamor_copy works in absolute coordinates, so the dx and dy values
passed in need to be converted from drawable-relative to absolute by
adding the drawable x/y values.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-05-27 13:24:39 -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
Keith Packard b07bc700b3 glamor: glamor_make_current sooner in glamor_composite_with_shader
glamor_make_current is supposed to be called before any GL APIs.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-05-26 09:17:59 -07:00
Keith Packard 743b6f231e glamor: Disable logic ops when doing compositing [v4]
If the logic op gets left enabled, it overrides the blending
operation, causing incorrect contents on the display.

v2: Disable only on non-ES2, but disable even for PictOpSrc

v3: Found another place this is needed in
    glamor_composite_set_shader_blend

v4: Remove change dependent on new glamor_set_composite_texture
    API. This belongs in a different patch.
    Found by Emil Velikov <emil.l.velikov@gmail.com>

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-05-26 09:17:59 -07:00
Michel Dänzer b64108fa30 glamor: Check for composite operations which are equivalent to copies
Increases x11perf -compwinwin500 numbers by a factor of 10 for me with
radeonsi.

Conditions copied from exaComposite().

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-05-25 11:10:14 -04:00
Michel Dänzer 4711ebc174 glamor: Fix sampling outside of RGBx source/mask pictures
RENDER requires that sampling outside of any source/mask picture results
in alpha == 0.0.

The OpenGL border colour cannot set alpha = 0.0 if the texture format
doesn't have an alpha channel, so we have to use the RepeatFix handling
in that case.

Also, only force alpha = 1.0 when sampling inside of RGBx source/mask
pictures.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94514
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-05-25 11:09:09 -04:00
Eric Anholt ee7ca670b1 glamor: Make sure that GLAMOR_MEMORY pixmaps don't retain an FBO.
glamor_composite_choose_shader() may upload our scratch pixmaps to get
a Render operation completed.  We don't want to hang onto GL memory
for our scratch pixmaps, since we'll just have to reallocate them at a
new w/h next time around, and the contents will be updated as well.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
2016-03-10 11:12:42 -05:00
Eric Anholt a96c6d4658 glamor: Simplify temporary picture uploading call stack.
glamor_upload_sub_pixmap_to_texture() only had the one caller, so we
can merge it in, fix its silly return value, and propagate a bunch of
constants.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
2016-03-10 11:12:42 -05:00
Eric Anholt 2c3e876844 glamor: Flip around conditionals in RepeatNone fixups.
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:52:41 -08:00
Eric Anholt e82c8c81df glamor: Cut down a bunch of conditional handling for RepeatFix.
For hardware that doesn't do actual jumps for conditionals (i915,
current vc4 driver), this reduces the number of texture fetches
performed (assuming the driver isn't really smart about noticing that
the same sampler is used on each side of an if just with different
coordinates).

No performance difference on i965 with x11perf -magpixwin100 (n=40).
Improves -magpixwin100 by 12.9174% +/- 0.405272% (n=5) on vc4.

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:52:41 -08:00
Eric Anholt 2c3273861c glamor: Clarify how the repeat values being passed around work.
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:52:41 -08:00
Eric Anholt 990a8ee013 glamor: Clean up formatting of RepeatFix shader code.
All sorts of weird indentation, and some cuddled conditional
statements deep in the if tree.

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:52:41 -08:00
Eric Anholt 20cb5b2d65 glamor: Clarify some logic in RepeatFix handling.
wh ratios are != 1.0 only when large, so with that we can simplify
down how we end up with RepeatFix being used.

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:52:41 -08:00
Eric Anholt 0dbce65b08 glamor: Reuse the glamor_program_alpha_* enums for Render.
This is a step toward using glamor_program.c for Render acceleration.

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:07 -08:00
Eric Anholt 9b676786de glamor: Drop extra SHADER_IN type for no mask present.
We can just hand in a constant mask and the driver will optimize away
the multiplication for us.

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:05 -08:00
Eric Anholt 9ef11f13af glamor: Clarify when Render fallbacks happen due to an unsupported op.
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:12:44 -08:00
Keith Packard e6754dcb59 glamor: Use GL_RED instead of GL_ALPHA if we have texture_swizzle (v3)
GL_RED is supported by core profiles while GL_ALPHA is not; use GL_RED
for one channel objects (depth 1 to 8), and then swizzle them into the
alpha channel when used as a mask.

[airlied: updated to master, add swizzle to composited glyphs and xv paths]

v2: consolidate setting swizzle into the texture creation code, it
    should work fine there. Handle swizzle when setting color as well.
v3: Fix drawing to a8 with Render (changes by anholt, reviewed by airlied).

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2016-01-26 12:03:54 -08:00
Eric Anholt 5042b0652b glamor: Drop duplicated GLAMOR_DEFAULT_PRECISIONs in render accel.
We only need it once at the top of the shader, so just put it
there.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2016-01-26 12:03:49 -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 cab14a9a08 glamor: Drop the composite_with_copy path entirely.
I originally inherited this from the EXA code, without determining
whether it was really needed.  Regular composite should end up doing
the same thing, since it's all just shaders anyway.  To the extent
that it doesn't, we should fix composite.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2016-01-26 12:02:37 -08:00
Eric Anholt 510c860564 glamor: Fix copy-like Render operations between 15 and 16 depth.
Reading and writing to 16-depth pixmaps using PICT_x1r5g5b5 ends up
failing, unless you're doing a straight copy at the same bpp where the
misinterpretation matches on both sides.

Fixes rendercheck/blend/over and renderhceck/blend/src in piglit.

Please cherry-pick this to active stable branches.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2016-01-21 17:50:25 -08:00
Eric Anholt 9a5972801f glamor: Fix segfault in fallback picture uploading.
If the source/mask pixmap is a pixmap that doesn't have an FBO
attached, and it doesn't match the Render operation's size, then we'll
composite it to a CPU temporary (not sure why).  We would take the
PictFormatShort from the source Picture, make a pixmap of that depth,
and try to look up the PictFormat description from the depth and the
PictFormatShort.  However, the screen's PictFormats are only attached
to the screen's visuals' depths.  So, with an x2r10g10b10 short format
(depth 30), we wouldn't find the screen's PictFormat for it
(associated with depth 32).

Instead of trying to look up from the screen, just use the pFormat
that came from our source picture.  The only time we need to look up a
PictFormat when we're doing non-shader gradients, which we put in
a8r8g8b8.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2015-11-10 13:55:51 -08:00
Eric Anholt 8097c88702 glamor: Drop tracking of the last picture attached to pixmaps.
Signed-off-by: Eric Anholt <eric@anholt.net>
Acked-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2015-07-10 09:42:58 -07:00
Eric Anholt 5a81de8284 glamor: Don't try to do rendering with unsupported formats.
I'm amazed we've made it as far as we have without these checks: if
you made an unusual format picture that wasn't the normal a8r8g8b8 or
x8r8g8b8 or a8, we'd go ahead and try to render with it, ignoring that
the sampler would fetch totally wrong bits.

Fixes 260 tests in rendercheck -t blend -o src -f a8r8g8b8,x2r10g10b10

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2015-07-10 09:42:58 -07:00
Eric Anholt 5c440817f7 glamor: Use ARRAY_SIZE in a couple more places for consistency.
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-07-02 10:06:36 -07:00
Eric Anholt 7b6edb5243 glamor: Mark a bunch of single-file data static.
This gives the compiler a chance to optimize when the data is never
changed -- for example, with pict_format_combine_tab, the compiler
ends up inlining the 24 bytes of data into just 10 more bytes of code.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-07-02 10:06:36 -07:00
Eric Anholt 3fe6731b17 glamor: Make a bunch of single-file glamor functions static.
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-07-02 10:05:59 -07:00
Eric Anholt 4fc4cde0ce glamor: Use the normal GL_QUADS drawing helper in the render code.
We use this for all of our other performance-sensitive rendering, too.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2015-06-29 21:43:35 -07:00
Eric Anholt c5e6fffbdd glamor: Drop CloseScreen-time GL resource cleanup code.
These will all be freed when the context is freed.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2015-06-29 21:43:35 -07:00
Dave Airlie fa12f2c150 glamor: don't do render ops with matching source/dest (v3)
XRender defines this, GL really doesn't like it.

kwin 4.x and qt 4.x seem to make this happen for the
gradient in the titlebar, and on radeonsi/r600 hw
this draws all kinds of wrong.

v2: bump this up a level, and check it earlier.
(I assume the XXXX was for this case.)
v3: add same code to largepixmap paths (Keith)

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2015-06-02 14:16:26 +10:00