Commit Graph

175 Commits

Author SHA1 Message Date
Simon Ser 859373b253 scene: listen to renderer destroy in wlr_scene_buffer
When a renderer is destroyed, so are all textures. Reset the
texture in that case.
2024-03-14 22:07:42 +01:00
Simon Ser 3d9f330ee0 scene: add scene_buffer_set_texture() 2024-03-14 22:06:10 +01:00
Alexander Orzechowski 86e1b24d84 wlr_scene: Track damage of null textures
If we hit this case, we effectively failed to render something, this might
be because a texture failed to upload or the texture is momentarily
unavailable after a GPU reset. If we fail to render, we have to continue
to track damage for the next frame in hopes that the texture becomes
available then.

An alternative approach would be to fail the commit completely if we
find this case, but in the case of gpu resets, clients may not commit
a new buffer for a while, and a frozen display does not help.

This fixes damage tracking issues after a gpu reset.
2024-03-13 07:53:33 +00:00
Alexander Orzechowski 2aebb8e444 wlr_scene: Fix crash when committing NULL buffer
If we commit a null buffer, we want to avoid the buffer damage path and
instead just update the node to avoid it.
2024-03-13 07:50:54 +00:00
Alexander Orzechowski 8da93e5936 wlr_scene: Add support for custom swapchains 2024-03-12 11:26:03 -04:00
Alexander Orzechowski 239354d644 wlr_scene: Decide when to commit output damage with buffers in damage ring
We will soon support custom swapchains. In order to track output damage
we should instead use the damage_ring which will hold all the buffers
we are currently tracking anyway across an arbitrary amount of swapchains.
2024-03-12 11:25:58 -04:00
Alexander Orzechowski 8220184a72 wlr_scene: Assert that buffer returned from swapchain is the right size 2024-03-12 11:16:30 -04:00
Simon Ser c79ed0706d scene: simplify scene_node_update() condition when setting buffer 2024-03-12 12:11:35 +01:00
Alexander Orzechowski 2d97935e82 wlr_scene: Call surface enter scale events on surface create
We would fail to call scene_node_update() which would then call output
events for us. We need to make sure to update the node when we first map
a buffer, as the comment explained.
2024-03-12 01:57:07 -04: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
Simon Ser 4ec901bb33 scene: release shm buffers once uploaded
Once a shm buffer is uploaded there's no reason for wlr_scene_buffer
to keep it locked any further. Allow the compositor to re-use it.
2024-01-27 12:21:54 +00:00
Simon Ser ab924064f2 scene: drop wlr_scene_set_presentation() 2023-12-27 13:41:20 +01:00
Alexander Orzechowski 62169bf5ac wlr_scene: fix transformed outputs backend damage clearing
When we cleared the pending backend damage when the output committed,
we would not take into account the output transform. It's easiest to fix
this by just changing pending_commit_damage to always have transformed
coordinates.
2023-12-04 07:06:35 -05:00
Alexander Orzechowski 364d7cba42 wlr_scene: Apply output damage once
We would apply it twice if we failed direct scanout. Once when we attempt
direct scanout and again when we composite.
2023-12-04 06:58:35 -05:00
Alexander Orzechowski fe8916fef0 wlr_scene: Don't damage whole damage ring when exiting direct scanout
Direct scanout damage will just accumulate on the damage ring while in
direct scanout and properly damage when we exit anyway. On the flip side
since we now manage backend damage submission ourselves, this won't break
that either.
2023-12-03 05:29:05 +00:00
Alexander Orzechowski 0619c99dc7 wlr_scene: Use wlr_damage_ring_rotate_buffer()
Compositors who use _build_state are no longer required to call
damage_ring_rotate themselves. This is a minor breaking change.
2023-12-03 05:29:05 +00:00
Alexander Orzechowski 06d301bf1a wlr_scene: Track output damage separately
The damage ring is only supposed to keep track of damage within
the swapchain
2023-12-03 05:29:05 +00:00
Simon Ser 56ec13596a Cleanup wlr_matrix.h includes
Many files used to require wlr_matrix but no longer do.
2023-11-25 08:37:43 +01:00
Simon Ser 2eb225236e util/transform: add wlr_output_transform_coords()
We hand-roll this in multiple places.
2023-11-23 11:07:34 +01:00
Simon Ser 9e702e9cfe util/transform: move over wl_output_transform helpers
These aren't really tied to wlr_output.
2023-11-23 11:03:57 +01:00
Alexander Orzechowski 303f23d7dd wlr_scene: Update outputs if subpixel status changes
This is important for buffers that are meant to render any sort of
text.
2023-11-15 18:42:12 -05:00
Alexander Orzechowski 50446fe75e wlr_scene: Update outputs when primary output is changed
Helpers care about the primary output. They need to know when it changes
even if intersection status has not changed necessarily.
2023-11-15 18:42:12 -05:00
Alexander Orzechowski 889c5ed5ff wlr_scene: Update outputs when output scale/transform changes
We want to call the outputs updated signal when an output scale or transform
changes. Otherwise helpers like the scene surface helpers will not be
notified of scale changes and not pass them to clients.
2023-11-15 18:38:12 -05:00
Alexander Orzechowski 33b437d574 wlr_scene: Amend scene_buffer.point_accepts_input to take coordinate pointers
The pointers mean that we can mutate them. This will be useful later
so we can hide details from the compositor when we clip subsurface trees.
2023-11-14 17:27:08 +00:00
Alexander Orzechowski 5fb0007e02 output_event_commit: Remove committed and buffer
The newly introduced state struct can be used to retrieve this.
2023-10-06 10:06:01 +00:00
Alexander Orzechowski 1b0694b794 treewide: Migrate from sizeof(struct) to sizeof(*pointer) where practical 2023-10-03 01:51:07 -04:00
Leo Li b18a849fc3 wlr_scene: Use cached node coordinates where possible
Avoids recalculating node coordinates.
2023-09-08 21:11:19 +00:00
Alexander Orzechowski fd540f6d07 wlr_scene: Don't damage when setting opaque region
Opaque region is a optimization hint, (bugs outstanding) it will not
change the output contents, therefore damage does not need to be submitted.

