mirror of
https://github.com/hyprwm/Hyprland
synced 2026-05-24 19:18:17 +02:00
* 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.
70 lines
2.7 KiB
C++
70 lines
2.7 KiB
C++
#pragma once
|
|
|
|
#include "../defines.hpp"
|
|
#include <aquamarine/buffer/Buffer.hpp>
|
|
#include <hyprutils/math/Misc.hpp>
|
|
|
|
class IHLBuffer;
|
|
HYPRUTILS_FORWARD(Math, CRegion);
|
|
|
|
enum eTextureType : int8_t {
|
|
TEXTURE_INVALID = -1, // Invalid
|
|
TEXTURE_RGBA = 0, // 4 channels
|
|
TEXTURE_RGBX, // discard A
|
|
TEXTURE_EXTERNAL, // EGLImage
|
|
};
|
|
|
|
class CTexture {
|
|
public:
|
|
CTexture();
|
|
|
|
CTexture(CTexture&) = delete;
|
|
CTexture(CTexture&&) = delete;
|
|
CTexture(const CTexture&&) = delete;
|
|
CTexture(const CTexture&) = delete;
|
|
|
|
CTexture(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, const Vector2D& size, bool keepDataCopy = false);
|
|
|
|
CTexture(const SP<Aquamarine::IBuffer> buffer, bool keepDataCopy = false);
|
|
// this ctor takes ownership of the eglImage.
|
|
CTexture(const Aquamarine::SDMABUFAttrs&, void* image);
|
|
~CTexture();
|
|
|
|
void destroyTexture();
|
|
void allocate();
|
|
void update(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, const CRegion& damage);
|
|
const std::vector<uint8_t>& dataCopy();
|
|
void bind();
|
|
void unbind();
|
|
void setTexParameter(GLenum pname, GLint param);
|
|
void swizzle(const std::array<GLint, 4>& colors);
|
|
|
|
eTextureType m_type = TEXTURE_RGBA;
|
|
GLenum m_target = GL_TEXTURE_2D;
|
|
GLuint m_texID = 0;
|
|
Vector2D m_size = {};
|
|
void* m_eglImage = nullptr;
|
|
eTransform m_transform = HYPRUTILS_TRANSFORM_NORMAL;
|
|
bool m_opaque = false;
|
|
uint32_t m_drmFormat = 0; // for shm
|
|
bool m_isSynchronous = false;
|
|
|
|
private:
|
|
enum eTextureParam : uint8_t {
|
|
TEXTURE_PAR_WRAP_S = 0,
|
|
TEXTURE_PAR_WRAP_T,
|
|
TEXTURE_PAR_MAG_FILTER,
|
|
TEXTURE_PAR_MIN_FILTER,
|
|
TEXTURE_PAR_SWIZZLE_R,
|
|
TEXTURE_PAR_SWIZZLE_B,
|
|
TEXTURE_PAR_LAST,
|
|
};
|
|
|
|
void createFromShm(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, const Vector2D& size);
|
|
void createFromDma(const Aquamarine::SDMABUFAttrs&, void* image);
|
|
inline constexpr std::optional<size_t> getCacheStateIndex(GLenum pname);
|
|
|
|
bool m_keepDataCopy = false;
|
|
std::vector<uint8_t> m_dataCopy;
|
|
std::array<std::optional<GLint>, TEXTURE_PAR_LAST> m_cachedStates;
|
|
};
|