mirror of
https://github.com/PabloMK7/citra.git
synced 2024-11-25 08:54:05 +00:00
Merge pull request #4681 from FearlessTobi/port-2188-2190
Port yuzu-emu/yuzu#2188 and yuzu-emu/yuzu#2190: various minor code refactoring changes
This commit is contained in:
commit
e9c2b27c68
11 changed files with 51 additions and 56 deletions
|
@ -374,7 +374,7 @@ int main(int argc, char** argv) {
|
|||
break; // Expected case
|
||||
}
|
||||
|
||||
Core::Telemetry().AddField(Telemetry::FieldType::App, "Frontend", "SDL");
|
||||
system.TelemetrySession().AddField(Telemetry::FieldType::App, "Frontend", "SDL");
|
||||
|
||||
if (use_multiplayer) {
|
||||
if (auto member = Network::GetRoomMember().lock()) {
|
||||
|
|
|
@ -51,8 +51,8 @@ void CompatDB::Submit() {
|
|||
case CompatDBPage::Final:
|
||||
back();
|
||||
LOG_DEBUG(Frontend, "Compatibility Rating: {}", compatibility->checkedId());
|
||||
Core::Telemetry().AddField(Telemetry::FieldType::UserFeedback, "Compatibility",
|
||||
compatibility->checkedId());
|
||||
Core::System::GetInstance().TelemetrySession().AddField(
|
||||
Telemetry::FieldType::UserFeedback, "Compatibility", compatibility->checkedId());
|
||||
|
||||
button(NextButton)->setEnabled(false);
|
||||
button(NextButton)->setText(tr("Submitting"));
|
||||
|
|
|
@ -799,7 +799,7 @@ bool GMainWindow::LoadROM(const QString& filename) {
|
|||
|
||||
game_path = filename;
|
||||
|
||||
Core::Telemetry().AddField(Telemetry::FieldType::App, "Frontend", "Qt");
|
||||
system.TelemetrySession().AddField(Telemetry::FieldType::App, "Frontend", "Qt");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,8 +39,10 @@ public:
|
|||
Impl(Impl const&) = delete;
|
||||
const Impl& operator=(Impl const&) = delete;
|
||||
|
||||
void PushEntry(Entry e) {
|
||||
message_queue.Push(std::move(e));
|
||||
void PushEntry(Class log_class, Level log_level, const char* filename, unsigned int line_num,
|
||||
const char* function, std::string message) {
|
||||
message_queue.Push(
|
||||
CreateEntry(log_class, log_level, filename, line_num, function, std::move(message)));
|
||||
}
|
||||
|
||||
void AddBackend(std::unique_ptr<Backend> backend) {
|
||||
|
@ -108,11 +110,33 @@ private:
|
|||
backend_thread.join();
|
||||
}
|
||||
|
||||
Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr,
|
||||
const char* function, std::string message) const {
|
||||
using std::chrono::duration_cast;
|
||||
using std::chrono::steady_clock;
|
||||
|
||||
// matches from the beginning up to the last '../' or 'src/'
|
||||
static const std::regex trim_source_path(R"(.*([\/\\]|^)((\.\.)|(src))[\/\\])");
|
||||
|
||||
Entry entry;
|
||||
entry.timestamp =
|
||||
duration_cast<std::chrono::microseconds>(steady_clock::now() - time_origin);
|
||||
entry.log_class = log_class;
|
||||
entry.log_level = log_level;
|
||||
entry.filename = std::regex_replace(filename, trim_source_path, "");
|
||||
entry.line_num = line_nr;
|
||||
entry.function = function;
|
||||
entry.message = std::move(message);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
std::mutex writing_mutex;
|
||||
std::thread backend_thread;
|
||||
std::vector<std::unique_ptr<Backend>> backends;
|
||||
Common::MPSCQueue<Log::Entry> message_queue;
|
||||
Filter filter;
|
||||
std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()};
|
||||
};
|
||||
|
||||
void ConsoleBackend::Write(const Entry& entry) {
|
||||
|
@ -249,27 +273,6 @@ const char* GetLevelName(Level log_level) {
|
|||
#undef LVL
|
||||
}
|
||||
|
||||
Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr,
|
||||
const char* function, std::string message) {
|
||||
using std::chrono::duration_cast;
|
||||
using std::chrono::steady_clock;
|
||||
|
||||
// matches from the beginning up to the last '../' or 'src/'
|
||||
static const std::regex trim_source_path(R"(.*([\/\\]|^)((\.\.)|(src))[\/\\])");
|
||||
static steady_clock::time_point time_origin = steady_clock::now();
|
||||
|
||||
Entry entry;
|
||||
entry.timestamp = duration_cast<std::chrono::microseconds>(steady_clock::now() - time_origin);
|
||||
entry.log_class = log_class;
|
||||
entry.log_level = log_level;
|
||||
entry.filename = std::regex_replace(filename, trim_source_path, "");
|
||||
entry.line_num = line_nr;
|
||||
entry.function = function;
|
||||
entry.message = std::move(message);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
void SetGlobalFilter(const Filter& filter) {
|
||||
Impl::Instance().SetGlobalFilter(filter);
|
||||
}
|
||||
|
@ -294,9 +297,7 @@ void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename,
|
|||
if (!filter.CheckMessage(log_class, log_level))
|
||||
return;
|
||||
|
||||
Entry entry =
|
||||
CreateEntry(log_class, log_level, filename, line_num, function, fmt::vformat(format, args));
|
||||
|
||||
instance.PushEntry(std::move(entry));
|
||||
instance.PushEntry(log_class, log_level, filename, line_num, function,
|
||||
fmt::vformat(format, args));
|
||||
}
|
||||
} // namespace Log
|
||||
|
|
|
@ -136,10 +136,6 @@ const char* GetLogClassName(Class log_class);
|
|||
*/
|
||||
const char* GetLevelName(Level log_level);
|
||||
|
||||
/// Creates a log entry by formatting the given source location, and message.
|
||||
Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr,
|
||||
const char* function, std::string message);
|
||||
|
||||
/**
|
||||
* The global filter will prevent any messages from even being processed if they are filtered. Each
|
||||
* backend can have a filter, but if the level is lower than the global filter, the backend will
|
||||
|
|
|
@ -286,13 +286,13 @@ void System::RegisterSoftwareKeyboard(std::shared_ptr<Frontend::SoftwareKeyboard
|
|||
|
||||
void System::Shutdown() {
|
||||
// Log last frame performance stats
|
||||
auto perf_results = GetAndResetPerfStats();
|
||||
Telemetry().AddField(Telemetry::FieldType::Performance, "Shutdown_EmulationSpeed",
|
||||
perf_results.emulation_speed * 100.0);
|
||||
Telemetry().AddField(Telemetry::FieldType::Performance, "Shutdown_Framerate",
|
||||
perf_results.game_fps);
|
||||
Telemetry().AddField(Telemetry::FieldType::Performance, "Shutdown_Frametime",
|
||||
perf_results.frametime * 1000.0);
|
||||
const auto perf_results = GetAndResetPerfStats();
|
||||
telemetry_session->AddField(Telemetry::FieldType::Performance, "Shutdown_EmulationSpeed",
|
||||
perf_results.emulation_speed * 100.0);
|
||||
telemetry_session->AddField(Telemetry::FieldType::Performance, "Shutdown_Framerate",
|
||||
perf_results.game_fps);
|
||||
telemetry_session->AddField(Telemetry::FieldType::Performance, "Shutdown_Frametime",
|
||||
perf_results.frametime * 1000.0);
|
||||
|
||||
// Shutdown emulation session
|
||||
GDBStub::Shutdown();
|
||||
|
|
|
@ -303,8 +303,4 @@ inline AudioCore::DspInterface& DSP() {
|
|||
return System::GetInstance().DSP();
|
||||
}
|
||||
|
||||
inline TelemetrySession& Telemetry() {
|
||||
return System::GetInstance().TelemetrySession();
|
||||
}
|
||||
|
||||
} // namespace Core
|
||||
|
|
|
@ -172,7 +172,8 @@ ResultStatus AppLoader_NCCH::Load(std::shared_ptr<Kernel::Process>& process) {
|
|||
overlay_ncch = &update_ncch;
|
||||
}
|
||||
|
||||
Core::Telemetry().AddField(Telemetry::FieldType::Session, "ProgramId", program_id);
|
||||
auto& system = Core::System::GetInstance();
|
||||
system.TelemetrySession().AddField(Telemetry::FieldType::Session, "ProgramId", program_id);
|
||||
|
||||
if (auto room_member = Network::GetRoomMember().lock()) {
|
||||
Network::GameInfo game_info;
|
||||
|
@ -187,7 +188,7 @@ ResultStatus AppLoader_NCCH::Load(std::shared_ptr<Kernel::Process>& process) {
|
|||
if (ResultStatus::Success != result)
|
||||
return result;
|
||||
|
||||
Core::System::GetInstance().ArchiveManager().RegisterSelfNCCH(*this);
|
||||
system.ArchiveManager().RegisterSelfNCCH(*this);
|
||||
|
||||
ParseRegionLockoutInfo();
|
||||
|
||||
|
|
|
@ -1549,8 +1549,8 @@ vec4 secondary_fragment_color = vec4(0.0);
|
|||
// Blend the fog
|
||||
out += "last_tex_env_out.rgb = mix(fog_color.rgb, last_tex_env_out.rgb, fog_factor);\n";
|
||||
} else if (state.fog_mode == TexturingRegs::FogMode::Gas) {
|
||||
Core::Telemetry().AddField(Telemetry::FieldType::Session, "VideoCore_Pica_UseGasMode",
|
||||
true);
|
||||
Core::System::GetInstance().TelemetrySession().AddField(Telemetry::FieldType::Session,
|
||||
"VideoCore_Pica_UseGasMode", true);
|
||||
LOG_CRITICAL(Render_OpenGL, "Unimplemented gas mode");
|
||||
out += "discard; }";
|
||||
return out;
|
||||
|
|
|
@ -83,9 +83,9 @@ inline GLenum WrapMode(Pica::TexturingRegs::TextureConfig::WrapMode mode) {
|
|||
}
|
||||
|
||||
if (index > 3) {
|
||||
Core::Telemetry().AddField(Telemetry::FieldType::Session,
|
||||
"VideoCore_Pica_UnsupportedTextureWrapMode",
|
||||
static_cast<u32>(index));
|
||||
Core::System::GetInstance().TelemetrySession().AddField(
|
||||
Telemetry::FieldType::Session, "VideoCore_Pica_UnsupportedTextureWrapMode",
|
||||
static_cast<u32>(index));
|
||||
LOG_WARNING(Render_OpenGL, "Using texture wrap mode {}", index);
|
||||
}
|
||||
|
||||
|
|
|
@ -552,9 +552,10 @@ Core::System::ResultStatus RendererOpenGL::Init() {
|
|||
LOG_INFO(Render_OpenGL, "GL_VENDOR: {}", gpu_vendor);
|
||||
LOG_INFO(Render_OpenGL, "GL_RENDERER: {}", gpu_model);
|
||||
|
||||
Core::Telemetry().AddField(Telemetry::FieldType::UserSystem, "GPU_Vendor", gpu_vendor);
|
||||
Core::Telemetry().AddField(Telemetry::FieldType::UserSystem, "GPU_Model", gpu_model);
|
||||
Core::Telemetry().AddField(Telemetry::FieldType::UserSystem, "GPU_OpenGL_Version", gl_version);
|
||||
auto& telemetry_session = Core::System::GetInstance().TelemetrySession();
|
||||
telemetry_session.AddField(Telemetry::FieldType::UserSystem, "GPU_Vendor", gpu_vendor);
|
||||
telemetry_session.AddField(Telemetry::FieldType::UserSystem, "GPU_Model", gpu_model);
|
||||
telemetry_session.AddField(Telemetry::FieldType::UserSystem, "GPU_OpenGL_Version", gl_version);
|
||||
|
||||
if (!strcmp(gpu_vendor, "GDI Generic")) {
|
||||
return Core::System::ResultStatus::ErrorVideoCore_ErrorGenericDrivers;
|
||||
|
|
Loading…
Reference in a new issue