fix nvidia crasherino lmao

This commit is contained in:
Vaxry 2024-07-05 21:06:23 +02:00
parent 940fe9fd47
commit 7f354f8ab5
10 changed files with 54 additions and 33 deletions

View file

@ -86,7 +86,7 @@ class CCompositor {
bool m_bReadyToProcess = false; bool m_bReadyToProcess = false;
bool m_bSessionActive = true; bool m_bSessionActive = true;
bool m_bDPMSStateON = true; bool m_bDPMSStateON = true;
bool m_bUnsafeState = false; // unsafe state is when there is no monitors. bool m_bUnsafeState = false; // unsafe state is when there is no monitors.
bool m_bNextIsUnsafe = false; bool m_bNextIsUnsafe = false;
CMonitor* m_pUnsafeOutput = nullptr; // fallback output for the unsafe state CMonitor* m_pUnsafeOutput = nullptr; // fallback output for the unsafe state
bool m_bExitTriggered = false; // For exit dispatcher bool m_bExitTriggered = false; // For exit dispatcher

View file

@ -139,8 +139,7 @@ void CCursorManager::setXCursor(const std::string& name) {
return; return;
} }
m_vCursorBuffers.emplace_back( m_vCursorBuffers.emplace_back(makeShared<CCursorBuffer>(xcursor.defaultCursor->pixels.data(), xcursor.defaultCursor->size, xcursor.defaultCursor->hotspot));
makeShared<CCursorBuffer>(xcursor.defaultCursor->pixels.data(), xcursor.defaultCursor->size, xcursor.defaultCursor->hotspot));
g_pPointerManager->setCursorBuffer(getCursorBuffer(), xcursor.defaultCursor->hotspot / scale, scale); g_pPointerManager->setCursorBuffer(getCursorBuffer(), xcursor.defaultCursor->hotspot / scale, scale);
if (m_vCursorBuffers.size() > 1) if (m_vCursorBuffers.size() > 1)

View file

@ -395,6 +395,9 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
g_pHyprOpenGL->m_RenderData.pMonitor = state->monitor.get(); g_pHyprOpenGL->m_RenderData.pMonitor = state->monitor.get();
const auto RBO = g_pHyprRenderer->getOrCreateRenderbuffer(buf, state->monitor->cursorSwapchain->currentOptions().format); const auto RBO = g_pHyprRenderer->getOrCreateRenderbuffer(buf, state->monitor->cursorSwapchain->currentOptions().format);
if (!RBO)
return nullptr;
RBO->bind(); RBO->bind();
g_pHyprOpenGL->beginSimple(state->monitor.get(), damage, RBO); g_pHyprOpenGL->beginSimple(state->monitor.get(), damage, RBO);
@ -410,7 +413,7 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
glFlush(); glFlush();
g_pHyprOpenGL->m_RenderData.pMonitor = nullptr; g_pHyprOpenGL->m_RenderData.pMonitor = nullptr;
g_pHyprRenderer->onRenderbufferDestroy(RBO); g_pHyprRenderer->onRenderbufferDestroy(RBO.get());
return buf; return buf;
} }

View file

