* protocols: add Fifo-v1 introduce fifo-v1 * fifo: only present locked surfaces dont present to unlocked surfaces and commit pending states from the fifo protocol. * fifo: cformat cformat * protocols: add committiming and surface state queue introduce CSurfaceStateQueue and commit-timing-v1 * fifo: schedule a frame if waiting on barrier if we are waiting on a barrier the state doesnt commit until the next refresh cycle meaning the monitor might have no pending damage and we never get onPresented to unlock the barrier, moment 22. so schedule a frame. * fifo: properly check monitor intersection check for m_enteredoutputs or monitor intersection if client hasnt bound one yet, and dont fifo lock it until the surface is mapped. * buffer: try to merge states before committing them try to merge states before committing them meaning way less churn and surface commits if a surface sends multiple small ones while we wait for buffer readyness from either fifo locks or simply fences. * buffer: dont commit states past the buffer certain changes are relative to the buffer attached, cant go beyond it and apply those onto the next buffer. * buffer: set the lockmask directly cant use .lock since the state hasnt been queued yet, set the lockmask directly when exporting buffer fence. * fifo: dont fifo lock on tearing dont fifo lock on tearing. * buffer: queue the state directly queue the state directly and use the .lock function instead of directly modify the lockMask on the state. * buffer: revert creating texture at commit time fifo barriers introduces such long wait that upon commit time a race happends with current xdg configure implentation that the buffer and image is actually destroyed when entering commitState, doing it at buffer creation time with EGL_PRESERVED_KHR means it sticks around until we are done. so revert82759d4and32f3233for now. * buffer: rename enum and lockreasons eLockReason and LOCK_REASON_NONE. * fifo: workaround direct scanout lock workaround cursor commits causing fifo to get forever locked, this entire thing needs to be worked out.
112 lines
3 KiB
C++
112 lines
3 KiB
C++
#pragma once
|
|
|
|
/*
|
|
Implementations for:
|
|
- wl_shm
|
|
- wl_shm_pool
|
|
- wl_buffer with shm
|
|
*/
|
|
|
|
#include <hyprutils/os/FileDescriptor.hpp>
|
|
#include <memory>
|
|
#include <vector>
|
|
#include <cstdint>
|
|
#include "../WaylandProtocol.hpp"
|
|
#include "wayland.hpp"
|
|
#include "../types/Buffer.hpp"
|
|
#include "../../helpers/math/Math.hpp"
|
|
|
|
class CWLSHMPoolResource;
|
|
|
|
class CSHMPool {
|
|
public:
|
|
CSHMPool() = delete;
|
|
CSHMPool(Hyprutils::OS::CFileDescriptor fd, size_t size);
|
|
~CSHMPool();
|
|
|
|
Hyprutils::OS::CFileDescriptor m_fd;
|
|
size_t m_size = 0;
|
|
void* m_data = nullptr;
|
|
|
|
void resize(size_t size);
|
|
};
|
|
|
|
class CWLSHMBuffer : public IHLBuffer {
|
|
public:
|
|
CWLSHMBuffer(WP<CWLSHMPoolResource> pool, uint32_t id, int32_t offset, const Vector2D& size, int32_t stride, uint32_t fmt);
|
|
virtual ~CWLSHMBuffer();
|
|
|
|
virtual Aquamarine::eBufferCapability caps();
|
|
virtual Aquamarine::eBufferType type();
|
|
virtual void update(const CRegion& damage);
|
|
virtual bool isSynchronous();
|
|
virtual Aquamarine::SSHMAttrs shm();
|
|
virtual std::tuple<uint8_t*, uint32_t, size_t> beginDataPtr(uint32_t flags);
|
|
virtual void endDataPtr();
|
|
|
|
bool good();
|
|
|
|
int32_t m_offset = 0;
|
|
int32_t m_stride = 0;
|
|
uint32_t m_fmt = 0;
|
|
SP<CSHMPool> m_pool;
|
|
|
|
private:
|
|
struct {
|
|
CHyprSignalListener bufferResourceDestroy;
|
|
} m_listeners;
|
|
};
|
|
|
|
class CWLSHMPoolResource {
|
|
public:
|
|
CWLSHMPoolResource(UP<CWlShmPool>&& resource_, Hyprutils::OS::CFileDescriptor fd, size_t size);
|
|
|
|
bool good();
|
|
|
|
SP<CSHMPool> m_pool;
|
|
|
|
WP<CWLSHMPoolResource> m_self;
|
|
|
|
private:
|
|
UP<CWlShmPool> m_resource;
|
|
|
|
friend class CWLSHMBuffer;
|
|
};
|
|
|
|
class CWLSHMResource {
|
|
public:
|
|
CWLSHMResource(UP<CWlShm>&& resource_);
|
|
|
|
bool good();
|
|
|
|
private:
|
|
UP<CWlShm> m_resource;
|
|
};
|
|
|
|
class CWLSHMProtocol : public IWaylandProtocol {
|
|
public:
|
|
CWLSHMProtocol(const wl_interface* iface, const int& ver, const std::string& name);
|
|
|
|
virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);
|
|
|
|
private:
|
|
void destroyResource(CWLSHMResource* resource);
|
|
void destroyResource(CWLSHMPoolResource* resource);
|
|
void destroyResource(CWLSHMBuffer* resource);
|
|
|
|
//
|
|
std::vector<UP<CWLSHMResource>> m_managers;
|
|
std::vector<UP<CWLSHMPoolResource>> m_pools;
|
|
std::vector<SP<CWLSHMBuffer>> m_buffers;
|
|
|
|
//
|
|
std::vector<uint32_t> m_shmFormats;
|
|
|
|
friend class CWLSHMResource;
|
|
friend class CWLSHMPoolResource;
|
|
friend class CWLSHMBuffer;
|
|
};
|
|
|
|
namespace PROTO {
|
|
inline UP<CWLSHMProtocol> shm;
|
|
};
|