Commit Graph

799 Commits

Author SHA1 Message Date
John Lindgren b1b34cd665 vulkan: perform sRGB-to-linear conversion correctly for premultiplied values
Pre-multipled sRGB values need to be un-multiplied before conversion
to linear and then re-multiplied after. Compare shaders/texture.frag.

This fixes an issue in labwc where titlebar corners (rendered as
ARGB textures) did not match the rest of the titlebar (rendered as
a solid wlr_scene_rect).

Note: 0.17 has other instances in render/vulkan/renderer.c that need
the same fix.
2024-04-11 09:24:03 +00:00
Biswapriyo Nath dd2061b073 render/vulkan: Fix clang compiler error in 32 bit ARM Android
This adds proper calling convention attribute for callbacks used in vulkan
and fixes the following compiler error.

../src/render/vulkan/vulkan.c:175:22: error: incompatible function pointer types
initializing 'PFN_vkDebugUtilsMessengerCallbackEXT' (aka 'unsigned int (*)
(enum VkDebugUtilsMessageSeverityFlagBitsEXT, unsigned int, const struct
VkDebugUtilsMessengerCallbackDataEXT *, void *) __attribute__((pcs("aapcs-vfp")))')
with an expression of type 'VkBool32 (*)(VkDebugUtilsMessageSeverityFlagBitsEXT,
VkDebugUtilsMessageTypeFlagsEXT, const VkDebugUtilsMessengerCallbackDataEXT *, void *)'
(aka 'unsigned int (*)(enum VkDebugUtilsMessageSeverityFlagBitsEXT, unsigned int,
const struct VkDebugUtilsMessengerCallbackDataEXT *, void *)')
[-Wincompatible-function-pointer-types]
    .pfnUserCallback = &debug_callback,
                       ^~~~~~~~~~~~~~~
2024-04-10 14:03:38 +00:00
Guido Günther 341b3c8bd2 gles2: Avoid crash when glGetInteger64vEXT is missing
The spec for GL_EXT_disjoint_timer_query says

> The GetInteger64vEXT command is required only if OpenGL ES 3.0 or later
> is not supported.

Some GLES 3.2 implementations like the proprietary mali driver on the
rk3566 based OrangePi advertise GL_EXT_disjoint_timer_query but lack
glGetInteger64vEXT. Use glGetInteger64v instead.
2024-03-12 19:06:21 +01:00
Simon Ser 54e1fefd2e render/egl: drop wlr_egl_is_current()
This is unused.
2024-02-23 18:52:48 +01:00
Simon Ser c31d307971 render/egl: drop wlr_egl_save_context()
This is no longer used.
2024-02-23 18:52:48 +01:00
Simon Ser d5556ec78f render/egl: add save_context parameter to wlr_egl_make_current()
Saving the old context and immediately making our own context
current is a common pattern. Let's make it easier to do.

No functional change, just refactoring.
2024-02-23 18:52:48 +01:00
Kenny Levinsen 4d68d3759b render/vulkan: Avoid double-free on calloc error
In query_modifier_support, the calloc for either or both of render_mods
and texture_mods may fail, in which case both are freed for convenience.
However, if one is non-NULL, vulkan_format_props_finish will try to free
it again.

NULL them to avoid double-free.
2024-02-22 23:07:58 +01:00
Kenny Levinsen 73dd934794 render/drm_format_set: Clean up on union failure
If drm_format_set_extend fails, we need to make sure each wlr_drm_format
is cleaned up together with the formats array. Finish the set to take
care of it.
2024-02-22 23:03:50 +01:00
Simon Ser 842093bb84 Define _POSIX_C_SOURCE globally
Stop trying to maintain a per-file _POSIX_C_SOURCE. Instead,
require POSIX.1-2008 globally. A lot of core source files depend
on that already.

Some care must be taken on a few select files where we need a bit
more than POSIX. Some files need XSI extensions (_XOPEN_SOURCE) and
some files need BSD extensions (_DEFAULT_SOURCE). In both cases,
these feature test macros imply _POSIX_C_SOURCE. Make sure to not
define both these macros and _POSIX_C_SOURCE explicitly to avoid
POSIX requirement conflicts (e.g. _POSIX_C_SOURCE says POSIX.1-2001
but _XOPEN_SOURCE says POSIX.1-2008).

Additionally, there is one special case in render/vulkan/vulkan.c.
That file needs major()/minor(), and these are system-specific.
On FreeBSD, _POSIX_C_SOURCE hides system-specific symbols so we need
to make sure it's not defined for this file. On Linux, we can
explicitly include <sys/sysmacros.h> and ensure that apart from
symbols defined there the file only uses POSIX toys.
2024-02-15 15:41:12 +01:00
Paul Cercueil 220df2aa0f
Add more POSIX compliance macros to fix uClibc support
- Add POSIX 1993.09 compliance macro in source files that use
  "struct timespec";
