Compare commits
37 Commits
__refs_pul
...
__refs_pul
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3cce51d25b | ||
|
|
4d395b3b72 | ||
|
|
b3e2c9f9f1 | ||
|
|
2a1acbfb4d | ||
|
|
a57150afbd | ||
|
|
60cc611f38 | ||
|
|
064bad6ddf | ||
|
|
007c3fa7df | ||
|
|
6c34adb1de | ||
|
|
9c6fc44a59 | ||
|
|
45f80f2b06 | ||
|
|
86cbd867d2 | ||
|
|
5c79a07a36 | ||
|
|
cfb76d8f3e | ||
|
|
6907d30258 | ||
|
|
219bd90152 | ||
|
|
f62f43c0da | ||
|
|
107aa52cdb | ||
|
|
238e46ec93 | ||
|
|
08ba16e105 | ||
|
|
099f3f639e | ||
|
|
4c9769d7ea | ||
|
|
9611a9e220 | ||
|
|
4d61319307 | ||
|
|
b854981917 | ||
|
|
d967ab8e79 | ||
|
|
7d5cc33feb | ||
|
|
0968e315f4 | ||
|
|
19d05bd4d7 | ||
|
|
a64ad8315f | ||
|
|
a2cfe3749a | ||
|
|
a0f235f4fd | ||
|
|
27313fe576 | ||
|
|
d0aa63069f | ||
|
|
1fc47361a1 | ||
|
|
cb0a410907 | ||
|
|
642c14f0c7 |
@@ -165,24 +165,3 @@ jobs:
|
||||
with:
|
||||
name: android
|
||||
path: artifacts/
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ android ]
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
steps:
|
||||
- uses: actions/download-artifact@v3
|
||||
- name: Create release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ github.ref_name }}
|
||||
release_name: ${{ github.ref_name }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
- name: Upload artifacts
|
||||
uses: alexellis/upload-assets@0.4.0
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
asset_paths: '["./**/*.tar.*","./**/*.AppImage","./**/*.7z","./**/*.zip","./**/*.apk","./**/*.aab"]'
|
||||
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -49,6 +49,6 @@
|
||||
[submodule "cpp-jwt"]
|
||||
path = externals/cpp-jwt
|
||||
url = https://github.com/arun11299/cpp-jwt.git
|
||||
[submodule "externals/libadrenotools"]
|
||||
[submodule "libadrenotools"]
|
||||
path = externals/libadrenotools
|
||||
url = https://github.com/bylaws/libadrenotools
|
||||
|
||||
@@ -255,7 +255,7 @@ endif()
|
||||
# boost asio's concept usage doesn't play nicely with some compilers yet.
|
||||
add_definitions(-DBOOST_ASIO_DISABLE_CONCEPTS)
|
||||
if (MSVC)
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/std:c++latest>)
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/std:c++20>)
|
||||
|
||||
# boost still makes use of deprecated result_of.
|
||||
add_definitions(-D_HAS_DEPRECATED_RESULT_OF)
|
||||
|
||||
@@ -43,7 +43,7 @@ if (MSVC)
|
||||
/Zo
|
||||
/permissive-
|
||||
/EHsc
|
||||
/std:c++latest
|
||||
/std:c++20
|
||||
/utf-8
|
||||
/volatile:iso
|
||||
/Zc:externConstexpr
|
||||
@@ -51,8 +51,10 @@ if (MSVC)
|
||||
/Zc:throwingNew
|
||||
/GT
|
||||
|
||||
# Modules
|
||||
/experimental:module- # Disable module support explicitly due to conflicts with precompiled headers
|
||||
|
||||
# External headers diagnostics
|
||||
/experimental:external # Enables the external headers options. This option isn't required in Visual Studio 2019 version 16.10 and later
|
||||
/external:anglebrackets # Treats all headers included by #include <header>, where the header file is enclosed in angle brackets (< >), as external headers
|
||||
/external:W0 # Sets the default warning level to 0 for external headers, effectively turning off warnings for external headers
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ android {
|
||||
applicationId = "org.yuzu.yuzu_emu"
|
||||
minSdk = 30
|
||||
targetSdk = 33
|
||||
versionCode = 1
|
||||
versionName = getGitVersion()
|
||||
|
||||
ndk {
|
||||
|
||||
@@ -6,17 +6,10 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<uses-feature
|
||||
android:name="android.hardware.touchscreen"
|
||||
android:required="false"/>
|
||||
<uses-feature
|
||||
android:name="android.hardware.gamepad"
|
||||
android:required="false"/>
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.vulkan.version"
|
||||
android:version="0x401000"
|
||||
android:required="true" />
|
||||
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.gamepad" android:required="false" />
|
||||
<uses-feature android:name="android.software.leanback" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.vulkan.version" android:version="0x401000" android:required="true" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
@@ -31,7 +24,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
android:hasFragileUserData="true"
|
||||
android:supportsRtl="true"
|
||||
android:isGame="true"
|
||||
android:banner="@drawable/ic_launcher"
|
||||
android:banner="@drawable/tv_banner"
|
||||
android:extractNativeLibs="true"
|
||||
android:fullBackupContent="@xml/data_extraction_rules"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules_api_31"
|
||||
@@ -44,9 +37,10 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
<!-- This intentfilter marks this Activity as the one that gets launched from Home screen. -->
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
|
||||
@@ -263,7 +263,8 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||
val config: Configuration = resources.configuration
|
||||
|
||||
if ((config.screenLayout and Configuration.SCREENLAYOUT_LONG_YES) != 0 ||
|
||||
(config.screenLayout and Configuration.SCREENLAYOUT_LONG_NO) == 0) {
|
||||
(config.screenLayout and Configuration.SCREENLAYOUT_LONG_NO) == 0 ||
|
||||
(config.screenLayout and Configuration.SCREENLAYOUT_SIZE_SMALL) != 0) {
|
||||
return rotation
|
||||
}
|
||||
when (rotation) {
|
||||
|
||||
@@ -765,18 +765,20 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context
|
||||
// If we have API access, calculate the safe area to draw the overlay
|
||||
var cutoutLeft = 0
|
||||
var cutoutBottom = 0
|
||||
val insets = context.windowManager.currentWindowMetrics.windowInsets.displayCutout
|
||||
if (insets != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
if (insets.boundingRectTop.bottom != 0 && insets.boundingRectTop.bottom > maxY / 2)
|
||||
insets.boundingRectTop.bottom.toFloat() else maxY
|
||||
if (insets.boundingRectRight.left != 0 && insets.boundingRectRight.left > maxX / 2)
|
||||
insets.boundingRectRight.left.toFloat() else maxX
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
val insets = context.windowManager.currentWindowMetrics.windowInsets.displayCutout
|
||||
if (insets != null) {
|
||||
if (insets.boundingRectTop.bottom != 0 && insets.boundingRectTop.bottom > maxY / 2)
|
||||
insets.boundingRectTop.bottom.toFloat() else maxY
|
||||
if (insets.boundingRectRight.left != 0 && insets.boundingRectRight.left > maxX / 2)
|
||||
insets.boundingRectRight.left.toFloat() else maxX
|
||||
|
||||
minX = insets.boundingRectLeft.right - insets.boundingRectLeft.left
|
||||
minY = insets.boundingRectBottom.top - insets.boundingRectBottom.bottom
|
||||
minX = insets.boundingRectLeft.right - insets.boundingRectLeft.left
|
||||
minY = insets.boundingRectBottom.top - insets.boundingRectBottom.bottom
|
||||
|
||||
cutoutLeft = insets.boundingRectRight.right - insets.boundingRectRight.left
|
||||
cutoutBottom = insets.boundingRectTop.top - insets.boundingRectTop.bottom
|
||||
cutoutLeft = insets.boundingRectRight.right - insets.boundingRectRight.left
|
||||
cutoutBottom = insets.boundingRectTop.top - insets.boundingRectTop.bottom
|
||||
}
|
||||
}
|
||||
|
||||
// This makes sure that if we have an inset on one side of the screen, we mirror it on
|
||||
|
||||
BIN
src/android/app/src/main/res/drawable-xhdpi/tv_banner.png
Normal file
BIN
src/android/app/src/main/res/drawable-xhdpi/tv_banner.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.6 KiB |
@@ -9,8 +9,9 @@
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||
org.gradle.jvmargs=-Xms512m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||
android.useAndroidX=true
|
||||
# Kotlin code style for this project: "official" or "obsolete":
|
||||
kotlin.code.style=official
|
||||
kotlin.parallel.tasks.in.project=true
|
||||
android.defaults.buildfeatures.buildconfig=true
|
||||
|
||||
@@ -47,12 +47,4 @@ AudioRenderer::ADSP::ADSP& AudioCore::GetADSP() {
|
||||
return *adsp;
|
||||
}
|
||||
|
||||
void AudioCore::SetNVDECActive(bool active) {
|
||||
nvdec_active = active;
|
||||
}
|
||||
|
||||
bool AudioCore::IsNVDECActive() const {
|
||||
return nvdec_active;
|
||||
}
|
||||
|
||||
} // namespace AudioCore
|
||||
|
||||
@@ -57,18 +57,6 @@ public:
|
||||
*/
|
||||
AudioRenderer::ADSP::ADSP& GetADSP();
|
||||
|
||||
/**
|
||||
* Toggle NVDEC state, used to avoid stall in playback.
|
||||
*
|
||||
* @param active - Set true if nvdec is active, otherwise false.
|
||||
*/
|
||||
void SetNVDECActive(bool active);
|
||||
|
||||
/**
|
||||
* Get NVDEC state.
|
||||
*/
|
||||
bool IsNVDECActive() const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Create the sinks on startup.
|
||||
@@ -83,8 +71,6 @@ private:
|
||||
std::unique_ptr<Sink::Sink> input_sink;
|
||||
/// The ADSP in the sysmodule
|
||||
std::unique_ptr<AudioRenderer::ADSP::ADSP> adsp;
|
||||
/// Is NVDec currently active?
|
||||
bool nvdec_active{false};
|
||||
};
|
||||
|
||||
} // namespace AudioCore
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
// Sub-directories contained within a yuzu data directory
|
||||
|
||||
#define AMIIBO_DIR "amiibo"
|
||||
#define CACHE_DIR "cache"
|
||||
#define CONFIG_DIR "config"
|
||||
#define DUMP_DIR "dump"
|
||||
|
||||
@@ -114,6 +114,7 @@ public:
|
||||
#endif
|
||||
|
||||
GenerateYuzuPath(YuzuPath::YuzuDir, yuzu_path);
|
||||
GenerateYuzuPath(YuzuPath::AmiiboDir, yuzu_path / AMIIBO_DIR);
|
||||
GenerateYuzuPath(YuzuPath::CacheDir, yuzu_path_cache);
|
||||
GenerateYuzuPath(YuzuPath::ConfigDir, yuzu_path_config);
|
||||
GenerateYuzuPath(YuzuPath::DumpDir, yuzu_path / DUMP_DIR);
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace Common::FS {
|
||||
|
||||
enum class YuzuPath {
|
||||
YuzuDir, // Where yuzu stores its data.
|
||||
AmiiboDir, // Where Amiibo backups are stored.
|
||||
CacheDir, // Where cached filesystem data is stored.
|
||||
ConfigDir, // Where config files are stored.
|
||||
DumpDir, // Where dumped data is stored.
|
||||
|
||||
@@ -235,6 +235,7 @@ void RestoreGlobalState(bool is_powered_on) {
|
||||
values.bg_green.SetGlobal(true);
|
||||
values.bg_blue.SetGlobal(true);
|
||||
values.enable_compute_pipelines.SetGlobal(true);
|
||||
values.use_video_framerate.SetGlobal(true);
|
||||
|
||||
// System
|
||||
values.language_index.SetGlobal(true);
|
||||
|
||||
@@ -482,6 +482,7 @@ struct Values {
|
||||
SwitchableSetting<AstcRecompression, true> astc_recompression{
|
||||
AstcRecompression::Uncompressed, AstcRecompression::Uncompressed, AstcRecompression::Bc3,
|
||||
"astc_recompression"};
|
||||
SwitchableSetting<bool> use_video_framerate{false, "use_video_framerate"};
|
||||
|
||||
SwitchableSetting<u8> bg_red{0, "bg_red"};
|
||||
SwitchableSetting<u8> bg_green{0, "bg_green"};
|
||||
|
||||
@@ -48,7 +48,7 @@ std::array<u8, 0x10> ConstructFromRawString(std::string_view raw_string) {
|
||||
}
|
||||
|
||||
std::array<u8, 0x10> ConstructFromFormattedString(std::string_view formatted_string) {
|
||||
std::array<u8, 0x10> uuid;
|
||||
std::array<u8, 0x10> uuid{};
|
||||
|
||||
size_t i = 0;
|
||||
|
||||
|
||||
@@ -216,6 +216,14 @@ struct System::Impl {
|
||||
}
|
||||
}
|
||||
|
||||
void SetNVDECActive(bool is_nvdec_active) {
|
||||
nvdec_active = is_nvdec_active;
|
||||
}
|
||||
|
||||
bool GetNVDECActive() {
|
||||
return nvdec_active;
|
||||
}
|
||||
|
||||
void InitializeDebugger(System& system, u16 port) {
|
||||
debugger = std::make_unique<Debugger>(system, port);
|
||||
}
|
||||
@@ -485,6 +493,8 @@ struct System::Impl {
|
||||
std::atomic_bool is_powered_on{};
|
||||
bool exit_lock = false;
|
||||
|
||||
bool nvdec_active{};
|
||||
|
||||
Reporter reporter;
|
||||
std::unique_ptr<Memory::CheatEngine> cheat_engine;
|
||||
std::unique_ptr<Tools::Freezer> memory_freezer;
|
||||
@@ -594,6 +604,14 @@ void System::UnstallApplication() {
|
||||
impl->UnstallApplication();
|
||||
}
|
||||
|
||||
void System::SetNVDECActive(bool is_nvdec_active) {
|
||||
impl->SetNVDECActive(is_nvdec_active);
|
||||
}
|
||||
|
||||
bool System::GetNVDECActive() {
|
||||
return impl->GetNVDECActive();
|
||||
}
|
||||
|
||||
void System::InitializeDebugger() {
|
||||
impl->InitializeDebugger(*this, Settings::values.gdbstub_port.GetValue());
|
||||
}
|
||||
|
||||
@@ -189,6 +189,9 @@ public:
|
||||
std::unique_lock<std::mutex> StallApplication();
|
||||
void UnstallApplication();
|
||||
|
||||
void SetNVDECActive(bool is_nvdec_active);
|
||||
[[nodiscard]] bool GetNVDECActive();
|
||||
|
||||
/**
|
||||
* Initialize the debugger.
|
||||
*/
|
||||
|
||||
@@ -23,8 +23,8 @@ const std::array<const char*, 16> LANGUAGE_NAMES{{
|
||||
"Portuguese",
|
||||
"Russian",
|
||||
"Korean",
|
||||
"Taiwanese",
|
||||
"Chinese",
|
||||
"TraditionalChinese",
|
||||
"SimplifiedChinese",
|
||||
"BrazilianPortuguese",
|
||||
}};
|
||||
|
||||
@@ -45,17 +45,17 @@ constexpr std::array<Language, 18> language_to_codes = {{
|
||||
Language::German,
|
||||
Language::Italian,
|
||||
Language::Spanish,
|
||||
Language::Chinese,
|
||||
Language::SimplifiedChinese,
|
||||
Language::Korean,
|
||||
Language::Dutch,
|
||||
Language::Portuguese,
|
||||
Language::Russian,
|
||||
Language::Taiwanese,
|
||||
Language::TraditionalChinese,
|
||||
Language::BritishEnglish,
|
||||
Language::CanadianFrench,
|
||||
Language::LatinAmericanSpanish,
|
||||
Language::Chinese,
|
||||
Language::Taiwanese,
|
||||
Language::SimplifiedChinese,
|
||||
Language::TraditionalChinese,
|
||||
Language::BrazilianPortuguese,
|
||||
}};
|
||||
|
||||
|
||||
@@ -84,8 +84,8 @@ enum class Language : u8 {
|
||||
Portuguese = 10,
|
||||
Russian = 11,
|
||||
Korean = 12,
|
||||
Taiwanese = 13,
|
||||
Chinese = 14,
|
||||
TraditionalChinese = 13,
|
||||
SimplifiedChinese = 14,
|
||||
BrazilianPortuguese = 15,
|
||||
|
||||
Default = 255,
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "core/file_sys/vfs_layered.h"
|
||||
#include "core/file_sys/vfs_vector.h"
|
||||
#include "core/hle/service/filesystem/filesystem.h"
|
||||
#include "core/hle/service/ns/language.h"
|
||||
#include "core/hle/service/set/set.h"
|
||||
#include "core/loader/loader.h"
|
||||
#include "core/loader/nso.h"
|
||||
#include "core/memory/cheat_engine.h"
|
||||
@@ -624,8 +626,37 @@ PatchManager::Metadata PatchManager::ParseControlNCA(const NCA& nca) const {
|
||||
|
||||
auto nacp = nacp_file == nullptr ? nullptr : std::make_unique<NACP>(nacp_file);
|
||||
|
||||
// Get language code from settings
|
||||
const auto language_code =
|
||||
Service::Set::GetLanguageCodeFromIndex(Settings::values.language_index.GetValue());
|
||||
|
||||
// Convert to application language and get priority list
|
||||
const auto application_language =
|
||||
Service::NS::ConvertToApplicationLanguage(language_code)
|
||||
.value_or(Service::NS::ApplicationLanguage::AmericanEnglish);
|
||||
const auto language_priority_list =
|
||||
Service::NS::GetApplicationLanguagePriorityList(application_language);
|
||||
|
||||
// Convert to language names
|
||||
auto priority_language_names = FileSys::LANGUAGE_NAMES; // Copy
|
||||
if (language_priority_list) {
|
||||
for (size_t i = 0; i < priority_language_names.size(); ++i) {
|
||||
// Relies on FileSys::LANGUAGE_NAMES being in the same order as
|
||||
// Service::NS::ApplicationLanguage
|
||||
const auto language_index = static_cast<u8>(language_priority_list->at(i));
|
||||
|
||||
if (language_index < FileSys::LANGUAGE_NAMES.size()) {
|
||||
priority_language_names[i] = FileSys::LANGUAGE_NAMES[language_index];
|
||||
} else {
|
||||
// Not a catastrophe, unlikely to happen
|
||||
LOG_WARNING(Loader, "Invalid language index {}", language_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get first matching icon
|
||||
VirtualFile icon_file;
|
||||
for (const auto& language : FileSys::LANGUAGE_NAMES) {
|
||||
for (const auto& language : priority_language_names) {
|
||||
icon_file = extracted->GetFile(std::string("icon_").append(language).append(".dat"));
|
||||
if (icon_file != nullptr) {
|
||||
break;
|
||||
|
||||
@@ -12,6 +12,11 @@
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "common/fs/file.h"
|
||||
#include "common/fs/fs.h"
|
||||
#include "common/fs/path_util.h"
|
||||
#include "common/input.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/string_util.h"
|
||||
@@ -136,7 +141,7 @@ bool NfcDevice::LoadNfcTag(std::span<const u8> data) {
|
||||
if (!NFP::AmiiboCrypto::IsKeyAvailable()) {
|
||||
LOG_INFO(Service_NFC, "Loading amiibo without keys");
|
||||
memcpy(&encrypted_tag_data, data.data(), sizeof(NFP::EncryptedNTAG215File));
|
||||
BuildAmiiboWithoutKeys();
|
||||
BuildAmiiboWithoutKeys(tag_data, encrypted_tag_data);
|
||||
is_plain_amiibo = true;
|
||||
is_write_protected = true;
|
||||
return true;
|
||||
@@ -366,16 +371,25 @@ Result NfcDevice::Mount(NFP::ModelType model_type, NFP::MountTarget mount_target
|
||||
|
||||
// The loaded amiibo is not encrypted
|
||||
if (is_plain_amiibo) {
|
||||
std::vector<u8> data(sizeof(NFP::NTAG215File));
|
||||
memcpy(data.data(), &tag_data, sizeof(tag_data));
|
||||
WriteBackupData(tag_data.uid, data);
|
||||
|
||||
device_state = DeviceState::TagMounted;
|
||||
mount_target = mount_target_;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
if (!NFP::AmiiboCrypto::DecodeAmiibo(encrypted_tag_data, tag_data)) {
|
||||
LOG_ERROR(Service_NFP, "Can't decode amiibo {}", device_state);
|
||||
return ResultCorruptedData;
|
||||
bool has_backup = HasBackup(encrypted_tag_data.uuid.uid).IsSuccess();
|
||||
LOG_ERROR(Service_NFP, "Can't decode amiibo, has_backup= {}", has_backup);
|
||||
return has_backup ? ResultCorruptedDataWithBackup : ResultCorruptedData;
|
||||
}
|
||||
|
||||
std::vector<u8> data(sizeof(NFP::EncryptedNTAG215File));
|
||||
memcpy(data.data(), &encrypted_tag_data, sizeof(encrypted_tag_data));
|
||||
WriteBackupData(encrypted_tag_data.uuid.uid, data);
|
||||
|
||||
device_state = DeviceState::TagMounted;
|
||||
mount_target = mount_target_;
|
||||
return ResultSuccess;
|
||||
@@ -470,6 +484,7 @@ Result NfcDevice::FlushWithBreak(NFP::BreakType break_type) {
|
||||
std::vector<u8> data(sizeof(NFP::EncryptedNTAG215File));
|
||||
if (is_plain_amiibo) {
|
||||
memcpy(data.data(), &tag_data, sizeof(tag_data));
|
||||
WriteBackupData(tag_data.uid, data);
|
||||
} else {
|
||||
if (!NFP::AmiiboCrypto::EncodeAmiibo(tag_data, encrypted_tag_data)) {
|
||||
LOG_ERROR(Service_NFP, "Failed to encode data");
|
||||
@@ -477,6 +492,7 @@ Result NfcDevice::FlushWithBreak(NFP::BreakType break_type) {
|
||||
}
|
||||
|
||||
memcpy(data.data(), &encrypted_tag_data, sizeof(encrypted_tag_data));
|
||||
WriteBackupData(encrypted_tag_data.uuid.uid, data);
|
||||
}
|
||||
|
||||
if (!npad_device->WriteNfc(data)) {
|
||||
@@ -488,7 +504,7 @@ Result NfcDevice::FlushWithBreak(NFP::BreakType break_type) {
|
||||
}
|
||||
|
||||
Result NfcDevice::Restore() {
|
||||
if (device_state != DeviceState::TagMounted) {
|
||||
if (device_state != DeviceState::TagFound) {
|
||||
LOG_ERROR(Service_NFP, "Wrong device state {}", device_state);
|
||||
if (device_state == DeviceState::TagRemoved) {
|
||||
return ResultTagRemoved;
|
||||
@@ -496,13 +512,59 @@ Result NfcDevice::Restore() {
|
||||
return ResultWrongDeviceState;
|
||||
}
|
||||
|
||||
if (mount_target == NFP::MountTarget::None || mount_target == NFP::MountTarget::Rom) {
|
||||
LOG_ERROR(Service_NFC, "Amiibo is read only", device_state);
|
||||
return ResultWrongDeviceState;
|
||||
NFC::TagInfo tag_info{};
|
||||
std::array<u8, sizeof(NFP::EncryptedNTAG215File)> data{};
|
||||
Result result = GetTagInfo(tag_info, false);
|
||||
|
||||
if (result.IsError()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// TODO: Load amiibo from backup on system
|
||||
LOG_ERROR(Service_NFP, "Not Implemented");
|
||||
result = ReadBackupData(tag_info.uuid, data);
|
||||
|
||||
if (result.IsError()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
NFP::NTAG215File temporary_tag_data{};
|
||||
NFP::EncryptedNTAG215File temporary_encrypted_tag_data{};
|
||||
|
||||
// Fallback for encrypted amiibos without keys
|
||||
if (is_write_protected) {
|
||||
return ResultWriteAmiiboFailed;
|
||||
}
|
||||
|
||||
// Fallback for plain amiibos
|
||||
if (is_plain_amiibo) {
|
||||
LOG_INFO(Service_NFP, "Restoring backup of plain amiibo");
|
||||
memcpy(&temporary_tag_data, data.data(), sizeof(NFP::EncryptedNTAG215File));
|
||||
temporary_encrypted_tag_data = NFP::AmiiboCrypto::EncodedDataToNfcData(temporary_tag_data);
|
||||
}
|
||||
|
||||
if (!is_plain_amiibo) {
|
||||
LOG_INFO(Service_NFP, "Restoring backup of encrypted amiibo");
|
||||
temporary_tag_data = {};
|
||||
memcpy(&temporary_encrypted_tag_data, data.data(), sizeof(NFP::EncryptedNTAG215File));
|
||||
}
|
||||
|
||||
if (!NFP::AmiiboCrypto::IsAmiiboValid(temporary_encrypted_tag_data)) {
|
||||
return ResultNotAnAmiibo;
|
||||
}
|
||||
|
||||
if (!is_plain_amiibo) {
|
||||
if (!NFP::AmiiboCrypto::DecodeAmiibo(temporary_encrypted_tag_data, temporary_tag_data)) {
|
||||
LOG_ERROR(Service_NFP, "Can't decode amiibo");
|
||||
return ResultCorruptedData;
|
||||
}
|
||||
}
|
||||
|
||||
// Overwrite tag contents with backup and mount the tag
|
||||
tag_data = temporary_tag_data;
|
||||
encrypted_tag_data = temporary_encrypted_tag_data;
|
||||
device_state = DeviceState::TagMounted;
|
||||
mount_target = NFP::MountTarget::All;
|
||||
is_data_moddified = true;
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
@@ -1132,13 +1194,69 @@ Result NfcDevice::BreakTag(NFP::BreakType break_type) {
|
||||
return FlushWithBreak(break_type);
|
||||
}
|
||||
|
||||
Result NfcDevice::ReadBackupData(std::span<u8> data) const {
|
||||
// Not implemented
|
||||
Result NfcDevice::HasBackup(const NFC::UniqueSerialNumber& uid) const {
|
||||
constexpr auto backup_dir = "backup";
|
||||
const auto yuzu_amiibo_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::AmiiboDir);
|
||||
const auto file_name = fmt::format("{0:02x}.bin", fmt::join(uid, ""));
|
||||
|
||||
if (!Common::FS::Exists(yuzu_amiibo_dir / backup_dir / file_name)) {
|
||||
return ResultUnableToAccessBackupFile;
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result NfcDevice::WriteBackupData(std::span<const u8> data) {
|
||||
// Not implemented
|
||||
Result NfcDevice::ReadBackupData(const NFC::UniqueSerialNumber& uid, std::span<u8> data) const {
|
||||
constexpr auto backup_dir = "backup";
|
||||
const auto yuzu_amiibo_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::AmiiboDir);
|
||||
const auto file_name = fmt::format("{0:02x}.bin", fmt::join(uid, ""));
|
||||
|
||||
const Common::FS::IOFile keys_file{yuzu_amiibo_dir / backup_dir / file_name,
|
||||
Common::FS::FileAccessMode::Read,
|
||||
Common::FS::FileType::BinaryFile};
|
||||
|
||||
if (!keys_file.IsOpen()) {
|
||||
LOG_ERROR(Service_NFP, "Failed to open amiibo backup");
|
||||
return ResultUnableToAccessBackupFile;
|
||||
}
|
||||
|
||||
if (keys_file.Read(data) != data.size()) {
|
||||
LOG_ERROR(Service_NFP, "Failed to read amiibo backup");
|
||||
return ResultUnableToAccessBackupFile;
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result NfcDevice::WriteBackupData(const NFC::UniqueSerialNumber& uid, std::span<const u8> data) {
|
||||
constexpr auto backup_dir = "backup";
|
||||
const auto yuzu_amiibo_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::AmiiboDir);
|
||||
const auto file_name = fmt::format("{0:02x}.bin", fmt::join(uid, ""));
|
||||
|
||||
if (HasBackup(uid).IsError()) {
|
||||
if (!Common::FS::CreateDir(yuzu_amiibo_dir / backup_dir)) {
|
||||
return ResultBackupPathAlreadyExist;
|
||||
}
|
||||
|
||||
if (!Common::FS::NewFile(yuzu_amiibo_dir / backup_dir / file_name)) {
|
||||
return ResultBackupPathAlreadyExist;
|
||||
}
|
||||
}
|
||||
|
||||
const Common::FS::IOFile keys_file{yuzu_amiibo_dir / backup_dir / file_name,
|
||||
Common::FS::FileAccessMode::ReadWrite,
|
||||
Common::FS::FileType::BinaryFile};
|
||||
|
||||
if (!keys_file.IsOpen()) {
|
||||
LOG_ERROR(Service_NFP, "Failed to open amiibo backup");
|
||||
return ResultUnableToAccessBackupFile;
|
||||
}
|
||||
|
||||
if (keys_file.Write(data) != data.size()) {
|
||||
LOG_ERROR(Service_NFP, "Failed to write amiibo backup");
|
||||
return ResultUnableToAccessBackupFile;
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
@@ -1177,7 +1295,8 @@ NFP::AmiiboName NfcDevice::GetAmiiboName(const NFP::AmiiboSettings& settings) co
|
||||
return amiibo_name;
|
||||
}
|
||||
|
||||
void NfcDevice::SetAmiiboName(NFP::AmiiboSettings& settings, const NFP::AmiiboName& amiibo_name) {
|
||||
void NfcDevice::SetAmiiboName(NFP::AmiiboSettings& settings,
|
||||
const NFP::AmiiboName& amiibo_name) const {
|
||||
std::array<char16_t, NFP::amiibo_name_length> settings_amiibo_name{};
|
||||
|
||||
// Convert from utf8 to utf16
|
||||
@@ -1258,22 +1377,23 @@ void NfcDevice::UpdateRegisterInfoCrc() {
|
||||
tag_data.register_info_crc = crc.checksum();
|
||||
}
|
||||
|
||||
void NfcDevice::BuildAmiiboWithoutKeys() {
|
||||
void NfcDevice::BuildAmiiboWithoutKeys(NFP::NTAG215File& stubbed_tag_data,
|
||||
const NFP::EncryptedNTAG215File& encrypted_file) const {
|
||||
Service::Mii::MiiManager manager;
|
||||
auto& settings = tag_data.settings;
|
||||
auto& settings = stubbed_tag_data.settings;
|
||||
|
||||
tag_data = NFP::AmiiboCrypto::NfcDataToEncodedData(encrypted_tag_data);
|
||||
stubbed_tag_data = NFP::AmiiboCrypto::NfcDataToEncodedData(encrypted_file);
|
||||
|
||||
// Common info
|
||||
tag_data.write_counter = 0;
|
||||
tag_data.amiibo_version = 0;
|
||||
stubbed_tag_data.write_counter = 0;
|
||||
stubbed_tag_data.amiibo_version = 0;
|
||||
settings.write_date = GetAmiiboDate(GetCurrentPosixTime());
|
||||
|
||||
// Register info
|
||||
SetAmiiboName(settings, {'y', 'u', 'z', 'u', 'A', 'm', 'i', 'i', 'b', 'o'});
|
||||
settings.settings.font_region.Assign(0);
|
||||
settings.init_date = GetAmiiboDate(GetCurrentPosixTime());
|
||||
tag_data.owner_mii = manager.BuildFromStoreData(manager.BuildDefault(0));
|
||||
stubbed_tag_data.owner_mii = manager.BuildFromStoreData(manager.BuildDefault(0));
|
||||
|
||||
// Admin info
|
||||
settings.settings.amiibo_initialized.Assign(1);
|
||||
|
||||
@@ -86,8 +86,9 @@ public:
|
||||
Result GetAll(NFP::NfpData& data) const;
|
||||
Result SetAll(const NFP::NfpData& data);
|
||||
Result BreakTag(NFP::BreakType break_type);
|
||||
Result ReadBackupData(std::span<u8> data) const;
|
||||
Result WriteBackupData(std::span<const u8> data);
|
||||
Result HasBackup(const NFC::UniqueSerialNumber& uid) const;
|
||||
Result ReadBackupData(const NFC::UniqueSerialNumber& uid, std::span<u8> data) const;
|
||||
Result WriteBackupData(const NFC::UniqueSerialNumber& uid, std::span<const u8> data);
|
||||
Result WriteNtf(std::span<const u8> data);
|
||||
|
||||
u64 GetHandle() const;
|
||||
@@ -103,14 +104,15 @@ private:
|
||||
void CloseNfcTag();
|
||||
|
||||
NFP::AmiiboName GetAmiiboName(const NFP::AmiiboSettings& settings) const;
|
||||
void SetAmiiboName(NFP::AmiiboSettings& settings, const NFP::AmiiboName& amiibo_name);
|
||||
void SetAmiiboName(NFP::AmiiboSettings& settings, const NFP::AmiiboName& amiibo_name) const;
|
||||
NFP::AmiiboDate GetAmiiboDate(s64 posix_time) const;
|
||||
u64 GetCurrentPosixTime() const;
|
||||
u64 RemoveVersionByte(u64 application_id) const;
|
||||
void UpdateSettingsCrc();
|
||||
void UpdateRegisterInfoCrc();
|
||||
|
||||
void BuildAmiiboWithoutKeys();
|
||||
void BuildAmiiboWithoutKeys(NFP::NTAG215File& stubbed_tag_data,
|
||||
const NFP::EncryptedNTAG215File& encrypted_file) const;
|
||||
|
||||
bool is_controller_set{};
|
||||
int callback_key;
|
||||
|
||||
@@ -543,9 +543,14 @@ Result DeviceManager::ReadBackupData(u64 device_handle, std::span<u8> data) cons
|
||||
|
||||
std::shared_ptr<NfcDevice> device = nullptr;
|
||||
auto result = GetDeviceHandle(device_handle, device);
|
||||
NFC::TagInfo tag_info{};
|
||||
|
||||
if (result.IsSuccess()) {
|
||||
result = device->ReadBackupData(data);
|
||||
result = device->GetTagInfo(tag_info, false);
|
||||
}
|
||||
|
||||
if (result.IsSuccess()) {
|
||||
result = device->ReadBackupData(tag_info.uuid, data);
|
||||
result = VerifyDeviceResult(device, result);
|
||||
}
|
||||
|
||||
@@ -557,9 +562,14 @@ Result DeviceManager::WriteBackupData(u64 device_handle, std::span<const u8> dat
|
||||
|
||||
std::shared_ptr<NfcDevice> device = nullptr;
|
||||
auto result = GetDeviceHandle(device_handle, device);
|
||||
NFC::TagInfo tag_info{};
|
||||
|
||||
if (result.IsSuccess()) {
|
||||
result = device->WriteBackupData(data);
|
||||
result = device->GetTagInfo(tag_info, false);
|
||||
}
|
||||
|
||||
if (result.IsSuccess()) {
|
||||
result = device->WriteBackupData(tag_info.uuid, data);
|
||||
result = VerifyDeviceResult(device, result);
|
||||
}
|
||||
|
||||
|
||||
@@ -302,7 +302,7 @@ Result NfcInterface::TranslateResultToServiceError(Result result) const {
|
||||
return TranslateResultToNfp(result);
|
||||
}
|
||||
default:
|
||||
if (result != ResultUnknown216) {
|
||||
if (result != ResultBackupPathAlreadyExist) {
|
||||
return result;
|
||||
}
|
||||
return ResultUnknown74;
|
||||
@@ -343,6 +343,9 @@ Result NfcInterface::TranslateResultToNfp(Result result) const {
|
||||
if (result == ResultApplicationAreaIsNotInitialized) {
|
||||
return NFP::ResultApplicationAreaIsNotInitialized;
|
||||
}
|
||||
if (result == ResultCorruptedDataWithBackup) {
|
||||
return NFP::ResultCorruptedDataWithBackup;
|
||||
}
|
||||
if (result == ResultCorruptedData) {
|
||||
return NFP::ResultCorruptedData;
|
||||
}
|
||||
@@ -355,6 +358,9 @@ Result NfcInterface::TranslateResultToNfp(Result result) const {
|
||||
if (result == ResultNotAnAmiibo) {
|
||||
return NFP::ResultNotAnAmiibo;
|
||||
}
|
||||
if (result == ResultUnableToAccessBackupFile) {
|
||||
return NFP::ResultUnableToAccessBackupFile;
|
||||
}
|
||||
LOG_WARNING(Service_NFC, "Result conversion not handled");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -9,20 +9,22 @@ namespace Service::NFC {
|
||||
|
||||
constexpr Result ResultDeviceNotFound(ErrorModule::NFC, 64);
|
||||
constexpr Result ResultInvalidArgument(ErrorModule::NFC, 65);
|
||||
constexpr Result ResultWrongApplicationAreaSize(ErrorModule::NFP, 68);
|
||||
constexpr Result ResultWrongApplicationAreaSize(ErrorModule::NFC, 68);
|
||||
constexpr Result ResultWrongDeviceState(ErrorModule::NFC, 73);
|
||||
constexpr Result ResultUnknown74(ErrorModule::NFC, 74);
|
||||
constexpr Result ResultUnknown76(ErrorModule::NFC, 76);
|
||||
constexpr Result ResultNfcNotInitialized(ErrorModule::NFC, 77);
|
||||
constexpr Result ResultNfcDisabled(ErrorModule::NFC, 80);
|
||||
constexpr Result ResultWriteAmiiboFailed(ErrorModule::NFP, 88);
|
||||
constexpr Result ResultWriteAmiiboFailed(ErrorModule::NFC, 88);
|
||||
constexpr Result ResultTagRemoved(ErrorModule::NFC, 97);
|
||||
constexpr Result ResultRegistrationIsNotInitialized(ErrorModule::NFP, 120);
|
||||
constexpr Result ResultApplicationAreaIsNotInitialized(ErrorModule::NFP, 128);
|
||||
constexpr Result ResultCorruptedData(ErrorModule::NFP, 144);
|
||||
constexpr Result ResultWrongApplicationAreaId(ErrorModule::NFP, 152);
|
||||
constexpr Result ResultApplicationAreaExist(ErrorModule::NFP, 168);
|
||||
constexpr Result ResultNotAnAmiibo(ErrorModule::NFP, 178);
|
||||
constexpr Result ResultUnknown216(ErrorModule::NFC, 216);
|
||||
constexpr Result ResultUnableToAccessBackupFile(ErrorModule::NFC, 113);
|
||||
constexpr Result ResultRegistrationIsNotInitialized(ErrorModule::NFC, 120);
|
||||
constexpr Result ResultApplicationAreaIsNotInitialized(ErrorModule::NFC, 128);
|
||||
constexpr Result ResultCorruptedDataWithBackup(ErrorModule::NFC, 136);
|
||||
constexpr Result ResultCorruptedData(ErrorModule::NFC, 144);
|
||||
constexpr Result ResultWrongApplicationAreaId(ErrorModule::NFC, 152);
|
||||
constexpr Result ResultApplicationAreaExist(ErrorModule::NFC, 168);
|
||||
constexpr Result ResultNotAnAmiibo(ErrorModule::NFC, 178);
|
||||
constexpr Result ResultBackupPathAlreadyExist(ErrorModule::NFC, 216);
|
||||
|
||||
} // namespace Service::NFC
|
||||
|
||||
@@ -126,7 +126,7 @@ void Interface::Flush(HLERequestContext& ctx) {
|
||||
void Interface::Restore(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto device_handle{rp.Pop<u64>()};
|
||||
LOG_WARNING(Service_NFP, "(STUBBED) called, device_handle={}", device_handle);
|
||||
LOG_INFO(Service_NFP, "called, device_handle={}", device_handle);
|
||||
|
||||
auto result = GetManager()->Restore(device_handle);
|
||||
result = TranslateResultToServiceError(result);
|
||||
@@ -394,7 +394,7 @@ void Interface::BreakTag(HLERequestContext& ctx) {
|
||||
void Interface::ReadBackupData(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto device_handle{rp.Pop<u64>()};
|
||||
LOG_WARNING(Service_NFP, "(STUBBED) called, device_handle={}", device_handle);
|
||||
LOG_INFO(Service_NFP, "called, device_handle={}", device_handle);
|
||||
|
||||
std::vector<u8> backup_data{};
|
||||
auto result = GetManager()->ReadBackupData(device_handle, backup_data);
|
||||
@@ -412,7 +412,7 @@ void Interface::WriteBackupData(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto device_handle{rp.Pop<u64>()};
|
||||
const auto backup_data_buffer{ctx.ReadBuffer()};
|
||||
LOG_WARNING(Service_NFP, "(STUBBED) called, device_handle={}", device_handle);
|
||||
LOG_INFO(Service_NFP, "called, device_handle={}", device_handle);
|
||||
|
||||
auto result = GetManager()->WriteBackupData(device_handle, backup_data_buffer);
|
||||
result = TranslateResultToServiceError(result);
|
||||
|
||||
@@ -17,9 +17,11 @@ constexpr Result ResultWriteAmiiboFailed(ErrorModule::NFP, 88);
|
||||
constexpr Result ResultTagRemoved(ErrorModule::NFP, 97);
|
||||
constexpr Result ResultRegistrationIsNotInitialized(ErrorModule::NFP, 120);
|
||||
constexpr Result ResultApplicationAreaIsNotInitialized(ErrorModule::NFP, 128);
|
||||
constexpr Result ResultCorruptedDataWithBackup(ErrorModule::NFP, 136);
|
||||
constexpr Result ResultCorruptedData(ErrorModule::NFP, 144);
|
||||
constexpr Result ResultWrongApplicationAreaId(ErrorModule::NFP, 152);
|
||||
constexpr Result ResultApplicationAreaExist(ErrorModule::NFP, 168);
|
||||
constexpr Result ResultNotAnAmiibo(ErrorModule::NFP, 178);
|
||||
constexpr Result ResultUnableToAccessBackupFile(ErrorModule::NFP, 200);
|
||||
|
||||
} // namespace Service::NFP
|
||||
|
||||
@@ -69,7 +69,7 @@ NvResult nvhost_nvdec::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> in
|
||||
|
||||
void nvhost_nvdec::OnOpen(DeviceFD fd) {
|
||||
LOG_INFO(Service_NVDRV, "NVDEC video stream started");
|
||||
system.AudioCore().SetNVDECActive(true);
|
||||
system.SetNVDECActive(true);
|
||||
}
|
||||
|
||||
void nvhost_nvdec::OnClose(DeviceFD fd) {
|
||||
@@ -79,7 +79,7 @@ void nvhost_nvdec::OnClose(DeviceFD fd) {
|
||||
if (iter != host1x_file.fd_to_id.end()) {
|
||||
system.GPU().ClearCdmaInstance(iter->second);
|
||||
}
|
||||
system.AudioCore().SetNVDECActive(false);
|
||||
system.SetNVDECActive(false);
|
||||
}
|
||||
|
||||
} // namespace Service::Nvidia::Devices
|
||||
|
||||
@@ -324,6 +324,10 @@ s64 Nvnflinger::GetNextTicks() const {
|
||||
speed_scale = 0.01f;
|
||||
}
|
||||
}
|
||||
if (system.GetNVDECActive() && settings.use_video_framerate.GetValue()) {
|
||||
// Run at intended presentation rate during video playback.
|
||||
speed_scale = 1.f;
|
||||
}
|
||||
|
||||
// As an extension, treat nonpositive swap interval as framerate multiplier.
|
||||
const f32 effective_fps = swap_interval <= 0 ? 120.f * static_cast<f32>(1 - swap_interval)
|
||||
|
||||
@@ -133,8 +133,8 @@ add_library(video_core STATIC
|
||||
renderer_opengl/gl_shader_util.h
|
||||
renderer_opengl/gl_state_tracker.cpp
|
||||
renderer_opengl/gl_state_tracker.h
|
||||
renderer_opengl/gl_stream_buffer.cpp
|
||||
renderer_opengl/gl_stream_buffer.h
|
||||
renderer_opengl/gl_staging_buffer_pool.cpp
|
||||
renderer_opengl/gl_staging_buffer_pool.h
|
||||
renderer_opengl/gl_texture_cache.cpp
|
||||
renderer_opengl/gl_texture_cache.h
|
||||
renderer_opengl/gl_texture_cache_base.cpp
|
||||
|
||||
@@ -478,7 +478,6 @@ void BufferCache<P>::CommitAsyncFlushesHigh() {
|
||||
|
||||
if (committed_ranges.empty()) {
|
||||
if constexpr (IMPLEMENTS_ASYNC_DOWNLOADS) {
|
||||
|
||||
async_buffers.emplace_back(std::optional<Async_Buffer>{});
|
||||
}
|
||||
return;
|
||||
@@ -539,7 +538,6 @@ void BufferCache<P>::CommitAsyncFlushesHigh() {
|
||||
committed_ranges.clear();
|
||||
if (downloads.empty()) {
|
||||
if constexpr (IMPLEMENTS_ASYNC_DOWNLOADS) {
|
||||
|
||||
async_buffers.emplace_back(std::optional<Async_Buffer>{});
|
||||
}
|
||||
return;
|
||||
@@ -691,7 +689,7 @@ void BufferCache<P>::BindHostIndexBuffer() {
|
||||
const u32 size = channel_state->index_buffer.size;
|
||||
const auto& draw_state = maxwell3d->draw_manager->GetDrawState();
|
||||
if (!draw_state.inline_index_draw_indexes.empty()) [[unlikely]] {
|
||||
if constexpr (USE_MEMORY_MAPS) {
|
||||
if constexpr (USE_MEMORY_MAPS_FOR_UPLOADS) {
|
||||
auto upload_staging = runtime.UploadStagingBuffer(size);
|
||||
std::array<BufferCopy, 1> copies{
|
||||
{BufferCopy{.src_offset = upload_staging.offset, .dst_offset = 0, .size = size}}};
|
||||
@@ -1462,7 +1460,7 @@ bool BufferCache<P>::SynchronizeBufferNoModified(Buffer& buffer, VAddr cpu_addr,
|
||||
template <class P>
|
||||
void BufferCache<P>::UploadMemory(Buffer& buffer, u64 total_size_bytes, u64 largest_copy,
|
||||
std::span<BufferCopy> copies) {
|
||||
if constexpr (USE_MEMORY_MAPS) {
|
||||
if constexpr (USE_MEMORY_MAPS_FOR_UPLOADS) {
|
||||
MappedUploadMemory(buffer, total_size_bytes, copies);
|
||||
} else {
|
||||
ImmediateUploadMemory(buffer, largest_copy, copies);
|
||||
@@ -1473,7 +1471,7 @@ template <class P>
|
||||
void BufferCache<P>::ImmediateUploadMemory([[maybe_unused]] Buffer& buffer,
|
||||
[[maybe_unused]] u64 largest_copy,
|
||||
[[maybe_unused]] std::span<const BufferCopy> copies) {
|
||||
if constexpr (!USE_MEMORY_MAPS) {
|
||||
if constexpr (!USE_MEMORY_MAPS_FOR_UPLOADS) {
|
||||
std::span<u8> immediate_buffer;
|
||||
for (const BufferCopy& copy : copies) {
|
||||
std::span<const u8> upload_span;
|
||||
@@ -1532,7 +1530,7 @@ bool BufferCache<P>::InlineMemory(VAddr dest_address, size_t copy_size,
|
||||
auto& buffer = slot_buffers[buffer_id];
|
||||
SynchronizeBuffer(buffer, dest_address, static_cast<u32>(copy_size));
|
||||
|
||||
if constexpr (USE_MEMORY_MAPS) {
|
||||
if constexpr (USE_MEMORY_MAPS_FOR_UPLOADS) {
|
||||
auto upload_staging = runtime.UploadStagingBuffer(copy_size);
|
||||
std::array copies{BufferCopy{
|
||||
.src_offset = upload_staging.offset,
|
||||
|
||||
@@ -173,6 +173,7 @@ class BufferCache : public VideoCommon::ChannelSetupCaches<BufferCacheChannelInf
|
||||
static constexpr bool USE_MEMORY_MAPS = P::USE_MEMORY_MAPS;
|
||||
static constexpr bool SEPARATE_IMAGE_BUFFERS_BINDINGS = P::SEPARATE_IMAGE_BUFFER_BINDINGS;
|
||||
static constexpr bool IMPLEMENTS_ASYNC_DOWNLOADS = P::IMPLEMENTS_ASYNC_DOWNLOADS;
|
||||
static constexpr bool USE_MEMORY_MAPS_FOR_UPLOADS = P::USE_MEMORY_MAPS_FOR_UPLOADS;
|
||||
|
||||
static constexpr s64 DEFAULT_EXPECTED_MEMORY = 512_MiB;
|
||||
static constexpr s64 DEFAULT_CRITICAL_MEMORY = 1_GiB;
|
||||
|
||||
@@ -106,8 +106,10 @@ GLuint Buffer::View(u32 offset, u32 size, PixelFormat format) {
|
||||
return views.back().texture.handle;
|
||||
}
|
||||
|
||||
BufferCacheRuntime::BufferCacheRuntime(const Device& device_)
|
||||
: device{device_}, has_fast_buffer_sub_data{device.HasFastBufferSubData()},
|
||||
BufferCacheRuntime::BufferCacheRuntime(const Device& device_,
|
||||
StagingBufferPool& staging_buffer_pool_)
|
||||
: device{device_}, staging_buffer_pool{staging_buffer_pool_},
|
||||
has_fast_buffer_sub_data{device.HasFastBufferSubData()},
|
||||
use_assembly_shaders{device.UseAssemblyShaders()},
|
||||
has_unified_vertex_buffers{device.HasVertexBufferUnifiedMemory()},
|
||||
stream_buffer{has_fast_buffer_sub_data ? std::nullopt : std::make_optional<StreamBuffer>()} {
|
||||
@@ -140,6 +142,14 @@ BufferCacheRuntime::BufferCacheRuntime(const Device& device_)
|
||||
}();
|
||||
}
|
||||
|
||||
StagingBufferMap BufferCacheRuntime::UploadStagingBuffer(size_t size) {
|
||||
return staging_buffer_pool.RequestUploadBuffer(size);
|
||||
}
|
||||
|
||||
StagingBufferMap BufferCacheRuntime::DownloadStagingBuffer(size_t size) {
|
||||
return staging_buffer_pool.RequestDownloadBuffer(size);
|
||||
}
|
||||
|
||||
u64 BufferCacheRuntime::GetDeviceMemoryUsage() const {
|
||||
if (device.CanReportMemoryUsage()) {
|
||||
return device_access_memory - device.GetCurrentDedicatedVideoMemory();
|
||||
@@ -147,13 +157,47 @@ u64 BufferCacheRuntime::GetDeviceMemoryUsage() const {
|
||||
return 2_GiB;
|
||||
}
|
||||
|
||||
void BufferCacheRuntime::CopyBuffer(GLuint dst_buffer, GLuint src_buffer,
|
||||
std::span<const VideoCommon::BufferCopy> copies, bool barrier) {
|
||||
if (barrier) {
|
||||
PreCopyBarrier();
|
||||
}
|
||||
for (const VideoCommon::BufferCopy& copy : copies) {
|
||||
glCopyNamedBufferSubData(src_buffer, dst_buffer, static_cast<GLintptr>(copy.src_offset),
|
||||
static_cast<GLintptr>(copy.dst_offset),
|
||||
static_cast<GLsizeiptr>(copy.size));
|
||||
}
|
||||
if (barrier) {
|
||||
PostCopyBarrier();
|
||||
}
|
||||
}
|
||||
|
||||
void BufferCacheRuntime::CopyBuffer(GLuint dst_buffer, Buffer& src_buffer,
|
||||
std::span<const VideoCommon::BufferCopy> copies, bool barrier) {
|
||||
CopyBuffer(dst_buffer, src_buffer.Handle(), copies, barrier);
|
||||
}
|
||||
|
||||
void BufferCacheRuntime::CopyBuffer(Buffer& dst_buffer, GLuint src_buffer,
|
||||
std::span<const VideoCommon::BufferCopy> copies, bool barrier) {
|
||||
CopyBuffer(dst_buffer.Handle(), src_buffer, copies, barrier);
|
||||
}
|
||||
|
||||
void BufferCacheRuntime::CopyBuffer(Buffer& dst_buffer, Buffer& src_buffer,
|
||||
std::span<const VideoCommon::BufferCopy> copies) {
|
||||
for (const VideoCommon::BufferCopy& copy : copies) {
|
||||
glCopyNamedBufferSubData(
|
||||
src_buffer.Handle(), dst_buffer.Handle(), static_cast<GLintptr>(copy.src_offset),
|
||||
static_cast<GLintptr>(copy.dst_offset), static_cast<GLsizeiptr>(copy.size));
|
||||
}
|
||||
CopyBuffer(dst_buffer.Handle(), src_buffer.Handle(), copies);
|
||||
}
|
||||
|
||||
void BufferCacheRuntime::PreCopyBarrier() {
|
||||
// TODO: finer grained barrier?
|
||||
glMemoryBarrier(GL_ALL_BARRIER_BITS);
|
||||
}
|
||||
|
||||
void BufferCacheRuntime::PostCopyBarrier() {
|
||||
glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT | GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT);
|
||||
}
|
||||
|
||||
void BufferCacheRuntime::Finish() {
|
||||
glFinish();
|
||||
}
|
||||
|
||||
void BufferCacheRuntime::ClearBuffer(Buffer& dest_buffer, u32 offset, size_t size, u32 value) {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "video_core/rasterizer_interface.h"
|
||||
#include "video_core/renderer_opengl/gl_device.h"
|
||||
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
||||
#include "video_core/renderer_opengl/gl_stream_buffer.h"
|
||||
#include "video_core/renderer_opengl/gl_staging_buffer_pool.h"
|
||||
|
||||
namespace OpenGL {
|
||||
|
||||
@@ -60,11 +60,28 @@ class BufferCacheRuntime {
|
||||
public:
|
||||
static constexpr u8 INVALID_BINDING = std::numeric_limits<u8>::max();
|
||||
|
||||
explicit BufferCacheRuntime(const Device& device_);
|
||||
explicit BufferCacheRuntime(const Device& device_, StagingBufferPool& staging_buffer_pool_);
|
||||
|
||||
[[nodiscard]] StagingBufferMap UploadStagingBuffer(size_t size);
|
||||
|
||||
[[nodiscard]] StagingBufferMap DownloadStagingBuffer(size_t size);
|
||||
|
||||
void CopyBuffer(GLuint dst_buffer, GLuint src_buffer,
|
||||
std::span<const VideoCommon::BufferCopy> copies, bool barrier = true);
|
||||
|
||||
void CopyBuffer(GLuint dst_buffer, Buffer& src_buffer,
|
||||
std::span<const VideoCommon::BufferCopy> copies, bool barrier = true);
|
||||
|
||||
void CopyBuffer(Buffer& dst_buffer, GLuint src_buffer,
|
||||
std::span<const VideoCommon::BufferCopy> copies, bool barrier = true);
|
||||
|
||||
void CopyBuffer(Buffer& dst_buffer, Buffer& src_buffer,
|
||||
std::span<const VideoCommon::BufferCopy> copies);
|
||||
|
||||
void PreCopyBarrier();
|
||||
void PostCopyBarrier();
|
||||
void Finish();
|
||||
|
||||
void ClearBuffer(Buffer& dest_buffer, u32 offset, size_t size, u32 value);
|
||||
|
||||
void BindIndexBuffer(Buffer& buffer, u32 offset, u32 size);
|
||||
@@ -169,6 +186,7 @@ private:
|
||||
};
|
||||
|
||||
const Device& device;
|
||||
StagingBufferPool& staging_buffer_pool;
|
||||
|
||||
bool has_fast_buffer_sub_data = false;
|
||||
bool use_assembly_shaders = false;
|
||||
@@ -201,7 +219,7 @@ private:
|
||||
struct BufferCacheParams {
|
||||
using Runtime = OpenGL::BufferCacheRuntime;
|
||||
using Buffer = OpenGL::Buffer;
|
||||
using Async_Buffer = u32;
|
||||
using Async_Buffer = OpenGL::StagingBufferMap;
|
||||
using MemoryTracker = VideoCommon::MemoryTrackerBase<VideoCore::RasterizerInterface>;
|
||||
|
||||
static constexpr bool IS_OPENGL = true;
|
||||
@@ -209,9 +227,12 @@ struct BufferCacheParams {
|
||||
static constexpr bool HAS_FULL_INDEX_AND_PRIMITIVE_SUPPORT = true;
|
||||
static constexpr bool NEEDS_BIND_UNIFORM_INDEX = true;
|
||||
static constexpr bool NEEDS_BIND_STORAGE_INDEX = true;
|
||||
static constexpr bool USE_MEMORY_MAPS = false;
|
||||
static constexpr bool USE_MEMORY_MAPS = true;
|
||||
static constexpr bool SEPARATE_IMAGE_BUFFER_BINDINGS = true;
|
||||
static constexpr bool IMPLEMENTS_ASYNC_DOWNLOADS = false;
|
||||
|
||||
// TODO: Investigate why OpenGL seems to perform worse with persistently mapped buffer uploads
|
||||
static constexpr bool USE_MEMORY_MAPS_FOR_UPLOADS = false;
|
||||
};
|
||||
|
||||
using BufferCache = VideoCommon::BufferCache<BufferCacheParams>;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "video_core/renderer_opengl/gl_query_cache.h"
|
||||
#include "video_core/renderer_opengl/gl_rasterizer.h"
|
||||
#include "video_core/renderer_opengl/gl_shader_cache.h"
|
||||
#include "video_core/renderer_opengl/gl_staging_buffer_pool.h"
|
||||
#include "video_core/renderer_opengl/gl_texture_cache.h"
|
||||
#include "video_core/renderer_opengl/maxwell_to_gl.h"
|
||||
#include "video_core/renderer_opengl/renderer_opengl.h"
|
||||
@@ -58,8 +59,9 @@ RasterizerOpenGL::RasterizerOpenGL(Core::Frontend::EmuWindow& emu_window_, Tegra
|
||||
StateTracker& state_tracker_)
|
||||
: RasterizerAccelerated(cpu_memory_), gpu(gpu_), device(device_), screen_info(screen_info_),
|
||||
program_manager(program_manager_), state_tracker(state_tracker_),
|
||||
texture_cache_runtime(device, program_manager, state_tracker),
|
||||
texture_cache(texture_cache_runtime, *this), buffer_cache_runtime(device),
|
||||
texture_cache_runtime(device, program_manager, state_tracker, staging_buffer_pool),
|
||||
texture_cache(texture_cache_runtime, *this),
|
||||
buffer_cache_runtime(device, staging_buffer_pool),
|
||||
buffer_cache(*this, cpu_memory_, buffer_cache_runtime),
|
||||
shader_cache(*this, emu_window_, device, texture_cache, buffer_cache, program_manager,
|
||||
state_tracker, gpu.ShaderNotify()),
|
||||
|
||||
@@ -230,6 +230,7 @@ private:
|
||||
ProgramManager& program_manager;
|
||||
StateTracker& state_tracker;
|
||||
|
||||
StagingBufferPool staging_buffer_pool;
|
||||
TextureCacheRuntime texture_cache_runtime;
|
||||
TextureCache texture_cache;
|
||||
BufferCacheRuntime buffer_cache_runtime;
|
||||
|
||||
150
src/video_core/renderer_opengl/gl_staging_buffer_pool.cpp
Normal file
150
src/video_core/renderer_opengl/gl_staging_buffer_pool.cpp
Normal file
@@ -0,0 +1,150 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
|
||||
#include <glad/glad.h>
|
||||
|
||||
#include "common/alignment.h"
|
||||
#include "common/assert.h"
|
||||
#include "common/bit_util.h"
|
||||
#include "common/microprofile.h"
|
||||
#include "video_core/renderer_opengl/gl_staging_buffer_pool.h"
|
||||
|
||||
MICROPROFILE_DEFINE(OpenGL_BufferRequest, "OpenGL", "BufferRequest", MP_RGB(128, 128, 192));
|
||||
|
||||
namespace OpenGL {
|
||||
|
||||
StagingBufferMap::~StagingBufferMap() {
|
||||
if (sync) {
|
||||
sync->Create();
|
||||
}
|
||||
}
|
||||
|
||||
StagingBuffers::StagingBuffers(GLenum storage_flags_, GLenum map_flags_)
|
||||
: storage_flags{storage_flags_}, map_flags{map_flags_} {}
|
||||
|
||||
StagingBuffers::~StagingBuffers() = default;
|
||||
|
||||
StagingBufferMap StagingBuffers::RequestMap(size_t requested_size, bool insert_fence) {
|
||||
MICROPROFILE_SCOPE(OpenGL_BufferRequest);
|
||||
|
||||
const size_t index = RequestBuffer(requested_size);
|
||||
OGLSync* const sync = insert_fence ? &syncs[index] : nullptr;
|
||||
sync_indices[index] = insert_fence ? ++current_sync_index : 0;
|
||||
return StagingBufferMap{
|
||||
.mapped_span = std::span(maps[index], requested_size),
|
||||
.sync = sync,
|
||||
.buffer = buffers[index].handle,
|
||||
};
|
||||
}
|
||||
|
||||
size_t StagingBuffers::RequestBuffer(size_t requested_size) {
|
||||
if (const std::optional<size_t> index = FindBuffer(requested_size); index) {
|
||||
return *index;
|
||||
}
|
||||
|
||||
OGLBuffer& buffer = buffers.emplace_back();
|
||||
buffer.Create();
|
||||
const auto next_pow2_size = Common::NextPow2(requested_size);
|
||||
glNamedBufferStorage(buffer.handle, next_pow2_size, nullptr,
|
||||
storage_flags | GL_MAP_PERSISTENT_BIT);
|
||||
maps.push_back(static_cast<u8*>(glMapNamedBufferRange(buffer.handle, 0, next_pow2_size,
|
||||
map_flags | GL_MAP_PERSISTENT_BIT)));
|
||||
syncs.emplace_back();
|
||||
sync_indices.emplace_back();
|
||||
sizes.push_back(next_pow2_size);
|
||||
|
||||
ASSERT(syncs.size() == buffers.size() && buffers.size() == maps.size() &&
|
||||
maps.size() == sizes.size());
|
||||
|
||||
return buffers.size() - 1;
|
||||
}
|
||||
|
||||
std::optional<size_t> StagingBuffers::FindBuffer(size_t requested_size) {
|
||||
size_t known_unsignaled_index = current_sync_index + 1;
|
||||
size_t smallest_buffer = std::numeric_limits<size_t>::max();
|
||||
std::optional<size_t> found;
|
||||
const size_t num_buffers = sizes.size();
|
||||
for (size_t index = 0; index < num_buffers; ++index) {
|
||||
const size_t buffer_size = sizes[index];
|
||||
if (buffer_size < requested_size || buffer_size >= smallest_buffer) {
|
||||
continue;
|
||||
}
|
||||
if (syncs[index].handle != 0) {
|
||||
if (sync_indices[index] >= known_unsignaled_index) {
|
||||
// This fence is later than a fence that is known to not be signaled
|
||||
continue;
|
||||
}
|
||||
if (!syncs[index].IsSignaled()) {
|
||||
// Since this fence hasn't been signaled, it's safe to assume all later
|
||||
// fences haven't been signaled either
|
||||
known_unsignaled_index = std::min(known_unsignaled_index, sync_indices[index]);
|
||||
continue;
|
||||
}
|
||||
syncs[index].Release();
|
||||
}
|
||||
smallest_buffer = buffer_size;
|
||||
found = index;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
StreamBuffer::StreamBuffer() {
|
||||
static constexpr GLenum flags = GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT;
|
||||
buffer.Create();
|
||||
glObjectLabel(GL_BUFFER, buffer.handle, -1, "Stream Buffer");
|
||||
glNamedBufferStorage(buffer.handle, STREAM_BUFFER_SIZE, nullptr, flags);
|
||||
mapped_pointer =
|
||||
static_cast<u8*>(glMapNamedBufferRange(buffer.handle, 0, STREAM_BUFFER_SIZE, flags));
|
||||
for (OGLSync& sync : fences) {
|
||||
sync.Create();
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<std::span<u8>, size_t> StreamBuffer::Request(size_t size) noexcept {
|
||||
ASSERT(size < REGION_SIZE);
|
||||
for (size_t region = Region(used_iterator), region_end = Region(iterator); region < region_end;
|
||||
++region) {
|
||||
fences[region].Create();
|
||||
}
|
||||
used_iterator = iterator;
|
||||
|
||||
for (size_t region = Region(free_iterator) + 1,
|
||||
region_end = std::min(Region(iterator + size) + 1, NUM_SYNCS);
|
||||
region < region_end; ++region) {
|
||||
glClientWaitSync(fences[region].handle, 0, GL_TIMEOUT_IGNORED);
|
||||
fences[region].Release();
|
||||
}
|
||||
if (iterator + size >= free_iterator) {
|
||||
free_iterator = iterator + size;
|
||||
}
|
||||
if (iterator + size > STREAM_BUFFER_SIZE) {
|
||||
for (size_t region = Region(used_iterator); region < NUM_SYNCS; ++region) {
|
||||
fences[region].Create();
|
||||
}
|
||||
used_iterator = 0;
|
||||
iterator = 0;
|
||||
free_iterator = size;
|
||||
|
||||
for (size_t region = 0, region_end = Region(size); region <= region_end; ++region) {
|
||||
glClientWaitSync(fences[region].handle, 0, GL_TIMEOUT_IGNORED);
|
||||
fences[region].Release();
|
||||
}
|
||||
}
|
||||
const size_t offset = iterator;
|
||||
iterator = Common::AlignUp(iterator + size, MAX_ALIGNMENT);
|
||||
return {std::span(mapped_pointer + offset, size), offset};
|
||||
}
|
||||
|
||||
StagingBufferMap StagingBufferPool::RequestUploadBuffer(size_t size) {
|
||||
return upload_buffers.RequestMap(size, true);
|
||||
}
|
||||
|
||||
StagingBufferMap StagingBufferPool::RequestDownloadBuffer(size_t size) {
|
||||
return download_buffers.RequestMap(size, false);
|
||||
}
|
||||
|
||||
} // namespace OpenGL
|
||||
@@ -4,8 +4,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <glad/glad.h>
|
||||
|
||||
@@ -17,6 +19,35 @@ namespace OpenGL {
|
||||
|
||||
using namespace Common::Literals;
|
||||
|
||||
struct StagingBufferMap {
|
||||
~StagingBufferMap();
|
||||
|
||||
std::span<u8> mapped_span;
|
||||
size_t offset = 0;
|
||||
OGLSync* sync;
|
||||
GLuint buffer;
|
||||
};
|
||||
|
||||
struct StagingBuffers {
|
||||
explicit StagingBuffers(GLenum storage_flags_, GLenum map_flags_);
|
||||
~StagingBuffers();
|
||||
|
||||
StagingBufferMap RequestMap(size_t requested_size, bool insert_fence);
|
||||
|
||||
size_t RequestBuffer(size_t requested_size);
|
||||
|
||||
std::optional<size_t> FindBuffer(size_t requested_size);
|
||||
|
||||
std::vector<OGLSync> syncs;
|
||||
std::vector<OGLBuffer> buffers;
|
||||
std::vector<u8*> maps;
|
||||
std::vector<size_t> sizes;
|
||||
std::vector<size_t> sync_indices;
|
||||
GLenum storage_flags;
|
||||
GLenum map_flags;
|
||||
size_t current_sync_index = 0;
|
||||
};
|
||||
|
||||
class StreamBuffer {
|
||||
static constexpr size_t STREAM_BUFFER_SIZE = 64_MiB;
|
||||
static constexpr size_t NUM_SYNCS = 16;
|
||||
@@ -48,4 +79,17 @@ private:
|
||||
std::array<OGLSync, NUM_SYNCS> fences;
|
||||
};
|
||||
|
||||
class StagingBufferPool {
|
||||
public:
|
||||
StagingBufferPool() = default;
|
||||
~StagingBufferPool() = default;
|
||||
|
||||
StagingBufferMap RequestUploadBuffer(size_t size);
|
||||
StagingBufferMap RequestDownloadBuffer(size_t size);
|
||||
|
||||
private:
|
||||
StagingBuffers upload_buffers{GL_MAP_WRITE_BIT, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT};
|
||||
StagingBuffers download_buffers{GL_MAP_READ_BIT | GL_CLIENT_STORAGE_BIT, GL_MAP_READ_BIT};
|
||||
};
|
||||
|
||||
} // namespace OpenGL
|
||||
@@ -1,63 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
|
||||
#include <glad/glad.h>
|
||||
|
||||
#include "common/alignment.h"
|
||||
#include "common/assert.h"
|
||||
#include "video_core/renderer_opengl/gl_stream_buffer.h"
|
||||
|
||||
namespace OpenGL {
|
||||
|
||||
StreamBuffer::StreamBuffer() {
|
||||
static constexpr GLenum flags = GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT;
|
||||
buffer.Create();
|
||||
glObjectLabel(GL_BUFFER, buffer.handle, -1, "Stream Buffer");
|
||||
glNamedBufferStorage(buffer.handle, STREAM_BUFFER_SIZE, nullptr, flags);
|
||||
mapped_pointer =
|
||||
static_cast<u8*>(glMapNamedBufferRange(buffer.handle, 0, STREAM_BUFFER_SIZE, flags));
|
||||
for (OGLSync& sync : fences) {
|
||||
sync.Create();
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<std::span<u8>, size_t> StreamBuffer::Request(size_t size) noexcept {
|
||||
ASSERT(size < REGION_SIZE);
|
||||
for (size_t region = Region(used_iterator), region_end = Region(iterator); region < region_end;
|
||||
++region) {
|
||||
fences[region].Create();
|
||||
}
|
||||
used_iterator = iterator;
|
||||
|
||||
for (size_t region = Region(free_iterator) + 1,
|
||||
region_end = std::min(Region(iterator + size) + 1, NUM_SYNCS);
|
||||
region < region_end; ++region) {
|
||||
glClientWaitSync(fences[region].handle, 0, GL_TIMEOUT_IGNORED);
|
||||
fences[region].Release();
|
||||
}
|
||||
if (iterator + size >= free_iterator) {
|
||||
free_iterator = iterator + size;
|
||||
}
|
||||
if (iterator + size > STREAM_BUFFER_SIZE) {
|
||||
for (size_t region = Region(used_iterator); region < NUM_SYNCS; ++region) {
|
||||
fences[region].Create();
|
||||
}
|
||||
used_iterator = 0;
|
||||
iterator = 0;
|
||||
free_iterator = size;
|
||||
|
||||
for (size_t region = 0, region_end = Region(size); region <= region_end; ++region) {
|
||||
glClientWaitSync(fences[region].handle, 0, GL_TIMEOUT_IGNORED);
|
||||
fences[region].Release();
|
||||
}
|
||||
}
|
||||
const size_t offset = iterator;
|
||||
iterator = Common::AlignUp(iterator + size, MAX_ALIGNMENT);
|
||||
return {std::span(mapped_pointer + offset, size), offset};
|
||||
}
|
||||
|
||||
} // namespace OpenGL
|
||||
@@ -456,19 +456,14 @@ OGLTexture MakeImage(const VideoCommon::ImageInfo& info, GLenum gl_internal_form
|
||||
return is_srgb ? GL_SRGB8_ALPHA8 : GL_RGBA8;
|
||||
}
|
||||
}
|
||||
|
||||
} // Anonymous namespace
|
||||
|
||||
ImageBufferMap::~ImageBufferMap() {
|
||||
if (sync) {
|
||||
sync->Create();
|
||||
}
|
||||
}
|
||||
|
||||
TextureCacheRuntime::TextureCacheRuntime(const Device& device_, ProgramManager& program_manager,
|
||||
StateTracker& state_tracker_)
|
||||
: device{device_}, state_tracker{state_tracker_}, util_shaders(program_manager),
|
||||
format_conversion_pass{util_shaders}, resolution{Settings::values.resolution_info} {
|
||||
StateTracker& state_tracker_,
|
||||
StagingBufferPool& staging_buffer_pool_)
|
||||
: device{device_}, state_tracker{state_tracker_}, staging_buffer_pool{staging_buffer_pool_},
|
||||
util_shaders(program_manager), format_conversion_pass{util_shaders},
|
||||
resolution{Settings::values.resolution_info} {
|
||||
static constexpr std::array TARGETS{GL_TEXTURE_1D_ARRAY, GL_TEXTURE_2D_ARRAY, GL_TEXTURE_3D};
|
||||
for (size_t i = 0; i < TARGETS.size(); ++i) {
|
||||
const GLenum target = TARGETS[i];
|
||||
@@ -558,12 +553,12 @@ void TextureCacheRuntime::Finish() {
|
||||
glFinish();
|
||||
}
|
||||
|
||||
ImageBufferMap TextureCacheRuntime::UploadStagingBuffer(size_t size) {
|
||||
return upload_buffers.RequestMap(size, true);
|
||||
StagingBufferMap TextureCacheRuntime::UploadStagingBuffer(size_t size) {
|
||||
return staging_buffer_pool.RequestUploadBuffer(size);
|
||||
}
|
||||
|
||||
ImageBufferMap TextureCacheRuntime::DownloadStagingBuffer(size_t size) {
|
||||
return download_buffers.RequestMap(size, false);
|
||||
StagingBufferMap TextureCacheRuntime::DownloadStagingBuffer(size_t size) {
|
||||
return staging_buffer_pool.RequestDownloadBuffer(size);
|
||||
}
|
||||
|
||||
u64 TextureCacheRuntime::GetDeviceMemoryUsage() const {
|
||||
@@ -648,7 +643,7 @@ void TextureCacheRuntime::BlitFramebuffer(Framebuffer* dst, Framebuffer* src,
|
||||
is_linear ? GL_LINEAR : GL_NEAREST);
|
||||
}
|
||||
|
||||
void TextureCacheRuntime::AccelerateImageUpload(Image& image, const ImageBufferMap& map,
|
||||
void TextureCacheRuntime::AccelerateImageUpload(Image& image, const StagingBufferMap& map,
|
||||
std::span<const SwizzleParameters> swizzles) {
|
||||
switch (image.info.type) {
|
||||
case ImageType::e2D:
|
||||
@@ -690,64 +685,6 @@ bool TextureCacheRuntime::HasNativeASTC() const noexcept {
|
||||
return device.HasASTC();
|
||||
}
|
||||
|
||||
TextureCacheRuntime::StagingBuffers::StagingBuffers(GLenum storage_flags_, GLenum map_flags_)
|
||||
: storage_flags{storage_flags_}, map_flags{map_flags_} {}
|
||||
|
||||
TextureCacheRuntime::StagingBuffers::~StagingBuffers() = default;
|
||||
|
||||
ImageBufferMap TextureCacheRuntime::StagingBuffers::RequestMap(size_t requested_size,
|
||||
bool insert_fence) {
|
||||
const size_t index = RequestBuffer(requested_size);
|
||||
OGLSync* const sync = insert_fence ? &syncs[index] : nullptr;
|
||||
return ImageBufferMap{
|
||||
.mapped_span = std::span(maps[index], requested_size),
|
||||
.sync = sync,
|
||||
.buffer = buffers[index].handle,
|
||||
};
|
||||
}
|
||||
|
||||
size_t TextureCacheRuntime::StagingBuffers::RequestBuffer(size_t requested_size) {
|
||||
if (const std::optional<size_t> index = FindBuffer(requested_size); index) {
|
||||
return *index;
|
||||
}
|
||||
|
||||
OGLBuffer& buffer = buffers.emplace_back();
|
||||
buffer.Create();
|
||||
glNamedBufferStorage(buffer.handle, requested_size, nullptr,
|
||||
storage_flags | GL_MAP_PERSISTENT_BIT);
|
||||
maps.push_back(static_cast<u8*>(glMapNamedBufferRange(buffer.handle, 0, requested_size,
|
||||
map_flags | GL_MAP_PERSISTENT_BIT)));
|
||||
|
||||
syncs.emplace_back();
|
||||
sizes.push_back(requested_size);
|
||||
|
||||
ASSERT(syncs.size() == buffers.size() && buffers.size() == maps.size() &&
|
||||
maps.size() == sizes.size());
|
||||
|
||||
return buffers.size() - 1;
|
||||
}
|
||||
|
||||
std::optional<size_t> TextureCacheRuntime::StagingBuffers::FindBuffer(size_t requested_size) {
|
||||
size_t smallest_buffer = std::numeric_limits<size_t>::max();
|
||||
std::optional<size_t> found;
|
||||
const size_t num_buffers = sizes.size();
|
||||
for (size_t index = 0; index < num_buffers; ++index) {
|
||||
const size_t buffer_size = sizes[index];
|
||||
if (buffer_size < requested_size || buffer_size >= smallest_buffer) {
|
||||
continue;
|
||||
}
|
||||
if (syncs[index].handle != 0) {
|
||||
if (!syncs[index].IsSignaled()) {
|
||||
continue;
|
||||
}
|
||||
syncs[index].Release();
|
||||
}
|
||||
smallest_buffer = buffer_size;
|
||||
found = index;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
Image::Image(TextureCacheRuntime& runtime_, const VideoCommon::ImageInfo& info_, GPUVAddr gpu_addr_,
|
||||
VAddr cpu_addr_)
|
||||
: VideoCommon::ImageBase(info_, gpu_addr_, cpu_addr_), runtime{&runtime_} {
|
||||
@@ -823,7 +760,7 @@ void Image::UploadMemory(GLuint buffer_handle, size_t buffer_offset,
|
||||
}
|
||||
}
|
||||
|
||||
void Image::UploadMemory(const ImageBufferMap& map,
|
||||
void Image::UploadMemory(const StagingBufferMap& map,
|
||||
std::span<const VideoCommon::BufferImageCopy> copies) {
|
||||
UploadMemory(map.buffer, map.offset, copies);
|
||||
}
|
||||
@@ -870,7 +807,7 @@ void Image::DownloadMemory(std::span<GLuint> buffer_handles, std::span<size_t> b
|
||||
}
|
||||
}
|
||||
|
||||
void Image::DownloadMemory(ImageBufferMap& map,
|
||||
void Image::DownloadMemory(StagingBufferMap& map,
|
||||
std::span<const VideoCommon::BufferImageCopy> copies) {
|
||||
DownloadMemory(map.buffer, map.offset, copies);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "shader_recompiler/shader_info.h"
|
||||
#include "video_core/renderer_opengl/gl_device.h"
|
||||
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
||||
#include "video_core/renderer_opengl/gl_staging_buffer_pool.h"
|
||||
#include "video_core/renderer_opengl/util_shaders.h"
|
||||
#include "video_core/texture_cache/image_view_base.h"
|
||||
#include "video_core/texture_cache/texture_cache_base.h"
|
||||
@@ -37,15 +38,6 @@ using VideoCommon::Region2D;
|
||||
using VideoCommon::RenderTargets;
|
||||
using VideoCommon::SlotVector;
|
||||
|
||||
struct ImageBufferMap {
|
||||
~ImageBufferMap();
|
||||
|
||||
std::span<u8> mapped_span;
|
||||
size_t offset = 0;
|
||||
OGLSync* sync;
|
||||
GLuint buffer;
|
||||
};
|
||||
|
||||
struct FormatProperties {
|
||||
GLenum compatibility_class;
|
||||
bool compatibility_by_size;
|
||||
@@ -74,14 +66,15 @@ class TextureCacheRuntime {
|
||||
|
||||
public:
|
||||
explicit TextureCacheRuntime(const Device& device, ProgramManager& program_manager,
|
||||
StateTracker& state_tracker);
|
||||
StateTracker& state_tracker,
|
||||
StagingBufferPool& staging_buffer_pool);
|
||||
~TextureCacheRuntime();
|
||||
|
||||
void Finish();
|
||||
|
||||
ImageBufferMap UploadStagingBuffer(size_t size);
|
||||
StagingBufferMap UploadStagingBuffer(size_t size);
|
||||
|
||||
ImageBufferMap DownloadStagingBuffer(size_t size);
|
||||
StagingBufferMap DownloadStagingBuffer(size_t size);
|
||||
|
||||
u64 GetDeviceLocalMemory() const {
|
||||
return device_access_memory;
|
||||
@@ -120,7 +113,7 @@ public:
|
||||
const Region2D& src_region, Tegra::Engines::Fermi2D::Filter filter,
|
||||
Tegra::Engines::Fermi2D::Operation operation);
|
||||
|
||||
void AccelerateImageUpload(Image& image, const ImageBufferMap& map,
|
||||
void AccelerateImageUpload(Image& image, const StagingBufferMap& map,
|
||||
std::span<const VideoCommon::SwizzleParameters> swizzles);
|
||||
|
||||
void InsertUploadMemoryBarrier();
|
||||
@@ -149,35 +142,16 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
struct StagingBuffers {
|
||||
explicit StagingBuffers(GLenum storage_flags_, GLenum map_flags_);
|
||||
~StagingBuffers();
|
||||
|
||||
ImageBufferMap RequestMap(size_t requested_size, bool insert_fence);
|
||||
|
||||
size_t RequestBuffer(size_t requested_size);
|
||||
|
||||
std::optional<size_t> FindBuffer(size_t requested_size);
|
||||
|
||||
std::vector<OGLSync> syncs;
|
||||
std::vector<OGLBuffer> buffers;
|
||||
std::vector<u8*> maps;
|
||||
std::vector<size_t> sizes;
|
||||
GLenum storage_flags;
|
||||
GLenum map_flags;
|
||||
};
|
||||
|
||||
const Device& device;
|
||||
StateTracker& state_tracker;
|
||||
StagingBufferPool& staging_buffer_pool;
|
||||
|
||||
UtilShaders util_shaders;
|
||||
FormatConversionPass format_conversion_pass;
|
||||
|
||||
std::array<std::unordered_map<GLenum, FormatProperties>, 3> format_properties;
|
||||
bool has_broken_texture_view_formats = false;
|
||||
|
||||
StagingBuffers upload_buffers{GL_MAP_WRITE_BIT, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT};
|
||||
StagingBuffers download_buffers{GL_MAP_READ_BIT | GL_CLIENT_STORAGE_BIT, GL_MAP_READ_BIT};
|
||||
|
||||
OGLTexture null_image_1d_array;
|
||||
OGLTexture null_image_cube_array;
|
||||
OGLTexture null_image_3d;
|
||||
@@ -213,7 +187,7 @@ public:
|
||||
void UploadMemory(GLuint buffer_handle, size_t buffer_offset,
|
||||
std::span<const VideoCommon::BufferImageCopy> copies);
|
||||
|
||||
void UploadMemory(const ImageBufferMap& map,
|
||||
void UploadMemory(const StagingBufferMap& map,
|
||||
std::span<const VideoCommon::BufferImageCopy> copies);
|
||||
|
||||
void DownloadMemory(GLuint buffer_handle, size_t buffer_offset,
|
||||
@@ -222,7 +196,8 @@ public:
|
||||
void DownloadMemory(std::span<GLuint> buffer_handle, std::span<size_t> buffer_offset,
|
||||
std::span<const VideoCommon::BufferImageCopy> copies);
|
||||
|
||||
void DownloadMemory(ImageBufferMap& map, std::span<const VideoCommon::BufferImageCopy> copies);
|
||||
void DownloadMemory(StagingBufferMap& map,
|
||||
std::span<const VideoCommon::BufferImageCopy> copies);
|
||||
|
||||
GLuint StorageHandle() noexcept;
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "video_core/host_shaders/pitch_unswizzle_comp.h"
|
||||
#include "video_core/renderer_opengl/gl_shader_manager.h"
|
||||
#include "video_core/renderer_opengl/gl_shader_util.h"
|
||||
#include "video_core/renderer_opengl/gl_staging_buffer_pool.h"
|
||||
#include "video_core/renderer_opengl/gl_texture_cache.h"
|
||||
#include "video_core/renderer_opengl/util_shaders.h"
|
||||
#include "video_core/texture_cache/accelerated_swizzle.h"
|
||||
@@ -63,7 +64,7 @@ UtilShaders::UtilShaders(ProgramManager& program_manager_)
|
||||
|
||||
UtilShaders::~UtilShaders() = default;
|
||||
|
||||
void UtilShaders::ASTCDecode(Image& image, const ImageBufferMap& map,
|
||||
void UtilShaders::ASTCDecode(Image& image, const StagingBufferMap& map,
|
||||
std::span<const VideoCommon::SwizzleParameters> swizzles) {
|
||||
static constexpr GLuint BINDING_INPUT_BUFFER = 0;
|
||||
static constexpr GLuint BINDING_OUTPUT_IMAGE = 0;
|
||||
@@ -111,7 +112,7 @@ void UtilShaders::ASTCDecode(Image& image, const ImageBufferMap& map,
|
||||
program_manager.RestoreGuestCompute();
|
||||
}
|
||||
|
||||
void UtilShaders::BlockLinearUpload2D(Image& image, const ImageBufferMap& map,
|
||||
void UtilShaders::BlockLinearUpload2D(Image& image, const StagingBufferMap& map,
|
||||
std::span<const SwizzleParameters> swizzles) {
|
||||
static constexpr Extent3D WORKGROUP_SIZE{32, 32, 1};
|
||||
static constexpr GLuint BINDING_SWIZZLE_BUFFER = 0;
|
||||
@@ -148,7 +149,7 @@ void UtilShaders::BlockLinearUpload2D(Image& image, const ImageBufferMap& map,
|
||||
program_manager.RestoreGuestCompute();
|
||||
}
|
||||
|
||||
void UtilShaders::BlockLinearUpload3D(Image& image, const ImageBufferMap& map,
|
||||
void UtilShaders::BlockLinearUpload3D(Image& image, const StagingBufferMap& map,
|
||||
std::span<const SwizzleParameters> swizzles) {
|
||||
static constexpr Extent3D WORKGROUP_SIZE{16, 8, 8};
|
||||
|
||||
@@ -189,7 +190,7 @@ void UtilShaders::BlockLinearUpload3D(Image& image, const ImageBufferMap& map,
|
||||
program_manager.RestoreGuestCompute();
|
||||
}
|
||||
|
||||
void UtilShaders::PitchUpload(Image& image, const ImageBufferMap& map,
|
||||
void UtilShaders::PitchUpload(Image& image, const StagingBufferMap& map,
|
||||
std::span<const SwizzleParameters> swizzles) {
|
||||
static constexpr Extent3D WORKGROUP_SIZE{32, 32, 1};
|
||||
static constexpr GLuint BINDING_INPUT_BUFFER = 0;
|
||||
|
||||
@@ -16,23 +16,23 @@ namespace OpenGL {
|
||||
class Image;
|
||||
class ProgramManager;
|
||||
|
||||
struct ImageBufferMap;
|
||||
struct StagingBufferMap;
|
||||
|
||||
class UtilShaders {
|
||||
public:
|
||||
explicit UtilShaders(ProgramManager& program_manager);
|
||||
~UtilShaders();
|
||||
|
||||
void ASTCDecode(Image& image, const ImageBufferMap& map,
|
||||
void ASTCDecode(Image& image, const StagingBufferMap& map,
|
||||
std::span<const VideoCommon::SwizzleParameters> swizzles);
|
||||
|
||||
void BlockLinearUpload2D(Image& image, const ImageBufferMap& map,
|
||||
void BlockLinearUpload2D(Image& image, const StagingBufferMap& map,
|
||||
std::span<const VideoCommon::SwizzleParameters> swizzles);
|
||||
|
||||
void BlockLinearUpload3D(Image& image, const ImageBufferMap& map,
|
||||
void BlockLinearUpload3D(Image& image, const StagingBufferMap& map,
|
||||
std::span<const VideoCommon::SwizzleParameters> swizzles);
|
||||
|
||||
void PitchUpload(Image& image, const ImageBufferMap& map,
|
||||
void PitchUpload(Image& image, const StagingBufferMap& map,
|
||||
std::span<const VideoCommon::SwizzleParameters> swizzles);
|
||||
|
||||
void CopyBC4(Image& dst_image, Image& src_image,
|
||||
|
||||
@@ -157,6 +157,7 @@ struct BufferCacheParams {
|
||||
static constexpr bool USE_MEMORY_MAPS = true;
|
||||
static constexpr bool SEPARATE_IMAGE_BUFFER_BINDINGS = false;
|
||||
static constexpr bool IMPLEMENTS_ASYNC_DOWNLOADS = true;
|
||||
static constexpr bool USE_MEMORY_MAPS_FOR_UPLOADS = true;
|
||||
};
|
||||
|
||||
using BufferCache = VideoCommon::BufferCache<BufferCacheParams>;
|
||||
|
||||
@@ -850,15 +850,11 @@ void TextureCache<P>::PopAsyncFlushes() {
|
||||
template <class P>
|
||||
ImageId TextureCache<P>::DmaImageId(const Tegra::DMA::ImageOperand& operand, bool is_upload) {
|
||||
const ImageInfo dst_info(operand);
|
||||
const ImageId dst_id = FindDMAImage(dst_info, operand.address);
|
||||
if (!dst_id) {
|
||||
return NULL_IMAGE_ID;
|
||||
}
|
||||
auto& image = slot_images[dst_id];
|
||||
if (False(image.flags & ImageFlagBits::GpuModified)) {
|
||||
// No need to waste time on an image that's synced with guest
|
||||
const ImageId image_id = FindDMAImage(dst_info, operand.address);
|
||||
if (!image_id) {
|
||||
return NULL_IMAGE_ID;
|
||||
}
|
||||
auto& image = slot_images[image_id];
|
||||
if (!is_upload && !image.info.dma_downloaded) {
|
||||
// Force a full sync.
|
||||
image.info.dma_downloaded = true;
|
||||
@@ -868,7 +864,7 @@ ImageId TextureCache<P>::DmaImageId(const Tegra::DMA::ImageOperand& operand, boo
|
||||
if (!base) {
|
||||
return NULL_IMAGE_ID;
|
||||
}
|
||||
return dst_id;
|
||||
return image_id;
|
||||
}
|
||||
|
||||
template <class P>
|
||||
|
||||
@@ -85,7 +85,6 @@
|
||||
|
||||
// Define extensions which must be supported.
|
||||
#define FOR_EACH_VK_MANDATORY_EXTENSION(EXTENSION_NAME) \
|
||||
EXTENSION_NAME(VK_EXT_ROBUSTNESS_2_EXTENSION_NAME) \
|
||||
EXTENSION_NAME(VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME) \
|
||||
EXTENSION_NAME(VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME) \
|
||||
EXTENSION_NAME(VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME) \
|
||||
@@ -105,6 +104,7 @@
|
||||
EXTENSION_NAME(VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME) \
|
||||
EXTENSION_NAME(VK_EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME) \
|
||||
EXTENSION_NAME(VK_EXT_LINE_RASTERIZATION_EXTENSION_NAME) \
|
||||
EXTENSION_NAME(VK_EXT_ROBUSTNESS_2_EXTENSION_NAME) \
|
||||
EXTENSION_NAME(VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME) \
|
||||
EXTENSION_NAME(VK_NV_GEOMETRY_SHADER_PASSTHROUGH_EXTENSION_NAME) \
|
||||
EXTENSION_NAME(VK_NV_VIEWPORT_ARRAY2_EXTENSION_NAME) \
|
||||
@@ -141,9 +141,6 @@
|
||||
FEATURE_NAME(features, vertexPipelineStoresAndAtomics) \
|
||||
FEATURE_NAME(features, wideLines) \
|
||||
FEATURE_NAME(host_query_reset, hostQueryReset) \
|
||||
FEATURE_NAME(robustness2, nullDescriptor) \
|
||||
FEATURE_NAME(robustness2, robustBufferAccess2) \
|
||||
FEATURE_NAME(robustness2, robustImageAccess2) \
|
||||
FEATURE_NAME(shader_demote_to_helper_invocation, shaderDemoteToHelperInvocation) \
|
||||
FEATURE_NAME(shader_draw_parameters, shaderDrawParameters) \
|
||||
FEATURE_NAME(variable_pointer, variablePointers) \
|
||||
@@ -156,6 +153,9 @@
|
||||
FEATURE_NAME(index_type_uint8, indexTypeUint8) \
|
||||
FEATURE_NAME(primitive_topology_list_restart, primitiveTopologyListRestart) \
|
||||
FEATURE_NAME(provoking_vertex, provokingVertexLast) \
|
||||
FEATURE_NAME(robustness2, nullDescriptor) \
|
||||
FEATURE_NAME(robustness2, robustBufferAccess2) \
|
||||
FEATURE_NAME(robustness2, robustImageAccess2) \
|
||||
FEATURE_NAME(shader_float16_int8, shaderFloat16) \
|
||||
FEATURE_NAME(shader_float16_int8, shaderInt8) \
|
||||
FEATURE_NAME(timeline_semaphore, timelineSemaphore) \
|
||||
|
||||
@@ -101,6 +101,12 @@ const std::map<Settings::RendererBackend, QString> Config::renderer_backend_text
|
||||
{Settings::RendererBackend::Null, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "Null"))},
|
||||
};
|
||||
|
||||
const std::map<Settings::ShaderBackend, QString> Config::shader_backend_texts_map = {
|
||||
{Settings::ShaderBackend::GLSL, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "GLSL"))},
|
||||
{Settings::ShaderBackend::GLASM, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "GLASM"))},
|
||||
{Settings::ShaderBackend::SPIRV, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "SPIRV"))},
|
||||
};
|
||||
|
||||
// This shouldn't have anything except static initializers (no functions). So
|
||||
// QKeySequence(...).toString() is NOT ALLOWED HERE.
|
||||
// This must be in alphabetical order according to action name as it must have the same order as
|
||||
|
||||
@@ -54,6 +54,7 @@ public:
|
||||
static const std::map<bool, QString> use_docked_mode_texts_map;
|
||||
static const std::map<Settings::GPUAccuracy, QString> gpu_accuracy_texts_map;
|
||||
static const std::map<Settings::RendererBackend, QString> renderer_backend_texts_map;
|
||||
static const std::map<Settings::ShaderBackend, QString> shader_backend_texts_map;
|
||||
|
||||
static constexpr UISettings::Theme default_theme{
|
||||
#ifdef _WIN32
|
||||
|
||||
@@ -42,6 +42,7 @@ void ConfigureGraphicsAdvanced::SetConfiguration() {
|
||||
Settings::values.use_vulkan_driver_pipeline_cache.GetValue());
|
||||
ui->enable_compute_pipelines_checkbox->setChecked(
|
||||
Settings::values.enable_compute_pipelines.GetValue());
|
||||
ui->use_video_framerate_checkbox->setChecked(Settings::values.use_video_framerate.GetValue());
|
||||
|
||||
if (Settings::IsConfiguringGlobal()) {
|
||||
ui->gpu_accuracy->setCurrentIndex(
|
||||
@@ -91,6 +92,8 @@ void ConfigureGraphicsAdvanced::ApplyConfiguration() {
|
||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.enable_compute_pipelines,
|
||||
ui->enable_compute_pipelines_checkbox,
|
||||
enable_compute_pipelines);
|
||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_video_framerate,
|
||||
ui->use_video_framerate_checkbox, use_video_framerate);
|
||||
}
|
||||
|
||||
void ConfigureGraphicsAdvanced::changeEvent(QEvent* event) {
|
||||
@@ -125,6 +128,8 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() {
|
||||
Settings::values.max_anisotropy.UsingGlobal());
|
||||
ui->enable_compute_pipelines_checkbox->setEnabled(
|
||||
Settings::values.enable_compute_pipelines.UsingGlobal());
|
||||
ui->use_video_framerate_checkbox->setEnabled(
|
||||
Settings::values.use_video_framerate.UsingGlobal());
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -149,6 +154,9 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() {
|
||||
ConfigurationShared::SetColoredTristate(ui->enable_compute_pipelines_checkbox,
|
||||
Settings::values.enable_compute_pipelines,
|
||||
enable_compute_pipelines);
|
||||
ConfigurationShared::SetColoredTristate(ui->use_video_framerate_checkbox,
|
||||
Settings::values.use_video_framerate,
|
||||
use_video_framerate);
|
||||
ConfigurationShared::SetColoredComboBox(
|
||||
ui->gpu_accuracy, ui->label_gpu_accuracy,
|
||||
static_cast<int>(Settings::values.gpu_accuracy.GetValue(true)));
|
||||
|
||||
@@ -47,6 +47,7 @@ private:
|
||||
ConfigurationShared::CheckState use_fast_gpu_time;
|
||||
ConfigurationShared::CheckState use_vulkan_driver_pipeline_cache;
|
||||
ConfigurationShared::CheckState enable_compute_pipelines;
|
||||
ConfigurationShared::CheckState use_video_framerate;
|
||||
|
||||
const Core::System& system;
|
||||
};
|
||||
|
||||
@@ -191,6 +191,16 @@ Compute pipelines are always enabled on all other drivers.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="use_video_framerate_checkbox">
|
||||
<property name="toolTip">
|
||||
<string>Run the game at normal speed during video playback, even when the framerate is unlocked.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Sync to framerate of video playback</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="af_layout" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_1">
|
||||
|
||||
@@ -3491,6 +3491,7 @@ void GMainWindow::ResetWindowSize1080() {
|
||||
void GMainWindow::OnConfigure() {
|
||||
const auto old_theme = UISettings::values.theme;
|
||||
const bool old_discord_presence = UISettings::values.enable_discord_presence.GetValue();
|
||||
const auto old_language_index = Settings::values.language_index.GetValue();
|
||||
|
||||
Settings::SetConfiguringGlobal(true);
|
||||
ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(), *system,
|
||||
@@ -3559,7 +3560,7 @@ void GMainWindow::OnConfigure() {
|
||||
emit UpdateThemedIcons();
|
||||
|
||||
const auto reload = UISettings::values.is_game_list_reload_pending.exchange(false);
|
||||
if (reload) {
|
||||
if (reload || Settings::values.language_index.GetValue() != old_language_index) {
|
||||
game_list->PopulateAsync(UISettings::values.game_dirs);
|
||||
}
|
||||
|
||||
@@ -4115,7 +4116,13 @@ void GMainWindow::UpdateDockedButton() {
|
||||
void GMainWindow::UpdateAPIText() {
|
||||
const auto api = Settings::values.renderer_backend.GetValue();
|
||||
const auto renderer_status_text = Config::renderer_backend_texts_map.find(api)->second;
|
||||
renderer_status_button->setText(renderer_status_text.toUpper());
|
||||
renderer_status_button->setText(
|
||||
api == Settings::RendererBackend::OpenGL
|
||||
? tr("%1 %2").arg(
|
||||
renderer_status_text.toUpper(),
|
||||
Config::shader_backend_texts_map.find(Settings::values.shader_backend.GetValue())
|
||||
->second)
|
||||
: renderer_status_text.toUpper());
|
||||
}
|
||||
|
||||
void GMainWindow::UpdateFilterText() {
|
||||
|
||||
Reference in New Issue
Block a user