Merge pull request #1016 from lioncash/video

video_core: Get rid of global variable g_toggle_framelimit_enabled
master
bunnei 2018-08-11 14:10:55 +07:00 committed by GitHub
commit d64303d185
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 44 additions and 35 deletions

@ -6,6 +6,7 @@
#include <vector>
#include <boost/optional.hpp>
#include "common/common_funcs.h"
#include "common/math_util.h"
#include "common/swap.h"
#include "core/hle/kernel/event.h"

@ -7,22 +7,18 @@
#include "core/hle/service/hid/hid.h"
#include "core/settings.h"
#include "video_core/renderer_base.h"
#include "video_core/video_core.h"
namespace Settings {
Values values = {};
void Apply() {
GDBStub::SetServerPort(values.gdbstub_port);
GDBStub::ToggleServer(values.use_gdbstub);
VideoCore::g_toggle_framelimit_enabled = values.toggle_framelimit;
auto& system_instance = Core::System::GetInstance();
if (system_instance.IsPoweredOn()) {
system_instance.Renderer().UpdateCurrentFramebufferLayout();
system_instance.Renderer().RefreshBaseSettings();
}
Service::HID::ReloadInputDevices();

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/assert.h"
#include "video_core/engines/fermi_2d.h"
#include "video_core/engines/maxwell_3d.h"
#include "video_core/engines/maxwell_compute.h"
@ -11,6 +12,15 @@
namespace Tegra {
u32 FramebufferConfig::BytesPerPixel(PixelFormat format) {
switch (format) {
case PixelFormat::ABGR8:
return 4;
}
UNREACHABLE();
}
GPU::GPU(VideoCore::RasterizerInterface& rasterizer) {
memory_manager = std::make_unique<MemoryManager>();
maxwell_3d = std::make_unique<Engines::Maxwell3D>(rasterizer, *memory_manager);

@ -6,7 +6,6 @@
#include <memory>
#include <unordered_map>
#include <vector>
#include "common/common_types.h"
#include "core/hle/service/nvflinger/buffer_queue.h"
#include "video_core/memory_manager.h"
@ -72,14 +71,7 @@ struct FramebufferConfig {
/**
* Returns the number of bytes per pixel.
*/
static u32 BytesPerPixel(PixelFormat format) {
switch (format) {
case PixelFormat::ABGR8:
return 4;
}
UNREACHABLE();
}
static u32 BytesPerPixel(PixelFormat format);
VAddr address;
u32 offset;

@ -4,18 +4,23 @@
#include <memory>
#include "core/frontend/emu_window.h"
#include "core/settings.h"
#include "video_core/renderer_base.h"
#include "video_core/renderer_opengl/gl_rasterizer.h"
namespace VideoCore {
RendererBase::RendererBase(EmuWindow& window) : render_window{window} {}
RendererBase::RendererBase(EmuWindow& window) : render_window{window} {
RefreshBaseSettings();
}
RendererBase::~RendererBase() = default;
void RendererBase::UpdateCurrentFramebufferLayout() {
const Layout::FramebufferLayout& layout = render_window.GetFramebufferLayout();
void RendererBase::RefreshBaseSettings() {
RefreshRasterizerSetting();
UpdateCurrentFramebufferLayout();
render_window.UpdateCurrentFramebufferLayout(layout.width, layout.height);
renderer_settings.use_framelimiter = Settings::values.toggle_framelimit;
}
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

@ -4,9 +4,9 @@
#pragma once
#include <atomic>
#include <memory>
#include <boost/optional.hpp>
#include "common/assert.h"
#include "common/common_types.h"
#include "video_core/gpu.h"
#include "video_core/rasterizer_interface.h"
@ -15,11 +15,12 @@ class EmuWindow;
namespace VideoCore {
struct RendererSettings {
std::atomic_bool use_framelimiter{false};
};
class RendererBase : NonCopyable {
public:
/// Used to reference a framebuffer
enum kFramebuffer { kFramebuffer_VirtualXFB = 0, kFramebuffer_EFB, kFramebuffer_Texture };
explicit RendererBase(EmuWindow& window);
virtual ~RendererBase();
@ -32,9 +33,6 @@ public:
/// Shutdown the renderer
virtual void ShutDown() = 0;
/// Updates the framebuffer layout of the contained render window handle.
void UpdateCurrentFramebufferLayout();
// Getter/setter functions:
// ------------------------
@ -54,13 +52,23 @@ public:
return *rasterizer;
}
void RefreshRasterizerSetting();
/// Refreshes the settings common to all renderers
void RefreshBaseSettings();
protected:
/// Refreshes settings specific to the rasterizer.
void RefreshRasterizerSetting();
EmuWindow& render_window; ///< Reference to the render window handle.
std::unique_ptr<RasterizerInterface> rasterizer;
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
RendererSettings renderer_settings;
private:
/// Updates the framebuffer layout of the contained render window handle.
void UpdateCurrentFramebufferLayout();
};
} // namespace VideoCore

@ -9,8 +9,6 @@
namespace VideoCore {
std::atomic<bool> g_toggle_framelimit_enabled;
std::unique_ptr<RendererBase> CreateRenderer(EmuWindow& emu_window) {
return std::make_unique<RendererOpenGL>(emu_window);
}

@ -4,7 +4,6 @@
#pragma once
#include <atomic>
#include <memory>
class EmuWindow;
@ -13,12 +12,6 @@ namespace VideoCore {
class RendererBase;
enum class Renderer { Software, OpenGL };
// 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.
*