mirror of
https://github.com/hyprwm/Hyprland
synced 2025-02-17 03:42:08 +01:00
renderer: cleanup drm format selection
This commit is contained in:
parent
ea5d9584da
commit
ea45bfb63c
1 changed files with 22 additions and 19 deletions
|
@ -1780,31 +1780,34 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
||||||
|
|
||||||
pMonitor->vecPixelSize = pMonitor->vecSize;
|
pMonitor->vecPixelSize = pMonitor->vecSize;
|
||||||
|
|
||||||
if (pMonitorRule->enable10bit) {
|
// clang-format off
|
||||||
// try 10b RGB
|
static const std::array<std::vector<std::pair<std::string, uint32_t>>, 2> formats{
|
||||||
wlr_output_set_render_format(pMonitor->output, DRM_FORMAT_XRGB2101010);
|
std::vector<std::pair<std::string, uint32_t>>{ /* 10-bit */
|
||||||
pMonitor->enabled10bit = true;
|
{"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;
|
||||||
|
|
||||||
|
for (auto& fmt : formats[(int)!pMonitorRule->enable10bit]) {
|
||||||
|
wlr_output_set_render_format(pMonitor->output, fmt.second);
|
||||||
|
|
||||||
if (!wlr_output_test(pMonitor->output)) {
|
if (!wlr_output_test(pMonitor->output)) {
|
||||||
Debug::log(ERR, "Output {} -> 10 bit enabled, but failed format DRM_FORMAT_XRGB2101010. Trying BGR.", pMonitor->output->name);
|
Debug::log(ERR, "output {} failed basic test on format {}", pMonitor->szName, fmt.first);
|
||||||
|
|
||||||
wlr_output_set_render_format(pMonitor->output, DRM_FORMAT_XBGR2101010);
|
|
||||||
|
|
||||||
if (!wlr_output_test(pMonitor->output)) {
|
|
||||||
Debug::log(ERR, "Output {} -> 10 bit enabled, but failed format DRM_FORMAT_XBGR2101010. Falling back to 8 bit.", pMonitor->output->name);
|
|
||||||
|
|
||||||
wlr_output_set_render_format(pMonitor->output, DRM_FORMAT_XRGB8888);
|
|
||||||
} else {
|
|
||||||
Debug::log(LOG, "10bit format DRM_FORMAT_XBGR2101010 succeeded for output {}", pMonitor->output->name);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Debug::log(LOG, "10bit format DRM_FORMAT_XRGB2101010 succeeded for output {}", pMonitor->output->name);
|
Debug::log(LOG, "output {} succeeded basic test on format {}", pMonitor->szName, fmt.first);
|
||||||
|
if (pMonitorRule->enable10bit && fmt.first.contains("101010"))
|
||||||
|
set10bit = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
wlr_output_set_render_format(pMonitor->output, DRM_FORMAT_XRGB8888);
|
|
||||||
pMonitor->enabled10bit = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pMonitor->enabled10bit = set10bit;
|
||||||
|
|
||||||
if (!wlr_output_commit(pMonitor->output)) {
|
if (!wlr_output_commit(pMonitor->output)) {
|
||||||
Debug::log(ERR, "Couldn't commit output named {}", pMonitor->output->name);
|
Debug::log(ERR, "Couldn't commit output named {}", pMonitor->output->name);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue