From ece278558259e9174d6ae3a4ec923e3eb73c1b6f Mon Sep 17 00:00:00 2001 From: PixelyIon Date: Thu, 2 Dec 2021 00:43:10 +0530 Subject: [PATCH] Introduce `ShaderManager` with Proxy Shader Compiler Logger/Settings This class will be entirely responsible for any interop with the shader compiler, it is also responsible for caching and compilation of shaders in itself. --- app/CMakeLists.txt | 3 +- app/libraries/shader-compiler | 2 +- app/src/main/cpp/skyline/gpu.cpp | 2 +- app/src/main/cpp/skyline/gpu.h | 3 ++ .../main/cpp/skyline/gpu/shader_manager.cpp | 32 +++++++++++++++++++ app/src/main/cpp/skyline/gpu/shader_manager.h | 17 ++++++++++ 6 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 app/src/main/cpp/skyline/gpu/shader_manager.cpp create mode 100644 app/src/main/cpp/skyline/gpu/shader_manager.h diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 6a90a5f5..7c558cd1 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -160,6 +160,7 @@ add_library(skyline SHARED ${source_DIR}/skyline/gpu/command_scheduler.cpp ${source_DIR}/skyline/gpu/texture/texture.cpp ${source_DIR}/skyline/gpu/presentation_engine.cpp + ${source_DIR}/skyline/gpu/shader_manager.cpp ${source_DIR}/skyline/gpu/interconnect/command_executor.cpp ${source_DIR}/skyline/gpu/interconnect/command_nodes.cpp ${source_DIR}/skyline/soc/smmu.cpp @@ -301,4 +302,4 @@ target_include_directories(skyline PRIVATE ${source_DIR}/skyline) target_compile_options(skyline PRIVATE -Wall -Wno-unknown-attributes -Wno-c++20-extensions -Wno-c++17-extensions -Wno-c99-designator -Wno-reorder -Wno-missing-braces -Wno-unused-variable -Wno-unused-private-field -Wno-dangling-else -Wconversion) target_link_libraries(skyline PRIVATE shader_recompiler) -target_link_libraries_system(skyline android perfetto fmt lz4_static tzcode oboe vkma mbedcrypto opus Boost::container) +target_link_libraries_system(skyline android perfetto fmt lz4_static tzcode oboe vkma mbedcrypto opus Boost::intrusive Boost::container range-v3) diff --git a/app/libraries/shader-compiler b/app/libraries/shader-compiler index 26adbfd2..d56926aa 160000 --- a/app/libraries/shader-compiler +++ b/app/libraries/shader-compiler @@ -1 +1 @@ -Subproject commit 26adbfd2f3ab9b39cee64230ef5a6b28d3f28846 +Subproject commit d56926aad6cce2ba5df958a3cd0f854ce84fdb9a diff --git a/app/src/main/cpp/skyline/gpu.cpp b/app/src/main/cpp/skyline/gpu.cpp index f22a15b3..81591cca 100644 --- a/app/src/main/cpp/skyline/gpu.cpp +++ b/app/src/main/cpp/skyline/gpu.cpp @@ -201,5 +201,5 @@ namespace skyline::gpu { }); } - GPU::GPU(const DeviceState &state) : vkInstance(CreateInstance(state, vkContext)), vkDebugReportCallback(CreateDebugReportCallback(vkInstance)), vkPhysicalDevice(CreatePhysicalDevice(vkInstance)), vkDevice(CreateDevice(vkPhysicalDevice, vkQueueFamilyIndex, quirks)), vkQueue(vkDevice, vkQueueFamilyIndex, 0), memory(*this), scheduler(*this), presentation(state, *this), texture(*this) {} + GPU::GPU(const DeviceState &state) : vkInstance(CreateInstance(state, vkContext)), vkDebugReportCallback(CreateDebugReportCallback(vkInstance)), vkPhysicalDevice(CreatePhysicalDevice(vkInstance)), vkDevice(CreateDevice(vkPhysicalDevice, vkQueueFamilyIndex, quirks)), vkQueue(vkDevice, vkQueueFamilyIndex, 0), memory(*this), scheduler(*this), presentation(state, *this), texture(*this), shader(state) {} } diff --git a/app/src/main/cpp/skyline/gpu.h b/app/src/main/cpp/skyline/gpu.h index 115c1a25..9e3c2dee 100644 --- a/app/src/main/cpp/skyline/gpu.h +++ b/app/src/main/cpp/skyline/gpu.h @@ -8,6 +8,7 @@ #include "gpu/command_scheduler.h" #include "gpu/presentation_engine.h" #include "gpu/texture_manager.h" +#include "gpu/shader_manager.h" namespace skyline::gpu { /** @@ -45,6 +46,8 @@ namespace skyline::gpu { TextureManager texture; + ShaderManager shader; + GPU(const DeviceState &state); }; } diff --git a/app/src/main/cpp/skyline/gpu/shader_manager.cpp b/app/src/main/cpp/skyline/gpu/shader_manager.cpp new file mode 100644 index 00000000..ba4ac297 --- /dev/null +++ b/app/src/main/cpp/skyline/gpu/shader_manager.cpp @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright © 2021 Skyline Team and Contributors (https://github.com/skyline-emu/) + +#include +#include +#include "shader_manager.h" + +namespace Shader::Log { + void Debug(const std::string &message) { + skyline::Logger::Write(skyline::Logger::LogLevel::Debug, message); + } + + void Warn(const std::string &message) { + skyline::Logger::Write(skyline::Logger::LogLevel::Warn, message); + } + + void Error(const std::string &message) { + skyline::Logger::Write(skyline::Logger::LogLevel::Error, message); + } +} + +namespace skyline::gpu { + ShaderManager::ShaderManager(const DeviceState &state) { + Shader::Settings::values = { + .disable_shader_loop_safety_checks = false, + .renderer_debug = true, + .resolution_info = { + .active = false, + }, + }; + } +} diff --git a/app/src/main/cpp/skyline/gpu/shader_manager.h b/app/src/main/cpp/skyline/gpu/shader_manager.h new file mode 100644 index 00000000..7c78d798 --- /dev/null +++ b/app/src/main/cpp/skyline/gpu/shader_manager.h @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright © 2021 Skyline Team and Contributors (https://github.com/skyline-emu/) + +#pragma once + +#include +#include + +namespace skyline::gpu { + /** + * @brief The Shader Manager is responsible for caching and looking up shaders alongside handling compilation of shaders when not found in any cache + */ + class ShaderManager { + public: + ShaderManager(const DeviceState& state); + }; +}