Commit Graph

854 Commits

Author SHA1 Message Date
Simon Ser
3bbfae73ae render/vulkan: add support for explicit sync 2024-10-28 17:51:21 +00:00
Simon Ser
9351c78d70 render/vulkan: add render_pass_destroy()
De-duplicate the cleanup logic.
2024-10-28 17:51:21 +00:00
Simon Ser
7ce868bcf6 render/vulkan: make VK_KHR_external_semaphore_fd optional
We already block instead of using sync_file when the driver
doesn't support import/export.
2024-10-03 19:24:30 +02:00
Simon Ser
3da6fac1f2 render/vulkan: check size when creating shm texture 2024-09-29 15:22:56 +00:00
Simon Ser
d55c175777 render/vulkan: log size when importing too-large DMA-BUF 2024-09-29 15:22:56 +00:00
YaoBing Xiao
0db4df4c8e gles2/pass: remove duplicate variable declarations 2024-08-27 20:25:18 +08:00
Alexander Orzechowski
3187479c07 render/color: Invert ownership model of color_transform types.
Color transform can have multiple types and these different types
want to store different metadata. We previously stored this metadata
directly on wlr_color_transform even for transforms that don't use it.

Instead, let's take the prior art from wlr_scene where each scene node
is built on a base node. Notice how wlr_color_transform_lut3d now has
a `struct wlr_color_transform base`. This is advantageous in multiple
ways:

1. We don't allocate memory for metadata that will never be used.
2. This is more type safe: Compositors can pass around a
struct wlr_color_transform_lut3d if they know they only want to use a
3d_lut.
3. This is more scalable. As we add more transform types, we don't have
to keep growing a monolithic struct.
2024-08-24 14:33:22 -04:00
Simon Ser
fa2abbeefb render/color: return tranform in wlr_color_transform_ref()
This is more consistent with the rest of the wlroots APIs and is
more concise.
2024-08-24 11:07:58 +02:00
Simon Ser
52dce29e06 render/vulkan: use non-coherent memory for read_pixels()
The spec for VkMemoryPropertyFlagBits says:

> device coherent accesses may be slower than equivalent accesses
> without device coherence [...] it is generally inadvisable to
> use device coherent or device uncached memory except when really
> needed

We don't really need coherent memory so let's not require it and
invalidate the memory range after mapping instead.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3868
2024-08-22 18:19:22 +02:00
Alexander Orzechowski
bfcaa4bc44 swapchain, damage_ring: Drop buffer age 2024-08-21 09:45:54 -04:00
YaoBing Xiao
3048fb3fc6 render/egl: Release devices before return 2024-08-19 23:18:11 +08:00
Kenny Levinsen
5df2b34d2b allocator/gbm: Reset errno before gbm_bo_create
Not all paths in GBM set errno properly on error. Reset it to zero
before calling GBM to avoid accidentally printing a garbage error.
2024-08-19 14:59:44 +02:00
Kenny Levinsen
ccd4703207 allocator/gbm: Log errno if gbm_bo_create fails 2024-08-19 14:41:09 +02:00
Simon Ser
e6dbe4580e render/gles2: check for DRM_CAP_SYNCOBJ_TIMELINE
Before advertising support for timelines, check for
DRM_CAP_SYNCOBJ_TIMELINE. Without this, the user cannot
create/import drm_syncobj timelines.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4715#note_2523517
2024-08-12 22:37:34 +00:00
Simon Ser
775817e278 render: add WLR_RENDER_NO_EXPLICIT_SYNC env var
This can be handy to figure out if a bug is due to explicit sync.
2024-08-06 17:37:06 +00:00
Simon Ser
edb867bc05 render/drm_syncobj: add wlr_drm_syncobj_timeline_export() 2024-08-06 17:37:06 +00:00
Simon Ser
5552de65f8 render/drm_syncobj: add wlr_drm_syncobj_timeline_transfer() 2024-08-06 17:37:06 +00:00
Simon Ser
d2374b3e4e render/gles2: implement explicit sync API 2024-08-06 17:37:06 +00:00
Simon Ser
19ffbfe356 render/egl: add support for explicit sync extensions 2024-08-06 17:37:06 +00:00
chenyongxing
015bb8512e render/vulkan: Fix draw rect clip region invalid in blend none mod 2024-07-16 14:24:46 +08:00
Simon Ser
59138460c4 render: init wl_shm version 2 2024-07-07 18:52:24 +02:00
Simon Ser
a75c6cca54 render/color: fix return value type
../render/color_lcms2.c: In function ‘wlr_color_transform_init_linear_to_icc’:
    ../render/color_lcms2.c:26:24: error: incompatible types when returning type ‘_Bool’ but ‘struct wlr_color_transform *’ was expected
       26 |                 return false;
          |                        ^~~~~
