mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 02:45:59 +01:00
parent
3fe6162af1
commit
6f733292bf
3 changed files with 51 additions and 2 deletions
|
@ -99,7 +99,6 @@ set(CMAKE_ENABLE_EXPORTS TRUE)
|
|||
message(STATUS "Checking deps...")
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-server wayland-client wayland-cursor wayland-protocols cairo libdrm xkbcommon libinput pango pangocairo pixman-1) # we do not check for wlroots, as we provide it ourselves
|
||||
|
|
|
@ -4,11 +4,51 @@
|
|||
#include "../helpers/Region.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
extern "C" {
|
||||
#include <xf86drm.h>
|
||||
}
|
||||
|
||||
CHyprRenderer::CHyprRenderer() {
|
||||
const auto ENV = getenv("WLR_DRM_NO_ATOMIC");
|
||||
|
||||
if (ENV && std::string(ENV) == "1")
|
||||
m_bTearingEnvSatisfied = true;
|
||||
|
||||
if (g_pCompositor->m_sWLRSession) {
|
||||
wlr_device* dev;
|
||||
wl_list_for_each(dev, &g_pCompositor->m_sWLRSession->devices, link) {
|
||||
const auto DRMV = drmGetVersion(dev->fd);
|
||||
|
||||
std::string name = std::string{DRMV->name, DRMV->name_len};
|
||||
std::transform(name.begin(), name.end(), name.begin(), tolower);
|
||||
|
||||
if (name.contains("nvidia"))
|
||||
m_bNvidia = true;
|
||||
|
||||
Debug::log(LOG, "DRM driver information: {} v{}.{}.{} from {} description {}", name, DRMV->version_major, DRMV->version_minor, DRMV->version_patchlevel,
|
||||
std::string{DRMV->date, DRMV->date_len}, std::string{DRMV->desc, DRMV->desc_len});
|
||||
|
||||
drmFreeVersion(DRMV);
|
||||
}
|
||||
} else {
|
||||
Debug::log(LOG, "m_sWLRSession is null, omitting full DRM node checks");
|
||||
|
||||
const auto DRMV = drmGetVersion(g_pCompositor->m_iDRMFD);
|
||||
|
||||
std::string name = std::string{DRMV->name, DRMV->name_len};
|
||||
std::transform(name.begin(), name.end(), name.begin(), tolower);
|
||||
|
||||
if (name.contains("nvidia"))
|
||||
m_bNvidia = true;
|
||||
|
||||
Debug::log(LOG, "Primary DRM driver information: {} v{}.{}.{} from {} description {}", name, DRMV->version_major, DRMV->version_minor, DRMV->version_patchlevel,
|
||||
std::string{DRMV->date, DRMV->date_len}, std::string{DRMV->desc, DRMV->desc_len});
|
||||
|
||||
drmFreeVersion(DRMV);
|
||||
}
|
||||
|
||||
if (m_bNvidia)
|
||||
Debug::log(WARN, "NVIDIA detected, please remember to follow nvidia instructions on the wiki");
|
||||
}
|
||||
|
||||
void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
|
||||
|
@ -2284,6 +2324,9 @@ void CHyprRenderer::endRender() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (isNvidia())
|
||||
glFinish();
|
||||
else
|
||||
glFlush();
|
||||
|
||||
if (m_eRenderMode == RENDER_MODE_NORMAL)
|
||||
|
@ -2305,3 +2348,7 @@ void CHyprRenderer::onRenderbufferDestroy(CRenderbuffer* rb) {
|
|||
CRenderbuffer* CHyprRenderer::getCurrentRBO() {
|
||||
return m_pCurrentRenderbuffer;
|
||||
}
|
||||
|
||||
bool CHyprRenderer::isNvidia() {
|
||||
return m_bNvidia;
|
||||
}
|
|
@ -69,6 +69,7 @@ class CHyprRenderer {
|
|||
void renderSoftwareCursors(CMonitor* pMonitor, const CRegion& damage, std::optional<Vector2D> overridePos = {});
|
||||
void onRenderbufferDestroy(CRenderbuffer* rb);
|
||||
CRenderbuffer* getCurrentRBO();
|
||||
bool isNvidia();
|
||||
|
||||
bool beginRender(CMonitor* pMonitor, CRegion& damage, eRenderMode mode = RENDER_MODE_NORMAL, wlr_buffer* withBuffer = nullptr);
|
||||
void endRender();
|
||||
|
@ -121,6 +122,8 @@ class CHyprRenderer {
|
|||
eRenderMode m_eRenderMode = RENDER_MODE_NORMAL;
|
||||
int m_iLastBufferAge = 0;
|
||||
|
||||
bool m_bNvidia = false;
|
||||
|
||||
CRenderbuffer* getOrCreateRenderbuffer(wlr_buffer* buffer, uint32_t fmt);
|
||||
std::vector<std::unique_ptr<CRenderbuffer>> m_vRenderbuffers;
|
||||
|
||||
|
|
Loading…
Reference in a new issue