summaryrefslogtreecommitdiff
path: root/src/render
diff options
context:
space:
mode:
Diffstat (limited to 'src/render')
-rw-r--r--src/render/OpenGL.cpp59
-rw-r--r--src/render/OpenGL.hpp13
-rw-r--r--src/render/Renderer.cpp24
-rw-r--r--src/render/pass/SurfacePassElement.cpp8
4 files changed, 26 insertions, 78 deletions
diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp
index a8a38bac..86e81efb 100644
--- a/src/render/OpenGL.cpp
+++ b/src/render/OpenGL.cpp
@@ -1292,16 +1292,16 @@ void CHyprOpenGLImpl::renderTexture(SP<CTexture> tex, const CBox& box, float alp
}
void CHyprOpenGLImpl::renderTextureWithDamage(SP<CTexture> tex, const CBox& box, const CRegion& damage, float alpha, int round, float roundingPower, bool discardActive,
- bool allowCustomUV, SP<CSyncTimeline> waitTimeline, uint64_t waitPoint) {
+ bool allowCustomUV) {
RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!");
- renderTextureInternalWithDamage(tex, box, alpha, damage, round, roundingPower, discardActive, false, allowCustomUV, true, waitTimeline, waitPoint);
+ renderTextureInternalWithDamage(tex, box, alpha, damage, round, roundingPower, discardActive, false, allowCustomUV, true);
scissor(nullptr);
}
void CHyprOpenGLImpl::renderTextureInternalWithDamage(SP<CTexture> tex, const CBox& box, float alpha, const CRegion& damage, int round, float roundingPower, bool discardActive,
- bool noAA, bool allowCustomUV, bool allowDim, SP<CSyncTimeline> waitTimeline, uint64_t waitPoint) {
+ bool noAA, bool allowCustomUV, bool allowDim) {
RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!");
RASSERT((tex->m_iTexID > 0), "Attempted to draw nullptr texture!");
@@ -1324,15 +1324,8 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(SP<CTexture> tex, const CB
if (m_bEndFrame || TRANSFORMS_MATCH)
TRANSFORM = wlTransformToHyprutils(invertTransform(m_RenderData.pMonitor->transform));
- Mat3x3 matrix = m_RenderData.monitorProjection.projectBox(newBox, TRANSFORM, newBox.rot);
- Mat3x3 glMatrix = m_RenderData.projection.copy().multiply(matrix);
-
- if (waitTimeline != nullptr) {
- if (!waitForTimelinePoint(waitTimeline, waitPoint)) {
- Debug::log(ERR, "renderTextureInternalWithDamage: failed to wait for explicit sync point {}", waitPoint);
- return;
- }
- }
+ Mat3x3 matrix = m_RenderData.monitorProjection.projectBox(newBox, TRANSFORM, newBox.rot);
+ Mat3x3 glMatrix = m_RenderData.projection.copy().multiply(matrix);
CShader* shader = nullptr;
@@ -2915,11 +2908,11 @@ std::vector<SDRMFormat> CHyprOpenGLImpl::getDRMFormats() {
return drmFormats;
}
-SP<CEGLSync> CHyprOpenGLImpl::createEGLSync(CFileDescriptor fenceFD) {
+SP<CEGLSync> CHyprOpenGLImpl::createEGLSync(int fenceFD) {
std::vector<EGLint> attribs;
CFileDescriptor dupFd;
- if (fenceFD.isValid()) {
- dupFd = fenceFD.duplicate();
+ if (fenceFD >= 0) {
+ dupFd = CFileDescriptor{fcntl(fenceFD, F_DUPFD_CLOEXEC, 0)};
if (!dupFd.isValid()) {
Debug::log(ERR, "createEGLSync: dup failed");
return nullptr;
@@ -2953,27 +2946,6 @@ SP<CEGLSync> CHyprOpenGLImpl::createEGLSync(CFileDescriptor fenceFD) {
return eglsync;
}
-bool CHyprOpenGLImpl::waitForTimelinePoint(SP<CSyncTimeline> timeline, uint64_t point) {
- auto fd = timeline->exportAsSyncFileFD(point);
- if (!fd.isValid()) {
- Debug::log(ERR, "waitForTimelinePoint: failed to get a fd from explicit timeline");
- return false;
- }
-
- auto sync = g_pHyprOpenGL->createEGLSync(std::move(fd));
- if (!sync) {
- Debug::log(ERR, "waitForTimelinePoint: failed to get an eglsync from explicit timeline");
- return false;
- }
-
- if (!sync->wait()) {
- Debug::log(ERR, "waitForTimelinePoint: failed to wait on an eglsync from explicit timeline");
- return false;
- }
-
- return true;
-}
-
void SRenderModifData::applyToBox(CBox& box) {
if (!enabled)
return;
@@ -3043,17 +3015,10 @@ CEGLSync::~CEGLSync() {
Debug::log(ERR, "eglDestroySyncKHR failed");
}
-CFileDescriptor& CEGLSync::fd() {
- return m_iFd;
+CFileDescriptor&& CEGLSync::takeFD() {
+ return std::move(m_iFd);
}
-bool CEGLSync::wait() {
- if (sync == EGL_NO_SYNC_KHR)
- return false;
-
- if (g_pHyprOpenGL->m_sProc.eglWaitSyncKHR(g_pHyprOpenGL->m_pEglDisplay, sync, 0) != EGL_TRUE) {
- Debug::log(ERR, "eglWaitSyncKHR failed");
- return false;
- }
- return true;
+CFileDescriptor& CEGLSync::fd() {
+ return m_iFd;
}
diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp
index 11079591..3933bfc4 100644
--- a/src/render/OpenGL.hpp
+++ b/src/render/OpenGL.hpp
@@ -148,10 +148,10 @@ class CEGLSync {
public:
~CEGLSync();
- EGLSyncKHR sync = nullptr;
+ EGLSyncKHR sync = nullptr;
- Hyprutils::OS::CFileDescriptor& fd();
- bool wait();
+ Hyprutils::OS::CFileDescriptor&& takeFD();
+ Hyprutils::OS::CFileDescriptor& fd();
private:
CEGLSync() = default;
@@ -177,7 +177,7 @@ class CHyprOpenGLImpl {
void renderRectWithDamage(const CBox&, const CHyprColor&, const CRegion& damage, int round = 0, float roundingPower = 2.0f);
void renderTexture(SP<CTexture>, const CBox&, float a, int round = 0, float roundingPower = 2.0f, bool discardActive = false, bool allowCustomUV = false);
void renderTextureWithDamage(SP<CTexture>, const CBox&, const CRegion& damage, float a, int round = 0, float roundingPower = 2.0f, bool discardActive = false,
- bool allowCustomUV = false, SP<CSyncTimeline> waitTimeline = nullptr, uint64_t waitPoint = 0);
+ bool allowCustomUV = false);
void renderTextureWithBlur(SP<CTexture>, const CBox&, float a, SP<CWLSurfaceResource> pSurface, int round = 0, float roundingPower = 2.0f, bool blockBlurOptimization = false,
float blurA = 1.f, float overallA = 1.f);
void renderRoundedShadow(const CBox&, int round, float roundingPower, int range, const CHyprColor& color, float a = 1.0);
@@ -230,8 +230,7 @@ class CHyprOpenGLImpl {
uint32_t getPreferredReadFormat(PHLMONITOR pMonitor);
std::vector<SDRMFormat> getDRMFormats();
EGLImageKHR createEGLImage(const Aquamarine::SDMABUFAttrs& attrs);
- SP<CEGLSync> createEGLSync(Hyprutils::OS::CFileDescriptor fenceFD);
- bool waitForTimelinePoint(SP<CSyncTimeline> timeline, uint64_t point);
+ SP<CEGLSync> createEGLSync(int fence = -1);
SCurrentRenderData m_RenderData;
@@ -315,7 +314,7 @@ class CHyprOpenGLImpl {
CFramebuffer* blurMainFramebufferWithDamage(float a, CRegion* damage);
void renderTextureInternalWithDamage(SP<CTexture>, const CBox& box, float a, const CRegion& damage, int round = 0, float roundingPower = 2.0f, bool discardOpaque = false,
- bool noAA = false, bool allowCustomUV = false, bool allowDim = false, SP<CSyncTimeline> = nullptr, uint64_t waitPoint = 0);
+ bool noAA = false, bool allowCustomUV = false, bool allowDim = false);
void renderTexturePrimitive(SP<CTexture> tex, const CBox& box);
void renderSplash(cairo_t* const, cairo_surface_t* const, double offset, const Vector2D& size);
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 88de1ada..e7d3630a 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -1450,13 +1450,6 @@ static hdr_output_metadata createHDRMetadata(SImageDescription settings, A
bool CHyprRenderer::commitPendingAndDoExplicitSync(PHLMONITOR pMonitor) {
pMonitor->commitSeq++;
- // apply timelines for explicit sync
- // save inFD otherwise reset will reset it
- CFileDescriptor inFD{pMonitor->output->state->state().explicitInFence};
- pMonitor->output->state->resetExplicitFences();
- if (inFD.isValid())
- pMonitor->output->state->setExplicitInFence(inFD.get());
-
static auto PPASS = CConfigValue<Hyprlang::INT>("render:cm_fs_passthrough");
const bool PHDR = pMonitor->imageDescription.transferFunction == CM_TRANSFER_FUNCTION_ST2084_PQ;
@@ -1517,7 +1510,7 @@ bool CHyprRenderer::commitPendingAndDoExplicitSync(PHLMONITOR pMonitor) {
bool ok = pMonitor->state.commit();
if (!ok) {
- if (inFD.isValid()) {
+ if (pMonitor->inFence.isValid()) {
Debug::log(TRACE, "Monitor state commit failed, retrying without a fence");
pMonitor->output->state->resetExplicitFences();
ok = pMonitor->state.commit();
@@ -1537,21 +1530,20 @@ bool CHyprRenderer::commitPendingAndDoExplicitSync(PHLMONITOR pMonitor) {
return ok;
Debug::log(TRACE, "Explicit: {} presented", explicitPresented.size());
- auto sync = g_pHyprOpenGL->createEGLSync({});
+ auto sync = g_pHyprOpenGL->createEGLSync(pMonitor->inFence.get());
if (!sync)
Debug::log(TRACE, "Explicit: can't add sync, EGLSync failed");
else {
for (auto const& e : explicitPresented) {
- if (!e->current.buffer || !e->current.buffer->releaser)
+ if (!e->current.buffer || !e->current.buffer->buffer || !e->current.buffer->buffer->syncReleaser)
continue;
- e->current.buffer->releaser->addReleaseSync(sync);
+ e->current.buffer->buffer->syncReleaser->addReleaseSync(sync);
}
}
explicitPresented.clear();
-
pMonitor->output->state->resetExplicitFences();
return ok;
@@ -2269,7 +2261,7 @@ void CHyprRenderer::endRender() {
auto explicitOptions = getExplicitSyncSettings(PMONITOR->output);
if (PMONITOR->inTimeline && explicitOptions.explicitEnabled && explicitOptions.explicitKMSEnabled) {
- auto sync = g_pHyprOpenGL->createEGLSync({});
+ auto sync = g_pHyprOpenGL->createEGLSync();
if (!sync) {
Debug::log(ERR, "renderer: couldn't create an EGLSync for out in endRender");
return;
@@ -2281,13 +2273,13 @@ void CHyprRenderer::endRender() {
return;
}
- auto fd = PMONITOR->inTimeline->exportAsSyncFileFD(PMONITOR->commitSeq);
- if (!fd.isValid()) {
+ PMONITOR->inFence = CFileDescriptor{PMONITOR->inTimeline->exportAsSyncFileFD(PMONITOR->commitSeq)};
+ if (!PMONITOR->inFence.isValid()) {
Debug::log(ERR, "renderer: couldn't export from sync timeline in endRender");
return;
}
- PMONITOR->output->state->setExplicitInFence(fd.take());
+ PMONITOR->output->state->setExplicitInFence(PMONITOR->inFence.get());
} else {
if (isNvidia() && *PNVIDIAANTIFLICKER)
glFinish();
diff --git a/src/render/pass/SurfacePassElement.cpp b/src/render/pass/SurfacePassElement.cpp
index 46c6d221..813ab8ea 100644
--- a/src/render/pass/SurfacePassElement.cpp
+++ b/src/render/pass/SurfacePassElement.cpp
@@ -51,14 +51,6 @@ void CSurfacePassElement::draw(const CRegion& damage) {
if (!TEXTURE->m_iTexID)
return;
- // explicit sync: wait for the timeline, if any
- if (data.surface->syncobj && data.surface->syncobj->current.acquireTimeline) {
- if (!g_pHyprOpenGL->waitForTimelinePoint(data.surface->syncobj->current.acquireTimeline->timeline, data.surface->syncobj->current.acquirePoint)) {
- Debug::log(ERR, "Renderer: failed to wait for explicit timeline");
- return;
- }
- }
-
const auto INTERACTIVERESIZEINPROGRESS = data.pWindow && g_pInputManager->currentlyDraggedWindow && g_pInputManager->dragMode == MBIND_RESIZE;
TRACY_GPU_ZONE("RenderSurface");