summaryrefslogtreecommitdiff
path: root/src/render
diff options
context:
space:
mode:
Diffstat (limited to 'src/render')
-rw-r--r--src/render/Framebuffer.cpp15
-rw-r--r--src/render/Renderbuffer.cpp13
-rw-r--r--src/render/Renderbuffer.hpp3
3 files changed, 12 insertions, 19 deletions
diff --git a/src/render/Framebuffer.cpp b/src/render/Framebuffer.cpp
index 98947297..fdeb3fb9 100644
--- a/src/render/Framebuffer.cpp
+++ b/src/render/Framebuffer.cpp
@@ -9,13 +9,10 @@ bool CFramebuffer::alloc(int w, int h, uint32_t drmFormat) {
bool firstAlloc = false;
RASSERT((w > 0 && h > 0), "cannot alloc a FB with negative / zero size! (attempted {}x{})", w, h);
- uint32_t glFormat = NFormatUtils::drmFormatToGL(drmFormat);
- uint32_t glType = NFormatUtils::glFormatToType(glFormat);
-
- if (drmFormat != m_drmFormat || m_size != Vector2D{w, h})
- release();
-
- m_drmFormat = drmFormat;
+ const uint32_t glFormat = NFormatUtils::drmFormatToGL(drmFormat);
+ const uint32_t glType = NFormatUtils::glFormatToType(glFormat);
+ const bool sizeChanged = (m_size != Vector2D(w, h));
+ const bool formatChanged = (drmFormat != m_drmFormat);
if (!m_tex) {
m_tex = makeShared<CTexture>();
@@ -34,7 +31,7 @@ bool CFramebuffer::alloc(int w, int h, uint32_t drmFormat) {
firstAlloc = true;
}
- if (firstAlloc || m_size != Vector2D(w, h)) {
+ if (firstAlloc || sizeChanged || formatChanged) {
m_tex->bind();
glTexImage2D(GL_TEXTURE_2D, 0, glFormat, w, h, 0, GL_RGBA, glType, nullptr);
glBindFramebuffer(GL_FRAMEBUFFER, m_fb);
@@ -80,7 +77,7 @@ void CFramebuffer::bind() {
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fb);
if (g_pHyprOpenGL)
- g_pHyprOpenGL->setViewport(0, 0, g_pHyprOpenGL->m_renderData.pMonitor->m_pixelSize.x, g_pHyprOpenGL->m_renderData.pMonitor->m_pixelSize.y);
+ g_pHyprOpenGL->setViewport(0, 0, m_size.x, m_size.y);
else
glViewport(0, 0, m_size.x, m_size.y);
}
diff --git a/src/render/Renderbuffer.cpp b/src/render/Renderbuffer.cpp
index d7a77b74..bb638e20 100644
--- a/src/render/Renderbuffer.cpp
+++ b/src/render/Renderbuffer.cpp
@@ -16,9 +16,12 @@ CRenderbuffer::~CRenderbuffer() {
unbind();
m_framebuffer.release();
- glDeleteRenderbuffers(1, &m_rbo);
- g_pHyprOpenGL->m_proc.eglDestroyImageKHR(g_pHyprOpenGL->m_eglDisplay, m_image);
+ if (m_rbo)
+ glDeleteRenderbuffers(1, &m_rbo);
+
+ if (m_image != EGL_NO_IMAGE_KHR)
+ g_pHyprOpenGL->m_proc.eglDestroyImageKHR(g_pHyprOpenGL->m_eglDisplay, m_image);
}
CRenderbuffer::CRenderbuffer(SP<Aquamarine::IBuffer> buffer, uint32_t format) : m_hlBuffer(buffer), m_drmFormat(format) {
@@ -58,16 +61,10 @@ bool CRenderbuffer::good() {
}
void CRenderbuffer::bind() {
- glBindRenderbuffer(GL_RENDERBUFFER, m_rbo);
- bindFB();
-}
-
-void CRenderbuffer::bindFB() {
m_framebuffer.bind();
}
void CRenderbuffer::unbind() {
- glBindRenderbuffer(GL_RENDERBUFFER, 0);
m_framebuffer.unbind();
}
diff --git a/src/render/Renderbuffer.hpp b/src/render/Renderbuffer.hpp
index c0924141..90c539b1 100644
--- a/src/render/Renderbuffer.hpp
+++ b/src/render/Renderbuffer.hpp
@@ -14,7 +14,6 @@ class CRenderbuffer {
bool good();
void bind();
- void bindFB();
void unbind();
CFramebuffer* getFB();
uint32_t getFormat();
@@ -31,4 +30,4 @@ class CRenderbuffer {
struct {
CHyprSignalListener destroyBuffer;
} m_listeners;
-}; \ No newline at end of file
+};