Commit Graph

99 Commits

Author SHA1 Message Date
Dave Airlie a955286869 glamor: add EXT_gpu_shader4 support
This enables a number of the GLSL 1.30 paths on GPUs that have
EXT_gpu_shader4 but don't have GLSL 1.30 exposed.

(Intel gen4/5 mainly)

Reviewed-by: Adam Jackson <ajax@redhat.com>
2021-07-07 08:42:09 +10:00
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
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 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 a3d01ee9d0 glamor: Remove unused format_for_pixmap helper
Reviewed-by: Eric Anholt <eric@anholt.net>
2018-12-21 09:47:45 +01:00
Julien Isorce 44f5885686 glamor: add support for GL_RG
Allow to upload the CbCr plane of an NV12 image into a GL texture.

Signed-off-by: Julien Isorce <jisorce@oblong.com>
Tested-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-09-11 15:54:57 -04: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 aa29298416 glamor: unifdef XORG_VERSION_CURRENT
This is always true now that glamor is in-tree.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-02-26 16:38:36 -05:00
Hawking Zhang 9a416a478c glamor: Add 30bit RGB color format support
Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>

[ Michel Dänzer: Adapt to glamor changes since 1.19 ]

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-01-25 12:21:49 -05:00
Daniel Martin d5379b350f Use ARRAY_SIZE all over the tree
Roundhouse kick replacing the various (sizeof(foo)/sizeof(foo[0])) with
the ARRAY_SIZE macro from dix.h when possible. A semantic patch for
coccinelle has been used first. Additionally, a few macros have been
inlined as they had only one or two users.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2017-10-30 13:45:20 -04:00
Eric Anholt e6ab3b1109 glamor: Scissor CopyArea to the bounds of the drawing.
Like the previous fix to rectangles, this reduces the area drawn on
tiled renderers by letting the CPU-side tile setup know what tiles
might be drawn at all.

Surprisingly, it improves x11perf -copypixwin1 -repeat 1 -reps 10000
on i965 by 2.93185% +/- 1.5561% (n=90).

v2: Drop extra glamor_bounds_union_box() from previous debugging
    (caught by Mark Marshall).

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com> (v1)
2017-08-14 12:36:35 -07:00
Eric Anholt 60cc7e367a glamor: Scissor rectangle drawing to the bounds of the rects.
Scissors provide a critical hint to tiled renderers as to what tiles
need to be load/stored because they could be modified by the
rendering.

The bounds calculation here is limited to when we have a small number
of rects (large enough to cover rounded window corners, but probably
not xeyes) to avoid overhead on desktop GL.

No performance difference on i965 with x11perf -rect1 -repeat 1 -reps
10000 (n=50)

v2: Clamp rectangle bounds addition.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2017-08-14 12:35:55 -07:00
Michel Dänzer 7c88977d33 glamor: Store the actual EGL/GLX context pointer in lastGLContext
Fixes subtle breakage which could sometimes trigger after a server reset
with multiple screens using glamor:

Screen A enters glamor_close_screen last and calls various cleanup
functions, which at some point call glamor_make_current to make sure
screen A's GL context is current. This sets lastGLContext to screen A's
&glamor_priv->ctx. Finally, glamor_close_screen calls
glamor_release_screen_priv, which calls free(glamor_priv).

Later, screen B enters glamor_init, which allocates a new glamor_priv.
With bad luck, this can return the same pointer which was previously
used for screen A's glamor_priv. So when screen B's glamor_init calls
glamor_make_current, lastGLContext == &glamor_priv->ctx, so MakeCurrent
isn't called for screen B's GL context, and the following OpenGL API
calls triggered by glamor_init mess up screen A's GL context.

The observed end result of this was a crash in glamor_get_vbo_space
because glamor_priv->vbo didn't match the GL context, though there might
be other possible outcomes.