- Add POSIX 2001.12 compliance macro in source files that use
  "struct sigaction" and the SA_SIGINFO macro, or the fchmod()
  function;
- Add POSIX 2008.09 compliance macro in source files that use the
  getline() function.

These compliance macros are enough for wlroots to compile with the
git-master version of uClibc-ng.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
2024-02-12 17:41:45 +01:00
Austin Shafer d368028bd5 allocator: remove backend parameter in allocator_autocreate_with_drm_fd
Since we only use the backend capabilities here we can simply pass
them in directly. This allows other locations to create an allocator
even if they don't have a backend. They can simply specify the caps
they want instead.
2024-02-02 16:36:31 -05:00
Leo Li 60af3b6b78 render/gles2: Fixup dropping has_alpha from pixel_format
Fixes: 71fb55f3 ("render/pixel-format: Move has_alpha into it's own array")
2024-01-31 20:27:22 +01:00
Leo Li 71fb55f3bf render/pixel-format: Move has_alpha into it's own array
Some opaque pixel formats (nv12, p010) require per-plane bytes_per_block
info. However, it doesn't make sense to store them in
wlr_pixel_format_info, as they will never be useful (currently, this
info is used for shm, which doesn't have a concept of multi-planar
buffers.)

Let's define a separate array and function for determining whether a
pixel format has alpha.
2024-01-31 13:47:17 -05:00
Félix Poisot 5ae8ce807a render/vulkan: correct sRBG gamma expansion in shader 2024-01-26 13:50:55 +00:00
Kirill Primak 20b99ed854 render/drm_format_set: fix possible leak on realloc error 2024-01-17 15:44:37 +00:00
Kirill Primak 3eb89e5325 render/vulkan: fix possible double free 2024-01-17 15:44:37 +00:00
Simon Ser a0b1329ee6 Fix bool return types
This makes wlroots build in C23 mode.

C23 is more strict and rejects implicit conversions from bool to a
pointer.
2024-01-04 22:24:06 +01:00
Simon Ser 2f2a55ebd3 render: stop auto-creating wl_drm
wl_drm is a legacy interface superseded by the linux-dmabuf
protocol. All clients should migrate.

As a first step, stop creating the wl_drm global by default.
This should let us discover any remaining issues in clients.
Compositors can still manually create the global if they want to.
As a second step, we can completely drop our implementation.
2024-01-03 20:52:34 +00:00
Roman Gilg 3531007b75 render/pixman: add wlr_pixman_renderer_get_buffer_image()
This is similar to wlr_pixman_texture_get_image and can be useful for
compositors to access the rendering data.
2023-12-11 19:47:55 +01:00
Simon Ser 1f64f3925c render/gles2: add wlr_gles2_renderer_get_buffer_fbo()
Replacement for wlr_gles2_renderer_get_current_fbo(). Wayfire uses
it for instance.
2023-12-05 18:57:43 +01:00
Simon Ser 4ed8df9ab2 render: disable linux-dmabuf without DRM FD
linux-dmabuf used to not need a DRM FD, however since v4 a DRM FD
is required for the main_device event.
2023-12-04 15:28:18 +00:00
Manuel Stoeckl d6859da3b4 render/vulkan: use _SRGB image view when possible
This is the last of a set of commits which ensures that both textures
and render buffers can be accessed through _UNORM and _SRGB image
views. While _UNORM image views are not yet used for 8-bpc image
formats, they will be needed in the future to support color transforms
for both textures and render buffers.
2023-12-04 15:13:31 +00:00
Manuel Stoeckl 566c413d8f render/vulkan: constify vulkan_format_props_find_modifier 2023-12-04 15:13:31 +00:00
Manuel Stoeckl 88a4b9eefd render/vulkan: create VkImage with option for _SRGB view, if possible 2023-12-04 15:13:31 +00:00
Manuel Stoeckl fd4548bb93 render/vulkan: detect which _UNORM formats support _SRGB views 2023-12-04 15:13:31 +00:00
Manuel Stoeckl acc70ee3a5 render/vulkan: extract shm texture format query into function 2023-12-04 15:13:31 +00:00
Manuel Stoeckl eab89d6c76 render/vulkan: track and use _UNORM variants of _SRGB formats
Later commits will start using _SRGB image views again,
where appropriate.
2023-12-04 15:13:31 +00:00
Alexander Orzechowski 6e03d3015e swapchain: Add wlr_swapchain_has_buffer 2023-12-03 05:29:05 +00:00
Alexander Orzechowski d3a339a03e renderer: Drop buffer binding 2023-11-30 20:11:50 -05:00
Alexander Orzechowski 3ed1268f64 render: Nuke old read pixels API
Sadly, the new API is not backwards compatible with the old API. Since
we have already switched all users in wlroots to the new API compositors
are already practically mandated to implement the new API. Let's get rid
of the old one since there is no point.
2023-11-30 20:01:12 -05:00
Alexander Orzechowski c5a3c5ca4c render: Implement texture_preferred_read_format 2023-11-30 20:01:12 -05:00
Alexander Orzechowski 57b18d26d0 wlr_texture: Introduce wlr_texture_preferred_read_format 2023-11-30 19:56:54 -05:00
Alexander Orzechowski 09f16b2a9c render/vulkan: Implement texture_read_pixels 2023-11-30 19:56:54 -05:00
Alexander Orzechowski e7055b4840 render/gles2: Implement texture_read_pixels
Also get rid of gles2_texture.owns_texture. We only use the tex/fbo
2023-11-30 19:56:41 -05:00
Alexander Orzechowski 01bd098166 render/pixman: Implement texture_read_pixels 2023-11-30 19:56:17 -05:00
Alexander Orzechowski e85e8bc324 wlr_texture: Introduce wlr_texture_read_pixels_options helpers 2023-11-30 19:55:51 -05:00
Alexander Orzechowski 4c6caa7c48 wlr_texture: Introduce wlr_texture_read_pixels 2023-11-30 19:55:12 -05:00
Simon Ser e8b187cc92 render/gles2: save/restore context when creating/submitting a render pass
This is useful for e.g. lazily blitting a texture for readback
purposes while rendering.
2023-11-30 17:47:11 +01:00
Simon Ser 876d789ad5 render/gles2: reword wlr_gles2_texture comments
These comments were a bit misleading:

