Commit Graph

1035 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult ee302a1ac0 (submit/drop-obsolete-have-dix-config.h) drop obsolete HAVE_DIX_CONFIG_H
The symbol controls whether to include dix-config.h, and it's always set,
thus we don't need it (and dozens of ifdef's) anymore.

This commit only removes them from our own source files, where we can
guarantee that dix-config.h is present - leaving the (potentially exported)
headers untouched.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 20:51:21 +02:00
Enrico Weigelt, metux IT consult f26f17c66a treewide: mark pGC->ops->CopyArea() calls not using result as void
We alread have several of these calls, that aren't interested in result value,
explicitly casting to void. Fixing this up for the remaining ones.

This is helpful for the human reader as well as quality analysis tools.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1648>
2024-08-26 03:44:23 +00:00
Nicolas Dufresne 39c8a6f367 glamor: xv: Rewrite UYVY shader to match NV12/I420 CSC
This rewrites the shader so that we use the same (more flexible) CSC as
we have for I420 and NV12. This also fixes the reverse of odd/even which
caused chroma shift.

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1633>
2024-08-01 10:51:20 +03:00
Konstantin eb26f32368 glamor: xv: fix UYVY alignment
UYVY videos should be aligned by 2 to avoid breakups in the shader

Fixes: 832b392f7 - glamor: xv: enable UYVY acceleration
Suggested-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Konstantin <ria.freelander@gmail.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1633>
2024-08-01 10:48:25 +03:00
Konstantin 75f56b7923 glamor: check BPP by render_format.
Check actual BPP by render_format in upload_boxes, not by drawable BPP.

It is required when we used different BPP formats for storing and
rendering (for example, in the case of UYVY).

The problem of UYVY size lies inside method of glamor downloading boxes.

When we set GLAMOR_CREATE_FORMAT_CBCR, it actually uses 16-bit GL and
Pixman formats, but before this change in glamor_download_boxes, that
function deduces GL and Pixman formats from BPP, which is wrong in this
case (will be deduced to 32).

When GL and Pixman format BPP is identical to drawable BPP, this change
does nothing, but when it is different - it will prioritize Pixman
format, not the format deduced from BPP.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1730
Signed-off-by: Konstantin Pugin <ria.freelander@gmail.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1633>
2024-08-01 10:48:11 +03:00
Olivier Fourdan 34ea020344 glamor: Fix possible double-free
If glamor_link_glsl_prog() fails, we may jump to the failed code path
which frees the variable vs_prog_string and fs_prog_string.

But those variables were already freed just before, so in that case we
end up freeing the memory twice.

Simply move the free at the end of the success code path so we are sure
to free the values only once, either in the successful of failed code
paths.

Fixes: 2906ee5e4 - glamor: Fix leak in glamor_build_program()
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1629>
2024-07-29 13:49:27 +00:00
Enrico Weigelt, metux IT consult dec57e5796 treewide: replace xnfstrdup() calls by XNFstrdup()
This has been nothing but an alias for two decades now (somewhere in R6.6),
so there doesn't seem to be any practical need for this indirection.

The macro still needs to remain, as long as (external) drivers still using it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1529>
2024-07-26 23:41:34 +00:00
Enrico Weigelt, metux IT consult c55ddd072b treewide: replace xnfalloc() calls to XNFalloc()
This has been nothing but an alias for two decades now (somewhere in R6.6),
so there doesn't seem to be any practical need for this indirection.

The macro still needs to remain, as long as (external) drivers still using it.

Fixes: ded6147bfb
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1529>
2024-07-26 23:41:33 +00:00
Enrico Weigelt, metux IT consult b30edf326b fix missing includes of <X11/Xfuncproto.h>
Several places using _X_ATTRIBUTE_PRINTF macro from X11/Xfuncproto.h
but missing to include it, so it depends on other headers whether it's
included by mere accident, which quickly causes trouble if include order
changes. Cleaning that up by adding explicit include statements.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1580>
2024-07-20 17:18:38 +00:00
Alan Coopersmith 522f469fe9 Move sizeof to second argument in calloc calls
Clears -Wcalloc-transposed-args warnings from gcc 14.1, such as:

../dix/main.c:165:42: warning: ‘calloc’ sizes specified with ‘sizeof’ in the
 earlier argument and not in the later argument [-Wcalloc-transposed-args]
  165 |             serverClient = calloc(sizeof(ClientRec), 1);
      |                                          ^~~~~~~~~
