From d669ea7db20bad576f13f2b0f7aca038d95536e1 Mon Sep 17 00:00:00 2001 From: fazzi <18248986+fxzzi@users.noreply.github.com> Date: Sun, 26 Apr 2026 19:20:18 +0100 Subject: [PATCH] renderer: swizzle on shm screencopy (#14167) in ds format (XBGR8888) the swizzle was pretty much being ignored. It would cause screenshots taken within DS, or apps which use screencopy like hyprpicker, wayfreeze, and still, to come out with the red and blue channels flipped. --- src/render/gl/GLFramebuffer.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/render/gl/GLFramebuffer.cpp b/src/render/gl/GLFramebuffer.cpp index 59c0c4e35..d8b198c3e 100644 --- a/src/render/gl/GLFramebuffer.cpp +++ b/src/render/gl/GLFramebuffer.cpp @@ -127,21 +127,17 @@ bool CGLFramebuffer::readPixels(CHLBufferReference buffer, uint32_t offsetX, uin uint32_t packStride = minStride(PFORMAT, m_size.x); int glFormat = PFORMAT->glFormat; - if (glFormat == GL_RGBA) - glFormat = GL_BGRA_EXT; - - if (glFormat != GL_BGRA_EXT && glFormat != GL_RGB) { - if (PFORMAT->swizzle.has_value()) { - if (PFORMAT->swizzle == SWIZZLE_RGBA) - glFormat = GL_RGBA; - else if (PFORMAT->swizzle == SWIZZLE_BGRA) - glFormat = GL_BGRA_EXT; - else { - LOGM(Log::ERR, "Copied frame via shm might be broken or color flipped"); - glFormat = GL_RGBA; - } + if (PFORMAT->swizzle.has_value()) { + if (PFORMAT->swizzle == SWIZZLE_RGBA) + glFormat = GL_RGBA; + else if (PFORMAT->swizzle == SWIZZLE_BGRA) + glFormat = GL_BGRA_EXT; + else { + LOGM(Log::ERR, "Copied frame via shm might be broken or color flipped"); + glFormat = GL_RGBA; } - } + } else if (glFormat == GL_RGBA) + glFormat = GL_BGRA_EXT; // This could be optimized by using a pixel buffer object to make this async, // but really clients should just use a dma buffer anyways.