2024-06-27 18:13:05 +00:00
Simon Ser
099350a414 build: check eglext.h header version
We use EGL_EXT_device_drm_render_node, which has been introduced
here:
53f038f6fd
2024-06-27 17:54:57 +00:00
Kenny Levinsen
bf67eb342b render/vulkan: vkMapMemory stage spans up front
We always need these mapped for CPU access, so map it up front instead
of duplicating lazy mapping at each site of use.
2024-06-26 21:10:46 +00:00
Kenny Levinsen
bf0246e50c render/vulkan: Fix 3dlut stage span map offset
The mapping is shared between all users of the stage span, so it should
always map the whole thing and apply the allocation offset to the mapped
pointer.
2024-06-26 21:10:46 +00:00
Kenny Levinsen
6da71b6a89 render/vulkan: Unref color transform on pass submit
We increment the ref counter of the color transform at the start of the
render pass. Decrement it at the end to not leak the color transform.
2024-06-26 22:43:15 +02:00
Kenny Levinsen
bc82835756 render/vulkan: Use new span map handling for 3dlut
The use of stage spans for 3dluts was missed when the new cached
mappings were introduced, meaning that it would try to map and unmap
memory that might already have a cached mapping.

Vulkan does not support mapping memory multiple times, so make sure the
3dlut code also uses the cached mapping to avoid segfaults after unmap.
2024-06-26 13:14:07 +02:00
Kenny Levinsen
53464074e9 render/vulkan: Unmap span before freeing memory 2024-06-26 13:13:40 +02:00
Kenny Levinsen
47c578945c render/vulkan: Recycle memory maps for stage spans
Remapping buffers on every use causes a lot of unwanted pagefaults.
Reuse the mapping to significantly speed up the memcpy.
2024-06-24 15:55:10 +00:00
Simon Ser
d9bfb47648 render/drm_syncobj: add helpers to wait for timeline points
References: https://patchwork.freedesktop.org/patch/506761/
2024-06-12 18:39:45 +02:00
Simon Ser
ea75aa3065 render/drm_syncobj: add wlr_drm_syncobj_timeline_import() 2024-06-12 18:38:42 +02:00
Simon Ser
7fc00ef777 render/drm_syncobj: introduce wlr_drm_syncobj_timeline
wlr_drm_syncobj_timeline is a synchronization primitive based on
drm_syncobj timelines. They are heavily inspired from Vulkan
timeline semaphores [1].

[1]: https://www.khronos.org/blog/vulkan-timeline-semaphores
2024-06-12 17:45:06 +02:00
Simon Ser
6d07193bda render/color: add fallback stub when LCMS2 is disabled
It's cumbersome for compositors to guard every
wlr_color_transform_ref() or wlr_color_transform_unref() call
behind a #if WLR_HAS_COLOR_MANAGEMENT. Moreover, none of the LCMS2
types are used in our public API.

Instead, always install the color.h header, and add a stub for
wlr_color_transform_init_linear_to_icc().
2024-06-04 17:45:51 +00:00
David Turner
34201b0e7f render/pixman: Fix non-uniform scale with rotation
e08d52bb introduced a bug when rotating by 90 or 270 degrees and doing
non-uniform scaling (different scale factor on X and Y axes).  The scale
factor was calculated as the ratio between the src box and the rotated
dst box.  But scaling is applied after rotation, so the scale factor
should instead be the ratio between rotated src box and dst box.
2024-05-23 11:56:59 +00:00
David Turner
d7f63ab76c render/pixman: Remove half-pixel shift
Reverts 77006e5565.  It turns out this
change really breaks the labwc drop-shadow implementation (which relies
on scaling up single-pixel-wide buffers).