../dix/main.c:165:42: note: earlier argument should specify number of
 elements, later size of each element

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1606>
2024-07-19 23:45:21 +00:00
Michel Dänzer 08113b8923 xwayland/glamor: Handle depth 15 in gbm_format_for_depth
Prevents Xwayland with glamor from logging

 unexpected depth: 15

to stderr many times when running

 rendercheck -t blend -o clear

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1507>
2024-04-25 17:17:55 +02:00
Balló György 007e98b186 glamor: Fallback to software rendering on GLSL link failure
Instead of thowing fatal error on GLSL link failure, fall back to software
rendering. This allows using Glamor on systems with limited hardware resources
(such as i915).

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1173>
2024-04-11 12:01:14 +00:00
Enrico Weigelt, metux IT consult 368055d3f1 render: move private definitions out of public glyphstr.h
Public module API headers don't need / shouldn't to contain anything that
isn't part of the API (non-exported functions, etc).

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1287>
2024-03-03 22:54:16 +00:00
Enrico Weigelt, metux IT consult e343a52fcf glamor: drop duplicate _X_EXPORT from .c source
These are already defined in glamor.h

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1274>
2024-03-03 22:34:26 +00:00
Enrico Weigelt, metux IT consult 113ffdf85c glamor: glamor_debug.h: drop unused AbortServer() declaration
This really looks like a leftover from b861aad8e2.

In any case, if that function shall become part of extension/driver API,
it should be declared with _X_EXPORT in some suitable header file - locally
declaring extern really isn't a good idea and just an invitation for subtle bugs.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1265>
2024-03-03 22:29:52 +00:00
Michel Dänzer e5a3f3e84d glamor: Fall back for mixed depth 24/32 in glamor_set_alu
For ALUs which may leave the alpha channel at values other than 1.0.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1615

v2:
* List safe ALUs instead of unsafe ones
2024-01-11 10:03:10 +00:00
Michel Dänzer 8f66c15694 glamor: Make glamor_set_alu take a DrawablePtr
Preparation for the following commit, no functional change intended.
2024-01-11 10:03:10 +00:00
Michel Dänzer d1bbf82d72 glamor: Don't override source alpha to 1.0 if it's used for blending
It caused an incorrect result of the blend operation.

Use glColorMask to prevent non-1.0 alpha channel values in a depth 32
pixmap backing an effective depth 24 window. For blending operations,
the expectation is that the destination drawable contains valid pixel
values, so the alpha channel should already be 1.0.

Fixes: d1f142891e ("glamor: Ignore destination alpha as necessary for composite operation")
Issue: https://gitlab.gnome.org/GNOME/mutter/-/issues/3104
2024-01-10 08:56:26 +00:00
Ville Syrjälä 2bf0f9e113 glamor: Enable dmabuf_capable by default on Intel hardware
With the potential modeset vs. modifiers issue covered by
commit 899c87af1f ("modesetting: unflip before any setcrtc() calls")
we can safely enable modifiers by default, at least on Intel
hardware where we know that things work properly.

I suppose the one open question is whether everything will work
correctly with wonky multi-GPU setups? I don't have one to test
myself.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2023-12-19 02:52:26 +02:00
msizanoen1 e2eeaab2a4 glamor: Use render node for glamor device path where possible
On certain system deployments, /dev/dri/card* nodes aren't directly
accessible to the currently logged in user, but the display server only
access it by asking systemd-logind to open the device for it. This
causes the X server to fail when trying to re-open the card* device
directly, causing all use of DRI3 to fail.

Fix this by using the render device path instead where possible.
2023-12-17 17:45:06 +00:00
Alexey 4cf8922270 Fixed mirrored glyphs on big-endian machines 2023-12-17 16:44:45 +00:00
Yuriy Vasilev c170056111 glamor: xv: add rgb565
This commit adds RGB565 format to XVideo with reuse of RGBA32 shader

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Yuriy Vasilev <uuvasiliev@yandex.ru>
2023-11-29 21:18:29 +00:00
Yuriy Vasilev 15412e78c8 glamor: xv: add rgba32 format
This commit adds RGBA32 format to XVideo along with shader for handling it.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Yuriy Vasilev <uuvasiliev@yandex.ru>
2023-11-29 21:18:29 +00:00
Konstantin 832b392f70 glamor: xv: enable UYVY acceleration
This commit adds UYVY format in XVideo for Glamor
along with shader support.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-29 21:18:29 +00:00
Konstantin ffd7151b10 glamor: xv: prepare to one-plane formats
As a preparation to one-plane formats (for example, UYVY), second
texture definition is moved inside a format switch, and all allocations
now also done inside a texture switch.
No functional change.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-29 21:18:29 +00:00
Konstantin 81ef43dd4a glamor: xv: reuse ports and shaders when possible
Xv currently calls glamor_xv_free_port_data at the end of every putImage.
This leads to shader recompilation for every frame, which is a huge performance loss.
This commit changes behaviour of glamor_xv_free_port_data, and its now is called only
if width, height or format is changed for xv port.

