mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
feat: GPU acceleration (DX12/DirectML)
Co-authored-by: SherkeyXD <253294679@qq.com>
This commit is contained in:
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -367,7 +367,7 @@ jobs:
|
||||
- name: Build XCFramework
|
||||
run: |
|
||||
xcodebuild -create-xcframework -library libMaaCore.dylib -headers ../include -output MaaCore.xcframework
|
||||
xcodebuild -create-xcframework -library libMaaDerpLearning.dylib -output MaaDerpLearning.xcframework
|
||||
xcodebuild -create-xcframework -library libfastdeploy_ppocr.dylib -output fastdeploy_ppocr.xcframework
|
||||
xcodebuild -create-xcframework -library libonnxruntime.*.dylib -output ONNXRuntime.xcframework
|
||||
xcodebuild -create-xcframework -library libopencv*.dylib -output OpenCV.xcframework
|
||||
working-directory: build
|
||||
|
||||
@@ -84,36 +84,32 @@ find_package(cpr CONFIG REQUIRED)
|
||||
list(APPEND maa_libs ${OpenCV_LIBS} ZLIB::ZLIB cpr::cpr header_only_libraries)
|
||||
|
||||
if(USE_MAADEPS)
|
||||
find_package(ONNXRuntime REQUIRED)
|
||||
find_package(asio REQUIRED)
|
||||
list(APPEND maa_libs ONNXRuntime::ONNXRuntime asio::asio)
|
||||
|
||||
find_package(MaaDerpLearning REQUIRED)
|
||||
list(APPEND maa_libs MaaDerpLearning)
|
||||
else()
|
||||
find_package(onnxruntime REQUIRED) # provided by onnxruntime>=1.16
|
||||
list(APPEND maa_libs onnxruntime::onnxruntime)
|
||||
if(DEFINED fastdeploy_SOURCE_DIR)
|
||||
# TODO: FetchContent github.com/MaaAssistantArknights/FastDeploy
|
||||
if(NOT DEFINED fastdeploy_BINARY_DIR)
|
||||
set(fastdeploy_BINARY_DIR ${CMAKE_BINARY_DIR}/fastdeploy)
|
||||
endif()
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
add_subdirectory(${fastdeploy_SOURCE_DIR} ${fastdeploy_BINARY_DIR} EXCLUDE_FROM_ALL SYSTEM)
|
||||
if(NOT DEFINED fastdeploy_INCLUDE_DIRS)
|
||||
set(fastdeploy_INCLUDE_DIRS ${fastdeploy_SOURCE_DIR})
|
||||
endif()
|
||||
get_target_property(fastdeploy_type fastdeploy_ppocr TYPE)
|
||||
if(fastdeploy_type STREQUAL "SHARED_LIBRARY")
|
||||
install(TARGETS fastdeploy_ppocr)
|
||||
endif()
|
||||
else()
|
||||
find_package(fastdeploy_ppocr REQUIRED)
|
||||
endif()
|
||||
list(APPEND maa_libs fastdeploy_ppocr)
|
||||
target_include_directories(MaaCore SYSTEM PRIVATE ${fastdeploy_INCLUDE_DIRS})
|
||||
list(APPEND maa_libs asio::asio)
|
||||
endif()
|
||||
|
||||
find_package(onnxruntime CONFIG REQUIRED) # provided by onnxruntime>=1.16
|
||||
list(APPEND maa_libs onnxruntime::onnxruntime)
|
||||
if(DEFINED fastdeploy_SOURCE_DIR)
|
||||
# TODO: FetchContent github.com/MaaAssistantArknights/FastDeploy
|
||||
if(NOT DEFINED fastdeploy_BINARY_DIR)
|
||||
set(fastdeploy_BINARY_DIR ${CMAKE_BINARY_DIR}/fastdeploy)
|
||||
endif()
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
add_subdirectory(${fastdeploy_SOURCE_DIR} ${fastdeploy_BINARY_DIR} EXCLUDE_FROM_ALL SYSTEM)
|
||||
if(NOT DEFINED fastdeploy_INCLUDE_DIRS)
|
||||
set(fastdeploy_INCLUDE_DIRS ${fastdeploy_SOURCE_DIR})
|
||||
endif()
|
||||
target_include_directories(MaaCore SYSTEM PRIVATE ${fastdeploy_INCLUDE_DIRS})
|
||||
get_target_property(fastdeploy_type fastdeploy_ppocr TYPE)
|
||||
if(fastdeploy_type STREQUAL "SHARED_LIBRARY")
|
||||
install(TARGETS fastdeploy_ppocr)
|
||||
endif()
|
||||
else()
|
||||
find_package(fastdeploy_ppocr REQUIRED)
|
||||
endif()
|
||||
list(APPEND maa_libs fastdeploy_ppocr)
|
||||
|
||||
target_link_libraries(MaaCore ${maa_libs})
|
||||
|
||||
if(WITH_EMULATOR_EXTRAS AND NOT EXISTS ${PROJECT_SOURCE_DIR}/3rdparty/EmulatorExtras/Mumu)
|
||||
|
||||
2
MaaDeps
2
MaaDeps
Submodule MaaDeps updated: 1297324ea7...10d51f5832
@@ -1,22 +0,0 @@
|
||||
# TODO: replace with cmake-generated interface file
|
||||
|
||||
find_path(FastDeploy_INCLUDE_DIR NAMES fastdeploy/fastdeploy_model.h)
|
||||
|
||||
find_library(FastDeploy_LIBRARY NAMES fastdeploy)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(
|
||||
FastDeploy
|
||||
REQUIRED_VARS FastDeploy_LIBRARY FastDeploy_INCLUDE_DIR
|
||||
)
|
||||
|
||||
if(FastDeploy_FOUND)
|
||||
set(FastDeploy_INCLUDE_DIRS ${FastDeploy_INCLUDE_DIR})
|
||||
if(NOT TARGET FastDeploy::FastDeploy)
|
||||
add_library(FastDeploy::FastDeploy UNKNOWN IMPORTED)
|
||||
set_target_properties(FastDeploy::FastDeploy PROPERTIES
|
||||
IMPORTED_LOCATION "${FastDeploy_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${FastDeploy_INCLUDE_DIR}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
@@ -1,20 +0,0 @@
|
||||
find_path(ONNXRuntime_INCLUDE_DIR NAMES onnxruntime/core/session/onnxruntime_c_api.h)
|
||||
|
||||
find_library(ONNXRuntime_LIBRARY NAMES onnxruntime)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(
|
||||
ONNXRuntime
|
||||
REQUIRED_VARS ONNXRuntime_LIBRARY ONNXRuntime_INCLUDE_DIR
|
||||
)
|
||||
|
||||
if(ONNXRuntime_FOUND)
|
||||
set(ONNXRuntime_INCLUDE_DIRS ${ONNXRuntime_INCLUDE_DIR})
|
||||
if(NOT TARGET ONNXRuntime::ONNXRuntime)
|
||||
add_library(ONNXRuntime::ONNXRuntime UNKNOWN IMPORTED)
|
||||
set_target_properties(ONNXRuntime::ONNXRuntime PROPERTIES
|
||||
IMPORTED_LOCATION "${ONNXRuntime_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${ONNXRuntime_INCLUDE_DIR}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
@@ -1,50 +0,0 @@
|
||||
|
||||
|
||||
set(FASTDEPLOY_URL_PREFIX "https://github.com/MaaAssistantArknights/build-fastdeploy/releases/download")
|
||||
|
||||
set(FASTDEPLOY_TAG "gac255b8a")
|
||||
|
||||
set(COMPRESSED_SUFFIX ".tar.gz")
|
||||
|
||||
if(WIN32)
|
||||
set(FASTDEPLOY_FILENAME "FastDeploy-Windows")
|
||||
set(FASTDEPLOY_CHECKSUM "0a0700d4e8923bcd4c387a658e5e9a689ed9e0d114c260b11d082a2176c233d4")
|
||||
elseif(APPLE)
|
||||
if (CURRENT_OSX_ARCH STREQUAL "arm64")
|
||||
set(FASTDEPLOY_FILENAME "FastDeploy-macOS-arm64")
|
||||
set(FASTDEPLOY_CHECKSUM "28a771814d197ba8056f1fcb7cc0671facec90a8733a0dac2cf0b68a8cc36d24")
|
||||
else()
|
||||
set(FASTDEPLOY_FILENAME "FastDeploy-macOS-x86_64")
|
||||
set(FASTDEPLOY_CHECKSUM "76e97c7e944a18eb160646fa32ac0a7e24c87751b2b127dc33454f993f6d4b97")
|
||||
endif()
|
||||
else()
|
||||
set(FASTDEPLOY_FILENAME "FastDeploy-Linux")
|
||||
set(FASTDEPLOY_CHECKSUM "4d106e5499e9b5b29426667617215ac7e4e70d2353af10caccdfdf6c1f1534a7")
|
||||
endif(WIN32)
|
||||
|
||||
set(FASTDEPLOY_URL ${FASTDEPLOY_URL_PREFIX}/${FASTDEPLOY_TAG}/${FASTDEPLOY_FILENAME}${COMPRESSED_SUFFIX})
|
||||
|
||||
if (FASTDEPLOY_DIRECTORY)
|
||||
set(FastDeploy_DIR ${FASTDEPLOY_DIRECTORY})
|
||||
find_package(FastDeploy REQUIRED PATHS ${FastDeploy_DIR})
|
||||
include_directories(${FastDeploy_INCLUDE_DIRS})
|
||||
list(APPEND DEPEND_LIBS ${FastDeploy_LIBS})
|
||||
else ()
|
||||
download_and_decompress(${FASTDEPLOY_URL}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${FASTDEPLOY_FILENAME}${COMPRESSED_SUFFIX}
|
||||
${FASTDEPLOY_CHECKSUM}
|
||||
${THIRD_PARTY_PATH}/install/)
|
||||
set(FASTDEPLOY_FILENAME fastdeploy)
|
||||
set(FastDeploy_DIR ${THIRD_PARTY_PATH}/install/${FASTDEPLOY_FILENAME})
|
||||
|
||||
find_package(FastDeploy REQUIRED PATHS ${FastDeploy_DIR} NO_DEFAULT_PATH)
|
||||
include_directories(${FastDeploy_INCLUDE_DIRS})
|
||||
list(APPEND DEPEND_LIBS ${FastDeploy_LIBS})
|
||||
endif (FASTDEPLOY_DIRECTORY)
|
||||
|
||||
if (INSTALL_THIRD_LIBS)
|
||||
install(DIRECTORY ${FastDeploy_DIR}/lib/ DESTINATION . USE_SOURCE_PERMISSIONS)
|
||||
install(DIRECTORY ${ORT_LIB_PATH}/ DESTINATION . USE_SOURCE_PERMISSIONS)
|
||||
install(DIRECTORY ${FastDeploy_DIR}/third_libs/install/paddle2onnx/lib/
|
||||
DESTINATION . USE_SOURCE_PERMISSIONS)
|
||||
endif (INSTALL_THIRD_LIBS)
|
||||
@@ -15,13 +15,13 @@ if (BUILD_XCFRAMEWORK)
|
||||
COMMAND xcodebuild -create-xcframework -library "${PROJECT_SOURCE_DIR}/MaaDeps/runtime/${MAADEPS_TRIPLET}/libonnxruntime.1.14.1.dylib" -output ONNXRuntime.xcframework
|
||||
)
|
||||
|
||||
add_custom_command(OUTPUT MaaDerpLearning.xcframework
|
||||
COMMAND rm -rf MaaDerpLearning.xcframework
|
||||
COMMAND xcodebuild -create-xcframework -library "${PROJECT_SOURCE_DIR}/MaaDeps/runtime/${MAADEPS_TRIPLET}/libMaaDerpLearning.dylib" -output MaaDerpLearning.xcframework
|
||||
add_custom_command(OUTPUT fastdeploy_ppocr.xcframework
|
||||
COMMAND rm -rf fastdeploy_ppocr.xcframework
|
||||
COMMAND xcodebuild -create-xcframework -library "${PROJECT_SOURCE_DIR}/MaaDeps/runtime/${MAADEPS_TRIPLET}/libfastdeploy_ppocr.dylib" -output fastdeploy_ppocr.xcframework
|
||||
)
|
||||
|
||||
add_custom_target(MaaXCFramework ALL
|
||||
DEPENDS MaaCore MaaCore.xcframework OpenCV.xcframework ONNXRuntime.xcframework MaaDerpLearning.xcframework
|
||||
DEPENDS MaaCore MaaCore.xcframework OpenCV.xcframework ONNXRuntime.xcframework fastdeploy_ppocr.xcframework
|
||||
)
|
||||
endif (BUILD_XCFRAMEWORK)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import time
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
|
||||
TARGET_TAG = "2023-04-24-3"
|
||||
TARGET_TAG = "2024-05-30"
|
||||
basedir = Path(__file__).parent
|
||||
|
||||
def detect_host_triplet():
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "Config/GeneralConfig.h"
|
||||
#include "Config/Miscellaneous/OcrPack.h"
|
||||
#include "Config/OnnxSessions.h"
|
||||
#include "Config/ResourceLoader.h"
|
||||
#include "Controller/Controller.h"
|
||||
#include "Status.h"
|
||||
@@ -40,12 +41,14 @@ bool ::AsstExtAPI::set_static_option(StaticOptionKey key, const std::string& val
|
||||
case StaticOptionKey::CpuOCR: {
|
||||
WordOcr::get_instance().use_cpu();
|
||||
CharOcr::get_instance().use_cpu();
|
||||
OnnxSessions::get_instance().use_cpu();
|
||||
return true;
|
||||
} break;
|
||||
case StaticOptionKey::GpuOCR: {
|
||||
int device_id = std::stoi(value);
|
||||
WordOcr::get_instance().use_gpu(device_id);
|
||||
CharOcr::get_instance().use_gpu(device_id);
|
||||
OnnxSessions::get_instance().use_gpu(device_id);
|
||||
return true;
|
||||
} break;
|
||||
default:
|
||||
|
||||
@@ -6,6 +6,16 @@
|
||||
|
||||
#include "Utils/Logger.hpp"
|
||||
|
||||
#if __has_include(<onnxruntime/dml_provider_factory.h>)
|
||||
#define WITH_DML
|
||||
#include <onnxruntime/dml_provider_factory.h>
|
||||
#endif
|
||||
|
||||
#if __has_include(<onnxruntime/coreml_provider_factory.h>)
|
||||
#define WITH_COREML
|
||||
#include <onnxruntime/coreml_provider_factory.h>
|
||||
#endif
|
||||
|
||||
bool asst::OnnxSessions::load(const std::filesystem::path& path)
|
||||
{
|
||||
LogTraceFunction;
|
||||
@@ -30,3 +40,61 @@ Ort::Session& asst::OnnxSessions::get(const std::string& name)
|
||||
}
|
||||
return m_sessions.at(name);
|
||||
}
|
||||
|
||||
bool asst::OnnxSessions::use_cpu()
|
||||
{
|
||||
if (m_sessions.size() != 0) return false;
|
||||
m_options = Ort::SessionOptions();
|
||||
gpu_enabled = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool asst::OnnxSessions::use_gpu(int device_id)
|
||||
{
|
||||
if (gpu_enabled) return true;
|
||||
if (m_sessions.size() != 0) return false;
|
||||
auto all_providers = Ort::GetAvailableProviders();
|
||||
bool support_cuda = false;
|
||||
bool support_dml = false;
|
||||
bool support_coreml = false;
|
||||
for (const auto& provider : all_providers) {
|
||||
if (provider == "CUDAExecutionProvider") {
|
||||
support_cuda = true;
|
||||
}
|
||||
if (provider == "DmlExecutionProvider") {
|
||||
support_dml = true;
|
||||
}
|
||||
if (provider == "CoreMLExecutionProvider") {
|
||||
support_coreml = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool any_gpu = support_cuda || support_dml || support_coreml;
|
||||
|
||||
if (support_cuda) {
|
||||
OrtCUDAProviderOptions cuda_options;
|
||||
cuda_options.device_id = device_id;
|
||||
m_options.AppendExecutionProvider_CUDA(cuda_options);
|
||||
}
|
||||
#ifdef WITH_DML
|
||||
else if (support_dml) {
|
||||
if (!Ort::Status(OrtSessionOptionsAppendExecutionProvider_DML(m_options, device_id)).IsOK()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef WITH_COREML
|
||||
else if (support_coreml) {
|
||||
if (!Ort::Status(OrtSessionOptionsAppendExecutionProvider_CoreML((OrtSessionOptions*)m_options, 0)).IsOK()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!any_gpu) {
|
||||
Log.error(__FUNCTION__, "No GPU execution provider available");
|
||||
return false;
|
||||
}
|
||||
|
||||
gpu_enabled = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
#if __has_include(<onnxruntime_cxx_api.h>)
|
||||
#include <onnxruntime_cxx_api.h>
|
||||
#elif __has_include(<onnxruntime/onnxruntime_cxx_api.h>)
|
||||
#include <onnxruntime/onnxruntime_cxx_api.h>
|
||||
#else
|
||||
#include <onnxruntime/core/session/onnxruntime_cxx_api.h>
|
||||
#endif
|
||||
@@ -19,11 +21,14 @@ namespace asst
|
||||
virtual bool load(const std::filesystem::path& path) override;
|
||||
|
||||
Ort::Session& get(const std::string& name);
|
||||
bool use_cpu();
|
||||
bool use_gpu(int device_id);
|
||||
|
||||
private:
|
||||
Ort::Env m_env;
|
||||
Ort::SessionOptions m_options;
|
||||
std::unordered_map<std::string, Ort::Session> m_sessions;
|
||||
std::unordered_map<std::string, std::filesystem::path> m_model_paths;
|
||||
bool gpu_enabled;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -521,7 +521,7 @@
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>MaaDerpLearning.lib;opencv_world4.lib;zlib.lib;ws2_32.lib;onnxruntime.lib;cpr.lib;libcurl.lib;crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>fastdeploy_ppocr.lib;opencv_world4.lib;zlib.lib;ws2_32.lib;onnxruntime.lib;cpr.lib;libcurl.lib;crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
|
||||
<Profile>true</Profile>
|
||||
<AdditionalOptions>/ignore:4286 %(AdditionalOptions)</AdditionalOptions>
|
||||
@@ -568,7 +568,7 @@
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>MaaDerpLearning.lib;opencv_world4.lib;zlib.lib;ws2_32.lib;onnxruntime.lib;cpr.lib;libcurl.lib;crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>fastdeploy_ppocr.lib;opencv_world4.lib;zlib.lib;ws2_32.lib;onnxruntime.lib;cpr.lib;libcurl.lib;crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
|
||||
<Profile>true</Profile>
|
||||
<AdditionalOptions>/ignore:4286 %(AdditionalOptions)</AdditionalOptions>
|
||||
@@ -619,7 +619,7 @@
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>MaaDerpLearning.lib;opencv_world4.lib;zlib.lib;ws2_32.lib;onnxruntime.lib;cpr.lib;libcurl.lib;crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>fastdeploy_ppocr.lib;opencv_world4.lib;zlib.lib;ws2_32.lib;onnxruntime.lib;cpr.lib;libcurl.lib;crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
|
||||
<Profile>true</Profile>
|
||||
<AdditionalOptions>/ignore:4286 %(AdditionalOptions)</AdditionalOptions>
|
||||
@@ -673,7 +673,7 @@
|
||||
<OptimizeReferences>
|
||||
</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>MaaDerpLearning.lib;opencv_world4d.lib;zlibd.lib;ws2_32.lib;onnxruntime.lib;cpr.lib;libcurl-d.lib;crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>fastdeploy_ppocr.lib;opencv_world4d.lib;zlibd.lib;ws2_32.lib;onnxruntime.lib;cpr.lib;libcurl-d.lib;crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
|
||||
<Profile>
|
||||
</Profile>
|
||||
@@ -724,7 +724,7 @@
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>MaaDerpLearning.lib;opencv_world4.lib;zlib.lib;ws2_32.lib;onnxruntime.lib;cpr.lib;libcurl.lib;crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>fastdeploy_ppocr.lib;opencv_world4.lib;zlib.lib;ws2_32.lib;onnxruntime.lib;cpr.lib;libcurl.lib;crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
|
||||
<Profile>true</Profile>
|
||||
<AdditionalOptions>/ignore:4286 %(AdditionalOptions)</AdditionalOptions>
|
||||
@@ -777,7 +777,7 @@
|
||||
<OptimizeReferences>
|
||||
</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>MaaDerpLearning.lib;opencv_world4.lib;zlib.lib;ws2_32.lib;onnxruntime.lib;cpr.lib;libcurl.lib;crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>fastdeploy_ppocr.lib;opencv_world4.lib;zlib.lib;ws2_32.lib;onnxruntime.lib;cpr.lib;libcurl.lib;crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
|
||||
<Profile>
|
||||
</Profile>
|
||||
|
||||
Submodule src/MaaMacGui updated: 3c1787a511...b3553eee75
@@ -231,6 +231,10 @@ namespace MaaWpfGui.Constants
|
||||
public const string ExternalNotificationBarkSendKey = "ExternalNotification.Bark.SendKey";
|
||||
public const string ExternalNotificationBarkServer = "ExternalNotification.Bark.Server";
|
||||
|
||||
public const string PerformanceUseGpu = "Performance.UseGpu";
|
||||
public const string PerformancePreferredGpuDescription = "Performance.PreferredGpuDescription";
|
||||
public const string PerformancePreferredGpuInstancePath = "Performance.PreferredGpuInstancePath";
|
||||
|
||||
// The following should not be modified manually
|
||||
public const string VersionName = "VersionUpdate.name";
|
||||
|
||||
|
||||
303
src/MaaWpfGui/Helper/GpuOption.cs
Normal file
303
src/MaaWpfGui/Helper/GpuOption.cs
Normal file
@@ -0,0 +1,303 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DirectN;
|
||||
using MaaWpfGui.Constants;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace MaaWpfGui.Helper
|
||||
{
|
||||
public abstract class GpuOption
|
||||
{
|
||||
public static GpuOption Disable => DisableOption.Instance;
|
||||
|
||||
public static GpuOption SystemDefault => SystemDefaultOption.Instance;
|
||||
|
||||
private static readonly List<GpuOption> _unavailableOptions = [Disable];
|
||||
|
||||
private static IDXGIFactory4? GetDxgiFactory()
|
||||
{
|
||||
var hr = DXGIFunctions.CreateDXGIFactory2(0, typeof(IDXGIFactory4).GUID, out var comobj);
|
||||
if (!hr.IsSuccess)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (IDXGIFactory4)comobj;
|
||||
}
|
||||
|
||||
public static List<GpuOption> GetGpuOptions()
|
||||
{
|
||||
var factory = GetDxgiFactory();
|
||||
|
||||
if (factory == null)
|
||||
{
|
||||
return _unavailableOptions;
|
||||
}
|
||||
|
||||
uint i = 0;
|
||||
|
||||
var options = new List<GpuOption>()
|
||||
{
|
||||
Disable,
|
||||
SystemDefault,
|
||||
};
|
||||
|
||||
while (true)
|
||||
{
|
||||
IDXGIAdapter1 adapter;
|
||||
var hr = factory.EnumAdapters1(i, out adapter);
|
||||
if (hr == HRESULTS.DXGI_ERROR_NOT_FOUND)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var index = i;
|
||||
i++;
|
||||
|
||||
var desc = adapter.GetDesc1();
|
||||
|
||||
if ((desc.Flags & (uint)DXGI_ADAPTER_FLAG.DXGI_ADAPTER_FLAG_SOFTWARE) != 0)
|
||||
{
|
||||
// skip software device
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!CheckD3D12Support(adapter))
|
||||
{
|
||||
// skip adapters without D3D12 support
|
||||
continue;
|
||||
}
|
||||
|
||||
var instance_path = GetAdapterInstancePath((ulong)desc.AdapterLuid.Value);
|
||||
|
||||
if (instance_path != null && IsIndirectDisplayAdapter(instance_path))
|
||||
{
|
||||
// skip virtual adapters (streaming/RDP)
|
||||
continue;
|
||||
}
|
||||
|
||||
options.Add(new SpecificGpuOption(index, desc, instance_path ?? string.Empty));
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
return _unavailableOptions;
|
||||
}
|
||||
|
||||
// show index if multiple adapters with same name installed
|
||||
var counter = new Dictionary<string, int>();
|
||||
foreach (var option in options.OfType<SpecificGpuOption>())
|
||||
{
|
||||
counter[option.Description] = counter.GetValueOrDefault(option.Description, 0) + 1;
|
||||
}
|
||||
|
||||
foreach (var option in options.OfType<SpecificGpuOption>())
|
||||
{
|
||||
if (counter.GetValueOrDefault(option.Description, 0) > 1)
|
||||
{
|
||||
option.ShowIndex = true;
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
private static bool CheckD3D12Support(IDXGIAdapter1 adapter)
|
||||
{
|
||||
// using the same feature level as onnxruntime does
|
||||
var hr = D3D12Functions.D3D12CheckDeviceCreate<ID3D12Device>(adapter, D3D_FEATURE_LEVEL.D3D_FEATURE_LEVEL_11_0);
|
||||
|
||||
return hr == HRESULTS.S_FALSE;
|
||||
}
|
||||
|
||||
private static string? GetAdapterInstancePath(ulong luid)
|
||||
{
|
||||
try
|
||||
{
|
||||
var adpname = Vanara.PInvoke.User32.DisplayConfigGetDeviceInfo<Vanara.PInvoke.Gdi32.DISPLAYCONFIG_ADAPTER_NAME>(luid, 0, Vanara.PInvoke.Gdi32.DISPLAYCONFIG_DEVICE_INFO_TYPE.DISPLAYCONFIG_DEVICE_INFO_GET_ADAPTER_NAME);
|
||||
|
||||
var interface_path = adpname.adapterDevicePath;
|
||||
|
||||
var interface_guid_pos = interface_path.LastIndexOf('#');
|
||||
if (interface_guid_pos == -1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return interface_path[4..interface_guid_pos].Replace('#', '\\');
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsIndirectDisplayAdapter(string instance_path)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var regkey = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Enum\\" + instance_path, false);
|
||||
|
||||
if (regkey == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var upperfilters = regkey.GetValue("UpperFilters");
|
||||
|
||||
if (upperfilters == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (upperfilters is string[] sa)
|
||||
{
|
||||
return sa.Any(s => s.Equals("IndirectKmd", StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static GpuOption GetCurrent()
|
||||
{
|
||||
bool.TryParse(ConfigurationHelper.GetValue(ConfigurationKeys.PerformanceUseGpu, "false"), out var useGpu);
|
||||
var preferredGpuInstancePath = ConfigurationHelper.GetValue(ConfigurationKeys.PerformancePreferredGpuInstancePath, string.Empty);
|
||||
var preferredGpuDescription = ConfigurationHelper.GetValue(ConfigurationKeys.PerformancePreferredGpuDescription, string.Empty);
|
||||
|
||||
GpuOption result;
|
||||
if (useGpu)
|
||||
{
|
||||
var options = GetGpuOptions();
|
||||
if (ReferenceEquals(options, _unavailableOptions))
|
||||
{
|
||||
result = Disable;
|
||||
}
|
||||
|
||||
result = SystemDefault;
|
||||
if (preferredGpuInstancePath != string.Empty)
|
||||
{
|
||||
result = options.OfType<SpecificGpuOption>().FirstOrDefault(x => string.Equals(((SpecificGpuOption)x).InstancePath, preferredGpuInstancePath, StringComparison.Ordinal), SystemDefault);
|
||||
}
|
||||
|
||||
if (result == SystemDefault && preferredGpuDescription != string.Empty)
|
||||
{
|
||||
// instance path lookup failed, fallback to description (name) lookup
|
||||
result = options.OfType<SpecificGpuOption>().FirstOrDefault(x => string.Equals(((SpecificGpuOption)x).Description, preferredGpuDescription, StringComparison.OrdinalIgnoreCase), SystemDefault);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = Disable;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void SetCurrent(GpuOption option)
|
||||
{
|
||||
switch (option)
|
||||
{
|
||||
case DisableOption _:
|
||||
ConfigurationHelper.SetValue(ConfigurationKeys.PerformanceUseGpu, "false");
|
||||
break;
|
||||
case SystemDefaultOption _:
|
||||
ConfigurationHelper.SetValue(ConfigurationKeys.PerformanceUseGpu, "true");
|
||||
ConfigurationHelper.SetValue(ConfigurationKeys.PerformancePreferredGpuDescription, string.Empty);
|
||||
ConfigurationHelper.SetValue(ConfigurationKeys.PerformancePreferredGpuInstancePath, string.Empty);
|
||||
break;
|
||||
case SpecificGpuOption x:
|
||||
ConfigurationHelper.SetValue(ConfigurationKeys.PerformanceUseGpu, "true");
|
||||
ConfigurationHelper.SetValue(ConfigurationKeys.PerformancePreferredGpuDescription, x.Description);
|
||||
ConfigurationHelper.SetValue(ConfigurationKeys.PerformancePreferredGpuInstancePath, x.InstancePath);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public class DisableOption : GpuOption
|
||||
{
|
||||
public static DisableOption Instance { get; } = new DisableOption();
|
||||
|
||||
private DisableOption() { }
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return obj is DisableOption;
|
||||
}
|
||||
|
||||
public override int GetHashCode() => typeof(DisableOption).GetHashCode();
|
||||
|
||||
public override string ToString() => LocalizationHelper.GetString("GpuOptionDisable");
|
||||
}
|
||||
|
||||
public abstract class EnableOption : GpuOption
|
||||
{
|
||||
public abstract uint Index { get; }
|
||||
}
|
||||
|
||||
public class SystemDefaultOption : EnableOption
|
||||
{
|
||||
public static SystemDefaultOption Instance { get; } = new SystemDefaultOption();
|
||||
|
||||
private SystemDefaultOption() { }
|
||||
|
||||
public override uint Index => 0;
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return obj is SystemDefaultOption;
|
||||
}
|
||||
|
||||
public override int GetHashCode() => typeof(SystemDefaultOption).GetHashCode();
|
||||
|
||||
public override string ToString() => LocalizationHelper.GetString("GpuOptionSystemDefault");
|
||||
}
|
||||
|
||||
public class SpecificGpuOption : EnableOption
|
||||
{
|
||||
private DXGI_ADAPTER_DESC1 _description;
|
||||
private uint _index;
|
||||
private string _instance_path;
|
||||
|
||||
public bool ShowIndex { get; set; }
|
||||
|
||||
public SpecificGpuOption(uint index, DXGI_ADAPTER_DESC1 description, string instance_path)
|
||||
{
|
||||
_index = index;
|
||||
_description = description;
|
||||
_instance_path = instance_path;
|
||||
}
|
||||
|
||||
public override uint Index => _index;
|
||||
|
||||
public string Description => _description.Description;
|
||||
|
||||
public string InstancePath => _instance_path;
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj is SpecificGpuOption x)
|
||||
{
|
||||
return x._description.AdapterLuid.Value == _description.AdapterLuid.Value;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override int GetHashCode() => (typeof(SpecificGpuOption), _description, _index, _instance_path).GetHashCode();
|
||||
|
||||
public override string ToString() => ShowIndex ? _description + $" (GPU {_index})" : _description.Description;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,6 +89,7 @@
|
||||
<!-- Nuget Packages -->
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CalcBinding" Version="2.5.2" />
|
||||
<PackageReference Include="DirectNCore" Version="1.16.1" />
|
||||
<PackageReference Include="FluentEmail.Liquid" Version="3.0.2" />
|
||||
<PackageReference Include="FluentEmail.MailKit" Version="3.0.2" />
|
||||
<PackageReference Include="Fody" Version="6.8.0">
|
||||
|
||||
@@ -259,6 +259,11 @@ namespace MaaWpfGui.Main
|
||||
/// </summary>
|
||||
public void Init()
|
||||
{
|
||||
if (GpuOption.GetCurrent() is GpuOption.EnableOption x)
|
||||
{
|
||||
AsstSetStaticOption(AsstStaticOptionKey.GpuOCR, x.Index.ToString());
|
||||
}
|
||||
|
||||
bool loaded = LoadResource();
|
||||
|
||||
_handle = MaaService.AsstCreateEx(_callback, AsstHandle.Zero);
|
||||
@@ -1597,6 +1602,11 @@ namespace MaaWpfGui.Main
|
||||
return AsstSetInstanceOption(_handle, (AsstInstanceOptionKey)key, value);
|
||||
}
|
||||
|
||||
public bool AsstSetStaticOption(AsstStaticOptionKey key, string value)
|
||||
{
|
||||
return MaaService.AsstSetStaticOption(key, value);
|
||||
}
|
||||
|
||||
private static readonly bool _forcedReloadResource = File.Exists("DEBUG") || File.Exists("DEBUG.txt");
|
||||
|
||||
/// <summary>
|
||||
@@ -2632,6 +2642,24 @@ namespace MaaWpfGui.Main
|
||||
SubTaskStopped,
|
||||
}
|
||||
|
||||
public enum AsstStaticOptionKey
|
||||
{
|
||||
/// <summary>
|
||||
/// 无效
|
||||
/// </summary>
|
||||
Invalid,
|
||||
|
||||
/// <summary>
|
||||
/// 用CPU进行OCR
|
||||
/// </summary>
|
||||
CpuOCR,
|
||||
|
||||
/// <summary>
|
||||
/// 用GPU进行OCR
|
||||
/// </summary>
|
||||
GpuOCR,
|
||||
}
|
||||
|
||||
public enum InstanceOptionKey
|
||||
{
|
||||
/* Deprecated */ // MinitouchEnabled = 1,
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<system:String x:Key="Settings">Settings</system:String>
|
||||
<system:String x:Key="GeneralSettings">General</system:String>
|
||||
<system:String x:Key="AdvancedSettings">Advanced</system:String>
|
||||
<system:String x:Key="PerformanceSettings">Performance</system:String>
|
||||
<system:String x:Key="GameSettings">Client</system:String>
|
||||
<system:String x:Key="BaseSettings">Base</system:String>
|
||||
<system:String x:Key="RoguelikeSettings">I.S.</system:String>
|
||||
@@ -47,6 +48,9 @@
|
||||
<system:String x:Key="ExternalNotificationDiscordUserId">User ID</system:String>
|
||||
<system:String x:Key="ExternalNotificationTelegramBotToken">Bot Token</system:String>
|
||||
<system:String x:Key="ExternalNotificationTelegramChatId">Chat ID</system:String>
|
||||
<system:String x:Key="UseGpuForInference">Use GPU for inference acceleration</system:String>
|
||||
<system:String x:Key="GpuOptionDisable">Don’t use</system:String>
|
||||
<system:String x:Key="GpuOptionSystemDefault">System default GPU</system:String>
|
||||
<!-- Settings Guide -->
|
||||
<system:String x:Key="TaskSettings">Task Settings</system:String>
|
||||
<system:String x:Key="SettingsGuide">Settings Guide</system:String>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<system:String x:Key="Settings">设置</system:String>
|
||||
<system:String x:Key="GeneralSettings">常规设置</system:String>
|
||||
<system:String x:Key="AdvancedSettings">高级设置</system:String>
|
||||
<system:String x:Key="PerformanceSettings">性能设置</system:String>
|
||||
<system:String x:Key="GameSettings">游戏设置</system:String>
|
||||
<system:String x:Key="BaseSettings">基建设置</system:String>
|
||||
<system:String x:Key="RoguelikeSettings">肉鸽设置</system:String>
|
||||
@@ -47,6 +48,10 @@
|
||||
<system:String x:Key="ExternalNotificationDiscordUserId">用户 ID</system:String>
|
||||
<system:String x:Key="ExternalNotificationTelegramBotToken">机器人 Token</system:String>
|
||||
<system:String x:Key="ExternalNotificationTelegramChatId">聊天 ID</system:String>
|
||||
<system:String x:Key="UseGpuForInference">使用 GPU 加速推理</system:String>
|
||||
<system:String x:Key="GpuOptionDisable">不使用</system:String>
|
||||
<system:String x:Key="GpuOptionSystemDefault">系统默认 GPU</system:String>
|
||||
|
||||
<!-- 设置指引 -->
|
||||
<system:String x:Key="TaskSettings">任务设置</system:String>
|
||||
<system:String x:Key="SettingsGuide">设置指引</system:String>
|
||||
|
||||
@@ -36,6 +36,9 @@ namespace MaaWpfGui.Services
|
||||
[DllImport("MaaCore.dll")]
|
||||
public static extern unsafe bool AsstSetInstanceOption(AsstHandle handle, AsstInstanceOptionKey key, byte* value);
|
||||
|
||||
[DllImport("MaaCore.dll")]
|
||||
public static extern unsafe bool AsstSetStaticOption(AsstStaticOptionKey key, [MarshalAs(UnmanagedType.LPUTF8Str)] string value);
|
||||
|
||||
[DllImport("MaaCore.dll")]
|
||||
public static extern unsafe bool AsstLoadResource(byte* dirname);
|
||||
|
||||
|
||||
@@ -565,10 +565,27 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
|
||||
#endregion External Notifications
|
||||
|
||||
#region Performance
|
||||
|
||||
public List<GpuOption> GpuOptions => GpuOption.GetGpuOptions();
|
||||
|
||||
public GpuOption ActiveGpuOption
|
||||
{
|
||||
get => GpuOption.GetCurrent();
|
||||
set
|
||||
{
|
||||
GpuOption.SetCurrent(value);
|
||||
AskRestartToApplySettings();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Performance
|
||||
|
||||
private List<string> _listTitle =
|
||||
[
|
||||
LocalizationHelper.GetString("SwitchConfiguration"),
|
||||
LocalizationHelper.GetString("ScheduleSettings"),
|
||||
LocalizationHelper.GetString("PerformanceSettings"),
|
||||
LocalizationHelper.GetString("GameSettings"),
|
||||
LocalizationHelper.GetString("ConnectionSettings"),
|
||||
LocalizationHelper.GetString("StartupSettings"),
|
||||
@@ -1237,15 +1254,7 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
Instances.TaskQueueViewModel.UpdateStageList(true);
|
||||
Instances.TaskQueueViewModel.UpdateDatePrompt();
|
||||
Instances.AsstProxy.LoadResource();
|
||||
var result = MessageBoxHelper.Show(
|
||||
LocalizationHelper.GetString("PromptRestartForSettingsChange"),
|
||||
LocalizationHelper.GetString("Tip"),
|
||||
MessageBoxButton.OKCancel,
|
||||
MessageBoxImage.Question);
|
||||
if (result == MessageBoxResult.OK)
|
||||
{
|
||||
Bootstrapper.ShutdownAndRestartWithoutArgs();
|
||||
}
|
||||
AskRestartToApplySettings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2555,7 +2564,6 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether to collect special access rewards.
|
||||
/// </summary>
|
||||
|
||||
public bool ReceiveSpecialAccess
|
||||
{
|
||||
get => _receiveReceiveSpecialAccess;
|
||||
@@ -3798,15 +3806,7 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
SetAndNotify(ref _touchMode, value);
|
||||
UpdateInstanceSettings();
|
||||
ConfigurationHelper.SetValue(ConfigurationKeys.TouchMode, value);
|
||||
var result = MessageBoxHelper.Show(
|
||||
LocalizationHelper.GetString("PromptRestartForSettingsChange"),
|
||||
LocalizationHelper.GetString("Tip"),
|
||||
MessageBoxButton.OKCancel,
|
||||
MessageBoxImage.Question);
|
||||
if (result == MessageBoxResult.OK)
|
||||
{
|
||||
Bootstrapper.ShutdownAndRestartWithoutArgs();
|
||||
}
|
||||
AskRestartToApplySettings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4173,15 +4173,7 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
SwitchDarkMode();
|
||||
|
||||
/*
|
||||
var result = MessageBoxHelper.Show(
|
||||
LocalizationHelper.GetString("PromptRestartForSettingsChange"),
|
||||
LocalizationHelper.GetString("Tip"),
|
||||
MessageBoxButton.OKCancel,
|
||||
MessageBoxImage.Question);
|
||||
if (result == MessageBoxResult.OK)
|
||||
{
|
||||
Bootstrapper.ShutdownAndRestartWithOutArgs();
|
||||
}
|
||||
AskToRestartToApplySettings();
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -4652,6 +4644,22 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
|
||||
#endregion SettingsGuide
|
||||
|
||||
/// <summary>
|
||||
/// 要求用户重启以应用设置
|
||||
/// </summary>
|
||||
private void AskRestartToApplySettings()
|
||||
{
|
||||
var result = MessageBoxHelper.Show(
|
||||
LocalizationHelper.GetString("PromptRestartForSettingsChange"),
|
||||
LocalizationHelper.GetString("Tip"),
|
||||
MessageBoxButton.OKCancel,
|
||||
MessageBoxImage.Question);
|
||||
if (result == MessageBoxResult.OK)
|
||||
{
|
||||
Bootstrapper.ShutdownAndRestartWithoutArgs();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Make comboBox searchable
|
||||
/// </summary>
|
||||
|
||||
@@ -52,36 +52,39 @@
|
||||
<userControl:TimerSettingsUserControl Margin="0,20" HorizontalAlignment="Center" />
|
||||
|
||||
<hc:Divider Content="{Binding ListTitle[2]}" />
|
||||
<userControl:PerformanceUserControl Margin="0,20" HorizontalAlignment="Center" />
|
||||
|
||||
<hc:Divider Content="{Binding ListTitle[3]}" />
|
||||
<userControl:GameClientUserControl
|
||||
Margin="0,20"
|
||||
HorizontalAlignment="Center"
|
||||
IsEnabled="{Binding Idle}" />
|
||||
|
||||
<hc:Divider Content="{Binding ListTitle[3]}" />
|
||||
<hc:Divider Content="{Binding ListTitle[4]}" />
|
||||
<userControl:ConnectSettingsUserControl
|
||||
Margin="0,20"
|
||||
HorizontalAlignment="Center"
|
||||
IsEnabled="{Binding Idle}" />
|
||||
|
||||
<hc:Divider Content="{Binding ListTitle[4]}" />
|
||||
<hc:Divider Content="{Binding ListTitle[5]}" />
|
||||
<userControl:StartSettingsUserControl Margin="0,20" HorizontalAlignment="Center" />
|
||||
|
||||
<hc:Divider Content="{Binding ListTitle[5]}" />
|
||||
<hc:Divider Content="{Binding ListTitle[6]}" />
|
||||
<userControl:RemoteControlUserControl Margin="0,20" HorizontalAlignment="Center" />
|
||||
|
||||
<hc:Divider Content="{Binding ListTitle[6]}" />
|
||||
<hc:Divider Content="{Binding ListTitle[7]}" />
|
||||
<userControl:GUISettingsUserControl Margin="0,20" HorizontalAlignment="Center" />
|
||||
|
||||
<hc:Divider Content="{Binding ListTitle[7]}" />
|
||||
<hc:Divider Content="{Binding ListTitle[8]}" />
|
||||
<userControl:ExternalNotificationSettingsUserControl Margin="0,20" HorizontalAlignment="Center" />
|
||||
|
||||
<hc:Divider Content="{Binding ListTitle[8]}" />
|
||||
<hc:Divider Content="{Binding ListTitle[9]}" />
|
||||
<userControl:HotKeySettingsUserControl Margin="0,20" HorizontalAlignment="Center" />
|
||||
|
||||
<hc:Divider Content="{Binding ListTitle[9]}" />
|
||||
<hc:Divider Content="{Binding ListTitle[10]}" />
|
||||
<userControl:VersionUpdateSettingsUserControl Margin="0,20" HorizontalAlignment="Center" />
|
||||
|
||||
<hc:Divider Content="{Binding ListTitle[10]}" />
|
||||
<hc:Divider Content="{Binding ListTitle[11]}" />
|
||||
<userControl:AboutUserControl Margin="0,20" HorizontalAlignment="Center" />
|
||||
<!--<Rectangle HorizontalAlignment="Stretch" Fill="{DynamicResource BorderBrush}" Height="1" />-->
|
||||
</StackPanel>
|
||||
|
||||
@@ -306,11 +306,5 @@
|
||||
IsChecked="{Binding BlockSleepWithScreenOn}"
|
||||
Visibility="{c:Binding BlockSleep}" />
|
||||
</StackPanel>
|
||||
<controls:TextBlock
|
||||
Grid.Row="11"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
HorizontalAlignment="Center"
|
||||
Text="{c:Binding ScreencapCost}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
56
src/MaaWpfGui/Views/UserControl/PerformanceUserControl.xaml
Normal file
56
src/MaaWpfGui/Views/UserControl/PerformanceUserControl.xaml
Normal file
@@ -0,0 +1,56 @@
|
||||
<UserControl
|
||||
x:Class="MaaWpfGui.Views.UserControl.PerformanceUserControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:c="clr-namespace:CalcBinding;assembly=CalcBinding"
|
||||
xmlns:constants="clr-namespace:MaaWpfGui.Constants"
|
||||
xmlns:controls="clr-namespace:MaaWpfGui.Styles.Controls"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:dd="urn:gong-wpf-dragdrop"
|
||||
xmlns:helper="clr-namespace:MaaWpfGui.Helper"
|
||||
xmlns:local="clr-namespace:MaaWpfGui"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:styles="clr-namespace:MaaWpfGui.Styles"
|
||||
xmlns:ui="clr-namespace:MaaWpfGui.ViewModels.UI"
|
||||
xmlns:viewModels="clr-namespace:MaaWpfGui.ViewModels"
|
||||
xmlns:vm="clr-namespace:MaaWpfGui"
|
||||
d:DataContext="{d:DesignInstance {x:Type ui:SettingsViewModel}}"
|
||||
d:DesignWidth="550"
|
||||
mc:Ignorable="d">
|
||||
<Grid
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<controls:TextBlock Margin="24, 0, 0, 0"
|
||||
Text="{DynamicResource UseGpuForInference}"/>
|
||||
<hc:ComboBox
|
||||
Width="240"
|
||||
Margin="10"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
ItemsSource="{Binding GpuOptions}"
|
||||
SelectedValue="{Binding ActiveGpuOption}"/>
|
||||
</StackPanel>
|
||||
<controls:TextBlock
|
||||
Grid.Row="1"
|
||||
Grid.ColumnSpan="2"
|
||||
HorizontalAlignment="Center"
|
||||
Text="{c:Binding ScreencapCost}"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,29 @@
|
||||
// <copyright file="GameClientUserControl.xaml.cs" company="MaaAssistantArknights">
|
||||
// MaaWpfGui - A part of the MaaCoreArknights project
|
||||
// Copyright (C) 2021 MistEO and Contributors
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License v3.0 only as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY
|
||||
// </copyright>
|
||||
|
||||
namespace MaaWpfGui.Views.UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// GameClientUserControl.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class PerformanceUserControl : System.Windows.Controls.UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PerformanceUserControl"/> class.
|
||||
/// </summary>
|
||||
public PerformanceUserControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ done
|
||||
|
||||
pushd build
|
||||
xcodebuild -create-xcframework -library libMaaCore.dylib -headers ../include -output MaaCore.xcframework
|
||||
xcodebuild -create-xcframework -library libMaaDerpLearning.dylib -output MaaDerpLearning.xcframework
|
||||
xcodebuild -create-xcframework -library libfastdeploy_ppocr.dylib -output fastdeploy_ppocr.xcframework
|
||||
xcodebuild -create-xcframework -library libonnxruntime.*.dylib -output ONNXRuntime.xcframework
|
||||
xcodebuild -create-xcframework -library libopencv*.dylib -output OpenCV.xcframework
|
||||
rm -rf *.dylib
|
||||
|
||||
Reference in New Issue
Block a user