Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Client/cefweb/CWebApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ CefRefPtr<CefResourceHandler> CWebApp::HandleError(const SString& strError, unsi

void CWebApp::OnBeforeCommandLineProcessing(const CefString& process_type, CefRefPtr<CefCommandLine> command_line)
{
CWebCore* pWebCore = static_cast<CWebCore*>(g_pCore->GetWebCore());

if (!pWebCore->GetGPUEnabled()) // if GPU is disabled...
{
command_line->AppendSwitch("disable-gpu-compositing");
command_line->AppendSwitch("disable-gpu");
}
else if (!pWebCore->GetGPUCompositingEnabled()) // if GPU is enabled, but compositing is disabled...
command_line->AppendSwitch("disable-gpu-compositing");

// command_line->AppendSwitch("disable-d3d11");
command_line->AppendSwitch("enable-begin-frame-scheduling");

Expand Down
16 changes: 15 additions & 1 deletion Client/cefweb/CWebCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@ CWebCore::~CWebCore()
delete m_pXmlConfig;
}

bool CWebCore::Initialise()
bool CWebCore::Initialise(bool gpuEnabled, bool gpuCompositingEnabled)
{
CefMainArgs mainArgs;
void* sandboxInfo = nullptr;

m_bGPUEnabled = gpuEnabled;
m_bGPUCompositingEnabled = gpuCompositingEnabled;

CefRefPtr<CWebApp> app(new CWebApp);

#ifdef CEF_ENABLE_SANDBOX
Expand Down Expand Up @@ -869,3 +873,13 @@ void CWebCore::StaticFetchBlacklistFinished(const SHttpDownloadResult& result)
OutputDebugLine("Updated browser blacklist!");
#endif
}

bool CWebCore::GetGPUEnabled() const noexcept
{
return m_bGPUEnabled;
}

bool CWebCore::GetGPUCompositingEnabled() const noexcept
{
return m_bGPUCompositingEnabled;
}
9 changes: 8 additions & 1 deletion Client/cefweb/CWebCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CWebCore : public CWebCoreInterface
public:
CWebCore();
~CWebCore();
bool Initialise() override;
bool Initialise(bool gpuEnabled, bool gpuCompositingEnabled) override;

CWebViewInterface* CreateWebView(unsigned int uiWidth, unsigned int uiHeight, bool bIsLocal, CWebBrowserItem* pWebBrowserRenderItem, bool bTransparent);
void DestroyWebView(CWebViewInterface* pWebViewInterface);
Expand Down Expand Up @@ -108,6 +108,9 @@ class CWebCore : public CWebCoreInterface
static void StaticFetchWhitelistFinished(const SHttpDownloadResult& result);
static void StaticFetchBlacklistFinished(const SHttpDownloadResult& result);

bool GetGPUEnabled() const noexcept;
bool GetGPUCompositingEnabled() const noexcept;

private:
typedef std::pair<bool, eWebFilterType> WebFilterPair;

Expand All @@ -129,4 +132,8 @@ class CWebCore : public CWebCoreInterface
CXMLFile* m_pXmlConfig;
int m_iWhitelistRevision;
int m_iBlacklistRevision;

// Shouldn't be changed after init
bool m_bGPUEnabled;
bool m_bGPUCompositingEnabled;
};
2 changes: 2 additions & 0 deletions Client/core/CClientVariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ void CClientVariables::LoadDefaults()
DEFAULT("discord_rpc_share_data", false); // Consistent Rich Presence data sharing
DEFAULT("discord_rpc_share_data_firsttime", false); // Display the user data sharing consent dialog box - for the first time
DEFAULT("_beta_qc_rightclick_command", _S("reconnect")); // Command to run when right clicking quick connect (beta - can be removed at any time)
DEFAULT("browser_enable_gpu", true); // Enable GPU in CEF? (allows stuff like WebGL to function)
DEFAULT("browser_enable_gpu_compositing", true); // Enable GPU compositing in CEF? (required GPU enabled)