Shader management also done in a port now, because if shaders will be
stored in core glamor and try to be reused, this can lead to a bug if we
try to play 2 videos with different formats simultaneously.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-29 21:18:29 +00:00
Konstantin a8270fc5f0 glamor: xv: do not force a version on XV shaders
There is a no need to force a low version for XV shaders, it will
work on higher version too.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-29 21:18:29 +00:00
Konstantin 10d7fa53f8 Revert "glamor/glxprov: Stop exposing non-db(-capable) configs"
The recent commit a563f530 - "glamor/glxprov: Stop exposing non-db
(-capable) configs" was aiming at reducing the number of advertised
visuals for optimizing GLX initialization.

Unfortunately, GL applications which rely exclusively on single-buffered
visuals will fail to find a suitable visual with this.

Revert the commit to expose the single-buffered visuals and restore the
compatibility with applications which rely on single-buffered configs.

This reverts commit a563f530f6

Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-14 17:44:47 +03:00
Konstantin Pugin 8252b110f3 Xephyr: use glamor glx provider
Xephyr now gained an ability to use glamor glx provider.
Unfortunately, without DRI3, we end up with same llvmpipe as before

Signed-off-by: Konstantin Pugin <ria.freelander@gmail.com>
2023-11-07 18:20:48 +03:00
Konstantin a449bb4c5d glamor_egl: add support of GlxVendorLibrary option
Same semantics as in glxdri2.c, and same purpose.

Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-07 17:59:43 +03:00
Konstantin Pugin a987fc7c36 xorg: initialize glamor provider
This allows Xorg to use Glamor GLX when Glamor is requested,
and eliminates usage of DRI2 in case of Glamor.

Signed-off-by: Konstantin Pugin <ria.freelander@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Acked-by: Emma Anholt <emma@anholt.net>
2023-11-07 17:59:43 +03:00
Adam Jackson a563f530f6 glamor/glxprov: Stop exposing non-db(-capable) configs 2023-11-07 17:59:24 +03:00
Adam Jackson 58b88ba0b1 glamor: Lift the GLX EGL backend from Xwayland
This code is almost entirely ddx-agnostic already, and I'd like to use
it from the other EGL glamor consumers. Which, right now that's just
Xorg, but soon it'll be Xephyr too.
2023-11-07 17:59:24 +03:00
Konstantin Pugin 3caf7aa88d glamor: add glvnd_vendor private
This commit adds an ability to store a glvnd vendor in Glamor
structures, which can be used for initialize some vendor-based values
without hooking into DDX internals. Also this adds setting this value
into Xorg and Xwayland

Signed-off-by: Konstantin Pugin <ria.freelander@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Acked-by: Emma Anholt <emma@anholt.net>
2023-11-07 17:59:24 +03:00
Konstantin c014f33b43 glamor_egl: add info message about context API
It is useful to know on what context we are running, and
we need to show it into xorg.log

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-02 08:18:00 +00:00
Konstantin a44a4b0d4d glamor_egl: add RenderingAPI option
This allows to choose between Glamor on OpenGL and Glamor on OpenGL ES
via an option.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-02 08:18:00 +00:00
Konstantin d5c2a4d3f5 glamor_egl: add helper functions for contexts
This is just a split big glamor_egl_init to 3 smaller functions.
No functional change.

Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-02 08:18:00 +00:00
Balló György 910847f452 glamor: Don't require EXT_gpu_shader4 unconditionally
It causes a shader compilation error on systems without EXT_gpu_shader4.

Fixes: ee107cd4
2023-11-01 07:31:32 +00:00
Konstantin Pugin e573d4ca03 glamor: accelerate incomplete textures for GL ES
If texture can be uploaded to GL using glTexImage2D normally, but
cannot be read back using glReadPixels, we still can accelerate it,
but we cannot create pixmap with FBO using this texture type. So,
add a flag to avoid such creations.

This allow us to accelerate 8-bit glyph masks on GL ES 2.0, because those
masks are used only as textures, and in next stages are rendered on RGBA
surfaces normally, so, we do not need to call glReadPixels on them.