Assigning the actual GL context pointer to lastGLContext prevents this
by preventing the false negative test in glamor_make_current.

Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2017-06-05 18:32:15 +09: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 4b5326aeba glamor: Remove many unused glamor util functions.
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2016-09-29 09:11:09 -07:00
Eric Anholt 8f1411c384 glamor: Drop the REVERT_UPLOADING_1_5_5_5 path.
There was only a pretty special case that could have even worked --
you've got a GLES2 renderer, you've got a SHM pixmap, it's 1555 (not
the usual 565 for 16-bit), and you're little endian (BE was broken,
since GL's 5_5_5_1 picks the 1 bit from the lowest bit of the short,
and on BE we weren't doing the conversion path that swaps around the
channels).  This is just not worth the complexity.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
2016-03-10 11:12:43 -05:00
Eric Anholt 2cc7a0815e glamor: Drop the GLES2 REVERT_UPLOADING_2_10_10_10 paths.
These just smash your 2_10_10_10 data into 8888, despite what the
comments said.  That's not valid rendering, so just ditch this path
and fall back to software.  One might also note in the code being
removed here that the REVERT_UPLOADING_10_10_10_2 path wasn't even
connected.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
2016-03-10 11:12:43 -05:00
Eric Anholt c7574c63c6 glamor: Propagate that is_upload is always true.
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 5d7bef2eed glamor: Drop dead glamor_pict_format_is_compatible().
This hasn't been used since 2f80c7791b
(GLAMOR_SEPARATE_TEXTURE removal).

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:55 -08:00
Eric Anholt f7c24e6ac3 glamor: Rename the *y_inverted helpers to not say "inverted".
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:51 -08:00
Eric Anholt 1fcb6f4cbf glamor: Drop dead *_from_x_coord_y() functions.
They've been dead since the yInverted removal
(e310387f44).

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:48 -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 fde13565c1 glamor: Drop unused box translation/bounds code.
These are dead since the glamor_copy.c replacement.

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 ab5aa270c7 glamor: Move cache_format to glamor_fbo.c, where it's used.
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 0ca783e8ee glamor: Drop another dead function.
This hasn't been used since the format swap/revert stuff for pictures
was added back in 2012.

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 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 1bd966d16d glamor: Ignore picture formats when choosing color for core rendering.
Attaching a picture to a pixmap doesn't change its GL format, so it
doesn't change how core rendering should be assigning colors to it.

(Imagine XCreatePixmap(), optional XCreatePicture(pixmap) with various
formats, XFillRectangle, XGetImage().  If the XGetImage results
changed, this would be wrong).

Fixes all failures in "rendercheck -t fill" and, as a result, the
remaining failures 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 80b6652c9f glamor: Drop a bunch of glamor_priv == NULL checks.
Now that it's always non-null when the pixmap is non-null, we don't
need so much of this.  glamor_get_pixmap_private() itself still
accepts a NULL pixmap and returns NULL, because of glamor_render.c

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
Eric Anholt d278c30e68 glamor: Drop dead glamor_is_large_picture().
It died as of keithp's new glyphs code.

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
Eric Anholt fe3fedf280 glamor: Drop dead GLAMOR_FBO_DOWNLOADED flag.
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2015-07-02 10:05:59 -07:00
Eric Anholt 0e3f1252da glamor: Avoid using GL_QUADS on VC4.
Improves text rendering from about 284k glyphs per second to 320k
glyphs per second.  There's no GL extension for probing this, because
of the philosophy of "Don't expose whether things are really in
hardware or not."

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2015-06-29 21:43:36 -07:00
Eric Anholt 4001a7465e glamor: Provide a fallback path for using an index buffer to do quads.
Improves x11perf -aa10text performance by 1377.59% +/- 23.8198% (n=93)
on Intel with GLES2.

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 9e9fcf5780 glamor: Add a helper function for the common GL_QUADS fallback pattern.
We should do better than this with an index buffer, but for now at
least make it so that we don't have to copy the same code to new
places.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2015-03-24 12:43:34 -07:00
Keith Packard cc731ce0ca glamor: Create inline tests for small/large pixmaps
This will let us eliminate the pixmap types shortly

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
2015-03-24 12:35:02 -07:00
Keith Packard 020fcc5828 glamor: Eliminate separate 'large' pixmap private structure
Just embed the large elements in the regular pixmap private and
collapse the union to a single struct.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
2015-03-24 12:34:50 -07:00
Keith Packard af687396f1 glamor: Remove screen private and pixmap ptrs from pixmap private and fbo
There's no reason to waste memory storing redundant copies of the same
pointer all over the system; just pass in pointers as necessary to
each function.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
2015-03-24 12:32:46 -07:00
Keith Packard 1eb954c383 glamor: Remove remaining support for FBOs not matching pixmap size
The core rendering code already requires that FBOs be allocated at
exactly the pixmap size so that tiling and stippling work
correctly. Remove the allocation support for that, along with the
render code.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
2015-03-24 12:32:05 -07:00
Keith Packard c6ab135667 glamor: Remove ddx fallback check functions
With no DDX-based fallback support, we can remove these functions as
they are no longer called.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
2015-03-24 12:01:39 -07:00
Eric Anholt e310387f44 glamor: Remove always-true yInverted flag.
All users of glamor had the same value set, and it complicated things
for no reason.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-07-17 17:35:38 -07:00
Keith Packard 15e4d14dfa glamor: Replace fallback preparation code
These offer a simpler and more efficient means for temporarily
transitioning to CPU-accessible memory for fallback implementations.