However, we still need to update the visibility state of the other
nodes in the tree. To do this call scene_update_region() by ourselves
but not `scene_node_update()` which will damage the outputs.
2023-07-22 19:23:36 -04:00
Alexander Orzechowski a32180afa7 wlr_scene: Fix damage tracking with non atomic opaque region configuration
We need to intersect the opaque region with the node size or else we'll
get damage tracking effects with compositors attempting to use
wlr_scene_buffer_set_opaque_region() along with resizing the buffer
at the same time in a certain order.

Consider this: I have a new buffer that I want to commit to my scene buffer
that is smaller than the old one. However, I still have the old opaque
region that is the size of the old larger buffer, so that means that
for the small moment between when we reconfigure the opaque region for the
new buffer the opaque region will be oversized. Scene logic will then
try to apply occluding optimizations outside of the node boundaries
causing damage artifacts.
2023-07-22 19:23:36 -04:00
Ronan Pigott b18c76642a scene: apply rounding when translating buffer damage
Without a round in this case the damage region is translated to truncated coordinates, potentially
misplacing it relative to the actual position of that region in the output buffer.
2023-07-16 02:55:09 -07:00
Simon Ser fe84bfc8d9 scene: add wlr_scene_output_sample_event
This contains the output and a bool indicating direct scan-out.
2023-07-14 15:16:12 +02:00
Simon Ser 88942d43fd scene: rename output_present event to output_sample
Using "present" is confusing here: the event is emitted when the
buffer is being sampled to be displayed on an output, not when it's
being presented on-screen.

Rename to match the presentation-time terminology.
2023-07-14 15:06:13 +02:00
Alexander Orzechowski d8585d661c wlr_scene: Fix buffer damage for output state
We would transform the damage based on output state which might be
out of date.
2023-07-12 17:20:12 +00:00
Simon Ser fe06e5f49a Use wl_container_of() instead of casts
This slightly improves type safety.

The culprits were found with:

    git grep -E '\([a-z0-9_ ]+ \*\)\W?[a-z]'
2023-07-11 20:16:17 +02:00
Rose Hudson 214df8eda0 scene_output: optionally record and report timings 2023-07-10 09:57:02 +00:00
Simon Ser 7a9f8d8d6b Use struct initializers instead of memset()
This is a bit more type-safe.
2023-07-07 17:31:11 +02:00
Alexander Orzechowski 57a0313779 wlr_scene: Don't recompute node location during rendering
We already compute it during the render list creation, we should cache
it and re-use the value.
2023-07-01 09:48:25 +00:00
Alexander Orzechowski 48f2a7a3a1 wlr_scene: Simplify direct scanout handling
By adding a sent_feedback bool into the list entry that we can mutate
we no longer need to maintain this `sent_direct_scanout_feedback` variable.

sent_feedback will also be useful for output layers.
2023-07-01 09:48:25 +00:00
Alexander Orzechowski 9613b3bc8a wlr_scene: Wrap render_list nodes in struct
We will be able to add more state here
2023-07-01 09:48:25 +00:00
Alexander Orzechowski ea3c6fde3a wlr_scene: Add opaque region blend mode optimization
If we are only rendering within a region of the surface that is
advertised as opaque, we can choose no blending
2023-06-27 14:02:25 +00:00
Simon Ser be05097968 output: add wlr_output_state_init()
This changes the semantics of wlr_output_state. Instead of having
fields with uninitialized memory when missing from the committed
bitflag, all fields are always initialized (and maybe NULL/empty),
just like we do in wlr_surface_state. This reduces the chances of
footguns when reading a field, and removes the need to check for
the committed bitfield everywhere.

A new wlr_output_state_init() function takes care of initializing
the Pixman region.
2023-06-23 18:07:26 +00:00
Alexander Orzechowski b5eaa47049 scene: Use wlr_output_state_copy for direct scanout path 2023-06-22 11:56:30 +02:00
Alexander Orzechowski 2ac31fc630 wlr_scene: Introduce wlr_scene_buffer_set_filter_mode 2023-06-20 09:04:35 +00:00
Alexander Orzechowski 58a2f8bd5c wlr_scene: Clear damage ring on transform change 2023-06-15 14:57:51 +00:00
Alexander Orzechowski 61667404ce wlr_scene: Clear damage ring on scale change
If we were trying to change the scale in wlr_scene_output_build_state,
we would be using incorrect damage
2023-06-15 14:57:51 +00:00
Alexander Orzechowski 96b95bf775 wlr_scene: Reset damage ring bounds every frame
This fixes damage issues when a output state attempts to change
the transformed size in some way
2023-06-15 14:57:51 +00:00
Alexander Orzechowski 4391845910 wlr_damage_ring_set_bounds: Ignore duplicate size requests 2023-06-15 14:57:51 +00:00
Alexander Orzechowski 3896b6b107 wlr_scene: Fix transforms with non 1 scale
wlr_region_transform / wlr_box_transform want unscaled coordinates here
2023-06-15 14:57:51 +00:00
Alexander Orzechowski 0925a500d1 wlr_scene: Don't use direct scanout if trying to commit a new render_format
Found by inspection.
2023-06-12 20:30:09 -04:00
Alexander Orzechowski 05dd08afe5 scene: introduce wlr_scene_output_build_state() 2023-06-12 14:13:09 +02:00