From 70c8bdf37199790af4607b89fadb250ffb2517f1 Mon Sep 17 00:00:00 2001 From: Ikalco <73481042+ikalco@users.noreply.github.com> Date: Thu, 23 Jan 2025 16:26:49 -0600 Subject: [PATCH] move renderer to EGLRenderer --- include/aquamarine/allocator/DRMDumb.hpp | 2 +- include/aquamarine/allocator/GBM.hpp | 2 +- include/aquamarine/backend/DRM.hpp | 4 +- include/aquamarine/buffer/Buffer.hpp | 1 - .../aquamarine/renderer/EGLRenderer.hpp | 23 ++-- src/allocator/DRMDumb.cpp | 2 +- src/allocator/GBM.cpp | 11 +- src/backend/drm/DRM.cpp | 6 +- .../Renderer.cpp => renderer/EGLRenderer.cpp} | 113 ++++++++++-------- 9 files changed, 88 insertions(+), 76 deletions(-) rename src/backend/drm/Renderer.hpp => include/aquamarine/renderer/EGLRenderer.hpp (88%) rename src/{backend/drm/Renderer.cpp => renderer/EGLRenderer.cpp} (87%) diff --git a/include/aquamarine/allocator/DRMDumb.hpp b/include/aquamarine/allocator/DRMDumb.hpp index a5eca2c..a13ab85 100644 --- a/include/aquamarine/allocator/DRMDumb.hpp +++ b/include/aquamarine/allocator/DRMDumb.hpp @@ -63,6 +63,6 @@ namespace Aquamarine { int drmfd = -1; friend class CDRMDumbBuffer; - friend class CDRMRenderer; + friend class CEGLRenderer; }; }; diff --git a/include/aquamarine/allocator/GBM.hpp b/include/aquamarine/allocator/GBM.hpp index 09e6cb9..716b496 100644 --- a/include/aquamarine/allocator/GBM.hpp +++ b/include/aquamarine/allocator/GBM.hpp @@ -66,6 +66,6 @@ namespace Aquamarine { std::string drmName = ""; friend class CGBMBuffer; - friend class CDRMRenderer; + friend class CEGLRenderer; }; }; diff --git a/include/aquamarine/backend/DRM.hpp b/include/aquamarine/backend/DRM.hpp index 9f7f718..280af12 100644 --- a/include/aquamarine/backend/DRM.hpp +++ b/include/aquamarine/backend/DRM.hpp @@ -14,7 +14,7 @@ namespace Aquamarine { class CDRMFB; class CDRMOutput; struct SDRMConnector; - class CDRMRenderer; + class CEGLRenderer; class CDRMDumbAllocator; typedef std::function FIdleCallback; @@ -411,7 +411,7 @@ namespace Aquamarine { struct { Hyprutils::Memory::CSharedPointer allocator; - Hyprutils::Memory::CSharedPointer renderer; // may be null if creation fails + Hyprutils::Memory::CSharedPointer renderer; // may be null if creation fails } rendererState; Hyprutils::Memory::CWeakPointer backend; diff --git a/include/aquamarine/buffer/Buffer.hpp b/include/aquamarine/buffer/Buffer.hpp index a96008f..ee18130 100644 --- a/include/aquamarine/buffer/Buffer.hpp +++ b/include/aquamarine/buffer/Buffer.hpp @@ -73,5 +73,4 @@ namespace Aquamarine { private: int locks = 0; }; - }; diff --git a/src/backend/drm/Renderer.hpp b/include/aquamarine/renderer/EGLRenderer.hpp similarity index 88% rename from src/backend/drm/Renderer.hpp rename to include/aquamarine/renderer/EGLRenderer.hpp index 5749754..8f20cf4 100644 --- a/src/backend/drm/Renderer.hpp +++ b/include/aquamarine/renderer/EGLRenderer.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include "FormatUtils.hpp" #include #include @@ -21,11 +22,11 @@ namespace Aquamarine { GLuint target = GL_TEXTURE_2D; }; - class CDRMRendererBufferAttachment : public IAttachment { + class CEGLRendererBufferAttachment : public IAttachment { public: - CDRMRendererBufferAttachment(Hyprutils::Memory::CWeakPointer renderer_, Hyprutils::Memory::CSharedPointer buffer, EGLImageKHR image, GLuint fbo_, + CEGLRendererBufferAttachment(Hyprutils::Memory::CWeakPointer renderer_, Hyprutils::Memory::CSharedPointer buffer, EGLImageKHR image, GLuint fbo_, GLuint rbo_, SGLTex tex); - virtual ~CDRMRendererBufferAttachment() { + virtual ~CEGLRendererBufferAttachment() { ; } virtual eAttachmentType type() { @@ -37,13 +38,13 @@ namespace Aquamarine { SGLTex tex; Hyprutils::Signal::CHyprSignalListener bufferDestroy; - Hyprutils::Memory::CWeakPointer renderer; + Hyprutils::Memory::CWeakPointer renderer; }; - class CDRMRenderer { + class CEGLRenderer { public: - ~CDRMRenderer(); - static Hyprutils::Memory::CSharedPointer attempt(Hyprutils::Memory::CSharedPointer allocator_, + ~CEGLRenderer(); + static Hyprutils::Memory::CSharedPointer attempt(Hyprutils::Memory::CSharedPointer allocator_, Hyprutils::Memory::CSharedPointer backend_); int drmFD = -1; @@ -60,7 +61,7 @@ namespace Aquamarine { void setEGL(); void restoreEGL(); - void onBufferAttachmentDrop(CDRMRendererBufferAttachment* attachment); + void onBufferAttachmentDrop(CEGLRendererBufferAttachment* attachment); struct { struct SShader { @@ -96,11 +97,11 @@ namespace Aquamarine { SGLTex glTex(Hyprutils::Memory::CSharedPointer buf); - Hyprutils::Memory::CWeakPointer self; + Hyprutils::Memory::CWeakPointer self; std::vector formats; private: - CDRMRenderer() = default; + CEGLRenderer() = default; EGLImageKHR createEGLImage(const SDMABUFAttrs& attrs); std::optional>> getModsForFormat(EGLint format); @@ -112,4 +113,4 @@ namespace Aquamarine { Hyprutils::Memory::CWeakPointer backend; }; -}; \ No newline at end of file +}; diff --git a/src/allocator/DRMDumb.cpp b/src/allocator/DRMDumb.cpp index e1fb32f..27506f4 100644 --- a/src/allocator/DRMDumb.cpp +++ b/src/allocator/DRMDumb.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "FormatUtils.hpp" #include "Shared.hpp" #include @@ -10,7 +11,6 @@ #include #include #include -#include "../backend/drm/Renderer.hpp" using namespace Aquamarine; using namespace Hyprutils::Memory; diff --git a/src/allocator/GBM.cpp b/src/allocator/GBM.cpp index aacd2eb..e55bb5e 100644 --- a/src/allocator/GBM.cpp +++ b/src/allocator/GBM.cpp @@ -3,12 +3,12 @@ #include #include #include +#include #include "FormatUtils.hpp" #include "Shared.hpp" #include #include #include -#include "../backend/drm/Renderer.hpp" using namespace Aquamarine; using namespace Hyprutils::Memory; @@ -24,8 +24,7 @@ static SDRMFormat guessFormatFrom(std::vector formats, bool cursor, For cursors, don't, as these almost never support that. */ if (!scanout) { - if (auto it = - std::ranges::find_if(formats, [](const auto& f) { return f.drmFormat == DRM_FORMAT_ARGB2101010 || f.drmFormat == DRM_FORMAT_ABGR2101010; }); + if (auto it = std::ranges::find_if(formats, [](const auto& f) { return f.drmFormat == DRM_FORMAT_ARGB2101010 || f.drmFormat == DRM_FORMAT_ABGR2101010; }); it != formats.end()) return *it; } @@ -36,13 +35,11 @@ static SDRMFormat guessFormatFrom(std::vector formats, bool cursor, } if (!scanout || cursor /* don't set opaque for cursor plane */) { - if (auto it = std::ranges::find_if(formats, [](const auto& f) { return f.drmFormat == DRM_FORMAT_ARGB8888 || f.drmFormat == DRM_FORMAT_ABGR8888; }); - it != formats.end()) + if (auto it = std::ranges::find_if(formats, [](const auto& f) { return f.drmFormat == DRM_FORMAT_ARGB8888 || f.drmFormat == DRM_FORMAT_ABGR8888; }); it != formats.end()) return *it; } - if (auto it = std::ranges::find_if(formats, [](const auto& f) { return f.drmFormat == DRM_FORMAT_XRGB8888 || f.drmFormat == DRM_FORMAT_XBGR8888; }); - it != formats.end()) + if (auto it = std::ranges::find_if(formats, [](const auto& f) { return f.drmFormat == DRM_FORMAT_XRGB8888 || f.drmFormat == DRM_FORMAT_XBGR8888; }); it != formats.end()) return *it; for (auto const& f : formats) { diff --git a/src/backend/drm/DRM.cpp b/src/backend/drm/DRM.cpp index af4681f..7c0d2a8 100644 --- a/src/backend/drm/DRM.cpp +++ b/src/backend/drm/DRM.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -32,7 +33,6 @@ extern "C" { #include "FormatUtils.hpp" #include "Shared.hpp" #include "hwdata.hpp" -#include "Renderer.hpp" using namespace Aquamarine; using namespace Hyprutils::Memory; @@ -562,7 +562,7 @@ bool Aquamarine::CDRMBackend::initMgpu() { return false; } - rendererState.renderer = CDRMRenderer::attempt(newAllocator, backend.lock()); + rendererState.renderer = CEGLRenderer::attempt(newAllocator, backend.lock()); if (!rendererState.renderer) { backend->log(AQ_LOG_ERROR, "drm: initMgpu: no renderer"); @@ -937,7 +937,7 @@ void Aquamarine::CDRMBackend::onReady() { if (!a) backend->log(AQ_LOG_ERROR, "drm: onReady: no renderer for gl formats"); else { - auto r = CDRMRenderer::attempt(a, backend.lock()); + auto r = CEGLRenderer::attempt(a, backend.lock()); if (!r) backend->log(AQ_LOG_ERROR, "drm: onReady: no renderer for gl formats"); else { diff --git a/src/backend/drm/Renderer.cpp b/src/renderer/EGLRenderer.cpp similarity index 87% rename from src/backend/drm/Renderer.cpp rename to src/renderer/EGLRenderer.cpp index 5388926..fb78ee9 100644 --- a/src/backend/drm/Renderer.cpp +++ b/src/renderer/EGLRenderer.cpp @@ -1,14 +1,14 @@ -#include "Renderer.hpp" #include #include #include #include #include #include -#include "Math.hpp" +#include "../backend/drm/Math.hpp" #include "Shared.hpp" #include "FormatUtils.hpp" #include +#include using namespace Aquamarine; using namespace Hyprutils::Memory; @@ -108,7 +108,7 @@ inline void loadGLProc(void* pProc, const char* name) { // ------------------- -std::optional>> CDRMRenderer::getModsForFormat(EGLint format) { +std::optional>> CEGLRenderer::getModsForFormat(EGLint format) { // TODO: return std::expected when clang supports it EGLint len = 0; @@ -140,7 +140,7 @@ std::optional>> CDRMRenderer::getModsForFo return result; } -bool CDRMRenderer::initDRMFormats() { +bool CEGLRenderer::initDRMFormats() { std::vector formats; EGLint len = 0; @@ -198,7 +198,7 @@ bool CDRMRenderer::initDRMFormats() { return true; } -Aquamarine::CDRMRenderer::~CDRMRenderer() { +Aquamarine::CEGLRenderer::~CEGLRenderer() { eglMakeCurrent(egl.display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglDestroyContext(egl.display, egl.context); @@ -207,8 +207,8 @@ Aquamarine::CDRMRenderer::~CDRMRenderer() { eglReleaseThread(); } -SP CDRMRenderer::attempt(Hyprutils::Memory::CSharedPointer allocator_, SP backend_) { - SP renderer = SP(new CDRMRenderer()); +SP CEGLRenderer::attempt(Hyprutils::Memory::CSharedPointer allocator_, SP backend_) { + SP renderer = SP(new CEGLRenderer()); renderer->drmFD = allocator_->drmFD(); renderer->backend = backend_; gBackend = backend_; @@ -216,14 +216,14 @@ SP CDRMRenderer::attempt(Hyprutils::Memory::CSharedPointerlog(AQ_LOG_ERROR, "CDRMRenderer: fail, no gbm support"); + backend_->log(AQ_LOG_ERROR, "CEGLRenderer: fail, no gbm support"); return nullptr; } // init egl if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) { - backend_->log(AQ_LOG_ERROR, "CDRMRenderer: fail, eglBindAPI failed"); + backend_->log(AQ_LOG_ERROR, "CEGLRenderer: fail, eglBindAPI failed"); return nullptr; } @@ -240,45 +240,45 @@ SP CDRMRenderer::attempt(Hyprutils::Memory::CSharedPointeregl.eglDupNativeFenceFDANDROID, "eglDupNativeFenceFDANDROID"); if (!renderer->egl.eglCreateSyncKHR) { - backend_->log(AQ_LOG_ERROR, "CDRMRenderer: fail, no eglCreateSyncKHR"); + backend_->log(AQ_LOG_ERROR, "CEGLRenderer: fail, no eglCreateSyncKHR"); return nullptr; } if (!renderer->egl.eglDupNativeFenceFDANDROID) { - backend_->log(AQ_LOG_ERROR, "CDRMRenderer: fail, no eglDupNativeFenceFDANDROID"); + backend_->log(AQ_LOG_ERROR, "CEGLRenderer: fail, no eglDupNativeFenceFDANDROID"); return nullptr; } if (!renderer->egl.eglGetPlatformDisplayEXT) { - backend_->log(AQ_LOG_ERROR, "CDRMRenderer: fail, no eglGetPlatformDisplayEXT"); + backend_->log(AQ_LOG_ERROR, "CEGLRenderer: fail, no eglGetPlatformDisplayEXT"); return nullptr; } if (!renderer->egl.eglCreateImageKHR) { - backend_->log(AQ_LOG_ERROR, "CDRMRenderer: fail, no eglCreateImageKHR"); + backend_->log(AQ_LOG_ERROR, "CEGLRenderer: fail, no eglCreateImageKHR"); return nullptr; } if (!renderer->egl.eglQueryDmaBufFormatsEXT) { - backend_->log(AQ_LOG_ERROR, "CDRMRenderer: fail, no eglQueryDmaBufFormatsEXT"); + backend_->log(AQ_LOG_ERROR, "CEGLRenderer: fail, no eglQueryDmaBufFormatsEXT"); return nullptr; } if (!renderer->egl.eglQueryDmaBufModifiersEXT) { - backend_->log(AQ_LOG_ERROR, "CDRMRenderer: fail, no eglQueryDmaBufModifiersEXT"); + backend_->log(AQ_LOG_ERROR, "CEGLRenderer: fail, no eglQueryDmaBufModifiersEXT"); return nullptr; } std::vector attrs = {EGL_NONE}; renderer->egl.display = renderer->egl.eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_KHR, allocator_->gbmDevice, attrs.data()); if (renderer->egl.display == EGL_NO_DISPLAY) { - backend_->log(AQ_LOG_ERROR, "CDRMRenderer: fail, eglGetPlatformDisplayEXT failed"); + backend_->log(AQ_LOG_ERROR, "CEGLRenderer: fail, eglGetPlatformDisplayEXT failed"); return nullptr; } EGLint major, minor; if (eglInitialize(renderer->egl.display, &major, &minor) == EGL_FALSE) { - backend_->log(AQ_LOG_ERROR, "CDRMRenderer: fail, eglInitialize failed"); + backend_->log(AQ_LOG_ERROR, "CEGLRenderer: fail, eglInitialize failed"); return nullptr; } @@ -297,12 +297,12 @@ SP CDRMRenderer::attempt(Hyprutils::Memory::CSharedPointerlog(AQ_LOG_ERROR, "CDRMRenderer: fail, no EXT_image_dma_buf_import_modifiers ext"); + backend_->log(AQ_LOG_ERROR, "CEGLRenderer: fail, no EXT_image_dma_buf_import_modifiers ext"); return nullptr; } if (!EGLEXTENSIONS2.contains("EXT_image_dma_buf_import")) { - backend_->log(AQ_LOG_ERROR, "CDRMRenderer: fail, no EXT_image_dma_buf_import ext"); + backend_->log(AQ_LOG_ERROR, "CEGLRenderer: fail, no EXT_image_dma_buf_import ext"); return nullptr; } @@ -317,7 +317,7 @@ SP CDRMRenderer::attempt(Hyprutils::Memory::CSharedPointeregl.context = eglCreateContext(renderer->egl.display, EGL_NO_CONFIG_KHR, EGL_NO_CONTEXT, attrs.data()); if (renderer->egl.context == EGL_NO_CONTEXT) { - backend_->log(AQ_LOG_ERROR, "CDRMRenderer: fail, eglCreateContext failed"); + backend_->log(AQ_LOG_ERROR, "CEGLRenderer: fail, eglCreateContext failed"); return nullptr; } @@ -325,9 +325,9 @@ SP CDRMRenderer::attempt(Hyprutils::Memory::CSharedPointeregl.display, renderer->egl.context, EGL_CONTEXT_PRIORITY_LEVEL_IMG, &priority); if (priority != EGL_CONTEXT_PRIORITY_HIGH_IMG) - backend_->log(AQ_LOG_DEBUG, "CDRMRenderer: didnt get a high priority context"); + backend_->log(AQ_LOG_DEBUG, "CEGLRenderer: didnt get a high priority context"); else - backend_->log(AQ_LOG_DEBUG, "CDRMRenderer: got a high priority context"); + backend_->log(AQ_LOG_DEBUG, "CEGLRenderer: got a high priority context"); } // init shaders @@ -335,13 +335,13 @@ SP CDRMRenderer::attempt(Hyprutils::Memory::CSharedPointersetEGL(); if (!renderer->initDRMFormats()) { - backend_->log(AQ_LOG_ERROR, "CDRMRenderer: fail, initDRMFormats failed"); + backend_->log(AQ_LOG_ERROR, "CEGLRenderer: fail, initDRMFormats failed"); return nullptr; } renderer->gl.shader.program = createProgram(VERT_SRC, FRAG_SRC); if (renderer->gl.shader.program == 0) { - backend_->log(AQ_LOG_ERROR, "CDRMRenderer: fail, shader failed"); + backend_->log(AQ_LOG_ERROR, "CEGLRenderer: fail, shader failed"); return nullptr; } @@ -352,7 +352,7 @@ SP CDRMRenderer::attempt(Hyprutils::Memory::CSharedPointergl.shaderExt.program = createProgram(VERT_SRC, FRAG_SRC_EXT); if (renderer->gl.shaderExt.program == 0) { - backend_->log(AQ_LOG_ERROR, "CDRMRenderer: fail, shaderExt failed"); + backend_->log(AQ_LOG_ERROR, "CEGLRenderer: fail, shaderExt failed"); return nullptr; } @@ -363,22 +363,22 @@ SP CDRMRenderer::attempt(Hyprutils::Memory::CSharedPointerrestoreEGL(); - backend_->log(AQ_LOG_DEBUG, "CDRMRenderer: success"); + backend_->log(AQ_LOG_DEBUG, "CEGLRenderer: success"); return renderer; } -void CDRMRenderer::setEGL() { +void CEGLRenderer::setEGL() { savedEGLState.display = eglGetCurrentDisplay(); savedEGLState.context = eglGetCurrentContext(); savedEGLState.draw = eglGetCurrentSurface(EGL_DRAW); savedEGLState.read = eglGetCurrentSurface(EGL_READ); if (!eglMakeCurrent(egl.display, EGL_NO_SURFACE, EGL_NO_SURFACE, egl.context)) - backend->log(AQ_LOG_WARNING, "CDRMRenderer: setEGL eglMakeCurrent failed"); + backend->log(AQ_LOG_WARNING, "CEGLRenderer: setEGL eglMakeCurrent failed"); } -void CDRMRenderer::restoreEGL() { +void CEGLRenderer::restoreEGL() { EGLDisplay dpy = savedEGLState.display ? savedEGLState.display : egl.display; // egl can't handle this @@ -386,10 +386,10 @@ void CDRMRenderer::restoreEGL() { return; if (!eglMakeCurrent(dpy, savedEGLState.draw, savedEGLState.read, savedEGLState.context)) - backend->log(AQ_LOG_WARNING, "CDRMRenderer: restoreEGL eglMakeCurrent failed"); + backend->log(AQ_LOG_WARNING, "CEGLRenderer: restoreEGL eglMakeCurrent failed"); } -EGLImageKHR CDRMRenderer::createEGLImage(const SDMABUFAttrs& attrs) { +EGLImageKHR CEGLRenderer::createEGLImage(const SDMABUFAttrs& attrs) { std::vector attribs; attribs.push_back(EGL_WIDTH); @@ -407,11 +407,26 @@ EGLImageKHR CDRMRenderer::createEGLImage(const SDMABUFAttrs& attrs) { EGLint pitch; EGLint modlo; EGLint modhi; - } attrNames[4] = { - {.fd = EGL_DMA_BUF_PLANE0_FD_EXT, .offset = EGL_DMA_BUF_PLANE0_OFFSET_EXT, .pitch = EGL_DMA_BUF_PLANE0_PITCH_EXT, .modlo = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT, .modhi = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT}, - {.fd = EGL_DMA_BUF_PLANE1_FD_EXT, .offset = EGL_DMA_BUF_PLANE1_OFFSET_EXT, .pitch = EGL_DMA_BUF_PLANE1_PITCH_EXT, .modlo = EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT, .modhi = EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT}, - {.fd = EGL_DMA_BUF_PLANE2_FD_EXT, .offset = EGL_DMA_BUF_PLANE2_OFFSET_EXT, .pitch = EGL_DMA_BUF_PLANE2_PITCH_EXT, .modlo = EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT, .modhi = EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT}, - {.fd = EGL_DMA_BUF_PLANE3_FD_EXT, .offset = EGL_DMA_BUF_PLANE3_OFFSET_EXT, .pitch = EGL_DMA_BUF_PLANE3_PITCH_EXT, .modlo = EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT, .modhi = EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT}}; + } attrNames[4] = {{.fd = EGL_DMA_BUF_PLANE0_FD_EXT, + .offset = EGL_DMA_BUF_PLANE0_OFFSET_EXT, + .pitch = EGL_DMA_BUF_PLANE0_PITCH_EXT, + .modlo = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT, + .modhi = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT}, + {.fd = EGL_DMA_BUF_PLANE1_FD_EXT, + .offset = EGL_DMA_BUF_PLANE1_OFFSET_EXT, + .pitch = EGL_DMA_BUF_PLANE1_PITCH_EXT, + .modlo = EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT, + .modhi = EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT}, + {.fd = EGL_DMA_BUF_PLANE2_FD_EXT, + .offset = EGL_DMA_BUF_PLANE2_OFFSET_EXT, + .pitch = EGL_DMA_BUF_PLANE2_PITCH_EXT, + .modlo = EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT, + .modhi = EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT}, + {.fd = EGL_DMA_BUF_PLANE3_FD_EXT, + .offset = EGL_DMA_BUF_PLANE3_OFFSET_EXT, + .pitch = EGL_DMA_BUF_PLANE3_PITCH_EXT, + .modlo = EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT, + .modhi = EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT}}; for (int i = 0; i < attrs.planes; i++) { attribs.push_back(attrNames[i].fd); @@ -453,7 +468,7 @@ EGLImageKHR CDRMRenderer::createEGLImage(const SDMABUFAttrs& attrs) { } \ } -SGLTex CDRMRenderer::glTex(Hyprutils::Memory::CSharedPointer buffa) { +SGLTex CEGLRenderer::glTex(Hyprutils::Memory::CSharedPointer buffa) { SGLTex tex; const auto dma = buffa->dmabuf(); @@ -469,7 +484,7 @@ SGLTex CDRMRenderer::glTex(Hyprutils::Memory::CSharedPointer buffa) { if (fmt.drmFormat != dma.format || fmt.modifier != dma.modifier) continue; - backend->log(AQ_LOG_DEBUG, std::format("CDRMRenderer::glTex: found format+mod, external = {}", fmt.external)); + backend->log(AQ_LOG_DEBUG, std::format("CEGLRenderer::glTex: found format+mod, external = {}", fmt.external)); external = fmt.external; break; } @@ -494,7 +509,7 @@ inline const float fullVerts[] = { 0, 1, // bottom left }; -void CDRMRenderer::waitOnSync(int fd) { +void CEGLRenderer::waitOnSync(int fd) { TRACE(backend->log(AQ_LOG_TRACE, std::format("EGL (waitOnSync): attempting to wait on fd {}", fd))); std::vector attribs; @@ -529,7 +544,7 @@ void CDRMRenderer::waitOnSync(int fd) { TRACE(backend->log(AQ_LOG_TRACE, "EGL (waitOnSync): failed to destroy sync")); } -int CDRMRenderer::recreateBlitSync() { +int CEGLRenderer::recreateBlitSync() { TRACE(backend->log(AQ_LOG_TRACE, "EGL (recreateBlitSync): recreating blit sync")); if (egl.lastBlitSync) { @@ -571,7 +586,7 @@ int CDRMRenderer::recreateBlitSync() { return fd; } -void CDRMRenderer::clearBuffer(IBuffer* buf) { +void CEGLRenderer::clearBuffer(IBuffer* buf) { setEGL(); auto dmabuf = buf->dmabuf(); @@ -617,7 +632,7 @@ void CDRMRenderer::clearBuffer(IBuffer* buf) { restoreEGL(); } -CDRMRenderer::SBlitResult CDRMRenderer::blit(SP from, SP to, int waitFD) { +CEGLRenderer::SBlitResult CEGLRenderer::blit(SP from, SP to, int waitFD) { setEGL(); if (from->dmabuf().size != to->dmabuf().size) { @@ -640,7 +655,7 @@ CDRMRenderer::SBlitResult CDRMRenderer::blit(SP from, SP to, i auto attachment = from->attachments.get(AQ_ATTACHMENT_DRM_RENDERER_DATA); if (attachment) { TRACE(backend->log(AQ_LOG_TRACE, "EGL (blit): From attachment found")); - auto att = (CDRMRendererBufferAttachment*)attachment.get(); + auto att = (CEGLRendererBufferAttachment*)attachment.get(); fromTex = att->tex; } @@ -650,7 +665,7 @@ CDRMRenderer::SBlitResult CDRMRenderer::blit(SP from, SP to, i // should never remove anything, but JIC. We'll leak an EGLImage if this removes anything. from->attachments.removeByType(AQ_ATTACHMENT_DRM_RENDERER_DATA); - from->attachments.add(makeShared(self, from, nullptr, 0, 0, fromTex)); + from->attachments.add(makeShared(self, from, nullptr, 0, 0, fromTex)); } } @@ -674,7 +689,7 @@ CDRMRenderer::SBlitResult CDRMRenderer::blit(SP from, SP to, i auto attachment = to->attachments.get(AQ_ATTACHMENT_DRM_RENDERER_DATA); if (attachment) { TRACE(backend->log(AQ_LOG_TRACE, "EGL (blit): To attachment found")); - auto att = (CDRMRendererBufferAttachment*)attachment.get(); + auto att = (CEGLRendererBufferAttachment*)attachment.get(); rboImage = att->eglImage; fboID = att->fbo; rboID = att->rbo; @@ -705,7 +720,7 @@ CDRMRenderer::SBlitResult CDRMRenderer::blit(SP from, SP to, i // should never remove anything, but JIC. We'll leak an RBO and FBO if this removes anything. to->attachments.removeByType(AQ_ATTACHMENT_DRM_RENDERER_DATA); - to->attachments.add(makeShared(self, to, rboImage, fboID, rboID, SGLTex{})); + to->attachments.add(makeShared(self, to, rboImage, fboID, rboID, SGLTex{})); } } @@ -791,7 +806,7 @@ CDRMRenderer::SBlitResult CDRMRenderer::blit(SP from, SP to, i return {.success = true, .syncFD = explicitFD == -1 ? std::nullopt : std::optional{explicitFD}}; } -void CDRMRenderer::onBufferAttachmentDrop(CDRMRendererBufferAttachment* attachment) { +void CEGLRenderer::onBufferAttachmentDrop(CEGLRendererBufferAttachment* attachment) { setEGL(); TRACE(backend->log(AQ_LOG_TRACE, @@ -811,7 +826,7 @@ void CDRMRenderer::onBufferAttachmentDrop(CDRMRendererBufferAttachment* attachme restoreEGL(); } -bool CDRMRenderer::verifyDestinationDMABUF(const SDMABUFAttrs& attrs) { +bool CEGLRenderer::verifyDestinationDMABUF(const SDMABUFAttrs& attrs) { for (auto const& fmt : formats) { if (fmt.drmFormat != attrs.format) continue; @@ -826,7 +841,7 @@ bool CDRMRenderer::verifyDestinationDMABUF(const SDMABUFAttrs& attrs) { return false; } -CDRMRendererBufferAttachment::CDRMRendererBufferAttachment(Hyprutils::Memory::CWeakPointer renderer_, Hyprutils::Memory::CSharedPointer buffer, +CEGLRendererBufferAttachment::CEGLRendererBufferAttachment(Hyprutils::Memory::CWeakPointer renderer_, Hyprutils::Memory::CSharedPointer buffer, EGLImageKHR image, GLuint fbo_, GLuint rbo_, SGLTex tex_) : eglImage(image), fbo(fbo_), rbo(rbo_), renderer(renderer_), tex(tex_) { bufferDestroy = buffer->events.destroy.registerListener([this](std::any d) { renderer->onBufferAttachmentDrop(this); });