if (!Exists("locale"))
{
Expand Down
8 changes: 7 additions & 1 deletion Client/core/CCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1155,8 +1155,14 @@ CWebCoreInterface* CCore::GetWebCore()
{
if (m_pWebCore == nullptr)
{
bool gpuEnabled;
bool gpuCompositingEnabled;
auto cvars = g_pCore->GetCVars();
cvars->Get("browser_enable_gpu", gpuEnabled);
cvars->Get("browser_enable_gpu_compositing", gpuCompositingEnabled);

m_pWebCore = CreateModule<CWebCoreInterface>(m_WebCoreModule, "CefWeb", "cefweb", "InitWebCoreInterface", this);
m_pWebCore->Initialise();
m_pWebCore->Initialise(gpuEnabled, gpuCompositingEnabled);
}
return m_pWebCore;
}
Expand Down
41 changes: 40 additions & 1 deletion Client/core/CSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,16 @@ void CSettings::CreateGUI()
m_pCheckBoxRemoteJavascript->GetPosition(vecTemp);
m_pCheckBoxRemoteJavascript->AutoSize(NULL, 20.0f);

m_pCheckBoxBrowserGPUEnabled = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(m_pTabBrowser, _("Enable GPU rendering"), true));
m_pCheckBoxBrowserGPUEnabled->SetPosition(CVector2D(vecTemp.fX + 300.0f, vecTemp.fY - 20.0f));
m_pCheckBoxBrowserGPUEnabled->AutoSize(NULL, 20.0f);
m_pCheckBoxBrowserGPUEnabled->SetClickHandler(GUI_CALLBACK(&CSettings::OnGPUSettingChanged, this));

m_pCheckBoxBrowserGPUCompositingEnabled =
reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(m_pTabBrowser, _("Enable GPU compositing"), true));
m_pCheckBoxBrowserGPUCompositingEnabled->SetPosition(CVector2D(vecTemp.fX + 300.0f, vecTemp.fY));
m_pCheckBoxBrowserGPUCompositingEnabled->AutoSize(NULL, 20.0f);

m_pLabelBrowserCustomBlacklist = reinterpret_cast<CGUILabel*>(pManager->CreateLabel(m_pTabBrowser, _("Custom blacklist")));
m_pLabelBrowserCustomBlacklist->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 30.0f));
m_pLabelBrowserCustomBlacklist->GetPosition(vecTemp);
Expand Down Expand Up @@ -3287,6 +3297,14 @@ void CSettings::LoadData()
m_pCheckBoxRemoteBrowser->SetSelected(bVar);
CVARS_GET("browser_remote_javascript", bVar);
m_pCheckBoxRemoteJavascript->SetSelected(bVar);
CVARS_GET("browser_enable_gpu", bVar);
m_pCheckBoxBrowserGPUEnabled->SetSelected(bVar);

if (!bVar)
m_pCheckBoxBrowserGPUCompositingEnabled->SetEnabled(false);

CVARS_GET("browser_enable_gpu_compositing", bVar);
m_pCheckBoxBrowserGPUCompositingEnabled->SetSelected(bVar);

ReloadBrowserLists();
}
Expand Down Expand Up @@ -3711,6 +3729,20 @@ void CSettings::SaveData()
bBrowserSettingChanged = true;
}

bool bBrowserGPUEnabled = false;
CVARS_GET("browser_enable_gpu", bBrowserGPUEnabled);

bool bBrowserGPUSetting = m_pCheckBoxBrowserGPUEnabled->GetSelected();
bool bBrowserGPUSettingChanged = (bBrowserGPUSetting != bBrowserGPUEnabled);
CVARS_SET("browser_enable_gpu", bBrowserGPUSetting);

bool bBrowserGPUCompositingEnabled = false;
CVARS_GET("browser_enable_gpu_compositing", bBrowserGPUCompositingEnabled);

bool bBrowserGPUCompositingSetting = m_pCheckBoxBrowserGPUCompositingEnabled->GetSelected();
bool bBrowserGPUCompositingSettingChanged = (bBrowserGPUCompositingSetting != bBrowserGPUCompositingEnabled);
CVARS_SET("browser_enable_gpu_compositing", bBrowserGPUCompositingSetting);

// Ensure CVARS ranges ok
CClientVariables::GetSingleton().ValidateValues();

Expand All @@ -3720,7 +3752,8 @@ void CSettings::SaveData()
gameSettings->Save();

// Ask to restart?
if (bIsVideoModeChanged || bIsAntiAliasingChanged || bIsCustomizedSAFilesChanged || processsDPIAwareChanged)
if (bIsVideoModeChanged || bIsAntiAliasingChanged || bIsCustomizedSAFilesChanged || processsDPIAwareChanged || bBrowserGPUSettingChanged ||
bBrowserGPUCompositingSettingChanged)
ShowRestartQuestion();
else if (CModManager::GetSingleton().IsLoaded() && bBrowserSettingChanged)
ShowDisconnectQuestion();
Expand Down Expand Up @@ -4873,3 +4906,9 @@ bool CSettings::IsActive()
{
return m_pWindow->IsActive();
}

