diff options
| author | 2023-10-18 01:06:58 -0300 | |
|---|---|---|
| committer | 2023-10-18 01:06:58 -0300 | |
| commit | 59b6ada7b7ef44ca883613567459b7156e55e1c8 (patch) | |
| tree | ab8892a2edf7ef24be813ce45726ed9f053a48fd /src | |
| parent | Final refactorization (diff) | |
| parent | Merge pull request #11774 from liamwhite/refcount-issue (diff) | |
| download | yuzu-59b6ada7b7ef44ca883613567459b7156e55e1c8.tar.gz yuzu-59b6ada7b7ef44ca883613567459b7156e55e1c8.tar.xz yuzu-59b6ada7b7ef44ca883613567459b7156e55e1c8.zip | |
Merge branch 'yuzu-emu:master' into new-shortcut
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/core.cpp | 7 | ||||
| -rw-r--r-- | src/core/file_sys/fsmitm_romfsbuild.cpp | 84 | ||||
| -rw-r--r-- | src/core/file_sys/patch_manager.cpp | 8 | ||||
| -rw-r--r-- | src/core/file_sys/registered_cache.cpp | 3 | ||||
| -rw-r--r-- | src/core/file_sys/romfs.cpp | 5 | ||||
| -rw-r--r-- | src/core/file_sys/vfs_cached.cpp | 6 | ||||
| -rw-r--r-- | src/core/file_sys/vfs_cached.h | 2 | ||||
| -rw-r--r-- | src/core/file_sys/vfs_concat.cpp | 27 | ||||
| -rw-r--r-- | src/core/file_sys/vfs_concat.h | 12 | ||||
| -rw-r--r-- | src/core/file_sys/vfs_layered.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/buffer_cache/buffer_cache_base.h | 4 | ||||
| -rw-r--r-- | src/video_core/host_shaders/convert_d24s8_to_abgr8.frag | 8 | ||||
| -rw-r--r-- | src/video_core/host_shaders/convert_s8d24_to_abgr8.frag | 8 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_query_cache.cpp | 1 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 13 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_render_pass_cache.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/texture_cache/formatter.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/texture_cache/samples_helper.h | 2 | ||||
| -rw-r--r-- | src/video_core/texture_cache/util.cpp | 11 |
19 files changed, 120 insertions, 99 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 0ab2e3b76..d7e2efbd7 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -116,11 +116,8 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, | |||
| 116 | } | 116 | } |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | if (concat.empty()) { | 119 | return FileSys::ConcatenatedVfsFile::MakeConcatenatedFile(dir->GetName(), |
| 120 | return nullptr; | 120 | std::move(concat)); |
| 121 | } | ||
| 122 | |||
| 123 | return FileSys::ConcatenatedVfsFile::MakeConcatenatedFile(concat, dir->GetName()); | ||
| 124 | } | 121 | } |
| 125 | 122 | ||
| 126 | if (Common::FS::IsDir(path)) { | 123 | if (Common::FS::IsDir(path)) { |
diff --git a/src/core/file_sys/fsmitm_romfsbuild.cpp b/src/core/file_sys/fsmitm_romfsbuild.cpp index e39c7b62b..f1d3e4129 100644 --- a/src/core/file_sys/fsmitm_romfsbuild.cpp +++ b/src/core/file_sys/fsmitm_romfsbuild.cpp | |||
| @@ -107,62 +107,56 @@ static u64 romfs_get_hash_table_count(u64 num_entries) { | |||
| 107 | 107 | ||
| 108 | void RomFSBuildContext::VisitDirectory(VirtualDir romfs_dir, VirtualDir ext_dir, | 108 | void RomFSBuildContext::VisitDirectory(VirtualDir romfs_dir, VirtualDir ext_dir, |
| 109 | std::shared_ptr<RomFSBuildDirectoryContext> parent) { | 109 | std::shared_ptr<RomFSBuildDirectoryContext> parent) { |
| 110 | std::vector<std::shared_ptr<RomFSBuildDirectoryContext>> child_dirs; | 110 | for (auto& child_romfs_file : romfs_dir->GetFiles()) { |
| 111 | const auto name = child_romfs_file->GetName(); | ||
| 112 | const auto child = std::make_shared<RomFSBuildFileContext>(); | ||
| 113 | // Set child's path. | ||
| 114 | child->cur_path_ofs = parent->path_len + 1; | ||
| 115 | child->path_len = child->cur_path_ofs + static_cast<u32>(name.size()); | ||
| 116 | child->path = parent->path + "/" + name; | ||
| 117 | |||
| 118 | if (ext_dir != nullptr && ext_dir->GetFile(name + ".stub") != nullptr) { | ||
| 119 | continue; | ||
| 120 | } | ||
| 111 | 121 | ||
| 112 | const auto entries = romfs_dir->GetEntries(); | 122 | // Sanity check on path_len |
| 123 | ASSERT(child->path_len < FS_MAX_PATH); | ||
| 113 | 124 | ||
| 114 | for (const auto& kv : entries) { | 125 | child->source = std::move(child_romfs_file); |
| 115 | if (kv.second == VfsEntryType::Directory) { | ||
| 116 | const auto child = std::make_shared<RomFSBuildDirectoryContext>(); | ||
| 117 | // Set child's path. | ||
| 118 | child->cur_path_ofs = parent->path_len + 1; | ||
| 119 | child->path_len = child->cur_path_ofs + static_cast<u32>(kv.first.size()); | ||
| 120 | child->path = parent->path + "/" + kv.first; | ||
| 121 | 126 | ||
| 122 | if (ext_dir != nullptr && ext_dir->GetFile(kv.first + ".stub") != nullptr) { | 127 | if (ext_dir != nullptr) { |
| 123 | continue; | 128 | if (const auto ips = ext_dir->GetFile(name + ".ips")) { |
| 129 | if (auto patched = PatchIPS(child->source, ips)) { | ||
| 130 | child->source = std::move(patched); | ||
| 131 | } | ||
| 124 | } | 132 | } |
| 133 | } | ||
| 125 | 134 | ||
| 126 | // Sanity check on path_len | 135 | child->size = child->source->GetSize(); |
| 127 | ASSERT(child->path_len < FS_MAX_PATH); | ||
| 128 | |||
| 129 | if (AddDirectory(parent, child)) { | ||
| 130 | child_dirs.push_back(child); | ||
| 131 | } | ||
| 132 | } else { | ||
| 133 | const auto child = std::make_shared<RomFSBuildFileContext>(); | ||
| 134 | // Set child's path. | ||
| 135 | child->cur_path_ofs = parent->path_len + 1; | ||
| 136 | child->path_len = child->cur_path_ofs + static_cast<u32>(kv.first.size()); | ||
| 137 | child->path = parent->path + "/" + kv.first; | ||
| 138 | |||
| 139 | if (ext_dir != nullptr && ext_dir->GetFile(kv.first + ".stub") != nullptr) { | ||
| 140 | continue; | ||
| 141 | } | ||
| 142 | 136 | ||
| 143 | // Sanity check on path_len | 137 | AddFile(parent, child); |
| 144 | ASSERT(child->path_len < FS_MAX_PATH); | 138 | } |
| 145 | 139 | ||
| 146 | child->source = romfs_dir->GetFile(kv.first); | 140 | for (auto& child_romfs_dir : romfs_dir->GetSubdirectories()) { |
| 141 | const auto name = child_romfs_dir->GetName(); | ||
| 142 | const auto child = std::make_shared<RomFSBuildDirectoryContext>(); | ||
| 143 | // Set child's path. | ||
| 144 | child->cur_path_ofs = parent->path_len + 1; | ||
| 145 | child->path_len = child->cur_path_ofs + static_cast<u32>(name.size()); | ||
| 146 | child->path = parent->path + "/" + name; | ||
| 147 | 147 | ||
| 148 | if (ext_dir != nullptr) { | 148 | if (ext_dir != nullptr && ext_dir->GetFile(name + ".stub") != nullptr) { |
| 149 | if (const auto ips = ext_dir->GetFile(kv.first + ".ips")) { | 149 | continue; |
| 150 | if (auto patched = PatchIPS(child->source, ips)) { | 150 | } |
| 151 | child->source = std::move(patched); | ||
| 152 | } | ||
| 153 | } | ||
| 154 | } | ||
| 155 | 151 | ||
| 156 | child->size = child->source->GetSize(); | 152 | // Sanity check on path_len |
| 153 | ASSERT(child->path_len < FS_MAX_PATH); | ||
| 157 | 154 | ||
| 158 | AddFile(parent, child); | 155 | if (!AddDirectory(parent, child)) { |
| 156 | continue; | ||
| 159 | } | 157 | } |
| 160 | } | ||
| 161 | 158 | ||
| 162 | for (auto& child : child_dirs) { | 159 | auto child_ext_dir = ext_dir != nullptr ? ext_dir->GetSubdirectory(name) : nullptr; |
| 163 | auto subdir_name = std::string_view(child->path).substr(child->cur_path_ofs); | ||
| 164 | auto child_romfs_dir = romfs_dir->GetSubdirectory(subdir_name); | ||
| 165 | auto child_ext_dir = ext_dir != nullptr ? ext_dir->GetSubdirectory(subdir_name) : nullptr; | ||
| 166 | this->VisitDirectory(child_romfs_dir, child_ext_dir, child); | 160 | this->VisitDirectory(child_romfs_dir, child_ext_dir, child); |
| 167 | } | 161 | } |
| 168 | } | 162 | } |
| @@ -293,7 +287,7 @@ std::multimap<u64, VirtualFile> RomFSBuildContext::Build() { | |||
| 293 | 287 | ||
| 294 | cur_entry.name_size = name_size; | 288 | cur_entry.name_size = name_size; |
| 295 | 289 | ||
| 296 | out.emplace(cur_file->offset + ROMFS_FILEPARTITION_OFS, cur_file->source); | 290 | out.emplace(cur_file->offset + ROMFS_FILEPARTITION_OFS, std::move(cur_file->source)); |
| 297 | std::memcpy(file_table.data() + cur_file->entry_offset, &cur_entry, sizeof(RomFSFileEntry)); | 291 | std::memcpy(file_table.data() + cur_file->entry_offset, &cur_entry, sizeof(RomFSFileEntry)); |
| 298 | std::memset(file_table.data() + cur_file->entry_offset + sizeof(RomFSFileEntry), 0, | 292 | std::memset(file_table.data() + cur_file->entry_offset + sizeof(RomFSFileEntry), 0, |
| 299 | Common::AlignUp(cur_entry.name_size, 4)); | 293 | Common::AlignUp(cur_entry.name_size, 4)); |
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index 8e475f25a..0bca05587 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp | |||
| @@ -377,16 +377,16 @@ static void ApplyLayeredFS(VirtualFile& romfs, u64 title_id, ContentRecordType t | |||
| 377 | 377 | ||
| 378 | auto romfs_dir = FindSubdirectoryCaseless(subdir, "romfs"); | 378 | auto romfs_dir = FindSubdirectoryCaseless(subdir, "romfs"); |
| 379 | if (romfs_dir != nullptr) | 379 | if (romfs_dir != nullptr) |
| 380 | layers.push_back(std::make_shared<CachedVfsDirectory>(romfs_dir)); | 380 | layers.emplace_back(std::make_shared<CachedVfsDirectory>(std::move(romfs_dir))); |
| 381 | 381 | ||
| 382 | auto ext_dir = FindSubdirectoryCaseless(subdir, "romfs_ext"); | 382 | auto ext_dir = FindSubdirectoryCaseless(subdir, "romfs_ext"); |
| 383 | if (ext_dir != nullptr) | 383 | if (ext_dir != nullptr) |
| 384 | layers_ext.push_back(std::make_shared<CachedVfsDirectory>(ext_dir)); | 384 | layers_ext.emplace_back(std::make_shared<CachedVfsDirectory>(std::move(ext_dir))); |
| 385 | 385 | ||
| 386 | if (type == ContentRecordType::HtmlDocument) { | 386 | if (type == ContentRecordType::HtmlDocument) { |
| 387 | auto manual_dir = FindSubdirectoryCaseless(subdir, "manual_html"); | 387 | auto manual_dir = FindSubdirectoryCaseless(subdir, "manual_html"); |
| 388 | if (manual_dir != nullptr) | 388 | if (manual_dir != nullptr) |
| 389 | layers.push_back(std::make_shared<CachedVfsDirectory>(manual_dir)); | 389 | layers.emplace_back(std::make_shared<CachedVfsDirectory>(std::move(manual_dir))); |
| 390 | } | 390 | } |
| 391 | } | 391 | } |
| 392 | 392 | ||
| @@ -400,7 +400,7 @@ static void ApplyLayeredFS(VirtualFile& romfs, u64 title_id, ContentRecordType t | |||
| 400 | return; | 400 | return; |
| 401 | } | 401 | } |
| 402 | 402 | ||
| 403 | layers.push_back(std::move(extracted)); | 403 | layers.emplace_back(std::move(extracted)); |
| 404 | 404 | ||
| 405 | auto layered = LayeredVfsDirectory::MakeLayeredDirectory(std::move(layers)); | 405 | auto layered = LayeredVfsDirectory::MakeLayeredDirectory(std::move(layers)); |
| 406 | if (layered == nullptr) { | 406 | if (layered == nullptr) { |
diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index 04da93d5c..1cc77ad14 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp | |||
| @@ -322,7 +322,8 @@ VirtualFile RegisteredCache::OpenFileOrDirectoryConcat(const VirtualDir& open_di | |||
| 322 | return nullptr; | 322 | return nullptr; |
| 323 | } | 323 | } |
| 324 | 324 | ||
| 325 | return ConcatenatedVfsFile::MakeConcatenatedFile(concat, concat.front()->GetName()); | 325 | auto name = concat.front()->GetName(); |
| 326 | return ConcatenatedVfsFile::MakeConcatenatedFile(std::move(name), std::move(concat)); | ||
| 326 | } | 327 | } |
| 327 | 328 | ||
| 328 | VirtualFile RegisteredCache::GetFileAtID(NcaID id) const { | 329 | VirtualFile RegisteredCache::GetFileAtID(NcaID id) const { |
diff --git a/src/core/file_sys/romfs.cpp b/src/core/file_sys/romfs.cpp index 614da2130..1c580de57 100644 --- a/src/core/file_sys/romfs.cpp +++ b/src/core/file_sys/romfs.cpp | |||
| @@ -133,7 +133,7 @@ VirtualDir ExtractRomFS(VirtualFile file, RomFSExtractionType type) { | |||
| 133 | out = out->GetSubdirectories().front(); | 133 | out = out->GetSubdirectories().front(); |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | return std::make_shared<CachedVfsDirectory>(out); | 136 | return std::make_shared<CachedVfsDirectory>(std::move(out)); |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | VirtualFile CreateRomFS(VirtualDir dir, VirtualDir ext) { | 139 | VirtualFile CreateRomFS(VirtualDir dir, VirtualDir ext) { |
| @@ -141,8 +141,7 @@ VirtualFile CreateRomFS(VirtualDir dir, VirtualDir ext) { | |||
| 141 | return nullptr; | 141 | return nullptr; |
| 142 | 142 | ||
| 143 | RomFSBuildContext ctx{dir, ext}; | 143 | RomFSBuildContext ctx{dir, ext}; |
| 144 | auto file_map = ctx.Build(); | 144 | return ConcatenatedVfsFile::MakeConcatenatedFile(0, dir->GetName(), ctx.Build()); |
| 145 | return ConcatenatedVfsFile::MakeConcatenatedFile(0, file_map, dir->GetName()); | ||
| 146 | } | 145 | } |
| 147 | 146 | ||
| 148 | } // namespace FileSys | 147 | } // namespace FileSys |
diff --git a/src/core/file_sys/vfs_cached.cpp b/src/core/file_sys/vfs_cached.cpp index c3154ee81..7ee5300e5 100644 --- a/src/core/file_sys/vfs_cached.cpp +++ b/src/core/file_sys/vfs_cached.cpp | |||
| @@ -6,13 +6,13 @@ | |||
| 6 | 6 | ||
| 7 | namespace FileSys { | 7 | namespace FileSys { |
| 8 | 8 | ||
| 9 | CachedVfsDirectory::CachedVfsDirectory(VirtualDir& source_dir) | 9 | CachedVfsDirectory::CachedVfsDirectory(VirtualDir&& source_dir) |
| 10 | : name(source_dir->GetName()), parent(source_dir->GetParentDirectory()) { | 10 | : name(source_dir->GetName()), parent(source_dir->GetParentDirectory()) { |
| 11 | for (auto& dir : source_dir->GetSubdirectories()) { | 11 | for (auto& dir : source_dir->GetSubdirectories()) { |
| 12 | dirs.emplace(dir->GetName(), std::make_shared<CachedVfsDirectory>(dir)); | 12 | dirs.emplace(dir->GetName(), std::make_shared<CachedVfsDirectory>(std::move(dir))); |
| 13 | } | 13 | } |
| 14 | for (auto& file : source_dir->GetFiles()) { | 14 | for (auto& file : source_dir->GetFiles()) { |
| 15 | files.emplace(file->GetName(), file); | 15 | files.emplace(file->GetName(), std::move(file)); |
| 16 | } | 16 | } |
| 17 | } | 17 | } |
| 18 | 18 | ||
diff --git a/src/core/file_sys/vfs_cached.h b/src/core/file_sys/vfs_cached.h index 113acac12..1e5300784 100644 --- a/src/core/file_sys/vfs_cached.h +++ b/src/core/file_sys/vfs_cached.h | |||
| @@ -11,7 +11,7 @@ namespace FileSys { | |||
| 11 | 11 | ||
| 12 | class CachedVfsDirectory : public ReadOnlyVfsDirectory { | 12 | class CachedVfsDirectory : public ReadOnlyVfsDirectory { |
| 13 | public: | 13 | public: |
| 14 | CachedVfsDirectory(VirtualDir& source_directory); | 14 | CachedVfsDirectory(VirtualDir&& source_directory); |
| 15 | 15 | ||
| 16 | ~CachedVfsDirectory() override; | 16 | ~CachedVfsDirectory() override; |
| 17 | VirtualFile GetFile(std::string_view file_name) const override; | 17 | VirtualFile GetFile(std::string_view file_name) const override; |
diff --git a/src/core/file_sys/vfs_concat.cpp b/src/core/file_sys/vfs_concat.cpp index 311a59e5f..168b9cbec 100644 --- a/src/core/file_sys/vfs_concat.cpp +++ b/src/core/file_sys/vfs_concat.cpp | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | namespace FileSys { | 11 | namespace FileSys { |
| 12 | 12 | ||
| 13 | ConcatenatedVfsFile::ConcatenatedVfsFile(ConcatenationMap&& concatenation_map_, std::string&& name_) | 13 | ConcatenatedVfsFile::ConcatenatedVfsFile(std::string&& name_, ConcatenationMap&& concatenation_map_) |
| 14 | : concatenation_map(std::move(concatenation_map_)), name(std::move(name_)) { | 14 | : concatenation_map(std::move(concatenation_map_)), name(std::move(name_)) { |
| 15 | DEBUG_ASSERT(this->VerifyContinuity()); | 15 | DEBUG_ASSERT(this->VerifyContinuity()); |
| 16 | } | 16 | } |
| @@ -30,8 +30,8 @@ bool ConcatenatedVfsFile::VerifyContinuity() const { | |||
| 30 | 30 | ||
| 31 | ConcatenatedVfsFile::~ConcatenatedVfsFile() = default; | 31 | ConcatenatedVfsFile::~ConcatenatedVfsFile() = default; |
| 32 | 32 | ||
| 33 | VirtualFile ConcatenatedVfsFile::MakeConcatenatedFile(const std::vector<VirtualFile>& files, | 33 | VirtualFile ConcatenatedVfsFile::MakeConcatenatedFile(std::string&& name, |
| 34 | std::string&& name) { | 34 | std::vector<VirtualFile>&& files) { |
| 35 | // Fold trivial cases. | 35 | // Fold trivial cases. |
| 36 | if (files.empty()) { | 36 | if (files.empty()) { |
| 37 | return nullptr; | 37 | return nullptr; |
| @@ -46,20 +46,21 @@ VirtualFile ConcatenatedVfsFile::MakeConcatenatedFile(const std::vector<VirtualF | |||
| 46 | u64 last_offset = 0; | 46 | u64 last_offset = 0; |
| 47 | 47 | ||
| 48 | for (auto& file : files) { | 48 | for (auto& file : files) { |
| 49 | const auto size = file->GetSize(); | ||
| 50 | |||
| 49 | concatenation_map.emplace_back(ConcatenationEntry{ | 51 | concatenation_map.emplace_back(ConcatenationEntry{ |
| 50 | .offset = last_offset, | 52 | .offset = last_offset, |
| 51 | .file = file, | 53 | .file = std::move(file), |
| 52 | }); | 54 | }); |
| 53 | 55 | ||
| 54 | last_offset += file->GetSize(); | 56 | last_offset += size; |
| 55 | } | 57 | } |
| 56 | 58 | ||
| 57 | return VirtualFile(new ConcatenatedVfsFile(std::move(concatenation_map), std::move(name))); | 59 | return VirtualFile(new ConcatenatedVfsFile(std::move(name), std::move(concatenation_map))); |
| 58 | } | 60 | } |
| 59 | 61 | ||
| 60 | VirtualFile ConcatenatedVfsFile::MakeConcatenatedFile(u8 filler_byte, | 62 | VirtualFile ConcatenatedVfsFile::MakeConcatenatedFile(u8 filler_byte, std::string&& name, |
| 61 | const std::multimap<u64, VirtualFile>& files, | 63 | std::multimap<u64, VirtualFile>&& files) { |
| 62 | std::string&& name) { | ||
| 63 | // Fold trivial cases. | 64 | // Fold trivial cases. |
| 64 | if (files.empty()) { | 65 | if (files.empty()) { |
| 65 | return nullptr; | 66 | return nullptr; |
| @@ -76,6 +77,8 @@ VirtualFile ConcatenatedVfsFile::MakeConcatenatedFile(u8 filler_byte, | |||
| 76 | 77 | ||
| 77 | // Iteration of a multimap is ordered, so offset will be strictly non-decreasing. | 78 | // Iteration of a multimap is ordered, so offset will be strictly non-decreasing. |
| 78 | for (auto& [offset, file] : files) { | 79 | for (auto& [offset, file] : files) { |
| 80 | const auto size = file->GetSize(); | ||
| 81 | |||
| 79 | if (offset > last_offset) { | 82 | if (offset > last_offset) { |
| 80 | concatenation_map.emplace_back(ConcatenationEntry{ | 83 | concatenation_map.emplace_back(ConcatenationEntry{ |
| 81 | .offset = last_offset, | 84 | .offset = last_offset, |
| @@ -85,13 +88,13 @@ VirtualFile ConcatenatedVfsFile::MakeConcatenatedFile(u8 filler_byte, | |||
| 85 | 88 | ||
| 86 | concatenation_map.emplace_back(ConcatenationEntry{ | 89 | concatenation_map.emplace_back(ConcatenationEntry{ |
| 87 | .offset = offset, | 90 | .offset = offset, |
| 88 | .file = file, | 91 | .file = std::move(file), |
| 89 | }); | 92 | }); |
| 90 | 93 | ||
| 91 | last_offset = offset + file->GetSize(); | 94 | last_offset = offset + size; |
| 92 | } | 95 | } |
| 93 | 96 | ||
| 94 | return VirtualFile(new ConcatenatedVfsFile(std::move(concatenation_map), std::move(name))); | 97 | return VirtualFile(new ConcatenatedVfsFile(std::move(name), std::move(concatenation_map))); |
| 95 | } | 98 | } |
| 96 | 99 | ||
| 97 | std::string ConcatenatedVfsFile::GetName() const { | 100 | std::string ConcatenatedVfsFile::GetName() const { |
diff --git a/src/core/file_sys/vfs_concat.h b/src/core/file_sys/vfs_concat.h index 6b329d545..cbddd12bd 100644 --- a/src/core/file_sys/vfs_concat.h +++ b/src/core/file_sys/vfs_concat.h | |||
| @@ -24,22 +24,20 @@ private: | |||
| 24 | }; | 24 | }; |
| 25 | using ConcatenationMap = std::vector<ConcatenationEntry>; | 25 | using ConcatenationMap = std::vector<ConcatenationEntry>; |
| 26 | 26 | ||
| 27 | explicit ConcatenatedVfsFile(std::vector<ConcatenationEntry>&& concatenation_map, | 27 | explicit ConcatenatedVfsFile(std::string&& name, |
| 28 | std::string&& name); | 28 | std::vector<ConcatenationEntry>&& concatenation_map); |
| 29 | bool VerifyContinuity() const; | 29 | bool VerifyContinuity() const; |
| 30 | 30 | ||
| 31 | public: | 31 | public: |
| 32 | ~ConcatenatedVfsFile() override; | 32 | ~ConcatenatedVfsFile() override; |
| 33 | 33 | ||
| 34 | /// Wrapper function to allow for more efficient handling of files.size() == 0, 1 cases. | 34 | /// Wrapper function to allow for more efficient handling of files.size() == 0, 1 cases. |
| 35 | static VirtualFile MakeConcatenatedFile(const std::vector<VirtualFile>& files, | 35 | static VirtualFile MakeConcatenatedFile(std::string&& name, std::vector<VirtualFile>&& files); |
| 36 | std::string&& name); | ||
| 37 | 36 | ||
| 38 | /// Convenience function that turns a map of offsets to files into a concatenated file, filling | 37 | /// Convenience function that turns a map of offsets to files into a concatenated file, filling |
| 39 | /// gaps with a given filler byte. | 38 | /// gaps with a given filler byte. |
| 40 | static VirtualFile MakeConcatenatedFile(u8 filler_byte, | 39 | static VirtualFile MakeConcatenatedFile(u8 filler_byte, std::string&& name, |
| 41 | const std::multimap<u64, VirtualFile>& files, | 40 | std::multimap<u64, VirtualFile>&& files); |
| 42 | std::string&& name); | ||
| 43 | 41 | ||
| 44 | std::string GetName() const override; | 42 | std::string GetName() const override; |
| 45 | std::size_t GetSize() const override; | 43 | std::size_t GetSize() const override; |
diff --git a/src/core/file_sys/vfs_layered.cpp b/src/core/file_sys/vfs_layered.cpp index 3e6426afc..08daca397 100644 --- a/src/core/file_sys/vfs_layered.cpp +++ b/src/core/file_sys/vfs_layered.cpp | |||
| @@ -38,7 +38,7 @@ VirtualDir LayeredVfsDirectory::GetDirectoryRelative(std::string_view path) cons | |||
| 38 | for (const auto& layer : dirs) { | 38 | for (const auto& layer : dirs) { |
| 39 | auto dir = layer->GetDirectoryRelative(path); | 39 | auto dir = layer->GetDirectoryRelative(path); |
| 40 | if (dir != nullptr) { | 40 | if (dir != nullptr) { |
| 41 | out.push_back(std::move(dir)); | 41 | out.emplace_back(std::move(dir)); |
| 42 | } | 42 | } |
| 43 | } | 43 | } |
| 44 | 44 | ||
| @@ -62,11 +62,11 @@ std::vector<VirtualFile> LayeredVfsDirectory::GetFiles() const { | |||
| 62 | std::set<std::string, std::less<>> out_names; | 62 | std::set<std::string, std::less<>> out_names; |
| 63 | 63 | ||
| 64 | for (const auto& layer : dirs) { | 64 | for (const auto& layer : dirs) { |
| 65 | for (const auto& file : layer->GetFiles()) { | 65 | for (auto& file : layer->GetFiles()) { |
| 66 | auto file_name = file->GetName(); | 66 | auto file_name = file->GetName(); |
| 67 | if (!out_names.contains(file_name)) { | 67 | if (!out_names.contains(file_name)) { |
| 68 | out_names.emplace(std::move(file_name)); | 68 | out_names.emplace(std::move(file_name)); |
| 69 | out.push_back(file); | 69 | out.emplace_back(std::move(file)); |
| 70 | } | 70 | } |
| 71 | } | 71 | } |
| 72 | } | 72 | } |
| @@ -86,7 +86,7 @@ std::vector<VirtualDir> LayeredVfsDirectory::GetSubdirectories() const { | |||
| 86 | std::vector<VirtualDir> out; | 86 | std::vector<VirtualDir> out; |
| 87 | out.reserve(names.size()); | 87 | out.reserve(names.size()); |
| 88 | for (const auto& subdir : names) | 88 | for (const auto& subdir : names) |
| 89 | out.push_back(GetSubdirectory(subdir)); | 89 | out.emplace_back(GetSubdirectory(subdir)); |
| 90 | 90 | ||
| 91 | return out; | 91 | return out; |
| 92 | } | 92 | } |
diff --git a/src/video_core/buffer_cache/buffer_cache_base.h b/src/video_core/buffer_cache/buffer_cache_base.h index c4f6e8d12..eed267361 100644 --- a/src/video_core/buffer_cache/buffer_cache_base.h +++ b/src/video_core/buffer_cache/buffer_cache_base.h | |||
| @@ -62,7 +62,11 @@ using BufferId = SlotId; | |||
| 62 | using VideoCore::Surface::PixelFormat; | 62 | using VideoCore::Surface::PixelFormat; |
| 63 | using namespace Common::Literals; | 63 | using namespace Common::Literals; |
| 64 | 64 | ||
| 65 | #ifdef __APPLE__ | ||
| 66 | constexpr u32 NUM_VERTEX_BUFFERS = 16; | ||
| 67 | #else | ||
| 65 | constexpr u32 NUM_VERTEX_BUFFERS = 32; | 68 | constexpr u32 NUM_VERTEX_BUFFERS = 32; |
| 69 | #endif | ||
| 66 | constexpr u32 NUM_TRANSFORM_FEEDBACK_BUFFERS = 4; | 70 | constexpr u32 NUM_TRANSFORM_FEEDBACK_BUFFERS = 4; |
| 67 | constexpr u32 NUM_GRAPHICS_UNIFORM_BUFFERS = 18; | 71 | constexpr u32 NUM_GRAPHICS_UNIFORM_BUFFERS = 18; |
| 68 | constexpr u32 NUM_COMPUTE_UNIFORM_BUFFERS = 8; | 72 | constexpr u32 NUM_COMPUTE_UNIFORM_BUFFERS = 8; |
diff --git a/src/video_core/host_shaders/convert_d24s8_to_abgr8.frag b/src/video_core/host_shaders/convert_d24s8_to_abgr8.frag index d33131d7c..b81a54056 100644 --- a/src/video_core/host_shaders/convert_d24s8_to_abgr8.frag +++ b/src/video_core/host_shaders/convert_d24s8_to_abgr8.frag | |||
| @@ -3,16 +3,16 @@ | |||
| 3 | 3 | ||
| 4 | #version 450 | 4 | #version 450 |
| 5 | 5 | ||
| 6 | precision mediump int; | ||
| 7 | precision highp float; | ||
| 8 | |||
| 6 | layout(binding = 0) uniform sampler2D depth_tex; | 9 | layout(binding = 0) uniform sampler2D depth_tex; |
| 7 | layout(binding = 1) uniform isampler2D stencil_tex; | 10 | layout(binding = 1) uniform usampler2D stencil_tex; |
| 8 | 11 | ||
| 9 | layout(location = 0) out vec4 color; | 12 | layout(location = 0) out vec4 color; |
| 10 | 13 | ||
| 11 | void main() { | 14 | void main() { |
| 12 | ivec2 coord = ivec2(gl_FragCoord.xy); | 15 | ivec2 coord = ivec2(gl_FragCoord.xy); |
| 13 | uint depth = uint(textureLod(depth_tex, coord, 0).r * (exp2(24.0) - 1.0f)); | ||
| 14 | uint stencil = uint(textureLod(stencil_tex, coord, 0).r); | ||
| 15 | |||
| 16 | highp uint depth_val = | 16 | highp uint depth_val = |
| 17 | uint(textureLod(depth_tex, coord, 0).r * (exp2(32.0) - 1.0)); | 17 | uint(textureLod(depth_tex, coord, 0).r * (exp2(32.0) - 1.0)); |
| 18 | lowp uint stencil_val = textureLod(stencil_tex, coord, 0).r; | 18 | lowp uint stencil_val = textureLod(stencil_tex, coord, 0).r; |
diff --git a/src/video_core/host_shaders/convert_s8d24_to_abgr8.frag b/src/video_core/host_shaders/convert_s8d24_to_abgr8.frag index 31db7d426..6a457981d 100644 --- a/src/video_core/host_shaders/convert_s8d24_to_abgr8.frag +++ b/src/video_core/host_shaders/convert_s8d24_to_abgr8.frag | |||
| @@ -3,16 +3,16 @@ | |||
| 3 | 3 | ||
| 4 | #version 450 | 4 | #version 450 |
| 5 | 5 | ||
| 6 | precision mediump int; | ||
| 7 | precision highp float; | ||
| 8 | |||
| 6 | layout(binding = 0) uniform sampler2D depth_tex; | 9 | layout(binding = 0) uniform sampler2D depth_tex; |
| 7 | layout(binding = 1) uniform isampler2D stencil_tex; | 10 | layout(binding = 1) uniform usampler2D stencil_tex; |
| 8 | 11 | ||
| 9 | layout(location = 0) out vec4 color; | 12 | layout(location = 0) out vec4 color; |
| 10 | 13 | ||
| 11 | void main() { | 14 | void main() { |
| 12 | ivec2 coord = ivec2(gl_FragCoord.xy); | 15 | ivec2 coord = ivec2(gl_FragCoord.xy); |
| 13 | uint depth = uint(textureLod(depth_tex, coord, 0).r * (exp2(24.0) - 1.0f)); | ||
| 14 | uint stencil = uint(textureLod(stencil_tex, coord, 0).r); | ||
| 15 | |||
| 16 | highp uint depth_val = | 16 | highp uint depth_val = |
| 17 | uint(textureLod(depth_tex, coord, 0).r * (exp2(32.0) - 1.0)); | 17 | uint(textureLod(depth_tex, coord, 0).r * (exp2(32.0) - 1.0)); |
| 18 | lowp uint stencil_val = textureLod(stencil_tex, coord, 0).r; | 18 | lowp uint stencil_val = textureLod(stencil_tex, coord, 0).r; |
diff --git a/src/video_core/renderer_vulkan/vk_query_cache.cpp b/src/video_core/renderer_vulkan/vk_query_cache.cpp index 2edaafa7e..66c03bf17 100644 --- a/src/video_core/renderer_vulkan/vk_query_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_query_cache.cpp | |||
| @@ -1436,6 +1436,7 @@ void QueryCacheRuntime::Barriers(bool is_prebarrier) { | |||
| 1436 | .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, | 1436 | .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, |
| 1437 | .dstAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT, | 1437 | .dstAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT, |
| 1438 | }; | 1438 | }; |
| 1439 | impl->scheduler.RequestOutsideRenderPassOperationContext(); | ||
| 1439 | if (is_prebarrier) { | 1440 | if (is_prebarrier) { |
| 1440 | impl->scheduler.Record([](vk::CommandBuffer cmdbuf) { | 1441 | impl->scheduler.Record([](vk::CommandBuffer cmdbuf) { |
| 1441 | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | 1442 | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 83f2b6045..61d03daae 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp | |||
| @@ -975,6 +975,19 @@ void RasterizerVulkan::UpdateScissorsState(Tegra::Engines::Maxwell3D::Regs& regs | |||
| 975 | if (!state_tracker.TouchScissors()) { | 975 | if (!state_tracker.TouchScissors()) { |
| 976 | return; | 976 | return; |
| 977 | } | 977 | } |
| 978 | if (!regs.viewport_scale_offset_enabled) { | ||
| 979 | const auto x = static_cast<float>(regs.surface_clip.x); | ||
| 980 | const auto y = static_cast<float>(regs.surface_clip.y); | ||
| 981 | const auto width = static_cast<float>(regs.surface_clip.width); | ||
| 982 | const auto height = static_cast<float>(regs.surface_clip.height); | ||
| 983 | VkRect2D scissor; | ||
| 984 | scissor.offset.x = static_cast<u32>(x); | ||
| 985 | scissor.offset.y = static_cast<u32>(y); | ||
| 986 | scissor.extent.width = static_cast<u32>(width != 0.0f ? width : 1.0f); | ||
| 987 | scissor.extent.height = static_cast<u32>(height != 0.0f ? height : 1.0f); | ||
| 988 | scheduler.Record([scissor](vk::CommandBuffer cmdbuf) { cmdbuf.SetScissor(0, scissor); }); | ||
| 989 | return; | ||
| 990 | } | ||
| 978 | u32 up_scale = 1; | 991 | u32 up_scale = 1; |
| 979 | u32 down_shift = 0; | 992 | u32 down_shift = 0; |
| 980 | if (texture_cache.IsRescaling()) { | 993 | if (texture_cache.IsRescaling()) { |
diff --git a/src/video_core/renderer_vulkan/vk_render_pass_cache.cpp b/src/video_core/renderer_vulkan/vk_render_pass_cache.cpp index ae9f1de64..7746a88d3 100644 --- a/src/video_core/renderer_vulkan/vk_render_pass_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_render_pass_cache.cpp | |||
| @@ -19,7 +19,7 @@ VkAttachmentDescription AttachmentDescription(const Device& device, PixelFormat | |||
| 19 | VkSampleCountFlagBits samples) { | 19 | VkSampleCountFlagBits samples) { |
| 20 | using MaxwellToVK::SurfaceFormat; | 20 | using MaxwellToVK::SurfaceFormat; |
| 21 | return { | 21 | return { |
| 22 | .flags = VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT, | 22 | .flags = {}, |
| 23 | .format = SurfaceFormat(device, FormatType::Optimal, true, format).format, | 23 | .format = SurfaceFormat(device, FormatType::Optimal, true, format).format, |
| 24 | .samples = samples, | 24 | .samples = samples, |
| 25 | .loadOp = VK_ATTACHMENT_LOAD_OP_LOAD, | 25 | .loadOp = VK_ATTACHMENT_LOAD_OP_LOAD, |
diff --git a/src/video_core/texture_cache/formatter.cpp b/src/video_core/texture_cache/formatter.cpp index 6279d8e9e..2b7e0df72 100644 --- a/src/video_core/texture_cache/formatter.cpp +++ b/src/video_core/texture_cache/formatter.cpp | |||
| @@ -10,19 +10,23 @@ | |||
| 10 | #include "video_core/texture_cache/image_info.h" | 10 | #include "video_core/texture_cache/image_info.h" |
| 11 | #include "video_core/texture_cache/image_view_base.h" | 11 | #include "video_core/texture_cache/image_view_base.h" |
| 12 | #include "video_core/texture_cache/render_targets.h" | 12 | #include "video_core/texture_cache/render_targets.h" |
| 13 | #include "video_core/texture_cache/samples_helper.h" | ||
| 13 | 14 | ||
| 14 | namespace VideoCommon { | 15 | namespace VideoCommon { |
| 15 | 16 | ||
| 16 | std::string Name(const ImageBase& image) { | 17 | std::string Name(const ImageBase& image) { |
| 17 | const GPUVAddr gpu_addr = image.gpu_addr; | 18 | const GPUVAddr gpu_addr = image.gpu_addr; |
| 18 | const ImageInfo& info = image.info; | 19 | const ImageInfo& info = image.info; |
| 19 | const u32 width = info.size.width; | 20 | u32 width = info.size.width; |
| 20 | const u32 height = info.size.height; | 21 | u32 height = info.size.height; |
| 21 | const u32 depth = info.size.depth; | 22 | const u32 depth = info.size.depth; |
| 22 | const u32 num_layers = image.info.resources.layers; | 23 | const u32 num_layers = image.info.resources.layers; |
| 23 | const u32 num_levels = image.info.resources.levels; | 24 | const u32 num_levels = image.info.resources.levels; |
| 24 | std::string resource; | 25 | std::string resource; |
| 25 | if (image.info.num_samples > 1) { | 26 | if (image.info.num_samples > 1) { |
| 27 | const auto [samples_x, samples_y] = VideoCommon::SamplesLog2(image.info.num_samples); | ||
| 28 | width >>= samples_x; | ||
| 29 | height >>= samples_y; | ||
| 26 | resource += fmt::format(":{}xMSAA", image.info.num_samples); | 30 | resource += fmt::format(":{}xMSAA", image.info.num_samples); |
| 27 | } | 31 | } |
| 28 | if (num_layers > 1) { | 32 | if (num_layers > 1) { |
diff --git a/src/video_core/texture_cache/samples_helper.h b/src/video_core/texture_cache/samples_helper.h index 203ac1b11..2ee2f8312 100644 --- a/src/video_core/texture_cache/samples_helper.h +++ b/src/video_core/texture_cache/samples_helper.h | |||
| @@ -24,7 +24,7 @@ namespace VideoCommon { | |||
| 24 | return {2, 2}; | 24 | return {2, 2}; |
| 25 | } | 25 | } |
| 26 | ASSERT_MSG(false, "Invalid number of samples={}", num_samples); | 26 | ASSERT_MSG(false, "Invalid number of samples={}", num_samples); |
| 27 | return {1, 1}; | 27 | return {0, 0}; |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | [[nodiscard]] inline int NumSamples(Tegra::Texture::MsaaMode msaa_mode) { | 30 | [[nodiscard]] inline int NumSamples(Tegra::Texture::MsaaMode msaa_mode) { |
diff --git a/src/video_core/texture_cache/util.cpp b/src/video_core/texture_cache/util.cpp index 8151cabf0..15596c925 100644 --- a/src/video_core/texture_cache/util.cpp +++ b/src/video_core/texture_cache/util.cpp | |||
| @@ -167,6 +167,13 @@ template <u32 GOB_EXTENT> | |||
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | [[nodiscard]] constexpr Extent3D TileShift(const LevelInfo& info, u32 level) { | 169 | [[nodiscard]] constexpr Extent3D TileShift(const LevelInfo& info, u32 level) { |
| 170 | if (level == 0 && info.num_levels == 1) { | ||
| 171 | return Extent3D{ | ||
| 172 | .width = info.block.width, | ||
| 173 | .height = info.block.height, | ||
| 174 | .depth = info.block.depth, | ||
| 175 | }; | ||
| 176 | } | ||
| 170 | const Extent3D blocks = NumLevelBlocks(info, level); | 177 | const Extent3D blocks = NumLevelBlocks(info, level); |
| 171 | return Extent3D{ | 178 | return Extent3D{ |
| 172 | .width = AdjustTileSize(info.block.width, GOB_SIZE_X, blocks.width), | 179 | .width = AdjustTileSize(info.block.width, GOB_SIZE_X, blocks.width), |
| @@ -1293,9 +1300,9 @@ u32 MapSizeBytes(const ImageBase& image) { | |||
| 1293 | 1300 | ||
| 1294 | static_assert(CalculateLevelSize(LevelInfo{{1920, 1080, 1}, {0, 2, 0}, {1, 1}, 2, 0, 1}, 0) == | 1301 | static_assert(CalculateLevelSize(LevelInfo{{1920, 1080, 1}, {0, 2, 0}, {1, 1}, 2, 0, 1}, 0) == |
| 1295 | 0x7f8000); | 1302 | 0x7f8000); |
| 1296 | static_assert(CalculateLevelSize(LevelInfo{{32, 32, 1}, {0, 0, 4}, {1, 1}, 4, 0, 1}, 0) == 0x4000); | 1303 | static_assert(CalculateLevelSize(LevelInfo{{32, 32, 1}, {0, 0, 4}, {1, 1}, 4, 0, 1}, 0) == 0x40000); |
| 1297 | 1304 | ||
| 1298 | static_assert(CalculateLevelSize(LevelInfo{{128, 8, 1}, {0, 4, 0}, {1, 1}, 4, 0, 1}, 0) == 0x4000); | 1305 | static_assert(CalculateLevelSize(LevelInfo{{128, 8, 1}, {0, 4, 0}, {1, 1}, 4, 0, 1}, 0) == 0x40000); |
| 1299 | 1306 | ||
| 1300 | static_assert(CalculateLevelOffset(PixelFormat::R8_SINT, {1920, 1080, 1}, {0, 2, 0}, 0, 7) == | 1307 | static_assert(CalculateLevelOffset(PixelFormat::R8_SINT, {1920, 1080, 1}, {0, 2, 0}, 0, 7) == |
| 1301 | 0x2afc00); | 1308 | 0x2afc00); |