- "GL_TEXTURE_2D == mutable": not really, imported non-external-only
  DMA-BUFs would also use this target, but are not mutable.
- "Only affects target == GL_TEXTURE_2D": same here.
- "If imported from a wlr_buffer": not really, would be NULL if
  imported from a shm wlr_buffer.

Adjust these comments to better reflect reality and adjust the check
in gles2_texture_update_from_buffer().
2023-11-30 16:38:25 +01:00
Alexander Orzechowski 84bef5c0c2 render/gles2: Inline texture invalidation
Let's us share more code with the other code path
2023-11-30 10:13:18 -05:00
Alexander Orzechowski 9bf51e744e render/gles2: Don't attach texture as buffer addon
Since wlr_gles2_buffer is now managing importing for us, there is
no reason for us to continue doing this.
2023-11-30 10:13:18 -05:00
Alexander Orzechowski 829e34b305 render/gles2: Don't track image in texture
We can get it from the buffer
2023-11-30 10:13:18 -05:00
Alexander Orzechowski cb5f67431b render/gles2: Don't double import dmabuf
We can double import a dmabuf if we use it as a texture target and
a render target. Instead, let's unify render targets and texture dmabuf
imports to use wlr_gles2_buffer which manages the EGLImageKHR
2023-11-30 10:13:18 -05:00
Alexander Orzechowski 665055a1a0 render/gles2: Destroy textures first
Since imported textures will be based off of gles2_buffer we have
to destroy textures first or else they will have an invalid reference
to the buffers they are imported from.
2023-11-30 10:13:18 -05:00
Alexander Orzechowski 484e248446 renderer/gles2: Bail rendering to external buffers when binding them
We can't do it while we're creating them because we'll want to use
gles2 buffers for textures soon.
2023-11-30 10:13:18 -05:00
Alexander Orzechowski 0d9cd6932a render/gles2: Lazily create buffer fbo 2023-11-30 10:13:18 -05:00
Alexander Orzechowski d7ecdad4e0 render: Drop rendering_with_buffer
This is always true now that we can only render with a buffer.
2023-11-29 16:00:24 -05:00
Alexander Orzechowski 3faf9883dc renderer: Drop wlr_renderer_begin 2023-11-29 15:13:24 -05:00
Simon Ser 62b6c492d5 render/gles2: check external-only flag in get_or_create_buffer()
If the external-only flag is set, then the EGLImage is only
supported for use with GL_TEXTURE_EXTERNAL_OES texture targets.
In particular, the EGLImage cannot be bound to a RBO.
2023-11-29 15:28:50 +00:00
Alexander Orzechowski 9118226634 render/gles2: Don't track has_alpha in pixel_format
Why track the alpha here when we can already get that information
elsewhere?
2023-11-29 13:25:06 +01:00