feat: expand Intel GPU display management

This commit is contained in:
2026-07-30 17:12:08 +01:00
parent 86de3400a9
commit 471903bafb
25 changed files with 1715 additions and 16 deletions
+17 -1
View File
@@ -8,6 +8,7 @@
#include <cstdint>
#include <montauk/syscall.h>
#include <montauk/string.h>
#include <montauk/config.h>
#include "gui/gui.hpp"
namespace gui {
@@ -61,6 +62,20 @@ class Framebuffer {
return 0xFF000000 | (rr << 16) | (gg << 8) | bb;
}
static bool prefer_hardware_page_flip() {
char user[64] = {};
if (montauk::getuser(user, sizeof(user)) > 0 && user[0]) {
auto doc = montauk::config::load_user(user, "display");
bool enabled = doc.get_bool("graphics.tear_free", true);
doc.destroy();
return enabled;
}
auto doc = montauk::config::load("display");
bool enabled = doc.get_bool("graphics.tear_free", true);
doc.destroy();
return enabled;
}
public:
Framebuffer() : hw_fb(nullptr), hw_fb2(nullptr), back_buf(nullptr),
fb_width(0), fb_height(0), fb_pitch(0), hw_next(1) {
@@ -76,7 +91,8 @@ public:
// Hardware page flipping: fb_map() maps the second scanout buffer
// directly after the first when the kernel supports flipping.
if (hw_fb && montauk::fb_flip(-1, 0) == 1) {
if (hw_fb && prefer_hardware_page_flip()
&& montauk::fb_flip(-1, 0) == 1) {
uint64_t pages = ((uint64_t)fb_height * fb_pitch + 0xFFF) / 0x1000;
hw_fb2 = (uint32_t*)((uint8_t*)hw_fb + pages * 0x1000);
}