This is needed for correctly working fonts on GL ES 2.0, due to inability
to use GL_RED and texture swizzle. We should use GL_ALPHA there, and
with this format we cannot have a complete framebuffer. But completed
framebuffer, according to testing, is not required for fonts anyway.
Also it fixes all 8-bit formats for GLES2.

Fixes #1362
Fixes #1411

Signed-off-by: Konstantin Pugin <ria.freelander@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Acked-by: Martin Roukala <martin.roukala@mupuf.org>
2023-10-20 14:09:57 +03:00
Jeffy Chen 0076671e24 glamor: xv: Fix invalid accessing of plane attributes for NV12
NV12 only has 2 planes.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2023-10-10 20:18:43 +00:00
Konstantin Pugin ee107cd491 glamor: support GLES3 shaders
Some hardware (preferably mobile) working on GLES3 way faster than
on desktop GL and supports more features. This commit will allow using
GLES3 if glamor is running over GL ES, and version 3 is supported.

Changes are the following:
1. Add compatibility layer for 120/GLES2 shaders with defines in and out
2. Switch attribute and varying to in and out in almost all shaders
   (aside gradient)
3. Add newGL-only frag_color variable, which defines as gl_FragColor on
   old pipelines
4. Switch all shaders to use frag_color.
5. Previous commit is reverted, because now we have more than one GL ES
version, previous commit used to set version 100 for all ES shaders, which
is not true for ES 3

Signed-off-by: Konstantin Pugin <ria.freelander@gmail.com>
2023-10-09 17:25:28 +00:00
Konstantin f273c960c1 glamor: add gl_PointSize for ES shaders
GLES3.2 spec, page 126:
> The variable gl_PointSize is intended for a shader to write
> the size of the point to be rasterized. It is measured in pixels.
> If gl_PointSize is not written to, its value
> is undefined in subsequent pipe stages.

If glamor shader is use points, we should define gl_PointSize for GLES.
On Desktop GL, it "just work" due to default gl_PointSize is 1.

As @anholt requested, define this only for minimal amount of shaders
(point and glyphbit ones), to make sure than performance will not
affected

Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-09-20 03:00:00 +00:00
Konstantin baaddf47d5 glamor: fixes GL_INVALID_ENUM errors on ES if there is no quads
If there is no quads to draw, then we have a possibility to call
glDrawElements with type as zero, which will generate
GL_INVALID_ENUM error. While this error is harmless, it is annoying.

Signed-off-by: Konstantin <ria.freelander@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2023-09-19 13:42:34 +03:00
Michel Dänzer d1f142891e glamor: Ignore destination alpha as necessary for composite operation
If the destination drawable is a window with effective depth 24 backed
by a depth 32 pixmap.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1575
2023-09-12 16:57:16 +02:00
Michel Dänzer d4e11f4c92 glamor: Make glamor_solid_boxes take a DrawablePtr
Instead of a PixmapPtr. Gives better results if the window depth
doesn't match the backing pixmap depth.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1565
2023-07-20 10:14:56 +02:00
Michel Dänzer 3e044b1e64 glamor: Add and use glamor_drawable_effective_depth helper
Consider the following window hierarchy, from ancestors to descendants:

 A
 |
 B
 |
 C

If both A & C have depth 32, but B has depth 24, C must effectively
behave as if it had depth 24, even if its backing pixmap has depth 32
as well.

Fixes the xmag issue described in the GitLab issue below.

Issue: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1564
2023-07-20 10:14:56 +02:00
Michel Dänzer 16aa40f1c8 glamor: Use DrawablePtr in struct copy_args
Will give better results if the window depth doesn't match the backing
pixmap depth.
2023-07-18 09:34:39 +00:00
Michel Dänzer 5371690891 glamor: Fix up alpha channel if needed in glamor_upload_boxes
It's needed for a depth 24 window backed by a depth 32 pixmap, to make
sure the window's pixels sample alpha as 1.0.

v2:
* Make sure glamor_finish_access doesn't pass in a NULL pointer.
2023-07-18 09:34:39 +00:00
Michel Dänzer 78e0bb500e glamor: glamor_prep_pixmap_box → glamor_prep_drawable_box
Pass the DrawablePtr directly to glamor_download_boxes. This will allow
for better results if the window depth doesn't match the backing pixmap
depth.
2023-07-18 09:34:39 +00:00
Michel Dänzer ff27ffa1c1 glamor: Eliminate glamor_fini_pixmap
Pass the DrawablePtr directly from glamor_finish_access to
glamor_upload_boxes. This will allow for better results if the window
depth doesn't match the backing pixmap depth.
2023-07-18 09:34:39 +00:00