bool CSettings::OnGPUSettingChanged(CGUIElement* pElement)
{
m_pCheckBoxBrowserGPUCompositingEnabled->SetEnabled(m_pCheckBoxBrowserGPUEnabled->GetSelected());
return true;
}
3 changes: 3 additions & 0 deletions Client/core/CSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ class CSettings
CGUIButton* m_pButtonBrowserWhitelistAdd;
CGUIGridList* m_pGridBrowserWhitelist;
CGUIButton* m_pButtonBrowserWhitelistRemove;
CGUICheckBox* m_pCheckBoxBrowserGPUEnabled;
CGUICheckBox* m_pCheckBoxBrowserGPUCompositingEnabled;
bool m_bBrowserListsChanged;
bool m_bBrowserListsLoadEnabled;

Expand Down Expand Up @@ -382,6 +384,7 @@ class CSettings
bool OnBrowserWhitelistRemove(CGUIElement* pElement);
bool OnBrowserWhitelistDomainAddFocused(CGUIElement* pElement);
bool OnBrowserWhitelistDomainAddDefocused(CGUIElement* pElement);
bool OnGPUSettingChanged(CGUIElement* pElement);

bool OnMouseDoubleClick(CGUIMouseEventArgs Args);

Expand Down
7 changes: 7 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaBrowserDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void CLuaBrowserDefs::LoadFunctions()
{"resizeBrowser", ResizeBrowser},
{"guiCreateBrowser", GUICreateBrowser},
{"guiGetBrowser", GUIGetBrowser},
{"isBrowserGPUEnabled", ArgumentParser<IsBrowserGPUEnabled>},
};

// Add browser functions
Expand Down Expand Up @@ -97,6 +98,7 @@ void CLuaBrowserDefs::AddClass(lua_State* luaVM)
lua_classvariable(luaVM, "renderingPaused", "setBrowserRenderingPaused", "isBrowserRenderingPaused");
lua_classvariable(luaVM, "volume", "setBrowserVolume", "getBrowserVolume");
lua_classvariable(luaVM, "devTools", "toggleBrowserDevTools", nullptr);
lua_classvariable(luaVM, "gpuEnabled", nullptr, "isBrowserGPUEnabled");

lua_registerclass(luaVM, "Browser", "DxTexture");

Expand Down Expand Up @@ -1054,3 +1056,8 @@ int CLuaBrowserDefs::SetBrowserAjaxHandler(lua_State* luaVM)
lua_pushboolean(luaVM, false);
return 1;
}

bool CLuaBrowserDefs::IsBrowserGPUEnabled() noexcept
{
return g_pCore->GetWebCore()->GetGPUEnabled();
}
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaBrowserDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ class CLuaBrowserDefs : public CLuaDefs
LUA_DECLARE(ResizeBrowser);
LUA_DECLARE(GUICreateBrowser);
LUA_DECLARE(GUIGetBrowser);
static bool IsBrowserGPUEnabled() noexcept;
};
5 changes: 4 additions & 1 deletion Client/sdk/core/CWebCoreInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CWebCoreInterface
{
public:
virtual ~CWebCoreInterface() {}
virtual bool Initialise() = 0;
virtual bool Initialise(bool gpuEnabled, bool gpuCompositingEnabled) = 0;

virtual CWebViewInterface* CreateWebView(unsigned int uiWidth, unsigned int uiHeight, bool bIsLocal, CWebBrowserItem* pWebBrowserRenderItem,
bool bTransparent) = 0;
Expand Down Expand Up @@ -90,4 +90,7 @@ class CWebCoreInterface
virtual void WriteCustomList(const SString& strListName, const std::vector<SString>& customList, bool bReset = true) = 0;
virtual void GetFilterEntriesByType(std::vector<std::pair<SString, bool>>& outEntries, eWebFilterType filterType,
eWebFilterState state = eWebFilterState::WEBFILTER_ALL) = 0;

virtual bool GetGPUEnabled() const noexcept = 0;
virtual bool GetGPUCompositingEnabled() const noexcept = 0;
};
Loading