Prepare frontend for multiple graphics APIs (#6347)
* externals: Update dynarmic * settings: Introduce GraphicsAPI enum * For now it's OpenGL only but will be expanded upon later * citra_qt: Introduce backend agnostic context management * Mostly a direct port from yuzu * core: Simplify context acquire * settings: Add option to create debug contexts * renderer_opengl: Abstract initialization to Driver * This commit also updates glad and adds some useful extensions which we will use in part 2 * Rasterizer construction is moved to the specific renderer instead of RendererBase. Software rendering has been disable to achieve this but will be brought back in the next commit. * video_core: Remove Init/Shutdown methods from renderer * The constructor and destructor can do the same job * In addition move opengl function loading to Qt since SDL already does this. Also remove ErrorVideoCore which is never reached * citra_qt: Decouple software renderer from opengl part 1 * citra: Decouple software renderer from opengl part 2 * android: Decouple software renderer from opengl part 3 * swrasterizer: Decouple software renderer from opengl part 4 * This commit simply enforces the renderer naming conventions in the software renderer * video_core: Move RendererBase to VideoCore * video_core: De-globalize screenshot state * video_core: Pass system to the renderers * video_core: Commonize shader uniform data * video_core: Abstract backend agnostic rasterizer operations * bootmanager: Remove references to OpenGL for macOS OpenGL macOS headers definitions clash heavily with each other * citra_qt: Proper title for api settings * video_core: Reduce boost usage * bootmanager: Fix hide mouse option Remove event handlers from RenderWidget for events that are already handled by the parent GRenderWindow. Also enable mouse tracking on the RenderWidget. * android: Remove software from graphics api list * code: Address review comments * citra: Port per-game settings read * Having to update the default value for all backends is a pain so lets centralize it * android: Rename to OpenGLES --------- Co-authored-by: MerryMage <MerryMage@users.noreply.github.com> Co-authored-by: Vitor Kiguchi <vitor-kiguchi@hotmail.com>
This commit is contained in:
@ -6,11 +6,13 @@
|
||||
#include "common/archives.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/settings.h"
|
||||
#include "core/core.h"
|
||||
#include "video_core/pica.h"
|
||||
#include "video_core/pica_state.h"
|
||||
#include "video_core/renderer_base.h"
|
||||
#include "video_core/renderer_opengl/gl_vars.h"
|
||||
#include "video_core/renderer_opengl/renderer_opengl.h"
|
||||
#include "video_core/renderer_software/renderer_software.h"
|
||||
#include "video_core/video_core.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -18,9 +20,8 @@
|
||||
|
||||
namespace VideoCore {
|
||||
|
||||
std::unique_ptr<RendererBase> g_renderer; ///< Renderer plugin
|
||||
std::unique_ptr<RendererBase> g_renderer{}; ///< Renderer plugin
|
||||
|
||||
std::atomic<bool> g_hw_renderer_enabled;
|
||||
std::atomic<bool> g_shader_jit_enabled;
|
||||
std::atomic<bool> g_hw_shader_enabled;
|
||||
std::atomic<bool> g_separable_shader_enabled;
|
||||
@ -30,65 +31,49 @@ std::atomic<bool> g_renderer_bg_color_update_requested;
|
||||
std::atomic<bool> g_renderer_sampler_update_requested;
|
||||
std::atomic<bool> g_renderer_shader_update_requested;
|
||||
std::atomic<bool> g_texture_filter_update_requested;
|
||||
// Screenshot
|
||||
std::atomic<bool> g_renderer_screenshot_requested;
|
||||
void* g_screenshot_bits;
|
||||
std::function<void()> g_screenshot_complete_callback;
|
||||
Layout::FramebufferLayout g_screenshot_framebuffer_layout;
|
||||
|
||||
Memory::MemorySystem* g_memory;
|
||||
|
||||
/// Initialize the video core
|
||||
ResultStatus Init(Frontend::EmuWindow& emu_window, Frontend::EmuWindow* secondary_window,
|
||||
Memory::MemorySystem& memory) {
|
||||
g_memory = &memory;
|
||||
void Init(Frontend::EmuWindow& emu_window, Frontend::EmuWindow* secondary_window,
|
||||
Core::System& system) {
|
||||
g_memory = &system.Memory();
|
||||
Pica::Init();
|
||||
|
||||
const Settings::GraphicsAPI graphics_api = Settings::values.graphics_api.GetValue();
|
||||
OpenGL::GLES = Settings::values.use_gles.GetValue();
|
||||
|
||||
g_renderer = std::make_unique<OpenGL::RendererOpenGL>(emu_window, secondary_window);
|
||||
ResultStatus result = g_renderer->Init();
|
||||
|
||||
if (result != ResultStatus::Success) {
|
||||
LOG_ERROR(Render, "initialization failed !");
|
||||
} else {
|
||||
LOG_DEBUG(Render, "initialized OK");
|
||||
switch (graphics_api) {
|
||||
case Settings::GraphicsAPI::Software:
|
||||
g_renderer = std::make_unique<VideoCore::RendererSoftware>(system, emu_window);
|
||||
break;
|
||||
case Settings::GraphicsAPI::OpenGL:
|
||||
g_renderer = std::make_unique<OpenGL::RendererOpenGL>(system, emu_window, secondary_window);
|
||||
break;
|
||||
default:
|
||||
LOG_CRITICAL(Render, "Unknown graphics API {}, using OpenGL", graphics_api);
|
||||
g_renderer = std::make_unique<OpenGL::RendererOpenGL>(system, emu_window, secondary_window);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Shutdown the video core
|
||||
void Shutdown() {
|
||||
Pica::Shutdown();
|
||||
|
||||
g_renderer->ShutDown();
|
||||
g_renderer.reset();
|
||||
|
||||
LOG_DEBUG(Render, "shutdown OK");
|
||||
}
|
||||
|
||||
void RequestScreenshot(void* data, std::function<void()> callback,
|
||||
const Layout::FramebufferLayout& layout) {
|
||||
if (g_renderer_screenshot_requested) {
|
||||
LOG_ERROR(Render, "A screenshot is already requested or in progress, ignoring the request");
|
||||
return;
|
||||
}
|
||||
g_screenshot_bits = data;
|
||||
g_screenshot_complete_callback = std::move(callback);
|
||||
g_screenshot_framebuffer_layout = layout;
|
||||
g_renderer_screenshot_requested = true;
|
||||
}
|
||||
|
||||
u16 GetResolutionScaleFactor() {
|
||||
if (g_hw_renderer_enabled) {
|
||||
return Settings::values.resolution_factor.GetValue()
|
||||
? Settings::values.resolution_factor.GetValue()
|
||||
: g_renderer->GetRenderWindow().GetFramebufferLayout().GetScalingRatio();
|
||||
} else {
|
||||
const auto graphics_api = Settings::values.graphics_api.GetValue();
|
||||
if (graphics_api == Settings::GraphicsAPI::Software) {
|
||||
// Software renderer always render at native resolution
|
||||
return 1;
|
||||
}
|
||||
|
||||
return Settings::values.resolution_factor.GetValue()
|
||||
? Settings::values.resolution_factor.GetValue()
|
||||
: g_renderer->GetRenderWindow().GetFramebufferLayout().GetScalingRatio();
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
|
Reference in New Issue
Block a user