@ -617,7 +617,7 @@ bool CHyprOpenGLImpl::passRequiresIntrospection(CMonitor* pMonitor) {
return false; return false;
} }
void CHyprOpenGLImpl::beginSimple(CMonitor* pMonitor, const CRegion& damage, CRenderbuffer* rb, CFramebuffer* fb) { void CHyprOpenGLImpl::beginSimple(CMonitor* pMonitor, const CRegion& damage, SP<CRenderbuffer> rb, CFramebuffer* fb) {
m_RenderData.pMonitor = pMonitor; m_RenderData.pMonitor = pMonitor;
#ifndef GLES2 #ifndef GLES2
@ -1556,7 +1556,8 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, CRegion* o
// prep damage // prep damage
CRegion damage{*originalDamage}; CRegion damage{*originalDamage};
damage.transform(wlTransformToHyprutils(invertTransform(m_RenderData.pMonitor->transform)), m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y); damage.transform(wlTransformToHyprutils(invertTransform(m_RenderData.pMonitor->transform)), m_RenderData.pMonitor->vecTransformedSize.x,
m_RenderData.pMonitor->vecTransformedSize.y);
damage.expand(*PBLURPASSES > 10 ? pow(2, 15) : std::clamp(*PBLURSIZE, (int64_t)1, (int64_t)40) * pow(2, *PBLURPASSES)); damage.expand(*PBLURPASSES > 10 ? pow(2, 15) : std::clamp(*PBLURSIZE, (int64_t)1, (int64_t)40) * pow(2, *PBLURPASSES));
// helper // helper

View file

@ -130,7 +130,7 @@ class CHyprOpenGLImpl {
CHyprOpenGLImpl(); CHyprOpenGLImpl();
void begin(CMonitor*, const CRegion& damage, CFramebuffer* fb = nullptr, std::optional<CRegion> finalDamage = {}); void begin(CMonitor*, const CRegion& damage, CFramebuffer* fb = nullptr, std::optional<CRegion> finalDamage = {});
void beginSimple(CMonitor*, const CRegion& damage, CRenderbuffer* rb = nullptr, CFramebuffer* fb = nullptr); void beginSimple(CMonitor*, const CRegion& damage, SP<CRenderbuffer> rb = nullptr, CFramebuffer* fb = nullptr);
void end(); void end();
void renderRect(CBox*, const CColor&, int round = 0); void renderRect(CBox*, const CColor&, int round = 0);

View file

@ -22,8 +22,10 @@ CRenderbuffer::CRenderbuffer(SP<Aquamarine::IBuffer> buffer, uint32_t format) :
auto dma = buffer->dmabuf(); auto dma = buffer->dmabuf();
m_iImage = g_pHyprOpenGL->createEGLImage(dma); m_iImage = g_pHyprOpenGL->createEGLImage(dma);
if (m_iImage == EGL_NO_IMAGE_KHR) if (m_iImage == EGL_NO_IMAGE_KHR) {
throw std::runtime_error("createEGLImage failed"); Debug::log(ERR, "rb: createEGLImage failed");
return;
}
glGenRenderbuffers(1, &m_iRBO); glGenRenderbuffers(1, &m_iRBO);
glBindRenderbuffer(GL_RENDERBUFFER, m_iRBO); glBindRenderbuffer(GL_RENDERBUFFER, m_iRBO);
@ -35,12 +37,20 @@ CRenderbuffer::CRenderbuffer(SP<Aquamarine::IBuffer> buffer, uint32_t format) :
m_sFramebuffer.bind(); m_sFramebuffer.bind();
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_iRBO); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_iRBO);
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
throw std::runtime_error("rbo: glCheckFramebufferStatus failed"); Debug::log(ERR, "rbo: glCheckFramebufferStatus failed");
return;
}
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
listeners.destroyBuffer = buffer->events.destroy.registerListener([this](std::any d) { g_pHyprRenderer->onRenderbufferDestroy(this); }); listeners.destroyBuffer = buffer->events.destroy.registerListener([this](std::any d) { g_pHyprRenderer->onRenderbufferDestroy(this); });
m_bGood = true;
}
bool CRenderbuffer::good() {
return m_bGood;
} }
void CRenderbuffer::bind() { void CRenderbuffer::bind() {

View file

@ -10,6 +10,7 @@ class CRenderbuffer {
CRenderbuffer(SP<Aquamarine::IBuffer> buffer, uint32_t format); CRenderbuffer(SP<Aquamarine::IBuffer> buffer, uint32_t format);
~CRenderbuffer(); ~CRenderbuffer();
bool good();
void bind(); void bind();
void bindFB(); void bindFB();
void unbind(); void unbind();
@ -23,6 +24,7 @@ class CRenderbuffer {
GLuint m_iRBO = 0; GLuint m_iRBO = 0;
CFramebuffer m_sFramebuffer; CFramebuffer m_sFramebuffer;
uint32_t m_uDrmFormat = 0; uint32_t m_uDrmFormat = 0;
bool m_bGood = false;
struct { struct {
CHyprSignalListener destroyBuffer; CHyprSignalListener destroyBuffer;

View file

@ -2538,13 +2538,19 @@ void CHyprRenderer::recheckSolitaryForMonitor(CMonitor* pMonitor) {
pMonitor->solitaryClient = PCANDIDATE; pMonitor->solitaryClient = PCANDIDATE;
} }
CRenderbuffer* CHyprRenderer::getOrCreateRenderbuffer(SP<Aquamarine::IBuffer> buffer, uint32_t fmt) { SP<CRenderbuffer> CHyprRenderer::getOrCreateRenderbuffer(SP<Aquamarine::IBuffer> buffer, uint32_t fmt) {
auto it = std::find_if(m_vRenderbuffers.begin(), m_vRenderbuffers.end(), [&](const auto& other) { return other->m_pHLBuffer == buffer; }); auto it = std::find_if(m_vRenderbuffers.begin(), m_vRenderbuffers.end(), [&](const auto& other) { return other->m_pHLBuffer == buffer; });
if (it != m_vRenderbuffers.end()) if (it != m_vRenderbuffers.end())
return it->get(); return *it;
return m_vRenderbuffers.emplace_back(std::make_unique<CRenderbuffer>(buffer, fmt)).get(); auto buf = makeShared<CRenderbuffer>(buffer, fmt);
if (!buf->good())
return nullptr;
m_vRenderbuffers.emplace_back(buf);
return buf;
} }
void CHyprRenderer::makeEGLCurrent() { void CHyprRenderer::makeEGLCurrent() {
@ -2647,7 +2653,7 @@ void CHyprRenderer::onRenderbufferDestroy(CRenderbuffer* rb) {
std::erase_if(m_vRenderbuffers, [&](const auto& rbo) { return rbo.get() == rb; }); std::erase_if(m_vRenderbuffers, [&](const auto& rbo) { return rbo.get() == rb; });
} }
CRenderbuffer* CHyprRenderer::getCurrentRBO() { SP<CRenderbuffer> CHyprRenderer::getCurrentRBO() {
return m_pCurrentRenderbuffer; return m_pCurrentRenderbuffer;
} }

View file

@ -69,7 +69,7 @@ class CHyprRenderer {
void setCursorSurface(SP<CWLSurface> surf, int hotspotX, int hotspotY, bool force = false); void setCursorSurface(SP<CWLSurface> surf, int hotspotX, int hotspotY, bool force = false);
void setCursorFromName(const std::string& name, bool force = false); void setCursorFromName(const std::string& name, bool force = false);
void onRenderbufferDestroy(CRenderbuffer* rb); void onRenderbufferDestroy(CRenderbuffer* rb);
CRenderbuffer* getCurrentRBO(); SP<CRenderbuffer> getCurrentRBO();
bool isNvidia(); bool isNvidia();
void makeEGLCurrent(); void makeEGLCurrent();
void unsetEGL(); void unsetEGL();
@ -107,21 +107,21 @@ class CHyprRenderer {
} m_sLastCursorData; } m_sLastCursorData;
private: private:
void arrangeLayerArray(CMonitor*, const std::vector<PHLLSREF>&, bool, CBox*); void arrangeLayerArray(CMonitor*, const std::vector<PHLLSREF>&, bool, CBox*);
void renderWorkspaceWindowsFullscreen(CMonitor*, PHLWORKSPACE, timespec*); // renders workspace windows (fullscreen) (tiled, floating, pinned, but no special) void renderWorkspaceWindowsFullscreen(CMonitor*, PHLWORKSPACE, timespec*); // renders workspace windows (fullscreen) (tiled, floating, pinned, but no special)
void renderWorkspaceWindows(CMonitor*, PHLWORKSPACE, timespec*); // renders workspace windows (no fullscreen) (tiled, floating, pinned, but no special) void renderWorkspaceWindows(CMonitor*, PHLWORKSPACE, timespec*); // renders workspace windows (no fullscreen) (tiled, floating, pinned, but no special)
void renderWindow(PHLWINDOW, CMonitor*, timespec*, bool, eRenderPassMode, bool ignorePosition = false, bool ignoreAllGeometry = false); void renderWindow(PHLWINDOW, CMonitor*, timespec*, bool, eRenderPassMode, bool ignorePosition = false, bool ignoreAllGeometry = false);
void renderLayer(PHLLS, CMonitor*, timespec*, bool popups = false); void renderLayer(PHLLS, CMonitor*, timespec*, bool popups = false);
void renderSessionLockSurface(SSessionLockSurface*, CMonitor*, timespec*); void renderSessionLockSurface(SSessionLockSurface*, CMonitor*, timespec*);
void renderDragIcon(CMonitor*, timespec*); void renderDragIcon(CMonitor*, timespec*);
void renderIMEPopup(CInputPopup*, CMonitor*, timespec*); void renderIMEPopup(CInputPopup*, CMonitor*, timespec*);
void renderWorkspace(CMonitor* pMonitor, PHLWORKSPACE pWorkspace, timespec* now, const CBox& geometry); void renderWorkspace(CMonitor* pMonitor, PHLWORKSPACE pWorkspace, timespec* now, const CBox& geometry);
void sendFrameEventsToWorkspace(CMonitor* pMonitor, PHLWORKSPACE pWorkspace, timespec* now); // sends frame displayed events but doesn't actually render anything void sendFrameEventsToWorkspace(CMonitor* pMonitor, PHLWORKSPACE pWorkspace, timespec* now); // sends frame displayed events but doesn't actually render anything
void renderAllClientsForWorkspace(CMonitor* pMonitor, PHLWORKSPACE pWorkspace, timespec* now, const Vector2D& translate = {0, 0}, const float& scale = 1.f); void renderAllClientsForWorkspace(CMonitor* pMonitor, PHLWORKSPACE pWorkspace, timespec* now, const Vector2D& translate = {0, 0}, const float& scale = 1.f);
bool m_bCursorHidden = false; bool m_bCursorHidden = false;
bool m_bCursorHasSurface = false; bool m_bCursorHasSurface = false;
CRenderbuffer* m_pCurrentRenderbuffer = nullptr; SP<CRenderbuffer> m_pCurrentRenderbuffer = nullptr;
SP<Aquamarine::IBuffer> m_pCurrentBuffer; SP<Aquamarine::IBuffer> m_pCurrentBuffer;
eRenderMode m_eRenderMode = RENDER_MODE_NORMAL; eRenderMode m_eRenderMode = RENDER_MODE_NORMAL;
@ -133,8 +133,8 @@ class CHyprRenderer {
bool hiddenOnKeyboard = false; bool hiddenOnKeyboard = false;
} m_sCursorHiddenConditions; } m_sCursorHiddenConditions;
CRenderbuffer* getOrCreateRenderbuffer(SP<Aquamarine::IBuffer> buffer, uint32_t fmt); SP<CRenderbuffer> getOrCreateRenderbuffer(SP<Aquamarine::IBuffer> buffer, uint32_t fmt);
std::vector<std::unique_ptr<CRenderbuffer>> m_vRenderbuffers; std::vector<SP<CRenderbuffer>> m_vRenderbuffers;
friend class CHyprOpenGLImpl; friend class CHyprOpenGLImpl;
friend class CToplevelExportProtocolManager; friend class CToplevelExportProtocolManager;

View file

@ -37,7 +37,7 @@ class CTexture {
GLenum m_iTarget = GL_TEXTURE_2D; GLenum m_iTarget = GL_TEXTURE_2D;
GLuint m_iTexID = 0; GLuint m_iTexID = 0;
Vector2D m_vSize; Vector2D m_vSize;
void* m_pEglImage = nullptr; void* m_pEglImage = nullptr;
private: private:
void createFromShm(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, const Vector2D& size); void createFromShm(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, const Vector2D& size);