After reverting this there's still something subtley wrong with scaling
pixel locations (shown by `weston-scaler -b`) but I can't see an obvious
way to make both weston-scaler and labwc drop-shadows work in the same
way with pixman and gles2. I'll have a harder look at this but in the
mean time reverting this patch seems to make things less broken on
average.
2024-05-23 11:56:59 +00:00
Simon Ser
2c4d3ad12d render/vulkan: don't use UNDEFINED layout for imported DMA-BUFs
UNDEFINED when used as source layout means that the contents of
the underlying memory becomes undefined. This isn't what we want
here: we don't want to mutate the imported pixel data.

The Vulkan spec isn't really clear what the proper value should be
here, but after discussing with driver developers [1] it seems like
UNDEFINED isn't the right one. The recommendation is to use GENERAL
instead.

[1]: https://github.com/ValveSoftware/gamescope/issues/356
2024-05-14 13:14:28 +02:00
Kirill Primak
f0b7fb72a8 render/vulkan: don't free a descriptor set from an already destroyed lut3d dummy pool 2024-05-09 19:07:54 +03:00
Kirill Primak
073c3e8837 render/vulkan: free render format setups on destroy 2024-05-09 18:47:02 +03:00
Kirill Primak
e20ae113f8 render/vulkan: free pipeline layouts on destroy 2024-05-09 18:46:55 +03:00
Kirill Primak
00bc75439f render/vulkan: fix texture clip region leak 2024-05-09 18:40:31 +03:00
Simon Ser
aa340ade65 render/color: split off lcms2 code
Fixes compilation with color management disabled.
2024-04-30 16:56:03 +02:00
David Turner
77006e5565 render/pixman: half-pixel shift to match GPUs
Add a half-pixel shift in the pixman renderer to match the results given
by GPU-based renderers when scaling.
2024-04-30 14:02:21 +00:00
David Turner
e08d52bbc6 render/pixman: Improve transform performance
The old code to render transformed textures with pixman would run
composite over the whole output regardless of the texture size.  When
rendering something small this caused a huge performance hit.

Rewrite the transform branch of render_pass_add_texture to:
- Only composite over the rectangle we're drawing to
- Generally try to make things a lot clearer and some comments

Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3832
2024-04-30 14:02:21 +00:00
Manuel Stoeckl
82b4bc3f5f renderer: add field to indicate color transform support 2024-04-26 17:17:36 +00:00
Manuel Stoeckl
ffdbfdbbbd render/vulkan: add support for output color transforms 2024-04-26 17:17:36 +00:00
Manuel Stoeckl
e443434876 render/vulkan: create plain framebuffers on demand
This change makes it possible to support both the direct srgb-format
pipeline and indirect (color-managed, or non-srgb-format) pipeline
for the same render buffer.
2024-04-26 17:17:36 +00:00
Manuel Stoeckl
adbfd3c321 render/vulkan: add lut3d output shader option
While a corresponding pipeline is created, it is not yet used.
2024-04-26 17:17:36 +00:00
Manuel Stoeckl
c64144a39b render/vulkan: add dummy 3d lookup table to output shader
Later commits will add shader options that use a real 3d
lookup table.
2024-04-26 17:17:36 +00:00
Simon Ser
895e3d18b9 render/color: introduce wlr_color_transform
Co-authored-by: Manuel Stoeckl <code@mstoeckl.com>
2024-04-26 17:17:36 +00:00
David Turner
ee0007c0f2 render/pixman: Fix source crop
Fix source crop in the pixman render backend.  It was being applied by
using a source offset as arguments to pixman_image_composite32().  But
this is wrong because the source crop should get applied before all the
other transforms, not after them (or at least this is how it works in
the other wlroots render backends).  Instead, apply the source crop as
yet another matrix transform when we're doing transforms (Or keep it the
same as previously if there's no other transforming going on).

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3830
2024-04-26 16:12:38 +00:00