Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 81fff7aec0 | |||
| deecd7f074 | |||
| 6f511c8006 | |||
| 47ccfabe18 | |||
| f883cd4f0e | |||
| 25702b6256 | |||
| d82b181d44 | |||
| 6c41d1cd7e | |||
| 3c54edae24 | |||
| 5a0a9c7449 | |||
| 3a20d9734f | |||
| 43503a69bf | |||
| 50ad745585 | |||
| 8eb1398f8d | |||
| 8e0c80f269 | |||
| 57fe7fdec0 | |||
| 3d4a0b94e3 | |||
| d45ad75404 | |||
| 25ee892d5e | |||
| e1afeec76d | |||
| f297e9ff22 | |||
| 2b9b695fa7 | |||
| e03f46fb0e | |||
| 8d0b1a957e | |||
| 5c907f85fc | |||
| 0759df0aff | |||
| ab6f8d8a1e | |||
| 634c6e24b0 | |||
| 1dbd22e695 | |||
| 99db7d23dd | |||
| 8566096794 | |||
| 87e7cc2d5a | |||
| aacb473aa2 | |||
| f4417eab8f |
@@ -5,7 +5,7 @@ cd /yuzu
|
||||
ccache -s
|
||||
|
||||
mkdir build || true && cd build
|
||||
cmake .. -G Ninja -DYUZU_USE_BUNDLED_UNICORN=ON -DYUZU_USE_QT_WEB_ENGINE=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/lib/ccache/gcc -DCMAKE_CXX_COMPILER=/usr/lib/ccache/g++ -DYUZU_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DUSE_DISCORD_PRESENCE=ON
|
||||
cmake .. -G Ninja -DDISPLAY_VERSION=$1 -DYUZU_USE_BUNDLED_UNICORN=ON -DYUZU_USE_QT_WEB_ENGINE=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/lib/ccache/gcc -DCMAKE_CXX_COMPILER=/usr/lib/ccache/g++ -DYUZU_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DUSE_DISCORD_PRESENCE=ON
|
||||
|
||||
ninja
|
||||
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
mkdir -p "ccache" || true
|
||||
chmod a+x ./.ci/scripts/linux/docker.sh
|
||||
docker run -e ENABLE_COMPATIBILITY_REPORTING -e CCACHE_DIR=/yuzu/ccache -v $(pwd):/yuzu yuzuemu/build-environments:linux-fresh /bin/bash /yuzu/.ci/scripts/linux/docker.sh
|
||||
docker run -e ENABLE_COMPATIBILITY_REPORTING -e CCACHE_DIR=/yuzu/ccache -v $(pwd):/yuzu yuzuemu/build-environments:linux-fresh /bin/bash /yuzu/.ci/scripts/linux/docker.sh $1
|
||||
|
||||
@@ -13,7 +13,7 @@ echo '' >> /bin/cmd
|
||||
chmod +x /bin/cmd
|
||||
|
||||
mkdir build || true && cd build
|
||||
cmake .. -G Ninja -DCMAKE_TOOLCHAIN_FILE="$(pwd)/../CMakeModules/MinGWCross.cmake" -DUSE_CCACHE=ON -DYUZU_USE_BUNDLED_UNICORN=ON -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DCMAKE_BUILD_TYPE=Release
|
||||
cmake .. -G Ninja -DDISPLAY_VERSION=$1 -DCMAKE_TOOLCHAIN_FILE="$(pwd)/../CMakeModules/MinGWCross.cmake" -DUSE_CCACHE=ON -DYUZU_USE_BUNDLED_UNICORN=ON -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DCMAKE_BUILD_TYPE=Release
|
||||
ninja
|
||||
|
||||
# Clean up the dirty hacks
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
mkdir -p "ccache" || true
|
||||
chmod a+x ./.ci/scripts/windows/docker.sh
|
||||
docker run -e CCACHE_DIR=/yuzu/ccache -v $(pwd):/yuzu yuzuemu/build-environments:linux-mingw /bin/bash -ex /yuzu/.ci/scripts/windows/docker.sh
|
||||
docker run -e CCACHE_DIR=/yuzu/ccache -v $(pwd):/yuzu yuzuemu/build-environments:linux-mingw /bin/bash -ex /yuzu/.ci/scripts/windows/docker.sh $1
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
parameters:
|
||||
artifactSource: 'true'
|
||||
cache: 'false'
|
||||
version: ''
|
||||
|
||||
steps:
|
||||
- script: mkdir build && cd build && set DATE=`date '+%Y.%m.%d'` && set CI=true && set AZURE_REPO_NAME=yuzu-emu/yuzu-$(BuildName) && set AZURE_REPO_TAG=$(BuildName)-$DATE && cmake -G "Visual Studio 15 2017 Win64" --config Release -DYUZU_USE_BUNDLED_QT=1 -DYUZU_USE_BUNDLED_SDL2=1 -DYUZU_USE_BUNDLED_UNICORN=1 -DYUZU_USE_QT_WEB_ENGINE=ON -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DYUZU_ENABLE_COMPATIBILITY_REPORTING=${COMPAT} -DUSE_DISCORD_PRESENCE=ON .. && cd ..
|
||||
- script: mkdir build && cd build && cmake -G "Visual Studio 15 2017 Win64" --config Release -DYUZU_USE_BUNDLED_QT=1 -DYUZU_USE_BUNDLED_SDL2=1 -DYUZU_USE_BUNDLED_UNICORN=1 -DYUZU_USE_QT_WEB_ENGINE=ON -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DYUZU_ENABLE_COMPATIBILITY_REPORTING=${COMPAT} -DUSE_DISCORD_PRESENCE=ON -DDISPLAY_VERSION=${{ parameters['version'] }} .. && cd ..
|
||||
displayName: 'Configure CMake'
|
||||
- task: MSBuild@1
|
||||
displayName: 'Build'
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
parameters:
|
||||
artifactSource: 'true'
|
||||
cache: 'false'
|
||||
version: ''
|
||||
|
||||
steps:
|
||||
- task: DockerInstaller@0
|
||||
@@ -13,7 +14,7 @@ steps:
|
||||
key: yuzu-v1-$(BuildName)-$(BuildSuffix)-$(CacheSuffix)
|
||||
path: $(System.DefaultWorkingDirectory)/ccache
|
||||
cacheHitVar: CACHE_RESTORED
|
||||
- script: export DATE=`date '+%Y.%m.%d'` && export CI=true && export AZURE_REPO_NAME=yuzu-emu/yuzu-$(BuildName) && export AZURE_REPO_TAG=$(BuildName)-$DATE && chmod a+x ./.ci/scripts/$(ScriptFolder)/exec.sh && ./.ci/scripts/$(ScriptFolder)/exec.sh
|
||||
- script: chmod a+x ./.ci/scripts/$(ScriptFolder)/exec.sh && ./.ci/scripts/$(ScriptFolder)/exec.sh ${{ parameters['version'] }}
|
||||
displayName: 'Build'
|
||||
- script: chmod a+x ./.ci/scripts/$(ScriptFolder)/upload.sh && RELEASE_NAME=$(BuildName) ./.ci/scripts/$(ScriptFolder)/upload.sh
|
||||
displayName: 'Package Artifacts'
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
parameters:
|
||||
version: ''
|
||||
|
||||
jobs:
|
||||
- job: build
|
||||
displayName: 'standard'
|
||||
@@ -20,4 +23,5 @@ jobs:
|
||||
- template: ./build-single.yml
|
||||
parameters:
|
||||
artifactSource: 'false'
|
||||
cache: $(parameters.cache)
|
||||
cache: $(parameters.cache)
|
||||
version: $(parameters.version)
|
||||
@@ -1,3 +1,6 @@
|
||||
parameters:
|
||||
version: ''
|
||||
|
||||
jobs:
|
||||
- job: build_test
|
||||
displayName: 'testing'
|
||||
@@ -31,3 +34,4 @@ jobs:
|
||||
parameters:
|
||||
artifactSource: 'false'
|
||||
cache: 'false'
|
||||
version: $(parameters.version)
|
||||
@@ -1,6 +1,9 @@
|
||||
trigger:
|
||||
- master
|
||||
|
||||
variables:
|
||||
DisplayVersion: $[counter(variables['DisplayPrefix'], 1)]
|
||||
|
||||
stages:
|
||||
- stage: format
|
||||
displayName: 'format'
|
||||
@@ -34,6 +37,7 @@ stages:
|
||||
parameters:
|
||||
artifactSource: 'false'
|
||||
cache: 'true'
|
||||
version: $(DisplayVersion)
|
||||
- stage: build_win
|
||||
dependsOn: format
|
||||
displayName: 'build-windows'
|
||||
@@ -51,6 +55,7 @@ stages:
|
||||
parameters:
|
||||
artifactSource: 'false'
|
||||
cache: 'true'
|
||||
version: $(DisplayVersion)
|
||||
- stage: release
|
||||
displayName: 'Release'
|
||||
dependsOn:
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
trigger:
|
||||
- master
|
||||
|
||||
variables:
|
||||
DisplayVersion: $[counter(variables['DisplayPrefix'], 1)]
|
||||
|
||||
stages:
|
||||
- stage: format
|
||||
displayName: 'format'
|
||||
@@ -28,3 +31,4 @@ stages:
|
||||
parameters:
|
||||
artifactSource: 'false'
|
||||
cache: $(parameters.cache)
|
||||
version: $(DisplayVersion)
|
||||
|
||||
@@ -15,11 +15,23 @@ if (DEFINED ENV{CI})
|
||||
set(BUILD_TAG $ENV{AZURE_REPO_TAG})
|
||||
endif()
|
||||
endif()
|
||||
if (DEFINED ENV{TITLEBARFORMATIDLE})
|
||||
set(TITLE_BAR_FORMAT_IDLE $ENV{TITLEBARFORMATIDLE})
|
||||
endif ()
|
||||
if (DEFINED ENV{TITLEBARFORMATRUNNING})
|
||||
set(TITLE_BAR_FORMAT_RUNNING $ENV{TITLEBARFORMATRUNNING})
|
||||
endif ()
|
||||
if (DEFINED ENV{DISPLAYVERSION})
|
||||
set(DISPLAY_VERSION $ENV{DISPLAYVERSION})
|
||||
endif ()
|
||||
add_custom_command(OUTPUT scm_rev.cpp
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DSRC_DIR="${CMAKE_SOURCE_DIR}"
|
||||
-DBUILD_REPOSITORY="${BUILD_REPOSITORY}"
|
||||
-DTITLE_BAR_FORMAT_IDLE="${TITLE_BAR_FORMAT_IDLE}"
|
||||
-DTITLE_BAR_FORMAT_RUNNING="${TITLE_BAR_FORMAT_RUNNING}"
|
||||
-DBUILD_TAG="${BUILD_TAG}"
|
||||
-DBUILD_ID="${DISPLAY_VERSION}"
|
||||
-P "${CMAKE_SOURCE_DIR}/CMakeModules/GenerateSCMRev.cmake"
|
||||
DEPENDS
|
||||
# WARNING! It was too much work to try and make a common location for this list,
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#define LOAD_DIR "load"
|
||||
#define DUMP_DIR "dump"
|
||||
#define SHADER_DIR "shader"
|
||||
#define RESCALING_DIR "rescaling"
|
||||
#define LOG_DIR "log"
|
||||
|
||||
// Filenames
|
||||
|
||||
@@ -695,7 +695,6 @@ const std::string& GetUserPath(UserPath path, const std::string& new_path) {
|
||||
paths.emplace(UserPath::LoadDir, user_path + LOAD_DIR DIR_SEP);
|
||||
paths.emplace(UserPath::DumpDir, user_path + DUMP_DIR DIR_SEP);
|
||||
paths.emplace(UserPath::ShaderDir, user_path + SHADER_DIR DIR_SEP);
|
||||
paths.emplace(UserPath::RescalingDir, user_path + RESCALING_DIR DIR_SEP);
|
||||
paths.emplace(UserPath::SysDataDir, user_path + SYSDATA_DIR DIR_SEP);
|
||||
paths.emplace(UserPath::KeysDir, user_path + KEYS_DIR DIR_SEP);
|
||||
// TODO: Put the logs in a better location for each OS
|
||||
@@ -714,7 +713,6 @@ const std::string& GetUserPath(UserPath path, const std::string& new_path) {
|
||||
case UserPath::RootDir:
|
||||
user_path = paths[UserPath::RootDir] + DIR_SEP;
|
||||
break;
|
||||
|
||||
case UserPath::UserDir:
|
||||
user_path = paths[UserPath::RootDir] + DIR_SEP;
|
||||
paths[UserPath::ConfigDir] = user_path + CONFIG_DIR DIR_SEP;
|
||||
@@ -722,6 +720,8 @@ const std::string& GetUserPath(UserPath path, const std::string& new_path) {
|
||||
paths[UserPath::SDMCDir] = user_path + SDMC_DIR DIR_SEP;
|
||||
paths[UserPath::NANDDir] = user_path + NAND_DIR DIR_SEP;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ enum class UserPath {
|
||||
LoadDir,
|
||||
DumpDir,
|
||||
ShaderDir,
|
||||
RescalingDir,
|
||||
SysDataDir,
|
||||
UserDir,
|
||||
};
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
#define BUILD_DATE "@BUILD_DATE@"
|
||||
#define BUILD_FULLNAME "@BUILD_FULLNAME@"
|
||||
#define BUILD_VERSION "@BUILD_VERSION@"
|
||||
#define BUILD_ID "@BUILD_ID@"
|
||||
#define TITLE_BAR_FORMAT_IDLE "@TITLE_BAR_FORMAT_IDLE@"
|
||||
#define TITLE_BAR_FORMAT_RUNNING "@TITLE_BAR_FORMAT_RUNNING@"
|
||||
#define SHADER_CACHE_VERSION "@SHADER_CACHE_VERSION@"
|
||||
|
||||
namespace Common {
|
||||
@@ -22,6 +25,9 @@ const char g_build_name[] = BUILD_NAME;
|
||||
const char g_build_date[] = BUILD_DATE;
|
||||
const char g_build_fullname[] = BUILD_FULLNAME;
|
||||
const char g_build_version[] = BUILD_VERSION;
|
||||
const char g_build_id[] = BUILD_ID;
|
||||
const char g_title_bar_format_idle[] = TITLE_BAR_FORMAT_IDLE;
|
||||
const char g_title_bar_format_running[] = TITLE_BAR_FORMAT_RUNNING;
|
||||
const char g_shader_cache_version[] = SHADER_CACHE_VERSION;
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -13,6 +13,9 @@ extern const char g_build_name[];
|
||||
extern const char g_build_date[];
|
||||
extern const char g_build_fullname[];
|
||||
extern const char g_build_version[];
|
||||
extern const char g_build_id[];
|
||||
extern const char g_title_bar_format_idle[];
|
||||
extern const char g_title_bar_format_running[];
|
||||
extern const char g_shader_cache_version[];
|
||||
|
||||
} // namespace Common
|
||||
|
||||
@@ -147,6 +147,7 @@ private:
|
||||
void GetAccumulatedSuspendedTickValue(Kernel::HLERequestContext& ctx);
|
||||
void GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequestContext& ctx);
|
||||
|
||||
Core::System& system;
|
||||
std::shared_ptr<NVFlinger::NVFlinger> nvflinger;
|
||||
Kernel::EventPair launchable_event;
|
||||
Kernel::EventPair accumulated_suspended_tick_changed_event;
|
||||
@@ -154,8 +155,6 @@ private:
|
||||
u32 idle_time_detection_extension = 0;
|
||||
u64 num_fatal_sections_entered = 0;
|
||||
bool is_auto_sleep_disabled = false;
|
||||
|
||||
Core::System& system;
|
||||
};
|
||||
|
||||
class ICommonStateGetter final : public ServiceFramework<ICommonStateGetter> {
|
||||
|
||||
@@ -13,7 +13,7 @@ constexpr PerformanceConfiguration DEFAULT_PERFORMANCE_CONFIGURATION =
|
||||
PerformanceConfiguration::Config7;
|
||||
|
||||
Controller::Controller(Core::Timing::CoreTiming& core_timing)
|
||||
: core_timing(core_timing), configs{
|
||||
: core_timing{core_timing}, configs{
|
||||
{PerformanceMode::Handheld, DEFAULT_PERFORMANCE_CONFIGURATION},
|
||||
{PerformanceMode::Docked, DEFAULT_PERFORMANCE_CONFIGURATION},
|
||||
} {}
|
||||
@@ -63,6 +63,7 @@ PerformanceConfiguration Controller::GetCurrentPerformanceConfiguration(Performa
|
||||
void Controller::SetClockSpeed(u32 mhz) {
|
||||
LOG_INFO(Service_APM, "called, mhz={:08X}", mhz);
|
||||
// TODO(DarkLordZach): Actually signal core_timing to change clock speed.
|
||||
// TODO(Rodrigo): Remove [[maybe_unused]] when core_timing is used.
|
||||
}
|
||||
|
||||
} // namespace Service::APM
|
||||
|
||||
@@ -50,7 +50,7 @@ enum class PerformanceMode : u8 {
|
||||
// system during times of high load -- this simply maps to different PerformanceConfigs to use.
|
||||
class Controller {
|
||||
public:
|
||||
Controller(Core::Timing::CoreTiming& core_timing);
|
||||
explicit Controller(Core::Timing::CoreTiming& core_timing);
|
||||
~Controller();
|
||||
|
||||
void SetPerformanceConfiguration(PerformanceMode mode, PerformanceConfiguration config);
|
||||
@@ -62,9 +62,9 @@ public:
|
||||
private:
|
||||
void SetClockSpeed(u32 mhz);
|
||||
|
||||
std::map<PerformanceMode, PerformanceConfiguration> configs;
|
||||
[[maybe_unused]] Core::Timing::CoreTiming& core_timing;
|
||||
|
||||
Core::Timing::CoreTiming& core_timing;
|
||||
std::map<PerformanceMode, PerformanceConfiguration> configs;
|
||||
};
|
||||
|
||||
} // namespace Service::APM
|
||||
|
||||
@@ -205,7 +205,7 @@ private:
|
||||
AudioCore::StreamPtr stream;
|
||||
std::string device_name;
|
||||
|
||||
AudoutParams audio_params{};
|
||||
[[maybe_unused]] AudoutParams audio_params {};
|
||||
|
||||
/// This is the event handle used to check if the audio buffer was released
|
||||
Kernel::EventPair buffer_event;
|
||||
|
||||
@@ -88,7 +88,7 @@ std::ostream& operator<<(std::ostream& os, DownloadResult result) {
|
||||
|
||||
constexpr u32 PORT = 443;
|
||||
constexpr u32 TIMEOUT_SECONDS = 30;
|
||||
constexpr u64 VFS_COPY_BLOCK_SIZE = 1ull << 24; // 4MB
|
||||
[[maybe_unused]] constexpr u64 VFS_COPY_BLOCK_SIZE = 1ULL << 24; // 4MB
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
@@ -567,7 +567,7 @@ std::unique_ptr<Backend> CreateBackendFromSettings(DirectoryGetter getter) {
|
||||
|
||||
Module::Interface::Interface(std::shared_ptr<Module> module, FileSystem::FileSystemController& fsc,
|
||||
const char* name)
|
||||
: ServiceFramework(name), module(std::move(module)), fsc(fsc),
|
||||
: ServiceFramework(name), fsc(fsc), module(std::move(module)),
|
||||
backend(CreateBackendFromSettings([&fsc](u64 tid) { return fsc.GetBCATDirectory(tid); })) {}
|
||||
|
||||
Module::Interface::~Interface() = default;
|
||||
|
||||
@@ -803,7 +803,7 @@ void FSP_SRV::CreateSaveDataFileSystem(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
|
||||
auto save_struct = rp.PopRaw<FileSys::SaveDataDescriptor>();
|
||||
auto save_create_struct = rp.PopRaw<std::array<u8, 0x40>>();
|
||||
[[maybe_unused]] auto save_create_struct = rp.PopRaw<std::array<u8, 0x40>>();
|
||||
u128 uid = rp.PopRaw<u128>();
|
||||
|
||||
LOG_DEBUG(Service_FS, "called save_struct = {}, uid = {:016X}{:016X}", save_struct.DebugInfo(),
|
||||
|
||||
@@ -237,7 +237,6 @@ private:
|
||||
};
|
||||
|
||||
Common::UUID uuid;
|
||||
bool is_event_created = false;
|
||||
Kernel::EventPair notification_event;
|
||||
std::queue<SizedNotificationInfo> notifications;
|
||||
States states{};
|
||||
|
||||
@@ -11,11 +11,10 @@
|
||||
namespace Service::HID {
|
||||
|
||||
constexpr s32 HID_JOYSTICK_MAX = 0x7fff;
|
||||
constexpr s32 HID_JOYSTICK_MIN = -0x7fff;
|
||||
[[maybe_unused]] constexpr s32 HID_JOYSTICK_MIN = -0x7fff;
|
||||
enum class JoystickId : std::size_t { Joystick_Left, Joystick_Right };
|
||||
|
||||
Controller_DebugPad::Controller_DebugPad(Core::System& system)
|
||||
: ControllerBase(system), system(system) {}
|
||||
Controller_DebugPad::Controller_DebugPad(Core::System& system) : ControllerBase(system) {}
|
||||
Controller_DebugPad::~Controller_DebugPad() = default;
|
||||
|
||||
void Controller_DebugPad::OnInit() {}
|
||||
|
||||
@@ -89,6 +89,5 @@ private:
|
||||
buttons;
|
||||
std::array<std::unique_ptr<Input::AnalogDevice>, Settings::NativeAnalog::NUM_STICKS_HID>
|
||||
analogs;
|
||||
Core::System& system;
|
||||
};
|
||||
} // namespace Service::HID
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
namespace Service::HID {
|
||||
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3BA00;
|
||||
|
||||
Controller_Gesture::Controller_Gesture(Core::System& system)
|
||||
: ControllerBase(system), system(system) {}
|
||||
Controller_Gesture::Controller_Gesture(Core::System& system) : ControllerBase(system) {}
|
||||
Controller_Gesture::~Controller_Gesture() = default;
|
||||
|
||||
void Controller_Gesture::OnInit() {}
|
||||
|
||||
@@ -59,6 +59,5 @@ private:
|
||||
std::array<GestureState, 17> gesture_states;
|
||||
};
|
||||
SharedMemory shared_memory{};
|
||||
Core::System& system;
|
||||
};
|
||||
} // namespace Service::HID
|
||||
|
||||
@@ -12,8 +12,7 @@ namespace Service::HID {
|
||||
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3800;
|
||||
constexpr u8 KEYS_PER_BYTE = 8;
|
||||
|
||||
Controller_Keyboard::Controller_Keyboard(Core::System& system)
|
||||
: ControllerBase(system), system(system) {}
|
||||
Controller_Keyboard::Controller_Keyboard(Core::System& system) : ControllerBase(system) {}
|
||||
Controller_Keyboard::~Controller_Keyboard() = default;
|
||||
|
||||
void Controller_Keyboard::OnInit() {}
|
||||
|
||||
@@ -53,6 +53,5 @@ private:
|
||||
keyboard_keys;
|
||||
std::array<std::unique_ptr<Input::ButtonDevice>, Settings::NativeKeyboard::NumKeyboardMods>
|
||||
keyboard_mods;
|
||||
Core::System& system;
|
||||
};
|
||||
} // namespace Service::HID
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace Service::HID {
|
||||
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3400;
|
||||
|
||||
Controller_Mouse::Controller_Mouse(Core::System& system) : ControllerBase(system), system(system) {}
|
||||
Controller_Mouse::Controller_Mouse(Core::System& system) : ControllerBase(system) {}
|
||||
Controller_Mouse::~Controller_Mouse() = default;
|
||||
|
||||
void Controller_Mouse::OnInit() {}
|
||||
|
||||
@@ -53,6 +53,5 @@ private:
|
||||
std::unique_ptr<Input::MouseDevice> mouse_device;
|
||||
std::array<std::unique_ptr<Input::ButtonDevice>, Settings::NativeMouseButton::NumMouseButtons>
|
||||
mouse_button_devices;
|
||||
Core::System& system;
|
||||
};
|
||||
} // namespace Service::HID
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
namespace Service::HID {
|
||||
constexpr s32 HID_JOYSTICK_MAX = 0x7fff;
|
||||
constexpr s32 HID_JOYSTICK_MIN = -0x7fff;
|
||||
[[maybe_unused]] constexpr s32 HID_JOYSTICK_MIN = -0x7fff;
|
||||
constexpr std::size_t NPAD_OFFSET = 0x9A00;
|
||||
constexpr u32 BATTERY_FULL = 2;
|
||||
constexpr u32 MAX_NPAD_ID = 7;
|
||||
@@ -105,6 +105,8 @@ void Controller_NPad::InitNewlyAddedControler(std::size_t controller_idx) {
|
||||
controller.joy_styles.raw = 0; // Zero out
|
||||
controller.device_type.raw = 0;
|
||||
switch (controller_type) {
|
||||
case NPadControllerType::None:
|
||||
UNREACHABLE();
|
||||
case NPadControllerType::Handheld:
|
||||
controller.joy_styles.handheld.Assign(1);
|
||||
controller.device_type.handheld.Assign(1);
|
||||
@@ -239,7 +241,7 @@ void Controller_NPad::OnRelease() {}
|
||||
|
||||
void Controller_NPad::RequestPadStateUpdate(u32 npad_id) {
|
||||
const auto controller_idx = NPadIdToIndex(npad_id);
|
||||
const auto controller_type = connected_controllers[controller_idx].type;
|
||||
[[maybe_unused]] const auto controller_type = connected_controllers[controller_idx].type;
|
||||
if (!connected_controllers[controller_idx].is_connected) {
|
||||
return;
|
||||
}
|
||||
@@ -346,6 +348,8 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
|
||||
libnx_entry.connection_status.raw = 0;
|
||||
|
||||
switch (controller_type) {
|
||||
case NPadControllerType::None:
|
||||
UNREACHABLE();
|
||||
case NPadControllerType::Handheld:
|
||||
handheld_entry.connection_status.raw = 0;
|
||||
handheld_entry.connection_status.IsWired.Assign(1);
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
|
||||
namespace Service::HID {
|
||||
|
||||
Controller_Stubbed::Controller_Stubbed(Core::System& system)
|
||||
: ControllerBase(system), system(system) {}
|
||||
Controller_Stubbed::Controller_Stubbed(Core::System& system) : ControllerBase(system) {}
|
||||
Controller_Stubbed::~Controller_Stubbed() = default;
|
||||
|
||||
void Controller_Stubbed::OnInit() {}
|
||||
|
||||
@@ -30,6 +30,5 @@ public:
|
||||
private:
|
||||
bool smart_update{};
|
||||
std::size_t common_offset{};
|
||||
Core::System& system;
|
||||
};
|
||||
} // namespace Service::HID
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
namespace Service::HID {
|
||||
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x400;
|
||||
|
||||
Controller_Touchscreen::Controller_Touchscreen(Core::System& system)
|
||||
: ControllerBase(system), system(system) {}
|
||||
Controller_Touchscreen::Controller_Touchscreen(Core::System& system) : ControllerBase(system) {}
|
||||
Controller_Touchscreen::~Controller_Touchscreen() = default;
|
||||
|
||||
void Controller_Touchscreen::OnInit() {}
|
||||
|
||||
@@ -69,6 +69,5 @@ private:
|
||||
TouchScreenSharedMemory shared_memory{};
|
||||
std::unique_ptr<Input::TouchDevice> touch_device;
|
||||
s64_le last_touch{};
|
||||
Core::System& system;
|
||||
};
|
||||
} // namespace Service::HID
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace Service::HID {
|
||||
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3C00;
|
||||
|
||||
Controller_XPad::Controller_XPad(Core::System& system) : ControllerBase(system), system(system) {}
|
||||
Controller_XPad::Controller_XPad(Core::System& system) : ControllerBase(system) {}
|
||||
Controller_XPad::~Controller_XPad() = default;
|
||||
|
||||
void Controller_XPad::OnInit() {}
|
||||
|
||||
@@ -56,6 +56,5 @@ private:
|
||||
};
|
||||
static_assert(sizeof(SharedMemory) == 0x1000, "SharedMemory is an invalid size");
|
||||
SharedMemory shared_memory{};
|
||||
Core::System& system;
|
||||
};
|
||||
} // namespace Service::HID
|
||||
|
||||
@@ -38,8 +38,10 @@ namespace Service::HID {
|
||||
// Updating period for each HID device.
|
||||
// TODO(ogniK): Find actual polling rate of hid
|
||||
constexpr s64 pad_update_ticks = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 66);
|
||||
constexpr s64 accelerometer_update_ticks = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 100);
|
||||
constexpr s64 gyroscope_update_ticks = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 100);
|
||||
[[maybe_unused]] constexpr s64 accelerometer_update_ticks =
|
||||
static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 100);
|
||||
[[maybe_unused]] constexpr s64 gyroscope_update_ticks =
|
||||
static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 100);
|
||||
constexpr std::size_t SHARED_MEMORY_SIZE = 0x40000;
|
||||
|
||||
IAppletResource::IAppletResource(Core::System& system)
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
namespace Service::NFP {
|
||||
|
||||
namespace ErrCodes {
|
||||
constexpr ResultCode ERR_TAG_FAILED(ErrorModule::NFP,
|
||||
-1); // TODO(ogniK): Find the actual error code
|
||||
[[maybe_unused]] constexpr ResultCode ERR_TAG_FAILED(ErrorModule::NFP,
|
||||
-1); // TODO(ogniK): Find the actual error code
|
||||
constexpr ResultCode ERR_NO_APPLICATION_AREA(ErrorModule::NFP, 152);
|
||||
} // namespace ErrCodes
|
||||
|
||||
@@ -35,7 +35,7 @@ Module::Interface::~Interface() = default;
|
||||
class IUser final : public ServiceFramework<IUser> {
|
||||
public:
|
||||
IUser(Module::Interface& nfp_interface, Core::System& system)
|
||||
: ServiceFramework("NFP::IUser"), nfp_interface(nfp_interface), system(system) {
|
||||
: ServiceFramework("NFP::IUser"), nfp_interface(nfp_interface) {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &IUser::Initialize, "Initialize"},
|
||||
{1, &IUser::Finalize, "Finalize"},
|
||||
@@ -183,6 +183,8 @@ private:
|
||||
case DeviceState::TagRemoved:
|
||||
device_state = DeviceState::Initialized;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
@@ -324,7 +326,6 @@ private:
|
||||
Kernel::EventPair deactivate_event;
|
||||
Kernel::EventPair availability_change_event;
|
||||
const Module::Interface& nfp_interface;
|
||||
Core::System& system;
|
||||
};
|
||||
|
||||
void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) {
|
||||
|
||||
@@ -45,6 +45,8 @@ u32 nvhost_as_gpu::ioctl(Ioctl command, const std::vector<u8>& input, const std:
|
||||
return GetVARegions(input, output);
|
||||
case IoctlCommand::IocUnmapBufferCommand:
|
||||
return UnmapBuffer(input, output);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (static_cast<IoctlCommand>(command.cmd.Value()) == IoctlCommand::IocRemapCommand)
|
||||
|
||||
@@ -38,9 +38,10 @@ u32 nvhost_ctrl::ioctl(Ioctl command, const std::vector<u8>& input, const std::v
|
||||
return IocCtrlEventUnregister(input, output);
|
||||
case IoctlCommand::IocCtrlEventSignalCommand:
|
||||
return IocCtrlEventSignal(input, output);
|
||||
default:
|
||||
UNIMPLEMENTED_MSG("Unimplemented ioctl");
|
||||
return 0;
|
||||
}
|
||||
UNIMPLEMENTED_MSG("Unimplemented ioctl");
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 nvhost_ctrl::NvOsGetConfigU32(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
|
||||
@@ -40,9 +40,10 @@ u32 nvhost_ctrl_gpu::ioctl(Ioctl command, const std::vector<u8>& input,
|
||||
return FlushL2(input, output);
|
||||
case IoctlCommand::IocGetGpuTime:
|
||||
return GetGpuTime(input, output);
|
||||
default:
|
||||
UNIMPLEMENTED_MSG("Unimplemented ioctl");
|
||||
return 0;
|
||||
}
|
||||
UNIMPLEMENTED_MSG("Unimplemented ioctl");
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 nvhost_ctrl_gpu::GetCharacteristics(const std::vector<u8>& input, std::vector<u8>& output,
|
||||
|
||||
@@ -44,6 +44,8 @@ u32 nvhost_gpu::ioctl(Ioctl command, const std::vector<u8>& input, const std::ve
|
||||
return GetWaitbase(input, output);
|
||||
case IoctlCommand::IocChannelSetTimeoutCommand:
|
||||
return ChannelSetTimeout(input, output);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (command.group == NVGPU_IOCTL_MAGIC) {
|
||||
|
||||
@@ -94,7 +94,6 @@ void LogSettings() {
|
||||
LogSetting("Renderer_UseAccurateGpuEmulation", Settings::values.use_accurate_gpu_emulation);
|
||||
LogSetting("Renderer_UseAsynchronousGpuEmulation",
|
||||
Settings::values.use_asynchronous_gpu_emulation);
|
||||
LogSetting("Renderer_UseResolutionScanner", Settings::values.use_resolution_scanner);
|
||||
LogSetting("Audio_OutputEngine", Settings::values.sink_id);
|
||||
LogSetting("Audio_EnableAudioStretching", Settings::values.enable_audio_stretching);
|
||||
LogSetting("Audio_OutputDevice", Settings::values.audio_device_id);
|
||||
|
||||
@@ -423,7 +423,6 @@ struct Values {
|
||||
bool use_accurate_gpu_emulation;
|
||||
bool use_asynchronous_gpu_emulation;
|
||||
bool force_30fps_mode;
|
||||
bool use_resolution_scanner;
|
||||
|
||||
float bg_red;
|
||||
float bg_green;
|
||||
|
||||
@@ -122,8 +122,6 @@ add_library(video_core STATIC
|
||||
shader/track.cpp
|
||||
surface.cpp
|
||||
surface.h
|
||||
texture_cache/resolution_scaling/database.cpp
|
||||
texture_cache/resolution_scaling/database.h
|
||||
texture_cache/surface_base.cpp
|
||||
texture_cache/surface_base.h
|
||||
texture_cache/surface_params.cpp
|
||||
@@ -173,7 +171,7 @@ endif()
|
||||
create_target_directory_groups(video_core)
|
||||
|
||||
target_link_libraries(video_core PUBLIC common core)
|
||||
target_link_libraries(video_core PRIVATE glad json-headers)
|
||||
target_link_libraries(video_core PRIVATE glad)
|
||||
if (ENABLE_VULKAN)
|
||||
target_link_libraries(video_core PRIVATE sirit)
|
||||
endif()
|
||||
|
||||
@@ -251,10 +251,7 @@ void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) {
|
||||
if (!gpu.regs.IsShaderConfigEnabled(index)) {
|
||||
switch (program) {
|
||||
case Maxwell::ShaderProgram::Geometry:
|
||||
shader_program_manager->BindGeometryShader(nullptr);
|
||||
break;
|
||||
case Maxwell::ShaderProgram::Fragment:
|
||||
shader_program_manager->BindFragmentShader(nullptr);
|
||||
shader_program_manager->UseTrivialGeometryShader();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -264,6 +261,14 @@ void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) {
|
||||
|
||||
const std::size_t stage{index == 0 ? 0 : index - 1}; // Stage indices are 0 - 5
|
||||
|
||||
GLShader::MaxwellUniformData ubo{};
|
||||
ubo.SetFromRegs(gpu, stage);
|
||||
const auto [buffer, offset] =
|
||||
buffer_cache.UploadHostMemory(&ubo, sizeof(ubo), device.GetUniformBufferAlignment());
|
||||
|
||||
// Bind the emulation info buffer
|
||||
bind_ubo_pushbuffer.Push(buffer, offset, static_cast<GLsizeiptr>(sizeof(ubo)));
|
||||
|
||||
Shader shader{shader_cache.GetStageProgram(program)};
|
||||
|
||||
const auto stage_enum = static_cast<Maxwell::ShaderStage>(stage);
|
||||
@@ -277,13 +282,13 @@ void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) {
|
||||
switch (program) {
|
||||
case Maxwell::ShaderProgram::VertexA:
|
||||
case Maxwell::ShaderProgram::VertexB:
|
||||
shader_program_manager->BindVertexShader(&program_handle);
|
||||
shader_program_manager->UseProgrammableVertexShader(program_handle);
|
||||
break;
|
||||
case Maxwell::ShaderProgram::Geometry:
|
||||
shader_program_manager->BindGeometryShader(&program_handle);
|
||||
shader_program_manager->UseProgrammableGeometryShader(program_handle);
|
||||
break;
|
||||
case Maxwell::ShaderProgram::Fragment:
|
||||
shader_program_manager->BindFragmentShader(&program_handle);
|
||||
shader_program_manager->UseProgrammableFragmentShader(program_handle);
|
||||
break;
|
||||
default:
|
||||
UNIMPLEMENTED_MSG("Unimplemented shader index={}, enable={}, offset=0x{:08X}", index,
|
||||
@@ -375,7 +380,6 @@ void RasterizerOpenGL::UpdatePagesCachedCount(VAddr addr, u64 size, int delta) {
|
||||
void RasterizerOpenGL::LoadDiskResources(const std::atomic_bool& stop_loading,
|
||||
const VideoCore::DiskResourceLoadCallback& callback) {
|
||||
shader_cache.LoadDiskCache(stop_loading, callback);
|
||||
texture_cache.LoadResources();
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::ConfigureFramebuffers() {
|
||||
@@ -422,6 +426,7 @@ void RasterizerOpenGL::ConfigureFramebuffers() {
|
||||
texture_cache.GuardRenderTargets(false);
|
||||
|
||||
state.draw.draw_framebuffer = framebuffer_cache.GetFramebuffer(fbkey);
|
||||
SyncViewport(state);
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::ConfigureClearFramebuffer(OpenGLState& current_state, bool using_color_fb,
|
||||
@@ -547,16 +552,9 @@ void RasterizerOpenGL::Clear() {
|
||||
|
||||
ConfigureClearFramebuffer(clear_state, use_color, use_depth, use_stencil);
|
||||
|
||||
bool res_scaling;
|
||||
if (use_color) {
|
||||
res_scaling = texture_cache.IsResolutionScalingEnabledRT(regs.clear_buffers.RT);
|
||||
} else {
|
||||
res_scaling = texture_cache.IsResolutionScalingEnabledDB();
|
||||
}
|
||||
|
||||
SyncViewport(clear_state, res_scaling);
|
||||
SyncViewport(clear_state);
|
||||
if (regs.clear_flags.scissor) {
|
||||
SyncScissorTest(clear_state, res_scaling);
|
||||
SyncScissorTest(clear_state);
|
||||
}
|
||||
|
||||
if (regs.clear_flags.viewport) {
|
||||
@@ -591,6 +589,7 @@ void RasterizerOpenGL::DrawPrelude() {
|
||||
SyncLogicOpState();
|
||||
SyncCullMode();
|
||||
SyncPrimitiveRestart();
|
||||
SyncScissorTest(state);
|
||||
SyncTransformFeedback();
|
||||
SyncPointState();
|
||||
SyncPolygonOffset();
|
||||
@@ -606,6 +605,11 @@ void RasterizerOpenGL::DrawPrelude() {
|
||||
buffer_size = Common::AlignUp(buffer_size, 4) + CalculateIndexBufferSize();
|
||||
}
|
||||
|
||||
// Uniform space for the 5 shader stages
|
||||
buffer_size = Common::AlignUp<std::size_t>(buffer_size, 4) +
|
||||
(sizeof(GLShader::MaxwellUniformData) + device.GetUniformBufferAlignment()) *
|
||||
Maxwell::MaxShaderStage;
|
||||
|
||||
// Add space for at least 18 constant buffers
|
||||
buffer_size += Maxwell::MaxConstBuffers *
|
||||
(Maxwell::MaxConstBufferSize + device.GetUniformBufferAlignment());
|
||||
@@ -647,11 +651,6 @@ void RasterizerOpenGL::DrawPrelude() {
|
||||
gpu.dirty.ResetVertexArrays();
|
||||
}
|
||||
|
||||
const bool res_scaling = texture_cache.IsResolutionScalingEnabled();
|
||||
SyncViewport(state, res_scaling);
|
||||
SyncScissorTest(state, res_scaling);
|
||||
|
||||
shader_program_manager->SetConstants(gpu, res_scaling);
|
||||
shader_program_manager->ApplyTo(state);
|
||||
state.Apply();
|
||||
|
||||
@@ -774,7 +773,7 @@ void RasterizerOpenGL::DispatchCompute(GPUVAddr code_addr) {
|
||||
SetupComputeImages(kernel);
|
||||
|
||||
const auto [program, next_bindings] = kernel->GetProgramHandle(variant);
|
||||
state.draw.shader_program = program.handle;
|
||||
state.draw.shader_program = program;
|
||||
state.draw.program_pipeline = 0;
|
||||
|
||||
const std::size_t buffer_size =
|
||||
@@ -1073,21 +1072,20 @@ void RasterizerOpenGL::SetupImage(u32 binding, const Tegra::Texture::TICEntry& t
|
||||
state.images[binding] = view->GetTexture();
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::SyncViewport(OpenGLState& current_state, bool rescaling) {
|
||||
void RasterizerOpenGL::SyncViewport(OpenGLState& current_state) {
|
||||
const auto& regs = system.GPU().Maxwell3D().regs;
|
||||
const bool geometry_shaders_enabled =
|
||||
regs.IsShaderConfigEnabled(static_cast<size_t>(Maxwell::ShaderProgram::Geometry));
|
||||
const std::size_t viewport_count =
|
||||
geometry_shaders_enabled ? Tegra::Engines::Maxwell3D::Regs::NumViewports : 1;
|
||||
const float factor = rescaling ? Settings::values.resolution_factor : 1.0f;
|
||||
for (std::size_t i = 0; i < viewport_count; i++) {
|
||||
auto& viewport = current_state.viewports[i];
|
||||
const auto& src = regs.viewports[i];
|
||||
const Common::Rectangle<s32> viewport_rect{regs.viewport_transform[i].GetRect()};
|
||||
viewport.x = static_cast<GLint>(viewport_rect.left * factor);
|
||||
viewport.y = static_cast<GLint>(viewport_rect.bottom * factor);
|
||||
viewport.width = static_cast<GLint>(viewport_rect.GetWidth() * factor);
|
||||
viewport.height = static_cast<GLint>(viewport_rect.GetHeight() * factor);
|
||||
viewport.x = viewport_rect.left;
|
||||
viewport.y = viewport_rect.bottom;
|
||||
viewport.width = viewport_rect.GetWidth();
|
||||
viewport.height = viewport_rect.GetHeight();
|
||||
viewport.depth_range_far = src.depth_range_far;
|
||||
viewport.depth_range_near = src.depth_range_near;
|
||||
}
|
||||
@@ -1298,13 +1296,12 @@ void RasterizerOpenGL::SyncLogicOpState() {
|
||||
state.logic_op.operation = MaxwellToGL::LogicOp(regs.logic_op.operation);
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::SyncScissorTest(OpenGLState& current_state, bool rescaling) {
|
||||
void RasterizerOpenGL::SyncScissorTest(OpenGLState& current_state) {
|
||||
const auto& regs = system.GPU().Maxwell3D().regs;
|
||||
const bool geometry_shaders_enabled =
|
||||
regs.IsShaderConfigEnabled(static_cast<size_t>(Maxwell::ShaderProgram::Geometry));
|
||||
const std::size_t viewport_count =
|
||||
geometry_shaders_enabled ? Tegra::Engines::Maxwell3D::Regs::NumViewports : 1;
|
||||
const float factor = rescaling ? Settings::values.resolution_factor : 1.0f;
|
||||
for (std::size_t i = 0; i < viewport_count; i++) {
|
||||
const auto& src = regs.scissor_test[i];
|
||||
auto& dst = current_state.viewports[i].scissor;
|
||||
@@ -1314,10 +1311,10 @@ void RasterizerOpenGL::SyncScissorTest(OpenGLState& current_state, bool rescalin
|
||||
}
|
||||
const u32 width = src.max_x - src.min_x;
|
||||
const u32 height = src.max_y - src.min_y;
|
||||
dst.x = static_cast<u32>(src.min_x * factor);
|
||||
dst.y = static_cast<u32>(src.min_y * factor);
|
||||
dst.width = static_cast<u32>(width * factor);
|
||||
dst.height = static_cast<u32>(height * factor);
|
||||
dst.x = src.min_x;
|
||||
dst.y = src.min_y;
|
||||
dst.width = width;
|
||||
dst.height = height;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ private:
|
||||
const GLShader::ImageEntry& entry);
|
||||
|
||||
/// Syncs the viewport and depth range to match the guest state
|
||||
void SyncViewport(OpenGLState& current_state, bool rescaling);
|
||||
void SyncViewport(OpenGLState& current_state);
|
||||
|
||||
/// Syncs the clip enabled status to match the guest state
|
||||
void SyncClipEnabled(
|
||||
@@ -162,7 +162,7 @@ private:
|
||||
void SyncMultiSampleState();
|
||||
|
||||
/// Syncs the scissor test state to match the guest state
|
||||
void SyncScissorTest(OpenGLState& current_state, bool rescaling);
|
||||
void SyncScissorTest(OpenGLState& current_state);
|
||||
|
||||
/// Syncs the transform feedback state to match the guest state
|
||||
void SyncTransformFeedback();
|
||||
|
||||
@@ -23,6 +23,9 @@ namespace OpenGL {
|
||||
|
||||
using VideoCommon::Shader::ProgramCode;
|
||||
|
||||
// One UBO is always reserved for emulation values on staged shaders
|
||||
constexpr u32 STAGE_RESERVED_UBOS = 1;
|
||||
|
||||
struct UnspecializedShader {
|
||||
std::string code;
|
||||
GLShader::ShaderEntries entries;
|
||||
@@ -221,6 +224,10 @@ CachedProgram SpecializeShader(const std::string& code, const GLShader::ShaderEn
|
||||
}
|
||||
source += '\n';
|
||||
|
||||
if (program_type != ProgramType::Compute) {
|
||||
source += fmt::format("#define EMULATION_UBO_BINDING {}\n", base_bindings.cbuf++);
|
||||
}
|
||||
|
||||
for (const auto& cbuf : entries.const_buffers) {
|
||||
source +=
|
||||
fmt::format("#define CBUF_BINDING_{} {}\n", cbuf.GetIndex(), base_bindings.cbuf++);
|
||||
@@ -266,9 +273,8 @@ CachedProgram SpecializeShader(const std::string& code, const GLShader::ShaderEn
|
||||
OGLShader shader;
|
||||
shader.Create(source.c_str(), GetShaderType(program_type));
|
||||
|
||||
auto program = std::make_shared<GLShader::StageProgram>();
|
||||
auto program = std::make_shared<OGLProgram>();
|
||||
program->Create(true, hint_retrievable, shader.handle);
|
||||
program->SetUniformLocations();
|
||||
return program;
|
||||
}
|
||||
|
||||
@@ -342,26 +348,28 @@ Shader CachedShader::CreateKernelFromCache(const ShaderParameters& params,
|
||||
new CachedShader(params, ProgramType::Compute, std::move(result)));
|
||||
}
|
||||
|
||||
std::tuple<GLShader::StageProgram&, BaseBindings> CachedShader::GetProgramHandle(
|
||||
const ProgramVariant& variant) {
|
||||
std::tuple<GLuint, BaseBindings> CachedShader::GetProgramHandle(const ProgramVariant& variant) {
|
||||
const auto [entry, is_cache_miss] = programs.try_emplace(variant);
|
||||
auto& stage_program = entry->second;
|
||||
auto& program = entry->second;
|
||||
if (is_cache_miss) {
|
||||
stage_program = TryLoadProgram(variant);
|
||||
if (!stage_program) {
|
||||
stage_program = SpecializeShader(code, entries, program_type, variant);
|
||||
program = TryLoadProgram(variant);
|
||||
if (!program) {
|
||||
program = SpecializeShader(code, entries, program_type, variant);
|
||||
disk_cache.SaveUsage(GetUsage(variant));
|
||||
}
|
||||
|
||||
LabelGLObject(GL_PROGRAM, stage_program->handle, cpu_addr);
|
||||
LabelGLObject(GL_PROGRAM, program->handle, cpu_addr);
|
||||
}
|
||||
|
||||
auto base_bindings{variant.base_bindings};
|
||||
auto base_bindings = variant.base_bindings;
|
||||
base_bindings.cbuf += static_cast<u32>(entries.const_buffers.size());
|
||||
if (program_type != ProgramType::Compute) {
|
||||
base_bindings.cbuf += STAGE_RESERVED_UBOS;
|
||||
}
|
||||
base_bindings.gmem += static_cast<u32>(entries.global_memory_entries.size());
|
||||
base_bindings.sampler += static_cast<u32>(entries.samplers.size());
|
||||
|
||||
return {*stage_program, base_bindings};
|
||||
return {program->handle, base_bindings};
|
||||
}
|
||||
|
||||
CachedProgram CachedShader::TryLoadProgram(const ProgramVariant& variant) const {
|
||||
@@ -508,7 +516,7 @@ CachedProgram ShaderCacheOpenGL::GeneratePrecompiledProgram(
|
||||
return {};
|
||||
}
|
||||
|
||||
CachedProgram shader = std::make_shared<GLShader::StageProgram>();
|
||||
CachedProgram shader = std::make_shared<OGLProgram>();
|
||||
shader->handle = glCreateProgram();
|
||||
glProgramParameteri(shader->handle, GL_PROGRAM_SEPARABLE, GL_TRUE);
|
||||
glProgramBinary(shader->handle, dump.binary_format, dump.binary.data(),
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
||||
#include "video_core/renderer_opengl/gl_shader_decompiler.h"
|
||||
#include "video_core/renderer_opengl/gl_shader_disk_cache.h"
|
||||
#include "video_core/renderer_opengl/gl_shader_manager.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
@@ -38,7 +37,7 @@ class RasterizerOpenGL;
|
||||
struct UnspecializedShader;
|
||||
|
||||
using Shader = std::shared_ptr<CachedShader>;
|
||||
using CachedProgram = std::shared_ptr<GLShader::StageProgram>;
|
||||
using CachedProgram = std::shared_ptr<OGLProgram>;
|
||||
using Maxwell = Tegra::Engines::Maxwell3D::Regs;
|
||||
using PrecompiledPrograms = std::unordered_map<ShaderDiskCacheUsage, CachedProgram>;
|
||||
using PrecompiledShaders = std::unordered_map<u64, GLShader::ProgramResult>;
|
||||
@@ -81,8 +80,7 @@ public:
|
||||
}
|
||||
|
||||
/// Gets the GL program handle for the shader
|
||||
std::tuple<GLShader::StageProgram&, BaseBindings> GetProgramHandle(
|
||||
const ProgramVariant& variant);
|
||||
std::tuple<GLuint, BaseBindings> GetProgramHandle(const ProgramVariant& variant);
|
||||
|
||||
private:
|
||||
explicit CachedShader(const ShaderParameters& params, ProgramType program_type,
|
||||
|
||||
@@ -946,18 +946,9 @@ private:
|
||||
return {fmt::format("gl_in[{}].gl_Position{}", Visit(buffer).AsUint(),
|
||||
GetSwizzle(element)),
|
||||
Type::Float};
|
||||
case ProgramType::Fragment: {
|
||||
switch (element) {
|
||||
case 0:
|
||||
return {"(gl_FragCoord.x / utof(config_pack[3]))", Type::Float};
|
||||
case 1:
|
||||
return {"(gl_FragCoord.y / utof(config_pack[3]))", Type::Float};
|
||||
case 2:
|
||||
return {"gl_FragCoord.z", Type::Float};
|
||||
case 3:
|
||||
return {"1.0f", Type::Float};
|
||||
}
|
||||
}
|
||||
case ProgramType::Fragment:
|
||||
return {element == 3 ? "1.0f" : ("gl_FragCoord"s + GetSwizzle(element)),
|
||||
Type::Float};
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
@@ -2495,9 +2486,7 @@ std::string GetCommonDeclarations() {
|
||||
" bvec2 is_nan2 = isnan(pair2);\n"
|
||||
" return bvec2(comparison.x || is_nan1.x || is_nan2.x, comparison.y || is_nan1.y || "
|
||||
"is_nan2.y);\n"
|
||||
"}}\n\n"
|
||||
"uniform uvec4 config_pack; // instance_id, flip_stage, y_direction, padding\n"
|
||||
"uniform vec2 viewport_flip;\n\n");
|
||||
"}}\n\n");
|
||||
}
|
||||
|
||||
ProgramResult Decompile(const Device& device, const ShaderIR& ir, ProgramType stage,
|
||||
|
||||
@@ -27,6 +27,14 @@ ProgramResult GenerateVertexShader(const Device& device, const ShaderSetup& setu
|
||||
std::string out = "// Shader Unique Id: VS" + id + "\n\n";
|
||||
out += GetCommonDeclarations();
|
||||
|
||||
out += R"(
|
||||
layout (std140, binding = EMULATION_UBO_BINDING) uniform vs_config {
|
||||
vec4 viewport_flip;
|
||||
uvec4 config_pack; // instance_id, flip_stage, y_direction, padding
|
||||
};
|
||||
|
||||
)";
|
||||
|
||||
const ShaderIR program_ir(setup.program.code, PROGRAM_OFFSET, setup.program.size_a, settings);
|
||||
const auto stage = setup.IsDualProgram() ? ProgramType::VertexA : ProgramType::VertexB;
|
||||
ProgramResult program = Decompile(device, program_ir, stage, "vertex");
|
||||
@@ -69,6 +77,14 @@ ProgramResult GenerateGeometryShader(const Device& device, const ShaderSetup& se
|
||||
std::string out = "// Shader Unique Id: GS" + id + "\n\n";
|
||||
out += GetCommonDeclarations();
|
||||
|
||||
out += R"(
|
||||
layout (std140, binding = EMULATION_UBO_BINDING) uniform gs_config {
|
||||
vec4 viewport_flip;
|
||||
uvec4 config_pack; // instance_id, flip_stage, y_direction, padding
|
||||
};
|
||||
|
||||
)";
|
||||
|
||||
const ShaderIR program_ir(setup.program.code, PROGRAM_OFFSET, setup.program.size_a, settings);
|
||||
ProgramResult program = Decompile(device, program_ir, ProgramType::Geometry, "geometry");
|
||||
out += program.first;
|
||||
@@ -76,7 +92,7 @@ ProgramResult GenerateGeometryShader(const Device& device, const ShaderSetup& se
|
||||
out += R"(
|
||||
void main() {
|
||||
execute_geometry();
|
||||
})";
|
||||
};)";
|
||||
|
||||
return {std::move(out), std::move(program.second)};
|
||||
}
|
||||
@@ -97,6 +113,11 @@ layout (location = 5) out vec4 FragColor5;
|
||||
layout (location = 6) out vec4 FragColor6;
|
||||
layout (location = 7) out vec4 FragColor7;
|
||||
|
||||
layout (std140, binding = EMULATION_UBO_BINDING) uniform fs_config {
|
||||
vec4 viewport_flip;
|
||||
uvec4 config_pack; // instance_id, flip_stage, y_direction, padding
|
||||
};
|
||||
|
||||
)";
|
||||
|
||||
const ShaderIR program_ir(setup.program.code, PROGRAM_OFFSET, setup.program.size_a, settings);
|
||||
|
||||
@@ -2,35 +2,13 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <array>
|
||||
#include "common/common_types.h"
|
||||
#include "core/settings.h"
|
||||
#include "video_core/engines/maxwell_3d.h"
|
||||
#include "video_core/renderer_opengl/gl_shader_manager.h"
|
||||
|
||||
namespace OpenGL::GLShader {
|
||||
|
||||
using Maxwell = Tegra::Engines::Maxwell3D::Regs;
|
||||
|
||||
StageProgram::StageProgram() = default;
|
||||
|
||||
StageProgram::~StageProgram() = default;
|
||||
|
||||
void StageProgram::SetUniformLocations() {
|
||||
config_pack_location = glGetUniformLocation(handle, "config_pack");
|
||||
viewport_flip_location = glGetUniformLocation(handle, "viewport_flip");
|
||||
}
|
||||
|
||||
void StageProgram::UpdateConstants() {
|
||||
if (state.config_pack != old_state.config_pack) {
|
||||
glProgramUniform4uiv(handle, config_pack_location, 1, state.config_pack.data());
|
||||
old_state.config_pack = state.config_pack;
|
||||
}
|
||||
if (state.viewport_scale != old_state.viewport_scale) {
|
||||
glProgramUniform2fv(handle, viewport_flip_location, 1, state.viewport_scale.data());
|
||||
old_state.viewport_scale = state.viewport_scale;
|
||||
}
|
||||
}
|
||||
using Tegra::Engines::Maxwell3D;
|
||||
|
||||
ProgramManager::ProgramManager() {
|
||||
pipeline.Create();
|
||||
@@ -38,59 +16,12 @@ ProgramManager::ProgramManager() {
|
||||
|
||||
ProgramManager::~ProgramManager() = default;
|
||||
|
||||
void ProgramManager::SetConstants(Tegra::Engines::Maxwell3D& maxwell_3d, bool rescaling) {
|
||||
const auto& regs = maxwell_3d.regs;
|
||||
const auto& state = maxwell_3d.state;
|
||||
|
||||
// TODO(bunnei): Support more than one viewport
|
||||
const GLfloat flip_x = regs.viewport_transform[0].scale_x < 0.0 ? -1.0f : 1.0f;
|
||||
const GLfloat flip_y = regs.viewport_transform[0].scale_y < 0.0 ? -1.0f : 1.0f;
|
||||
|
||||
const GLuint instance_id = state.current_instance;
|
||||
|
||||
// Assign in which stage the position has to be flipped (the last stage before the fragment
|
||||
// shader).
|
||||
const GLuint flip_stage = [&]() {
|
||||
constexpr u32 geometry_index = static_cast<u32>(Maxwell::ShaderProgram::Geometry);
|
||||
if (regs.shader_config[geometry_index].enable) {
|
||||
return geometry_index;
|
||||
} else {
|
||||
return static_cast<u32>(Maxwell::ShaderProgram::VertexB);
|
||||
}
|
||||
}();
|
||||
|
||||
// Y_NEGATE controls what value S2R returns for the Y_DIRECTION system value.
|
||||
const GLfloat y_direction = regs.screen_y_control.y_negate == 0 ? 1.0f : -1.0f;
|
||||
|
||||
const GLfloat rescale_factor = rescaling ? Settings::values.resolution_factor : 1.0f;
|
||||
|
||||
for (const auto stage :
|
||||
{current_state.vertex, current_state.geometry, current_state.fragment}) {
|
||||
if (!stage) {
|
||||
continue;
|
||||
}
|
||||
stage->SetInstanceID(instance_id);
|
||||
stage->SetFlipStage(flip_stage);
|
||||
stage->SetYDirection(y_direction);
|
||||
stage->SetViewportScale(flip_x, flip_y);
|
||||
stage->SetRescalingFactor(rescale_factor);
|
||||
stage->UpdateConstants();
|
||||
}
|
||||
}
|
||||
|
||||
void ProgramManager::ApplyTo(OpenGLState& state) {
|
||||
UpdatePipeline();
|
||||
state.draw.shader_program = 0;
|
||||
state.draw.program_pipeline = pipeline.handle;
|
||||
}
|
||||
|
||||
GLuint GetHandle(StageProgram* program) {
|
||||
if (!program) {
|
||||
return 0;
|
||||
}
|
||||
return program->handle;
|
||||
}
|
||||
|
||||
void ProgramManager::UpdatePipeline() {
|
||||
// Avoid updating the pipeline when values have no changed
|
||||
if (old_state == current_state) {
|
||||
@@ -102,11 +33,34 @@ void ProgramManager::UpdatePipeline() {
|
||||
GL_FRAGMENT_SHADER_BIT};
|
||||
glUseProgramStages(pipeline.handle, all_used_stages, 0);
|
||||
|
||||
glUseProgramStages(pipeline.handle, GL_VERTEX_SHADER_BIT, GetHandle(current_state.vertex));
|
||||
glUseProgramStages(pipeline.handle, GL_GEOMETRY_SHADER_BIT, GetHandle(current_state.geometry));
|
||||
glUseProgramStages(pipeline.handle, GL_FRAGMENT_SHADER_BIT, GetHandle(current_state.fragment));
|
||||
glUseProgramStages(pipeline.handle, GL_VERTEX_SHADER_BIT, current_state.vertex_shader);
|
||||
glUseProgramStages(pipeline.handle, GL_GEOMETRY_SHADER_BIT, current_state.geometry_shader);
|
||||
glUseProgramStages(pipeline.handle, GL_FRAGMENT_SHADER_BIT, current_state.fragment_shader);
|
||||
|
||||
old_state = current_state;
|
||||
}
|
||||
|
||||
void MaxwellUniformData::SetFromRegs(const Maxwell3D& maxwell, std::size_t shader_stage) {
|
||||
const auto& regs = maxwell.regs;
|
||||
const auto& state = maxwell.state;
|
||||
|
||||
// TODO(bunnei): Support more than one viewport
|
||||
viewport_flip[0] = regs.viewport_transform[0].scale_x < 0.0 ? -1.0f : 1.0f;
|
||||
viewport_flip[1] = regs.viewport_transform[0].scale_y < 0.0 ? -1.0f : 1.0f;
|
||||
|
||||
instance_id = state.current_instance;
|
||||
|
||||
// Assign in which stage the position has to be flipped
|
||||
// (the last stage before the fragment shader).
|
||||
constexpr u32 geometry_index = static_cast<u32>(Maxwell3D::Regs::ShaderProgram::Geometry);
|
||||
if (maxwell.regs.shader_config[geometry_index].enable) {
|
||||
flip_stage = geometry_index;
|
||||
} else {
|
||||
flip_stage = static_cast<u32>(Maxwell3D::Regs::ShaderProgram::VertexB);
|
||||
}
|
||||
|
||||
// Y_NEGATE controls what value S2R returns for the Y_DIRECTION system value.
|
||||
y_direction = regs.screen_y_control.y_negate == 0 ? 1.f : -1.f;
|
||||
}
|
||||
|
||||
} // namespace OpenGL::GLShader
|
||||
|
||||
@@ -4,108 +4,71 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <tuple>
|
||||
|
||||
#include <glad/glad.h>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
||||
#include "video_core/renderer_opengl/gl_state.h"
|
||||
#include "video_core/renderer_opengl/maxwell_to_gl.h"
|
||||
|
||||
namespace Tegra::Engines {
|
||||
class Maxwell3D;
|
||||
}
|
||||
|
||||
namespace OpenGL::GLShader {
|
||||
|
||||
class StageProgram final : public OGLProgram {
|
||||
public:
|
||||
explicit StageProgram();
|
||||
~StageProgram();
|
||||
/// Uniform structure for the Uniform Buffer Object, all vectors must be 16-byte aligned
|
||||
/// @note Always keep a vec4 at the end. The GL spec is not clear whether the alignment at
|
||||
/// the end of a uniform block is included in UNIFORM_BLOCK_DATA_SIZE or not.
|
||||
/// Not following that rule will cause problems on some AMD drivers.
|
||||
struct MaxwellUniformData {
|
||||
void SetFromRegs(const Tegra::Engines::Maxwell3D& maxwell, std::size_t shader_stage);
|
||||
|
||||
void SetUniformLocations();
|
||||
|
||||
void UpdateConstants();
|
||||
|
||||
void SetInstanceID(GLuint instance_id) {
|
||||
state.instance_id = instance_id;
|
||||
}
|
||||
|
||||
void SetFlipStage(GLuint flip_stage) {
|
||||
state.flip_stage = flip_stage;
|
||||
}
|
||||
|
||||
void SetYDirection(GLfloat y_direction) {
|
||||
state.y_direction = y_direction;
|
||||
}
|
||||
|
||||
void SetRescalingFactor(GLfloat rescaling_factor) {
|
||||
state.rescaling_factor = rescaling_factor;
|
||||
}
|
||||
|
||||
void SetViewportScale(GLfloat x, GLfloat y) {
|
||||
state.viewport_scale = {x, y};
|
||||
}
|
||||
|
||||
private:
|
||||
struct State {
|
||||
union {
|
||||
std::array<GLuint, 4> config_pack{};
|
||||
struct {
|
||||
GLuint instance_id;
|
||||
GLuint flip_stage;
|
||||
GLfloat y_direction;
|
||||
GLfloat rescaling_factor;
|
||||
};
|
||||
};
|
||||
|
||||
std::array<GLfloat, 2> viewport_scale{};
|
||||
alignas(16) GLvec4 viewport_flip;
|
||||
struct alignas(16) {
|
||||
GLuint instance_id;
|
||||
GLuint flip_stage;
|
||||
GLfloat y_direction;
|
||||
};
|
||||
|
||||
GLint config_pack_location = -1;
|
||||
GLint viewport_flip_location = -1;
|
||||
|
||||
State state;
|
||||
State old_state;
|
||||
};
|
||||
static_assert(sizeof(MaxwellUniformData) == 32, "MaxwellUniformData structure size is incorrect");
|
||||
static_assert(sizeof(MaxwellUniformData) < 16384,
|
||||
"MaxwellUniformData structure must be less than 16kb as per the OpenGL spec");
|
||||
|
||||
class ProgramManager final {
|
||||
class ProgramManager {
|
||||
public:
|
||||
explicit ProgramManager();
|
||||
~ProgramManager();
|
||||
|
||||
void SetConstants(Tegra::Engines::Maxwell3D& maxwell_3d, bool rescaling);
|
||||
|
||||
void ApplyTo(OpenGLState& state);
|
||||
|
||||
void BindVertexShader(StageProgram* program) {
|
||||
current_state.vertex = program;
|
||||
void UseProgrammableVertexShader(GLuint program) {
|
||||
current_state.vertex_shader = program;
|
||||
}
|
||||
|
||||
void BindGeometryShader(StageProgram* program) {
|
||||
current_state.geometry = program;
|
||||
void UseProgrammableGeometryShader(GLuint program) {
|
||||
current_state.geometry_shader = program;
|
||||
}
|
||||
|
||||
void BindFragmentShader(StageProgram* program) {
|
||||
current_state.fragment = program;
|
||||
void UseProgrammableFragmentShader(GLuint program) {
|
||||
current_state.fragment_shader = program;
|
||||
}
|
||||
|
||||
void UseTrivialGeometryShader() {
|
||||
current_state.geometry_shader = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
struct PipelineState {
|
||||
bool operator==(const PipelineState& rhs) const {
|
||||
return vertex == rhs.vertex && fragment == rhs.fragment && geometry == rhs.geometry;
|
||||
return vertex_shader == rhs.vertex_shader && fragment_shader == rhs.fragment_shader &&
|
||||
geometry_shader == rhs.geometry_shader;
|
||||
}
|
||||
|
||||
bool operator!=(const PipelineState& rhs) const {
|
||||
return !operator==(rhs);
|
||||
}
|
||||
|
||||
StageProgram* vertex{};
|
||||
StageProgram* fragment{};
|
||||
StageProgram* geometry{};
|
||||
GLuint vertex_shader{};
|
||||
GLuint fragment_shader{};
|
||||
GLuint geometry_shader{};
|
||||
};
|
||||
|
||||
void UpdatePipeline();
|
||||
|
||||
@@ -199,7 +199,7 @@ void ApplyTextureDefaults(const SurfaceParams& params, GLuint texture) {
|
||||
}
|
||||
|
||||
OGLTexture CreateTexture(const SurfaceParams& params, GLenum target, GLenum internal_format,
|
||||
OGLBuffer& texture_buffer, u32 resolution_factor) {
|
||||
OGLBuffer& texture_buffer) {
|
||||
OGLTexture texture;
|
||||
texture.Create(target);
|
||||
|
||||
@@ -214,9 +214,6 @@ OGLTexture CreateTexture(const SurfaceParams& params, GLenum target, GLenum inte
|
||||
glTextureBuffer(texture.handle, internal_format, texture_buffer.handle);
|
||||
break;
|
||||
case SurfaceTarget::Texture2D:
|
||||
glTextureStorage2D(texture.handle, params.emulated_levels, internal_format,
|
||||
params.width * resolution_factor, params.height * resolution_factor);
|
||||
break;
|
||||
case SurfaceTarget::TextureCubemap:
|
||||
glTextureStorage2D(texture.handle, params.emulated_levels, internal_format, params.width,
|
||||
params.height);
|
||||
@@ -245,13 +242,8 @@ CachedSurface::CachedSurface(const GPUVAddr gpu_addr, const SurfaceParams& param
|
||||
format = tuple.format;
|
||||
type = tuple.type;
|
||||
is_compressed = tuple.compressed;
|
||||
}
|
||||
|
||||
void CachedSurface::Init() {
|
||||
target = GetTextureTarget(params.target);
|
||||
const u32 resolution_factor =
|
||||
IsRescaled() ? static_cast<u32>(Settings::values.resolution_factor) : 1;
|
||||
texture = CreateTexture(params, target, internal_format, texture_buffer, resolution_factor);
|
||||
texture = CreateTexture(params, target, internal_format, texture_buffer);
|
||||
DecorateSurfaceName();
|
||||
main_view = CreateViewInner(
|
||||
ViewParams(params.target, 0, params.is_layered ? params.depth : 1, 0, params.num_levels),
|
||||
@@ -469,10 +461,7 @@ TextureCacheOpenGL::TextureCacheOpenGL(Core::System& system,
|
||||
TextureCacheOpenGL::~TextureCacheOpenGL() = default;
|
||||
|
||||
Surface TextureCacheOpenGL::CreateSurface(GPUVAddr gpu_addr, const SurfaceParams& params) {
|
||||
Surface new_surface = std::make_shared<CachedSurface>(gpu_addr, params);
|
||||
SignalCreatedSurface(new_surface);
|
||||
new_surface->Init();
|
||||
return new_surface;
|
||||
return std::make_shared<CachedSurface>(gpu_addr, params);
|
||||
}
|
||||
|
||||
void TextureCacheOpenGL::ImageCopy(Surface& src_surface, Surface& dst_surface,
|
||||
@@ -483,21 +472,15 @@ void TextureCacheOpenGL::ImageCopy(Surface& src_surface, Surface& dst_surface,
|
||||
// A fallback is needed
|
||||
return;
|
||||
}
|
||||
const bool src_rescaled = src_surface->IsRescaled();
|
||||
const bool dst_rescaled = dst_surface->IsRescaled();
|
||||
if (src_rescaled != dst_rescaled) {
|
||||
LOG_CRITICAL(HW_GPU, "Rescaling Database is incorrectly set! Rescan the database!.");
|
||||
}
|
||||
const u32 factor = src_rescaled ? static_cast<u32>(Settings::values.resolution_factor) : 1U;
|
||||
const auto src_handle = src_surface->GetTexture();
|
||||
const auto src_target = src_surface->GetTarget();
|
||||
const auto dst_handle = dst_surface->GetTexture();
|
||||
const auto dst_target = dst_surface->GetTarget();
|
||||
glCopyImageSubData(src_handle, src_target, copy_params.source_level,
|
||||
copy_params.source_x * factor, copy_params.source_y * factor,
|
||||
copy_params.source_z, dst_handle, dst_target, copy_params.dest_level,
|
||||
copy_params.dest_x * factor, copy_params.dest_y * factor, copy_params.dest_z,
|
||||
copy_params.width * factor, copy_params.height * factor, copy_params.depth);
|
||||
glCopyImageSubData(src_handle, src_target, copy_params.source_level, copy_params.source_x,
|
||||
copy_params.source_y, copy_params.source_z, dst_handle, dst_target,
|
||||
copy_params.dest_level, copy_params.dest_x, copy_params.dest_y,
|
||||
copy_params.dest_z, copy_params.width, copy_params.height,
|
||||
copy_params.depth);
|
||||
}
|
||||
|
||||
void TextureCacheOpenGL::ImageBlit(View& src_view, View& dst_view,
|
||||
@@ -556,14 +539,8 @@ void TextureCacheOpenGL::ImageBlit(View& src_view, View& dst_view,
|
||||
const Common::Rectangle<u32>& dst_rect = copy_config.dst_rect;
|
||||
const bool is_linear = copy_config.filter == Tegra::Engines::Fermi2D::Filter::Linear;
|
||||
|
||||
const bool src_rescaled = src_view->GetParent().IsRescaled();
|
||||
const bool dst_rescaled = dst_view->GetParent().IsRescaled();
|
||||
const u32 factor1 = src_rescaled ? static_cast<u32>(Settings::values.resolution_factor) : 1U;
|
||||
const u32 factor2 = dst_rescaled ? static_cast<u32>(Settings::values.resolution_factor) : 1U;
|
||||
|
||||
glBlitFramebuffer(src_rect.left * factor1, src_rect.top * factor1, src_rect.right * factor1,
|
||||
src_rect.bottom * factor1, dst_rect.left * factor2, dst_rect.top * factor2,
|
||||
dst_rect.right * factor2, dst_rect.bottom * factor2, buffers,
|
||||
glBlitFramebuffer(src_rect.left, src_rect.top, src_rect.right, src_rect.bottom, dst_rect.left,
|
||||
dst_rect.top, dst_rect.right, dst_rect.bottom, buffers,
|
||||
is_linear && (buffers == GL_COLOR_BUFFER_BIT) ? GL_LINEAR : GL_NEAREST);
|
||||
}
|
||||
|
||||
@@ -576,15 +553,8 @@ void TextureCacheOpenGL::BufferCopy(Surface& src_surface, Surface& dst_surface)
|
||||
const auto source_format = GetFormatTuple(src_params.pixel_format, src_params.component_type);
|
||||
const auto dest_format = GetFormatTuple(dst_params.pixel_format, dst_params.component_type);
|
||||
|
||||
const bool src_rescaled = src_surface->IsRescaled();
|
||||
const bool dst_rescaled = dst_surface->IsRescaled();
|
||||
if (src_rescaled != dst_rescaled) {
|
||||
LOG_CRITICAL(HW_GPU, "Rescaling Database is incorrectly set! Rescan the database!.");
|
||||
}
|
||||
const u32 factor = src_rescaled ? static_cast<u32>(Settings::values.resolution_factor) : 1U;
|
||||
|
||||
const std::size_t source_size = src_surface->GetHostSizeInBytes() * factor * factor;
|
||||
const std::size_t dest_size = dst_surface->GetHostSizeInBytes() * factor * factor;
|
||||
const std::size_t source_size = src_surface->GetHostSizeInBytes();
|
||||
const std::size_t dest_size = dst_surface->GetHostSizeInBytes();
|
||||
|
||||
const std::size_t buffer_size = std::max(source_size, dest_size);
|
||||
|
||||
@@ -603,8 +573,8 @@ void TextureCacheOpenGL::BufferCopy(Surface& src_surface, Surface& dst_surface)
|
||||
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, copy_pbo_handle);
|
||||
|
||||
const GLsizei width = static_cast<GLsizei>(dst_params.width * factor);
|
||||
const GLsizei height = static_cast<GLsizei>(dst_params.height * factor);
|
||||
const GLsizei width = static_cast<GLsizei>(dst_params.width);
|
||||
const GLsizei height = static_cast<GLsizei>(dst_params.height);
|
||||
const GLsizei depth = static_cast<GLsizei>(dst_params.depth);
|
||||
if (dest_format.compressed) {
|
||||
LOG_CRITICAL(HW_GPU, "Compressed buffer copy is unimplemented!");
|
||||
|
||||
@@ -39,8 +39,6 @@ public:
|
||||
explicit CachedSurface(GPUVAddr gpu_addr, const SurfaceParams& params);
|
||||
~CachedSurface();
|
||||
|
||||
void Init();
|
||||
|
||||
void UploadTexture(const std::vector<u8>& staging_buffer) override;
|
||||
void DownloadTexture(std::vector<u8>& staging_buffer) override;
|
||||
|
||||
@@ -98,10 +96,6 @@ public:
|
||||
return texture_view.handle;
|
||||
}
|
||||
|
||||
const CachedSurface& GetParent() const {
|
||||
return surface;
|
||||
}
|
||||
|
||||
const SurfaceParams& GetSurfaceParams() const {
|
||||
return surface.GetSurfaceParams();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ void ASTZipper::Init(const ASTNode new_first, const ASTNode parent) {
|
||||
ASSERT(new_first->manager == nullptr);
|
||||
first = new_first;
|
||||
last = new_first;
|
||||
|
||||
ASTNode current = first;
|
||||
while (current) {
|
||||
current->manager = this;
|
||||
@@ -92,7 +93,7 @@ void ASTZipper::InsertBefore(const ASTNode new_node, const ASTNode at_node) {
|
||||
new_node->manager = this;
|
||||
}
|
||||
|
||||
void ASTZipper::DetachTail(const ASTNode node) {
|
||||
void ASTZipper::DetachTail(ASTNode node) {
|
||||
ASSERT(node->manager == this);
|
||||
if (node == first) {
|
||||
first.reset();
|
||||
@@ -103,7 +104,8 @@ void ASTZipper::DetachTail(const ASTNode node) {
|
||||
last = node->previous;
|
||||
last->next.reset();
|
||||
node->previous.reset();
|
||||
ASTNode current = node;
|
||||
|
||||
ASTNode current = std::move(node);
|
||||
while (current) {
|
||||
current->manager = nullptr;
|
||||
current->parent.reset();
|
||||
@@ -185,9 +187,7 @@ void ASTZipper::Remove(const ASTNode node) {
|
||||
|
||||
class ExprPrinter final {
|
||||
public:
|
||||
ExprPrinter() = default;
|
||||
|
||||
void operator()(ExprAnd const& expr) {
|
||||
void operator()(const ExprAnd& expr) {
|
||||
inner += "( ";
|
||||
std::visit(*this, *expr.operand1);
|
||||
inner += " && ";
|
||||
@@ -195,7 +195,7 @@ public:
|
||||
inner += ')';
|
||||
}
|
||||
|
||||
void operator()(ExprOr const& expr) {
|
||||
void operator()(const ExprOr& expr) {
|
||||
inner += "( ";
|
||||
std::visit(*this, *expr.operand1);
|
||||
inner += " || ";
|
||||
@@ -203,29 +203,29 @@ public:
|
||||
inner += ')';
|
||||
}
|
||||
|
||||
void operator()(ExprNot const& expr) {
|
||||
void operator()(const ExprNot& expr) {
|
||||
inner += "!";
|
||||
std::visit(*this, *expr.operand1);
|
||||
}
|
||||
|
||||
void operator()(ExprPredicate const& expr) {
|
||||
void operator()(const ExprPredicate& expr) {
|
||||
inner += "P" + std::to_string(expr.predicate);
|
||||
}
|
||||
|
||||
void operator()(ExprCondCode const& expr) {
|
||||
void operator()(const ExprCondCode& expr) {
|
||||
u32 cc = static_cast<u32>(expr.cc);
|
||||
inner += "CC" + std::to_string(cc);
|
||||
}
|
||||
|
||||
void operator()(ExprVar const& expr) {
|
||||
void operator()(const ExprVar& expr) {
|
||||
inner += "V" + std::to_string(expr.var_index);
|
||||
}
|
||||
|
||||
void operator()(ExprBoolean const& expr) {
|
||||
void operator()(const ExprBoolean& expr) {
|
||||
inner += expr.value ? "true" : "false";
|
||||
}
|
||||
|
||||
std::string& GetResult() {
|
||||
const std::string& GetResult() const {
|
||||
return inner;
|
||||
}
|
||||
|
||||
@@ -234,9 +234,7 @@ public:
|
||||
|
||||
class ASTPrinter {
|
||||
public:
|
||||
ASTPrinter() = default;
|
||||
|
||||
void operator()(ASTProgram& ast) {
|
||||
void operator()(const ASTProgram& ast) {
|
||||
scope++;
|
||||
inner += "program {\n";
|
||||
ASTNode current = ast.nodes.GetFirst();
|
||||
@@ -248,7 +246,7 @@ public:
|
||||
scope--;
|
||||
}
|
||||
|
||||
void operator()(ASTIfThen& ast) {
|
||||
void operator()(const ASTIfThen& ast) {
|
||||
ExprPrinter expr_parser{};
|
||||
std::visit(expr_parser, *ast.condition);
|
||||
inner += Ident() + "if (" + expr_parser.GetResult() + ") {\n";
|
||||
@@ -262,7 +260,7 @@ public:
|
||||
inner += Ident() + "}\n";
|
||||
}
|
||||
|
||||
void operator()(ASTIfElse& ast) {
|
||||
void operator()(const ASTIfElse& ast) {
|
||||
inner += Ident() + "else {\n";
|
||||
scope++;
|
||||
ASTNode current = ast.nodes.GetFirst();
|
||||
@@ -274,34 +272,34 @@ public:
|
||||
inner += Ident() + "}\n";
|
||||
}
|
||||
|
||||
void operator()(ASTBlockEncoded& ast) {
|
||||
void operator()(const ASTBlockEncoded& ast) {
|
||||
inner += Ident() + "Block(" + std::to_string(ast.start) + ", " + std::to_string(ast.end) +
|
||||
");\n";
|
||||
}
|
||||
|
||||
void operator()(ASTBlockDecoded& ast) {
|
||||
void operator()(const ASTBlockDecoded& ast) {
|
||||
inner += Ident() + "Block;\n";
|
||||
}
|
||||
|
||||
void operator()(ASTVarSet& ast) {
|
||||
void operator()(const ASTVarSet& ast) {
|
||||
ExprPrinter expr_parser{};
|
||||
std::visit(expr_parser, *ast.condition);
|
||||
inner +=
|
||||
Ident() + "V" + std::to_string(ast.index) + " := " + expr_parser.GetResult() + ";\n";
|
||||
}
|
||||
|
||||
void operator()(ASTLabel& ast) {
|
||||
void operator()(const ASTLabel& ast) {
|
||||
inner += "Label_" + std::to_string(ast.index) + ":\n";
|
||||
}
|
||||
|
||||
void operator()(ASTGoto& ast) {
|
||||
void operator()(const ASTGoto& ast) {
|
||||
ExprPrinter expr_parser{};
|
||||
std::visit(expr_parser, *ast.condition);
|
||||
inner += Ident() + "(" + expr_parser.GetResult() + ") -> goto Label_" +
|
||||
std::to_string(ast.label) + ";\n";
|
||||
}
|
||||
|
||||
void operator()(ASTDoWhile& ast) {
|
||||
void operator()(const ASTDoWhile& ast) {
|
||||
ExprPrinter expr_parser{};
|
||||
std::visit(expr_parser, *ast.condition);
|
||||
inner += Ident() + "do {\n";
|
||||
@@ -315,14 +313,14 @@ public:
|
||||
inner += Ident() + "} while (" + expr_parser.GetResult() + ");\n";
|
||||
}
|
||||
|
||||
void operator()(ASTReturn& ast) {
|
||||
void operator()(const ASTReturn& ast) {
|
||||
ExprPrinter expr_parser{};
|
||||
std::visit(expr_parser, *ast.condition);
|
||||
inner += Ident() + "(" + expr_parser.GetResult() + ") -> " +
|
||||
(ast.kills ? "discard" : "exit") + ";\n";
|
||||
}
|
||||
|
||||
void operator()(ASTBreak& ast) {
|
||||
void operator()(const ASTBreak& ast) {
|
||||
ExprPrinter expr_parser{};
|
||||
std::visit(expr_parser, *ast.condition);
|
||||
inner += Ident() + "(" + expr_parser.GetResult() + ") -> break;\n";
|
||||
@@ -341,7 +339,7 @@ public:
|
||||
std::visit(*this, *node->GetInnerData());
|
||||
}
|
||||
|
||||
std::string& GetResult() {
|
||||
const std::string& GetResult() const {
|
||||
return inner;
|
||||
}
|
||||
|
||||
@@ -352,11 +350,9 @@ private:
|
||||
std::string tabs_memo{};
|
||||
u32 memo_scope{};
|
||||
|
||||
static std::string tabs;
|
||||
static constexpr std::string_view tabs{" "};
|
||||
};
|
||||
|
||||
std::string ASTPrinter::tabs = " ";
|
||||
|
||||
std::string ASTManager::Print() {
|
||||
ASTPrinter printer{};
|
||||
printer.Visit(main_node);
|
||||
@@ -376,30 +372,6 @@ void ASTManager::Init() {
|
||||
false_condition = MakeExpr<ExprBoolean>(false);
|
||||
}
|
||||
|
||||
ASTManager::ASTManager(ASTManager&& other) noexcept
|
||||
: labels_map(std::move(other.labels_map)), labels_count{other.labels_count},
|
||||
gotos(std::move(other.gotos)), labels(std::move(other.labels)), variables{other.variables},
|
||||
program{other.program}, main_node{other.main_node}, false_condition{other.false_condition},
|
||||
disable_else_derivation{other.disable_else_derivation} {
|
||||
other.main_node.reset();
|
||||
}
|
||||
|
||||
ASTManager& ASTManager::operator=(ASTManager&& other) noexcept {
|
||||
full_decompile = other.full_decompile;
|
||||
labels_map = std::move(other.labels_map);
|
||||
labels_count = other.labels_count;
|
||||
gotos = std::move(other.gotos);
|
||||
labels = std::move(other.labels);
|
||||
variables = other.variables;
|
||||
program = other.program;
|
||||
main_node = other.main_node;
|
||||
false_condition = other.false_condition;
|
||||
disable_else_derivation = other.disable_else_derivation;
|
||||
|
||||
other.main_node.reset();
|
||||
return *this;
|
||||
}
|
||||
|
||||
void ASTManager::DeclareLabel(u32 address) {
|
||||
const auto pair = labels_map.emplace(address, labels_count);
|
||||
if (pair.second) {
|
||||
@@ -417,19 +389,19 @@ void ASTManager::InsertLabel(u32 address) {
|
||||
|
||||
void ASTManager::InsertGoto(Expr condition, u32 address) {
|
||||
const u32 index = labels_map[address];
|
||||
const ASTNode goto_node = ASTBase::Make<ASTGoto>(main_node, condition, index);
|
||||
const ASTNode goto_node = ASTBase::Make<ASTGoto>(main_node, std::move(condition), index);
|
||||
gotos.push_back(goto_node);
|
||||
program->nodes.PushBack(goto_node);
|
||||
}
|
||||
|
||||
void ASTManager::InsertBlock(u32 start_address, u32 end_address) {
|
||||
const ASTNode block = ASTBase::Make<ASTBlockEncoded>(main_node, start_address, end_address);
|
||||
program->nodes.PushBack(block);
|
||||
ASTNode block = ASTBase::Make<ASTBlockEncoded>(main_node, start_address, end_address);
|
||||
program->nodes.PushBack(std::move(block));
|
||||
}
|
||||
|
||||
void ASTManager::InsertReturn(Expr condition, bool kills) {
|
||||
const ASTNode node = ASTBase::Make<ASTReturn>(main_node, condition, kills);
|
||||
program->nodes.PushBack(node);
|
||||
ASTNode node = ASTBase::Make<ASTReturn>(main_node, std::move(condition), kills);
|
||||
program->nodes.PushBack(std::move(node));
|
||||
}
|
||||
|
||||
// The decompile algorithm is based on
|
||||
@@ -496,10 +468,10 @@ void ASTManager::Decompile() {
|
||||
}
|
||||
labels.clear();
|
||||
} else {
|
||||
auto it = labels.begin();
|
||||
while (it != labels.end()) {
|
||||
auto label_it = labels.begin();
|
||||
while (label_it != labels.end()) {
|
||||
bool can_remove = true;
|
||||
ASTNode label = *it;
|
||||
ASTNode label = *label_it;
|
||||
for (const ASTNode& goto_node : gotos) {
|
||||
const auto label_index = goto_node->GetGotoLabel();
|
||||
if (!label_index) {
|
||||
@@ -543,11 +515,11 @@ bool ASTManager::IsBackwardsJump(ASTNode goto_node, ASTNode label_node) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ASTManager::IndirectlyRelated(ASTNode first, ASTNode second) {
|
||||
bool ASTManager::IndirectlyRelated(const ASTNode& first, const ASTNode& second) const {
|
||||
return !(first->GetParent() == second->GetParent() || DirectlyRelated(first, second));
|
||||
}
|
||||
|
||||
bool ASTManager::DirectlyRelated(ASTNode first, ASTNode second) {
|
||||
bool ASTManager::DirectlyRelated(const ASTNode& first, const ASTNode& second) const {
|
||||
if (first->GetParent() == second->GetParent()) {
|
||||
return false;
|
||||
}
|
||||
@@ -577,7 +549,7 @@ bool ASTManager::DirectlyRelated(ASTNode first, ASTNode second) {
|
||||
return min->GetParent() == max->GetParent();
|
||||
}
|
||||
|
||||
void ASTManager::ShowCurrentState(std::string state) {
|
||||
void ASTManager::ShowCurrentState(std::string_view state) {
|
||||
LOG_CRITICAL(HW_GPU, "\nState {}:\n\n{}\n", state, Print());
|
||||
SanityCheck();
|
||||
}
|
||||
@@ -696,7 +668,7 @@ class ASTClearer {
|
||||
public:
|
||||
ASTClearer() = default;
|
||||
|
||||
void operator()(ASTProgram& ast) {
|
||||
void operator()(const ASTProgram& ast) {
|
||||
ASTNode current = ast.nodes.GetFirst();
|
||||
while (current) {
|
||||
Visit(current);
|
||||
@@ -704,7 +676,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void operator()(ASTIfThen& ast) {
|
||||
void operator()(const ASTIfThen& ast) {
|
||||
ASTNode current = ast.nodes.GetFirst();
|
||||
while (current) {
|
||||
Visit(current);
|
||||
@@ -712,7 +684,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void operator()(ASTIfElse& ast) {
|
||||
void operator()(const ASTIfElse& ast) {
|
||||
ASTNode current = ast.nodes.GetFirst();
|
||||
while (current) {
|
||||
Visit(current);
|
||||
@@ -720,19 +692,19 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void operator()(ASTBlockEncoded& ast) {}
|
||||
void operator()([[maybe_unused]] const ASTBlockEncoded& ast) {}
|
||||
|
||||
void operator()(ASTBlockDecoded& ast) {
|
||||
ast.nodes.clear();
|
||||
}
|
||||
|
||||
void operator()(ASTVarSet& ast) {}
|
||||
void operator()([[maybe_unused]] const ASTVarSet& ast) {}
|
||||
|
||||
void operator()(ASTLabel& ast) {}
|
||||
void operator()([[maybe_unused]] const ASTLabel& ast) {}
|
||||
|
||||
void operator()(ASTGoto& ast) {}
|
||||
void operator()([[maybe_unused]] const ASTGoto& ast) {}
|
||||
|
||||
void operator()(ASTDoWhile& ast) {
|
||||
void operator()(const ASTDoWhile& ast) {
|
||||
ASTNode current = ast.nodes.GetFirst();
|
||||
while (current) {
|
||||
Visit(current);
|
||||
@@ -740,11 +712,11 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void operator()(ASTReturn& ast) {}
|
||||
void operator()([[maybe_unused]] const ASTReturn& ast) {}
|
||||
|
||||
void operator()(ASTBreak& ast) {}
|
||||
void operator()([[maybe_unused]] const ASTBreak& ast) {}
|
||||
|
||||
void Visit(ASTNode& node) {
|
||||
void Visit(const ASTNode& node) {
|
||||
std::visit(*this, *node->GetInnerData());
|
||||
node->Clear();
|
||||
}
|
||||
|
||||
+50
-41
@@ -18,17 +18,17 @@
|
||||
namespace VideoCommon::Shader {
|
||||
|
||||
class ASTBase;
|
||||
class ASTProgram;
|
||||
class ASTIfThen;
|
||||
class ASTIfElse;
|
||||
class ASTBlockEncoded;
|
||||
class ASTBlockDecoded;
|
||||
class ASTVarSet;
|
||||
class ASTGoto;
|
||||
class ASTLabel;
|
||||
class ASTDoWhile;
|
||||
class ASTReturn;
|
||||
class ASTBlockEncoded;
|
||||
class ASTBreak;
|
||||
class ASTDoWhile;
|
||||
class ASTGoto;
|
||||
class ASTIfElse;
|
||||
class ASTIfThen;
|
||||
class ASTLabel;
|
||||
class ASTProgram;
|
||||
class ASTReturn;
|
||||
class ASTVarSet;
|
||||
|
||||
using ASTData = std::variant<ASTProgram, ASTIfThen, ASTIfElse, ASTBlockEncoded, ASTBlockDecoded,
|
||||
ASTVarSet, ASTGoto, ASTLabel, ASTDoWhile, ASTReturn, ASTBreak>;
|
||||
@@ -48,11 +48,11 @@ public:
|
||||
|
||||
void Init(ASTNode first, ASTNode parent);
|
||||
|
||||
ASTNode GetFirst() {
|
||||
ASTNode GetFirst() const {
|
||||
return first;
|
||||
}
|
||||
|
||||
ASTNode GetLast() {
|
||||
ASTNode GetLast() const {
|
||||
return last;
|
||||
}
|
||||
|
||||
@@ -71,20 +71,18 @@ public:
|
||||
|
||||
class ASTProgram {
|
||||
public:
|
||||
explicit ASTProgram() = default;
|
||||
ASTZipper nodes{};
|
||||
};
|
||||
|
||||
class ASTIfThen {
|
||||
public:
|
||||
explicit ASTIfThen(Expr condition) : condition(condition) {}
|
||||
explicit ASTIfThen(Expr condition) : condition{std::move(condition)} {}
|
||||
Expr condition;
|
||||
ASTZipper nodes{};
|
||||
};
|
||||
|
||||
class ASTIfElse {
|
||||
public:
|
||||
explicit ASTIfElse() = default;
|
||||
ASTZipper nodes{};
|
||||
};
|
||||
|
||||
@@ -103,7 +101,7 @@ public:
|
||||
|
||||
class ASTVarSet {
|
||||
public:
|
||||
explicit ASTVarSet(u32 index, Expr condition) : index{index}, condition{condition} {}
|
||||
explicit ASTVarSet(u32 index, Expr condition) : index{index}, condition{std::move(condition)} {}
|
||||
u32 index;
|
||||
Expr condition;
|
||||
};
|
||||
@@ -117,42 +115,45 @@ public:
|
||||
|
||||
class ASTGoto {
|
||||
public:
|
||||
explicit ASTGoto(Expr condition, u32 label) : condition{condition}, label{label} {}
|
||||
explicit ASTGoto(Expr condition, u32 label) : condition{std::move(condition)}, label{label} {}
|
||||
Expr condition;
|
||||
u32 label;
|
||||
};
|
||||
|
||||
class ASTDoWhile {
|
||||
public:
|
||||
explicit ASTDoWhile(Expr condition) : condition(condition) {}
|
||||
explicit ASTDoWhile(Expr condition) : condition{std::move(condition)} {}
|
||||
Expr condition;
|
||||
ASTZipper nodes{};
|
||||
};
|
||||
|
||||
class ASTReturn {
|
||||
public:
|
||||
explicit ASTReturn(Expr condition, bool kills) : condition{condition}, kills{kills} {}
|
||||
explicit ASTReturn(Expr condition, bool kills)
|
||||
: condition{std::move(condition)}, kills{kills} {}
|
||||
Expr condition;
|
||||
bool kills;
|
||||
};
|
||||
|
||||
class ASTBreak {
|
||||
public:
|
||||
explicit ASTBreak(Expr condition) : condition{condition} {}
|
||||
explicit ASTBreak(Expr condition) : condition{std::move(condition)} {}
|
||||
Expr condition;
|
||||
};
|
||||
|
||||
class ASTBase {
|
||||
public:
|
||||
explicit ASTBase(ASTNode parent, ASTData data) : parent{parent}, data{data} {}
|
||||
explicit ASTBase(ASTNode parent, ASTData data)
|
||||
: data{std::move(data)}, parent{std::move(parent)} {}
|
||||
|
||||
template <class U, class... Args>
|
||||
static ASTNode Make(ASTNode parent, Args&&... args) {
|
||||
return std::make_shared<ASTBase>(parent, ASTData(U(std::forward<Args>(args)...)));
|
||||
return std::make_shared<ASTBase>(std::move(parent),
|
||||
ASTData(U(std::forward<Args>(args)...)));
|
||||
}
|
||||
|
||||
void SetParent(ASTNode new_parent) {
|
||||
parent = new_parent;
|
||||
parent = std::move(new_parent);
|
||||
}
|
||||
|
||||
ASTNode& GetParent() {
|
||||
@@ -177,6 +178,10 @@ public:
|
||||
return &data;
|
||||
}
|
||||
|
||||
const ASTData* GetInnerData() const {
|
||||
return &data;
|
||||
}
|
||||
|
||||
ASTNode GetNext() const {
|
||||
return next;
|
||||
}
|
||||
@@ -189,6 +194,10 @@ public:
|
||||
return *manager;
|
||||
}
|
||||
|
||||
const ASTZipper& GetManager() const {
|
||||
return *manager;
|
||||
}
|
||||
|
||||
std::optional<u32> GetGotoLabel() const {
|
||||
auto inner = std::get_if<ASTGoto>(&data);
|
||||
if (inner) {
|
||||
@@ -239,7 +248,7 @@ public:
|
||||
void SetGotoCondition(Expr new_condition) {
|
||||
auto inner = std::get_if<ASTGoto>(&data);
|
||||
if (inner) {
|
||||
inner->condition = new_condition;
|
||||
inner->condition = std::move(new_condition);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,8 +313,8 @@ public:
|
||||
ASTManager(const ASTManager& o) = delete;
|
||||
ASTManager& operator=(const ASTManager& other) = delete;
|
||||
|
||||
ASTManager(ASTManager&& other) noexcept;
|
||||
ASTManager& operator=(ASTManager&& other) noexcept;
|
||||
ASTManager(ASTManager&& other) noexcept = default;
|
||||
ASTManager& operator=(ASTManager&& other) noexcept = default;
|
||||
|
||||
void Init();
|
||||
|
||||
@@ -323,7 +332,7 @@ public:
|
||||
|
||||
void Decompile();
|
||||
|
||||
void ShowCurrentState(std::string state);
|
||||
void ShowCurrentState(std::string_view state);
|
||||
|
||||
void SanityCheck();
|
||||
|
||||
@@ -331,20 +340,20 @@ public:
|
||||
|
||||
bool IsFullyDecompiled() const {
|
||||
if (full_decompile) {
|
||||
return gotos.size() == 0;
|
||||
} else {
|
||||
for (ASTNode goto_node : gotos) {
|
||||
auto label_index = goto_node->GetGotoLabel();
|
||||
if (!label_index) {
|
||||
return false;
|
||||
}
|
||||
ASTNode glabel = labels[*label_index];
|
||||
if (IsBackwardsJump(goto_node, glabel)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return gotos.empty();
|
||||
}
|
||||
|
||||
for (ASTNode goto_node : gotos) {
|
||||
auto label_index = goto_node->GetGotoLabel();
|
||||
if (!label_index) {
|
||||
return false;
|
||||
}
|
||||
ASTNode glabel = labels[*label_index];
|
||||
if (IsBackwardsJump(goto_node, glabel)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
ASTNode GetProgram() const {
|
||||
@@ -362,9 +371,9 @@ public:
|
||||
private:
|
||||
bool IsBackwardsJump(ASTNode goto_node, ASTNode label_node) const;
|
||||
|
||||
bool IndirectlyRelated(ASTNode first, ASTNode second);
|
||||
bool IndirectlyRelated(const ASTNode& first, const ASTNode& second) const;
|
||||
|
||||
bool DirectlyRelated(ASTNode first, ASTNode second);
|
||||
bool DirectlyRelated(const ASTNode& first, const ASTNode& second) const;
|
||||
|
||||
void EncloseDoWhile(ASTNode goto_node, ASTNode label);
|
||||
|
||||
|
||||
@@ -479,7 +479,7 @@ std::unique_ptr<ShaderCharacteristics> ScanFlow(const ProgramCode& program_code,
|
||||
auto result_out = std::make_unique<ShaderCharacteristics>();
|
||||
if (settings.depth == CompileDepth::BruteForce) {
|
||||
result_out->settings.depth = CompileDepth::BruteForce;
|
||||
return std::move(result_out);
|
||||
return result_out;
|
||||
}
|
||||
|
||||
CFGRebuildState state{program_code, program_size, start_address};
|
||||
@@ -490,7 +490,7 @@ std::unique_ptr<ShaderCharacteristics> ScanFlow(const ProgramCode& program_code,
|
||||
while (!state.inspect_queries.empty()) {
|
||||
if (!TryInspectAddress(state)) {
|
||||
result_out->settings.depth = CompileDepth::BruteForce;
|
||||
return std::move(result_out);
|
||||
return result_out;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -530,14 +530,15 @@ std::unique_ptr<ShaderCharacteristics> ScanFlow(const ProgramCode& program_code,
|
||||
state.manager->ShowCurrentState("Of Shader");
|
||||
state.manager->Clear();
|
||||
} else {
|
||||
auto result_out = std::make_unique<ShaderCharacteristics>();
|
||||
result_out->start = start_address;
|
||||
result_out->settings.depth = settings.depth;
|
||||
result_out->manager = std::move(manager);
|
||||
result_out->end = state.block_info.back().end + 1;
|
||||
return std::move(result_out);
|
||||
auto characteristics = std::make_unique<ShaderCharacteristics>();
|
||||
characteristics->start = start_address;
|
||||
characteristics->settings.depth = settings.depth;
|
||||
characteristics->manager = std::move(manager);
|
||||
characteristics->end = state.block_info.back().end + 1;
|
||||
return characteristics;
|
||||
}
|
||||
}
|
||||
|
||||
result_out->start = start_address;
|
||||
result_out->settings.depth =
|
||||
use_flow_stack ? CompileDepth::FlowStack : CompileDepth::NoFlowStack;
|
||||
@@ -557,8 +558,9 @@ std::unique_ptr<ShaderCharacteristics> ScanFlow(const ProgramCode& program_code,
|
||||
}
|
||||
if (!use_flow_stack) {
|
||||
result_out->labels = std::move(state.labels);
|
||||
return std::move(result_out);
|
||||
return result_out;
|
||||
}
|
||||
|
||||
auto back = result_out->blocks.begin();
|
||||
auto next = std::next(back);
|
||||
while (next != result_out->blocks.end()) {
|
||||
@@ -570,6 +572,7 @@ std::unique_ptr<ShaderCharacteristics> ScanFlow(const ProgramCode& program_code,
|
||||
back = next;
|
||||
++next;
|
||||
}
|
||||
return std::move(result_out);
|
||||
|
||||
return result_out;
|
||||
}
|
||||
} // namespace VideoCommon::Shader
|
||||
|
||||
@@ -2,40 +2,51 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <variant>
|
||||
|
||||
#include "video_core/shader/expr.h"
|
||||
|
||||
namespace VideoCommon::Shader {
|
||||
namespace {
|
||||
bool ExprIsBoolean(const Expr& expr) {
|
||||
return std::holds_alternative<ExprBoolean>(*expr);
|
||||
}
|
||||
|
||||
bool ExprBooleanGet(const Expr& expr) {
|
||||
return std::get_if<ExprBoolean>(expr.get())->value;
|
||||
}
|
||||
} // Anonymous namespace
|
||||
|
||||
bool ExprAnd::operator==(const ExprAnd& b) const {
|
||||
return (*operand1 == *b.operand1) && (*operand2 == *b.operand2);
|
||||
}
|
||||
|
||||
bool ExprAnd::operator!=(const ExprAnd& b) const {
|
||||
return !operator==(b);
|
||||
}
|
||||
|
||||
bool ExprOr::operator==(const ExprOr& b) const {
|
||||
return (*operand1 == *b.operand1) && (*operand2 == *b.operand2);
|
||||
}
|
||||
|
||||
bool ExprOr::operator!=(const ExprOr& b) const {
|
||||
return !operator==(b);
|
||||
}
|
||||
|
||||
bool ExprNot::operator==(const ExprNot& b) const {
|
||||
return (*operand1 == *b.operand1);
|
||||
return *operand1 == *b.operand1;
|
||||
}
|
||||
|
||||
bool ExprIsBoolean(Expr expr) {
|
||||
return std::holds_alternative<ExprBoolean>(*expr);
|
||||
}
|
||||
|
||||
bool ExprBooleanGet(Expr expr) {
|
||||
return std::get_if<ExprBoolean>(expr.get())->value;
|
||||
bool ExprNot::operator!=(const ExprNot& b) const {
|
||||
return !operator==(b);
|
||||
}
|
||||
|
||||
Expr MakeExprNot(Expr first) {
|
||||
if (std::holds_alternative<ExprNot>(*first)) {
|
||||
return std::get_if<ExprNot>(first.get())->operand1;
|
||||
}
|
||||
return MakeExpr<ExprNot>(first);
|
||||
return MakeExpr<ExprNot>(std::move(first));
|
||||
}
|
||||
|
||||
Expr MakeExprAnd(Expr first, Expr second) {
|
||||
@@ -45,7 +56,7 @@ Expr MakeExprAnd(Expr first, Expr second) {
|
||||
if (ExprIsBoolean(second)) {
|
||||
return ExprBooleanGet(second) ? first : second;
|
||||
}
|
||||
return MakeExpr<ExprAnd>(first, second);
|
||||
return MakeExpr<ExprAnd>(std::move(first), std::move(second));
|
||||
}
|
||||
|
||||
Expr MakeExprOr(Expr first, Expr second) {
|
||||
@@ -55,14 +66,14 @@ Expr MakeExprOr(Expr first, Expr second) {
|
||||
if (ExprIsBoolean(second)) {
|
||||
return ExprBooleanGet(second) ? second : first;
|
||||
}
|
||||
return MakeExpr<ExprOr>(first, second);
|
||||
return MakeExpr<ExprOr>(std::move(first), std::move(second));
|
||||
}
|
||||
|
||||
bool ExprAreEqual(Expr first, Expr second) {
|
||||
bool ExprAreEqual(const Expr& first, const Expr& second) {
|
||||
return (*first) == (*second);
|
||||
}
|
||||
|
||||
bool ExprAreOpposite(Expr first, Expr second) {
|
||||
bool ExprAreOpposite(const Expr& first, const Expr& second) {
|
||||
if (std::holds_alternative<ExprNot>(*first)) {
|
||||
return ExprAreEqual(std::get_if<ExprNot>(first.get())->operand1, second);
|
||||
}
|
||||
@@ -72,7 +83,7 @@ bool ExprAreOpposite(Expr first, Expr second) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ExprIsTrue(Expr first) {
|
||||
bool ExprIsTrue(const Expr& first) {
|
||||
if (ExprIsBoolean(first)) {
|
||||
return ExprBooleanGet(first);
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@ using Tegra::Shader::ConditionCode;
|
||||
using Tegra::Shader::Pred;
|
||||
|
||||
class ExprAnd;
|
||||
class ExprOr;
|
||||
class ExprNot;
|
||||
class ExprPredicate;
|
||||
class ExprCondCode;
|
||||
class ExprVar;
|
||||
class ExprBoolean;
|
||||
class ExprCondCode;
|
||||
class ExprNot;
|
||||
class ExprOr;
|
||||
class ExprPredicate;
|
||||
class ExprVar;
|
||||
|
||||
using ExprData =
|
||||
std::variant<ExprVar, ExprCondCode, ExprPredicate, ExprNot, ExprOr, ExprAnd, ExprBoolean>;
|
||||
@@ -28,9 +28,10 @@ using Expr = std::shared_ptr<ExprData>;
|
||||
|
||||
class ExprAnd final {
|
||||
public:
|
||||
explicit ExprAnd(Expr a, Expr b) : operand1{a}, operand2{b} {}
|
||||
explicit ExprAnd(Expr a, Expr b) : operand1{std::move(a)}, operand2{std::move(b)} {}
|
||||
|
||||
bool operator==(const ExprAnd& b) const;
|
||||
bool operator!=(const ExprAnd& b) const;
|
||||
|
||||
Expr operand1;
|
||||
Expr operand2;
|
||||
@@ -38,9 +39,10 @@ public:
|
||||
|
||||
class ExprOr final {
|
||||
public:
|
||||
explicit ExprOr(Expr a, Expr b) : operand1{a}, operand2{b} {}
|
||||
explicit ExprOr(Expr a, Expr b) : operand1{std::move(a)}, operand2{std::move(b)} {}
|
||||
|
||||
bool operator==(const ExprOr& b) const;
|
||||
bool operator!=(const ExprOr& b) const;
|
||||
|
||||
Expr operand1;
|
||||
Expr operand2;
|
||||
@@ -48,9 +50,10 @@ public:
|
||||
|
||||
class ExprNot final {
|
||||
public:
|
||||
explicit ExprNot(Expr a) : operand1{a} {}
|
||||
explicit ExprNot(Expr a) : operand1{std::move(a)} {}
|
||||
|
||||
bool operator==(const ExprNot& b) const;
|
||||
bool operator!=(const ExprNot& b) const;
|
||||
|
||||
Expr operand1;
|
||||
};
|
||||
@@ -63,6 +66,10 @@ public:
|
||||
return var_index == b.var_index;
|
||||
}
|
||||
|
||||
bool operator!=(const ExprVar& b) const {
|
||||
return !operator==(b);
|
||||
}
|
||||
|
||||
u32 var_index;
|
||||
};
|
||||
|
||||
@@ -74,6 +81,10 @@ public:
|
||||
return predicate == b.predicate;
|
||||
}
|
||||
|
||||
bool operator!=(const ExprPredicate& b) const {
|
||||
return !operator==(b);
|
||||
}
|
||||
|
||||
u32 predicate;
|
||||
};
|
||||
|
||||
@@ -85,6 +96,10 @@ public:
|
||||
return cc == b.cc;
|
||||
}
|
||||
|
||||
bool operator!=(const ExprCondCode& b) const {
|
||||
return !operator==(b);
|
||||
}
|
||||
|
||||
ConditionCode cc;
|
||||
};
|
||||
|
||||
@@ -96,6 +111,10 @@ public:
|
||||
return value == b.value;
|
||||
}
|
||||
|
||||
bool operator!=(const ExprBoolean& b) const {
|
||||
return !operator==(b);
|
||||
}
|
||||
|
||||
bool value;
|
||||
};
|
||||
|
||||
@@ -105,9 +124,9 @@ Expr MakeExpr(Args&&... args) {
|
||||
return std::make_shared<ExprData>(T(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
bool ExprAreEqual(Expr first, Expr second);
|
||||
bool ExprAreEqual(const Expr& first, const Expr& second);
|
||||
|
||||
bool ExprAreOpposite(Expr first, Expr second);
|
||||
bool ExprAreOpposite(const Expr& first, const Expr& second);
|
||||
|
||||
Expr MakeExprNot(Expr first);
|
||||
|
||||
@@ -115,6 +134,6 @@ Expr MakeExprAnd(Expr first, Expr second);
|
||||
|
||||
Expr MakeExprOr(Expr first, Expr second);
|
||||
|
||||
bool ExprIsTrue(Expr first);
|
||||
bool ExprIsTrue(const Expr& first);
|
||||
|
||||
} // namespace VideoCommon::Shader
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
// Copyright 2019 yuzu Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <fmt/format.h>
|
||||
#include <json.hpp>
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/common_paths.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/file_util.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/kernel/process.h"
|
||||
#include "video_core/texture_cache/resolution_scaling/database.h"
|
||||
|
||||
namespace VideoCommon::Resolution {
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
std::string GetBaseDir() {
|
||||
return FileUtil::GetUserPath(FileUtil::UserPath::RescalingDir);
|
||||
}
|
||||
|
||||
ScalingDatabase::ScalingDatabase(Core::System& system) : system{system} {}
|
||||
|
||||
ScalingDatabase::~ScalingDatabase() {
|
||||
SaveDatabase();
|
||||
}
|
||||
|
||||
void ScalingDatabase::Init() {
|
||||
title_id = system.CurrentProcess()->GetTitleID();
|
||||
LoadDatabase();
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
void ScalingDatabase::LoadDatabase() {
|
||||
const std::string path = GetProfilePath();
|
||||
const bool exists = FileUtil::Exists(path);
|
||||
if (!exists) {
|
||||
return;
|
||||
}
|
||||
std::ifstream file;
|
||||
OpenFStream(file, path, std::ios_base::in);
|
||||
json in;
|
||||
file >> in;
|
||||
u32 version = in["version"].get<u32>();
|
||||
if (version != DBVersion) {
|
||||
return;
|
||||
}
|
||||
for (const auto& entry : in["entries"]) {
|
||||
ResolutionKey key{};
|
||||
key.format = static_cast<PixelFormat>(entry["format"].get<u32>());
|
||||
key.width = entry["width"].get<u32>();
|
||||
key.height = entry["height"].get<u32>();
|
||||
database.insert(key);
|
||||
}
|
||||
for (const auto& entry : in["blacklist"]) {
|
||||
ResolutionKey key{};
|
||||
key.format = static_cast<PixelFormat>(entry["format"].get<u32>());
|
||||
key.width = entry["width"].get<u32>();
|
||||
key.height = entry["height"].get<u32>();
|
||||
blacklist.insert(key);
|
||||
}
|
||||
}
|
||||
|
||||
void ScalingDatabase::SaveDatabase() {
|
||||
const std::string dir = GetBaseDir();
|
||||
if (!FileUtil::CreateDir(dir)) {
|
||||
LOG_ERROR(HW_GPU, "Failed to create directory={}", dir);
|
||||
return;
|
||||
}
|
||||
json out;
|
||||
out.emplace("version", DBVersion);
|
||||
auto entries = json::array();
|
||||
for (const auto& key : database) {
|
||||
entries.push_back({
|
||||
{"format", static_cast<u32>(key.format)},
|
||||
{"width", key.width},
|
||||
{"height", key.height},
|
||||
});
|
||||
}
|
||||
out.emplace("entries", std::move(entries));
|
||||
auto blacklist_entries = json::array();
|
||||
for (const auto& key : blacklist) {
|
||||
blacklist_entries.push_back({
|
||||
{"format", static_cast<u32>(key.format)},
|
||||
{"width", key.width},
|
||||
{"height", key.height},
|
||||
});
|
||||
}
|
||||
out.emplace("blacklist", std::move(blacklist_entries));
|
||||
const std::string path = GetProfilePath();
|
||||
std::ofstream file;
|
||||
OpenFStream(file, path, std::ios_base::out);
|
||||
file << std::setw(4) << out << std::endl;
|
||||
}
|
||||
|
||||
void ScalingDatabase::Register(PixelFormat format, u32 width, u32 height) {
|
||||
const ResolutionKey key{format, width, height};
|
||||
if (blacklist.count(key) == 0) {
|
||||
database.insert(key);
|
||||
}
|
||||
}
|
||||
|
||||
void ScalingDatabase::Unregister(PixelFormat format, u32 width, u32 height) {
|
||||
const ResolutionKey key{format, width, height};
|
||||
database.erase(key);
|
||||
blacklist.insert(key);
|
||||
}
|
||||
|
||||
std::string ScalingDatabase::GetTitleID() const {
|
||||
return fmt::format("{:016X}", title_id);
|
||||
}
|
||||
|
||||
std::string ScalingDatabase::GetProfilePath() const {
|
||||
return FileUtil::SanitizePath(GetBaseDir() + DIR_SEP_CHR + GetTitleID() + ".json");
|
||||
}
|
||||
|
||||
} // namespace VideoCommon::Resolution
|
||||
@@ -1,88 +0,0 @@
|
||||
// Copyright 2019 yuzu Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <unordered_set>
|
||||
#include "video_core/surface.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace VideoCommon::Resolution {
|
||||
|
||||
using VideoCore::Surface::PixelFormat;
|
||||
|
||||
struct ResolutionKey {
|
||||
PixelFormat format;
|
||||
u32 width;
|
||||
u32 height;
|
||||
std::size_t Hash() const {
|
||||
const std::size_t comp1 = static_cast<std::size_t>(format) << 44;
|
||||
const std::size_t comp2 = static_cast<std::size_t>(height) << 24;
|
||||
const std::size_t comp3 = static_cast<std::size_t>(width);
|
||||
return comp1 | comp2 | comp3;
|
||||
}
|
||||
|
||||
bool operator==(const ResolutionKey& ks) const {
|
||||
return std::tie(format, width, height) == std::tie(ks.format, ks.width, ks.height);
|
||||
}
|
||||
|
||||
bool operator!=(const ResolutionKey& ks) const {
|
||||
return !(*this == ks);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace VideoCommon::Resolution
|
||||
|
||||
namespace std {
|
||||
|
||||
template <>
|
||||
struct hash<VideoCommon::Resolution::ResolutionKey> {
|
||||
std::size_t operator()(const VideoCommon::Resolution::ResolutionKey& k) const {
|
||||
return k.Hash();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
namespace VideoCommon::Resolution {
|
||||
|
||||
class ScalingDatabase {
|
||||
public:
|
||||
explicit ScalingDatabase(Core::System& system);
|
||||
~ScalingDatabase();
|
||||
|
||||
void SaveDatabase();
|
||||
void LoadDatabase();
|
||||
void Init();
|
||||
|
||||
bool IsInDatabase(const PixelFormat format, const u32 width, const u32 height) const {
|
||||
const ResolutionKey key{format, width, height};
|
||||
return database.count(key) > 0;
|
||||
}
|
||||
|
||||
bool IsBlacklisted(const PixelFormat format, const u32 width, const u32 height) const {
|
||||
const ResolutionKey key{format, width, height};
|
||||
return blacklist.count(key) > 0;
|
||||
}
|
||||
|
||||
void Register(const PixelFormat format, const u32 width, const u32 height);
|
||||
void Unregister(const PixelFormat format, const u32 width, const u32 height);
|
||||
|
||||
std::string GetTitleID() const;
|
||||
std::string GetProfilePath() const;
|
||||
|
||||
private:
|
||||
std::unordered_set<ResolutionKey> database{};
|
||||
std::unordered_set<ResolutionKey> blacklist{};
|
||||
bool initialized{};
|
||||
u64 title_id{};
|
||||
Core::System& system;
|
||||
|
||||
static constexpr u32 DBVersion = 1;
|
||||
};
|
||||
|
||||
} // namespace VideoCommon::Resolution
|
||||
@@ -205,10 +205,6 @@ public:
|
||||
index = index_;
|
||||
}
|
||||
|
||||
void MarkAsRescaled(const bool is_rescaled) {
|
||||
this->is_rescaled = is_rescaled;
|
||||
}
|
||||
|
||||
void MarkAsPicked(bool is_picked_) {
|
||||
is_picked = is_picked_;
|
||||
}
|
||||
@@ -230,10 +226,6 @@ public:
|
||||
return index;
|
||||
}
|
||||
|
||||
bool IsRescaled() const {
|
||||
return is_rescaled;
|
||||
}
|
||||
|
||||
bool IsRegistered() const {
|
||||
return is_registered;
|
||||
}
|
||||
@@ -326,7 +318,6 @@ private:
|
||||
bool is_target{};
|
||||
bool is_registered{};
|
||||
bool is_picked{};
|
||||
bool is_rescaled{};
|
||||
u32 index{NO_RT};
|
||||
u64 modification_tick{};
|
||||
};
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <tuple>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <boost/icl/interval_map.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
@@ -30,7 +29,6 @@
|
||||
#include "video_core/rasterizer_interface.h"
|
||||
#include "video_core/surface.h"
|
||||
#include "video_core/texture_cache/copy_params.h"
|
||||
#include "video_core/texture_cache/resolution_scaling/database.h"
|
||||
#include "video_core/texture_cache/surface_base.h"
|
||||
#include "video_core/texture_cache/surface_params.h"
|
||||
#include "video_core/texture_cache/surface_view.h"
|
||||
@@ -55,27 +53,15 @@ class TextureCache {
|
||||
using IntervalMap = boost::icl::interval_map<CacheAddr, std::set<TSurface>>;
|
||||
using IntervalType = typename IntervalMap::interval_type;
|
||||
|
||||
private:
|
||||
enum class UnregisterReason : u32 {
|
||||
Invalidated,
|
||||
Recycled,
|
||||
Rebuilt,
|
||||
Restructured,
|
||||
};
|
||||
|
||||
public:
|
||||
void InvalidateRegion(CacheAddr addr, std::size_t size) {
|
||||
std::lock_guard lock{mutex};
|
||||
|
||||
for (const auto& surface : GetSurfacesInRegion(addr, size)) {
|
||||
Unregister(surface, UnregisterReason::Invalidated);
|
||||
Unregister(surface);
|
||||
}
|
||||
}
|
||||
|
||||
void LoadResources() {
|
||||
scaling_database.Init();
|
||||
}
|
||||
|
||||
/***
|
||||
* `Guard` guarantees that rendertargets don't unregister themselves if the
|
||||
* collide. Protection is currently only done on 3D slices.
|
||||
@@ -165,12 +151,8 @@ public:
|
||||
depth_buffer.target->MarkAsRenderTarget(false, NO_RT);
|
||||
depth_buffer.target = surface_view.first;
|
||||
depth_buffer.view = surface_view.second;
|
||||
if (depth_buffer.target) {
|
||||
if (depth_buffer.target)
|
||||
depth_buffer.target->MarkAsRenderTarget(true, DEPTH_RT);
|
||||
if (IsResolutionScannerEnabled()) {
|
||||
MarkScanner(depth_buffer.target);
|
||||
}
|
||||
}
|
||||
return surface_view.second;
|
||||
}
|
||||
|
||||
@@ -203,12 +185,8 @@ public:
|
||||
render_targets[index].target->MarkAsRenderTarget(false, NO_RT);
|
||||
render_targets[index].target = surface_view.first;
|
||||
render_targets[index].view = surface_view.second;
|
||||
if (render_targets[index].target) {
|
||||
if (render_targets[index].target)
|
||||
render_targets[index].target->MarkAsRenderTarget(true, static_cast<u32>(index));
|
||||
if (IsResolutionScannerEnabled()) {
|
||||
MarkScanner(render_targets[index].target);
|
||||
}
|
||||
}
|
||||
return surface_view.second;
|
||||
}
|
||||
|
||||
@@ -253,12 +231,6 @@ public:
|
||||
DeduceBestBlit(src_params, dst_params, src_gpu_addr, dst_gpu_addr);
|
||||
std::pair<TSurface, TView> dst_surface = GetSurface(dst_gpu_addr, dst_params, true, false);
|
||||
std::pair<TSurface, TView> src_surface = GetSurface(src_gpu_addr, src_params, true, false);
|
||||
if (IsResolutionScannerEnabled()) {
|
||||
bool is_candidate = IsInRSDatabase(src_surface.first);
|
||||
if (is_candidate) {
|
||||
MarkScanner(dst_surface.first);
|
||||
}
|
||||
}
|
||||
ImageBlit(src_surface.second, dst_surface.second, copy_config);
|
||||
dst_surface.first->MarkAsModified(true, Tick());
|
||||
}
|
||||
@@ -282,46 +254,13 @@ public:
|
||||
return ++ticks;
|
||||
}
|
||||
|
||||
bool IsResolutionScalingEnabled() {
|
||||
if (IsResolutionScannerEnabled()) {
|
||||
return CheckBlackListMatch();
|
||||
}
|
||||
if (!EnabledRescaling()) {
|
||||
return false;
|
||||
}
|
||||
return CheckResolutionScalingEnabled();
|
||||
}
|
||||
|
||||
bool IsResolutionScalingEnabledRT(const std::size_t index) {
|
||||
if (!EnabledRescaling()) {
|
||||
return false;
|
||||
}
|
||||
if (render_targets[index].target) {
|
||||
return render_targets[index].target->IsRescaled();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsResolutionScalingEnabledDB() {
|
||||
if (!EnabledRescaling()) {
|
||||
return false;
|
||||
}
|
||||
if (depth_buffer.target) {
|
||||
return depth_buffer.target->IsRescaled();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
TextureCache(Core::System& system, VideoCore::RasterizerInterface& rasterizer)
|
||||
: system{system}, rasterizer{rasterizer}, scaling_database{system} {
|
||||
: system{system}, rasterizer{rasterizer} {
|
||||
for (std::size_t i = 0; i < Tegra::Engines::Maxwell3D::Regs::NumRenderTargets; i++) {
|
||||
SetEmptyColorBuffer(i);
|
||||
}
|
||||
|
||||
enable_resolution_scaling =
|
||||
Settings::values.resolution_factor != 1.0f && !Settings::values.use_resolution_scanner;
|
||||
|
||||
SetEmptyDepthBuffer();
|
||||
staging_cache.SetSize(2);
|
||||
|
||||
@@ -382,19 +321,13 @@ protected:
|
||||
rasterizer.UpdatePagesCachedCount(*cpu_addr, size, 1);
|
||||
}
|
||||
|
||||
void Unregister(TSurface surface, UnregisterReason reason) {
|
||||
void Unregister(TSurface surface) {
|
||||
if (guard_render_targets && surface->IsProtected()) {
|
||||
return;
|
||||
}
|
||||
if (!guard_render_targets && surface->IsRenderTarget()) {
|
||||
ManageRenderTargetUnregister(surface);
|
||||
}
|
||||
|
||||
if (IsResolutionScannerEnabled()) {
|
||||
if (reason == UnregisterReason::Restructured) {
|
||||
UnmarkScanner(surface);
|
||||
}
|
||||
}
|
||||
const std::size_t size = surface->GetSizeInBytes();
|
||||
const VAddr cpu_addr = surface->GetCpuAddr();
|
||||
rasterizer.UpdatePagesCachedCount(cpu_addr, size, -1);
|
||||
@@ -420,13 +353,6 @@ protected:
|
||||
return GetSurface(gpu_addr, params, true, false);
|
||||
}
|
||||
|
||||
// Must be called by child's create surface
|
||||
void SignalCreatedSurface(TSurface& new_surface) {
|
||||
if (EnabledRescaling() && IsInRSDatabase(new_surface)) {
|
||||
new_surface->MarkAsRescaled(true);
|
||||
}
|
||||
}
|
||||
|
||||
Core::System& system;
|
||||
|
||||
private:
|
||||
@@ -510,7 +436,7 @@ private:
|
||||
const MatchTopologyResult untopological) {
|
||||
const bool do_load = preserve_contents && Settings::values.use_accurate_gpu_emulation;
|
||||
for (auto& surface : overlaps) {
|
||||
Unregister(surface, UnregisterReason::Recycled);
|
||||
Unregister(surface);
|
||||
}
|
||||
switch (PickStrategy(overlaps, params, gpu_addr, untopological)) {
|
||||
case RecycleStrategy::Ignore: {
|
||||
@@ -569,22 +495,7 @@ private:
|
||||
ImageCopy(current_surface, new_surface, brick);
|
||||
}
|
||||
}
|
||||
if (IsResolutionScannerEnabled()) {
|
||||
if (IsInRSDatabase(current_surface)) {
|
||||
if (IsRSBlacklisted(new_surface)) {
|
||||
UnmarkScanner(current_surface);
|
||||
} else {
|
||||
MarkScanner(new_surface);
|
||||
}
|
||||
} else if (IsInRSDatabase(new_surface)) {
|
||||
if (IsRSBlacklisted(current_surface)) {
|
||||
UnmarkScanner(new_surface);
|
||||
} else {
|
||||
MarkScanner(current_surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
Unregister(current_surface, UnregisterReason::Rebuilt);
|
||||
Unregister(current_surface);
|
||||
Register(new_surface);
|
||||
new_surface->MarkAsModified(current_surface->IsModified(), Tick());
|
||||
return {new_surface, new_surface->GetMainView()};
|
||||
@@ -665,7 +576,7 @@ private:
|
||||
return {};
|
||||
}
|
||||
for (auto surface : overlaps) {
|
||||
Unregister(surface, UnregisterReason::Restructured);
|
||||
Unregister(surface);
|
||||
}
|
||||
new_surface->MarkAsModified(modified, Tick());
|
||||
Register(new_surface);
|
||||
@@ -932,30 +843,7 @@ private:
|
||||
return {new_surface, new_surface->GetMainView()};
|
||||
}
|
||||
|
||||
void LoadSurfaceRescaled(TSurface& surface) {
|
||||
const auto& params = surface->GetSurfaceParams();
|
||||
enable_resolution_scaling = false;
|
||||
TSurface proxy = CreateSurface(surface->GetGpuAddr(), params);
|
||||
enable_resolution_scaling = true;
|
||||
staging_cache.GetBuffer(0).resize(proxy->GetHostSizeInBytes());
|
||||
proxy->LoadBuffer(system.GPU().MemoryManager(), staging_cache);
|
||||
proxy->UploadTexture(staging_cache.GetBuffer(0));
|
||||
Tegra::Engines::Fermi2D::Config copy_config;
|
||||
const Common::Rectangle<u32> rect{0, 0, params.width, params.height};
|
||||
copy_config.operation = Tegra::Engines::Fermi2D::Operation::SrcCopy;
|
||||
copy_config.filter = Tegra::Engines::Fermi2D::Filter::Linear;
|
||||
copy_config.src_rect = rect;
|
||||
copy_config.dst_rect = rect;
|
||||
TView src_view = proxy->GetMainView();
|
||||
TView dst_view = surface->GetMainView();
|
||||
ImageBlit(src_view, dst_view, copy_config);
|
||||
}
|
||||
|
||||
void LoadSurface(TSurface& surface) {
|
||||
if (surface->IsRescaled()) {
|
||||
LoadSurfaceRescaled(surface);
|
||||
return;
|
||||
}
|
||||
void LoadSurface(const TSurface& surface) {
|
||||
staging_cache.GetBuffer(0).resize(surface->GetHostSizeInBytes());
|
||||
surface->LoadBuffer(system.GPU().MemoryManager(), staging_cache);
|
||||
surface->UploadTexture(staging_cache.GetBuffer(0));
|
||||
@@ -966,9 +854,6 @@ private:
|
||||
if (!surface->IsModified()) {
|
||||
return;
|
||||
}
|
||||
if (IsResolutionScannerEnabled()) {
|
||||
UnmarkScanner(surface);
|
||||
}
|
||||
staging_cache.GetBuffer(0).resize(surface->GetHostSizeInBytes());
|
||||
surface->DownloadTexture(staging_cache.GetBuffer(0));
|
||||
surface->FlushBuffer(system.GPU().MemoryManager(), staging_cache);
|
||||
@@ -1039,115 +924,6 @@ private:
|
||||
return {};
|
||||
}
|
||||
|
||||
bool EnabledRescaling() const {
|
||||
return enable_resolution_scaling;
|
||||
}
|
||||
|
||||
bool IsResolutionScannerEnabled() const {
|
||||
return Settings::values.use_resolution_scanner;
|
||||
}
|
||||
|
||||
void UnmarkScanner(const TSurface& surface) {
|
||||
const auto params = surface->GetSurfaceParams();
|
||||
scaling_database.Unregister(params.pixel_format, params.width, params.height);
|
||||
}
|
||||
|
||||
void MarkScanner(const TSurface& surface) {
|
||||
const auto params = surface->GetSurfaceParams();
|
||||
if (params.target != SurfaceTarget::Texture2D || params.num_levels > 1 ||
|
||||
params.IsCompressed() || params.block_depth > 1) {
|
||||
return;
|
||||
}
|
||||
scaling_database.Register(params.pixel_format, params.width, params.height);
|
||||
}
|
||||
|
||||
bool IsRSBlacklisted(const TSurface& surface) const {
|
||||
const auto params = surface->GetSurfaceParams();
|
||||
return scaling_database.IsBlacklisted(params.pixel_format, params.width, params.height);
|
||||
}
|
||||
|
||||
bool IsInRSDatabase(const TSurface& surface) const {
|
||||
const auto& params = surface->GetSurfaceParams();
|
||||
return scaling_database.IsInDatabase(params.pixel_format, params.width, params.height);
|
||||
}
|
||||
|
||||
bool CheckBlackListMatch() {
|
||||
u32 enabled_targets = 0;
|
||||
u32 black_listed = 0;
|
||||
bool black_list = false;
|
||||
for (const auto& target : render_targets) {
|
||||
if (target.target) {
|
||||
enabled_targets++;
|
||||
if (IsRSBlacklisted(target.target)) {
|
||||
black_list = true;
|
||||
black_listed++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (depth_buffer.target) {
|
||||
enabled_targets++;
|
||||
if (IsRSBlacklisted(depth_buffer.target)) {
|
||||
black_list = true;
|
||||
black_listed++;
|
||||
}
|
||||
}
|
||||
if (black_list) {
|
||||
if (black_listed != enabled_targets) {
|
||||
std::string blacklist_msg{};
|
||||
for (const auto& target : render_targets) {
|
||||
if (target.target) {
|
||||
UnmarkScanner(target.target);
|
||||
const auto& params = target.target->GetSurfaceParams();
|
||||
blacklist_msg += fmt::format("Format:{}, Height:{}, Width:{}\n",
|
||||
static_cast<u32>(params.pixel_format),
|
||||
params.height, params.width);
|
||||
}
|
||||
}
|
||||
if (depth_buffer.target) {
|
||||
UnmarkScanner(depth_buffer.target);
|
||||
const auto& params = depth_buffer.target->GetSurfaceParams();
|
||||
blacklist_msg += fmt::format("Format:{}, Height:{}, Width:{}\n",
|
||||
static_cast<u32>(params.pixel_format),
|
||||
params.height, params.width);
|
||||
}
|
||||
LOG_CRITICAL(HW_GPU, "Scan detected a conflict:\n{}\nBlacklisting all",
|
||||
blacklist_msg);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CheckResolutionScalingEnabled() {
|
||||
u32 enabled_targets = 0;
|
||||
u32 rescaled_targets = 0;
|
||||
bool rescaling = false;
|
||||
for (const auto& target : render_targets) {
|
||||
if (target.target) {
|
||||
enabled_targets++;
|
||||
if (target.target->IsRescaled()) {
|
||||
rescaling = true;
|
||||
rescaled_targets++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (depth_buffer.target) {
|
||||
enabled_targets++;
|
||||
if (depth_buffer.target->IsRescaled()) {
|
||||
rescaling = true;
|
||||
rescaled_targets++;
|
||||
}
|
||||
}
|
||||
if (rescaling) {
|
||||
if (rescaled_targets != enabled_targets) {
|
||||
LOG_CRITICAL(HW_GPU,
|
||||
"Rescaling Database is incorrectly set! Rescan the database!.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
constexpr PixelFormat GetSiblingFormat(PixelFormat format) const {
|
||||
return siblings_table[static_cast<std::size_t>(format)];
|
||||
}
|
||||
@@ -1164,7 +940,6 @@ private:
|
||||
// Guards the cache for protection conflicts.
|
||||
bool guard_render_targets{};
|
||||
bool guard_samplers{};
|
||||
bool enable_resolution_scaling{};
|
||||
|
||||
// The siblings table is for formats that can inter exchange with one another
|
||||
// without causing issues. This is only valid when a conflict occurs on a non
|
||||
@@ -1197,8 +972,6 @@ private:
|
||||
|
||||
StagingCache staging_cache;
|
||||
std::recursive_mutex mutex;
|
||||
|
||||
Resolution::ScalingDatabase scaling_database;
|
||||
};
|
||||
|
||||
} // namespace VideoCommon
|
||||
|
||||
@@ -624,8 +624,6 @@ void Config::ReadRendererValues() {
|
||||
ReadSetting(QStringLiteral("use_accurate_gpu_emulation"), false).toBool();
|
||||
Settings::values.use_asynchronous_gpu_emulation =
|
||||
ReadSetting(QStringLiteral("use_asynchronous_gpu_emulation"), false).toBool();
|
||||
Settings::values.use_resolution_scanner =
|
||||
ReadSetting(QStringLiteral("use_resolution_scanner"), false).toBool();
|
||||
Settings::values.force_30fps_mode =
|
||||
ReadSetting(QStringLiteral("force_30fps_mode"), false).toBool();
|
||||
|
||||
@@ -1049,8 +1047,6 @@ void Config::SaveRendererValues() {
|
||||
Settings::values.use_accurate_gpu_emulation, false);
|
||||
WriteSetting(QStringLiteral("use_asynchronous_gpu_emulation"),
|
||||
Settings::values.use_asynchronous_gpu_emulation, false);
|
||||
WriteSetting(QStringLiteral("use_resolution_scanner"), Settings::values.use_resolution_scanner,
|
||||
false);
|
||||
WriteSetting(QStringLiteral("force_30fps_mode"), Settings::values.force_30fps_mode, false);
|
||||
|
||||
// Cast to double because Qt's written float values are not human-readable
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace {
|
||||
enum class Resolution : int {
|
||||
Scanner,
|
||||
Auto,
|
||||
Scale1x,
|
||||
Scale2x,
|
||||
Scale3x,
|
||||
@@ -19,8 +19,8 @@ enum class Resolution : int {
|
||||
|
||||
float ToResolutionFactor(Resolution option) {
|
||||
switch (option) {
|
||||
case Resolution::Scanner:
|
||||
return 1.f;
|
||||
case Resolution::Auto:
|
||||
return 0.f;
|
||||
case Resolution::Scale1x:
|
||||
return 1.f;
|
||||
case Resolution::Scale2x:
|
||||
@@ -30,12 +30,12 @@ float ToResolutionFactor(Resolution option) {
|
||||
case Resolution::Scale4x:
|
||||
return 4.f;
|
||||
}
|
||||
return 1.f;
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
Resolution FromResolutionFactor(float factor, bool scanner_on) {
|
||||
if (scanner_on) {
|
||||
return Resolution::Scanner;
|
||||
Resolution FromResolutionFactor(float factor) {
|
||||
if (factor == 0.f) {
|
||||
return Resolution::Auto;
|
||||
} else if (factor == 1.f) {
|
||||
return Resolution::Scale1x;
|
||||
} else if (factor == 2.f) {
|
||||
@@ -45,7 +45,7 @@ Resolution FromResolutionFactor(float factor, bool scanner_on) {
|
||||
} else if (factor == 4.f) {
|
||||
return Resolution::Scale4x;
|
||||
}
|
||||
return Resolution::Scale1x;
|
||||
return Resolution::Auto;
|
||||
}
|
||||
} // Anonymous namespace
|
||||
|
||||
@@ -69,9 +69,8 @@ ConfigureGraphics::~ConfigureGraphics() = default;
|
||||
void ConfigureGraphics::SetConfiguration() {
|
||||
const bool runtime_lock = !Core::System::GetInstance().IsPoweredOn();
|
||||
|
||||
ui->resolution_factor_combobox->setEnabled(runtime_lock);
|
||||
ui->resolution_factor_combobox->setCurrentIndex(static_cast<int>(FromResolutionFactor(
|
||||
Settings::values.resolution_factor, Settings::values.use_resolution_scanner)));
|
||||
ui->resolution_factor_combobox->setCurrentIndex(
|
||||
static_cast<int>(FromResolutionFactor(Settings::values.resolution_factor)));
|
||||
ui->use_disk_shader_cache->setEnabled(runtime_lock);
|
||||
ui->use_disk_shader_cache->setChecked(Settings::values.use_disk_shader_cache);
|
||||
ui->use_accurate_gpu_emulation->setChecked(Settings::values.use_accurate_gpu_emulation);
|
||||
@@ -84,13 +83,12 @@ void ConfigureGraphics::SetConfiguration() {
|
||||
}
|
||||
|
||||
void ConfigureGraphics::ApplyConfiguration() {
|
||||
const auto resolution = static_cast<Resolution>(ui->resolution_factor_combobox->currentIndex());
|
||||
Settings::values.resolution_factor = ToResolutionFactor(resolution);
|
||||
Settings::values.resolution_factor =
|
||||
ToResolutionFactor(static_cast<Resolution>(ui->resolution_factor_combobox->currentIndex()));
|
||||
Settings::values.use_disk_shader_cache = ui->use_disk_shader_cache->isChecked();
|
||||
Settings::values.use_accurate_gpu_emulation = ui->use_accurate_gpu_emulation->isChecked();
|
||||
Settings::values.use_asynchronous_gpu_emulation =
|
||||
ui->use_asynchronous_gpu_emulation->isChecked();
|
||||
Settings::values.use_resolution_scanner = resolution == Resolution::Scanner;
|
||||
Settings::values.force_30fps_mode = ui->force_30fps_mode->isChecked();
|
||||
Settings::values.bg_red = static_cast<float>(bg_color.redF());
|
||||
Settings::values.bg_green = static_cast<float>(bg_color.greenF());
|
||||
|
||||
@@ -63,27 +63,27 @@
|
||||
<widget class="QComboBox" name="resolution_factor_combobox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Profile Scanner (Native)</string>
|
||||
<string>Auto (Window Size)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Native (1280x720/1920x1080)</string>
|
||||
<string>Native (1280x720)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2x Native (2560x1440/3840x2160)</string>
|
||||
<string>2x Native (2560x1440)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>3x Native (3840x2160/5760x3240)</string>
|
||||
<string>3x Native (3840x2160)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>4x Native (5120x2880/7680x4320)</string>
|
||||
<string>4x Native (5120x2880)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
|
||||
@@ -73,6 +73,8 @@ std::pair<QString, QString> ConfigureService::BCATDownloadEvents() {
|
||||
const auto res = Service::BCAT::Boxcat::GetStatus(global, map);
|
||||
|
||||
switch (res) {
|
||||
case Service::BCAT::Boxcat::StatusResult::Success:
|
||||
break;
|
||||
case Service::BCAT::Boxcat::StatusResult::Offline:
|
||||
return {QString{},
|
||||
tr("The boxcat service is offline or you are not connected to the internet.")};
|
||||
|
||||
@@ -172,9 +172,7 @@ void GameList::onTextChanged(const QString& new_text) {
|
||||
const int folder_count = tree_view->model()->rowCount();
|
||||
QString edit_filter_text = new_text.toLower();
|
||||
QStandardItem* folder;
|
||||
QStandardItem* child;
|
||||
int children_total = 0;
|
||||
QModelIndex root_index = item_model->invisibleRootItem()->index();
|
||||
|
||||
// If the searchfield is empty every item is visible
|
||||
// Otherwise the filter gets applied
|
||||
@@ -272,6 +270,8 @@ void GameList::onUpdateThemedIcons() {
|
||||
.scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
|
||||
Qt::DecorationRole);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -392,6 +392,8 @@ void GameList::ValidateEntry(const QModelIndex& item) {
|
||||
case GameListItemType::AddDir:
|
||||
emit AddDirectory();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,6 +464,8 @@ void GameList::PopupContextMenu(const QPoint& menu_location) {
|
||||
case GameListItemType::SysNandDir:
|
||||
AddPermDirPopup(context_menu, selected);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
context_menu.exec(tree_view->viewport()->mapToGlobal(menu_location));
|
||||
}
|
||||
@@ -471,7 +475,6 @@ void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, std::string pat
|
||||
QAction* open_lfs_location = context_menu.addAction(tr("Open Mod Data Location"));
|
||||
QAction* open_transferable_shader_cache =
|
||||
context_menu.addAction(tr("Open Transferable Shader Cache"));
|
||||
QAction* open_rescaling_profile_cache = context_menu.addAction(tr("Open Rescaling Profile"));
|
||||
context_menu.addSeparator();
|
||||
QAction* dump_romfs = context_menu.addAction(tr("Dump RomFS"));
|
||||
QAction* copy_tid = context_menu.addAction(tr("Copy Title ID to Clipboard"));
|
||||
@@ -491,8 +494,6 @@ void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, std::string pat
|
||||
});
|
||||
connect(open_transferable_shader_cache, &QAction::triggered,
|
||||
[this, program_id]() { emit OpenTransferableShaderCacheRequested(program_id); });
|
||||
connect(open_rescaling_profile_cache, &QAction::triggered,
|
||||
[this, program_id]() { emit OpenResolutionProfileRequested(program_id); });
|
||||
connect(dump_romfs, &QAction::triggered,
|
||||
[this, program_id, path]() { emit DumpRomFSRequested(program_id, path); });
|
||||
connect(copy_tid, &QAction::triggered,
|
||||
|
||||
@@ -75,7 +75,6 @@ signals:
|
||||
void ShouldCancelWorker();
|
||||
void OpenFolderRequested(u64 program_id, GameListOpenTarget target);
|
||||
void OpenTransferableShaderCacheRequested(u64 program_id);
|
||||
void OpenResolutionProfileRequested(u64 program_id);
|
||||
void DumpRomFSRequested(u64 program_id, const std::string& game_path);
|
||||
void CopyTIDRequested(u64 program_id);
|
||||
void NavigateToGamedbEntryRequested(u64 program_id,
|
||||
|
||||
@@ -247,7 +247,7 @@ public:
|
||||
Qt::DecorationRole);
|
||||
setData(QObject::tr("System Titles"), Qt::DisplayRole);
|
||||
break;
|
||||
case GameListItemType::CustomDir:
|
||||
case GameListItemType::CustomDir: {
|
||||
const QString icon_name = QFileInfo::exists(game_dir->path)
|
||||
? QStringLiteral("folder")
|
||||
: QStringLiteral("bad_folder");
|
||||
@@ -256,8 +256,11 @@ public:
|
||||
Qt::DecorationRole);
|
||||
setData(game_dir->path, Qt::DisplayRole);
|
||||
break;
|
||||
};
|
||||
};
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int type() const override {
|
||||
return static_cast<int>(dir_type);
|
||||
|
||||
@@ -326,10 +326,10 @@ void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_pa
|
||||
}
|
||||
} else {
|
||||
std::vector<u8> icon;
|
||||
const auto res1 = loader->ReadIcon(icon);
|
||||
[[maybe_unused]] const auto res1 = loader->ReadIcon(icon);
|
||||
|
||||
std::string name = " ";
|
||||
const auto res3 = loader->ReadTitle(name);
|
||||
[[maybe_unused]] const auto res3 = loader->ReadTitle(name);
|
||||
|
||||
const FileSys::PatchManager patch{program_id};
|
||||
|
||||
@@ -354,20 +354,20 @@ void GameListWorker::run() {
|
||||
for (UISettings::GameDir& game_dir : game_dirs) {
|
||||
if (game_dir.path == QStringLiteral("SDMC")) {
|
||||
auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SdmcDir);
|
||||
emit DirEntryReady({game_list_dir});
|
||||
emit DirEntryReady(game_list_dir);
|
||||
AddTitlesToGameList(game_list_dir);
|
||||
} else if (game_dir.path == QStringLiteral("UserNAND")) {
|
||||
auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::UserNandDir);
|
||||
emit DirEntryReady({game_list_dir});
|
||||
emit DirEntryReady(game_list_dir);
|
||||
AddTitlesToGameList(game_list_dir);
|
||||
} else if (game_dir.path == QStringLiteral("SysNAND")) {
|
||||
auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SysNandDir);
|
||||
emit DirEntryReady({game_list_dir});
|
||||
emit DirEntryReady(game_list_dir);
|
||||
AddTitlesToGameList(game_list_dir);
|
||||
} else {
|
||||
watch_list.append(game_dir.path);
|
||||
auto* const game_list_dir = new GameListDir(game_dir);
|
||||
emit DirEntryReady({game_list_dir});
|
||||
emit DirEntryReady(game_list_dir);
|
||||
provider->ClearAllEntries();
|
||||
ScanFileSystem(ScanTarget::FillManualContentProvider, game_dir.path.toStdString(), 2,
|
||||
game_list_dir);
|
||||
|
||||
@@ -75,8 +75,9 @@ private:
|
||||
|
||||
std::shared_ptr<FileSys::VfsFilesystem> vfs;
|
||||
FileSys::ManualContentProvider* provider;
|
||||
QStringList watch_list;
|
||||
const CompatibilityList& compatibility_list;
|
||||
QVector<UISettings::GameDir>& game_dirs;
|
||||
const CompatibilityList& compatibility_list;
|
||||
|
||||
QStringList watch_list;
|
||||
std::atomic_bool stop_processing;
|
||||
};
|
||||
|
||||
+28
-42
@@ -681,8 +681,6 @@ void GMainWindow::ConnectWidgetEvents() {
|
||||
connect(game_list, &GameList::OpenFolderRequested, this, &GMainWindow::OnGameListOpenFolder);
|
||||
connect(game_list, &GameList::OpenTransferableShaderCacheRequested, this,
|
||||
&GMainWindow::OnTransferableShaderCacheOpenFile);
|
||||
connect(game_list, &GameList::OpenResolutionProfileRequested, this,
|
||||
&GMainWindow::OnResolutionProfileOpenFile);
|
||||
connect(game_list, &GameList::DumpRomFSRequested, this, &GMainWindow::OnGameListDumpRomFS);
|
||||
connect(game_list, &GameList::CopyTIDRequested, this, &GMainWindow::OnGameListCopyTID);
|
||||
connect(game_list, &GameList::NavigateToGamedbEntryRequested, this,
|
||||
@@ -1149,23 +1147,6 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(qpath));
|
||||
}
|
||||
|
||||
void DisplayOrSelect(const QString& folder_path, const QString& file_path) {
|
||||
// Windows supports opening a folder with selecting a specified file in explorer. On every other
|
||||
// OS we just open the transferable shader cache folder without preselecting the transferable
|
||||
// shader cache file for the selected game.
|
||||
#if defined(Q_OS_WIN)
|
||||
const QString explorer = QStringLiteral("explorer");
|
||||
QStringList param;
|
||||
if (!QFileInfo(file_path).isDir()) {
|
||||
param << QStringLiteral("/select,");
|
||||
}
|
||||
param << QDir::toNativeSeparators(file_path);
|
||||
QProcess::startDetached(explorer, param);
|
||||
#else
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(folder_path));
|
||||
#endif
|
||||
}
|
||||
|
||||
void GMainWindow::OnTransferableShaderCacheOpenFile(u64 program_id) {
|
||||
ASSERT(program_id != 0);
|
||||
|
||||
@@ -1183,24 +1164,20 @@ void GMainWindow::OnTransferableShaderCacheOpenFile(u64 program_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
DisplayOrSelect(tranferable_shader_cache_folder_path, transferable_shader_cache_file_path);
|
||||
}
|
||||
|
||||
void GMainWindow::OnResolutionProfileOpenFile(u64 program_id) {
|
||||
ASSERT(program_id != 0);
|
||||
|
||||
const QString rescaling_dir =
|
||||
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::RescalingDir));
|
||||
const QString rescaling_profile_file_path =
|
||||
rescaling_dir + QString::fromStdString(fmt::format("{:016X}.json", program_id));
|
||||
|
||||
if (!QFile::exists(rescaling_profile_file_path)) {
|
||||
QMessageBox::warning(this, tr("Error Opening Rescaling Profile"),
|
||||
tr("A rescaling profile for this title does not exist."));
|
||||
return;
|
||||
// Windows supports opening a folder with selecting a specified file in explorer. On every other
|
||||
// OS we just open the transferable shader cache folder without preselecting the transferable
|
||||
// shader cache file for the selected game.
|
||||
#if defined(Q_OS_WIN)
|
||||
const QString explorer = QStringLiteral("explorer");
|
||||
QStringList param;
|
||||
if (!QFileInfo(transferable_shader_cache_file_path).isDir()) {
|
||||
param << QStringLiteral("/select,");
|
||||
}
|
||||
|
||||
DisplayOrSelect(rescaling_dir, rescaling_profile_file_path);
|
||||
param << QDir::toNativeSeparators(transferable_shader_cache_file_path);
|
||||
QProcess::startDetached(explorer, param);
|
||||
#else
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(tranferable_shader_cache_folder_path));
|
||||
#endif
|
||||
}
|
||||
|
||||
static std::size_t CalculateRomFSEntrySize(const FileSys::VirtualDir& dir, bool full) {
|
||||
@@ -1912,15 +1889,24 @@ void GMainWindow::OnCaptureScreenshot() {
|
||||
}
|
||||
|
||||
void GMainWindow::UpdateWindowTitle(const QString& title_name) {
|
||||
const QString full_name = QString::fromUtf8(Common::g_build_fullname);
|
||||
const QString branch_name = QString::fromUtf8(Common::g_scm_branch);
|
||||
const QString description = QString::fromUtf8(Common::g_scm_desc);
|
||||
const auto full_name = std::string(Common::g_build_fullname);
|
||||
const auto branch_name = std::string(Common::g_scm_branch);
|
||||
const auto description = std::string(Common::g_scm_desc);
|
||||
const auto build_id = std::string(Common::g_build_id);
|
||||
|
||||
const auto date =
|
||||
QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd")).toStdString();
|
||||
|
||||
if (title_name.isEmpty()) {
|
||||
setWindowTitle(QStringLiteral("yuzu %1| %2-%3").arg(full_name, branch_name, description));
|
||||
const auto fmt = std::string(Common::g_title_bar_format_idle);
|
||||
setWindowTitle(QString::fromStdString(fmt::format(fmt.empty() ? "yuzu {0}| {1}-{2}" : fmt,
|
||||
full_name, branch_name, description,
|
||||
std::string{}, date, build_id)));
|
||||
} else {
|
||||
setWindowTitle(QStringLiteral("yuzu %1| %4 | %2-%3")
|
||||
.arg(full_name, branch_name, description, title_name));
|
||||
const auto fmt = std::string(Common::g_title_bar_format_running);
|
||||
setWindowTitle(QString::fromStdString(
|
||||
fmt::format(fmt.empty() ? "yuzu {0}| {3} | {1}-{2}" : fmt, full_name, branch_name,
|
||||
description, title_name.toStdString(), date, build_id)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,6 @@ private slots:
|
||||
void OnGameListLoadFile(QString game_path);
|
||||
void OnGameListOpenFolder(u64 program_id, GameListOpenTarget target);
|
||||
void OnTransferableShaderCacheOpenFile(u64 program_id);
|
||||
void OnResolutionProfileOpenFile(u64 program_id);
|
||||
void OnGameListDumpRomFS(u64 program_id, const std::string& game_path);
|
||||
void OnGameListCopyTID(u64 program_id);
|
||||
void OnGameListNavigateToGamedbEntry(u64 program_id,
|
||||
|
||||
@@ -93,7 +93,6 @@ void Config::ReadValues() {
|
||||
|
||||
// System
|
||||
Settings::values.use_docked_mode = sdl2_config->GetBoolean("System", "use_docked_mode", false);
|
||||
const auto size = sdl2_config->GetInteger("System", "users_size", 0);
|
||||
|
||||
Settings::values.current_user = std::clamp<int>(
|
||||
sdl2_config->GetInteger("System", "current_user", 0), 0, Service::Account::MAX_USERS - 1);
|
||||
|
||||
Reference in New Issue
Block a user