thanks ikalco

This commit is contained in:
Vaxry 2024-07-13 12:30:16 +02:00
parent 955ee5f1bb
commit af4a13452b
3 changed files with 36 additions and 68 deletions

View file

@ -393,25 +393,9 @@ CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const
mainDevice = *dev;
// FIXME: this will break on multi-gpu
std::vector<Aquamarine::SDRMFormat> aqFormats;
for (auto& impl : g_pCompositor->m_pAqBackend->getImplementations()) {
if (impl->type() != Aquamarine::AQ_BACKEND_DRM)
continue;
aqFormats = impl->getRenderFormats();
if (!aqFormats.empty())
break;
}
if (aqFormats.empty()) {
// fallback: use EGL formats
for (auto& fmt : g_pHyprOpenGL->getDRMFormats()) {
aqFormats.emplace_back(Aquamarine::SDRMFormat{
.drmFormat = fmt.drmFormat,
.modifiers = fmt.modifiers,
});
}
}
std::vector<Aquamarine::SDRMFormat> aqFormats = g_pHyprOpenGL->getDRMFormats();
//
SDMABufTranche tranche = {
.device = *dev,
.formats = aqFormats,

View file

@ -2721,23 +2721,7 @@ void CHyprOpenGLImpl::setRenderModifEnabled(bool enabled) {
}
uint32_t CHyprOpenGLImpl::getPreferredReadFormat(CMonitor* pMonitor) {
GLint glf = -1, glt = -1, as = 0;
/*glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &glf);
glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &glt);
glGetIntegerv(GL_ALPHA_BITS, &as);*/
if (glf == 0 || glt == 0) {
glf = FormatUtils::drmFormatToGL(pMonitor->drmFormat);
glt = FormatUtils::glFormatToType(glf);
}
if (const auto FMT = FormatUtils::getPixelFormatFromGL(glf, glt, as > 0); FMT)
return FMT->drmFormat;
if (m_sExts.EXT_read_format_bgra)
return DRM_FORMAT_XRGB8888;
return DRM_FORMAT_XBGR8888;
return pMonitor->output->state->state().drmFormat;
}
std::vector<SDRMFormat> CHyprOpenGLImpl::getDRMFormats() {

View file

@ -1943,7 +1943,39 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
// Needed in case we are switching from a custom modeline to a standard mode
pMonitor->customDrmMode = {};
pMonitor->currentMode = nullptr;
bool autoScale = false;
// clang-format off
static const std::array<std::vector<std::pair<std::string, uint32_t>>, 2> formats{
std::vector<std::pair<std::string, uint32_t>>{ /* 10-bit */
{"DRM_FORMAT_XRGB2101010", DRM_FORMAT_XRGB2101010}, {"DRM_FORMAT_XBGR2101010", DRM_FORMAT_XBGR2101010}, {"DRM_FORMAT_XRGB8888", DRM_FORMAT_XRGB8888}, {"DRM_FORMAT_XBGR8888", DRM_FORMAT_XBGR8888}, {"DRM_FORMAT_INVALID", DRM_FORMAT_INVALID}
},
std::vector<std::pair<std::string, uint32_t>>{ /* 8-bit */
{"DRM_FORMAT_XRGB8888", DRM_FORMAT_XRGB8888}, {"DRM_FORMAT_XBGR8888", DRM_FORMAT_XBGR8888}, {"DRM_FORMAT_INVALID", DRM_FORMAT_INVALID}
}
};
// clang-format on
bool set10bit = false;
pMonitor->drmFormat = DRM_FORMAT_INVALID;
for (auto& fmt : formats[(int)!RULE->enable10bit]) {
pMonitor->output->state->setFormat(fmt.second);
if (!pMonitor->state.test()) {
Debug::log(ERR, "output {} failed basic test on format {}", pMonitor->szName, fmt.first);
} else {
Debug::log(LOG, "output {} succeeded basic test on format {}", pMonitor->szName, fmt.first);
if (RULE->enable10bit && fmt.first.contains("101010"))
set10bit = true;
pMonitor->drmFormat = fmt.second;
break;
}
}
pMonitor->enabled10bit = set10bit;
bool autoScale = false;
if (RULE->scale > 0.1) {
pMonitor->scale = RULE->scale;
@ -1955,7 +1987,6 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
pMonitor->setScale = pMonitor->scale;
pMonitor->transform = RULE->transform;
pMonitor->output->state->setFormat(DRM_FORMAT_XBGR8888);
const auto WLRREFRESHRATE = pMonitor->output->getBackend()->type() == Aquamarine::eBackendType::AQ_BACKEND_DRM ? RULE->refreshRate * 1000 : 0;
@ -2228,37 +2259,6 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
}
}
// clang-format off
static const std::array<std::vector<std::pair<std::string, uint32_t>>, 2> formats{
std::vector<std::pair<std::string, uint32_t>>{ /* 10-bit */
{"DRM_FORMAT_XRGB2101010", DRM_FORMAT_XRGB2101010}, {"DRM_FORMAT_XBGR2101010", DRM_FORMAT_XBGR2101010}, {"DRM_FORMAT_XRGB8888", DRM_FORMAT_XRGB8888}, {"DRM_FORMAT_XBGR8888", DRM_FORMAT_XBGR8888}, {"DRM_FORMAT_INVALID", DRM_FORMAT_INVALID}
},
std::vector<std::pair<std::string, uint32_t>>{ /* 8-bit */
{"DRM_FORMAT_XRGB8888", DRM_FORMAT_XRGB8888}, {"DRM_FORMAT_XBGR8888", DRM_FORMAT_XBGR8888}, {"DRM_FORMAT_INVALID", DRM_FORMAT_INVALID}
}
};
// clang-format on
bool set10bit = false;
pMonitor->drmFormat = DRM_FORMAT_INVALID;
for (auto& fmt : formats[(int)!RULE->enable10bit]) {
pMonitor->output->state->setFormat(fmt.second);
if (!pMonitor->state.test()) {
Debug::log(ERR, "output {} failed basic test on format {}", pMonitor->szName, fmt.first);
} else {
Debug::log(LOG, "output {} succeeded basic test on format {}", pMonitor->szName, fmt.first);
if (RULE->enable10bit && fmt.first.contains("101010"))
set10bit = true;
pMonitor->drmFormat = fmt.second;
break;
}
}
pMonitor->enabled10bit = set10bit;
pMonitor->output->scheduleFrame();
if (!pMonitor->state.commit())