2024-07-21 13:09:54 +02:00
# include "DRMSyncobj.hpp"
# include <algorithm>
# include "core/Compositor.hpp"
# include "../helpers/sync/SyncTimeline.hpp"
# include "../Compositor.hpp"
syncobj: use eventfd instead of stalling fd checks (#9437)
* syncobj: cleanup and use uniqueptrs
cleanup a bit missing removals if resource not good, erasing from
containers etc. make use of unique ptrs instead. and add default
destructors.
* syncobj: rework syncobj entirerly
remove early buffer release that was breaking explicit sync, the buffer
needs to exist until the surface commit event has been emitted and draw
calls added egl sync points, move to eventfd signaling instead of
stalling sync point checks, and recommit pending commits if waiting on a
signal. add a CDRMSyncPointState helper class. move a few weak pointers
to shared pointers so they dont destruct before we need to use them.
* syncobj: queue pending states for eventfd
eventfd requires us to queue pending stats until ready and then apply to
current, and also when no ready state exist commit the client commit on
the current existing buffer, if there is one.
* syncobj: clear current buffer damage
clear current buffer damage on current buffer commits.
* syncobj: cleanup code and fix hyprlock
remove unused code, and ensure we dont commit a empty texture causing
locksession protocol and gtk4-layer-shell misbehaving.
* syncobj: ensure buffers are cleaned up
ensure the containers having the various buffers actually gets cleaned
up from their containers, incase the CSignal isnt signaled because of
expired smart pointers or just wrong order destruction because mishaps.
also move the acquire/point setting to buffer attaching. instead of on
precommit.
* syncobj: remove unused code, optimize
remove unused code and merge sync fds if fence is valid, remove manual
directscanout buffer dropping that signals release point on pageflip, it
can cause us to signal the release point while still keeping the current
buffer and rendering it yet again causing wrong things.
* syncobj: delay buffer release on non syncobj
delay buffer releases on non syncobj surfaces until next commit, and
check on async buffers if syncobj and drop and signal the release point
on backend buffer release.
* syncobj: ensure we follow protocol
ensure we follow protocol by replacing acquire/release points if they
arrive late and replace already existing ones. also remove unneded
brackets, and dont try to manual lock/release buffers when it comes to
explicit protocol. it doesnt care about buffer releases only about
acquire and release points and signaling them.
* syncobj: lets not complicate things
set points in precommit, before checking protocol errors and we catch
any pending acquire/release points arriving late.
* syncobj: move SSurfaceState to types
remove destructor resource destroying, let resources destroys them on
their events, and move SSurfaceStates to types/SurfaceState.hpp
* syncobj: actually store the merged fd
have to actually store the mergedfd to use it.
* syncobj: cleanup a bit around fences
ensure the current asynchronous buffer is actually released on pageflip
not the previous. cleanup a bit FD handling in
commitPendingAndDoExplicitSync, and reuse the in fence when syncing
surfaces.
* syncobjs: ensure fence FD doesnt leak
calling resetexplicitfence without properly ensuring the FD is closed
before will leak it, store it per monitor and let it close itself with
the CFileDescriptor class.
* syncobj: ensure buffers are actually released
buffers were never being sent released properly.
* types: Defer buffer sync releaser until unlock
* syncobj: store directscanout fence in monitor
ensure the infence fd survives the scope of attemptdirectscanout so it
doesnt close before it should have.
* syncobj: check if if acquire is expired
we might hit a race to finish on exit where the timeline just has
destructed but the buffer waiter is still pending. and such we
removeAllWaiters null dereferences.
* syncobj: code style changes
remove quack comment, change to m_foo and use a std::vector and
weakpointer in the waiter for removal instead of a std::list.
* syncobj: remove unused async buffer drop
remove unused async buffer drop, only related to directscanout and is
handled elsewhere.
---------
Co-authored-by: Lee Bousfield <ljbousfield@gmail.com>
2025-03-14 15:08:20 +01:00
# include "render/OpenGL.hpp"
2024-07-21 13:09:54 +02:00
# include <fcntl.h>
2025-01-30 12:30:12 +01:00
using namespace Hyprutils : : OS ;
2024-07-21 13:09:54 +02:00
2025-03-21 20:19:53 +01:00
CDRMSyncPointState : : CDRMSyncPointState ( SP < CSyncTimeline > timeline_ , uint64_t point_ ) : m_timeline ( timeline_ ) , m_point ( point_ ) { }
syncobj: use eventfd instead of stalling fd checks (#9437)
* syncobj: cleanup and use uniqueptrs
cleanup a bit missing removals if resource not good, erasing from
containers etc. make use of unique ptrs instead. and add default
destructors.
* syncobj: rework syncobj entirerly
remove early buffer release that was breaking explicit sync, the buffer
needs to exist until the surface commit event has been emitted and draw
calls added egl sync points, move to eventfd signaling instead of
stalling sync point checks, and recommit pending commits if waiting on a
signal. add a CDRMSyncPointState helper class. move a few weak pointers
to shared pointers so they dont destruct before we need to use them.
* syncobj: queue pending states for eventfd
eventfd requires us to queue pending stats until ready and then apply to
current, and also when no ready state exist commit the client commit on
the current existing buffer, if there is one.
* syncobj: clear current buffer damage
clear current buffer damage on current buffer commits.
* syncobj: cleanup code and fix hyprlock
remove unused code, and ensure we dont commit a empty texture causing
locksession protocol and gtk4-layer-shell misbehaving.
* syncobj: ensure buffers are cleaned up
ensure the containers having the various buffers actually gets cleaned
up from their containers, incase the CSignal isnt signaled because of
expired smart pointers or just wrong order destruction because mishaps.
also move the acquire/point setting to buffer attaching. instead of on
precommit.
* syncobj: remove unused code, optimize
remove unused code and merge sync fds if fence is valid, remove manual
directscanout buffer dropping that signals release point on pageflip, it
can cause us to signal the release point while still keeping the current
buffer and rendering it yet again causing wrong things.
* syncobj: delay buffer release on non syncobj
delay buffer releases on non syncobj surfaces until next commit, and
check on async buffers if syncobj and drop and signal the release point
on backend buffer release.
* syncobj: ensure we follow protocol
ensure we follow protocol by replacing acquire/release points if they
arrive late and replace already existing ones. also remove unneded
brackets, and dont try to manual lock/release buffers when it comes to
explicit protocol. it doesnt care about buffer releases only about
acquire and release points and signaling them.
* syncobj: lets not complicate things
set points in precommit, before checking protocol errors and we catch
any pending acquire/release points arriving late.
* syncobj: move SSurfaceState to types
remove destructor resource destroying, let resources destroys them on
their events, and move SSurfaceStates to types/SurfaceState.hpp
* syncobj: actually store the merged fd
have to actually store the mergedfd to use it.
* syncobj: cleanup a bit around fences
ensure the current asynchronous buffer is actually released on pageflip
not the previous. cleanup a bit FD handling in
commitPendingAndDoExplicitSync, and reuse the in fence when syncing
surfaces.
* syncobjs: ensure fence FD doesnt leak
calling resetexplicitfence without properly ensuring the FD is closed
before will leak it, store it per monitor and let it close itself with
the CFileDescriptor class.
* syncobj: ensure buffers are actually released
buffers were never being sent released properly.
* types: Defer buffer sync releaser until unlock
* syncobj: store directscanout fence in monitor
ensure the infence fd survives the scope of attemptdirectscanout so it
doesnt close before it should have.
* syncobj: check if if acquire is expired
we might hit a race to finish on exit where the timeline just has
destructed but the buffer waiter is still pending. and such we
removeAllWaiters null dereferences.
* syncobj: code style changes
remove quack comment, change to m_foo and use a std::vector and
weakpointer in the waiter for removal instead of a std::list.
* syncobj: remove unused async buffer drop
remove unused async buffer drop, only related to directscanout and is
handled elsewhere.
---------
Co-authored-by: Lee Bousfield <ljbousfield@gmail.com>
2025-03-14 15:08:20 +01:00
const uint64_t & CDRMSyncPointState : : point ( ) {
return m_point ;
}
WP < CSyncTimeline > CDRMSyncPointState : : timeline ( ) {
2025-03-21 20:19:53 +01:00
return m_timeline ;
syncobj: use eventfd instead of stalling fd checks (#9437)
* syncobj: cleanup and use uniqueptrs
cleanup a bit missing removals if resource not good, erasing from
containers etc. make use of unique ptrs instead. and add default
destructors.
* syncobj: rework syncobj entirerly
remove early buffer release that was breaking explicit sync, the buffer
needs to exist until the surface commit event has been emitted and draw
calls added egl sync points, move to eventfd signaling instead of
stalling sync point checks, and recommit pending commits if waiting on a
signal. add a CDRMSyncPointState helper class. move a few weak pointers
to shared pointers so they dont destruct before we need to use them.
* syncobj: queue pending states for eventfd
eventfd requires us to queue pending stats until ready and then apply to
current, and also when no ready state exist commit the client commit on
the current existing buffer, if there is one.
* syncobj: clear current buffer damage
clear current buffer damage on current buffer commits.
* syncobj: cleanup code and fix hyprlock
remove unused code, and ensure we dont commit a empty texture causing
locksession protocol and gtk4-layer-shell misbehaving.
* syncobj: ensure buffers are cleaned up
ensure the containers having the various buffers actually gets cleaned
up from their containers, incase the CSignal isnt signaled because of
expired smart pointers or just wrong order destruction because mishaps.
also move the acquire/point setting to buffer attaching. instead of on
precommit.
* syncobj: remove unused code, optimize
remove unused code and merge sync fds if fence is valid, remove manual
directscanout buffer dropping that signals release point on pageflip, it
can cause us to signal the release point while still keeping the current
buffer and rendering it yet again causing wrong things.
* syncobj: delay buffer release on non syncobj
delay buffer releases on non syncobj surfaces until next commit, and
check on async buffers if syncobj and drop and signal the release point
on backend buffer release.
* syncobj: ensure we follow protocol
ensure we follow protocol by replacing acquire/release points if they
arrive late and replace already existing ones. also remove unneded
brackets, and dont try to manual lock/release buffers when it comes to
explicit protocol. it doesnt care about buffer releases only about
acquire and release points and signaling them.
* syncobj: lets not complicate things
set points in precommit, before checking protocol errors and we catch
any pending acquire/release points arriving late.
* syncobj: move SSurfaceState to types
remove destructor resource destroying, let resources destroys them on
their events, and move SSurfaceStates to types/SurfaceState.hpp
* syncobj: actually store the merged fd
have to actually store the mergedfd to use it.
* syncobj: cleanup a bit around fences
ensure the current asynchronous buffer is actually released on pageflip
not the previous. cleanup a bit FD handling in
commitPendingAndDoExplicitSync, and reuse the in fence when syncing
surfaces.
* syncobjs: ensure fence FD doesnt leak
calling resetexplicitfence without properly ensuring the FD is closed
before will leak it, store it per monitor and let it close itself with
the CFileDescriptor class.
* syncobj: ensure buffers are actually released
buffers were never being sent released properly.
* types: Defer buffer sync releaser until unlock
* syncobj: store directscanout fence in monitor
ensure the infence fd survives the scope of attemptdirectscanout so it
doesnt close before it should have.
* syncobj: check if if acquire is expired
we might hit a race to finish on exit where the timeline just has
destructed but the buffer waiter is still pending. and such we
removeAllWaiters null dereferences.
* syncobj: code style changes
remove quack comment, change to m_foo and use a std::vector and
weakpointer in the waiter for removal instead of a std::list.
* syncobj: remove unused async buffer drop
remove unused async buffer drop, only related to directscanout and is
handled elsewhere.
---------
Co-authored-by: Lee Bousfield <ljbousfield@gmail.com>
2025-03-14 15:08:20 +01:00
}
UP < CSyncReleaser > CDRMSyncPointState : : createSyncRelease ( ) {
if ( m_releaseTaken )
Debug : : log ( ERR , " CDRMSyncPointState: creating a sync releaser on an already created SyncRelease " ) ;
m_releaseTaken = true ;
2025-03-21 20:19:53 +01:00
return makeUnique < CSyncReleaser > ( m_timeline , m_point ) ;
syncobj: use eventfd instead of stalling fd checks (#9437)
* syncobj: cleanup and use uniqueptrs
cleanup a bit missing removals if resource not good, erasing from
containers etc. make use of unique ptrs instead. and add default
destructors.
* syncobj: rework syncobj entirerly
remove early buffer release that was breaking explicit sync, the buffer
needs to exist until the surface commit event has been emitted and draw
calls added egl sync points, move to eventfd signaling instead of
stalling sync point checks, and recommit pending commits if waiting on a
signal. add a CDRMSyncPointState helper class. move a few weak pointers
to shared pointers so they dont destruct before we need to use them.
* syncobj: queue pending states for eventfd
eventfd requires us to queue pending stats until ready and then apply to
current, and also when no ready state exist commit the client commit on
the current existing buffer, if there is one.
* syncobj: clear current buffer damage
clear current buffer damage on current buffer commits.
* syncobj: cleanup code and fix hyprlock
remove unused code, and ensure we dont commit a empty texture causing
locksession protocol and gtk4-layer-shell misbehaving.
* syncobj: ensure buffers are cleaned up
ensure the containers having the various buffers actually gets cleaned
up from their containers, incase the CSignal isnt signaled because of
expired smart pointers or just wrong order destruction because mishaps.
also move the acquire/point setting to buffer attaching. instead of on
precommit.
* syncobj: remove unused code, optimize
remove unused code and merge sync fds if fence is valid, remove manual
directscanout buffer dropping that signals release point on pageflip, it
can cause us to signal the release point while still keeping the current
buffer and rendering it yet again causing wrong things.
* syncobj: delay buffer release on non syncobj
delay buffer releases on non syncobj surfaces until next commit, and
check on async buffers if syncobj and drop and signal the release point
on backend buffer release.
* syncobj: ensure we follow protocol
ensure we follow protocol by replacing acquire/release points if they
arrive late and replace already existing ones. also remove unneded
brackets, and dont try to manual lock/release buffers when it comes to
explicit protocol. it doesnt care about buffer releases only about
acquire and release points and signaling them.
* syncobj: lets not complicate things
set points in precommit, before checking protocol errors and we catch
any pending acquire/release points arriving late.
* syncobj: move SSurfaceState to types
remove destructor resource destroying, let resources destroys them on
their events, and move SSurfaceStates to types/SurfaceState.hpp
* syncobj: actually store the merged fd
have to actually store the mergedfd to use it.
* syncobj: cleanup a bit around fences
ensure the current asynchronous buffer is actually released on pageflip
not the previous. cleanup a bit FD handling in
commitPendingAndDoExplicitSync, and reuse the in fence when syncing
surfaces.
* syncobjs: ensure fence FD doesnt leak
calling resetexplicitfence without properly ensuring the FD is closed
before will leak it, store it per monitor and let it close itself with
the CFileDescriptor class.
* syncobj: ensure buffers are actually released
buffers were never being sent released properly.
* types: Defer buffer sync releaser until unlock
* syncobj: store directscanout fence in monitor
ensure the infence fd survives the scope of attemptdirectscanout so it
doesnt close before it should have.
* syncobj: check if if acquire is expired
we might hit a race to finish on exit where the timeline just has
destructed but the buffer waiter is still pending. and such we
removeAllWaiters null dereferences.
* syncobj: code style changes
remove quack comment, change to m_foo and use a std::vector and
weakpointer in the waiter for removal instead of a std::list.
* syncobj: remove unused async buffer drop
remove unused async buffer drop, only related to directscanout and is
handled elsewhere.
---------
Co-authored-by: Lee Bousfield <ljbousfield@gmail.com>
2025-03-14 15:08:20 +01:00
}
bool CDRMSyncPointState : : addWaiter ( const std : : function < void ( ) > & waiter ) {
m_acquireCommitted = true ;
2025-03-21 20:19:53 +01:00
return m_timeline - > addWaiter ( waiter , m_point , 0u ) ;
syncobj: use eventfd instead of stalling fd checks (#9437)
* syncobj: cleanup and use uniqueptrs
cleanup a bit missing removals if resource not good, erasing from
containers etc. make use of unique ptrs instead. and add default
destructors.
* syncobj: rework syncobj entirerly
remove early buffer release that was breaking explicit sync, the buffer
needs to exist until the surface commit event has been emitted and draw
calls added egl sync points, move to eventfd signaling instead of
stalling sync point checks, and recommit pending commits if waiting on a
signal. add a CDRMSyncPointState helper class. move a few weak pointers
to shared pointers so they dont destruct before we need to use them.
* syncobj: queue pending states for eventfd
eventfd requires us to queue pending stats until ready and then apply to
current, and also when no ready state exist commit the client commit on
the current existing buffer, if there is one.
* syncobj: clear current buffer damage
clear current buffer damage on current buffer commits.
* syncobj: cleanup code and fix hyprlock
remove unused code, and ensure we dont commit a empty texture causing
locksession protocol and gtk4-layer-shell misbehaving.
* syncobj: ensure buffers are cleaned up
ensure the containers having the various buffers actually gets cleaned
up from their containers, incase the CSignal isnt signaled because of
expired smart pointers or just wrong order destruction because mishaps.
also move the acquire/point setting to buffer attaching. instead of on
precommit.
* syncobj: remove unused code, optimize
remove unused code and merge sync fds if fence is valid, remove manual
directscanout buffer dropping that signals release point on pageflip, it
can cause us to signal the release point while still keeping the current
buffer and rendering it yet again causing wrong things.
* syncobj: delay buffer release on non syncobj
delay buffer releases on non syncobj surfaces until next commit, and
check on async buffers if syncobj and drop and signal the release point
on backend buffer release.
* syncobj: ensure we follow protocol
ensure we follow protocol by replacing acquire/release points if they
arrive late and replace already existing ones. also remove unneded
brackets, and dont try to manual lock/release buffers when it comes to
explicit protocol. it doesnt care about buffer releases only about
acquire and release points and signaling them.
* syncobj: lets not complicate things
set points in precommit, before checking protocol errors and we catch
any pending acquire/release points arriving late.
* syncobj: move SSurfaceState to types
remove destructor resource destroying, let resources destroys them on
their events, and move SSurfaceStates to types/SurfaceState.hpp
* syncobj: actually store the merged fd
have to actually store the mergedfd to use it.
* syncobj: cleanup a bit around fences
ensure the current asynchronous buffer is actually released on pageflip
not the previous. cleanup a bit FD handling in
commitPendingAndDoExplicitSync, and reuse the in fence when syncing
surfaces.
* syncobjs: ensure fence FD doesnt leak
calling resetexplicitfence without properly ensuring the FD is closed
before will leak it, store it per monitor and let it close itself with
the CFileDescriptor class.
* syncobj: ensure buffers are actually released
buffers were never being sent released properly.
* types: Defer buffer sync releaser until unlock
* syncobj: store directscanout fence in monitor
ensure the infence fd survives the scope of attemptdirectscanout so it
doesnt close before it should have.
* syncobj: check if if acquire is expired
we might hit a race to finish on exit where the timeline just has
destructed but the buffer waiter is still pending. and such we
removeAllWaiters null dereferences.
* syncobj: code style changes
remove quack comment, change to m_foo and use a std::vector and
weakpointer in the waiter for removal instead of a std::list.
* syncobj: remove unused async buffer drop
remove unused async buffer drop, only related to directscanout and is
handled elsewhere.
---------
Co-authored-by: Lee Bousfield <ljbousfield@gmail.com>
2025-03-14 15:08:20 +01:00
}
bool CDRMSyncPointState : : comitted ( ) {
return m_acquireCommitted ;
}
CFileDescriptor CDRMSyncPointState : : exportAsFD ( ) {
2025-03-21 20:19:53 +01:00
return m_timeline - > exportAsSyncFileFD ( m_point ) ;
syncobj: use eventfd instead of stalling fd checks (#9437)
* syncobj: cleanup and use uniqueptrs
cleanup a bit missing removals if resource not good, erasing from
containers etc. make use of unique ptrs instead. and add default
destructors.
* syncobj: rework syncobj entirerly
remove early buffer release that was breaking explicit sync, the buffer
needs to exist until the surface commit event has been emitted and draw
calls added egl sync points, move to eventfd signaling instead of
stalling sync point checks, and recommit pending commits if waiting on a
signal. add a CDRMSyncPointState helper class. move a few weak pointers
to shared pointers so they dont destruct before we need to use them.
* syncobj: queue pending states for eventfd
eventfd requires us to queue pending stats until ready and then apply to
current, and also when no ready state exist commit the client commit on
the current existing buffer, if there is one.
* syncobj: clear current buffer damage
clear current buffer damage on current buffer commits.
* syncobj: cleanup code and fix hyprlock
remove unused code, and ensure we dont commit a empty texture causing
locksession protocol and gtk4-layer-shell misbehaving.
* syncobj: ensure buffers are cleaned up
ensure the containers having the various buffers actually gets cleaned
up from their containers, incase the CSignal isnt signaled because of
expired smart pointers or just wrong order destruction because mishaps.
also move the acquire/point setting to buffer attaching. instead of on
precommit.
* syncobj: remove unused code, optimize
remove unused code and merge sync fds if fence is valid, remove manual
directscanout buffer dropping that signals release point on pageflip, it
can cause us to signal the release point while still keeping the current
buffer and rendering it yet again causing wrong things.
* syncobj: delay buffer release on non syncobj
delay buffer releases on non syncobj surfaces until next commit, and
check on async buffers if syncobj and drop and signal the release point
on backend buffer release.
* syncobj: ensure we follow protocol
ensure we follow protocol by replacing acquire/release points if they
arrive late and replace already existing ones. also remove unneded
brackets, and dont try to manual lock/release buffers when it comes to
explicit protocol. it doesnt care about buffer releases only about
acquire and release points and signaling them.
* syncobj: lets not complicate things
set points in precommit, before checking protocol errors and we catch
any pending acquire/release points arriving late.
* syncobj: move SSurfaceState to types
remove destructor resource destroying, let resources destroys them on
their events, and move SSurfaceStates to types/SurfaceState.hpp
* syncobj: actually store the merged fd
have to actually store the mergedfd to use it.
* syncobj: cleanup a bit around fences
ensure the current asynchronous buffer is actually released on pageflip
not the previous. cleanup a bit FD handling in
commitPendingAndDoExplicitSync, and reuse the in fence when syncing
surfaces.
* syncobjs: ensure fence FD doesnt leak
calling resetexplicitfence without properly ensuring the FD is closed
before will leak it, store it per monitor and let it close itself with
the CFileDescriptor class.
* syncobj: ensure buffers are actually released
buffers were never being sent released properly.
* types: Defer buffer sync releaser until unlock
* syncobj: store directscanout fence in monitor
ensure the infence fd survives the scope of attemptdirectscanout so it
doesnt close before it should have.
* syncobj: check if if acquire is expired
we might hit a race to finish on exit where the timeline just has
destructed but the buffer waiter is still pending. and such we
removeAllWaiters null dereferences.
* syncobj: code style changes
remove quack comment, change to m_foo and use a std::vector and
weakpointer in the waiter for removal instead of a std::list.
* syncobj: remove unused async buffer drop
remove unused async buffer drop, only related to directscanout and is
handled elsewhere.
---------
Co-authored-by: Lee Bousfield <ljbousfield@gmail.com>
2025-03-14 15:08:20 +01:00
}
void CDRMSyncPointState : : signal ( ) {
2025-03-21 20:19:53 +01:00
m_timeline - > signal ( m_point ) ;
syncobj: use eventfd instead of stalling fd checks (#9437)
* syncobj: cleanup and use uniqueptrs
cleanup a bit missing removals if resource not good, erasing from
containers etc. make use of unique ptrs instead. and add default
destructors.
* syncobj: rework syncobj entirerly
remove early buffer release that was breaking explicit sync, the buffer
needs to exist until the surface commit event has been emitted and draw
calls added egl sync points, move to eventfd signaling instead of
stalling sync point checks, and recommit pending commits if waiting on a
signal. add a CDRMSyncPointState helper class. move a few weak pointers
to shared pointers so they dont destruct before we need to use them.
* syncobj: queue pending states for eventfd
eventfd requires us to queue pending stats until ready and then apply to
current, and also when no ready state exist commit the client commit on
the current existing buffer, if there is one.
* syncobj: clear current buffer damage
clear current buffer damage on current buffer commits.
* syncobj: cleanup code and fix hyprlock
remove unused code, and ensure we dont commit a empty texture causing
locksession protocol and gtk4-layer-shell misbehaving.
* syncobj: ensure buffers are cleaned up
ensure the containers having the various buffers actually gets cleaned
up from their containers, incase the CSignal isnt signaled because of
expired smart pointers or just wrong order destruction because mishaps.
also move the acquire/point setting to buffer attaching. instead of on
precommit.
* syncobj: remove unused code, optimize
remove unused code and merge sync fds if fence is valid, remove manual
directscanout buffer dropping that signals release point on pageflip, it
can cause us to signal the release point while still keeping the current
buffer and rendering it yet again causing wrong things.
* syncobj: delay buffer release on non syncobj
delay buffer releases on non syncobj surfaces until next commit, and
check on async buffers if syncobj and drop and signal the release point
on backend buffer release.
* syncobj: ensure we follow protocol
ensure we follow protocol by replacing acquire/release points if they
arrive late and replace already existing ones. also remove unneded
brackets, and dont try to manual lock/release buffers when it comes to
explicit protocol. it doesnt care about buffer releases only about
acquire and release points and signaling them.
* syncobj: lets not complicate things
set points in precommit, before checking protocol errors and we catch
any pending acquire/release points arriving late.
* syncobj: move SSurfaceState to types
remove destructor resource destroying, let resources destroys them on
their events, and move SSurfaceStates to types/SurfaceState.hpp
* syncobj: actually store the merged fd
have to actually store the mergedfd to use it.
* syncobj: cleanup a bit around fences
ensure the current asynchronous buffer is actually released on pageflip
not the previous. cleanup a bit FD handling in
commitPendingAndDoExplicitSync, and reuse the in fence when syncing
surfaces.
* syncobjs: ensure fence FD doesnt leak
calling resetexplicitfence without properly ensuring the FD is closed
before will leak it, store it per monitor and let it close itself with
the CFileDescriptor class.
* syncobj: ensure buffers are actually released
buffers were never being sent released properly.
* types: Defer buffer sync releaser until unlock
* syncobj: store directscanout fence in monitor
ensure the infence fd survives the scope of attemptdirectscanout so it
doesnt close before it should have.
* syncobj: check if if acquire is expired
we might hit a race to finish on exit where the timeline just has
destructed but the buffer waiter is still pending. and such we
removeAllWaiters null dereferences.
* syncobj: code style changes
remove quack comment, change to m_foo and use a std::vector and
weakpointer in the waiter for removal instead of a std::list.
* syncobj: remove unused async buffer drop
remove unused async buffer drop, only related to directscanout and is
handled elsewhere.
---------
Co-authored-by: Lee Bousfield <ljbousfield@gmail.com>
2025-03-14 15:08:20 +01:00
}
CDRMSyncobjSurfaceResource : : CDRMSyncobjSurfaceResource ( UP < CWpLinuxDrmSyncobjSurfaceV1 > & & resource_ , SP < CWLSurfaceResource > surface_ ) :
2025-05-04 00:13:29 +02:00
m_surface ( surface_ ) , m_resource ( std : : move ( resource_ ) ) {
2025-01-17 18:21:34 +01:00
if UNLIKELY ( ! good ( ) )
2024-07-21 13:09:54 +02:00
return ;
2025-05-04 00:13:29 +02:00
m_resource - > setData ( this ) ;
2024-07-21 13:09:54 +02:00
2025-05-04 00:13:29 +02:00
m_resource - > setOnDestroy ( [ this ] ( CWpLinuxDrmSyncobjSurfaceV1 * r ) { PROTO : : sync - > destroyResource ( this ) ; } ) ;
m_resource - > setDestroy ( [ this ] ( CWpLinuxDrmSyncobjSurfaceV1 * r ) { PROTO : : sync - > destroyResource ( this ) ; } ) ;
2024-07-21 13:09:54 +02:00
2025-05-04 00:13:29 +02:00
m_resource - > setSetAcquirePoint ( [ this ] ( CWpLinuxDrmSyncobjSurfaceV1 * r , wl_resource * timeline_ , uint32_t hi , uint32_t lo ) {
if ( ! m_surface ) {
m_resource - > error ( WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_SURFACE , " Surface is gone " ) ;
2024-07-21 13:09:54 +02:00
return ;
}
2025-05-04 00:13:29 +02:00
auto timeline = CDRMSyncobjTimelineResource : : fromResource ( timeline_ ) ;
m_pendingAcquire = { timeline - > m_timeline , ( ( uint64_t ) hi < < 32 ) | ( uint64_t ) lo } ;
2024-07-21 13:09:54 +02:00
} ) ;
2025-05-04 00:13:29 +02:00
m_resource - > setSetReleasePoint ( [ this ] ( CWpLinuxDrmSyncobjSurfaceV1 * r , wl_resource * timeline_ , uint32_t hi , uint32_t lo ) {
if ( ! m_surface ) {
m_resource - > error ( WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_SURFACE , " Surface is gone " ) ;
2024-07-21 13:09:54 +02:00
return ;
}
2025-05-04 00:13:29 +02:00
auto timeline = CDRMSyncobjTimelineResource : : fromResource ( timeline_ ) ;
m_pendingRelease = { timeline - > m_timeline , ( ( uint64_t ) hi < < 32 ) | ( uint64_t ) lo } ;
2024-07-21 13:09:54 +02:00
} ) ;
2025-07-08 09:56:40 -07:00
m_listeners . surfacePrecommit = m_surface - > m_events . precommit . listen ( [ this ] {
2025-07-07 16:18:06 +02:00
if ( ! m_surface - > m_pending . updated . bits . buffer | | ! m_surface - > m_pending . buffer ) {
2025-05-04 00:13:29 +02:00
if ( m_pendingAcquire . timeline ( ) | | m_pendingRelease . timeline ( ) ) {
m_resource - > error ( WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_BUFFER , " Missing buffer " ) ;
m_surface - > m_pending . rejected = true ;
2025-04-07 14:03:27 -05:00
}
return ;
2024-07-21 13:09:54 +02:00
}
2025-05-04 00:13:29 +02:00
if ( ! m_pendingAcquire . timeline ( ) ) {
m_resource - > error ( WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_ACQUIRE_POINT , " Missing acquire timeline " ) ;
m_surface - > m_pending . rejected = true ;
2025-04-07 14:03:27 -05:00
return ;
2024-07-21 13:09:54 +02:00
}
2025-05-04 00:13:29 +02:00
if ( ! m_pendingRelease . timeline ( ) ) {
m_resource - > error ( WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_RELEASE_POINT , " Missing release timeline " ) ;
m_surface - > m_pending . rejected = true ;
2024-10-12 17:56:46 +01:00
return ;
syncobj: use eventfd instead of stalling fd checks (#9437)
* syncobj: cleanup and use uniqueptrs
cleanup a bit missing removals if resource not good, erasing from
containers etc. make use of unique ptrs instead. and add default
destructors.
* syncobj: rework syncobj entirerly
remove early buffer release that was breaking explicit sync, the buffer
needs to exist until the surface commit event has been emitted and draw
calls added egl sync points, move to eventfd signaling instead of
stalling sync point checks, and recommit pending commits if waiting on a
signal. add a CDRMSyncPointState helper class. move a few weak pointers
to shared pointers so they dont destruct before we need to use them.
* syncobj: queue pending states for eventfd
eventfd requires us to queue pending stats until ready and then apply to
current, and also when no ready state exist commit the client commit on
the current existing buffer, if there is one.
* syncobj: clear current buffer damage
clear current buffer damage on current buffer commits.
* syncobj: cleanup code and fix hyprlock
remove unused code, and ensure we dont commit a empty texture causing
locksession protocol and gtk4-layer-shell misbehaving.
* syncobj: ensure buffers are cleaned up
ensure the containers having the various buffers actually gets cleaned
up from their containers, incase the CSignal isnt signaled because of
expired smart pointers or just wrong order destruction because mishaps.
also move the acquire/point setting to buffer attaching. instead of on
precommit.
* syncobj: remove unused code, optimize
remove unused code and merge sync fds if fence is valid, remove manual
directscanout buffer dropping that signals release point on pageflip, it
can cause us to signal the release point while still keeping the current
buffer and rendering it yet again causing wrong things.
* syncobj: delay buffer release on non syncobj
delay buffer releases on non syncobj surfaces until next commit, and
check on async buffers if syncobj and drop and signal the release point
on backend buffer release.
* syncobj: ensure we follow protocol
ensure we follow protocol by replacing acquire/release points if they
arrive late and replace already existing ones. also remove unneded
brackets, and dont try to manual lock/release buffers when it comes to
explicit protocol. it doesnt care about buffer releases only about
acquire and release points and signaling them.
* syncobj: lets not complicate things
set points in precommit, before checking protocol errors and we catch
any pending acquire/release points arriving late.
* syncobj: move SSurfaceState to types
remove destructor resource destroying, let resources destroys them on
their events, and move SSurfaceStates to types/SurfaceState.hpp
* syncobj: actually store the merged fd
have to actually store the mergedfd to use it.
* syncobj: cleanup a bit around fences
ensure the current asynchronous buffer is actually released on pageflip
not the previous. cleanup a bit FD handling in
commitPendingAndDoExplicitSync, and reuse the in fence when syncing
surfaces.
* syncobjs: ensure fence FD doesnt leak
calling resetexplicitfence without properly ensuring the FD is closed
before will leak it, store it per monitor and let it close itself with
the CFileDescriptor class.
* syncobj: ensure buffers are actually released
buffers were never being sent released properly.
* types: Defer buffer sync releaser until unlock
* syncobj: store directscanout fence in monitor
ensure the infence fd survives the scope of attemptdirectscanout so it
doesnt close before it should have.
* syncobj: check if if acquire is expired
we might hit a race to finish on exit where the timeline just has
destructed but the buffer waiter is still pending. and such we
removeAllWaiters null dereferences.
* syncobj: code style changes
remove quack comment, change to m_foo and use a std::vector and
weakpointer in the waiter for removal instead of a std::list.
* syncobj: remove unused async buffer drop
remove unused async buffer drop, only related to directscanout and is
handled elsewhere.
---------
Co-authored-by: Lee Bousfield <ljbousfield@gmail.com>
2025-03-14 15:08:20 +01:00
}
2024-10-12 17:56:46 +01:00
2025-05-04 00:13:29 +02:00
if ( m_pendingAcquire . timeline ( ) = = m_pendingRelease . timeline ( ) & & m_pendingAcquire . point ( ) > = m_pendingRelease . point ( ) ) {
m_resource - > error ( WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_CONFLICTING_POINTS , " Acquire and release points are on the same timeline, and acquire >= release " ) ;
m_surface - > m_pending . rejected = true ;
2025-04-07 14:03:27 -05:00
return ;
2024-10-12 03:12:07 +03:00
}
2024-07-21 13:09:54 +02:00
2025-07-07 16:18:06 +02:00
m_surface - > m_pending . updated . bits . acquire = true ;
m_surface - > m_pending . acquire = m_pendingAcquire ;
m_pendingAcquire = { } ;
2024-07-21 13:09:54 +02:00
2025-05-04 00:13:29 +02:00
m_surface - > m_pending . buffer - > addReleasePoint ( m_pendingRelease ) ;
m_pendingRelease = { } ;
2024-08-06 14:52:19 +01:00
} ) ;
syncobj: use eventfd instead of stalling fd checks (#9437)
* syncobj: cleanup and use uniqueptrs
cleanup a bit missing removals if resource not good, erasing from
containers etc. make use of unique ptrs instead. and add default
destructors.
* syncobj: rework syncobj entirerly
remove early buffer release that was breaking explicit sync, the buffer
needs to exist until the surface commit event has been emitted and draw
calls added egl sync points, move to eventfd signaling instead of
stalling sync point checks, and recommit pending commits if waiting on a
signal. add a CDRMSyncPointState helper class. move a few weak pointers
to shared pointers so they dont destruct before we need to use them.
* syncobj: queue pending states for eventfd
eventfd requires us to queue pending stats until ready and then apply to
current, and also when no ready state exist commit the client commit on
the current existing buffer, if there is one.
* syncobj: clear current buffer damage
clear current buffer damage on current buffer commits.
* syncobj: cleanup code and fix hyprlock
remove unused code, and ensure we dont commit a empty texture causing
locksession protocol and gtk4-layer-shell misbehaving.
* syncobj: ensure buffers are cleaned up
ensure the containers having the various buffers actually gets cleaned
up from their containers, incase the CSignal isnt signaled because of
expired smart pointers or just wrong order destruction because mishaps.
also move the acquire/point setting to buffer attaching. instead of on
precommit.
* syncobj: remove unused code, optimize
remove unused code and merge sync fds if fence is valid, remove manual
directscanout buffer dropping that signals release point on pageflip, it
can cause us to signal the release point while still keeping the current
buffer and rendering it yet again causing wrong things.
* syncobj: delay buffer release on non syncobj
delay buffer releases on non syncobj surfaces until next commit, and
check on async buffers if syncobj and drop and signal the release point
on backend buffer release.
* syncobj: ensure we follow protocol
ensure we follow protocol by replacing acquire/release points if they
arrive late and replace already existing ones. also remove unneded
brackets, and dont try to manual lock/release buffers when it comes to
explicit protocol. it doesnt care about buffer releases only about
acquire and release points and signaling them.
* syncobj: lets not complicate things
set points in precommit, before checking protocol errors and we catch
any pending acquire/release points arriving late.
* syncobj: move SSurfaceState to types
remove destructor resource destroying, let resources destroys them on
their events, and move SSurfaceStates to types/SurfaceState.hpp
* syncobj: actually store the merged fd
have to actually store the mergedfd to use it.
* syncobj: cleanup a bit around fences
ensure the current asynchronous buffer is actually released on pageflip
not the previous. cleanup a bit FD handling in
commitPendingAndDoExplicitSync, and reuse the in fence when syncing
surfaces.
* syncobjs: ensure fence FD doesnt leak
calling resetexplicitfence without properly ensuring the FD is closed
before will leak it, store it per monitor and let it close itself with
the CFileDescriptor class.
* syncobj: ensure buffers are actually released
buffers were never being sent released properly.
* types: Defer buffer sync releaser until unlock
* syncobj: store directscanout fence in monitor
ensure the infence fd survives the scope of attemptdirectscanout so it
doesnt close before it should have.
* syncobj: check if if acquire is expired
we might hit a race to finish on exit where the timeline just has
destructed but the buffer waiter is still pending. and such we
removeAllWaiters null dereferences.
* syncobj: code style changes
remove quack comment, change to m_foo and use a std::vector and
weakpointer in the waiter for removal instead of a std::list.
* syncobj: remove unused async buffer drop
remove unused async buffer drop, only related to directscanout and is
handled elsewhere.
---------
Co-authored-by: Lee Bousfield <ljbousfield@gmail.com>
2025-03-14 15:08:20 +01:00
}
2024-08-06 14:52:19 +01:00
2024-07-21 13:09:54 +02:00
bool CDRMSyncobjSurfaceResource : : good ( ) {
2025-05-04 00:13:29 +02:00
return m_resource - > resource ( ) ;
2024-07-21 13:09:54 +02:00
}
2025-05-04 00:13:29 +02:00
CDRMSyncobjTimelineResource : : CDRMSyncobjTimelineResource ( UP < CWpLinuxDrmSyncobjTimelineV1 > & & resource_ , CFileDescriptor & & fd_ ) :
m_fd ( std : : move ( fd_ ) ) , m_resource ( std : : move ( resource_ ) ) {
2025-01-17 18:21:34 +01:00
if UNLIKELY ( ! good ( ) )
2024-07-21 13:09:54 +02:00
return ;
2025-05-04 00:13:29 +02:00
m_resource - > setData ( this ) ;
2024-07-21 13:09:54 +02:00
2025-05-04 00:13:29 +02:00
m_resource - > setOnDestroy ( [ this ] ( CWpLinuxDrmSyncobjTimelineV1 * r ) { PROTO : : sync - > destroyResource ( this ) ; } ) ;
m_resource - > setDestroy ( [ this ] ( CWpLinuxDrmSyncobjTimelineV1 * r ) { PROTO : : sync - > destroyResource ( this ) ; } ) ;
2024-07-21 13:09:54 +02:00
2025-05-04 00:13:29 +02:00
m_timeline = CSyncTimeline : : create ( PROTO : : sync - > m_drmFD , std : : move ( m_fd ) ) ;
2024-07-21 13:09:54 +02:00
2025-05-04 00:13:29 +02:00
if ( ! m_timeline ) {
m_resource - > error ( WP_LINUX_DRM_SYNCOBJ_MANAGER_V1_ERROR_INVALID_TIMELINE , " Timeline failed importing " ) ;
2024-07-21 13:09:54 +02:00
return ;
}
}
syncobj: use eventfd instead of stalling fd checks (#9437)
* syncobj: cleanup and use uniqueptrs
cleanup a bit missing removals if resource not good, erasing from
containers etc. make use of unique ptrs instead. and add default
destructors.
* syncobj: rework syncobj entirerly
remove early buffer release that was breaking explicit sync, the buffer
needs to exist until the surface commit event has been emitted and draw
calls added egl sync points, move to eventfd signaling instead of
stalling sync point checks, and recommit pending commits if waiting on a
signal. add a CDRMSyncPointState helper class. move a few weak pointers
to shared pointers so they dont destruct before we need to use them.
* syncobj: queue pending states for eventfd
eventfd requires us to queue pending stats until ready and then apply to
current, and also when no ready state exist commit the client commit on
the current existing buffer, if there is one.
* syncobj: clear current buffer damage
clear current buffer damage on current buffer commits.
* syncobj: cleanup code and fix hyprlock
remove unused code, and ensure we dont commit a empty texture causing
locksession protocol and gtk4-layer-shell misbehaving.
* syncobj: ensure buffers are cleaned up
ensure the containers having the various buffers actually gets cleaned
up from their containers, incase the CSignal isnt signaled because of
expired smart pointers or just wrong order destruction because mishaps.
also move the acquire/point setting to buffer attaching. instead of on
precommit.
* syncobj: remove unused code, optimize
remove unused code and merge sync fds if fence is valid, remove manual
directscanout buffer dropping that signals release point on pageflip, it
can cause us to signal the release point while still keeping the current
buffer and rendering it yet again causing wrong things.
* syncobj: delay buffer release on non syncobj
delay buffer releases on non syncobj surfaces until next commit, and
check on async buffers if syncobj and drop and signal the release point
on backend buffer release.
* syncobj: ensure we follow protocol
ensure we follow protocol by replacing acquire/release points if they
arrive late and replace already existing ones. also remove unneded
brackets, and dont try to manual lock/release buffers when it comes to
explicit protocol. it doesnt care about buffer releases only about
acquire and release points and signaling them.
* syncobj: lets not complicate things
set points in precommit, before checking protocol errors and we catch
any pending acquire/release points arriving late.
* syncobj: move SSurfaceState to types
remove destructor resource destroying, let resources destroys them on
their events, and move SSurfaceStates to types/SurfaceState.hpp
* syncobj: actually store the merged fd
have to actually store the mergedfd to use it.
* syncobj: cleanup a bit around fences
ensure the current asynchronous buffer is actually released on pageflip
not the previous. cleanup a bit FD handling in
commitPendingAndDoExplicitSync, and reuse the in fence when syncing
surfaces.
* syncobjs: ensure fence FD doesnt leak
calling resetexplicitfence without properly ensuring the FD is closed
before will leak it, store it per monitor and let it close itself with
the CFileDescriptor class.
* syncobj: ensure buffers are actually released
buffers were never being sent released properly.
* types: Defer buffer sync releaser until unlock
* syncobj: store directscanout fence in monitor
ensure the infence fd survives the scope of attemptdirectscanout so it
doesnt close before it should have.
* syncobj: check if if acquire is expired
we might hit a race to finish on exit where the timeline just has
destructed but the buffer waiter is still pending. and such we
removeAllWaiters null dereferences.
* syncobj: code style changes
remove quack comment, change to m_foo and use a std::vector and
weakpointer in the waiter for removal instead of a std::list.
* syncobj: remove unused async buffer drop
remove unused async buffer drop, only related to directscanout and is
handled elsewhere.
---------
Co-authored-by: Lee Bousfield <ljbousfield@gmail.com>
2025-03-14 15:08:20 +01:00
WP < CDRMSyncobjTimelineResource > CDRMSyncobjTimelineResource : : fromResource ( wl_resource * res ) {
2025-05-04 00:13:29 +02:00
for ( const auto & r : PROTO : : sync - > m_timelines ) {
if ( r & & r - > m_resource & & r - > m_resource - > resource ( ) = = res )
syncobj: use eventfd instead of stalling fd checks (#9437)
* syncobj: cleanup and use uniqueptrs
cleanup a bit missing removals if resource not good, erasing from
containers etc. make use of unique ptrs instead. and add default
destructors.
* syncobj: rework syncobj entirerly
remove early buffer release that was breaking explicit sync, the buffer
needs to exist until the surface commit event has been emitted and draw
calls added egl sync points, move to eventfd signaling instead of
stalling sync point checks, and recommit pending commits if waiting on a
signal. add a CDRMSyncPointState helper class. move a few weak pointers
to shared pointers so they dont destruct before we need to use them.
* syncobj: queue pending states for eventfd
eventfd requires us to queue pending stats until ready and then apply to
current, and also when no ready state exist commit the client commit on
the current existing buffer, if there is one.
* syncobj: clear current buffer damage
clear current buffer damage on current buffer commits.
* syncobj: cleanup code and fix hyprlock
remove unused code, and ensure we dont commit a empty texture causing
locksession protocol and gtk4-layer-shell misbehaving.
* syncobj: ensure buffers are cleaned up
ensure the containers having the various buffers actually gets cleaned
up from their containers, incase the CSignal isnt signaled because of
expired smart pointers or just wrong order destruction because mishaps.
also move the acquire/point setting to buffer attaching. instead of on
precommit.
* syncobj: remove unused code, optimize
remove unused code and merge sync fds if fence is valid, remove manual
directscanout buffer dropping that signals release point on pageflip, it
can cause us to signal the release point while still keeping the current
buffer and rendering it yet again causing wrong things.
* syncobj: delay buffer release on non syncobj
delay buffer releases on non syncobj surfaces until next commit, and
check on async buffers if syncobj and drop and signal the release point
on backend buffer release.
* syncobj: ensure we follow protocol
ensure we follow protocol by replacing acquire/release points if they
arrive late and replace already existing ones. also remove unneded
brackets, and dont try to manual lock/release buffers when it comes to
explicit protocol. it doesnt care about buffer releases only about
acquire and release points and signaling them.
* syncobj: lets not complicate things
set points in precommit, before checking protocol errors and we catch
any pending acquire/release points arriving late.
* syncobj: move SSurfaceState to types
remove destructor resource destroying, let resources destroys them on
their events, and move SSurfaceStates to types/SurfaceState.hpp
* syncobj: actually store the merged fd
have to actually store the mergedfd to use it.
* syncobj: cleanup a bit around fences
ensure the current asynchronous buffer is actually released on pageflip
not the previous. cleanup a bit FD handling in
commitPendingAndDoExplicitSync, and reuse the in fence when syncing
surfaces.
* syncobjs: ensure fence FD doesnt leak
calling resetexplicitfence without properly ensuring the FD is closed
before will leak it, store it per monitor and let it close itself with
the CFileDescriptor class.
* syncobj: ensure buffers are actually released
buffers were never being sent released properly.
* types: Defer buffer sync releaser until unlock
* syncobj: store directscanout fence in monitor
ensure the infence fd survives the scope of attemptdirectscanout so it
doesnt close before it should have.
* syncobj: check if if acquire is expired
we might hit a race to finish on exit where the timeline just has
destructed but the buffer waiter is still pending. and such we
removeAllWaiters null dereferences.
* syncobj: code style changes
remove quack comment, change to m_foo and use a std::vector and
weakpointer in the waiter for removal instead of a std::list.
* syncobj: remove unused async buffer drop
remove unused async buffer drop, only related to directscanout and is
handled elsewhere.
---------
Co-authored-by: Lee Bousfield <ljbousfield@gmail.com>
2025-03-14 15:08:20 +01:00
return r ;
}
return { } ;
2024-07-21 13:09:54 +02:00
}
bool CDRMSyncobjTimelineResource : : good ( ) {
2025-05-04 00:13:29 +02:00
return m_resource - > resource ( ) ;
2024-07-21 13:09:54 +02:00
}
2025-05-04 00:13:29 +02:00
CDRMSyncobjManagerResource : : CDRMSyncobjManagerResource ( UP < CWpLinuxDrmSyncobjManagerV1 > & & resource_ ) : m_resource ( std : : move ( resource_ ) ) {
2025-01-17 18:21:34 +01:00
if UNLIKELY ( ! good ( ) )
2024-07-21 13:09:54 +02:00
return ;
2025-05-04 00:13:29 +02:00
m_resource - > setOnDestroy ( [ this ] ( CWpLinuxDrmSyncobjManagerV1 * r ) { PROTO : : sync - > destroyResource ( this ) ; } ) ;
m_resource - > setDestroy ( [ this ] ( CWpLinuxDrmSyncobjManagerV1 * r ) { PROTO : : sync - > destroyResource ( this ) ; } ) ;
2024-07-21 13:09:54 +02:00
2025-05-04 00:13:29 +02:00
m_resource - > setGetSurface ( [ this ] ( CWpLinuxDrmSyncobjManagerV1 * r , uint32_t id , wl_resource * surf ) {
2025-01-17 18:21:34 +01:00
if UNLIKELY ( ! surf ) {
2025-05-04 00:13:29 +02:00
m_resource - > error ( - 1 , " Invalid surface " ) ;
2024-07-21 13:09:54 +02:00
return ;
}
auto SURF = CWLSurfaceResource : : fromResource ( surf ) ;
2025-01-17 18:21:34 +01:00
if UNLIKELY ( ! SURF ) {
2025-05-04 00:13:29 +02:00
m_resource - > error ( - 1 , " Invalid surface (2) " ) ;
2024-07-21 13:09:54 +02:00
return ;
}
2025-05-03 16:02:49 +02:00
if UNLIKELY ( SURF - > m_syncobj ) {
2025-05-04 00:13:29 +02:00
m_resource - > error ( WP_LINUX_DRM_SYNCOBJ_MANAGER_V1_ERROR_SURFACE_EXISTS , " Surface already has a syncobj attached " ) ;
2024-07-21 13:09:54 +02:00
return ;
}
2025-05-04 00:13:29 +02:00
const auto & RESOURCE = PROTO : : sync - > m_surfaces . emplace_back (
makeUnique < CDRMSyncobjSurfaceResource > ( makeUnique < CWpLinuxDrmSyncobjSurfaceV1 > ( m_resource - > client ( ) , m_resource - > version ( ) , id ) , SURF ) ) ;
2025-01-17 18:21:34 +01:00
if UNLIKELY ( ! RESOURCE - > good ( ) ) {
2025-05-04 00:13:29 +02:00
m_resource - > noMemory ( ) ;
PROTO : : sync - > m_surfaces . pop_back ( ) ;
2024-07-21 13:09:54 +02:00
return ;
}
2025-05-03 16:02:49 +02:00
SURF - > m_syncobj = RESOURCE ;
2024-07-21 13:09:54 +02:00
LOGM ( LOG , " New linux_syncobj at {:x} for surface {:x} " , ( uintptr_t ) RESOURCE . get ( ) , ( uintptr_t ) SURF . get ( ) ) ;
} ) ;
2025-05-04 00:13:29 +02:00
m_resource - > setImportTimeline ( [ this ] ( CWpLinuxDrmSyncobjManagerV1 * r , uint32_t id , int32_t fd ) {
const auto & RESOURCE = PROTO : : sync - > m_timelines . emplace_back (
makeUnique < CDRMSyncobjTimelineResource > ( makeUnique < CWpLinuxDrmSyncobjTimelineV1 > ( m_resource - > client ( ) , m_resource - > version ( ) , id ) , CFileDescriptor { fd } ) ) ;
2025-01-17 18:21:34 +01:00
if UNLIKELY ( ! RESOURCE - > good ( ) ) {
2025-05-04 00:13:29 +02:00
m_resource - > noMemory ( ) ;
PROTO : : sync - > m_timelines . pop_back ( ) ;
2024-07-21 13:09:54 +02:00
return ;
}
LOGM ( LOG , " New linux_drm_timeline at {:x} " , ( uintptr_t ) RESOURCE . get ( ) ) ;
} ) ;
}
bool CDRMSyncobjManagerResource : : good ( ) {
2025-05-04 00:13:29 +02:00
return m_resource - > resource ( ) ;
2024-07-21 13:09:54 +02:00
}
2025-05-04 00:13:29 +02:00
CDRMSyncobjProtocol : : CDRMSyncobjProtocol ( const wl_interface * iface , const int & ver , const std : : string & name ) :
IWaylandProtocol ( iface , ver , name ) , m_drmFD ( g_pCompositor - > m_drmFD ) { }
2024-07-21 13:09:54 +02:00
void CDRMSyncobjProtocol : : bindManager ( wl_client * client , void * data , uint32_t ver , uint32_t id ) {
2025-05-04 00:13:29 +02:00
const auto & RESOURCE = m_managers . emplace_back ( makeUnique < CDRMSyncobjManagerResource > ( makeUnique < CWpLinuxDrmSyncobjManagerV1 > ( client , ver , id ) ) ) ;
2024-07-21 13:09:54 +02:00
2025-01-17 18:21:34 +01:00
if UNLIKELY ( ! RESOURCE - > good ( ) ) {
2024-07-21 13:09:54 +02:00
wl_client_post_no_memory ( client ) ;
2025-05-04 00:13:29 +02:00
m_managers . pop_back ( ) ;
2024-07-21 13:09:54 +02:00
return ;
}
}
void CDRMSyncobjProtocol : : destroyResource ( CDRMSyncobjManagerResource * resource ) {
2025-05-04 00:13:29 +02:00
std : : erase_if ( m_managers , [ resource ] ( const auto & e ) { return e . get ( ) = = resource ; } ) ;
2024-07-21 13:09:54 +02:00
}
void CDRMSyncobjProtocol : : destroyResource ( CDRMSyncobjTimelineResource * resource ) {
2025-05-04 00:13:29 +02:00
std : : erase_if ( m_timelines , [ resource ] ( const auto & e ) { return e . get ( ) = = resource ; } ) ;
2024-07-21 13:09:54 +02:00
}
void CDRMSyncobjProtocol : : destroyResource ( CDRMSyncobjSurfaceResource * resource ) {
2025-05-04 00:13:29 +02:00
std : : erase_if ( m_surfaces , [ resource ] ( const auto & e ) { return e . get ( ) = = resource ; } ) ;
2024-07-21 13:09:54 +02:00
}