Enable GPU/WebGL and add persistent cache dirs

Enable hardware-accelerated rendering and persist GPU/cache data. Added a BrowserSettings() helper that enables WebGL and use it when creating Chrome/Content/MenuPopup browsers (src/app/nebula_controller.cpp). Configure CefSettings to use a persistent user data and cache directory (src/app/run.cpp) by calling nebula::ui::GetUserDataDirectory() and GetCacheDirectory(). Add command-line switches to initialize the GPU process and avoid sandbox/blocklist fallbacks (disable GPU sandbox, in-process-gpu, ignore-gpu-blocklist, enable-accelerated-video-decode, use ANGLE D3D11) to prevent GPU crashes and Chromium falling back to software rendering (src/cef/nebula_app.cpp). Implement GetUserDataDirectory() and GetCacheDirectory() (preferring %LOCALAPPDATA% with an executable-directory fallback) and expose them in the header (src/ui/paths.cpp, src/ui/paths.h). These changes ensure GPU shader caching, WebGL support, and smoother video/graphics behavior.
This commit is contained in:
2026-05-14 19:37:49 +12:00
parent 10180b7109
commit a32940a3f3
5 changed files with 82 additions and 3 deletions
+9 -3
View File
@@ -40,6 +40,12 @@ CefWindowInfo ChildWindowInfo(HWND parent, const RECT& rect) {
return info;
}
CefBrowserSettings BrowserSettings() {
CefBrowserSettings settings;
settings.webgl = STATE_ENABLED;
return settings;
}
int ParseTabId(const std::string& value) {
int tab_id = 0;
const auto result = std::from_chars(value.data(), value.data() + value.size(), tab_id);
@@ -388,7 +394,7 @@ void NebulaController::CreateChromeBrowser() {
}
const auto layout = window_->CurrentLayout();
CefBrowserSettings browser_settings;
CefBrowserSettings browser_settings = BrowserSettings();
chrome_client_ = new nebula::cef::NebulaBrowserClient(nebula::cef::BrowserRole::Chrome, this);
CefWindowInfo window_info = ChildWindowInfo(window_->hwnd(), layout.chrome);
CefBrowserHost::CreateBrowser(
@@ -403,7 +409,7 @@ void NebulaController::CreateContentBrowser() {
const auto* tab = tabs_.ActiveTab();
const std::string url = tab && !tab->url.empty() ? tab->url : nebula::ui::GetHomeUrl();
const auto layout = window_->CurrentLayout();
CefBrowserSettings browser_settings;
CefBrowserSettings browser_settings = BrowserSettings();
content_client_ = new nebula::cef::NebulaBrowserClient(nebula::cef::BrowserRole::Content, this);
CefWindowInfo window_info = ChildWindowInfo(window_->hwnd(), layout.content);
CefBrowserHost::CreateBrowser(
@@ -431,7 +437,7 @@ void NebulaController::CreateMenuPopupBrowser() {
}
const auto layout = window_->CurrentLayout();
CefBrowserSettings browser_settings;
CefBrowserSettings browser_settings = BrowserSettings();
menu_popup_client_ = new nebula::cef::NebulaBrowserClient(nebula::cef::BrowserRole::MenuPopup, this);
CefWindowInfo window_info = ChildWindowInfo(window_->hwnd(), MenuPopupRect(window_->hwnd(), layout));
CefBrowserHost::CreateBrowser(
+13
View File
@@ -29,6 +29,19 @@ int RunNebula(HINSTANCE instance, int show_command) {
CefSettings settings;
settings.no_sandbox = true;
// A persistent profile is required for the GPU shader cache and several
// hardware acceleration features. Without these Chromium silently falls
// back to software rendering, which causes choppy video and disables
// WebGL/WebGL2 in the GPU diagnostics page.
const std::wstring user_data_dir = nebula::ui::GetUserDataDirectory().wstring();
const std::wstring cache_dir = nebula::ui::GetCacheDirectory().wstring();
if (!user_data_dir.empty()) {
CefString(&settings.root_cache_path).FromWString(user_data_dir);
}
if (!cache_dir.empty()) {
CefString(&settings.cache_path).FromWString(cache_dir);
}
if (!CefInitialize(main_args, settings, app, nullptr)) {
return CefGetExitCode();
}