Skip to content

Commit

Permalink
opengl: fix nvidia read formats
Browse files Browse the repository at this point in the history
fixes #4023
  • Loading branch information
vaxerski committed Dec 2, 2023
1 parent 758cf90 commit 80b9b21
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/render/OpenGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ CHyprOpenGLImpl::CHyprOpenGLImpl() {
loadGLProc(&m_sProc.glEGLImageTargetRenderbufferStorageOES, "glEGLImageTargetRenderbufferStorageOES");
loadGLProc(&m_sProc.eglDestroyImageKHR, "eglDestroyImageKHR");

m_sExts.EXT_read_format_bgra = m_szExtensions.contains("GL_EXT_read_format_bgra");

#ifdef USE_TRACY_GPU

loadGLProc(&glQueryCounter, "glQueryCounterEXT");
Expand Down Expand Up @@ -2067,12 +2069,10 @@ void CHyprOpenGLImpl::setMonitorTransformEnabled(bool enabled) {

uint32_t CHyprOpenGLImpl::getPreferredReadFormat(CMonitor* pMonitor) {
if (g_pHyprRenderer->isNvidia())
return DRM_FORMAT_XRGB8888;
return DRM_FORMAT_XBGR8888;

if (pMonitor->drmFormat == DRM_FORMAT_XRGB8888)
if (pMonitor->drmFormat == DRM_FORMAT_XRGB8888 || pMonitor->drmFormat == DRM_FORMAT_XBGR8888)
return DRM_FORMAT_XBGR8888;
if (pMonitor->drmFormat == DRM_FORMAT_XBGR8888)
return DRM_FORMAT_XRGB8888;
if (pMonitor->drmFormat == DRM_FORMAT_XRGB2101010 || pMonitor->drmFormat == DRM_FORMAT_XBGR2101010)
return DRM_FORMAT_XBGR2101010;
return DRM_FORMAT_INVALID;
Expand Down
4 changes: 4 additions & 0 deletions src/render/OpenGL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ class CHyprOpenGLImpl {
PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR = nullptr;
} m_sProc;

struct {
bool EXT_read_format_bgra = false;
} m_sExts;

private:
std::list<GLuint> m_lBuffers;
std::list<GLuint> m_lTextures;
Expand Down

0 comments on commit 80b9b21

Please sign in to comment.