early-access version 1345

main
pineappleEA 2021-01-21 01:01:05 +01:00
parent 82a86fa718
commit d92b7506c2
10 changed files with 76 additions and 21 deletions

View File

@ -1,7 +1,7 @@
yuzu emulator early access yuzu emulator early access
============= =============
This is the source code for early-access 1344. This is the source code for early-access 1345.
## Legal Notice ## Legal Notice

View File

@ -138,6 +138,8 @@ add_library(common STATIC
microprofile.h microprofile.h
microprofileui.h microprofileui.h
misc.cpp misc.cpp
nvidia_flags.cpp
nvidia_flags.h
page_table.cpp page_table.cpp
page_table.h page_table.h
param_package.cpp param_package.cpp

25
src/common/nvidia_flags.cpp Executable file
View File

@ -0,0 +1,25 @@
// Copyright 2021 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <filesystem>
#include <stdlib.h>
#include <fmt/format.h>
#include "common/file_util.h"
namespace Common {
void ConfigureNvidiaEnvironmentFlags() {
#ifdef _WIN32
const std::string shader_path = Common::FS::SanitizePath(
fmt::format("{}\\nvidia", Common::FS::GetUserPath(Common::FS::UserPath::ShaderDir)),
Common::FS::DirectorySeparator::PlatformDefault);
std::filesystem::create_directories(shader_path);
void(_putenv(fmt::format("__GL_SHADER_DISK_CACHE_PATH={}", shader_path).c_str()));
void(_putenv("__GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1"));
#endif
}
} // namespace Common

10
src/common/nvidia_flags.h Executable file
View File

@ -0,0 +1,10 @@
// Copyright 2021 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
namespace Common {
/// Configure platform specific flags for Nvidia's driver
void ConfigureNvidiaEnvironmentFlags();
} // namespace Common

View File

@ -26,20 +26,20 @@ enum class LogSeverity : u8 {
}; };
// To keep flags out of hashing as well as the payload size // To keep flags out of hashing as well as the payload size
struct LogPacketHeaderEntrty { struct LogPacketHeaderEntry {
u64_le pid{}; u64_le pid{};
u64_le tid{}; u64_le tid{};
LogSeverity severity{}; LogSeverity severity{};
u8 verbosity{}; u8 verbosity{};
auto operator<=>(const LogPacketHeaderEntrty&) const = default; auto operator<=>(const LogPacketHeaderEntry&) const = default;
}; };
} // namespace Service::LM } // namespace Service::LM
namespace std { namespace std {
template <> template <>
struct hash<Service::LM::LogPacketHeaderEntrty> { struct hash<Service::LM::LogPacketHeaderEntry> {
std::size_t operator()(const Service::LM::LogPacketHeaderEntrty& k) const { std::size_t operator()(const Service::LM::LogPacketHeaderEntry& k) const noexcept {
std::size_t seed{}; std::size_t seed{};
boost::hash_combine(seed, k.pid); boost::hash_combine(seed, k.pid);
boost::hash_combine(seed, k.tid); boost::hash_combine(seed, k.tid);
@ -95,7 +95,7 @@ private:
std::memcpy(&header, data.data(), sizeof(LogPacketHeader)); std::memcpy(&header, data.data(), sizeof(LogPacketHeader));
offset += sizeof(LogPacketHeader); offset += sizeof(LogPacketHeader);
LogPacketHeaderEntrty entry{ LogPacketHeaderEntry entry{
.pid = header.pid, .pid = header.pid,
.tid = header.tid, .tid = header.tid,
.severity = header.severity, .severity = header.severity,
@ -157,9 +157,12 @@ private:
return result; return result;
} }
std::string ReadString(const std::vector<u8>& data, std::size_t& offset, std::size_t length) { std::optional<std::string> ReadString(const std::vector<u8>& data, std::size_t& offset,
std::size_t length) {
if (length == 0) {
return std::nullopt;
}
std::string output(length, '\0'); std::string output(length, '\0');
output.resize(length);
std::memcpy(output.data(), data.data() + offset, length); std::memcpy(output.data(), data.data() + offset, length);
offset += length; offset += length;
return output; return output;
@ -181,7 +184,7 @@ private:
return output; return output;
} }
void ParseLog(const LogPacketHeaderEntrty entry, const std::vector<u8>& log_data) { void ParseLog(const LogPacketHeaderEntry entry, const std::vector<u8>& log_data) {
// Possible entries // Possible entries
std::optional<std::string> text_log; std::optional<std::string> text_log;
std::optional<u32> line_number; std::optional<u32> line_number;
@ -233,16 +236,16 @@ private:
} }
std::string output_log{}; std::string output_log{};
if (process_name && process_name->empty()) { if (process_name) {
output_log += fmt::format("Process: {}\n", *process_name); output_log += fmt::format("Process: {}\n", *process_name);
} }
if (module_name && !module_name->empty()) { if (module_name) {
output_log += fmt::format("Module: {}\n", *module_name); output_log += fmt::format("Module: {}\n", *module_name);
} }
if (file_name && !file_name->empty()) { if (file_name) {
output_log += fmt::format("File: {}\n", *file_name); output_log += fmt::format("File: {}\n", *file_name);
} }
if (function_name && !function_name->empty()) { if (function_name) {
output_log += fmt::format("Function: {}\n", *function_name); output_log += fmt::format("Function: {}\n", *function_name);
} }
if (line_number && *line_number != 0) { if (line_number && *line_number != 0) {
@ -251,7 +254,7 @@ private:
output_log += fmt::format("ProcessID: {}\n", entry.pid); output_log += fmt::format("ProcessID: {}\n", entry.pid);
output_log += fmt::format("ThreadID: {}\n", entry.tid); output_log += fmt::format("ThreadID: {}\n", entry.tid);
if (text_log && !text_log->empty()) { if (text_log) {
output_log += fmt::format("Log Text: {}\n", *text_log); output_log += fmt::format("Log Text: {}\n", *text_log);
} }
@ -283,7 +286,7 @@ private:
} }
} }
std::string DestinationToString(LogDestination destination) { static std::string DestinationToString(LogDestination destination) {
if (True(destination & LogDestination::All)) { if (True(destination & LogDestination::All)) {
return "TargetManager | Uart | UartSleep"; return "TargetManager | Uart | UartSleep";
} }
@ -328,7 +331,7 @@ private:
}; };
static_assert(sizeof(LogPacketHeader) == 0x18, "LogPacketHeader is an invalid size"); static_assert(sizeof(LogPacketHeader) == 0x18, "LogPacketHeader is an invalid size");
std::unordered_map<LogPacketHeaderEntrty, std::vector<u8>> entries{}; std::unordered_map<LogPacketHeaderEntry, std::vector<u8>> entries{};
LogDestination destination{LogDestination::All}; LogDestination destination{LogDestination::All};
}; };

View File

@ -249,6 +249,7 @@ Device::Device() {
GLAD_GL_NV_transform_feedback && GLAD_GL_NV_transform_feedback2; GLAD_GL_NV_transform_feedback && GLAD_GL_NV_transform_feedback2;
use_asynchronous_shaders = Settings::values.use_asynchronous_shaders.GetValue(); use_asynchronous_shaders = Settings::values.use_asynchronous_shaders.GetValue();
use_driver_cache = is_nvidia;
LOG_INFO(Render_OpenGL, "Renderer_VariableAOFFI: {}", has_variable_aoffi); LOG_INFO(Render_OpenGL, "Renderer_VariableAOFFI: {}", has_variable_aoffi);
LOG_INFO(Render_OpenGL, "Renderer_ComponentIndexingBug: {}", has_component_indexing_bug); LOG_INFO(Render_OpenGL, "Renderer_ComponentIndexingBug: {}", has_component_indexing_bug);

View File

@ -118,6 +118,10 @@ public:
return use_asynchronous_shaders; return use_asynchronous_shaders;
} }
bool UseDriverCache() const {
return use_driver_cache;
}
private: private:
static bool TestVariableAoffi(); static bool TestVariableAoffi();
static bool TestPreciseBug(); static bool TestPreciseBug();
@ -145,6 +149,7 @@ private:
bool has_debugging_tool_attached{}; bool has_debugging_tool_attached{};
bool use_assembly_shaders{}; bool use_assembly_shaders{};
bool use_asynchronous_shaders{}; bool use_asynchronous_shaders{};
bool use_driver_cache{};
}; };
} // namespace OpenGL } // namespace OpenGL