v2: Do not attempt fallbacks with GLAMOR_DRM_ONLY pixmaps

    glamor cannot transfer pixels for GLAMOR_DRM_ONLY pixmaps using
    glReadPixels and glTexSubImage2D, and so there's no way to perform
    fallback operations with these pixmaps.

v3: Clear ->pbo field when deleting the PBO.  Otherwise, we'd reuse
    the old name next time we fall back on the pixmap, which would
    potentially conflict with some other pixmap that genned a new
    name, or just do a lazy allocation of the name (compat GL context,
    like we currently use) or error out (core GL context, like we hope
    to use some day).  Also, style fixes.  Changes by anholt, acked by
    keithp.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-06-15 22:02:40 +01:00
Eric Anholt fab0a4a4c9 glamor: Replace glamor_get/put_context() with just glamor_make_current().
Now that we have the DIX global state for the current context, we
don't need to track nesting to try to reduce MakeCurrent overhead.

v2: Fix a mistaken replacement of a put_context with make_current in
    glamor_fill_spans_gl() (caught by keithp).

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> (v1)
Reviewed-by: Adam Jackson <ajax@redhat.com> (v1)
2014-04-23 10:32:23 -07:00
Eric Anholt b5e394b3f5 glamor: Use lastGLContext to coordinate the context with GLX.
This gets us some more context changes that are needed to make sure
the two sides render to the right drawables and manipulate the right
objects.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-04-23 10:32:18 -07:00
Eric Anholt 93f1824a0b glamor: Rely on nested mappings to handle src==dst and !prepare bugs.
Now that the core deals with that for us, we can avoid all this extra
carefulness.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>
2014-03-17 14:30:56 -07:00
Eric Anholt ca507d215f glamor: Fix a spelling mistake in GLAMOR_PIXMAP_FBO_NOT_EXACT_SIZE.
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus at selfnet.de>
2014-03-10 11:06:27 -07:00
Eric Anholt 3747c26081 glamor: Move glamor_get_tex_format_type_from_pictformat to a .c file.
A pair of 150 lines of inlined switch statements in a header file is
crazy.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-02-14 18:30:01 -08:00
Eric Anholt 0e4f341418 glamor: Unifdef the cache format indices.
We only ask for GL_RGB on desktop GL as far as I can see, but now if
GLES2 did happen to ask for GL_RGB it would return a cache index
instead of -1.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-02-14 18:30:01 -08:00
Eric Anholt d63283860a glamor: Pass pixmaps around to unifdef glamor_iformat_for_depth().
v2: Just pass in the PicturePtr to glamor_pict_format_is_compatible()
    (suggestion by keithp)

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-02-14 18:30:01 -08:00
Eric Anholt 4afe15d8bf glamor: Put in a pluggable context switcher for GLX versus EGL.
The GLX side just gets the context from the current state.  That's
also something I want to do for EGL, so that the making a context is
separate from initializing glamor, but I think I need the modesetting
driver in the server before I think about hacking on that more.

The previous code was rather incestuous, along with pulling in xf86
dependencies to our dix code.  The new code just initializes itself
from the current state.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-02-14 18:30:01 -08:00
Eric Anholt 781c692cf9 glamor: Rename glamor_get/put_dispatch to glamor_get/put_context.
It used to be the thing that returned your dispatch table and happeend
to set up the context, but now it just sets up the context.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-02-14 18:29:56 -08:00
Eric Anholt 0373b3f4f7 glamor: Convert to using libepoxy.
Libepoxy hides all the GL versus GLES2 dispatch handling for us, with
higher performance.

v2: Squash in the later patch to drop the later of two repeated
    glamor_get_dispatch()es instead (caught by keithp)

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-02-14 18:28:56 -08:00