This commit is contained in:
Vaxry 2024-03-18 23:03:38 +00:00
parent 941c003dec
commit 8f38c06ac1
3 changed files with 20 additions and 9 deletions

View file

@ -30,6 +30,8 @@ static int fdHandleWrite(int fd, uint32_t mask, void* data) {
g_pFrameSchedulingManager->gpuDone(RB->m_pWlrBuffer); g_pFrameSchedulingManager->gpuDone(RB->m_pWlrBuffer);
RB->removeFence();
return 0; return 0;
} }
@ -82,11 +84,6 @@ CRenderbuffer::CRenderbuffer(wlr_buffer* buffer, uint32_t format, CMonitor* pMon
}, },
this, "CRenderbuffer"); this, "CRenderbuffer");
wlr_dmabuf_attributes attrs = {0};
wlr_buffer_get_dmabuf(m_pWlrBuffer, &attrs);
m_pFDWrite = wl_event_loop_add_fd(g_pCompositor->m_sWLEventLoop, attrs.fd[0], WL_EVENT_READABLE, fdHandleWrite, this);
g_pFrameSchedulingManager->registerBuffer(m_pWlrBuffer, pMonitor); g_pFrameSchedulingManager->registerBuffer(m_pWlrBuffer, pMonitor);
} }
@ -111,3 +108,14 @@ void CRenderbuffer::unbind() {
CFramebuffer* CRenderbuffer::getFB() { CFramebuffer* CRenderbuffer::getFB() {
return &m_sFramebuffer; return &m_sFramebuffer;
} }
void CRenderbuffer::plantFence() {
wlr_dmabuf_attributes attrs = {0};
wlr_buffer_get_dmabuf(m_pWlrBuffer, &attrs);
m_pFDWrite = wl_event_loop_add_fd(g_pCompositor->m_sWLEventLoop, attrs.fd[0], WL_EVENT_WRITABLE, fdHandleWrite, this);
}
void CRenderbuffer::removeFence() {
wl_event_source_remove(m_pFDWrite);
m_pFDWrite = nullptr;
}

View file

@ -13,15 +13,17 @@ class CRenderbuffer {
void bindFB(); void bindFB();
void unbind(); void unbind();
CFramebuffer* getFB(); CFramebuffer* getFB();
void plantFence();
void removeFence();
wlr_buffer* m_pWlrBuffer = nullptr; wlr_buffer* m_pWlrBuffer = nullptr;
DYNLISTENER(destroyBuffer); DYNLISTENER(destroyBuffer);
private: private:
EGLImageKHR m_iImage = 0; EGLImageKHR m_iImage = 0;
GLuint m_iRBO = 0; GLuint m_iRBO = 0;
CFramebuffer m_sFramebuffer; CFramebuffer m_sFramebuffer;
CMonitor* m_pMonitor = nullptr; CMonitor* m_pMonitor = nullptr;
wl_event_source* m_pFDWrite = nullptr; wl_event_source* m_pFDWrite = nullptr;
}; };

View file

@ -2676,6 +2676,7 @@ void CHyprRenderer::endRender() {
glFlush(); glFlush();
if (m_eRenderMode == RENDER_MODE_NORMAL) { if (m_eRenderMode == RENDER_MODE_NORMAL) {
m_pCurrentRenderbuffer->plantFence();
wlr_output_state_set_buffer(PMONITOR->state.wlr(), m_pCurrentWlrBuffer); wlr_output_state_set_buffer(PMONITOR->state.wlr(), m_pCurrentWlrBuffer);
unsetEGL(); // flush the context unsetEGL(); // flush the context
} }