citra-emu
/
citra
Archived
1
0
Fork 0

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:
Tobias 2019-04-09 21:18:34 +02:00 committed by GitHub
commit e9c2b27c68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 51 additions and 56 deletions

View File

@ -374,7 +374,7 @@ int main(int argc, char** argv) {
break; // Expected case break; // Expected case
} }
Core::Telemetry().AddField(Telemetry::FieldType::App, "Frontend", "SDL"); system.TelemetrySession().AddField(Telemetry::FieldType::App, "Frontend", "SDL");
if (use_multiplayer) { if (use_multiplayer) {
if (auto member = Network::GetRoomMember().lock()) { if (auto member = Network::GetRoomMember().lock()) {

View File

@ -51,8 +51,8 @@ void CompatDB::Submit() {
case CompatDBPage::Final: case CompatDBPage::Final:
back(); back();
LOG_DEBUG(Frontend, "Compatibility Rating: {}", compatibility->checkedId()); LOG_DEBUG(Frontend, "Compatibility Rating: {}", compatibility->checkedId());
Core::Telemetry().AddField(Telemetry::FieldType::UserFeedback, "Compatibility", Core::System::GetInstance().TelemetrySession().AddField(
compatibility->checkedId()); Telemetry::FieldType::UserFeedback, "Compatibility", compatibility->checkedId());
button(NextButton)->setEnabled(false); button(NextButton)->setEnabled(false);
button(NextButton)->setText(tr("Submitting")); button(NextButton)->setText(tr("Submitting"));

View File

@ -799,7 +799,7 @@ bool GMainWindow::LoadROM(const QString& filename) {
game_path = filename; game_path = filename;
Core::Telemetry().AddField(Telemetry::FieldType::App, "Frontend", "Qt"); system.TelemetrySession().AddField(Telemetry::FieldType::App, "Frontend", "Qt");
return true; return true;
} }

View File

@ -39,8 +39,10 @@ public:
Impl(Impl const&) = delete; Impl(Impl const&) = delete;
const Impl& operator=(Impl const&) = delete; const Impl& operator=(Impl const&) = delete;
void PushEntry(Entry e) { void PushEntry(Class log_class, Level log_level, const char* filename, unsigned int line_num,
message_queue.Push(std::move(e)); 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) { void AddBackend(std::unique_ptr<Backend> backend) {
@ -108,11 +110,33 @@ private:
backend_thread.join(); 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::mutex writing_mutex;
std::thread backend_thread; std::thread backend_thread;
std::vector<std::unique_ptr<Backend>> backends; std::vector<std::unique_ptr<Backend>> backends;
Common::MPSCQueue<Log::Entry> message_queue; Common::MPSCQueue<Log::Entry> message_queue;
Filter filter; Filter filter;
std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()};
}; };
void ConsoleBackend::Write(const Entry& entry) { void ConsoleBackend::Write(const Entry& entry) {
@ -249,27 +273,6 @@ const char* GetLevelName(Level log_level) {
#undef LVL #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) { void SetGlobalFilter(const Filter& filter) {
Impl::Instance().SetGlobalFilter(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)) if (!filter.CheckMessage(log_class, log_level))
return; return;
Entry entry = instance.PushEntry(log_class, log_level, filename, line_num, function,
CreateEntry(log_class, log_level, filename, line_num, function, fmt::vformat(format, args)); fmt::vformat(format, args));
instance.PushEntry(std::move(entry));
} }
} // namespace Log } // namespace Log

View File

@ -136,10 +136,6 @@ const char* GetLogClassName(Class log_class);
*/ */
const char* GetLevelName(Level log_level); 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 * 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 * backend can have a filter, but if the level is lower than the global filter, the backend will

View File

@ -286,13 +286,13 @@ void System::RegisterSoftwareKeyboard(std::shared_ptr<Frontend::SoftwareKeyboard
void System::Shutdown() { void System::Shutdown() {
// Log last frame performance stats // Log last frame performance stats
auto perf_results = GetAndResetPerfStats(); const auto perf_results = GetAndResetPerfStats();
Telemetry().AddField(Telemetry::FieldType::Performance, "Shutdown_EmulationSpeed", telemetry_session->AddField(Telemetry::FieldType::Performance, "Shutdown_EmulationSpeed",
perf_results.emulation_speed * 100.0); perf_results.emulation_speed * 100.0);
Telemetry().AddField(Telemetry::FieldType::Performance, "Shutdown_Framerate", telemetry_session->AddField(Telemetry::FieldType::Performance, "Shutdown_Framerate",
perf_results.game_fps); perf_results.game_fps);
Telemetry().AddField(Telemetry::FieldType::Performance, "Shutdown_Frametime", telemetry_session->AddField(Telemetry::FieldType::Performance, "Shutdown_Frametime",
perf_results.frametime * 1000.0); perf_results.frametime * 1000.0);
// Shutdown emulation session // Shutdown emulation session
GDBStub::Shutdown(); GDBStub::Shutdown();

View File

@ -303,8 +303,4 @@ inline AudioCore::DspInterface& DSP() {
return System::GetInstance().DSP(); return System::GetInstance().DSP();
} }
inline TelemetrySession& Telemetry() {
return System::GetInstance().TelemetrySession();
}
} // namespace Core } // namespace Core

View File

@ -172,7 +172,8 @@ ResultStatus AppLoader_NCCH::Load(std::shared_ptr<Kernel::Process>& process) {
overlay_ncch = &update_ncch; 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()) { if (auto room_member = Network::GetRoomMember().lock()) {
Network::GameInfo game_info; Network::GameInfo game_info;
@ -187,7 +188,7 @@ ResultStatus AppLoader_NCCH::Load(std::shared_ptr<Kernel::Process>& process) {
if (ResultStatus::Success != result) if (ResultStatus::Success != result)
return result; return result;
Core::System::GetInstance().ArchiveManager().RegisterSelfNCCH(*this); system.ArchiveManager().RegisterSelfNCCH(*this);
ParseRegionLockoutInfo(); ParseRegionLockoutInfo();

View File

@ -1549,8 +1549,8 @@ vec4 secondary_fragment_color = vec4(0.0);
// Blend the fog // Blend the fog
out += "last_tex_env_out.rgb = mix(fog_color.rgb, last_tex_env_out.rgb, fog_factor);\n"; 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) { } else if (state.fog_mode == TexturingRegs::FogMode::Gas) {
Core::Telemetry().AddField(Telemetry::FieldType::Session, "VideoCore_Pica_UseGasMode", Core::System::GetInstance().TelemetrySession().AddField(Telemetry::FieldType::Session,
true); "VideoCore_Pica_UseGasMode", true);
LOG_CRITICAL(Render_OpenGL, "Unimplemented gas mode"); LOG_CRITICAL(Render_OpenGL, "Unimplemented gas mode");
out += "discard; }"; out += "discard; }";
return out; return out;

View File

@ -83,9 +83,9 @@ inline GLenum WrapMode(Pica::TexturingRegs::TextureConfig::WrapMode mode) {
} }
if (index > 3) { if (index > 3) {
Core::Telemetry().AddField(Telemetry::FieldType::Session, Core::System::GetInstance().TelemetrySession().AddField(
"VideoCore_Pica_UnsupportedTextureWrapMode", Telemetry::FieldType::Session, "VideoCore_Pica_UnsupportedTextureWrapMode",
static_cast<u32>(index)); static_cast<u32>(index));
LOG_WARNING(Render_OpenGL, "Using texture wrap mode {}", index); LOG_WARNING(Render_OpenGL, "Using texture wrap mode {}", index);
} }

View File

@ -552,9 +552,10 @@ Core::System::ResultStatus RendererOpenGL::Init() {
LOG_INFO(Render_OpenGL, "GL_VENDOR: {}", gpu_vendor); LOG_INFO(Render_OpenGL, "GL_VENDOR: {}", gpu_vendor);
LOG_INFO(Render_OpenGL, "GL_RENDERER: {}", gpu_model); LOG_INFO(Render_OpenGL, "GL_RENDERER: {}", gpu_model);
Core::Telemetry().AddField(Telemetry::FieldType::UserSystem, "GPU_Vendor", gpu_vendor); auto& telemetry_session = Core::System::GetInstance().TelemetrySession();
Core::Telemetry().AddField(Telemetry::FieldType::UserSystem, "GPU_Model", gpu_model); telemetry_session.AddField(Telemetry::FieldType::UserSystem, "GPU_Vendor", gpu_vendor);
Core::Telemetry().AddField(Telemetry::FieldType::UserSystem, "GPU_OpenGL_Version", gl_version); 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")) { if (!strcmp(gpu_vendor, "GDI Generic")) {
return Core::System::ResultStatus::ErrorVideoCore_ErrorGenericDrivers; return Core::System::ResultStatus::ErrorVideoCore_ErrorGenericDrivers;