View File

@ -159,6 +159,10 @@ std::unordered_set<GLenum> GetSupportedFormats() {
ProgramSharedPtr BuildShader(const Device& device, ShaderType shader_type, u64 unique_identifier, ProgramSharedPtr BuildShader(const Device& device, ShaderType shader_type, u64 unique_identifier,
const ShaderIR& ir, const Registry& registry, bool hint_retrievable) { const ShaderIR& ir, const Registry& registry, bool hint_retrievable) {
if (device.UseDriverCache()) {
// Ignore hint retrievable if we are using the driver cache
hint_retrievable = false;
}
const std::string shader_id = MakeShaderID(unique_identifier, shader_type); const std::string shader_id = MakeShaderID(unique_identifier, shader_type);
LOG_INFO(Render_OpenGL, "{}", shader_id); LOG_INFO(Render_OpenGL, "{}", shader_id);
@ -336,7 +340,7 @@ void ShaderCacheOpenGL::LoadDiskCache(u64 title_id, const std::atomic_bool& stop
} }
std::vector<ShaderDiskCachePrecompiled> gl_cache; std::vector<ShaderDiskCachePrecompiled> gl_cache;
if (!device.UseAssemblyShaders()) { if (!device.UseAssemblyShaders() && !device.UseDriverCache()) {
// Only load precompiled cache when we are not using assembly shaders // Only load precompiled cache when we are not using assembly shaders
gl_cache = disk_cache.LoadPrecompiled(); gl_cache = disk_cache.LoadPrecompiled();
} }
@ -356,8 +360,7 @@ void ShaderCacheOpenGL::LoadDiskCache(u64 title_id, const std::atomic_bool& stop
std::atomic_bool gl_cache_failed = false; std::atomic_bool gl_cache_failed = false;
const auto find_precompiled = [&gl_cache](u64 id) { const auto find_precompiled = [&gl_cache](u64 id) {
return std::find_if(gl_cache.begin(), gl_cache.end(), return std::ranges::find(gl_cache, id, &ShaderDiskCachePrecompiled::unique_identifier);
[id](const auto& entry) { return entry.unique_identifier == id; });
}; };
const auto worker = [&](Core::Frontend::GraphicsContext* context, std::size_t begin, const auto worker = [&](Core::Frontend::GraphicsContext* context, std::size_t begin,
@ -432,8 +435,8 @@ void ShaderCacheOpenGL::LoadDiskCache(u64 title_id, const std::atomic_bool& stop
return; return;
} }
if (device.UseAssemblyShaders()) { if (device.UseAssemblyShaders() || device.UseDriverCache()) {
// Don't store precompiled binaries for assembly shaders. // Don't store precompiled binaries for assembly shaders or when using the driver cache
return; return;
} }

View File

@ -16,6 +16,7 @@
#include "applets/profile_select.h" #include "applets/profile_select.h"
#include "applets/software_keyboard.h" #include "applets/software_keyboard.h"
#include "applets/web_browser.h" #include "applets/web_browser.h"
#include "common/nvidia_flags.h"
#include "configuration/configure_input.h" #include "configuration/configure_input.h"
#include "configuration/configure_per_game.h" #include "configuration/configure_per_game.h"
#include "configuration/configure_vibration.h" #include "configuration/configure_vibration.h"
@ -3023,6 +3024,8 @@ int main(int argc, char* argv[]) {
MicroProfileOnThreadCreate("Frontend"); MicroProfileOnThreadCreate("Frontend");
SCOPE_EXIT({ MicroProfileShutdown(); }); SCOPE_EXIT({ MicroProfileShutdown(); });
Common::ConfigureNvidiaEnvironmentFlags();
// Init settings params // Init settings params
QCoreApplication::setOrganizationName(QStringLiteral("yuzu team")); QCoreApplication::setOrganizationName(QStringLiteral("yuzu team"));
QCoreApplication::setApplicationName(QStringLiteral("yuzu")); QCoreApplication::setApplicationName(QStringLiteral("yuzu"));

View File

@ -17,6 +17,7 @@
#include "common/logging/filter.h" #include "common/logging/filter.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/microprofile.h" #include "common/microprofile.h"
#include "common/nvidia_flags.h"
#include "common/scm_rev.h" #include "common/scm_rev.h"
#include "common/scope_exit.h" #include "common/scope_exit.h"
#include "common/string_util.h" #include "common/string_util.h"
@ -152,6 +153,8 @@ int main(int argc, char** argv) {
MicroProfileOnThreadCreate("EmuThread"); MicroProfileOnThreadCreate("EmuThread");
SCOPE_EXIT({ MicroProfileShutdown(); }); SCOPE_EXIT({ MicroProfileShutdown(); });
Common::ConfigureNvidiaEnvironmentFlags();
if (filepath.empty()) { if (filepath.empty()) {
LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified"); LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified");
return -1; return -1;