diff options
-rw-r--r-- | src/common/hex_util.cpp | 4 | ||||
-rw-r--r-- | src/common/hex_util.h | 4 | ||||
-rw-r--r-- | src/core/crypto/key_manager.cpp | 8 | ||||
-rw-r--r-- | src/core/file_sys/registered_cache.cpp | 18 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 18 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 24 |
6 files changed, 48 insertions, 28 deletions
diff --git a/src/common/hex_util.cpp b/src/common/hex_util.cpp index ae17c89d4..609144def 100644 --- a/src/common/hex_util.cpp +++ b/src/common/hex_util.cpp @@ -4,6 +4,8 @@ #include "common/hex_util.h" +namespace Common { + u8 ToHexNibble(char c1) { if (c1 >= 65 && c1 <= 70) return c1 - 55; @@ -25,3 +27,5 @@ std::array<u8, 32> operator""_array32(const char* str, size_t len) { throw std::logic_error("Not of correct size."); return HexStringToArray<32>(str); } + +} // namespace Common diff --git a/src/common/hex_util.h b/src/common/hex_util.h index 13d586015..5fb79bb72 100644 --- a/src/common/hex_util.h +++ b/src/common/hex_util.h @@ -10,6 +10,8 @@ #include <fmt/format.h> #include "common/common_types.h" +namespace Common { + u8 ToHexNibble(char c1); template <size_t Size, bool le = false> @@ -35,3 +37,5 @@ std::string HexArrayToString(std::array<u8, Size> array, bool upper = true) { std::array<u8, 0x10> operator"" _array16(const char* str, size_t len); std::array<u8, 0x20> operator"" _array32(const char* str, size_t len); + +} // namespace Common diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp index 94d92579f..db8b22c85 100644 --- a/src/core/crypto/key_manager.cpp +++ b/src/core/crypto/key_manager.cpp @@ -52,20 +52,20 @@ void KeyManager::LoadFromFile(const std::string& filename, bool is_title_keys) { out[1].erase(std::remove(out[1].begin(), out[1].end(), ' '), out[1].end()); if (is_title_keys) { - auto rights_id_raw = HexStringToArray<16>(out[0]); + auto rights_id_raw = Common::HexStringToArray<16>(out[0]); u128 rights_id{}; std::memcpy(rights_id.data(), rights_id_raw.data(), rights_id_raw.size()); - Key128 key = HexStringToArray<16>(out[1]); + Key128 key = Common::HexStringToArray<16>(out[1]); SetKey(S128KeyType::Titlekey, key, rights_id[1], rights_id[0]); } else { std::transform(out[0].begin(), out[0].end(), out[0].begin(), ::tolower); if (s128_file_id.find(out[0]) != s128_file_id.end()) { const auto index = s128_file_id.at(out[0]); - Key128 key = HexStringToArray<16>(out[1]); + Key128 key = Common::HexStringToArray<16>(out[1]); SetKey(index.type, key, index.field1, index.field2); } else if (s256_file_id.find(out[0]) != s256_file_id.end()) { const auto index = s256_file_id.at(out[0]); - Key256 key = HexStringToArray<32>(out[1]); + Key256 key = Common::HexStringToArray<32>(out[1]); SetKey(index.type, key, index.field1, index.field2); } } diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index a5e935f64..d25eeee34 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp @@ -37,11 +37,12 @@ static bool FollowsNcaIdFormat(std::string_view name) { static std::string GetRelativePathFromNcaID(const std::array<u8, 16>& nca_id, bool second_hex_upper, bool within_two_digit) { if (!within_two_digit) - return fmt::format("/{}.nca", HexArrayToString(nca_id, second_hex_upper)); + return fmt::format("/{}.nca", Common::HexArrayToString(nca_id, second_hex_upper)); Core::Crypto::SHA256Hash hash{}; mbedtls_sha256(nca_id.data(), nca_id.size(), hash.data(), 0); - return fmt::format("/000000{:02X}/{}.nca", hash[0], HexArrayToString(nca_id, second_hex_upper)); + return fmt::format("/000000{:02X}/{}.nca", hash[0], + Common::HexArrayToString(nca_id, second_hex_upper)); } static std::string GetCNMTName(TitleType type, u64 title_id) { @@ -170,7 +171,7 @@ std::vector<NcaID> RegisteredCache::AccumulateFiles() const { std::vector<NcaID> ids; for (const auto& d2_dir : dir->GetSubdirectories()) { if (FollowsNcaIdFormat(d2_dir->GetName())) { - ids.push_back(HexStringToArray<0x10, true>(d2_dir->GetName().substr(0, 0x20))); + ids.push_back(Common::HexStringToArray<0x10, true>(d2_dir->GetName().substr(0, 0x20))); continue; } @@ -181,20 +182,21 @@ std::vector<NcaID> RegisteredCache::AccumulateFiles() const { if (!FollowsNcaIdFormat(nca_dir->GetName())) continue; - ids.push_back(HexStringToArray<0x10, true>(nca_dir->GetName().substr(0, 0x20))); + ids.push_back(Common::HexStringToArray<0x10, true>(nca_dir->GetName().substr(0, 0x20))); } for (const auto& nca_file : d2_dir->GetFiles()) { if (!FollowsNcaIdFormat(nca_file->GetName())) continue; - ids.push_back(HexStringToArray<0x10, true>(nca_file->GetName().substr(0, 0x20))); + ids.push_back( + Common::HexStringToArray<0x10, true>(nca_file->GetName().substr(0, 0x20))); } } for (const auto& d2_file : dir->GetFiles()) { if (FollowsNcaIdFormat(d2_file->GetName())) - ids.push_back(HexStringToArray<0x10, true>(d2_file->GetName().substr(0, 0x20))); + ids.push_back(Common::HexStringToArray<0x10, true>(d2_file->GetName().substr(0, 0x20))); } return ids; } @@ -339,7 +341,7 @@ std::vector<RegisteredCacheEntry> RegisteredCache::ListEntriesFilter( } static std::shared_ptr<NCA> GetNCAFromXCIForID(std::shared_ptr<XCI> xci, const NcaID& id) { - const auto filename = fmt::format("{}.nca", HexArrayToString(id, false)); + const auto filename = fmt::format("{}.nca", Common::HexArrayToString(id, false)); const auto iter = std::find_if(xci->GetNCAs().begin(), xci->GetNCAs().end(), [&filename](std::shared_ptr<NCA> nca) { return nca->GetName() == filename; }); @@ -361,7 +363,7 @@ InstallResult RegisteredCache::InstallEntry(std::shared_ptr<XCI> xci, bool overw // Install Metadata File const auto meta_id_raw = (*meta_iter)->GetName().substr(0, 32); - const auto meta_id = HexStringToArray<16>(meta_id_raw); + const auto meta_id = Common::HexStringToArray<16>(meta_id_raw); const auto res = RawInstallNCA(*meta_iter, copy, overwrite_if_exists, meta_id); if (res != InstallResult::Success) diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index b6947b97b..ac4db82cf 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -142,14 +142,16 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form {GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT, ComponentType::UInt, false}, // RG32UI {GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT, ComponentType::UInt, false}, // R32UI + // Depth formats + {GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT, ComponentType::Float, false}, // Z32F + {GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, ComponentType::UNorm, + false}, // Z16 + // DepthStencil formats {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, ComponentType::UNorm, false}, // Z24S8 {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, ComponentType::UNorm, - false}, // S8Z24 - {GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT, ComponentType::Float, false}, // Z32F - {GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, ComponentType::UNorm, - false}, // Z16 + false}, // S8Z24 {GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, ComponentType::Float, false}, // Z32FS8 }}; @@ -283,10 +285,10 @@ static constexpr std::array<void (*)(u32, u32, u32, std::vector<u8>&, Tegra::GPU MortonCopy<true, PixelFormat::RG8S>, MortonCopy<true, PixelFormat::RG32UI>, MortonCopy<true, PixelFormat::R32UI>, - MortonCopy<true, PixelFormat::Z24S8>, - MortonCopy<true, PixelFormat::S8Z24>, MortonCopy<true, PixelFormat::Z32F>, MortonCopy<true, PixelFormat::Z16>, + MortonCopy<true, PixelFormat::Z24S8>, + MortonCopy<true, PixelFormat::S8Z24>, MortonCopy<true, PixelFormat::Z32FS8>, // clang-format on }; @@ -339,10 +341,10 @@ static constexpr std::array<void (*)(u32, u32, u32, std::vector<u8>&, Tegra::GPU MortonCopy<false, PixelFormat::RG8S>, MortonCopy<false, PixelFormat::RG32UI>, MortonCopy<false, PixelFormat::R32UI>, - MortonCopy<false, PixelFormat::Z24S8>, - MortonCopy<false, PixelFormat::S8Z24>, MortonCopy<false, PixelFormat::Z32F>, MortonCopy<false, PixelFormat::Z16>, + MortonCopy<false, PixelFormat::Z24S8>, + MortonCopy<false, PixelFormat::S8Z24>, MortonCopy<false, PixelFormat::Z32FS8>, // clang-format on }; diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 55cf3782c..beec01746 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h @@ -68,11 +68,15 @@ struct SurfaceParams { MaxColorFormat, + // Depth formats + Z32F = 42, + Z16 = 43, + + MaxDepthFormat, + // DepthStencil formats - Z24S8 = 42, - S8Z24 = 43, - Z32F = 44, - Z16 = 45, + Z24S8 = 44, + S8Z24 = 45, Z32FS8 = 46, MaxDepthStencilFormat, @@ -153,10 +157,10 @@ struct SurfaceParams { 1, // RG8S 1, // RG32UI 1, // R32UI - 1, // Z24S8 - 1, // S8Z24 1, // Z32F 1, // Z16 + 1, // Z24S8 + 1, // S8Z24 1, // Z32FS8 }}; @@ -211,10 +215,10 @@ struct SurfaceParams { 16, // RG8S 64, // RG32UI 32, // R32UI - 32, // Z24S8 - 32, // S8Z24 32, // Z32F 16, // Z16 + 32, // Z24S8 + 32, // S8Z24 64, // Z32FS8 }}; @@ -587,6 +591,10 @@ struct SurfaceParams { return SurfaceType::ColorTexture; } + if (static_cast<size_t>(pixel_format) < static_cast<size_t>(PixelFormat::MaxDepthFormat)) { + return SurfaceType::Depth; + } + if (static_cast<size_t>(pixel_format) < static_cast<size_t>(PixelFormat::MaxDepthStencilFormat)) { return SurfaceType::DepthStencil; |