Hyprland/src/render/Framebuffer.hpp
Tom Englund 918e2bb9be
renderer/gl: add internal gl formats and reduce internal driver format conversions (#12879)
* format: add internal formats for drm formats

cross referenced with weston and added internal formats and types for a
lot of missing ones. also added a isFormatYUV helper.

* framebuffer: ensure we use right internalformat

ensure we use the right internal format to avoid internal driver
blitting, also since we only attach the GL_STENCIL_ATTACHMENT we might
just aswell only use the GL_STENCIL_INDEX8 to not confuse drivers that
we want a depth aswell.

* texture: use external on yuv or non linear mods

using external makes us use the gpu's internal detiler.
and this is makes intel a lot happier then having to format convert it
to a linear format internally.

* shaders: add external support to CM frag

add external support to CM frag, and correct ext.frag typo.

* formats: remove duplicates and fix a typo in cm.frag

remove duplicate formats and a typo in cm.frag

* formats: add swizzle logic to all formats

add swizzle logic from weston for all formats and use it in shm texture
paths.

* format: more format changes

use monitor drm format instead of forcing something different.

* shader: remove external from cm.frag

drivers want this resolved at compiletime cant use both
samplerExternalOES and sampler2d and then runtime branch it.

* screencopy: swizzle textures in screencopy

swizzle textures in screencopy, to get the right colors when copying.

* screencopy: restore old behaviour

try restore old behaviour before the gles3 format changes.
glReadPixels had the wrong format, so i went to far trying to mitigate
it. should be like before now.
2026-01-07 19:53:42 +01:00

36 lines
884 B
C++

#pragma once
#include "../defines.hpp"
#include "../helpers/Format.hpp"
#include "Texture.hpp"
#include <drm_fourcc.h>
class CFramebuffer {
public:
CFramebuffer();
~CFramebuffer();
bool alloc(int w, int h, uint32_t format = DRM_FORMAT_ARGB8888);
void addStencil(SP<CTexture> tex);
void bind();
void unbind();
void release();
void reset();
bool isAllocated();
SP<CTexture> getTexture();
SP<CTexture> getStencilTex();
GLuint getFBID();
void invalidate(const std::vector<GLenum>& attachments);
Vector2D m_size;
DRMFormat m_drmFormat = 0 /* DRM_FORMAT_INVALID */;
private:
SP<CTexture> m_tex;
GLuint m_fb = -1;
bool m_fbAllocated = false;
SP<CTexture> m_stencilTex;
friend class CRenderbuffer;
};