video_core; Get rid of global g_toggle_framelimit_enabled variable
Instead, we make a struct for renderer settings and allow the renderer to update all of these settings, getting rid of the need for global-scoped variables. This also uncovered a few indirect inclusions for certain headers, which this commit also fixes.
This commit is contained in:
parent
f380496728
commit
20c2928c2b
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
#include "common/common_funcs.h"
|
||||||
#include "common/math_util.h"
|
#include "common/math_util.h"
|
||||||
#include "common/swap.h"
|
#include "common/swap.h"
|
||||||
#include "core/hle/kernel/event.h"
|
#include "core/hle/kernel/event.h"
|
||||||
|
|
|
@ -7,22 +7,18 @@
|
||||||
#include "core/hle/service/hid/hid.h"
|
#include "core/hle/service/hid/hid.h"
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
#include "video_core/renderer_base.h"
|
#include "video_core/renderer_base.h"
|
||||||
#include "video_core/video_core.h"
|
|
||||||
|
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
|
|
||||||
Values values = {};
|
Values values = {};
|
||||||
|
|
||||||
void Apply() {
|
void Apply() {
|
||||||
|
|
||||||
GDBStub::SetServerPort(values.gdbstub_port);
|
GDBStub::SetServerPort(values.gdbstub_port);
|
||||||
GDBStub::ToggleServer(values.use_gdbstub);
|
GDBStub::ToggleServer(values.use_gdbstub);
|
||||||
|
|
||||||
VideoCore::g_toggle_framelimit_enabled = values.toggle_framelimit;
|
|
||||||
|
|
||||||
auto& system_instance = Core::System::GetInstance();
|
auto& system_instance = Core::System::GetInstance();
|
||||||
if (system_instance.IsPoweredOn()) {
|
if (system_instance.IsPoweredOn()) {
|
||||||
system_instance.Renderer().UpdateCurrentFramebufferLayout();
|
system_instance.Renderer().RefreshBaseSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
Service::HID::ReloadInputDevices();
|
Service::HID::ReloadInputDevices();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "common/assert.h"
|
||||||
#include "video_core/engines/fermi_2d.h"
|
#include "video_core/engines/fermi_2d.h"
|
||||||
#include "video_core/engines/maxwell_3d.h"
|
#include "video_core/engines/maxwell_3d.h"
|
||||||
#include "video_core/engines/maxwell_compute.h"
|
#include "video_core/engines/maxwell_compute.h"
|
||||||
|
@ -11,6 +12,15 @@
|
||||||
|
|
||||||
namespace Tegra {
|
namespace Tegra {
|
||||||
|
|
||||||
|
u32 FramebufferConfig::BytesPerPixel(PixelFormat format) {
|
||||||
|
switch (format) {
|
||||||
|
case PixelFormat::ABGR8:
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
|
|
||||||
GPU::GPU(VideoCore::RasterizerInterface& rasterizer) {
|
GPU::GPU(VideoCore::RasterizerInterface& rasterizer) {
|
||||||
memory_manager = std::make_unique<MemoryManager>();
|
memory_manager = std::make_unique<MemoryManager>();
|
||||||
maxwell_3d = std::make_unique<Engines::Maxwell3D>(rasterizer, *memory_manager);
|
maxwell_3d = std::make_unique<Engines::Maxwell3D>(rasterizer, *memory_manager);
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "core/hle/service/nvflinger/buffer_queue.h"
|
#include "core/hle/service/nvflinger/buffer_queue.h"
|
||||||
#include "video_core/memory_manager.h"
|
#include "video_core/memory_manager.h"
|
||||||
|
@ -65,14 +64,7 @@ struct FramebufferConfig {
|
||||||
/**
|
/**
|
||||||
* Returns the number of bytes per pixel.
|
* Returns the number of bytes per pixel.
|
||||||
*/
|
*/
|
||||||
static u32 BytesPerPixel(PixelFormat format) {
|
static u32 BytesPerPixel(PixelFormat format);
|
||||||
switch (format) {
|
|
||||||
case PixelFormat::ABGR8:
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
UNREACHABLE();
|
|
||||||
}
|
|
||||||
|
|
||||||
VAddr address;
|
VAddr address;
|
||||||
u32 offset;
|
u32 offset;
|
||||||
|
|
|
@ -4,18 +4,23 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "core/frontend/emu_window.h"
|
#include "core/frontend/emu_window.h"
|
||||||
|
#include "core/settings.h"
|
||||||
#include "video_core/renderer_base.h"
|
#include "video_core/renderer_base.h"
|
||||||
#include "video_core/renderer_opengl/gl_rasterizer.h"
|
#include "video_core/renderer_opengl/gl_rasterizer.h"
|
||||||
|
|
||||||
namespace VideoCore {
|
namespace VideoCore {
|
||||||
|
|
||||||
RendererBase::RendererBase(EmuWindow& window) : render_window{window} {}
|
RendererBase::RendererBase(EmuWindow& window) : render_window{window} {
|
||||||
|
RefreshBaseSettings();
|
||||||
|
}
|
||||||
|
|
||||||
RendererBase::~RendererBase() = default;
|
RendererBase::~RendererBase() = default;
|
||||||
|
|
||||||
void RendererBase::UpdateCurrentFramebufferLayout() {
|
void RendererBase::RefreshBaseSettings() {
|
||||||
const Layout::FramebufferLayout& layout = render_window.GetFramebufferLayout();
|
RefreshRasterizerSetting();
|
||||||
|
UpdateCurrentFramebufferLayout();
|
||||||
|
|
||||||
render_window.UpdateCurrentFramebufferLayout(layout.width, layout.height);
|
renderer_settings.use_framelimiter = Settings::values.toggle_framelimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererBase::RefreshRasterizerSetting() {
|
void RendererBase::RefreshRasterizerSetting() {
|
||||||
|
@ -24,4 +29,10 @@ void RendererBase::RefreshRasterizerSetting() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RendererBase::UpdateCurrentFramebufferLayout() {
|
||||||
|
const Layout::FramebufferLayout& layout = render_window.GetFramebufferLayout();
|
||||||
|
|
||||||
|
render_window.UpdateCurrentFramebufferLayout(layout.width, layout.height);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace VideoCore
|
} // namespace VideoCore
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include "common/assert.h"
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "video_core/gpu.h"
|
#include "video_core/gpu.h"
|
||||||
#include "video_core/rasterizer_interface.h"
|
#include "video_core/rasterizer_interface.h"
|
||||||
|
@ -15,6 +15,10 @@ class EmuWindow;
|
||||||
|
|
||||||
namespace VideoCore {
|
namespace VideoCore {
|
||||||
|
|
||||||
|
struct RendererSettings {
|
||||||
|
std::atomic_bool use_framelimiter{false};
|
||||||
|
};
|
||||||
|
|
||||||
class RendererBase : NonCopyable {
|
class RendererBase : NonCopyable {
|
||||||
public:
|
public:
|
||||||
explicit RendererBase(EmuWindow& window);
|
explicit RendererBase(EmuWindow& window);
|
||||||
|
@ -29,9 +33,6 @@ public:
|
||||||
/// Shutdown the renderer
|
/// Shutdown the renderer
|
||||||
virtual void ShutDown() = 0;
|
virtual void ShutDown() = 0;
|
||||||
|
|
||||||
/// Updates the framebuffer layout of the contained render window handle.
|
|
||||||
void UpdateCurrentFramebufferLayout();
|
|
||||||
|
|
||||||
// Getter/setter functions:
|
// Getter/setter functions:
|
||||||
// ------------------------
|
// ------------------------
|
||||||
|
|
||||||
|
@ -51,13 +52,23 @@ public:
|
||||||
return *rasterizer;
|
return *rasterizer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefreshRasterizerSetting();
|
/// Refreshes the settings common to all renderers
|
||||||
|
void RefreshBaseSettings();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
/// Refreshes settings specific to the rasterizer.
|
||||||
|
void RefreshRasterizerSetting();
|
||||||
|
|
||||||
EmuWindow& render_window; ///< Reference to the render window handle.
|
EmuWindow& render_window; ///< Reference to the render window handle.
|
||||||
std::unique_ptr<RasterizerInterface> rasterizer;
|
std::unique_ptr<RasterizerInterface> rasterizer;
|
||||||
f32 m_current_fps = 0.0f; ///< Current framerate, should be set by the renderer
|
f32 m_current_fps = 0.0f; ///< Current framerate, should be set by the renderer
|
||||||
int m_current_frame = 0; ///< Current frame, should be set by the renderer
|
int m_current_frame = 0; ///< Current frame, should be set by the renderer
|
||||||
|
|
||||||
|
RendererSettings renderer_settings;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// Updates the framebuffer layout of the contained render window handle.
|
||||||
|
void UpdateCurrentFramebufferLayout();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VideoCore
|
} // namespace VideoCore
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
|
|
||||||
namespace VideoCore {
|
namespace VideoCore {
|
||||||
|
|
||||||
std::atomic<bool> g_toggle_framelimit_enabled;
|
|
||||||
|
|
||||||
std::unique_ptr<RendererBase> CreateRenderer(EmuWindow& emu_window) {
|
std::unique_ptr<RendererBase> CreateRenderer(EmuWindow& emu_window) {
|
||||||
return std::make_unique<RendererOpenGL>(emu_window);
|
return std::make_unique<RendererOpenGL>(emu_window);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <atomic>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class EmuWindow;
|
class EmuWindow;
|
||||||
|
@ -13,10 +12,6 @@ namespace VideoCore {
|
||||||
|
|
||||||
class RendererBase;
|
class RendererBase;
|
||||||
|
|
||||||
// TODO: Wrap these in a user settings struct along with any other graphics settings (often set from
|
|
||||||
// qt ui)
|
|
||||||
extern std::atomic<bool> g_toggle_framelimit_enabled;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a renderer instance.
|
* Creates a renderer instance.
|
||||||
*
|
*
|
||||||
|
|
Reference in New Issue