1
0
Fork 0
forked from suyu/suyu

gl_device: Use a more robust way to use strict context mode

Instead of checking a environment variable which may not actually
exist or is just wrong, ask QT if it's running on the wayland
platform.
This commit is contained in:
Alexander Orzechowski 2022-12-13 14:39:03 -05:00
parent 2221afaf26
commit 09e3029c11
6 changed files with 17 additions and 8 deletions

View file

@ -131,6 +131,10 @@ public:
return active_config; return active_config;
} }
bool StrictContextRequired() const {
return strict_context_required;
}
/** /**
* Requests the internal configuration to be replaced by the specified argument at some point in * Requests the internal configuration to be replaced by the specified argument at some point in
* the future. * the future.
@ -207,6 +211,8 @@ protected:
WindowSystemInfo window_info; WindowSystemInfo window_info;
bool strict_context_required = false;
private: private:
/** /**
* Handler called when the minimal client area was requested to be changed via SetConfig. * Handler called when the minimal client area was requested to be changed via SetConfig.

View file

@ -112,7 +112,7 @@ bool IsASTCSupported() {
} }
} // Anonymous namespace } // Anonymous namespace
Device::Device() { Device::Device(Core::Frontend::EmuWindow& emu_window) {
if (!GLAD_GL_VERSION_4_6) { if (!GLAD_GL_VERSION_4_6) {
LOG_ERROR(Render_OpenGL, "OpenGL 4.6 is not available"); LOG_ERROR(Render_OpenGL, "OpenGL 4.6 is not available");
throw std::runtime_error{"Insufficient version"}; throw std::runtime_error{"Insufficient version"};
@ -127,10 +127,8 @@ Device::Device() {
#ifdef __unix__ #ifdef __unix__
constexpr bool is_linux = true; constexpr bool is_linux = true;
const bool is_wayland = strcasecmp(getenv("XDG_SESSION_TYPE"), "wayland") == 0;
#else #else
constexpr bool is_linux = false; constexpr bool is_linux = false;
constexpr bool is_wayland = false;
#endif #endif
bool disable_fast_buffer_sub_data = false; bool disable_fast_buffer_sub_data = false;
@ -195,12 +193,12 @@ Device::Device() {
} }
} }
strict_context_required = emu_window.StrictContextRequired();
// Blocks AMD and Intel OpenGL drivers on Windows from using asynchronous shader compilation. // Blocks AMD and Intel OpenGL drivers on Windows from using asynchronous shader compilation.
// Blocks EGL on Wayland from using asynchronous shader compilation. // Blocks EGL on Wayland from using asynchronous shader compilation.
use_asynchronous_shaders = Settings::values.use_asynchronous_shaders.GetValue() && use_asynchronous_shaders = Settings::values.use_asynchronous_shaders.GetValue() &&
!(is_amd || (is_intel && !is_linux)) && !is_wayland; !(is_amd || (is_intel && !is_linux)) && !strict_context_required;
use_driver_cache = is_nvidia; use_driver_cache = is_nvidia;
strict_context_required = is_wayland;
LOG_INFO(Render_OpenGL, "Renderer_VariableAOFFI: {}", has_variable_aoffi); LOG_INFO(Render_OpenGL, "Renderer_VariableAOFFI: {}", has_variable_aoffi);
LOG_INFO(Render_OpenGL, "Renderer_ComponentIndexingBug: {}", has_component_indexing_bug); LOG_INFO(Render_OpenGL, "Renderer_ComponentIndexingBug: {}", has_component_indexing_bug);

View file

@ -5,6 +5,7 @@
#include <cstddef> #include <cstddef>
#include "common/common_types.h" #include "common/common_types.h"
#include "core/frontend/emu_window.h"
#include "shader_recompiler/stage.h" #include "shader_recompiler/stage.h"
namespace Settings { namespace Settings {
@ -15,7 +16,7 @@ namespace OpenGL {
class Device { class Device {
public: public:
explicit Device(); explicit Device(Core::Frontend::EmuWindow& emu_window);
[[nodiscard]] std::string GetVendorName() const; [[nodiscard]] std::string GetVendorName() const;

View file

@ -140,8 +140,8 @@ RendererOpenGL::RendererOpenGL(Core::TelemetrySession& telemetry_session_,
Core::Memory::Memory& cpu_memory_, Tegra::GPU& gpu_, Core::Memory::Memory& cpu_memory_, Tegra::GPU& gpu_,
std::unique_ptr<Core::Frontend::GraphicsContext> context_) std::unique_ptr<Core::Frontend::GraphicsContext> context_)
: RendererBase{emu_window_, std::move(context_)}, telemetry_session{telemetry_session_}, : RendererBase{emu_window_, std::move(context_)}, telemetry_session{telemetry_session_},
emu_window{emu_window_}, cpu_memory{cpu_memory_}, gpu{gpu_}, state_tracker{}, emu_window{emu_window_}, cpu_memory{cpu_memory_}, gpu{gpu_}, device{emu_window_},
program_manager{device}, state_tracker{}, program_manager{device},
rasterizer(emu_window, gpu, cpu_memory, device, screen_info, program_manager, state_tracker) { rasterizer(emu_window, gpu, cpu_memory, device, screen_info, program_manager, state_tracker) {
if (Settings::values.renderer_debug && GLAD_GL_KHR_debug) { if (Settings::values.renderer_debug && GLAD_GL_KHR_debug) {
glEnable(GL_DEBUG_OUTPUT); glEnable(GL_DEBUG_OUTPUT);

View file

@ -314,6 +314,8 @@ GRenderWindow::GRenderWindow(GMainWindow* parent, EmuThread* emu_thread_,
input_subsystem->Initialize(); input_subsystem->Initialize();
this->setMouseTracking(true); this->setMouseTracking(true);
strict_context_required = QGuiApplication::platformName() == QStringLiteral("wayland");
connect(this, &GRenderWindow::FirstFrameDisplayed, parent, &GMainWindow::OnLoadComplete); connect(this, &GRenderWindow::FirstFrameDisplayed, parent, &GMainWindow::OnLoadComplete);
connect(this, &GRenderWindow::ExecuteProgramSignal, parent, &GMainWindow::OnExecuteProgram, connect(this, &GRenderWindow::ExecuteProgramSignal, parent, &GMainWindow::OnExecuteProgram,
Qt::QueuedConnection); Qt::QueuedConnection);

View file

@ -104,6 +104,8 @@ EmuWindow_SDL2_GL::EmuWindow_SDL2_GL(InputCommon::InputSubsystem* input_subsyste
exit(1); exit(1);
} }
strict_context_required = strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0;
SetWindowIcon(); SetWindowIcon();
if (fullscreen) { if (fullscreen) {